mirror of
https://github.com/storytold/placeholder-artcraft.git
synced 2026-10-22 08:04:59 +00:00
0daf83dba9
Need to remove secrets before entire repo can be made public.
1875 lines
55 KiB
JavaScript
1875 lines
55 KiB
JavaScript
import { S as a, R as S, i } from "./index-qcv8R9fr.js";
|
||
import { listen as C, once as L, emit as P, emitTo as O, TauriEvent as o } from "./event-BZ9JYSRZ.js";
|
||
class x {
|
||
constructor(...e) {
|
||
this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.width = e[0].Logical.width, this.height = e[0].Logical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
|
||
}
|
||
/**
|
||
* Converts the logical size to a physical one.
|
||
* @example
|
||
* ```typescript
|
||
* import { LogicalSize } from '@tauri-apps/api/dpi';
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
*
|
||
* const appWindow = getCurrentWindow();
|
||
* const factor = await appWindow.scaleFactor();
|
||
* const size = new LogicalSize(400, 500);
|
||
* const physical = size.toPhysical(factor);
|
||
* ```
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
toPhysical(e) {
|
||
return new c(this.width * e, this.height * e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
width: this.width,
|
||
height: this.height
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class c {
|
||
constructor(...e) {
|
||
this.type = "Physical", e.length === 1 ? "Physical" in e[0] ? (this.width = e[0].Physical.width, this.height = e[0].Physical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
|
||
}
|
||
/**
|
||
* Converts the physical size to a logical one.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const appWindow = getCurrentWindow();
|
||
* const factor = await appWindow.scaleFactor();
|
||
* const size = await appWindow.innerSize(); // PhysicalSize
|
||
* const logical = size.toLogical(factor);
|
||
* ```
|
||
*/
|
||
toLogical(e) {
|
||
return new x(this.width / e, this.height / e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
width: this.width,
|
||
height: this.height
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class h {
|
||
constructor(e) {
|
||
this.size = e;
|
||
}
|
||
toLogical(e) {
|
||
return this.size instanceof x ? this.size : this.size.toLogical(e);
|
||
}
|
||
toPhysical(e) {
|
||
return this.size instanceof c ? this.size : this.size.toPhysical(e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
[`${this.size.type}`]: {
|
||
width: this.size.width,
|
||
height: this.size.height
|
||
}
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class f {
|
||
constructor(...e) {
|
||
this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.x = e[0].Logical.x, this.y = e[0].Logical.y) : (this.x = e[0].x, this.y = e[0].y) : (this.x = e[0], this.y = e[1]);
|
||
}
|
||
/**
|
||
* Converts the logical position to a physical one.
|
||
* @example
|
||
* ```typescript
|
||
* import { LogicalPosition } from '@tauri-apps/api/dpi';
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
*
|
||
* const appWindow = getCurrentWindow();
|
||
* const factor = await appWindow.scaleFactor();
|
||
* const position = new LogicalPosition(400, 500);
|
||
* const physical = position.toPhysical(factor);
|
||
* ```
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
toPhysical(e) {
|
||
return new u(this.x * e, this.y * e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
x: this.x,
|
||
y: this.y
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class u {
|
||
constructor(...e) {
|
||
this.type = "Physical", e.length === 1 ? "Physical" in e[0] ? (this.x = e[0].Physical.x, this.y = e[0].Physical.y) : (this.x = e[0].x, this.y = e[0].y) : (this.x = e[0], this.y = e[1]);
|
||
}
|
||
/**
|
||
* Converts the physical position to a logical one.
|
||
* @example
|
||
* ```typescript
|
||
* import { PhysicalPosition } from '@tauri-apps/api/dpi';
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
*
|
||
* const appWindow = getCurrentWindow();
|
||
* const factor = await appWindow.scaleFactor();
|
||
* const position = new PhysicalPosition(400, 500);
|
||
* const physical = position.toLogical(factor);
|
||
* ```
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
toLogical(e) {
|
||
return new f(this.x / e, this.y / e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
x: this.x,
|
||
y: this.y
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class d {
|
||
constructor(e) {
|
||
this.position = e;
|
||
}
|
||
toLogical(e) {
|
||
return this.position instanceof f ? this.position : this.position.toLogical(e);
|
||
}
|
||
toPhysical(e) {
|
||
return this.position instanceof u ? this.position : this.position.toPhysical(e);
|
||
}
|
||
[a]() {
|
||
return {
|
||
[`${this.position.type}`]: {
|
||
x: this.position.x,
|
||
y: this.position.y
|
||
}
|
||
};
|
||
}
|
||
toJSON() {
|
||
return this[a]();
|
||
}
|
||
}
|
||
class w extends S {
|
||
/**
|
||
* Creates an Image from a resource ID. For internal use only.
|
||
*
|
||
* @ignore
|
||
*/
|
||
constructor(e) {
|
||
super(e);
|
||
}
|
||
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
||
static async new(e, n, l) {
|
||
return i("plugin:image|new", {
|
||
rgba: b(e),
|
||
width: n,
|
||
height: l
|
||
}).then((r) => new w(r));
|
||
}
|
||
/**
|
||
* Creates a new image using the provided bytes by inferring the file format.
|
||
* If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
|
||
*
|
||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||
*
|
||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||
* To enable it, change your Cargo.toml file:
|
||
* ```toml
|
||
* [dependencies]
|
||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||
* ```
|
||
*/
|
||
static async fromBytes(e) {
|
||
return i("plugin:image|from_bytes", {
|
||
bytes: b(e)
|
||
}).then((n) => new w(n));
|
||
}
|
||
/**
|
||
* Creates a new image using the provided path.
|
||
*
|
||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||
*
|
||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||
* To enable it, change your Cargo.toml file:
|
||
* ```toml
|
||
* [dependencies]
|
||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||
* ```
|
||
*/
|
||
static async fromPath(e) {
|
||
return i("plugin:image|from_path", { path: e }).then((n) => new w(n));
|
||
}
|
||
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
||
async rgba() {
|
||
return i("plugin:image|rgba", {
|
||
rid: this.rid
|
||
}).then((e) => new Uint8Array(e));
|
||
}
|
||
/** Returns the size of this image. */
|
||
async size() {
|
||
return i("plugin:image|size", { rid: this.rid });
|
||
}
|
||
}
|
||
function b(t) {
|
||
return t == null ? null : typeof t == "string" ? t : t instanceof w ? t.rid : t;
|
||
}
|
||
var g;
|
||
(function(t) {
|
||
t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
|
||
})(g || (g = {}));
|
||
class k {
|
||
constructor(e) {
|
||
this._preventDefault = !1, this.event = e.event, this.id = e.id;
|
||
}
|
||
preventDefault() {
|
||
this._preventDefault = !0;
|
||
}
|
||
isPreventDefault() {
|
||
return this._preventDefault;
|
||
}
|
||
}
|
||
var _;
|
||
(function(t) {
|
||
t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
|
||
})(_ || (_ = {}));
|
||
function T() {
|
||
return new D(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||
skip: !0
|
||
});
|
||
}
|
||
async function y() {
|
||
return i("plugin:window|get_all_windows").then((t) => t.map((e) => new D(e, {
|
||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||
skip: !0
|
||
})));
|
||
}
|
||
const p = ["tauri://created", "tauri://error"];
|
||
class D {
|
||
/**
|
||
* Creates a new Window.
|
||
* @example
|
||
* ```typescript
|
||
* import { Window } from '@tauri-apps/api/window';
|
||
* const appWindow = new Window('my-label');
|
||
* appWindow.once('tauri://created', function () {
|
||
* // window successfully created
|
||
* });
|
||
* appWindow.once('tauri://error', function (e) {
|
||
* // an error happened creating the window
|
||
* });
|
||
* ```
|
||
*
|
||
* @param label The unique window label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||
* @returns The {@link Window} instance to communicate with the window.
|
||
*/
|
||
constructor(e, n = {}) {
|
||
var l;
|
||
this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), n != null && n.skip || i("plugin:window|create", {
|
||
options: {
|
||
...n,
|
||
parent: typeof n.parent == "string" ? n.parent : (l = n.parent) === null || l === void 0 ? void 0 : l.label,
|
||
label: e
|
||
}
|
||
}).then(async () => this.emit("tauri://created")).catch(async (r) => this.emit("tauri://error", r));
|
||
}
|
||
/**
|
||
* Gets the Window associated with the given label.
|
||
* @example
|
||
* ```typescript
|
||
* import { Window } from '@tauri-apps/api/window';
|
||
* const mainWindow = Window.getByLabel('main');
|
||
* ```
|
||
*
|
||
* @param label The window label.
|
||
* @returns The Window instance to communicate with the window or null if the window doesn't exist.
|
||
*/
|
||
static async getByLabel(e) {
|
||
var n;
|
||
return (n = (await y()).find((l) => l.label === e)) !== null && n !== void 0 ? n : null;
|
||
}
|
||
/**
|
||
* Get an instance of `Window` for the current window.
|
||
*/
|
||
static getCurrent() {
|
||
return T();
|
||
}
|
||
/**
|
||
* Gets a list of instances of `Window` for all available windows.
|
||
*/
|
||
static async getAll() {
|
||
return y();
|
||
}
|
||
/**
|
||
* Gets the focused window.
|
||
* @example
|
||
* ```typescript
|
||
* import { Window } from '@tauri-apps/api/window';
|
||
* const focusedWindow = Window.getFocusedWindow();
|
||
* ```
|
||
*
|
||
* @returns The Window instance or `undefined` if there is not any focused window.
|
||
*/
|
||
static async getFocusedWindow() {
|
||
for (const e of await y())
|
||
if (await e.isFocused())
|
||
return e;
|
||
return null;
|
||
}
|
||
/**
|
||
* Listen to an emitted event on this window.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const unlisten = await getCurrentWindow().listen<string>('state-changed', (event) => {
|
||
* console.log(`Got error: ${payload}`);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||
* @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.
|
||
*/
|
||
async listen(e, n) {
|
||
return this._handleTauriEvent(e, n) ? () => {
|
||
const l = this.listeners[e];
|
||
l.splice(l.indexOf(n), 1);
|
||
} : C(e, n, {
|
||
target: { kind: "Window", label: this.label }
|
||
});
|
||
}
|
||
/**
|
||
* Listen to an emitted event on this window only once.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const unlisten = await getCurrentWindow().once<null>('initialized', (event) => {
|
||
* console.log(`Window initialized!`);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||
* @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.
|
||
*/
|
||
async once(e, n) {
|
||
return this._handleTauriEvent(e, n) ? () => {
|
||
const l = this.listeners[e];
|
||
l.splice(l.indexOf(n), 1);
|
||
} : L(e, n, {
|
||
target: { kind: "Window", label: this.label }
|
||
});
|
||
}
|
||
/**
|
||
* Emits an event to all {@link EventTarget|targets}.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });
|
||
* ```
|
||
*
|
||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||
* @param payload Event payload.
|
||
*/
|
||
async emit(e, n) {
|
||
if (p.includes(e)) {
|
||
for (const l of this.listeners[e] || [])
|
||
l({
|
||
event: e,
|
||
id: -1,
|
||
payload: n
|
||
});
|
||
return;
|
||
}
|
||
return P(e, n);
|
||
}
|
||
/**
|
||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });
|
||
* ```
|
||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||
* @param payload Event payload.
|
||
*/
|
||
async emitTo(e, n, l) {
|
||
if (p.includes(n)) {
|
||
for (const r of this.listeners[n] || [])
|
||
r({
|
||
event: n,
|
||
id: -1,
|
||
payload: l
|
||
});
|
||
return;
|
||
}
|
||
return O(e, n, l);
|
||
}
|
||
/** @ignore */
|
||
_handleTauriEvent(e, n) {
|
||
return p.includes(e) ? (e in this.listeners ? this.listeners[e].push(n) : this.listeners[e] = [n], !0) : !1;
|
||
}
|
||
// Getters
|
||
/**
|
||
* The scale factor that can be used to map physical pixels to logical pixels.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const factor = await getCurrentWindow().scaleFactor();
|
||
* ```
|
||
*
|
||
* @returns The window's monitor scale factor.
|
||
*/
|
||
async scaleFactor() {
|
||
return i("plugin:window|scale_factor", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const position = await getCurrentWindow().innerPosition();
|
||
* ```
|
||
*
|
||
* @returns The window's inner position.
|
||
*/
|
||
async innerPosition() {
|
||
return i("plugin:window|inner_position", {
|
||
label: this.label
|
||
}).then((e) => new u(e));
|
||
}
|
||
/**
|
||
* The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const position = await getCurrentWindow().outerPosition();
|
||
* ```
|
||
*
|
||
* @returns The window's outer position.
|
||
*/
|
||
async outerPosition() {
|
||
return i("plugin:window|outer_position", {
|
||
label: this.label
|
||
}).then((e) => new u(e));
|
||
}
|
||
/**
|
||
* The physical size of the window's client area.
|
||
* The client area is the content of the window, excluding the title bar and borders.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const size = await getCurrentWindow().innerSize();
|
||
* ```
|
||
*
|
||
* @returns The window's inner size.
|
||
*/
|
||
async innerSize() {
|
||
return i("plugin:window|inner_size", {
|
||
label: this.label
|
||
}).then((e) => new c(e));
|
||
}
|
||
/**
|
||
* The physical size of the entire window.
|
||
* These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const size = await getCurrentWindow().outerSize();
|
||
* ```
|
||
*
|
||
* @returns The window's outer size.
|
||
*/
|
||
async outerSize() {
|
||
return i("plugin:window|outer_size", {
|
||
label: this.label
|
||
}).then((e) => new c(e));
|
||
}
|
||
/**
|
||
* Gets the window's current fullscreen state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const fullscreen = await getCurrentWindow().isFullscreen();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is in fullscreen mode or not.
|
||
*/
|
||
async isFullscreen() {
|
||
return i("plugin:window|is_fullscreen", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current minimized state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const minimized = await getCurrentWindow().isMinimized();
|
||
* ```
|
||
*/
|
||
async isMinimized() {
|
||
return i("plugin:window|is_minimized", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current maximized state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const maximized = await getCurrentWindow().isMaximized();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is maximized or not.
|
||
*/
|
||
async isMaximized() {
|
||
return i("plugin:window|is_maximized", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current focus state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const focused = await getCurrentWindow().isFocused();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is focused or not.
|
||
*/
|
||
async isFocused() {
|
||
return i("plugin:window|is_focused", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current decorated state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const decorated = await getCurrentWindow().isDecorated();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is decorated or not.
|
||
*/
|
||
async isDecorated() {
|
||
return i("plugin:window|is_decorated", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current resizable state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const resizable = await getCurrentWindow().isResizable();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is resizable or not.
|
||
*/
|
||
async isResizable() {
|
||
return i("plugin:window|is_resizable", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's native maximize button state.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux / iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const maximizable = await getCurrentWindow().isMaximizable();
|
||
* ```
|
||
*
|
||
* @returns Whether the window's native maximize button is enabled or not.
|
||
*/
|
||
async isMaximizable() {
|
||
return i("plugin:window|is_maximizable", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's native minimize button state.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux / iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const minimizable = await getCurrentWindow().isMinimizable();
|
||
* ```
|
||
*
|
||
* @returns Whether the window's native minimize button is enabled or not.
|
||
*/
|
||
async isMinimizable() {
|
||
return i("plugin:window|is_minimizable", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's native close button state.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const closable = await getCurrentWindow().isClosable();
|
||
* ```
|
||
*
|
||
* @returns Whether the window's native close button is enabled or not.
|
||
*/
|
||
async isClosable() {
|
||
return i("plugin:window|is_closable", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current visible state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const visible = await getCurrentWindow().isVisible();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is visible or not.
|
||
*/
|
||
async isVisible() {
|
||
return i("plugin:window|is_visible", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current title.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const title = await getCurrentWindow().title();
|
||
* ```
|
||
*/
|
||
async title() {
|
||
return i("plugin:window|title", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Gets the window's current theme.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const theme = await getCurrentWindow().theme();
|
||
* ```
|
||
*
|
||
* @returns The window theme.
|
||
*/
|
||
async theme() {
|
||
return i("plugin:window|theme", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window is configured to be always on top of other windows or not.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop();
|
||
* ```
|
||
*
|
||
* @returns Whether the window is visible or not.
|
||
*/
|
||
async isAlwaysOnTop() {
|
||
return i("plugin:window|is_always_on_top", {
|
||
label: this.label
|
||
});
|
||
}
|
||
// Setters
|
||
/**
|
||
* Centers the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().center();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async center() {
|
||
return i("plugin:window|center", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Requests user attention to the window, this has no effect if the application
|
||
* is already focused. How requesting for user attention manifests is platform dependent,
|
||
* see `UserAttentionType` for details.
|
||
*
|
||
* Providing `null` will unset the request for user attention. Unsetting the request for
|
||
* user attention might not be done automatically by the WM when the window receives input.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **macOS:** `null` has no effect.
|
||
* - **Linux:** Urgency levels have the same effect.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().requestUserAttention();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async requestUserAttention(e) {
|
||
let n = null;
|
||
return e && (e === g.Critical ? n = { type: "Critical" } : n = { type: "Informational" }), i("plugin:window|request_user_attention", {
|
||
label: this.label,
|
||
value: n
|
||
});
|
||
}
|
||
/**
|
||
* Updates the window resizable flag.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setResizable(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setResizable(e) {
|
||
return i("plugin:window|set_resizable", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Enable or disable the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setEnabled(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
async setEnabled(e) {
|
||
return i("plugin:window|set_enabled", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window is enabled or disabled.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setEnabled(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
async isEnabled() {
|
||
return i("plugin:window|is_enabled", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Sets whether the window's native maximize button is enabled or not.
|
||
* If resizable is set to false, this setting is ignored.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
|
||
* - **Linux / iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setMaximizable(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setMaximizable(e) {
|
||
return i("plugin:window|set_maximizable", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets whether the window's native minimize button is enabled or not.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux / iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setMinimizable(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setMinimizable(e) {
|
||
return i("plugin:window|set_minimizable", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets whether the window's native close button is enabled or not.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux:** GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible
|
||
* - **iOS / Android:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setClosable(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setClosable(e) {
|
||
return i("plugin:window|set_closable", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window title.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setTitle('Tauri');
|
||
* ```
|
||
*
|
||
* @param title The new title
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setTitle(e) {
|
||
return i("plugin:window|set_title", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Maximizes the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().maximize();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async maximize() {
|
||
return i("plugin:window|maximize", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Unmaximizes the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().unmaximize();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async unmaximize() {
|
||
return i("plugin:window|unmaximize", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Toggles the window maximized state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().toggleMaximize();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async toggleMaximize() {
|
||
return i("plugin:window|toggle_maximize", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Minimizes the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().minimize();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async minimize() {
|
||
return i("plugin:window|minimize", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Unminimizes the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().unminimize();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async unminimize() {
|
||
return i("plugin:window|unminimize", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window visibility to true.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().show();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async show() {
|
||
return i("plugin:window|show", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window visibility to false.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().hide();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async hide() {
|
||
return i("plugin:window|hide", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Closes the window.
|
||
*
|
||
* Note this emits a closeRequested event so you can intercept it. To force window close, use {@link Window.destroy}.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().close();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async close() {
|
||
return i("plugin:window|close", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Destroys the window. Behaves like {@link Window.close} but forces the window close instead of emitting a closeRequested event.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().destroy();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async destroy() {
|
||
return i("plugin:window|destroy", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window should have borders and bars.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setDecorations(false);
|
||
* ```
|
||
*
|
||
* @param decorations Whether the window should have borders and bars.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setDecorations(e) {
|
||
return i("plugin:window|set_decorations", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Whether or not the window should have shadow.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Windows:**
|
||
* - `false` has no effect on decorated window, shadows are always ON.
|
||
* - `true` will make undecorated window have a 1px white border,
|
||
* and on Windows 11, it will have a rounded corners.
|
||
* - **Linux:** Unsupported.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setShadow(false);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setShadow(e) {
|
||
return i("plugin:window|set_shadow", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Set window effects.
|
||
*/
|
||
async setEffects(e) {
|
||
return i("plugin:window|set_effects", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Clear any applied effects if possible.
|
||
*/
|
||
async clearEffects() {
|
||
return i("plugin:window|set_effects", {
|
||
label: this.label,
|
||
value: null
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window should always be on top of other windows.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setAlwaysOnTop(true);
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async setAlwaysOnTop(e) {
|
||
return i("plugin:window|set_always_on_top", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window should always be below other windows.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setAlwaysOnBottom(true);
|
||
* ```
|
||
*
|
||
* @param alwaysOnBottom Whether the window should always be below other windows or not.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setAlwaysOnBottom(e) {
|
||
return i("plugin:window|set_always_on_bottom", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Prevents the window contents from being captured by other apps.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setContentProtected(true);
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setContentProtected(e) {
|
||
return i("plugin:window|set_content_protected", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Resizes the window with a new inner size.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setSize(new LogicalSize(600, 500));
|
||
* ```
|
||
*
|
||
* @param size The logical or physical inner size.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setSize(e) {
|
||
return i("plugin:window|set_size", {
|
||
label: this.label,
|
||
value: e instanceof h ? e : new h(e)
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async setMinSize(e) {
|
||
return i("plugin:window|set_min_size", {
|
||
label: this.label,
|
||
value: e instanceof h ? e : e ? new h(e) : null
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async setMaxSize(e) {
|
||
return i("plugin:window|set_max_size", {
|
||
label: this.label,
|
||
value: e instanceof h ? e : e ? new h(e) : null
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window inner size constraints.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setSizeConstraints({ minWidth: 300 });
|
||
* ```
|
||
*
|
||
* @param constraints The logical or physical inner size, or `null` to unset the constraint.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setSizeConstraints(e) {
|
||
function n(l) {
|
||
return l ? { Logical: l } : null;
|
||
}
|
||
return i("plugin:window|set_size_constraints", {
|
||
label: this.label,
|
||
value: {
|
||
minWidth: n(e == null ? void 0 : e.minWidth),
|
||
minHeight: n(e == null ? void 0 : e.minHeight),
|
||
maxWidth: n(e == null ? void 0 : e.maxWidth),
|
||
maxHeight: n(e == null ? void 0 : e.maxHeight)
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window outer position.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setPosition(new LogicalPosition(600, 500));
|
||
* ```
|
||
*
|
||
* @param position The new position, in logical or physical pixels.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setPosition(e) {
|
||
return i("plugin:window|set_position", {
|
||
label: this.label,
|
||
value: e instanceof d ? e : new d(e)
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window fullscreen state.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setFullscreen(true);
|
||
* ```
|
||
*
|
||
* @param fullscreen Whether the window should go to fullscreen or not.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setFullscreen(e) {
|
||
return i("plugin:window|set_fullscreen", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* On macOS, Toggles a fullscreen mode that doesn’t require a new macOS space. Returns a boolean indicating whether the transition was successful (this won’t work if the window was already in the native fullscreen).
|
||
* This is how fullscreen used to work on macOS in versions before Lion. And allows the user to have a fullscreen window without using another space or taking control over the entire monitor.
|
||
*
|
||
* On other platforms, this is the same as {@link Window.setFullscreen}.
|
||
*
|
||
* @param fullscreen Whether the window should go to simple fullscreen or not.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setSimpleFullscreen(e) {
|
||
return i("plugin:window|set_simple_fullscreen", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Bring the window to front and focus.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setFocus();
|
||
* ```
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setFocus() {
|
||
return i("plugin:window|set_focus", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Sets whether the window can be focused.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **macOS**: If the window is already focused, it is not possible to unfocus it after calling `set_focusable(false)`.
|
||
* In this case, you might consider calling {@link Window.setFocus} but it will move the window to the back i.e. at the bottom in terms of z-order.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setFocusable(true);
|
||
* ```
|
||
*
|
||
* @param focusable Whether the window can be focused.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setFocusable(e) {
|
||
return i("plugin:window|set_focusable", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window icon.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setIcon('/tauri/awesome.png');
|
||
* ```
|
||
*
|
||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||
* To enable it, change your Cargo.toml file:
|
||
* ```toml
|
||
* [dependencies]
|
||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||
* ```
|
||
*
|
||
* @param icon Icon bytes or path to the icon file.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setIcon(e) {
|
||
return i("plugin:window|set_icon", {
|
||
label: this.label,
|
||
value: b(e)
|
||
});
|
||
}
|
||
/**
|
||
* Whether the window icon should be hidden from the taskbar or not.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **macOS:** Unsupported.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setSkipTaskbar(true);
|
||
* ```
|
||
*
|
||
* @param skip true to hide window icon, false to show it.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setSkipTaskbar(e) {
|
||
return i("plugin:window|set_skip_taskbar", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Grabs the cursor, preventing it from leaving the window.
|
||
*
|
||
* There's no guarantee that the cursor will be hidden. You should
|
||
* hide it by yourself if you want so.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux:** Unsupported.
|
||
* - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setCursorGrab(true);
|
||
* ```
|
||
*
|
||
* @param grab `true` to grab the cursor icon, `false` to release it.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setCursorGrab(e) {
|
||
return i("plugin:window|set_cursor_grab", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Modifies the cursor's visibility.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Windows:** The cursor is only hidden within the confines of the window.
|
||
* - **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is
|
||
* outside of the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setCursorVisible(false);
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async setCursorVisible(e) {
|
||
return i("plugin:window|set_cursor_visible", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Modifies the cursor icon of the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setCursorIcon('help');
|
||
* ```
|
||
*
|
||
* @param icon The new cursor icon.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setCursorIcon(e) {
|
||
return i("plugin:window|set_cursor_icon", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the window background color.
|
||
*
|
||
* #### Platform-specific:
|
||
*
|
||
* - **Windows:** alpha channel is ignored.
|
||
* - **iOS / Android:** Unsupported.
|
||
*
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*
|
||
* @since 2.1.0
|
||
*/
|
||
async setBackgroundColor(e) {
|
||
return i("plugin:window|set_background_color", { color: e });
|
||
}
|
||
/**
|
||
* Changes the position of the cursor in window coordinates.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));
|
||
* ```
|
||
*
|
||
* @param position The new cursor position.
|
||
* @returns A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setCursorPosition(e) {
|
||
return i("plugin:window|set_cursor_position", {
|
||
label: this.label,
|
||
value: e instanceof d ? e : new d(e)
|
||
});
|
||
}
|
||
/**
|
||
* Changes the cursor events behavior.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setIgnoreCursorEvents(true);
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async setIgnoreCursorEvents(e) {
|
||
return i("plugin:window|set_ignore_cursor_events", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Starts dragging the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().startDragging();
|
||
* ```
|
||
*
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async startDragging() {
|
||
return i("plugin:window|start_dragging", {
|
||
label: this.label
|
||
});
|
||
}
|
||
/**
|
||
* Starts resize-dragging the window.
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().startResizeDragging();
|
||
* ```
|
||
*
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async startResizeDragging(e) {
|
||
return i("plugin:window|start_resize_dragging", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the badge count. It is app wide and not specific to this window.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Windows**: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setBadgeCount(5);
|
||
* ```
|
||
*
|
||
* @param count The badge count. Use `undefined` to remove the badge.
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setBadgeCount(e) {
|
||
return i("plugin:window|set_badge_count", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the badge cont **macOS only**.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setBadgeLabel("Hello");
|
||
* ```
|
||
*
|
||
* @param label The badge label. Use `undefined` to remove the badge.
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setBadgeLabel(e) {
|
||
return i("plugin:window|set_badge_label", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the overlay icon. **Windows only**
|
||
* The overlay icon can be set for every window.
|
||
*
|
||
*
|
||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||
* To enable it, change your Cargo.toml file:
|
||
*
|
||
* ```toml
|
||
* [dependencies]
|
||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||
* ```
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");
|
||
* ```
|
||
*
|
||
* @param icon Icon bytes or path to the icon file. Use `undefined` to remove the overlay icon.
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setOverlayIcon(e) {
|
||
return i("plugin:window|set_overlay_icon", {
|
||
label: this.label,
|
||
value: e ? b(e) : void 0
|
||
});
|
||
}
|
||
/**
|
||
* Sets the taskbar progress state.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux / macOS**: Progress bar is app-wide and not specific to this window.
|
||
* - **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME).
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
|
||
* await getCurrentWindow().setProgressBar({
|
||
* status: ProgressBarStatus.Normal,
|
||
* progress: 50,
|
||
* });
|
||
* ```
|
||
*
|
||
* @return A promise indicating the success or failure of the operation.
|
||
*/
|
||
async setProgressBar(e) {
|
||
return i("plugin:window|set_progress_bar", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets whether the window should be visible on all workspaces or virtual desktops.
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Windows / iOS / Android:** Unsupported.
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
async setVisibleOnAllWorkspaces(e) {
|
||
return i("plugin:window|set_visible_on_all_workspaces", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Sets the title bar style. **macOS only**.
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
async setTitleBarStyle(e) {
|
||
return i("plugin:window|set_title_bar_style", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
/**
|
||
* Set window theme, pass in `null` or `undefined` to follow system theme
|
||
*
|
||
* #### Platform-specific
|
||
*
|
||
* - **Linux / macOS**: Theme is app-wide and not specific to this window.
|
||
* - **iOS / Android:** Unsupported.
|
||
*
|
||
* @since 2.0.0
|
||
*/
|
||
async setTheme(e) {
|
||
return i("plugin:window|set_theme", {
|
||
label: this.label,
|
||
value: e
|
||
});
|
||
}
|
||
// Listeners
|
||
/**
|
||
* Listen to window resize.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
|
||
* console.log('Window resized', size);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onResized(e) {
|
||
return this.listen(o.WINDOW_RESIZED, (n) => {
|
||
n.payload = new c(n.payload), e(n);
|
||
});
|
||
}
|
||
/**
|
||
* Listen to window move.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
|
||
* console.log('Window moved', position);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onMoved(e) {
|
||
return this.listen(o.WINDOW_MOVED, (n) => {
|
||
n.payload = new u(n.payload), e(n);
|
||
});
|
||
}
|
||
/**
|
||
* Listen to window close requested. Emitted when the user requests to closes the window.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* import { confirm } from '@tauri-apps/api/dialog';
|
||
* const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
|
||
* const confirmed = await confirm('Are you sure?');
|
||
* if (!confirmed) {
|
||
* // user did not confirm closing the window; let's prevent it
|
||
* event.preventDefault();
|
||
* }
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onCloseRequested(e) {
|
||
return this.listen(o.WINDOW_CLOSE_REQUESTED, async (n) => {
|
||
const l = new k(n);
|
||
await e(l), l.isPreventDefault() || await this.destroy();
|
||
});
|
||
}
|
||
/**
|
||
* Listen to a file drop event.
|
||
* The listener is triggered when the user hovers the selected files on the webview,
|
||
* drops the files or cancels the operation.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/webview";
|
||
* const unlisten = await getCurrentWindow().onDragDropEvent((event) => {
|
||
* if (event.payload.type === 'over') {
|
||
* console.log('User hovering', event.payload.position);
|
||
* } else if (event.payload.type === 'drop') {
|
||
* console.log('User dropped', event.payload.paths);
|
||
* } else {
|
||
* console.log('File drop cancelled');
|
||
* }
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onDragDropEvent(e) {
|
||
const n = await this.listen(o.DRAG_ENTER, (s) => {
|
||
e({
|
||
...s,
|
||
payload: {
|
||
type: "enter",
|
||
paths: s.payload.paths,
|
||
position: new u(s.payload.position)
|
||
}
|
||
});
|
||
}), l = await this.listen(o.DRAG_OVER, (s) => {
|
||
e({
|
||
...s,
|
||
payload: {
|
||
type: "over",
|
||
position: new u(s.payload.position)
|
||
}
|
||
});
|
||
}), r = await this.listen(o.DRAG_DROP, (s) => {
|
||
e({
|
||
...s,
|
||
payload: {
|
||
type: "drop",
|
||
paths: s.payload.paths,
|
||
position: new u(s.payload.position)
|
||
}
|
||
});
|
||
}), W = await this.listen(o.DRAG_LEAVE, (s) => {
|
||
e({ ...s, payload: { type: "leave" } });
|
||
});
|
||
return () => {
|
||
n(), r(), l(), W();
|
||
};
|
||
}
|
||
/**
|
||
* Listen to window focus change.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
|
||
* console.log('Focus changed, window is focused? ' + focused);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onFocusChanged(e) {
|
||
const n = await this.listen(o.WINDOW_FOCUS, (r) => {
|
||
e({ ...r, payload: !0 });
|
||
}), l = await this.listen(o.WINDOW_BLUR, (r) => {
|
||
e({ ...r, payload: !1 });
|
||
});
|
||
return () => {
|
||
n(), l();
|
||
};
|
||
}
|
||
/**
|
||
* Listen to window scale change. Emitted when the window's scale factor has changed.
|
||
* The following user actions can cause DPI changes:
|
||
* - Changing the display's resolution.
|
||
* - Changing the display's scale factor (e.g. in Control Panel on Windows).
|
||
* - Moving the window to a display with a different scale factor.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
|
||
* console.log('Scale changed', payload.scaleFactor, payload.size);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onScaleChanged(e) {
|
||
return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED, e);
|
||
}
|
||
/**
|
||
* Listen to the system theme change.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
* const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
|
||
* console.log('New theme: ' + theme);
|
||
* });
|
||
*
|
||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||
* unlisten();
|
||
* ```
|
||
*
|
||
* @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.
|
||
*/
|
||
async onThemeChanged(e) {
|
||
return this.listen(o.WINDOW_THEME_CHANGED, e);
|
||
}
|
||
}
|
||
var m;
|
||
(function(t) {
|
||
t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
|
||
})(m || (m = {}));
|
||
var v;
|
||
(function(t) {
|
||
t.AppearanceBased = "appearanceBased", t.Light = "light", t.Dark = "dark", t.MediumLight = "mediumLight", t.UltraDark = "ultraDark", t.Titlebar = "titlebar", t.Selection = "selection", t.Menu = "menu", t.Popover = "popover", t.Sidebar = "sidebar", t.HeaderView = "headerView", t.Sheet = "sheet", t.WindowBackground = "windowBackground", t.HudWindow = "hudWindow", t.FullScreenUI = "fullScreenUI", t.Tooltip = "tooltip", t.ContentBackground = "contentBackground", t.UnderWindowBackground = "underWindowBackground", t.UnderPageBackground = "underPageBackground", t.Mica = "mica", t.Blur = "blur", t.Acrylic = "acrylic", t.Tabbed = "tabbed", t.TabbedDark = "tabbedDark", t.TabbedLight = "tabbedLight";
|
||
})(v || (v = {}));
|
||
var z;
|
||
(function(t) {
|
||
t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
|
||
})(z || (z = {}));
|
||
export {
|
||
k as CloseRequestedEvent,
|
||
v as Effect,
|
||
z as EffectState,
|
||
f as LogicalPosition,
|
||
x as LogicalSize,
|
||
u as PhysicalPosition,
|
||
c as PhysicalSize,
|
||
_ as ProgressBarStatus,
|
||
g as UserAttentionType,
|
||
D as Window,
|
||
y as getAllWindows,
|
||
T as getCurrentWindow
|
||
};
|