chore(api): update @since tag to 2.0.0 (#395)

pull/397/head
Lucas Fernandes Nogueira 2 years ago committed by GitHub
parent 7e3034904c
commit 9bf98f68e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,7 +22,7 @@ declare global {
* const appVersion = await getVersion(); * const appVersion = await getVersion();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function getVersion(): Promise<string> { async function getVersion(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:app|version"); return window.__TAURI_INVOKE__("plugin:app|version");
@ -36,7 +36,7 @@ async function getVersion(): Promise<string> {
* const appName = await getName(); * const appName = await getName();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function getName(): Promise<string> { async function getName(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:app|name"); return window.__TAURI_INVOKE__("plugin:app|name");
@ -51,7 +51,7 @@ async function getName(): Promise<string> {
* const tauriVersion = await getTauriVersion(); * const tauriVersion = await getTauriVersion();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function getTauriVersion(): Promise<string> { async function getTauriVersion(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:app|tauri_version"); return window.__TAURI_INVOKE__("plugin:app|tauri_version");
@ -66,7 +66,7 @@ async function getTauriVersion(): Promise<string> {
* await show(); * await show();
* ``` * ```
* *
* @since 1.2.0 * @since 2.0.0
*/ */
async function show(): Promise<void> { async function show(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:app|show"); return window.__TAURI_INVOKE__("plugin:app|show");
@ -81,7 +81,7 @@ async function show(): Promise<void> {
* await hide(); * await hide();
* ``` * ```
* *
* @since 1.2.0 * @since 2.0.0
*/ */
async function hide(): Promise<void> { async function hide(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:app|hide"); return window.__TAURI_INVOKE__("plugin:app|hide");

@ -15,7 +15,7 @@ declare global {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface ArgMatch { interface ArgMatch {
/** /**
@ -31,7 +31,7 @@ interface ArgMatch {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface SubcommandMatch { interface SubcommandMatch {
name: string; name: string;
@ -39,7 +39,7 @@ interface SubcommandMatch {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface CliMatches { interface CliMatches {
args: Record<string, ArgMatch>; args: Record<string, ArgMatch>;
@ -65,7 +65,7 @@ interface CliMatches {
* } * }
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function getMatches(): Promise<CliMatches> { async function getMatches(): Promise<CliMatches> {
return await window.__TAURI_INVOKE__("plugin:cli|cli_matches"); 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. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0. * @since 2.0.0
*/ */
async function writeText( async function writeText(
text: string, text: string,
@ -56,7 +56,7 @@ async function writeText(
* import { readText } from '@tauri-apps/plugin-clipboard'; * import { readText } from '@tauri-apps/plugin-clipboard';
* const clipboardText = await readText(); * const clipboardText = await readText();
* ``` * ```
* @since 1.0.0. * @since 2.0.0
*/ */
async function readText(): Promise<string> { async function readText(): Promise<string> {
const kind: ClipResponse = await window.__TAURI_INVOKE__( const kind: ClipResponse = await window.__TAURI_INVOKE__(

@ -23,7 +23,7 @@ interface FileResponse {
/** /**
* Extension filters for the file dialog. * Extension filters for the file dialog.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface DialogFilter { interface DialogFilter {
/** Filter name. */ /** Filter name. */
@ -41,7 +41,7 @@ interface DialogFilter {
/** /**
* Options for the open dialog. * Options for the open dialog.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface OpenDialogOptions { interface OpenDialogOptions {
/** The title of the dialog window. */ /** The title of the dialog window. */
@ -64,7 +64,7 @@ interface OpenDialogOptions {
/** /**
* Options for the save dialog. * Options for the save dialog.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface SaveDialogOptions { interface SaveDialogOptions {
/** The title of the dialog window. */ /** The title of the dialog window. */
@ -80,7 +80,7 @@ interface SaveDialogOptions {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface MessageDialogOptions { interface MessageDialogOptions {
/** The title of the dialog. Defaults to the app name. */ /** 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) * @returns A promise resolving to the selected path(s)
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function open( async function open(
options: OpenDialogOptions = {} options: OpenDialogOptions = {}
@ -198,7 +198,7 @@ async function open(
* *
* @returns A promise resolving to the selected path. * @returns A promise resolving to the selected path.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function save(options: SaveDialogOptions = {}): Promise<string | null> { async function save(options: SaveDialogOptions = {}): Promise<string | null> {
if (typeof options === "object") { 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. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
* *
*/ */
async function message( async function message(
@ -252,7 +252,7 @@ async function message(
* *
* @returns A promise resolving to a boolean indicating whether `Yes` was clicked or not. * @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( async function ask(
message: string, message: string,
@ -282,7 +282,7 @@ async function ask(
* *
* @returns A promise resolving to a boolean indicating whether `Ok` was clicked or not. * @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( async function confirm(
message: string, message: string,

@ -161,7 +161,7 @@ interface BackendMetadata {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface FsOptions { interface FsOptions {
dir?: BaseDirectory; dir?: BaseDirectory;
@ -169,7 +169,7 @@ interface FsOptions {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface FsDirOptions { interface FsDirOptions {
dir?: BaseDirectory; dir?: BaseDirectory;
@ -179,7 +179,7 @@ interface FsDirOptions {
/** /**
* Options object used to write a UTF-8 string to a file. * Options object used to write a UTF-8 string to a file.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface FsTextFileOption { interface FsTextFileOption {
/** Path to the file to write. */ /** 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. * Options object used to write a binary data to a file.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface FsBinaryFileOption { interface FsBinaryFileOption {
/** Path to the file to write. */ /** Path to the file to write. */
@ -203,7 +203,7 @@ interface FsBinaryFileOption {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface FileEntry { interface FileEntry {
path: string; path: string;
@ -225,7 +225,7 @@ interface FileEntry {
* const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig }); * const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig });
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function readTextFile( async function readTextFile(
filePath: string, filePath: string,
@ -246,7 +246,7 @@ async function readTextFile(
* const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource }); * const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource });
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function readBinaryFile( async function readBinaryFile(
filePath: string, filePath: string,
@ -269,7 +269,7 @@ async function readBinaryFile(
* await writeTextFile('app.conf', 'file contents', { dir: BaseDirectory.AppConfig }); * await writeTextFile('app.conf', 'file contents', { dir: BaseDirectory.AppConfig });
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeTextFile( async function writeTextFile(
path: string, path: string,
@ -287,7 +287,7 @@ async function writeTextFile(
* ``` * ```
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeTextFile( async function writeTextFile(
file: FsTextFileOption, file: FsTextFileOption,
@ -299,7 +299,7 @@ async function writeTextFile(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeTextFile( async function writeTextFile(
path: string | FsTextFileOption, path: string | FsTextFileOption,
@ -347,7 +347,7 @@ async function writeTextFile(
* @param options Configuration object. * @param options Configuration object.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeBinaryFile( async function writeBinaryFile(
path: string, path: string,
@ -368,7 +368,7 @@ async function writeBinaryFile(
* @param options Configuration object. * @param options Configuration object.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeBinaryFile( async function writeBinaryFile(
file: FsBinaryFileOption, file: FsBinaryFileOption,
@ -380,7 +380,7 @@ async function writeBinaryFile(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function writeBinaryFile( async function writeBinaryFile(
path: string | FsBinaryFileOption, path: string | FsBinaryFileOption,
@ -439,7 +439,7 @@ async function writeBinaryFile(
* } * }
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function readDir( async function readDir(
dir: string, dir: string,
@ -464,7 +464,7 @@ async function readDir(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function createDir( async function createDir(
dir: string, dir: string,
@ -488,7 +488,7 @@ async function createDir(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function removeDir( async function removeDir(
dir: string, dir: string,
@ -511,7 +511,7 @@ async function removeDir(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function copyFile( async function copyFile(
source: string, source: string,
@ -536,7 +536,7 @@ async function copyFile(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function removeFile( async function removeFile(
file: string, file: string,
@ -559,7 +559,7 @@ async function removeFile(
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function renameFile( async function renameFile(
oldPath: string, oldPath: string,
@ -582,7 +582,7 @@ async function renameFile(
* await exists('avatar.png', { dir: BaseDirectory.AppData }); * await exists('avatar.png', { dir: BaseDirectory.AppData });
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function exists(path: string): Promise<boolean> { async function exists(path: string): Promise<boolean> {
return await window.__TAURI_INVOKE__("plugin:fs|exists", { path }); 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. * Returns the metadata for the given path.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function metadata(path: string): Promise<Metadata> { async function metadata(path: string): Promise<Metadata> {
return await window 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 shortcut Shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q
* @param handler Shortcut handler callback - takes the triggered shortcut as argument * @param handler Shortcut handler callback - takes the triggered shortcut as argument
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function register( async function register(
shortcut: string, 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 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 * @param handler Shortcut handler callback - takes the triggered shortcut as argument
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function registerAll( async function registerAll(
shortcuts: string[], shortcuts: string[],
@ -82,7 +82,7 @@ async function registerAll(
* *
* @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q * @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> { async function isRegistered(shortcut: string): Promise<boolean> {
return await window.__TAURI_INVOKE__("plugin:globalShortcut|is_registered", { 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 * @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> { async function unregister(shortcut: string): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister", { return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister", {
@ -116,7 +116,7 @@ async function unregister(shortcut: string): Promise<void> {
* await unregisterAll(); * await unregisterAll();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function unregisterAll(): Promise<void> { async function unregisterAll(): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister_all"); 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 { interface Duration {
secs: number; secs: number;
@ -39,7 +39,7 @@ interface Duration {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface ClientOptions { interface ClientOptions {
/** /**
@ -51,7 +51,7 @@ interface ClientOptions {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
enum ResponseType { enum ResponseType {
JSON = 1, JSON = 1,
@ -60,7 +60,7 @@ enum ResponseType {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface FilePart<T> { interface FilePart<T> {
file: string | 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. * The body object to be used on POST and PUT requests.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
class Body { class Body {
type: string; type: string;
@ -115,6 +115,8 @@ class Body {
* @param data The body data. * @param data The body data.
* *
* @returns The body object ready to be used on the POST and PUT requests. * @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 { static form(data: Record<string, Part> | FormData): Body {
const form: Record<string, string | number[] | FilePart<number[]>> = {}; const form: Record<string, string | number[] | FilePart<number[]>> = {};
@ -166,6 +168,8 @@ class Body {
* @param data The body JSON object. * @param data The body JSON object.
* *
* @returns The body object ready to be used on the POST and PUT requests. * @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 { static json<K extends string | number | symbol, V>(data: Record<K, V>): Body {
return new Body("Json", data); return new Body("Json", data);
@ -182,6 +186,8 @@ class Body {
* @param value The body string. * @param value The body string.
* *
* @returns The body object ready to be used on the POST and PUT requests. * @returns The body object ready to be used on the POST and PUT requests.
*
* @since 2.0.0
*/ */
static text(value: string): Body { static text(value: string): Body {
return new Body("Text", value); return new Body("Text", value);
@ -198,6 +204,8 @@ class Body {
* @param bytes The body byte array. * @param bytes The body byte array.
* *
* @returns The body object ready to be used on the POST and PUT requests. * @returns The body object ready to be used on the POST and PUT requests.
*
* @since 2.0.0
*/ */
static bytes( static bytes(
bytes: Iterable<number> | ArrayLike<number> | ArrayBuffer bytes: Iterable<number> | ArrayLike<number> | ArrayBuffer
@ -225,7 +233,7 @@ type HttpVerb =
/** /**
* Options object sent to the backend. * Options object sent to the backend.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface HttpOptions { interface HttpOptions {
method: HttpVerb; method: HttpVerb;
@ -254,7 +262,7 @@ interface IResponse<T> {
/** /**
* Response object. * Response object.
* *
* @since 1.0.0 * @since 2.0.0
* */ * */
class Response<T> { class Response<T> {
/** The request URL. */ /** The request URL. */
@ -282,7 +290,7 @@ class Response<T> {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
class Client { class Client {
id: number; id: number;
@ -481,7 +489,7 @@ class Client {
* *
* @returns A promise resolving to the client instance. * @returns A promise resolving to the client instance.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function getClient(options?: ClientOptions): Promise<Client> { async function getClient(options?: ClientOptions): Promise<Client> {
return window return window

@ -18,7 +18,7 @@ import {
/** /**
* Options to send a notification. * Options to send a notification.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface Options { interface Options {
/** /**
@ -300,7 +300,7 @@ type Permission = "granted" | "denied" | "default";
* const permissionGranted = await isPermissionGranted(); * const permissionGranted = await isPermissionGranted();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function isPermissionGranted(): Promise<boolean> { async function isPermissionGranted(): Promise<boolean> {
if (window.Notification.permission !== "default") { 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. * @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> { async function requestPermission(): Promise<Permission> {
return window.Notification.requestPermission(); 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 { function sendNotification(options: Options | string): void {
if (typeof options === "string") { if (typeof options === "string") {

@ -50,7 +50,7 @@ function isWindows(): boolean {
* - `\n` on POSIX * - `\n` on POSIX
* - `\r\n` on Windows * - `\r\n` on Windows
* *
* @since 1.0.0 * @since 2.0.0
* */ * */
const EOL = isWindows() ? "\r\n" : "\n"; const EOL = isWindows() ? "\r\n" : "\n";
@ -63,7 +63,7 @@ const EOL = isWindows() ? "\r\n" : "\n";
* const platformName = await platform(); * const platformName = await platform();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
* *
*/ */
async function platform(): Promise<Platform> { async function platform(): Promise<Platform> {
@ -78,7 +78,7 @@ async function platform(): Promise<Platform> {
* const osVersion = await version(); * const osVersion = await version();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function version(): Promise<string> { async function version(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:os|version"); return window.__TAURI_INVOKE__("plugin:os|version");
@ -92,7 +92,7 @@ async function version(): Promise<string> {
* const osType = await type(); * const osType = await type();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function type(): Promise<OsType> { async function type(): Promise<OsType> {
return window.__TAURI_INVOKE__("plugin:os|kind"); return window.__TAURI_INVOKE__("plugin:os|kind");
@ -107,7 +107,7 @@ async function type(): Promise<OsType> {
* const archName = await arch(); * const archName = await arch();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function arch(): Promise<Arch> { async function arch(): Promise<Arch> {
return window.__TAURI_INVOKE__("plugin:os|arch"); return window.__TAURI_INVOKE__("plugin:os|arch");
@ -121,7 +121,7 @@ async function arch(): Promise<Arch> {
* const tempdirPath = await tempdir(); * const tempdirPath = await tempdir();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function tempdir(): Promise<string> { async function tempdir(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:os|tempdir"); return window.__TAURI_INVOKE__("plugin:os|tempdir");

@ -24,7 +24,7 @@ declare global {
* @param code The exit code to use. * @param code The exit code to use.
* @returns A promise indicating the success or failure of the operation. * @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> { async function exit(code = 0): Promise<void> {
return window.__TAURI_INVOKE__("plugin:process|exit", { code }); 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. * @returns A promise indicating the success or failure of the operation.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function relaunch(): Promise<void> { async function relaunch(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:process|restart"); return window.__TAURI_INVOKE__("plugin:process|restart");

@ -72,7 +72,7 @@ declare global {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface SpawnOptions { interface SpawnOptions {
/** Current working directory. */ /** Current working directory. */
@ -82,7 +82,7 @@ interface SpawnOptions {
/** /**
* Character encoding for stdout/stderr * Character encoding for stdout/stderr
* *
* @since 1.1.0 * @since 2.0.0
* */ * */
encoding?: string; encoding?: string;
} }
@ -93,7 +93,7 @@ interface InternalSpawnOptions extends SpawnOptions {
} }
/** /**
* @since 1.0.0 * @since 2.0.0
*/ */
interface ChildProcess<O extends IOPayload> { interface ChildProcess<O extends IOPayload> {
/** Exit code of the process. `null` if the process was terminated by a signal on Unix. */ /** 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 args Program arguments.
* @param options Configuration for the process spawn. * @param options Configuration for the process spawn.
* @returns A promise resolving to the process id. * @returns A promise resolving to the process id.
*
* @since 2.0.0
*/ */
async function execute<O extends IOPayload>( async function execute<O extends IOPayload>(
onEvent: (event: CommandEvent<O>) => void, 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any
class EventEmitter<E extends Record<string, 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)`. * Alias for `emitter.on(eventName, listener)`.
* *
* @since 1.1.0 * @since 2.0.0
*/ */
addListener<N extends keyof E>( addListener<N extends keyof E>(
eventName: N, eventName: N,
@ -159,7 +161,7 @@ class EventEmitter<E extends Record<string, any>> {
/** /**
* Alias for `emitter.off(eventName, listener)`. * Alias for `emitter.off(eventName, listener)`.
* *
* @since 1.1.0 * @since 2.0.0
*/ */
removeListener<N extends keyof E>( removeListener<N extends keyof E>(
eventName: N, 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. * 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>( on<N extends keyof E>(
eventName: N, 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. * 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>( once<N extends keyof E>(
eventName: N, 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 * 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. * 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>( off<N extends keyof E>(
eventName: N, 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. * 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 { removeAllListeners<N extends keyof E>(event?: N): this {
if (event) { if (event) {
@ -255,6 +257,8 @@ class EventEmitter<E extends Record<string, any>> {
* to each. * to each.
* *
* @returns `true` if the event had listeners, `false` otherwise. * @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 { emit<N extends keyof E>(eventName: N, arg: E[typeof eventName]): boolean {
if (eventName in this.eventListeners) { 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`. * 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 { listenerCount<N extends keyof E>(eventName: N): number {
if (eventName in this.eventListeners) 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. * 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>( prependListener<N extends keyof E>(
eventName: N, 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. * 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>( prependOnceListener<N extends keyof E>(
eventName: N, eventName: N,
@ -326,7 +330,7 @@ class EventEmitter<E extends Record<string, any>> {
} }
/** /**
* @since 1.1.0 * @since 2.0.0
*/ */
class Child { class Child {
/** The child process `pid`. */ /** The child process `pid`. */
@ -350,6 +354,8 @@ class Child {
* ``` * ```
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async write(data: IOPayload): Promise<void> { async write(data: IOPayload): Promise<void> {
return window.__TAURI_INVOKE__("plugin:shell|stdin_write", { return window.__TAURI_INVOKE__("plugin:shell|stdin_write", {
@ -363,6 +369,8 @@ class Child {
* Kills the child process. * Kills the child process.
* *
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async kill(): Promise<void> { async kill(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:shell|kill", { return window.__TAURI_INVOKE__("plugin:shell|kill", {
@ -399,7 +407,7 @@ interface OutputEvents<O extends IOPayload> {
* console.log('pid:', child.pid); * console.log('pid:', child.pid);
* ``` * ```
* *
* @since 1.1.0 * @since 2.0.0
* *
*/ */
class Command<O extends IOPayload> extends EventEmitter<CommandEvents> { 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. * Executes the command as a child process, returning a handle to it.
* *
* @returns A promise resolving to the child process handle. * @returns A promise resolving to the child process handle.
*
* @since 2.0.0
*/ */
async spawn(): Promise<Child> { async spawn(): Promise<Child> {
return execute<O>( return execute<O>(
@ -542,6 +552,8 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
* ``` * ```
* *
* @returns A promise resolving to the child process output. * @returns A promise resolving to the child process output.
*
* @since 2.0.0
*/ */
async execute(): Promise<ChildProcess<O>> { async execute(): Promise<ChildProcess<O>> {
return new Promise((resolve, reject) => { 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. * @param openWith The app to open the file or URL with.
* Defaults to the system default application for the specified path type. * 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> { async function open(path: string, openWith?: string): Promise<void> {
return window.__TAURI_INVOKE__("plugin:shell|open", { return window.__TAURI_INVOKE__("plugin:shell|open", {

@ -179,6 +179,8 @@ export class Store {
* @param key * @param key
* @param cb * @param cb
* @returns A promise resolving to a function to unlisten to the event. * @returns A promise resolving to a function to unlisten to the event.
*
* @since 2.0.0
*/ */
async onKeyChange<T>( async onKeyChange<T>(
key: string, key: string,
@ -195,6 +197,8 @@ export class Store {
* Listen to changes on the store. * Listen to changes on the store.
* @param cb * @param cb
* @returns A promise resolving to a function to unlisten to the event. * @returns A promise resolving to a function to unlisten to the event.
*
* @since 2.0.0
*/ */
async onChange<T>( async onChange<T>(
cb: (key: string, value: T | null) => void cb: (key: string, value: T | null) => void

@ -239,6 +239,8 @@ class ProcedureExecutor {
* Gets the Ed25519 public key of a SLIP10 private key. * 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`. * @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. * @returns A promise resolving to the public key hex string.
*
* @since 2.0.0
*/ */
async getEd25519PublicKey(privateKeyLocation: Location): Promise<Uint8Array> { async getEd25519PublicKey(privateKeyLocation: Location): Promise<Uint8Array> {
return await window 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 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. * @param msg The message to sign.
* @returns A promise resolving to the signature hex string. * @returns A promise resolving to the signature hex string.
*
* @since 2.0.0
*/ */
async signEd25519( async signEd25519(
privateKeyLocation: Location, privateKeyLocation: Location,

@ -38,7 +38,7 @@ type TitleBarStyle = "visible" | "transparent" | "overlay";
/** /**
* Allows you to retrieve information about a given monitor. * Allows you to retrieve information about a given monitor.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface Monitor { interface Monitor {
/** Human-readable name of the monitor */ /** Human-readable name of the monitor */
@ -54,7 +54,7 @@ interface Monitor {
/** /**
* The payload for the `scaleChange` event. * The payload for the `scaleChange` event.
* *
* @since 1.0.2 * @since 2.0.0
*/ */
interface ScaleFactorChanged { interface ScaleFactorChanged {
/** The new window scale factor. */ /** The new window scale factor. */
@ -72,7 +72,7 @@ type FileDropEvent =
/** /**
* A size represented in logical pixels. * A size represented in logical pixels.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
class LogicalSize { class LogicalSize {
type = "Logical"; type = "Logical";
@ -88,7 +88,7 @@ class LogicalSize {
/** /**
* A size represented in physical pixels. * A size represented in physical pixels.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
class PhysicalSize { class PhysicalSize {
type = "Physical"; type = "Physical";
@ -118,7 +118,7 @@ class PhysicalSize {
/** /**
* A position represented in logical pixels. * A position represented in logical pixels.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
class LogicalPosition { class LogicalPosition {
type = "Logical"; type = "Logical";
@ -134,7 +134,7 @@ class LogicalPosition {
/** /**
* A position represented in physical pixels. * A position represented in physical pixels.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
class PhysicalPosition { class PhysicalPosition {
type = "Physical"; type = "Physical";
@ -179,7 +179,7 @@ declare global {
/** /**
* Attention type to request on a window. * Attention type to request on a window.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
enum UserAttentionType { enum UserAttentionType {
/** /**
@ -240,7 +240,7 @@ export type CursorIcon =
/** /**
* Get an instance of `WebviewWindow` for the current webview window. * Get an instance of `WebviewWindow` for the current webview window.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
function getCurrent(): WebviewWindow { function getCurrent(): WebviewWindow {
return new WebviewWindow(window.__TAURI_METADATA__.__currentWindow.label, { 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. * Gets a list of instances of `WebviewWindow` for all available webview windows.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
function getAll(): WebviewWindow[] { function getAll(): WebviewWindow[] {
return window.__TAURI_METADATA__.__windows.map( 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. * A webview window handle allows emitting and listening to events from the backend that are tied to the window.
* *
* @ignore * @ignore
* @since 1.0.0 * @since 2.0.0
*/ */
class WebviewWindowHandle { class WebviewWindowHandle {
/** The window label. It is a unique identifier for the window, can be used to reference it later. */ /** 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. * @param handler Event handler.
* @returns A promise resolving to a function to unlisten to the event. * @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. * 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>( async listen<T>(
event: EventName, event: EventName,
@ -339,6 +341,8 @@ class WebviewWindowHandle {
* @param handler Event handler. * @param handler Event handler.
* @returns A promise resolving to a function to unlisten to the event. * @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. * 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> { async once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn> {
if (this._handleTauriEvent(event, handler)) { if (this._handleTauriEvent(event, handler)) {
@ -393,7 +397,7 @@ class WebviewWindowHandle {
* Manage the current window object. * Manage the current window object.
* *
* @ignore * @ignore
* @since 1.0.0 * @since 2.0.0
*/ */
class WindowManager extends WebviewWindowHandle { class WindowManager extends WebviewWindowHandle {
// Getters // Getters
@ -406,6 +410,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window's monitor scale factor. * @returns The window's monitor scale factor.
*
* @since 2.0.0
* */ * */
async scaleFactor(): Promise<number> { async scaleFactor(): Promise<number> {
return window.__TAURI_INVOKE__("plugin:window|scale_factor", { return window.__TAURI_INVOKE__("plugin:window|scale_factor", {
@ -422,6 +428,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window's inner position. * @returns The window's inner position.
*
* @since 2.0.0
* */ * */
async innerPosition(): Promise<PhysicalPosition> { async innerPosition(): Promise<PhysicalPosition> {
return window return window
@ -443,6 +451,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window's outer position. * @returns The window's outer position.
*
* @since 2.0.0
* */ * */
async outerPosition(): Promise<PhysicalPosition> { async outerPosition(): Promise<PhysicalPosition> {
return window return window
@ -465,6 +475,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window's inner size. * @returns The window's inner size.
*
* @since 2.0.0
*/ */
async innerSize(): Promise<PhysicalSize> { async innerSize(): Promise<PhysicalSize> {
return window return window
@ -487,6 +499,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window's outer size. * @returns The window's outer size.
*
* @since 2.0.0
*/ */
async outerSize(): Promise<PhysicalSize> { async outerSize(): Promise<PhysicalSize> {
return window return window
@ -508,6 +522,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns Whether the window is in fullscreen mode or not. * @returns Whether the window is in fullscreen mode or not.
*
* @since 2.0.0
* */ * */
async isFullscreen(): Promise<boolean> { async isFullscreen(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_fullscreen", { return window.__TAURI_INVOKE__("plugin:window|is_fullscreen", {
@ -523,7 +539,7 @@ class WindowManager extends WebviewWindowHandle {
* const minimized = await appWindow.isMinimized(); * const minimized = await appWindow.isMinimized();
* ``` * ```
* *
* @since 1.3.0 * @since 2.0.0
* */ * */
async isMinimized(): Promise<boolean> { async isMinimized(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_minimized", { return window.__TAURI_INVOKE__("plugin:window|is_minimized", {
@ -540,6 +556,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns Whether the window is maximized or not. * @returns Whether the window is maximized or not.
*
* @since 2.0.0
* */ * */
async isMaximized(): Promise<boolean> { async isMaximized(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_maximized", { return window.__TAURI_INVOKE__("plugin:window|is_maximized", {
@ -556,6 +574,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns Whether the window is decorated or not. * @returns Whether the window is decorated or not.
*
* @since 2.0.0
* */ * */
async isDecorated(): Promise<boolean> { async isDecorated(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_decorated", { return window.__TAURI_INVOKE__("plugin:window|is_decorated", {
@ -572,6 +592,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns Whether the window is resizable or not. * @returns Whether the window is resizable or not.
*
* @since 2.0.0
* */ * */
async isResizable(): Promise<boolean> { async isResizable(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_resizable", { return window.__TAURI_INVOKE__("plugin:window|is_resizable", {
@ -588,6 +610,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns Whether the window is visible or not. * @returns Whether the window is visible or not.
*
* @since 2.0.0
* */ * */
async isVisible(): Promise<boolean> { async isVisible(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_visible", { return window.__TAURI_INVOKE__("plugin:window|is_visible", {
@ -603,7 +627,7 @@ class WindowManager extends WebviewWindowHandle {
* const title = await appWindow.title(); * const title = await appWindow.title();
* ``` * ```
* *
* @since 1.3.0 * @since 2.0.0
* */ * */
async title(): Promise<string> { async title(): Promise<string> {
return window.__TAURI_INVOKE__("plugin:window|title", { return window.__TAURI_INVOKE__("plugin:window|title", {
@ -625,6 +649,8 @@ class WindowManager extends WebviewWindowHandle {
* ``` * ```
* *
* @returns The window theme. * @returns The window theme.
*
* @since 2.0.0
* */ * */
async theme(): Promise<Theme | null> { async theme(): Promise<Theme | null> {
return window.__TAURI_INVOKE__("plugin:window|theme", { return window.__TAURI_INVOKE__("plugin:window|theme", {
@ -644,6 +670,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param resizable * @param resizable
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async center(): Promise<void> { async center(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|center", { return window.__TAURI_INVOKE__("plugin:window|center", {
@ -671,6 +699,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param resizable * @param resizable
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async requestUserAttention( async requestUserAttention(
requestType: UserAttentionType | null requestType: UserAttentionType | null
@ -700,6 +730,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param resizable * @param resizable
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setResizable(resizable: boolean): Promise<void> { async setResizable(resizable: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_resizable", { return window.__TAURI_INVOKE__("plugin:window|set_resizable", {
@ -718,6 +750,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param title The new title * @param title The new title
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setTitle(title: string): Promise<void> { async setTitle(title: string): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_title", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async maximize(): Promise<void> { async maximize(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|maximize", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async unmaximize(): Promise<void> { async unmaximize(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|unmaximize", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async toggleMaximize(): Promise<void> { async toggleMaximize(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|toggle_maximize", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async minimize(): Promise<void> { async minimize(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|minimize", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async unminimize(): Promise<void> { async unminimize(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|unminimize", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async show(): Promise<void> { async show(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|show", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async hide(): Promise<void> { async hide(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|hide", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async close(): Promise<void> { async close(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|close", { 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. * @param decorations Whether the window should have borders and bars.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setDecorations(decorations: boolean): Promise<void> { async setDecorations(decorations: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_decorations", { 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. * @returns A promise indicating the success or failure of the operation.
* *
* @since 2.0 * @since 2.0.0
*/ */
async setShadow(enable: boolean): Promise<void> { async setShadow(enable: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_shadow", { 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. * @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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> { async setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_always_on_top", { 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. * @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> { async setContentProtected(protected_: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_content_protected", { 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. * @param size The logical or physical inner size.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setSize(size: LogicalSize | PhysicalSize): Promise<void> { async setSize(size: LogicalSize | PhysicalSize): Promise<void> {
if (!size || (size.type !== "Logical" && size.type !== "Physical")) { 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. * @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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setMinSize( async setMinSize(
size: LogicalSize | PhysicalSize | null | undefined 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. * @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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setMaxSize( async setMaxSize(
size: LogicalSize | PhysicalSize | null | undefined size: LogicalSize | PhysicalSize | null | undefined
@ -1045,6 +1105,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param position The new position, in logical or physical pixels. * @param position The new position, in logical or physical pixels.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setPosition( async setPosition(
position: LogicalPosition | PhysicalPosition position: LogicalPosition | PhysicalPosition
@ -1080,6 +1142,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param fullscreen Whether the window should go to fullscreen or not. * @param fullscreen Whether the window should go to fullscreen or not.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setFullscreen(fullscreen: boolean): Promise<void> { async setFullscreen(fullscreen: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_fullscreen", { 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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setFocus(): Promise<void> { async setFocus(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_focus", { 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. * @param icon Icon bytes or path to the icon file.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setIcon(icon: string | Uint8Array): Promise<void> { async setIcon(icon: string | Uint8Array): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_icon", { 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. * @param skip true to hide window icon, false to show it.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setSkipTaskbar(skip: boolean): Promise<void> { async setSkipTaskbar(skip: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_skip_taskbar", { 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. * @param grab `true` to grab the cursor icon, `false` to release it.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setCursorGrab(grab: boolean): Promise<void> { async setCursorGrab(grab: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_cursor_grab", { 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. * @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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setCursorVisible(visible: boolean): Promise<void> { async setCursorVisible(visible: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_cursor_visible", { return window.__TAURI_INVOKE__("plugin:window|set_cursor_visible", {
@ -1211,6 +1285,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param icon The new cursor icon. * @param icon The new cursor icon.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setCursorIcon(icon: CursorIcon): Promise<void> { async setCursorIcon(icon: CursorIcon): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_cursor_icon", { return window.__TAURI_INVOKE__("plugin:window|set_cursor_icon", {
@ -1229,6 +1305,8 @@ class WindowManager extends WebviewWindowHandle {
* *
* @param position The new cursor position. * @param position The new cursor position.
* @returns A promise indicating the success or failure of the operation. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setCursorPosition( async setCursorPosition(
position: LogicalPosition | PhysicalPosition 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. * @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. * @returns A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async setIgnoreCursorEvents(ignore: boolean): Promise<void> { async setIgnoreCursorEvents(ignore: boolean): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|set_ignore_cursor_events", { 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. * @return A promise indicating the success or failure of the operation.
*
* @since 2.0.0
*/ */
async startDragging(): Promise<void> { async startDragging(): Promise<void> {
return window.__TAURI_INVOKE__("plugin:window|start_dragging", { 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. * @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. * 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> { async onResized(handler: EventCallback<PhysicalSize>): Promise<UnlistenFn> {
return this.listen<PhysicalSize>(TauriEvent.WINDOW_RESIZED, (e) => { 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. * @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. * 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> { async onMoved(handler: EventCallback<PhysicalPosition>): Promise<UnlistenFn> {
return this.listen<PhysicalPosition>(TauriEvent.WINDOW_MOVED, (e) => { 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. * @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. * 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 */ /* eslint-disable @typescript-eslint/promise-function-async */
async onCloseRequested( async onCloseRequested(
@ -1399,7 +1481,7 @@ class WindowManager extends WebviewWindowHandle {
* @returns A promise resolving to a function to unlisten to the event. * @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. * 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> { async onFocusChanged(handler: EventCallback<boolean>): Promise<UnlistenFn> {
const unlistenFocus = await this.listen<PhysicalPosition>( 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. * @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. * 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( async onScaleChanged(
handler: EventCallback<ScaleFactorChanged> handler: EventCallback<ScaleFactorChanged>
@ -1469,7 +1551,7 @@ class WindowManager extends WebviewWindowHandle {
* @returns A promise resolving to a function to unlisten to the event. * @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. * 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> { async onMenuClicked(handler: EventCallback<string>): Promise<UnlistenFn> {
return this.listen<string>(TauriEvent.MENU, handler); 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. * @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. * 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( async onFileDropEvent(
handler: EventCallback<FileDropEvent> handler: EventCallback<FileDropEvent>
@ -1550,7 +1632,7 @@ class WindowManager extends WebviewWindowHandle {
* @returns A promise resolving to a function to unlisten to the event. * @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. * 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> { async onThemeChanged(handler: EventCallback<Theme>): Promise<UnlistenFn> {
return this.listen<Theme>(TauriEvent.WINDOW_THEME_CHANGED, handler); 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 { class CloseRequestedEvent {
/** Event name */ /** Event name */
@ -1615,7 +1697,7 @@ class CloseRequestedEvent {
* unlisten(); * unlisten();
* ``` * ```
* *
* @since 1.0.2 * @since 2.0.0
*/ */
class WebviewWindow extends WindowManager { 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-/:_`. * * @param label The unique webview window label. Must be alphanumeric: `a-zA-Z-/:_`.
* @returns The WebviewWindow instance to communicate with the webview. * @returns The WebviewWindow instance to communicate with the webview.
*
* @since 2.0.0
*/ */
constructor(label: WindowLabel, options: WindowOptions = {}) { constructor(label: WindowLabel, options: WindowOptions = {}) {
super(label); super(label);
@ -1663,6 +1747,8 @@ class WebviewWindow extends WindowManager {
* *
* @param label The webview window label. * @param label The webview window label.
* @returns The WebviewWindow instance to communicate with the webview or null if the webview doesn't exist. * @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 { static getByLabel(label: string): WebviewWindow | null {
if (getAll().some((w) => w.label === label)) { if (getAll().some((w) => w.label === label)) {
@ -1696,7 +1782,7 @@ if ("__TAURI_METADATA__" in window) {
/** /**
* Configuration for the window to create. * Configuration for the window to create.
* *
* @since 1.0.0 * @since 2.0.0
*/ */
interface WindowOptions { interface WindowOptions {
/** /**
@ -1762,7 +1848,7 @@ interface WindowOptions {
* and on Windows 11, it will have a rounded corners. * and on Windows 11, it will have a rounded corners.
* - **Linux:** Unsupported. * - **Linux:** Unsupported.
* *
* @since 2.0 * @since 2.0.0
*/ */
shadow?: boolean; shadow?: boolean;
/** /**
@ -1830,7 +1916,7 @@ function mapPhysicalSize(m: PhysicalSize): PhysicalSize {
* const monitor = currentMonitor(); * const monitor = currentMonitor();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function currentMonitor(): Promise<Monitor | null> { async function currentMonitor(): Promise<Monitor | null> {
return window return window
@ -1847,7 +1933,7 @@ async function currentMonitor(): Promise<Monitor | null> {
* const monitor = primaryMonitor(); * const monitor = primaryMonitor();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function primaryMonitor(): Promise<Monitor | null> { async function primaryMonitor(): Promise<Monitor | null> {
return window return window
@ -1863,7 +1949,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
* const monitors = availableMonitors(); * const monitors = availableMonitors();
* ``` * ```
* *
* @since 1.0.0 * @since 2.0.0
*/ */
async function availableMonitors(): Promise<Monitor[]> { async function availableMonitors(): Promise<Monitor[]> {
return window return window

Loading…
Cancel
Save