@vasakgroup/vue-libvasak 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/vue-libvasak.es.js +2084 -0
- package/dist/vue-libvasak.umd.js +1 -0
- package/package.json +27 -6
- package/src/.d.ts +0 -0
- package/src/index.ts +11 -0
- package/src/sidebar/SideBar.vue +0 -0
- package/src/sidebar/SideButton.vue +0 -0
- package/src/types/vue-libvasak.d.ts +10 -0
- package/src/window/TopBar.vue +30 -43
- package/src/window/WindowFrame.vue +3 -75
- package/COPYING +0 -674
- package/readme.md +0 -71
|
@@ -0,0 +1,2084 @@
|
|
|
1
|
+
import { createElementBlock as v, openBlock as f, renderSlot as R, defineComponent as C, createElementVNode as u, ref as p, onMounted as F, toDisplayString as U, unref as D, Fragment as V, createVNode as G } from "vue";
|
|
2
|
+
const $ = (i, e) => {
|
|
3
|
+
const t = i.__vccOpts || i;
|
|
4
|
+
for (const [l, s] of e)
|
|
5
|
+
t[l] = s;
|
|
6
|
+
return t;
|
|
7
|
+
}, H = {}, J = { class: "sidebar" };
|
|
8
|
+
function q(i, e) {
|
|
9
|
+
return f(), v("div", J, [
|
|
10
|
+
R(i.$slots, "default")
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
const j = /* @__PURE__ */ $(H, [["render", q]]), Z = {
|
|
14
|
+
href: "#",
|
|
15
|
+
class: "sidebar-button"
|
|
16
|
+
}, Q = ["src"], Y = /* @__PURE__ */ C({
|
|
17
|
+
__name: "SideButton",
|
|
18
|
+
props: {
|
|
19
|
+
title: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "Link"
|
|
22
|
+
},
|
|
23
|
+
image: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ""
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
setup(i) {
|
|
29
|
+
return (e, t) => (f(), v("a", Z, [
|
|
30
|
+
u("img", {
|
|
31
|
+
src: i.image,
|
|
32
|
+
class: "img-fluid"
|
|
33
|
+
}, null, 8, Q)
|
|
34
|
+
]));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function K(i, e, t, l) {
|
|
38
|
+
if (typeof e == "function" ? i !== e || !l : !e.has(i)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
39
|
+
return t === "m" ? l : t === "a" ? l.call(i) : l ? l.value : e.get(i);
|
|
40
|
+
}
|
|
41
|
+
function X(i, e, t, l, s) {
|
|
42
|
+
if (typeof e == "function" ? i !== e || !0 : !e.has(i)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
43
|
+
return e.set(i, t), t;
|
|
44
|
+
}
|
|
45
|
+
var y;
|
|
46
|
+
const o = "__TAURI_TO_IPC_KEY__";
|
|
47
|
+
function ee(i, e = !1) {
|
|
48
|
+
return window.__TAURI_INTERNALS__.transformCallback(i, e);
|
|
49
|
+
}
|
|
50
|
+
async function n(i, e = {}, t) {
|
|
51
|
+
return window.__TAURI_INTERNALS__.invoke(i, e, t);
|
|
52
|
+
}
|
|
53
|
+
class ie {
|
|
54
|
+
get rid() {
|
|
55
|
+
return K(this, y, "f");
|
|
56
|
+
}
|
|
57
|
+
constructor(e) {
|
|
58
|
+
y.set(this, void 0), X(this, y, e);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Destroys and cleans up this resource from memory.
|
|
62
|
+
* **You should not call any method on this object anymore and should drop any reference to it.**
|
|
63
|
+
*/
|
|
64
|
+
async close() {
|
|
65
|
+
return n("plugin:resources|close", {
|
|
66
|
+
rid: this.rid
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
y = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
class L {
|
|
72
|
+
constructor(...e) {
|
|
73
|
+
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]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Converts the logical size to a physical one.
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { LogicalSize } from '@tauri-apps/api/dpi';
|
|
80
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
81
|
+
*
|
|
82
|
+
* const appWindow = getCurrentWindow();
|
|
83
|
+
* const factor = await appWindow.scaleFactor();
|
|
84
|
+
* const size = new LogicalSize(400, 500);
|
|
85
|
+
* const physical = size.toPhysical(factor);
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @since 2.0.0
|
|
89
|
+
*/
|
|
90
|
+
toPhysical(e) {
|
|
91
|
+
return new b(this.width * e, this.height * e);
|
|
92
|
+
}
|
|
93
|
+
[o]() {
|
|
94
|
+
return {
|
|
95
|
+
width: this.width,
|
|
96
|
+
height: this.height
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
toJSON() {
|
|
100
|
+
return this[o]();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class b {
|
|
104
|
+
constructor(...e) {
|
|
105
|
+
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]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Converts the physical size to a logical one.
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
112
|
+
* const appWindow = getCurrentWindow();
|
|
113
|
+
* const factor = await appWindow.scaleFactor();
|
|
114
|
+
* const size = await appWindow.innerSize(); // PhysicalSize
|
|
115
|
+
* const logical = size.toLogical(factor);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
toLogical(e) {
|
|
119
|
+
return new L(this.width / e, this.height / e);
|
|
120
|
+
}
|
|
121
|
+
[o]() {
|
|
122
|
+
return {
|
|
123
|
+
width: this.width,
|
|
124
|
+
height: this.height
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
toJSON() {
|
|
128
|
+
return this[o]();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class w {
|
|
132
|
+
constructor(e) {
|
|
133
|
+
this.size = e;
|
|
134
|
+
}
|
|
135
|
+
toLogical(e) {
|
|
136
|
+
return this.size instanceof L ? this.size : this.size.toLogical(e);
|
|
137
|
+
}
|
|
138
|
+
toPhysical(e) {
|
|
139
|
+
return this.size instanceof b ? this.size : this.size.toPhysical(e);
|
|
140
|
+
}
|
|
141
|
+
[o]() {
|
|
142
|
+
return {
|
|
143
|
+
[`${this.size.type}`]: {
|
|
144
|
+
width: this.size.width,
|
|
145
|
+
height: this.size.height
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
toJSON() {
|
|
150
|
+
return this[o]();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
class E {
|
|
154
|
+
constructor(...e) {
|
|
155
|
+
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]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Converts the logical position to a physical one.
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* import { LogicalPosition } from '@tauri-apps/api/dpi';
|
|
162
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
163
|
+
*
|
|
164
|
+
* const appWindow = getCurrentWindow();
|
|
165
|
+
* const factor = await appWindow.scaleFactor();
|
|
166
|
+
* const position = new LogicalPosition(400, 500);
|
|
167
|
+
* const physical = position.toPhysical(factor);
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @since 2.0.0
|
|
171
|
+
*/
|
|
172
|
+
toPhysical(e) {
|
|
173
|
+
return new c(this.x * e, this.y * e);
|
|
174
|
+
}
|
|
175
|
+
[o]() {
|
|
176
|
+
return {
|
|
177
|
+
x: this.x,
|
|
178
|
+
y: this.y
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
toJSON() {
|
|
182
|
+
return this[o]();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
class c {
|
|
186
|
+
constructor(...e) {
|
|
187
|
+
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]);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Converts the physical position to a logical one.
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* import { PhysicalPosition } from '@tauri-apps/api/dpi';
|
|
194
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
195
|
+
*
|
|
196
|
+
* const appWindow = getCurrentWindow();
|
|
197
|
+
* const factor = await appWindow.scaleFactor();
|
|
198
|
+
* const position = new PhysicalPosition(400, 500);
|
|
199
|
+
* const physical = position.toLogical(factor);
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @since 2.0.0
|
|
203
|
+
*/
|
|
204
|
+
toLogical(e) {
|
|
205
|
+
return new E(this.x / e, this.y / e);
|
|
206
|
+
}
|
|
207
|
+
[o]() {
|
|
208
|
+
return {
|
|
209
|
+
x: this.x,
|
|
210
|
+
y: this.y
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
toJSON() {
|
|
214
|
+
return this[o]();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
class _ {
|
|
218
|
+
constructor(e) {
|
|
219
|
+
this.position = e;
|
|
220
|
+
}
|
|
221
|
+
toLogical(e) {
|
|
222
|
+
return this.position instanceof E ? this.position : this.position.toLogical(e);
|
|
223
|
+
}
|
|
224
|
+
toPhysical(e) {
|
|
225
|
+
return this.position instanceof c ? this.position : this.position.toPhysical(e);
|
|
226
|
+
}
|
|
227
|
+
[o]() {
|
|
228
|
+
return {
|
|
229
|
+
[`${this.position.type}`]: {
|
|
230
|
+
x: this.position.x,
|
|
231
|
+
y: this.position.y
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
toJSON() {
|
|
236
|
+
return this[o]();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
var r;
|
|
240
|
+
(function(i) {
|
|
241
|
+
i.WINDOW_RESIZED = "tauri://resize", i.WINDOW_MOVED = "tauri://move", i.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", i.WINDOW_DESTROYED = "tauri://destroyed", i.WINDOW_FOCUS = "tauri://focus", i.WINDOW_BLUR = "tauri://blur", i.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", i.WINDOW_THEME_CHANGED = "tauri://theme-changed", i.WINDOW_CREATED = "tauri://window-created", i.WEBVIEW_CREATED = "tauri://webview-created", i.DRAG_ENTER = "tauri://drag-enter", i.DRAG_OVER = "tauri://drag-over", i.DRAG_DROP = "tauri://drag-drop", i.DRAG_LEAVE = "tauri://drag-leave";
|
|
242
|
+
})(r || (r = {}));
|
|
243
|
+
async function P(i, e) {
|
|
244
|
+
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(i, e), await n("plugin:event|unlisten", {
|
|
245
|
+
event: i,
|
|
246
|
+
eventId: e
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async function T(i, e, t) {
|
|
250
|
+
var l;
|
|
251
|
+
const s = typeof t?.target == "string" ? { kind: "AnyLabel", label: t.target } : (l = t?.target) !== null && l !== void 0 ? l : { kind: "Any" };
|
|
252
|
+
return n("plugin:event|listen", {
|
|
253
|
+
event: i,
|
|
254
|
+
target: s,
|
|
255
|
+
handler: ee(e)
|
|
256
|
+
}).then((d) => async () => P(i, d));
|
|
257
|
+
}
|
|
258
|
+
async function te(i, e, t) {
|
|
259
|
+
return T(i, (l) => {
|
|
260
|
+
P(i, l.id), e(l);
|
|
261
|
+
}, t);
|
|
262
|
+
}
|
|
263
|
+
async function ne(i, e) {
|
|
264
|
+
await n("plugin:event|emit", {
|
|
265
|
+
event: i,
|
|
266
|
+
payload: e
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
async function le(i, e, t) {
|
|
270
|
+
await n("plugin:event|emit_to", {
|
|
271
|
+
target: typeof i == "string" ? { kind: "AnyLabel", label: i } : i,
|
|
272
|
+
event: e,
|
|
273
|
+
payload: t
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
class g extends ie {
|
|
277
|
+
/**
|
|
278
|
+
* Creates an Image from a resource ID. For internal use only.
|
|
279
|
+
*
|
|
280
|
+
* @ignore
|
|
281
|
+
*/
|
|
282
|
+
constructor(e) {
|
|
283
|
+
super(e);
|
|
284
|
+
}
|
|
285
|
+
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
|
286
|
+
static async new(e, t, l) {
|
|
287
|
+
return n("plugin:image|new", {
|
|
288
|
+
rgba: m(e),
|
|
289
|
+
width: t,
|
|
290
|
+
height: l
|
|
291
|
+
}).then((s) => new g(s));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Creates a new image using the provided bytes by inferring the file format.
|
|
295
|
+
* If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
|
|
296
|
+
*
|
|
297
|
+
* Only `ico` and `png` are supported (based on activated feature flag).
|
|
298
|
+
*
|
|
299
|
+
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
|
300
|
+
* To enable it, change your Cargo.toml file:
|
|
301
|
+
* ```toml
|
|
302
|
+
* [dependencies]
|
|
303
|
+
* tauri = { version = "...", features = ["...", "image-png"] }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
static async fromBytes(e) {
|
|
307
|
+
return n("plugin:image|from_bytes", {
|
|
308
|
+
bytes: m(e)
|
|
309
|
+
}).then((t) => new g(t));
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Creates a new image using the provided path.
|
|
313
|
+
*
|
|
314
|
+
* Only `ico` and `png` are supported (based on activated feature flag).
|
|
315
|
+
*
|
|
316
|
+
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
|
317
|
+
* To enable it, change your Cargo.toml file:
|
|
318
|
+
* ```toml
|
|
319
|
+
* [dependencies]
|
|
320
|
+
* tauri = { version = "...", features = ["...", "image-png"] }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
static async fromPath(e) {
|
|
324
|
+
return n("plugin:image|from_path", { path: e }).then((t) => new g(t));
|
|
325
|
+
}
|
|
326
|
+
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
|
327
|
+
async rgba() {
|
|
328
|
+
return n("plugin:image|rgba", {
|
|
329
|
+
rid: this.rid
|
|
330
|
+
}).then((e) => new Uint8Array(e));
|
|
331
|
+
}
|
|
332
|
+
/** Returns the size of this image. */
|
|
333
|
+
async size() {
|
|
334
|
+
return n("plugin:image|size", { rid: this.rid });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function m(i) {
|
|
338
|
+
return i == null ? null : typeof i == "string" ? i : i instanceof g ? i.rid : i;
|
|
339
|
+
}
|
|
340
|
+
var x;
|
|
341
|
+
(function(i) {
|
|
342
|
+
i[i.Critical = 1] = "Critical", i[i.Informational = 2] = "Informational";
|
|
343
|
+
})(x || (x = {}));
|
|
344
|
+
class se {
|
|
345
|
+
constructor(e) {
|
|
346
|
+
this._preventDefault = !1, this.event = e.event, this.id = e.id;
|
|
347
|
+
}
|
|
348
|
+
preventDefault() {
|
|
349
|
+
this._preventDefault = !0;
|
|
350
|
+
}
|
|
351
|
+
isPreventDefault() {
|
|
352
|
+
return this._preventDefault;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
var k;
|
|
356
|
+
(function(i) {
|
|
357
|
+
i.None = "none", i.Normal = "normal", i.Indeterminate = "indeterminate", i.Paused = "paused", i.Error = "error";
|
|
358
|
+
})(k || (k = {}));
|
|
359
|
+
function B() {
|
|
360
|
+
return new M(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
361
|
+
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
362
|
+
skip: !0
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
async function z() {
|
|
366
|
+
return n("plugin:window|get_all_windows").then((i) => i.map((e) => new M(e, {
|
|
367
|
+
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
368
|
+
skip: !0
|
|
369
|
+
})));
|
|
370
|
+
}
|
|
371
|
+
const S = ["tauri://created", "tauri://error"];
|
|
372
|
+
class M {
|
|
373
|
+
/**
|
|
374
|
+
* Creates a new Window.
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* import { Window } from '@tauri-apps/api/window';
|
|
378
|
+
* const appWindow = new Window('my-label');
|
|
379
|
+
* appWindow.once('tauri://created', function () {
|
|
380
|
+
* // window successfully created
|
|
381
|
+
* });
|
|
382
|
+
* appWindow.once('tauri://error', function (e) {
|
|
383
|
+
* // an error happened creating the window
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @param label The unique window label. Must be alphanumeric: `a-zA-Z-/:_`.
|
|
388
|
+
* @returns The {@link Window} instance to communicate with the window.
|
|
389
|
+
*/
|
|
390
|
+
constructor(e, t = {}) {
|
|
391
|
+
var l;
|
|
392
|
+
this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), t?.skip || n("plugin:window|create", {
|
|
393
|
+
options: {
|
|
394
|
+
...t,
|
|
395
|
+
parent: typeof t.parent == "string" ? t.parent : (l = t.parent) === null || l === void 0 ? void 0 : l.label,
|
|
396
|
+
label: e
|
|
397
|
+
}
|
|
398
|
+
}).then(async () => this.emit("tauri://created")).catch(async (s) => this.emit("tauri://error", s));
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Gets the Window associated with the given label.
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* import { Window } from '@tauri-apps/api/window';
|
|
405
|
+
* const mainWindow = Window.getByLabel('main');
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @param label The window label.
|
|
409
|
+
* @returns The Window instance to communicate with the window or null if the window doesn't exist.
|
|
410
|
+
*/
|
|
411
|
+
static async getByLabel(e) {
|
|
412
|
+
var t;
|
|
413
|
+
return (t = (await z()).find((l) => l.label === e)) !== null && t !== void 0 ? t : null;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Get an instance of `Window` for the current window.
|
|
417
|
+
*/
|
|
418
|
+
static getCurrent() {
|
|
419
|
+
return B();
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Gets a list of instances of `Window` for all available windows.
|
|
423
|
+
*/
|
|
424
|
+
static async getAll() {
|
|
425
|
+
return z();
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Gets the focused window.
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* import { Window } from '@tauri-apps/api/window';
|
|
432
|
+
* const focusedWindow = Window.getFocusedWindow();
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
436
|
+
*/
|
|
437
|
+
static async getFocusedWindow() {
|
|
438
|
+
for (const e of await z())
|
|
439
|
+
if (await e.isFocused())
|
|
440
|
+
return e;
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Listen to an emitted event on this window.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
449
|
+
* const unlisten = await getCurrentWindow().listen<string>('state-changed', (event) => {
|
|
450
|
+
* console.log(`Got error: ${payload}`);
|
|
451
|
+
* });
|
|
452
|
+
*
|
|
453
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
454
|
+
* unlisten();
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
458
|
+
* @param handler Event handler.
|
|
459
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
460
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
461
|
+
*/
|
|
462
|
+
async listen(e, t) {
|
|
463
|
+
return this._handleTauriEvent(e, t) ? () => {
|
|
464
|
+
const l = this.listeners[e];
|
|
465
|
+
l.splice(l.indexOf(t), 1);
|
|
466
|
+
} : T(e, t, {
|
|
467
|
+
target: { kind: "Window", label: this.label }
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Listen to an emitted event on this window only once.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
476
|
+
* const unlisten = await getCurrentWindow().once<null>('initialized', (event) => {
|
|
477
|
+
* console.log(`Window initialized!`);
|
|
478
|
+
* });
|
|
479
|
+
*
|
|
480
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
481
|
+
* unlisten();
|
|
482
|
+
* ```
|
|
483
|
+
*
|
|
484
|
+
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
485
|
+
* @param handler Event handler.
|
|
486
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
487
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
488
|
+
*/
|
|
489
|
+
async once(e, t) {
|
|
490
|
+
return this._handleTauriEvent(e, t) ? () => {
|
|
491
|
+
const l = this.listeners[e];
|
|
492
|
+
l.splice(l.indexOf(t), 1);
|
|
493
|
+
} : te(e, t, {
|
|
494
|
+
target: { kind: "Window", label: this.label }
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Emits an event to all {@link EventTarget|targets}.
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
502
|
+
* await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
506
|
+
* @param payload Event payload.
|
|
507
|
+
*/
|
|
508
|
+
async emit(e, t) {
|
|
509
|
+
if (S.includes(e)) {
|
|
510
|
+
for (const l of this.listeners[e] || [])
|
|
511
|
+
l({
|
|
512
|
+
event: e,
|
|
513
|
+
id: -1,
|
|
514
|
+
payload: t
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
return ne(e, t);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
526
|
+
* await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });
|
|
527
|
+
* ```
|
|
528
|
+
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
|
529
|
+
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
530
|
+
* @param payload Event payload.
|
|
531
|
+
*/
|
|
532
|
+
async emitTo(e, t, l) {
|
|
533
|
+
if (S.includes(t)) {
|
|
534
|
+
for (const s of this.listeners[t] || [])
|
|
535
|
+
s({
|
|
536
|
+
event: t,
|
|
537
|
+
id: -1,
|
|
538
|
+
payload: l
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
return le(e, t, l);
|
|
543
|
+
}
|
|
544
|
+
/** @ignore */
|
|
545
|
+
_handleTauriEvent(e, t) {
|
|
546
|
+
return S.includes(e) ? (e in this.listeners ? this.listeners[e].push(t) : this.listeners[e] = [t], !0) : !1;
|
|
547
|
+
}
|
|
548
|
+
// Getters
|
|
549
|
+
/**
|
|
550
|
+
* The scale factor that can be used to map physical pixels to logical pixels.
|
|
551
|
+
* @example
|
|
552
|
+
* ```typescript
|
|
553
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
554
|
+
* const factor = await getCurrentWindow().scaleFactor();
|
|
555
|
+
* ```
|
|
556
|
+
*
|
|
557
|
+
* @returns The window's monitor scale factor.
|
|
558
|
+
*/
|
|
559
|
+
async scaleFactor() {
|
|
560
|
+
return n("plugin:window|scale_factor", {
|
|
561
|
+
label: this.label
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
569
|
+
* const position = await getCurrentWindow().innerPosition();
|
|
570
|
+
* ```
|
|
571
|
+
*
|
|
572
|
+
* @returns The window's inner position.
|
|
573
|
+
*/
|
|
574
|
+
async innerPosition() {
|
|
575
|
+
return n("plugin:window|inner_position", {
|
|
576
|
+
label: this.label
|
|
577
|
+
}).then((e) => new c(e));
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
|
|
581
|
+
* @example
|
|
582
|
+
* ```typescript
|
|
583
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
584
|
+
* const position = await getCurrentWindow().outerPosition();
|
|
585
|
+
* ```
|
|
586
|
+
*
|
|
587
|
+
* @returns The window's outer position.
|
|
588
|
+
*/
|
|
589
|
+
async outerPosition() {
|
|
590
|
+
return n("plugin:window|outer_position", {
|
|
591
|
+
label: this.label
|
|
592
|
+
}).then((e) => new c(e));
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* The physical size of the window's client area.
|
|
596
|
+
* The client area is the content of the window, excluding the title bar and borders.
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
600
|
+
* const size = await getCurrentWindow().innerSize();
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @returns The window's inner size.
|
|
604
|
+
*/
|
|
605
|
+
async innerSize() {
|
|
606
|
+
return n("plugin:window|inner_size", {
|
|
607
|
+
label: this.label
|
|
608
|
+
}).then((e) => new b(e));
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The physical size of the entire window.
|
|
612
|
+
* These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
|
|
613
|
+
* @example
|
|
614
|
+
* ```typescript
|
|
615
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
616
|
+
* const size = await getCurrentWindow().outerSize();
|
|
617
|
+
* ```
|
|
618
|
+
*
|
|
619
|
+
* @returns The window's outer size.
|
|
620
|
+
*/
|
|
621
|
+
async outerSize() {
|
|
622
|
+
return n("plugin:window|outer_size", {
|
|
623
|
+
label: this.label
|
|
624
|
+
}).then((e) => new b(e));
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Gets the window's current fullscreen state.
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
631
|
+
* const fullscreen = await getCurrentWindow().isFullscreen();
|
|
632
|
+
* ```
|
|
633
|
+
*
|
|
634
|
+
* @returns Whether the window is in fullscreen mode or not.
|
|
635
|
+
*/
|
|
636
|
+
async isFullscreen() {
|
|
637
|
+
return n("plugin:window|is_fullscreen", {
|
|
638
|
+
label: this.label
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Gets the window's current minimized state.
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
646
|
+
* const minimized = await getCurrentWindow().isMinimized();
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
649
|
+
async isMinimized() {
|
|
650
|
+
return n("plugin:window|is_minimized", {
|
|
651
|
+
label: this.label
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Gets the window's current maximized state.
|
|
656
|
+
* @example
|
|
657
|
+
* ```typescript
|
|
658
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
659
|
+
* const maximized = await getCurrentWindow().isMaximized();
|
|
660
|
+
* ```
|
|
661
|
+
*
|
|
662
|
+
* @returns Whether the window is maximized or not.
|
|
663
|
+
*/
|
|
664
|
+
async isMaximized() {
|
|
665
|
+
return n("plugin:window|is_maximized", {
|
|
666
|
+
label: this.label
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Gets the window's current focus state.
|
|
671
|
+
* @example
|
|
672
|
+
* ```typescript
|
|
673
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
674
|
+
* const focused = await getCurrentWindow().isFocused();
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @returns Whether the window is focused or not.
|
|
678
|
+
*/
|
|
679
|
+
async isFocused() {
|
|
680
|
+
return n("plugin:window|is_focused", {
|
|
681
|
+
label: this.label
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Gets the window's current decorated state.
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
689
|
+
* const decorated = await getCurrentWindow().isDecorated();
|
|
690
|
+
* ```
|
|
691
|
+
*
|
|
692
|
+
* @returns Whether the window is decorated or not.
|
|
693
|
+
*/
|
|
694
|
+
async isDecorated() {
|
|
695
|
+
return n("plugin:window|is_decorated", {
|
|
696
|
+
label: this.label
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Gets the window's current resizable state.
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
704
|
+
* const resizable = await getCurrentWindow().isResizable();
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @returns Whether the window is resizable or not.
|
|
708
|
+
*/
|
|
709
|
+
async isResizable() {
|
|
710
|
+
return n("plugin:window|is_resizable", {
|
|
711
|
+
label: this.label
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Gets the window's native maximize button state.
|
|
716
|
+
*
|
|
717
|
+
* #### Platform-specific
|
|
718
|
+
*
|
|
719
|
+
* - **Linux / iOS / Android:** Unsupported.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```typescript
|
|
723
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
724
|
+
* const maximizable = await getCurrentWindow().isMaximizable();
|
|
725
|
+
* ```
|
|
726
|
+
*
|
|
727
|
+
* @returns Whether the window's native maximize button is enabled or not.
|
|
728
|
+
*/
|
|
729
|
+
async isMaximizable() {
|
|
730
|
+
return n("plugin:window|is_maximizable", {
|
|
731
|
+
label: this.label
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Gets the window's native minimize button state.
|
|
736
|
+
*
|
|
737
|
+
* #### Platform-specific
|
|
738
|
+
*
|
|
739
|
+
* - **Linux / iOS / Android:** Unsupported.
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```typescript
|
|
743
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
744
|
+
* const minimizable = await getCurrentWindow().isMinimizable();
|
|
745
|
+
* ```
|
|
746
|
+
*
|
|
747
|
+
* @returns Whether the window's native minimize button is enabled or not.
|
|
748
|
+
*/
|
|
749
|
+
async isMinimizable() {
|
|
750
|
+
return n("plugin:window|is_minimizable", {
|
|
751
|
+
label: this.label
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Gets the window's native close button state.
|
|
756
|
+
*
|
|
757
|
+
* #### Platform-specific
|
|
758
|
+
*
|
|
759
|
+
* - **iOS / Android:** Unsupported.
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```typescript
|
|
763
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
764
|
+
* const closable = await getCurrentWindow().isClosable();
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* @returns Whether the window's native close button is enabled or not.
|
|
768
|
+
*/
|
|
769
|
+
async isClosable() {
|
|
770
|
+
return n("plugin:window|is_closable", {
|
|
771
|
+
label: this.label
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Gets the window's current visible state.
|
|
776
|
+
* @example
|
|
777
|
+
* ```typescript
|
|
778
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
779
|
+
* const visible = await getCurrentWindow().isVisible();
|
|
780
|
+
* ```
|
|
781
|
+
*
|
|
782
|
+
* @returns Whether the window is visible or not.
|
|
783
|
+
*/
|
|
784
|
+
async isVisible() {
|
|
785
|
+
return n("plugin:window|is_visible", {
|
|
786
|
+
label: this.label
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Gets the window's current title.
|
|
791
|
+
* @example
|
|
792
|
+
* ```typescript
|
|
793
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
794
|
+
* const title = await getCurrentWindow().title();
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
async title() {
|
|
798
|
+
return n("plugin:window|title", {
|
|
799
|
+
label: this.label
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Gets the window's current theme.
|
|
804
|
+
*
|
|
805
|
+
* #### Platform-specific
|
|
806
|
+
*
|
|
807
|
+
* - **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* ```typescript
|
|
811
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
812
|
+
* const theme = await getCurrentWindow().theme();
|
|
813
|
+
* ```
|
|
814
|
+
*
|
|
815
|
+
* @returns The window theme.
|
|
816
|
+
*/
|
|
817
|
+
async theme() {
|
|
818
|
+
return n("plugin:window|theme", {
|
|
819
|
+
label: this.label
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Whether the window is configured to be always on top of other windows or not.
|
|
824
|
+
* @example
|
|
825
|
+
* ```typescript
|
|
826
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
827
|
+
* const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop();
|
|
828
|
+
* ```
|
|
829
|
+
*
|
|
830
|
+
* @returns Whether the window is visible or not.
|
|
831
|
+
*/
|
|
832
|
+
async isAlwaysOnTop() {
|
|
833
|
+
return n("plugin:window|is_always_on_top", {
|
|
834
|
+
label: this.label
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
// Setters
|
|
838
|
+
/**
|
|
839
|
+
* Centers the window.
|
|
840
|
+
* @example
|
|
841
|
+
* ```typescript
|
|
842
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
843
|
+
* await getCurrentWindow().center();
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
847
|
+
*/
|
|
848
|
+
async center() {
|
|
849
|
+
return n("plugin:window|center", {
|
|
850
|
+
label: this.label
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Requests user attention to the window, this has no effect if the application
|
|
855
|
+
* is already focused. How requesting for user attention manifests is platform dependent,
|
|
856
|
+
* see `UserAttentionType` for details.
|
|
857
|
+
*
|
|
858
|
+
* Providing `null` will unset the request for user attention. Unsetting the request for
|
|
859
|
+
* user attention might not be done automatically by the WM when the window receives input.
|
|
860
|
+
*
|
|
861
|
+
* #### Platform-specific
|
|
862
|
+
*
|
|
863
|
+
* - **macOS:** `null` has no effect.
|
|
864
|
+
* - **Linux:** Urgency levels have the same effect.
|
|
865
|
+
* @example
|
|
866
|
+
* ```typescript
|
|
867
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
868
|
+
* await getCurrentWindow().requestUserAttention();
|
|
869
|
+
* ```
|
|
870
|
+
*
|
|
871
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
872
|
+
*/
|
|
873
|
+
async requestUserAttention(e) {
|
|
874
|
+
let t = null;
|
|
875
|
+
return e && (e === x.Critical ? t = { type: "Critical" } : t = { type: "Informational" }), n("plugin:window|request_user_attention", {
|
|
876
|
+
label: this.label,
|
|
877
|
+
value: t
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Updates the window resizable flag.
|
|
882
|
+
* @example
|
|
883
|
+
* ```typescript
|
|
884
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
885
|
+
* await getCurrentWindow().setResizable(false);
|
|
886
|
+
* ```
|
|
887
|
+
*
|
|
888
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
889
|
+
*/
|
|
890
|
+
async setResizable(e) {
|
|
891
|
+
return n("plugin:window|set_resizable", {
|
|
892
|
+
label: this.label,
|
|
893
|
+
value: e
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Enable or disable the window.
|
|
898
|
+
* @example
|
|
899
|
+
* ```typescript
|
|
900
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
901
|
+
* await getCurrentWindow().setEnabled(false);
|
|
902
|
+
* ```
|
|
903
|
+
*
|
|
904
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
905
|
+
*
|
|
906
|
+
* @since 2.0.0
|
|
907
|
+
*/
|
|
908
|
+
async setEnabled(e) {
|
|
909
|
+
return n("plugin:window|set_enabled", {
|
|
910
|
+
label: this.label,
|
|
911
|
+
value: e
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Whether the window is enabled or disabled.
|
|
916
|
+
* @example
|
|
917
|
+
* ```typescript
|
|
918
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
919
|
+
* await getCurrentWindow().setEnabled(false);
|
|
920
|
+
* ```
|
|
921
|
+
*
|
|
922
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
923
|
+
*
|
|
924
|
+
* @since 2.0.0
|
|
925
|
+
*/
|
|
926
|
+
async isEnabled() {
|
|
927
|
+
return n("plugin:window|is_enabled", {
|
|
928
|
+
label: this.label
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Sets whether the window's native maximize button is enabled or not.
|
|
933
|
+
* If resizable is set to false, this setting is ignored.
|
|
934
|
+
*
|
|
935
|
+
* #### Platform-specific
|
|
936
|
+
*
|
|
937
|
+
* - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
|
|
938
|
+
* - **Linux / iOS / Android:** Unsupported.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```typescript
|
|
942
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
943
|
+
* await getCurrentWindow().setMaximizable(false);
|
|
944
|
+
* ```
|
|
945
|
+
*
|
|
946
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
947
|
+
*/
|
|
948
|
+
async setMaximizable(e) {
|
|
949
|
+
return n("plugin:window|set_maximizable", {
|
|
950
|
+
label: this.label,
|
|
951
|
+
value: e
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Sets whether the window's native minimize button is enabled or not.
|
|
956
|
+
*
|
|
957
|
+
* #### Platform-specific
|
|
958
|
+
*
|
|
959
|
+
* - **Linux / iOS / Android:** Unsupported.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* ```typescript
|
|
963
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
964
|
+
* await getCurrentWindow().setMinimizable(false);
|
|
965
|
+
* ```
|
|
966
|
+
*
|
|
967
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
968
|
+
*/
|
|
969
|
+
async setMinimizable(e) {
|
|
970
|
+
return n("plugin:window|set_minimizable", {
|
|
971
|
+
label: this.label,
|
|
972
|
+
value: e
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Sets whether the window's native close button is enabled or not.
|
|
977
|
+
*
|
|
978
|
+
* #### Platform-specific
|
|
979
|
+
*
|
|
980
|
+
* - **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
|
|
981
|
+
* - **iOS / Android:** Unsupported.
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* ```typescript
|
|
985
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
986
|
+
* await getCurrentWindow().setClosable(false);
|
|
987
|
+
* ```
|
|
988
|
+
*
|
|
989
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
990
|
+
*/
|
|
991
|
+
async setClosable(e) {
|
|
992
|
+
return n("plugin:window|set_closable", {
|
|
993
|
+
label: this.label,
|
|
994
|
+
value: e
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Sets the window title.
|
|
999
|
+
* @example
|
|
1000
|
+
* ```typescript
|
|
1001
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1002
|
+
* await getCurrentWindow().setTitle('Tauri');
|
|
1003
|
+
* ```
|
|
1004
|
+
*
|
|
1005
|
+
* @param title The new title
|
|
1006
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1007
|
+
*/
|
|
1008
|
+
async setTitle(e) {
|
|
1009
|
+
return n("plugin:window|set_title", {
|
|
1010
|
+
label: this.label,
|
|
1011
|
+
value: e
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Maximizes the window.
|
|
1016
|
+
* @example
|
|
1017
|
+
* ```typescript
|
|
1018
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1019
|
+
* await getCurrentWindow().maximize();
|
|
1020
|
+
* ```
|
|
1021
|
+
*
|
|
1022
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1023
|
+
*/
|
|
1024
|
+
async maximize() {
|
|
1025
|
+
return n("plugin:window|maximize", {
|
|
1026
|
+
label: this.label
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Unmaximizes the window.
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1034
|
+
* await getCurrentWindow().unmaximize();
|
|
1035
|
+
* ```
|
|
1036
|
+
*
|
|
1037
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1038
|
+
*/
|
|
1039
|
+
async unmaximize() {
|
|
1040
|
+
return n("plugin:window|unmaximize", {
|
|
1041
|
+
label: this.label
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Toggles the window maximized state.
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```typescript
|
|
1048
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1049
|
+
* await getCurrentWindow().toggleMaximize();
|
|
1050
|
+
* ```
|
|
1051
|
+
*
|
|
1052
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1053
|
+
*/
|
|
1054
|
+
async toggleMaximize() {
|
|
1055
|
+
return n("plugin:window|toggle_maximize", {
|
|
1056
|
+
label: this.label
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Minimizes the window.
|
|
1061
|
+
* @example
|
|
1062
|
+
* ```typescript
|
|
1063
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1064
|
+
* await getCurrentWindow().minimize();
|
|
1065
|
+
* ```
|
|
1066
|
+
*
|
|
1067
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1068
|
+
*/
|
|
1069
|
+
async minimize() {
|
|
1070
|
+
return n("plugin:window|minimize", {
|
|
1071
|
+
label: this.label
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Unminimizes the window.
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```typescript
|
|
1078
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1079
|
+
* await getCurrentWindow().unminimize();
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1083
|
+
*/
|
|
1084
|
+
async unminimize() {
|
|
1085
|
+
return n("plugin:window|unminimize", {
|
|
1086
|
+
label: this.label
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Sets the window visibility to true.
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```typescript
|
|
1093
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1094
|
+
* await getCurrentWindow().show();
|
|
1095
|
+
* ```
|
|
1096
|
+
*
|
|
1097
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1098
|
+
*/
|
|
1099
|
+
async show() {
|
|
1100
|
+
return n("plugin:window|show", {
|
|
1101
|
+
label: this.label
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Sets the window visibility to false.
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```typescript
|
|
1108
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1109
|
+
* await getCurrentWindow().hide();
|
|
1110
|
+
* ```
|
|
1111
|
+
*
|
|
1112
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1113
|
+
*/
|
|
1114
|
+
async hide() {
|
|
1115
|
+
return n("plugin:window|hide", {
|
|
1116
|
+
label: this.label
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Closes the window.
|
|
1121
|
+
*
|
|
1122
|
+
* Note this emits a closeRequested event so you can intercept it. To force window close, use {@link Window.destroy}.
|
|
1123
|
+
* @example
|
|
1124
|
+
* ```typescript
|
|
1125
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1126
|
+
* await getCurrentWindow().close();
|
|
1127
|
+
* ```
|
|
1128
|
+
*
|
|
1129
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1130
|
+
*/
|
|
1131
|
+
async close() {
|
|
1132
|
+
return n("plugin:window|close", {
|
|
1133
|
+
label: this.label
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Destroys the window. Behaves like {@link Window.close} but forces the window close instead of emitting a closeRequested event.
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```typescript
|
|
1140
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1141
|
+
* await getCurrentWindow().destroy();
|
|
1142
|
+
* ```
|
|
1143
|
+
*
|
|
1144
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1145
|
+
*/
|
|
1146
|
+
async destroy() {
|
|
1147
|
+
return n("plugin:window|destroy", {
|
|
1148
|
+
label: this.label
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Whether the window should have borders and bars.
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1156
|
+
* await getCurrentWindow().setDecorations(false);
|
|
1157
|
+
* ```
|
|
1158
|
+
*
|
|
1159
|
+
* @param decorations Whether the window should have borders and bars.
|
|
1160
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1161
|
+
*/
|
|
1162
|
+
async setDecorations(e) {
|
|
1163
|
+
return n("plugin:window|set_decorations", {
|
|
1164
|
+
label: this.label,
|
|
1165
|
+
value: e
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Whether or not the window should have shadow.
|
|
1170
|
+
*
|
|
1171
|
+
* #### Platform-specific
|
|
1172
|
+
*
|
|
1173
|
+
* - **Windows:**
|
|
1174
|
+
* - `false` has no effect on decorated window, shadows are always ON.
|
|
1175
|
+
* - `true` will make undecorated window have a 1px white border,
|
|
1176
|
+
* and on Windows 11, it will have a rounded corners.
|
|
1177
|
+
* - **Linux:** Unsupported.
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* ```typescript
|
|
1181
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1182
|
+
* await getCurrentWindow().setShadow(false);
|
|
1183
|
+
* ```
|
|
1184
|
+
*
|
|
1185
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1186
|
+
*/
|
|
1187
|
+
async setShadow(e) {
|
|
1188
|
+
return n("plugin:window|set_shadow", {
|
|
1189
|
+
label: this.label,
|
|
1190
|
+
value: e
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Set window effects.
|
|
1195
|
+
*/
|
|
1196
|
+
async setEffects(e) {
|
|
1197
|
+
return n("plugin:window|set_effects", {
|
|
1198
|
+
label: this.label,
|
|
1199
|
+
value: e
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Clear any applied effects if possible.
|
|
1204
|
+
*/
|
|
1205
|
+
async clearEffects() {
|
|
1206
|
+
return n("plugin:window|set_effects", {
|
|
1207
|
+
label: this.label,
|
|
1208
|
+
value: null
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Whether the window should always be on top of other windows.
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```typescript
|
|
1215
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1216
|
+
* await getCurrentWindow().setAlwaysOnTop(true);
|
|
1217
|
+
* ```
|
|
1218
|
+
*
|
|
1219
|
+
* @param alwaysOnTop Whether the window should always be on top of other windows or not.
|
|
1220
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1221
|
+
*/
|
|
1222
|
+
async setAlwaysOnTop(e) {
|
|
1223
|
+
return n("plugin:window|set_always_on_top", {
|
|
1224
|
+
label: this.label,
|
|
1225
|
+
value: e
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Whether the window should always be below other windows.
|
|
1230
|
+
* @example
|
|
1231
|
+
* ```typescript
|
|
1232
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1233
|
+
* await getCurrentWindow().setAlwaysOnBottom(true);
|
|
1234
|
+
* ```
|
|
1235
|
+
*
|
|
1236
|
+
* @param alwaysOnBottom Whether the window should always be below other windows or not.
|
|
1237
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1238
|
+
*/
|
|
1239
|
+
async setAlwaysOnBottom(e) {
|
|
1240
|
+
return n("plugin:window|set_always_on_bottom", {
|
|
1241
|
+
label: this.label,
|
|
1242
|
+
value: e
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Prevents the window contents from being captured by other apps.
|
|
1247
|
+
* @example
|
|
1248
|
+
* ```typescript
|
|
1249
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1250
|
+
* await getCurrentWindow().setContentProtected(true);
|
|
1251
|
+
* ```
|
|
1252
|
+
*
|
|
1253
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1254
|
+
*/
|
|
1255
|
+
async setContentProtected(e) {
|
|
1256
|
+
return n("plugin:window|set_content_protected", {
|
|
1257
|
+
label: this.label,
|
|
1258
|
+
value: e
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Resizes the window with a new inner size.
|
|
1263
|
+
* @example
|
|
1264
|
+
* ```typescript
|
|
1265
|
+
* import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
|
1266
|
+
* await getCurrentWindow().setSize(new LogicalSize(600, 500));
|
|
1267
|
+
* ```
|
|
1268
|
+
*
|
|
1269
|
+
* @param size The logical or physical inner size.
|
|
1270
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1271
|
+
*/
|
|
1272
|
+
async setSize(e) {
|
|
1273
|
+
return n("plugin:window|set_size", {
|
|
1274
|
+
label: this.label,
|
|
1275
|
+
value: e instanceof w ? e : new w(e)
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```typescript
|
|
1282
|
+
* import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
|
|
1283
|
+
* await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));
|
|
1284
|
+
* ```
|
|
1285
|
+
*
|
|
1286
|
+
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
|
1287
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1288
|
+
*/
|
|
1289
|
+
async setMinSize(e) {
|
|
1290
|
+
return n("plugin:window|set_min_size", {
|
|
1291
|
+
label: this.label,
|
|
1292
|
+
value: e instanceof w ? e : e ? new w(e) : null
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
|
1300
|
+
* await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));
|
|
1301
|
+
* ```
|
|
1302
|
+
*
|
|
1303
|
+
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
|
1304
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1305
|
+
*/
|
|
1306
|
+
async setMaxSize(e) {
|
|
1307
|
+
return n("plugin:window|set_max_size", {
|
|
1308
|
+
label: this.label,
|
|
1309
|
+
value: e instanceof w ? e : e ? new w(e) : null
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Sets the window inner size constraints.
|
|
1314
|
+
* @example
|
|
1315
|
+
* ```typescript
|
|
1316
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1317
|
+
* await getCurrentWindow().setSizeConstraints({ minWidth: 300 });
|
|
1318
|
+
* ```
|
|
1319
|
+
*
|
|
1320
|
+
* @param constraints The logical or physical inner size, or `null` to unset the constraint.
|
|
1321
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1322
|
+
*/
|
|
1323
|
+
async setSizeConstraints(e) {
|
|
1324
|
+
function t(l) {
|
|
1325
|
+
return l ? { Logical: l } : null;
|
|
1326
|
+
}
|
|
1327
|
+
return n("plugin:window|set_size_constraints", {
|
|
1328
|
+
label: this.label,
|
|
1329
|
+
value: {
|
|
1330
|
+
minWidth: t(e?.minWidth),
|
|
1331
|
+
minHeight: t(e?.minHeight),
|
|
1332
|
+
maxWidth: t(e?.maxWidth),
|
|
1333
|
+
maxHeight: t(e?.maxHeight)
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Sets the window outer position.
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
|
1342
|
+
* await getCurrentWindow().setPosition(new LogicalPosition(600, 500));
|
|
1343
|
+
* ```
|
|
1344
|
+
*
|
|
1345
|
+
* @param position The new position, in logical or physical pixels.
|
|
1346
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1347
|
+
*/
|
|
1348
|
+
async setPosition(e) {
|
|
1349
|
+
return n("plugin:window|set_position", {
|
|
1350
|
+
label: this.label,
|
|
1351
|
+
value: e instanceof _ ? e : new _(e)
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Sets the window fullscreen state.
|
|
1356
|
+
* @example
|
|
1357
|
+
* ```typescript
|
|
1358
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1359
|
+
* await getCurrentWindow().setFullscreen(true);
|
|
1360
|
+
* ```
|
|
1361
|
+
*
|
|
1362
|
+
* @param fullscreen Whether the window should go to fullscreen or not.
|
|
1363
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1364
|
+
*/
|
|
1365
|
+
async setFullscreen(e) {
|
|
1366
|
+
return n("plugin:window|set_fullscreen", {
|
|
1367
|
+
label: this.label,
|
|
1368
|
+
value: e
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* 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).
|
|
1373
|
+
* 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.
|
|
1374
|
+
*
|
|
1375
|
+
* On other platforms, this is the same as {@link Window.setFullscreen}.
|
|
1376
|
+
*
|
|
1377
|
+
* @param fullscreen Whether the window should go to simple fullscreen or not.
|
|
1378
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1379
|
+
*/
|
|
1380
|
+
async setSimpleFullscreen(e) {
|
|
1381
|
+
return n("plugin:window|set_simple_fullscreen", {
|
|
1382
|
+
label: this.label,
|
|
1383
|
+
value: e
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Bring the window to front and focus.
|
|
1388
|
+
* @example
|
|
1389
|
+
* ```typescript
|
|
1390
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1391
|
+
* await getCurrentWindow().setFocus();
|
|
1392
|
+
* ```
|
|
1393
|
+
*
|
|
1394
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1395
|
+
*/
|
|
1396
|
+
async setFocus() {
|
|
1397
|
+
return n("plugin:window|set_focus", {
|
|
1398
|
+
label: this.label
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Sets whether the window can be focused.
|
|
1403
|
+
*
|
|
1404
|
+
* #### Platform-specific
|
|
1405
|
+
*
|
|
1406
|
+
* - **macOS**: If the window is already focused, it is not possible to unfocus it after calling `set_focusable(false)`.
|
|
1407
|
+
* 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.
|
|
1408
|
+
*
|
|
1409
|
+
* @example
|
|
1410
|
+
* ```typescript
|
|
1411
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1412
|
+
* await getCurrentWindow().setFocusable(true);
|
|
1413
|
+
* ```
|
|
1414
|
+
*
|
|
1415
|
+
* @param focusable Whether the window can be focused.
|
|
1416
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1417
|
+
*/
|
|
1418
|
+
async setFocusable(e) {
|
|
1419
|
+
return n("plugin:window|set_focusable", {
|
|
1420
|
+
label: this.label,
|
|
1421
|
+
value: e
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Sets the window icon.
|
|
1426
|
+
* @example
|
|
1427
|
+
* ```typescript
|
|
1428
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1429
|
+
* await getCurrentWindow().setIcon('/tauri/awesome.png');
|
|
1430
|
+
* ```
|
|
1431
|
+
*
|
|
1432
|
+
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
|
1433
|
+
* To enable it, change your Cargo.toml file:
|
|
1434
|
+
* ```toml
|
|
1435
|
+
* [dependencies]
|
|
1436
|
+
* tauri = { version = "...", features = ["...", "image-png"] }
|
|
1437
|
+
* ```
|
|
1438
|
+
*
|
|
1439
|
+
* @param icon Icon bytes or path to the icon file.
|
|
1440
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1441
|
+
*/
|
|
1442
|
+
async setIcon(e) {
|
|
1443
|
+
return n("plugin:window|set_icon", {
|
|
1444
|
+
label: this.label,
|
|
1445
|
+
value: m(e)
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Whether the window icon should be hidden from the taskbar or not.
|
|
1450
|
+
*
|
|
1451
|
+
* #### Platform-specific
|
|
1452
|
+
*
|
|
1453
|
+
* - **macOS:** Unsupported.
|
|
1454
|
+
* @example
|
|
1455
|
+
* ```typescript
|
|
1456
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1457
|
+
* await getCurrentWindow().setSkipTaskbar(true);
|
|
1458
|
+
* ```
|
|
1459
|
+
*
|
|
1460
|
+
* @param skip true to hide window icon, false to show it.
|
|
1461
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1462
|
+
*/
|
|
1463
|
+
async setSkipTaskbar(e) {
|
|
1464
|
+
return n("plugin:window|set_skip_taskbar", {
|
|
1465
|
+
label: this.label,
|
|
1466
|
+
value: e
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Grabs the cursor, preventing it from leaving the window.
|
|
1471
|
+
*
|
|
1472
|
+
* There's no guarantee that the cursor will be hidden. You should
|
|
1473
|
+
* hide it by yourself if you want so.
|
|
1474
|
+
*
|
|
1475
|
+
* #### Platform-specific
|
|
1476
|
+
*
|
|
1477
|
+
* - **Linux:** Unsupported.
|
|
1478
|
+
* - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
|
|
1479
|
+
* @example
|
|
1480
|
+
* ```typescript
|
|
1481
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1482
|
+
* await getCurrentWindow().setCursorGrab(true);
|
|
1483
|
+
* ```
|
|
1484
|
+
*
|
|
1485
|
+
* @param grab `true` to grab the cursor icon, `false` to release it.
|
|
1486
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1487
|
+
*/
|
|
1488
|
+
async setCursorGrab(e) {
|
|
1489
|
+
return n("plugin:window|set_cursor_grab", {
|
|
1490
|
+
label: this.label,
|
|
1491
|
+
value: e
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Modifies the cursor's visibility.
|
|
1496
|
+
*
|
|
1497
|
+
* #### Platform-specific
|
|
1498
|
+
*
|
|
1499
|
+
* - **Windows:** The cursor is only hidden within the confines of the window.
|
|
1500
|
+
* - **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is
|
|
1501
|
+
* outside of the window.
|
|
1502
|
+
* @example
|
|
1503
|
+
* ```typescript
|
|
1504
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1505
|
+
* await getCurrentWindow().setCursorVisible(false);
|
|
1506
|
+
* ```
|
|
1507
|
+
*
|
|
1508
|
+
* @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
|
|
1509
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1510
|
+
*/
|
|
1511
|
+
async setCursorVisible(e) {
|
|
1512
|
+
return n("plugin:window|set_cursor_visible", {
|
|
1513
|
+
label: this.label,
|
|
1514
|
+
value: e
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Modifies the cursor icon of the window.
|
|
1519
|
+
* @example
|
|
1520
|
+
* ```typescript
|
|
1521
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1522
|
+
* await getCurrentWindow().setCursorIcon('help');
|
|
1523
|
+
* ```
|
|
1524
|
+
*
|
|
1525
|
+
* @param icon The new cursor icon.
|
|
1526
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1527
|
+
*/
|
|
1528
|
+
async setCursorIcon(e) {
|
|
1529
|
+
return n("plugin:window|set_cursor_icon", {
|
|
1530
|
+
label: this.label,
|
|
1531
|
+
value: e
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Sets the window background color.
|
|
1536
|
+
*
|
|
1537
|
+
* #### Platform-specific:
|
|
1538
|
+
*
|
|
1539
|
+
* - **Windows:** alpha channel is ignored.
|
|
1540
|
+
* - **iOS / Android:** Unsupported.
|
|
1541
|
+
*
|
|
1542
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1543
|
+
*
|
|
1544
|
+
* @since 2.1.0
|
|
1545
|
+
*/
|
|
1546
|
+
async setBackgroundColor(e) {
|
|
1547
|
+
return n("plugin:window|set_background_color", { color: e });
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Changes the position of the cursor in window coordinates.
|
|
1551
|
+
* @example
|
|
1552
|
+
* ```typescript
|
|
1553
|
+
* import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
|
1554
|
+
* await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));
|
|
1555
|
+
* ```
|
|
1556
|
+
*
|
|
1557
|
+
* @param position The new cursor position.
|
|
1558
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1559
|
+
*/
|
|
1560
|
+
async setCursorPosition(e) {
|
|
1561
|
+
return n("plugin:window|set_cursor_position", {
|
|
1562
|
+
label: this.label,
|
|
1563
|
+
value: e instanceof _ ? e : new _(e)
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Changes the cursor events behavior.
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```typescript
|
|
1571
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1572
|
+
* await getCurrentWindow().setIgnoreCursorEvents(true);
|
|
1573
|
+
* ```
|
|
1574
|
+
*
|
|
1575
|
+
* @param ignore `true` to ignore the cursor events; `false` to process them as usual.
|
|
1576
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
1577
|
+
*/
|
|
1578
|
+
async setIgnoreCursorEvents(e) {
|
|
1579
|
+
return n("plugin:window|set_ignore_cursor_events", {
|
|
1580
|
+
label: this.label,
|
|
1581
|
+
value: e
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Starts dragging the window.
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```typescript
|
|
1588
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1589
|
+
* await getCurrentWindow().startDragging();
|
|
1590
|
+
* ```
|
|
1591
|
+
*
|
|
1592
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1593
|
+
*/
|
|
1594
|
+
async startDragging() {
|
|
1595
|
+
return n("plugin:window|start_dragging", {
|
|
1596
|
+
label: this.label
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Starts resize-dragging the window.
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```typescript
|
|
1603
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1604
|
+
* await getCurrentWindow().startResizeDragging();
|
|
1605
|
+
* ```
|
|
1606
|
+
*
|
|
1607
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1608
|
+
*/
|
|
1609
|
+
async startResizeDragging(e) {
|
|
1610
|
+
return n("plugin:window|start_resize_dragging", {
|
|
1611
|
+
label: this.label,
|
|
1612
|
+
value: e
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Sets the badge count. It is app wide and not specific to this window.
|
|
1617
|
+
*
|
|
1618
|
+
* #### Platform-specific
|
|
1619
|
+
*
|
|
1620
|
+
* - **Windows**: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```typescript
|
|
1624
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1625
|
+
* await getCurrentWindow().setBadgeCount(5);
|
|
1626
|
+
* ```
|
|
1627
|
+
*
|
|
1628
|
+
* @param count The badge count. Use `undefined` to remove the badge.
|
|
1629
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1630
|
+
*/
|
|
1631
|
+
async setBadgeCount(e) {
|
|
1632
|
+
return n("plugin:window|set_badge_count", {
|
|
1633
|
+
label: this.label,
|
|
1634
|
+
value: e
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Sets the badge cont **macOS only**.
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1643
|
+
* await getCurrentWindow().setBadgeLabel("Hello");
|
|
1644
|
+
* ```
|
|
1645
|
+
*
|
|
1646
|
+
* @param label The badge label. Use `undefined` to remove the badge.
|
|
1647
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1648
|
+
*/
|
|
1649
|
+
async setBadgeLabel(e) {
|
|
1650
|
+
return n("plugin:window|set_badge_label", {
|
|
1651
|
+
label: this.label,
|
|
1652
|
+
value: e
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Sets the overlay icon. **Windows only**
|
|
1657
|
+
* The overlay icon can be set for every window.
|
|
1658
|
+
*
|
|
1659
|
+
*
|
|
1660
|
+
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
|
1661
|
+
* To enable it, change your Cargo.toml file:
|
|
1662
|
+
*
|
|
1663
|
+
* ```toml
|
|
1664
|
+
* [dependencies]
|
|
1665
|
+
* tauri = { version = "...", features = ["...", "image-png"] }
|
|
1666
|
+
* ```
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* ```typescript
|
|
1670
|
+
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
1671
|
+
* await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");
|
|
1672
|
+
* ```
|
|
1673
|
+
*
|
|
1674
|
+
* @param icon Icon bytes or path to the icon file. Use `undefined` to remove the overlay icon.
|
|
1675
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1676
|
+
*/
|
|
1677
|
+
async setOverlayIcon(e) {
|
|
1678
|
+
return n("plugin:window|set_overlay_icon", {
|
|
1679
|
+
label: this.label,
|
|
1680
|
+
value: e ? m(e) : void 0
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Sets the taskbar progress state.
|
|
1685
|
+
*
|
|
1686
|
+
* #### Platform-specific
|
|
1687
|
+
*
|
|
1688
|
+
* - **Linux / macOS**: Progress bar is app-wide and not specific to this window.
|
|
1689
|
+
* - **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME).
|
|
1690
|
+
*
|
|
1691
|
+
* @example
|
|
1692
|
+
* ```typescript
|
|
1693
|
+
* import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
|
|
1694
|
+
* await getCurrentWindow().setProgressBar({
|
|
1695
|
+
* status: ProgressBarStatus.Normal,
|
|
1696
|
+
* progress: 50,
|
|
1697
|
+
* });
|
|
1698
|
+
* ```
|
|
1699
|
+
*
|
|
1700
|
+
* @return A promise indicating the success or failure of the operation.
|
|
1701
|
+
*/
|
|
1702
|
+
async setProgressBar(e) {
|
|
1703
|
+
return n("plugin:window|set_progress_bar", {
|
|
1704
|
+
label: this.label,
|
|
1705
|
+
value: e
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Sets whether the window should be visible on all workspaces or virtual desktops.
|
|
1710
|
+
*
|
|
1711
|
+
* #### Platform-specific
|
|
1712
|
+
*
|
|
1713
|
+
* - **Windows / iOS / Android:** Unsupported.
|
|
1714
|
+
*
|
|
1715
|
+
* @since 2.0.0
|
|
1716
|
+
*/
|
|
1717
|
+
async setVisibleOnAllWorkspaces(e) {
|
|
1718
|
+
return n("plugin:window|set_visible_on_all_workspaces", {
|
|
1719
|
+
label: this.label,
|
|
1720
|
+
value: e
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Sets the title bar style. **macOS only**.
|
|
1725
|
+
*
|
|
1726
|
+
* @since 2.0.0
|
|
1727
|
+
*/
|
|
1728
|
+
async setTitleBarStyle(e) {
|
|
1729
|
+
return n("plugin:window|set_title_bar_style", {
|
|
1730
|
+
label: this.label,
|
|
1731
|
+
value: e
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Set window theme, pass in `null` or `undefined` to follow system theme
|
|
1736
|
+
*
|
|
1737
|
+
* #### Platform-specific
|
|
1738
|
+
*
|
|
1739
|
+
* - **Linux / macOS**: Theme is app-wide and not specific to this window.
|
|
1740
|
+
* - **iOS / Android:** Unsupported.
|
|
1741
|
+
*
|
|
1742
|
+
* @since 2.0.0
|
|
1743
|
+
*/
|
|
1744
|
+
async setTheme(e) {
|
|
1745
|
+
return n("plugin:window|set_theme", {
|
|
1746
|
+
label: this.label,
|
|
1747
|
+
value: e
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
// Listeners
|
|
1751
|
+
/**
|
|
1752
|
+
* Listen to window resize.
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```typescript
|
|
1756
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1757
|
+
* const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
|
|
1758
|
+
* console.log('Window resized', size);
|
|
1759
|
+
* });
|
|
1760
|
+
*
|
|
1761
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1762
|
+
* unlisten();
|
|
1763
|
+
* ```
|
|
1764
|
+
*
|
|
1765
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1766
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1767
|
+
*/
|
|
1768
|
+
async onResized(e) {
|
|
1769
|
+
return this.listen(r.WINDOW_RESIZED, (t) => {
|
|
1770
|
+
t.payload = new b(t.payload), e(t);
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Listen to window move.
|
|
1775
|
+
*
|
|
1776
|
+
* @example
|
|
1777
|
+
* ```typescript
|
|
1778
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1779
|
+
* const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
|
|
1780
|
+
* console.log('Window moved', position);
|
|
1781
|
+
* });
|
|
1782
|
+
*
|
|
1783
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1784
|
+
* unlisten();
|
|
1785
|
+
* ```
|
|
1786
|
+
*
|
|
1787
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1788
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1789
|
+
*/
|
|
1790
|
+
async onMoved(e) {
|
|
1791
|
+
return this.listen(r.WINDOW_MOVED, (t) => {
|
|
1792
|
+
t.payload = new c(t.payload), e(t);
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Listen to window close requested. Emitted when the user requests to closes the window.
|
|
1797
|
+
*
|
|
1798
|
+
* @example
|
|
1799
|
+
* ```typescript
|
|
1800
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1801
|
+
* import { confirm } from '@tauri-apps/api/dialog';
|
|
1802
|
+
* const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
|
|
1803
|
+
* const confirmed = await confirm('Are you sure?');
|
|
1804
|
+
* if (!confirmed) {
|
|
1805
|
+
* // user did not confirm closing the window; let's prevent it
|
|
1806
|
+
* event.preventDefault();
|
|
1807
|
+
* }
|
|
1808
|
+
* });
|
|
1809
|
+
*
|
|
1810
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1811
|
+
* unlisten();
|
|
1812
|
+
* ```
|
|
1813
|
+
*
|
|
1814
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1815
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1816
|
+
*/
|
|
1817
|
+
async onCloseRequested(e) {
|
|
1818
|
+
return this.listen(r.WINDOW_CLOSE_REQUESTED, async (t) => {
|
|
1819
|
+
const l = new se(t);
|
|
1820
|
+
await e(l), l.isPreventDefault() || await this.destroy();
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Listen to a file drop event.
|
|
1825
|
+
* The listener is triggered when the user hovers the selected files on the webview,
|
|
1826
|
+
* drops the files or cancels the operation.
|
|
1827
|
+
*
|
|
1828
|
+
* @example
|
|
1829
|
+
* ```typescript
|
|
1830
|
+
* import { getCurrentWindow } from "@tauri-apps/api/webview";
|
|
1831
|
+
* const unlisten = await getCurrentWindow().onDragDropEvent((event) => {
|
|
1832
|
+
* if (event.payload.type === 'over') {
|
|
1833
|
+
* console.log('User hovering', event.payload.position);
|
|
1834
|
+
* } else if (event.payload.type === 'drop') {
|
|
1835
|
+
* console.log('User dropped', event.payload.paths);
|
|
1836
|
+
* } else {
|
|
1837
|
+
* console.log('File drop cancelled');
|
|
1838
|
+
* }
|
|
1839
|
+
* });
|
|
1840
|
+
*
|
|
1841
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1842
|
+
* unlisten();
|
|
1843
|
+
* ```
|
|
1844
|
+
*
|
|
1845
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1846
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1847
|
+
*/
|
|
1848
|
+
async onDragDropEvent(e) {
|
|
1849
|
+
const t = await this.listen(r.DRAG_ENTER, (a) => {
|
|
1850
|
+
e({
|
|
1851
|
+
...a,
|
|
1852
|
+
payload: {
|
|
1853
|
+
type: "enter",
|
|
1854
|
+
paths: a.payload.paths,
|
|
1855
|
+
position: new c(a.payload.position)
|
|
1856
|
+
}
|
|
1857
|
+
});
|
|
1858
|
+
}), l = await this.listen(r.DRAG_OVER, (a) => {
|
|
1859
|
+
e({
|
|
1860
|
+
...a,
|
|
1861
|
+
payload: {
|
|
1862
|
+
type: "over",
|
|
1863
|
+
position: new c(a.payload.position)
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
}), s = await this.listen(r.DRAG_DROP, (a) => {
|
|
1867
|
+
e({
|
|
1868
|
+
...a,
|
|
1869
|
+
payload: {
|
|
1870
|
+
type: "drop",
|
|
1871
|
+
paths: a.payload.paths,
|
|
1872
|
+
position: new c(a.payload.position)
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
}), d = await this.listen(r.DRAG_LEAVE, (a) => {
|
|
1876
|
+
e({ ...a, payload: { type: "leave" } });
|
|
1877
|
+
});
|
|
1878
|
+
return () => {
|
|
1879
|
+
t(), s(), l(), d();
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Listen to window focus change.
|
|
1884
|
+
*
|
|
1885
|
+
* @example
|
|
1886
|
+
* ```typescript
|
|
1887
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1888
|
+
* const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
|
|
1889
|
+
* console.log('Focus changed, window is focused? ' + focused);
|
|
1890
|
+
* });
|
|
1891
|
+
*
|
|
1892
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1893
|
+
* unlisten();
|
|
1894
|
+
* ```
|
|
1895
|
+
*
|
|
1896
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1897
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1898
|
+
*/
|
|
1899
|
+
async onFocusChanged(e) {
|
|
1900
|
+
const t = await this.listen(r.WINDOW_FOCUS, (s) => {
|
|
1901
|
+
e({ ...s, payload: !0 });
|
|
1902
|
+
}), l = await this.listen(r.WINDOW_BLUR, (s) => {
|
|
1903
|
+
e({ ...s, payload: !1 });
|
|
1904
|
+
});
|
|
1905
|
+
return () => {
|
|
1906
|
+
t(), l();
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Listen to window scale change. Emitted when the window's scale factor has changed.
|
|
1911
|
+
* The following user actions can cause DPI changes:
|
|
1912
|
+
* - Changing the display's resolution.
|
|
1913
|
+
* - Changing the display's scale factor (e.g. in Control Panel on Windows).
|
|
1914
|
+
* - Moving the window to a display with a different scale factor.
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```typescript
|
|
1918
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1919
|
+
* const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
|
|
1920
|
+
* console.log('Scale changed', payload.scaleFactor, payload.size);
|
|
1921
|
+
* });
|
|
1922
|
+
*
|
|
1923
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1924
|
+
* unlisten();
|
|
1925
|
+
* ```
|
|
1926
|
+
*
|
|
1927
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1928
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1929
|
+
*/
|
|
1930
|
+
async onScaleChanged(e) {
|
|
1931
|
+
return this.listen(r.WINDOW_SCALE_FACTOR_CHANGED, e);
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Listen to the system theme change.
|
|
1935
|
+
*
|
|
1936
|
+
* @example
|
|
1937
|
+
* ```typescript
|
|
1938
|
+
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
1939
|
+
* const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
|
|
1940
|
+
* console.log('New theme: ' + theme);
|
|
1941
|
+
* });
|
|
1942
|
+
*
|
|
1943
|
+
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
1944
|
+
* unlisten();
|
|
1945
|
+
* ```
|
|
1946
|
+
*
|
|
1947
|
+
* @returns A promise resolving to a function to unlisten to the event.
|
|
1948
|
+
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1949
|
+
*/
|
|
1950
|
+
async onThemeChanged(e) {
|
|
1951
|
+
return this.listen(r.WINDOW_THEME_CHANGED, e);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
var O;
|
|
1955
|
+
(function(i) {
|
|
1956
|
+
i.Disabled = "disabled", i.Throttle = "throttle", i.Suspend = "suspend";
|
|
1957
|
+
})(O || (O = {}));
|
|
1958
|
+
var A;
|
|
1959
|
+
(function(i) {
|
|
1960
|
+
i.AppearanceBased = "appearanceBased", i.Light = "light", i.Dark = "dark", i.MediumLight = "mediumLight", i.UltraDark = "ultraDark", i.Titlebar = "titlebar", i.Selection = "selection", i.Menu = "menu", i.Popover = "popover", i.Sidebar = "sidebar", i.HeaderView = "headerView", i.Sheet = "sheet", i.WindowBackground = "windowBackground", i.HudWindow = "hudWindow", i.FullScreenUI = "fullScreenUI", i.Tooltip = "tooltip", i.ContentBackground = "contentBackground", i.UnderWindowBackground = "underWindowBackground", i.UnderPageBackground = "underPageBackground", i.Mica = "mica", i.Blur = "blur", i.Acrylic = "acrylic", i.Tabbed = "tabbed", i.TabbedDark = "tabbedDark", i.TabbedLight = "tabbedLight";
|
|
1961
|
+
})(A || (A = {}));
|
|
1962
|
+
var N;
|
|
1963
|
+
(function(i) {
|
|
1964
|
+
i.FollowsWindowActiveState = "followsWindowActiveState", i.Active = "active", i.Inactive = "inactive";
|
|
1965
|
+
})(N || (N = {}));
|
|
1966
|
+
async function ae(i) {
|
|
1967
|
+
try {
|
|
1968
|
+
return await n("plugin:vicons|get_icon", { name: i });
|
|
1969
|
+
} catch (e) {
|
|
1970
|
+
console.error("[Icon Error] Error obteniendo icono:", e);
|
|
1971
|
+
}
|
|
1972
|
+
return "";
|
|
1973
|
+
}
|
|
1974
|
+
function re(i) {
|
|
1975
|
+
try {
|
|
1976
|
+
const e = atob(i.substring(0, 32)), t = new Uint8Array(e.length);
|
|
1977
|
+
for (let l = 0; l < e.length; l++)
|
|
1978
|
+
t[l] = e.charCodeAt(l);
|
|
1979
|
+
return t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71 ? "image/png" : "image/svg+xml";
|
|
1980
|
+
} catch (e) {
|
|
1981
|
+
return console.error("Error identificando tipo de imagen:", e), "image/png";
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
async function W(i) {
|
|
1985
|
+
try {
|
|
1986
|
+
const e = await ae(i);
|
|
1987
|
+
return `data:${re(e)};base64,${e}`;
|
|
1988
|
+
} catch (e) {
|
|
1989
|
+
return console.error("[Icon Error] Error obteniendo icono:", e), "";
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
const oe = { "data-tauri-drag-region": "" }, ue = ["src"], ce = { "data-tauri-drag-region": "" }, de = { "data-tauri-drag-region": "" }, he = ["src"], we = ["src"], be = ["src"], ge = /* @__PURE__ */ C({
|
|
1993
|
+
__name: "TopBar",
|
|
1994
|
+
props: {
|
|
1995
|
+
title: String,
|
|
1996
|
+
image: String
|
|
1997
|
+
},
|
|
1998
|
+
setup(i) {
|
|
1999
|
+
const e = p(null), t = B(), l = p(""), s = p(""), d = p(""), a = i;
|
|
2000
|
+
return F(async () => {
|
|
2001
|
+
l.value = await W("window-close"), s.value = await W("window-minimize"), d.value = await W("window-maximize");
|
|
2002
|
+
}), (ye, h) => (f(), v("div", {
|
|
2003
|
+
"data-tauri-drag-region": "",
|
|
2004
|
+
class: "flex h-8 px-4 py-1 bg-vsk-primary rounded-t-window justify-between align-center",
|
|
2005
|
+
ref_key: "bar",
|
|
2006
|
+
ref: e
|
|
2007
|
+
}, [
|
|
2008
|
+
u("div", oe, [
|
|
2009
|
+
u("img", {
|
|
2010
|
+
src: a.image,
|
|
2011
|
+
"data-tauri-drag-region": "",
|
|
2012
|
+
class: "h-6 w-auto"
|
|
2013
|
+
}, null, 8, ue)
|
|
2014
|
+
]),
|
|
2015
|
+
u("div", ce, U(a.title), 1),
|
|
2016
|
+
u("div", de, [
|
|
2017
|
+
u("span", {
|
|
2018
|
+
class: "win-button",
|
|
2019
|
+
onClick: h[0] || (h[0] = (I) => D(t).minimize())
|
|
2020
|
+
}, [
|
|
2021
|
+
u("img", {
|
|
2022
|
+
src: s.value,
|
|
2023
|
+
class: "h-6 w-6 inline-block",
|
|
2024
|
+
alt: "Minimize"
|
|
2025
|
+
}, null, 8, he)
|
|
2026
|
+
]),
|
|
2027
|
+
u("span", {
|
|
2028
|
+
class: "win-button",
|
|
2029
|
+
onClick: h[1] || (h[1] = (I) => D(t).toggleMaximize())
|
|
2030
|
+
}, [
|
|
2031
|
+
u("img", {
|
|
2032
|
+
src: d.value,
|
|
2033
|
+
class: "h-6 w-6 inline-block",
|
|
2034
|
+
alt: "Maximize"
|
|
2035
|
+
}, null, 8, we)
|
|
2036
|
+
]),
|
|
2037
|
+
u("span", {
|
|
2038
|
+
class: "win-button",
|
|
2039
|
+
onClick: h[2] || (h[2] = (I) => D(t).close())
|
|
2040
|
+
}, [
|
|
2041
|
+
u("img", {
|
|
2042
|
+
src: l.value,
|
|
2043
|
+
class: "h-6 w-6 inline-block",
|
|
2044
|
+
alt: "Close"
|
|
2045
|
+
}, null, 8, be)
|
|
2046
|
+
])
|
|
2047
|
+
])
|
|
2048
|
+
], 512));
|
|
2049
|
+
}
|
|
2050
|
+
}), pe = /* @__PURE__ */ C({
|
|
2051
|
+
__name: "WindowFrame",
|
|
2052
|
+
props: {
|
|
2053
|
+
title: {
|
|
2054
|
+
type: String,
|
|
2055
|
+
default: "Vasak"
|
|
2056
|
+
},
|
|
2057
|
+
image: {
|
|
2058
|
+
type: String,
|
|
2059
|
+
default: ""
|
|
2060
|
+
}
|
|
2061
|
+
},
|
|
2062
|
+
setup(i) {
|
|
2063
|
+
const e = i;
|
|
2064
|
+
return (t, l) => (f(), v(V, null, [
|
|
2065
|
+
G(ge, {
|
|
2066
|
+
title: e.title,
|
|
2067
|
+
image: e.image
|
|
2068
|
+
}, null, 8, ["title", "image"]),
|
|
2069
|
+
R(t.$slots, "default")
|
|
2070
|
+
], 64));
|
|
2071
|
+
}
|
|
2072
|
+
}), _e = [j, Y, pe], ve = {
|
|
2073
|
+
install(i) {
|
|
2074
|
+
_e.forEach((e) => {
|
|
2075
|
+
i.component(e.name, e);
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
export {
|
|
2080
|
+
j as SideBar,
|
|
2081
|
+
Y as SideButton,
|
|
2082
|
+
pe as WindowFrame,
|
|
2083
|
+
ve as default
|
|
2084
|
+
};
|