@synnaxlabs/drift 0.37.0 → 0.38.1

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.
Files changed (65) hide show
  1. package/dist/debounce-BUAIXXZt.cjs +1 -0
  2. package/dist/debounce-DOZKRZa9.js +9 -0
  3. package/dist/electron.cjs +1 -0
  4. package/dist/electron.js +256 -0
  5. package/dist/index.cjs +1 -0
  6. package/dist/index.js +491 -0
  7. package/dist/react.cjs +1 -0
  8. package/dist/react.js +70 -0
  9. package/dist/selectors-CYHEOjO4.cjs +1 -0
  10. package/dist/selectors-DwAh3Dt_.js +25 -0
  11. package/dist/src/configureStore.d.ts +43 -0
  12. package/dist/src/configureStore.d.ts.map +1 -0
  13. package/dist/src/debug.d.ts +4 -0
  14. package/dist/src/debug.d.ts.map +1 -0
  15. package/dist/src/electron/index.d.ts +49 -0
  16. package/dist/src/electron/index.d.ts.map +1 -0
  17. package/dist/src/external.d.ts +8 -0
  18. package/dist/src/external.d.ts.map +1 -0
  19. package/dist/src/index.d.ts +3 -0
  20. package/dist/src/index.d.ts.map +1 -0
  21. package/dist/src/middleware.d.ts +27 -0
  22. package/dist/src/middleware.d.ts.map +1 -0
  23. package/dist/src/middleware.spec.d.ts +2 -0
  24. package/dist/src/middleware.spec.d.ts.map +1 -0
  25. package/dist/src/mock/index.d.ts +2 -0
  26. package/dist/src/mock/index.d.ts.map +1 -0
  27. package/dist/src/mock/runtime.d.ts +44 -0
  28. package/dist/src/mock/runtime.d.ts.map +1 -0
  29. package/dist/src/react/Provider.d.ts +23 -0
  30. package/dist/src/react/Provider.d.ts.map +1 -0
  31. package/dist/src/react/hooks.d.ts +15 -0
  32. package/dist/src/react/hooks.d.ts.map +1 -0
  33. package/dist/src/react/index.d.ts +4 -0
  34. package/dist/src/react/index.d.ts.map +1 -0
  35. package/dist/src/react/selectors.d.ts +13 -0
  36. package/dist/src/react/selectors.d.ts.map +1 -0
  37. package/dist/src/runtime.d.ts +99 -0
  38. package/dist/src/runtime.d.ts.map +1 -0
  39. package/dist/src/selectors.d.ts +9 -0
  40. package/dist/src/selectors.d.ts.map +1 -0
  41. package/dist/src/serialization/index.d.ts +6 -0
  42. package/dist/src/serialization/index.d.ts.map +1 -0
  43. package/dist/src/state.d.ts +100 -0
  44. package/dist/src/state.d.ts.map +1 -0
  45. package/dist/src/sugar.d.ts +24 -0
  46. package/dist/src/sugar.d.ts.map +1 -0
  47. package/dist/src/sugar.spec.d.ts +2 -0
  48. package/dist/src/sugar.spec.d.ts.map +1 -0
  49. package/dist/src/sync.d.ts +11 -0
  50. package/dist/src/sync.d.ts.map +1 -0
  51. package/dist/src/sync.spec.d.ts +2 -0
  52. package/dist/src/sync.spec.d.ts.map +1 -0
  53. package/dist/src/tauri/index.d.ts +47 -0
  54. package/dist/src/tauri/index.d.ts.map +1 -0
  55. package/dist/src/validate.d.ts +11 -0
  56. package/dist/src/validate.d.ts.map +1 -0
  57. package/dist/src/validate.spec.d.ts +2 -0
  58. package/dist/src/validate.spec.d.ts.map +1 -0
  59. package/dist/src/window.d.ts +177 -0
  60. package/dist/src/window.d.ts.map +1 -0
  61. package/dist/state-B8DVhsB5.js +5852 -0
  62. package/dist/state-Nl_4DIvw.cjs +13 -0
  63. package/dist/tauri.cjs +1 -0
  64. package/dist/tauri.js +2714 -0
  65. package/package.json +11 -12
package/dist/tauri.js ADDED
@@ -0,0 +1,2714 @@
1
+ var X = Object.defineProperty;
2
+ var ee = (t, e, i) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
+ var D = (t, e, i) => ee(t, typeof e != "symbol" ? e + "" : e, i);
4
+ import { H as ie, J as te, r as g, M as ne, K as se, G as le, _ as ae, T as G } from "./state-B8DVhsB5.js";
5
+ import { o as re } from "./debounce-DOZKRZa9.js";
6
+ function oe(t, e, i, n) {
7
+ if (i === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
8
+ if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
9
+ return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
10
+ }
11
+ function ue(t, e, i, n, l) {
12
+ if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13
+ return e.set(t, i), i;
14
+ }
15
+ var O;
16
+ const c = "__TAURI_TO_IPC_KEY__";
17
+ function ce(t, e = !1) {
18
+ return window.__TAURI_INTERNALS__.transformCallback(t, e);
19
+ }
20
+ async function s(t, e = {}, i) {
21
+ return window.__TAURI_INTERNALS__.invoke(t, e, i);
22
+ }
23
+ class he {
24
+ get rid() {
25
+ return oe(this, O, "f");
26
+ }
27
+ constructor(e) {
28
+ O.set(this, void 0), ue(this, O, e);
29
+ }
30
+ /**
31
+ * Destroys and cleans up this resource from memory.
32
+ * **You should not call any method on this object anymore and should drop any reference to it.**
33
+ */
34
+ async close() {
35
+ return s("plugin:resources|close", {
36
+ rid: this.rid
37
+ });
38
+ }
39
+ }
40
+ O = /* @__PURE__ */ new WeakMap();
41
+ var o;
42
+ (function(t) {
43
+ t.WINDOW_RESIZED = "tauri://resize", t.WINDOW_MOVED = "tauri://move", t.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", t.WINDOW_DESTROYED = "tauri://destroyed", t.WINDOW_FOCUS = "tauri://focus", t.WINDOW_BLUR = "tauri://blur", t.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", t.WINDOW_THEME_CHANGED = "tauri://theme-changed", t.WINDOW_CREATED = "tauri://window-created", t.WEBVIEW_CREATED = "tauri://webview-created", t.DRAG_ENTER = "tauri://drag-enter", t.DRAG_OVER = "tauri://drag-over", t.DRAG_DROP = "tauri://drag-drop", t.DRAG_LEAVE = "tauri://drag-leave";
44
+ })(o || (o = {}));
45
+ async function H(t, e) {
46
+ await s("plugin:event|unlisten", {
47
+ event: t,
48
+ eventId: e
49
+ });
50
+ }
51
+ async function v(t, e, i) {
52
+ var n;
53
+ const l = typeof (i == null ? void 0 : i.target) == "string" ? { kind: "AnyLabel", label: i.target } : (n = i == null ? void 0 : i.target) !== null && n !== void 0 ? n : { kind: "Any" };
54
+ return s("plugin:event|listen", {
55
+ event: t,
56
+ target: l,
57
+ handler: ce(e)
58
+ }).then((r) => async () => H(t, r));
59
+ }
60
+ async function A(t, e, i) {
61
+ return v(t, (n) => {
62
+ H(t, n.id), e(n);
63
+ }, i);
64
+ }
65
+ async function L(t, e) {
66
+ await s("plugin:event|emit", {
67
+ event: t,
68
+ payload: e
69
+ });
70
+ }
71
+ async function U(t, e, i) {
72
+ await s("plugin:event|emit_to", {
73
+ target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
74
+ event: e,
75
+ payload: i
76
+ });
77
+ }
78
+ class _ {
79
+ constructor(...e) {
80
+ 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]);
81
+ }
82
+ /**
83
+ * Converts the logical size to a physical one.
84
+ * @example
85
+ * ```typescript
86
+ * import { LogicalSize } from '@tauri-apps/api/dpi';
87
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
88
+ *
89
+ * const appWindow = getCurrentWindow();
90
+ * const factor = await appWindow.scaleFactor();
91
+ * const size = new LogicalSize(400, 500);
92
+ * const physical = size.toPhysical(factor);
93
+ * ```
94
+ *
95
+ * @since 2.0.0
96
+ */
97
+ toPhysical(e) {
98
+ return new d(this.width * e, this.height * e);
99
+ }
100
+ [c]() {
101
+ return {
102
+ width: this.width,
103
+ height: this.height
104
+ };
105
+ }
106
+ toJSON() {
107
+ return this[c]();
108
+ }
109
+ }
110
+ class d {
111
+ constructor(...e) {
112
+ 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]);
113
+ }
114
+ /**
115
+ * Converts the physical size to a logical one.
116
+ * @example
117
+ * ```typescript
118
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
119
+ * const appWindow = getCurrentWindow();
120
+ * const factor = await appWindow.scaleFactor();
121
+ * const size = await appWindow.innerSize(); // PhysicalSize
122
+ * const logical = size.toLogical(factor);
123
+ * ```
124
+ */
125
+ toLogical(e) {
126
+ return new _(this.width / e, this.height / e);
127
+ }
128
+ [c]() {
129
+ return {
130
+ width: this.width,
131
+ height: this.height
132
+ };
133
+ }
134
+ toJSON() {
135
+ return this[c]();
136
+ }
137
+ }
138
+ class h {
139
+ constructor(e) {
140
+ this.size = e;
141
+ }
142
+ toLogical(e) {
143
+ return this.size instanceof _ ? this.size : this.size.toLogical(e);
144
+ }
145
+ toPhysical(e) {
146
+ return this.size instanceof d ? this.size : this.size.toPhysical(e);
147
+ }
148
+ [c]() {
149
+ return {
150
+ [`${this.size.type}`]: {
151
+ width: this.size.width,
152
+ height: this.size.height
153
+ }
154
+ };
155
+ }
156
+ toJSON() {
157
+ return this[c]();
158
+ }
159
+ }
160
+ class N {
161
+ constructor(...e) {
162
+ 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]);
163
+ }
164
+ /**
165
+ * Converts the logical position to a physical one.
166
+ * @example
167
+ * ```typescript
168
+ * import { LogicalPosition } from '@tauri-apps/api/dpi';
169
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
170
+ *
171
+ * const appWindow = getCurrentWindow();
172
+ * const factor = await appWindow.scaleFactor();
173
+ * const position = new LogicalPosition(400, 500);
174
+ * const physical = position.toPhysical(factor);
175
+ * ```
176
+ *
177
+ * @since 2.0.0
178
+ */
179
+ toPhysical(e) {
180
+ return new u(this.x * e, this.y * e);
181
+ }
182
+ [c]() {
183
+ return {
184
+ x: this.x,
185
+ y: this.y
186
+ };
187
+ }
188
+ toJSON() {
189
+ return this[c]();
190
+ }
191
+ }
192
+ class u {
193
+ constructor(...e) {
194
+ 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]);
195
+ }
196
+ /**
197
+ * Converts the physical position to a logical one.
198
+ * @example
199
+ * ```typescript
200
+ * import { PhysicalPosition } from '@tauri-apps/api/dpi';
201
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
202
+ *
203
+ * const appWindow = getCurrentWindow();
204
+ * const factor = await appWindow.scaleFactor();
205
+ * const position = new PhysicalPosition(400, 500);
206
+ * const physical = position.toLogical(factor);
207
+ * ```
208
+ *
209
+ * @since 2.0.0
210
+ */
211
+ toLogical(e) {
212
+ return new N(this.x / e, this.y / e);
213
+ }
214
+ [c]() {
215
+ return {
216
+ x: this.x,
217
+ y: this.y
218
+ };
219
+ }
220
+ toJSON() {
221
+ return this[c]();
222
+ }
223
+ }
224
+ class b {
225
+ constructor(e) {
226
+ this.position = e;
227
+ }
228
+ toLogical(e) {
229
+ return this.position instanceof N ? this.position : this.position.toLogical(e);
230
+ }
231
+ toPhysical(e) {
232
+ return this.position instanceof u ? this.position : this.position.toPhysical(e);
233
+ }
234
+ [c]() {
235
+ return {
236
+ [`${this.position.type}`]: {
237
+ x: this.position.x,
238
+ y: this.position.y
239
+ }
240
+ };
241
+ }
242
+ toJSON() {
243
+ return this[c]();
244
+ }
245
+ }
246
+ class f extends he {
247
+ /**
248
+ * Creates an Image from a resource ID. For internal use only.
249
+ *
250
+ * @ignore
251
+ */
252
+ constructor(e) {
253
+ super(e);
254
+ }
255
+ /** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
256
+ static async new(e, i, n) {
257
+ return s("plugin:image|new", {
258
+ rgba: z(e),
259
+ width: i,
260
+ height: n
261
+ }).then((l) => new f(l));
262
+ }
263
+ /**
264
+ * Creates a new image using the provided bytes by inferring the file format.
265
+ * If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
266
+ *
267
+ * Only `ico` and `png` are supported (based on activated feature flag).
268
+ *
269
+ * Note that you need the `image-ico` or `image-png` Cargo features to use this API.
270
+ * To enable it, change your Cargo.toml file:
271
+ * ```toml
272
+ * [dependencies]
273
+ * tauri = { version = "...", features = ["...", "image-png"] }
274
+ * ```
275
+ */
276
+ static async fromBytes(e) {
277
+ return s("plugin:image|from_bytes", {
278
+ bytes: z(e)
279
+ }).then((i) => new f(i));
280
+ }
281
+ /**
282
+ * Creates a new image using the provided path.
283
+ *
284
+ * Only `ico` and `png` are supported (based on activated feature flag).
285
+ *
286
+ * Note that you need the `image-ico` or `image-png` Cargo features to use this API.
287
+ * To enable it, change your Cargo.toml file:
288
+ * ```toml
289
+ * [dependencies]
290
+ * tauri = { version = "...", features = ["...", "image-png"] }
291
+ * ```
292
+ */
293
+ static async fromPath(e) {
294
+ return s("plugin:image|from_path", { path: e }).then((i) => new f(i));
295
+ }
296
+ /** Returns the RGBA data for this image, in row-major order from top to bottom. */
297
+ async rgba() {
298
+ return s("plugin:image|rgba", {
299
+ rid: this.rid
300
+ }).then((e) => new Uint8Array(e));
301
+ }
302
+ /** Returns the size of this image. */
303
+ async size() {
304
+ return s("plugin:image|size", { rid: this.rid });
305
+ }
306
+ }
307
+ function z(t) {
308
+ return t == null ? null : typeof t == "string" ? t : t instanceof f ? t.rid : t;
309
+ }
310
+ var k;
311
+ (function(t) {
312
+ t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
313
+ })(k || (k = {}));
314
+ class we {
315
+ constructor(e) {
316
+ this._preventDefault = !1, this.event = e.event, this.id = e.id;
317
+ }
318
+ preventDefault() {
319
+ this._preventDefault = !0;
320
+ }
321
+ isPreventDefault() {
322
+ return this._preventDefault;
323
+ }
324
+ }
325
+ var C;
326
+ (function(t) {
327
+ t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
328
+ })(C || (C = {}));
329
+ function j() {
330
+ return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
331
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
332
+ skip: !0
333
+ });
334
+ }
335
+ async function S() {
336
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
337
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
338
+ skip: !0
339
+ })));
340
+ }
341
+ const R = ["tauri://created", "tauri://error"];
342
+ class P {
343
+ /**
344
+ * Creates a new Window.
345
+ * @example
346
+ * ```typescript
347
+ * import { Window } from '@tauri-apps/api/window';
348
+ * const appWindow = new Window('my-label');
349
+ * appWindow.once('tauri://created', function () {
350
+ * // window successfully created
351
+ * });
352
+ * appWindow.once('tauri://error', function (e) {
353
+ * // an error happened creating the window
354
+ * });
355
+ * ```
356
+ *
357
+ * @param label The unique window label. Must be alphanumeric: `a-zA-Z-/:_`.
358
+ * @returns The {@link Window} instance to communicate with the window.
359
+ */
360
+ constructor(e, i = {}) {
361
+ var n;
362
+ this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i != null && i.skip || s("plugin:window|create", {
363
+ options: {
364
+ ...i,
365
+ parent: typeof i.parent == "string" ? i.parent : (n = i.parent) === null || n === void 0 ? void 0 : n.label,
366
+ label: e
367
+ }
368
+ }).then(async () => this.emit("tauri://created")).catch(async (l) => this.emit("tauri://error", l));
369
+ }
370
+ /**
371
+ * Gets the Window associated with the given label.
372
+ * @example
373
+ * ```typescript
374
+ * import { Window } from '@tauri-apps/api/window';
375
+ * const mainWindow = Window.getByLabel('main');
376
+ * ```
377
+ *
378
+ * @param label The window label.
379
+ * @returns The Window instance to communicate with the window or null if the window doesn't exist.
380
+ */
381
+ static async getByLabel(e) {
382
+ var i;
383
+ return (i = (await S()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
384
+ }
385
+ /**
386
+ * Get an instance of `Window` for the current window.
387
+ */
388
+ static getCurrent() {
389
+ return j();
390
+ }
391
+ /**
392
+ * Gets a list of instances of `Window` for all available windows.
393
+ */
394
+ static async getAll() {
395
+ return S();
396
+ }
397
+ /**
398
+ * Gets the focused window.
399
+ * @example
400
+ * ```typescript
401
+ * import { Window } from '@tauri-apps/api/window';
402
+ * const focusedWindow = Window.getFocusedWindow();
403
+ * ```
404
+ *
405
+ * @returns The Window instance or `undefined` if there is not any focused window.
406
+ */
407
+ static async getFocusedWindow() {
408
+ for (const e of await S())
409
+ if (await e.isFocused())
410
+ return e;
411
+ return null;
412
+ }
413
+ /**
414
+ * Listen to an emitted event on this window.
415
+ *
416
+ * @example
417
+ * ```typescript
418
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
419
+ * const unlisten = await getCurrentWindow().listen<string>('state-changed', (event) => {
420
+ * console.log(`Got error: ${payload}`);
421
+ * });
422
+ *
423
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
424
+ * unlisten();
425
+ * ```
426
+ *
427
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
428
+ * @param handler Event handler.
429
+ * @returns A promise resolving to a function to unlisten to the event.
430
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
431
+ */
432
+ async listen(e, i) {
433
+ return this._handleTauriEvent(e, i) ? () => {
434
+ const n = this.listeners[e];
435
+ n.splice(n.indexOf(i), 1);
436
+ } : v(e, i, {
437
+ target: { kind: "Window", label: this.label }
438
+ });
439
+ }
440
+ /**
441
+ * Listen to an emitted event on this window only once.
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
446
+ * const unlisten = await getCurrentWindow().once<null>('initialized', (event) => {
447
+ * console.log(`Window initialized!`);
448
+ * });
449
+ *
450
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
451
+ * unlisten();
452
+ * ```
453
+ *
454
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
455
+ * @param handler Event handler.
456
+ * @returns A promise resolving to a function to unlisten to the event.
457
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
458
+ */
459
+ async once(e, i) {
460
+ return this._handleTauriEvent(e, i) ? () => {
461
+ const n = this.listeners[e];
462
+ n.splice(n.indexOf(i), 1);
463
+ } : A(e, i, {
464
+ target: { kind: "Window", label: this.label }
465
+ });
466
+ }
467
+ /**
468
+ * Emits an event to all {@link EventTarget|targets}.
469
+ * @example
470
+ * ```typescript
471
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
472
+ * await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });
473
+ * ```
474
+ *
475
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
476
+ * @param payload Event payload.
477
+ */
478
+ async emit(e, i) {
479
+ if (R.includes(e)) {
480
+ for (const n of this.listeners[e] || [])
481
+ n({
482
+ event: e,
483
+ id: -1,
484
+ payload: i
485
+ });
486
+ return;
487
+ }
488
+ return L(e, i);
489
+ }
490
+ /**
491
+ * Emits an event to all {@link EventTarget|targets} matching the given target.
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
496
+ * await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });
497
+ * ```
498
+ * @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
499
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
500
+ * @param payload Event payload.
501
+ */
502
+ async emitTo(e, i, n) {
503
+ if (R.includes(i)) {
504
+ for (const l of this.listeners[i] || [])
505
+ l({
506
+ event: i,
507
+ id: -1,
508
+ payload: n
509
+ });
510
+ return;
511
+ }
512
+ return U(e, i, n);
513
+ }
514
+ /** @ignore */
515
+ _handleTauriEvent(e, i) {
516
+ return R.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
517
+ }
518
+ // Getters
519
+ /**
520
+ * The scale factor that can be used to map physical pixels to logical pixels.
521
+ * @example
522
+ * ```typescript
523
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
524
+ * const factor = await getCurrentWindow().scaleFactor();
525
+ * ```
526
+ *
527
+ * @returns The window's monitor scale factor.
528
+ */
529
+ async scaleFactor() {
530
+ return s("plugin:window|scale_factor", {
531
+ label: this.label
532
+ });
533
+ }
534
+ /**
535
+ * The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
536
+ * @example
537
+ * ```typescript
538
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
539
+ * const position = await getCurrentWindow().innerPosition();
540
+ * ```
541
+ *
542
+ * @returns The window's inner position.
543
+ */
544
+ async innerPosition() {
545
+ return s("plugin:window|inner_position", {
546
+ label: this.label
547
+ }).then((e) => new u(e));
548
+ }
549
+ /**
550
+ * The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
551
+ * @example
552
+ * ```typescript
553
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
554
+ * const position = await getCurrentWindow().outerPosition();
555
+ * ```
556
+ *
557
+ * @returns The window's outer position.
558
+ */
559
+ async outerPosition() {
560
+ return s("plugin:window|outer_position", {
561
+ label: this.label
562
+ }).then((e) => new u(e));
563
+ }
564
+ /**
565
+ * The physical size of the window's client area.
566
+ * The client area is the content of the window, excluding the title bar and borders.
567
+ * @example
568
+ * ```typescript
569
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
570
+ * const size = await getCurrentWindow().innerSize();
571
+ * ```
572
+ *
573
+ * @returns The window's inner size.
574
+ */
575
+ async innerSize() {
576
+ return s("plugin:window|inner_size", {
577
+ label: this.label
578
+ }).then((e) => new d(e));
579
+ }
580
+ /**
581
+ * The physical size of the entire window.
582
+ * These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
583
+ * @example
584
+ * ```typescript
585
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
586
+ * const size = await getCurrentWindow().outerSize();
587
+ * ```
588
+ *
589
+ * @returns The window's outer size.
590
+ */
591
+ async outerSize() {
592
+ return s("plugin:window|outer_size", {
593
+ label: this.label
594
+ }).then((e) => new d(e));
595
+ }
596
+ /**
597
+ * Gets the window's current fullscreen state.
598
+ * @example
599
+ * ```typescript
600
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
601
+ * const fullscreen = await getCurrentWindow().isFullscreen();
602
+ * ```
603
+ *
604
+ * @returns Whether the window is in fullscreen mode or not.
605
+ */
606
+ async isFullscreen() {
607
+ return s("plugin:window|is_fullscreen", {
608
+ label: this.label
609
+ });
610
+ }
611
+ /**
612
+ * Gets the window's current minimized state.
613
+ * @example
614
+ * ```typescript
615
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
616
+ * const minimized = await getCurrentWindow().isMinimized();
617
+ * ```
618
+ */
619
+ async isMinimized() {
620
+ return s("plugin:window|is_minimized", {
621
+ label: this.label
622
+ });
623
+ }
624
+ /**
625
+ * Gets the window's current maximized state.
626
+ * @example
627
+ * ```typescript
628
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
629
+ * const maximized = await getCurrentWindow().isMaximized();
630
+ * ```
631
+ *
632
+ * @returns Whether the window is maximized or not.
633
+ */
634
+ async isMaximized() {
635
+ return s("plugin:window|is_maximized", {
636
+ label: this.label
637
+ });
638
+ }
639
+ /**
640
+ * Gets the window's current focus state.
641
+ * @example
642
+ * ```typescript
643
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
644
+ * const focused = await getCurrentWindow().isFocused();
645
+ * ```
646
+ *
647
+ * @returns Whether the window is focused or not.
648
+ */
649
+ async isFocused() {
650
+ return s("plugin:window|is_focused", {
651
+ label: this.label
652
+ });
653
+ }
654
+ /**
655
+ * Gets the window's current decorated state.
656
+ * @example
657
+ * ```typescript
658
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
659
+ * const decorated = await getCurrentWindow().isDecorated();
660
+ * ```
661
+ *
662
+ * @returns Whether the window is decorated or not.
663
+ */
664
+ async isDecorated() {
665
+ return s("plugin:window|is_decorated", {
666
+ label: this.label
667
+ });
668
+ }
669
+ /**
670
+ * Gets the window's current resizable state.
671
+ * @example
672
+ * ```typescript
673
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
674
+ * const resizable = await getCurrentWindow().isResizable();
675
+ * ```
676
+ *
677
+ * @returns Whether the window is resizable or not.
678
+ */
679
+ async isResizable() {
680
+ return s("plugin:window|is_resizable", {
681
+ label: this.label
682
+ });
683
+ }
684
+ /**
685
+ * Gets the window's native maximize button state.
686
+ *
687
+ * #### Platform-specific
688
+ *
689
+ * - **Linux / iOS / Android:** Unsupported.
690
+ *
691
+ * @example
692
+ * ```typescript
693
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
694
+ * const maximizable = await getCurrentWindow().isMaximizable();
695
+ * ```
696
+ *
697
+ * @returns Whether the window's native maximize button is enabled or not.
698
+ */
699
+ async isMaximizable() {
700
+ return s("plugin:window|is_maximizable", {
701
+ label: this.label
702
+ });
703
+ }
704
+ /**
705
+ * Gets the window's native minimize button state.
706
+ *
707
+ * #### Platform-specific
708
+ *
709
+ * - **Linux / iOS / Android:** Unsupported.
710
+ *
711
+ * @example
712
+ * ```typescript
713
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
714
+ * const minimizable = await getCurrentWindow().isMinimizable();
715
+ * ```
716
+ *
717
+ * @returns Whether the window's native minimize button is enabled or not.
718
+ */
719
+ async isMinimizable() {
720
+ return s("plugin:window|is_minimizable", {
721
+ label: this.label
722
+ });
723
+ }
724
+ /**
725
+ * Gets the window's native close button state.
726
+ *
727
+ * #### Platform-specific
728
+ *
729
+ * - **iOS / Android:** Unsupported.
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
734
+ * const closable = await getCurrentWindow().isClosable();
735
+ * ```
736
+ *
737
+ * @returns Whether the window's native close button is enabled or not.
738
+ */
739
+ async isClosable() {
740
+ return s("plugin:window|is_closable", {
741
+ label: this.label
742
+ });
743
+ }
744
+ /**
745
+ * Gets the window's current visible state.
746
+ * @example
747
+ * ```typescript
748
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
749
+ * const visible = await getCurrentWindow().isVisible();
750
+ * ```
751
+ *
752
+ * @returns Whether the window is visible or not.
753
+ */
754
+ async isVisible() {
755
+ return s("plugin:window|is_visible", {
756
+ label: this.label
757
+ });
758
+ }
759
+ /**
760
+ * Gets the window's current title.
761
+ * @example
762
+ * ```typescript
763
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
764
+ * const title = await getCurrentWindow().title();
765
+ * ```
766
+ */
767
+ async title() {
768
+ return s("plugin:window|title", {
769
+ label: this.label
770
+ });
771
+ }
772
+ /**
773
+ * Gets the window's current theme.
774
+ *
775
+ * #### Platform-specific
776
+ *
777
+ * - **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below.
778
+ *
779
+ * @example
780
+ * ```typescript
781
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
782
+ * const theme = await getCurrentWindow().theme();
783
+ * ```
784
+ *
785
+ * @returns The window theme.
786
+ */
787
+ async theme() {
788
+ return s("plugin:window|theme", {
789
+ label: this.label
790
+ });
791
+ }
792
+ // Setters
793
+ /**
794
+ * Centers the window.
795
+ * @example
796
+ * ```typescript
797
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
798
+ * await getCurrentWindow().center();
799
+ * ```
800
+ *
801
+ * @returns A promise indicating the success or failure of the operation.
802
+ */
803
+ async center() {
804
+ return s("plugin:window|center", {
805
+ label: this.label
806
+ });
807
+ }
808
+ /**
809
+ * Requests user attention to the window, this has no effect if the application
810
+ * is already focused. How requesting for user attention manifests is platform dependent,
811
+ * see `UserAttentionType` for details.
812
+ *
813
+ * Providing `null` will unset the request for user attention. Unsetting the request for
814
+ * user attention might not be done automatically by the WM when the window receives input.
815
+ *
816
+ * #### Platform-specific
817
+ *
818
+ * - **macOS:** `null` has no effect.
819
+ * - **Linux:** Urgency levels have the same effect.
820
+ * @example
821
+ * ```typescript
822
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
823
+ * await getCurrentWindow().requestUserAttention();
824
+ * ```
825
+ *
826
+ * @returns A promise indicating the success or failure of the operation.
827
+ */
828
+ async requestUserAttention(e) {
829
+ let i = null;
830
+ return e && (e === k.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
831
+ label: this.label,
832
+ value: i
833
+ });
834
+ }
835
+ /**
836
+ * Updates the window resizable flag.
837
+ * @example
838
+ * ```typescript
839
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
840
+ * await getCurrentWindow().setResizable(false);
841
+ * ```
842
+ *
843
+ * @returns A promise indicating the success or failure of the operation.
844
+ */
845
+ async setResizable(e) {
846
+ return s("plugin:window|set_resizable", {
847
+ label: this.label,
848
+ value: e
849
+ });
850
+ }
851
+ /**
852
+ * Enable or disable the window.
853
+ * @example
854
+ * ```typescript
855
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
856
+ * await getCurrentWindow().setEnabled(false);
857
+ * ```
858
+ *
859
+ * @returns A promise indicating the success or failure of the operation.
860
+ *
861
+ * @since 2.0.0
862
+ */
863
+ async setEnabled(e) {
864
+ return s("plugin:window|set_enabled", {
865
+ label: this.label,
866
+ value: e
867
+ });
868
+ }
869
+ /**
870
+ * Whether the window is enabled or disabled.
871
+ * @example
872
+ * ```typescript
873
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
874
+ * await getCurrentWindow().setEnabled(false);
875
+ * ```
876
+ *
877
+ * @returns A promise indicating the success or failure of the operation.
878
+ *
879
+ * @since 2.0.0
880
+ */
881
+ async isEnabled() {
882
+ return s("plugin:window|is_enabled", {
883
+ label: this.label
884
+ });
885
+ }
886
+ /**
887
+ * Sets whether the window's native maximize button is enabled or not.
888
+ * If resizable is set to false, this setting is ignored.
889
+ *
890
+ * #### Platform-specific
891
+ *
892
+ * - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
893
+ * - **Linux / iOS / Android:** Unsupported.
894
+ *
895
+ * @example
896
+ * ```typescript
897
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
898
+ * await getCurrentWindow().setMaximizable(false);
899
+ * ```
900
+ *
901
+ * @returns A promise indicating the success or failure of the operation.
902
+ */
903
+ async setMaximizable(e) {
904
+ return s("plugin:window|set_maximizable", {
905
+ label: this.label,
906
+ value: e
907
+ });
908
+ }
909
+ /**
910
+ * Sets whether the window's native minimize button is enabled or not.
911
+ *
912
+ * #### Platform-specific
913
+ *
914
+ * - **Linux / iOS / Android:** Unsupported.
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
919
+ * await getCurrentWindow().setMinimizable(false);
920
+ * ```
921
+ *
922
+ * @returns A promise indicating the success or failure of the operation.
923
+ */
924
+ async setMinimizable(e) {
925
+ return s("plugin:window|set_minimizable", {
926
+ label: this.label,
927
+ value: e
928
+ });
929
+ }
930
+ /**
931
+ * Sets whether the window's native close button is enabled or not.
932
+ *
933
+ * #### Platform-specific
934
+ *
935
+ * - **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
936
+ * - **iOS / Android:** Unsupported.
937
+ *
938
+ * @example
939
+ * ```typescript
940
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
941
+ * await getCurrentWindow().setClosable(false);
942
+ * ```
943
+ *
944
+ * @returns A promise indicating the success or failure of the operation.
945
+ */
946
+ async setClosable(e) {
947
+ return s("plugin:window|set_closable", {
948
+ label: this.label,
949
+ value: e
950
+ });
951
+ }
952
+ /**
953
+ * Sets the window title.
954
+ * @example
955
+ * ```typescript
956
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
957
+ * await getCurrentWindow().setTitle('Tauri');
958
+ * ```
959
+ *
960
+ * @param title The new title
961
+ * @returns A promise indicating the success or failure of the operation.
962
+ */
963
+ async setTitle(e) {
964
+ return s("plugin:window|set_title", {
965
+ label: this.label,
966
+ value: e
967
+ });
968
+ }
969
+ /**
970
+ * Maximizes the window.
971
+ * @example
972
+ * ```typescript
973
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
974
+ * await getCurrentWindow().maximize();
975
+ * ```
976
+ *
977
+ * @returns A promise indicating the success or failure of the operation.
978
+ */
979
+ async maximize() {
980
+ return s("plugin:window|maximize", {
981
+ label: this.label
982
+ });
983
+ }
984
+ /**
985
+ * Unmaximizes the window.
986
+ * @example
987
+ * ```typescript
988
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
989
+ * await getCurrentWindow().unmaximize();
990
+ * ```
991
+ *
992
+ * @returns A promise indicating the success or failure of the operation.
993
+ */
994
+ async unmaximize() {
995
+ return s("plugin:window|unmaximize", {
996
+ label: this.label
997
+ });
998
+ }
999
+ /**
1000
+ * Toggles the window maximized state.
1001
+ * @example
1002
+ * ```typescript
1003
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1004
+ * await getCurrentWindow().toggleMaximize();
1005
+ * ```
1006
+ *
1007
+ * @returns A promise indicating the success or failure of the operation.
1008
+ */
1009
+ async toggleMaximize() {
1010
+ return s("plugin:window|toggle_maximize", {
1011
+ label: this.label
1012
+ });
1013
+ }
1014
+ /**
1015
+ * Minimizes the window.
1016
+ * @example
1017
+ * ```typescript
1018
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1019
+ * await getCurrentWindow().minimize();
1020
+ * ```
1021
+ *
1022
+ * @returns A promise indicating the success or failure of the operation.
1023
+ */
1024
+ async minimize() {
1025
+ return s("plugin:window|minimize", {
1026
+ label: this.label
1027
+ });
1028
+ }
1029
+ /**
1030
+ * Unminimizes the window.
1031
+ * @example
1032
+ * ```typescript
1033
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1034
+ * await getCurrentWindow().unminimize();
1035
+ * ```
1036
+ *
1037
+ * @returns A promise indicating the success or failure of the operation.
1038
+ */
1039
+ async unminimize() {
1040
+ return s("plugin:window|unminimize", {
1041
+ label: this.label
1042
+ });
1043
+ }
1044
+ /**
1045
+ * Sets the window visibility to true.
1046
+ * @example
1047
+ * ```typescript
1048
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1049
+ * await getCurrentWindow().show();
1050
+ * ```
1051
+ *
1052
+ * @returns A promise indicating the success or failure of the operation.
1053
+ */
1054
+ async show() {
1055
+ return s("plugin:window|show", {
1056
+ label: this.label
1057
+ });
1058
+ }
1059
+ /**
1060
+ * Sets the window visibility to false.
1061
+ * @example
1062
+ * ```typescript
1063
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1064
+ * await getCurrentWindow().hide();
1065
+ * ```
1066
+ *
1067
+ * @returns A promise indicating the success or failure of the operation.
1068
+ */
1069
+ async hide() {
1070
+ return s("plugin:window|hide", {
1071
+ label: this.label
1072
+ });
1073
+ }
1074
+ /**
1075
+ * Closes the window.
1076
+ *
1077
+ * Note this emits a closeRequested event so you can intercept it. To force window close, use {@link Window.destroy}.
1078
+ * @example
1079
+ * ```typescript
1080
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1081
+ * await getCurrentWindow().close();
1082
+ * ```
1083
+ *
1084
+ * @returns A promise indicating the success or failure of the operation.
1085
+ */
1086
+ async close() {
1087
+ return s("plugin:window|close", {
1088
+ label: this.label
1089
+ });
1090
+ }
1091
+ /**
1092
+ * Destroys the window. Behaves like {@link Window.close} but forces the window close instead of emitting a closeRequested event.
1093
+ * @example
1094
+ * ```typescript
1095
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1096
+ * await getCurrentWindow().destroy();
1097
+ * ```
1098
+ *
1099
+ * @returns A promise indicating the success or failure of the operation.
1100
+ */
1101
+ async destroy() {
1102
+ return s("plugin:window|destroy", {
1103
+ label: this.label
1104
+ });
1105
+ }
1106
+ /**
1107
+ * Whether the window should have borders and bars.
1108
+ * @example
1109
+ * ```typescript
1110
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1111
+ * await getCurrentWindow().setDecorations(false);
1112
+ * ```
1113
+ *
1114
+ * @param decorations Whether the window should have borders and bars.
1115
+ * @returns A promise indicating the success or failure of the operation.
1116
+ */
1117
+ async setDecorations(e) {
1118
+ return s("plugin:window|set_decorations", {
1119
+ label: this.label,
1120
+ value: e
1121
+ });
1122
+ }
1123
+ /**
1124
+ * Whether or not the window should have shadow.
1125
+ *
1126
+ * #### Platform-specific
1127
+ *
1128
+ * - **Windows:**
1129
+ * - `false` has no effect on decorated window, shadows are always ON.
1130
+ * - `true` will make undecorated window have a 1px white border,
1131
+ * and on Windows 11, it will have a rounded corners.
1132
+ * - **Linux:** Unsupported.
1133
+ *
1134
+ * @example
1135
+ * ```typescript
1136
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1137
+ * await getCurrentWindow().setShadow(false);
1138
+ * ```
1139
+ *
1140
+ * @returns A promise indicating the success or failure of the operation.
1141
+ */
1142
+ async setShadow(e) {
1143
+ return s("plugin:window|set_shadow", {
1144
+ label: this.label,
1145
+ value: e
1146
+ });
1147
+ }
1148
+ /**
1149
+ * Set window effects.
1150
+ */
1151
+ async setEffects(e) {
1152
+ return s("plugin:window|set_effects", {
1153
+ label: this.label,
1154
+ value: e
1155
+ });
1156
+ }
1157
+ /**
1158
+ * Clear any applied effects if possible.
1159
+ */
1160
+ async clearEffects() {
1161
+ return s("plugin:window|set_effects", {
1162
+ label: this.label,
1163
+ value: null
1164
+ });
1165
+ }
1166
+ /**
1167
+ * Whether the window should always be on top of other windows.
1168
+ * @example
1169
+ * ```typescript
1170
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1171
+ * await getCurrentWindow().setAlwaysOnTop(true);
1172
+ * ```
1173
+ *
1174
+ * @param alwaysOnTop Whether the window should always be on top of other windows or not.
1175
+ * @returns A promise indicating the success or failure of the operation.
1176
+ */
1177
+ async setAlwaysOnTop(e) {
1178
+ return s("plugin:window|set_always_on_top", {
1179
+ label: this.label,
1180
+ value: e
1181
+ });
1182
+ }
1183
+ /**
1184
+ * Whether the window should always be below other windows.
1185
+ * @example
1186
+ * ```typescript
1187
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1188
+ * await getCurrentWindow().setAlwaysOnBottom(true);
1189
+ * ```
1190
+ *
1191
+ * @param alwaysOnBottom Whether the window should always be below other windows or not.
1192
+ * @returns A promise indicating the success or failure of the operation.
1193
+ */
1194
+ async setAlwaysOnBottom(e) {
1195
+ return s("plugin:window|set_always_on_bottom", {
1196
+ label: this.label,
1197
+ value: e
1198
+ });
1199
+ }
1200
+ /**
1201
+ * Prevents the window contents from being captured by other apps.
1202
+ * @example
1203
+ * ```typescript
1204
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1205
+ * await getCurrentWindow().setContentProtected(true);
1206
+ * ```
1207
+ *
1208
+ * @returns A promise indicating the success or failure of the operation.
1209
+ */
1210
+ async setContentProtected(e) {
1211
+ return s("plugin:window|set_content_protected", {
1212
+ label: this.label,
1213
+ value: e
1214
+ });
1215
+ }
1216
+ /**
1217
+ * Resizes the window with a new inner size.
1218
+ * @example
1219
+ * ```typescript
1220
+ * import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
1221
+ * await getCurrentWindow().setSize(new LogicalSize(600, 500));
1222
+ * ```
1223
+ *
1224
+ * @param size The logical or physical inner size.
1225
+ * @returns A promise indicating the success or failure of the operation.
1226
+ */
1227
+ async setSize(e) {
1228
+ return s("plugin:window|set_size", {
1229
+ label: this.label,
1230
+ value: e instanceof h ? e : new h(e)
1231
+ });
1232
+ }
1233
+ /**
1234
+ * Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
1235
+ * @example
1236
+ * ```typescript
1237
+ * import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
1238
+ * await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));
1239
+ * ```
1240
+ *
1241
+ * @param size The logical or physical inner size, or `null` to unset the constraint.
1242
+ * @returns A promise indicating the success or failure of the operation.
1243
+ */
1244
+ async setMinSize(e) {
1245
+ return s("plugin:window|set_min_size", {
1246
+ label: this.label,
1247
+ value: e instanceof h ? e : e ? new h(e) : null
1248
+ });
1249
+ }
1250
+ /**
1251
+ * Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
1252
+ * @example
1253
+ * ```typescript
1254
+ * import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
1255
+ * await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));
1256
+ * ```
1257
+ *
1258
+ * @param size The logical or physical inner size, or `null` to unset the constraint.
1259
+ * @returns A promise indicating the success or failure of the operation.
1260
+ */
1261
+ async setMaxSize(e) {
1262
+ return s("plugin:window|set_max_size", {
1263
+ label: this.label,
1264
+ value: e instanceof h ? e : e ? new h(e) : null
1265
+ });
1266
+ }
1267
+ /**
1268
+ * Sets the window inner size constraints.
1269
+ * @example
1270
+ * ```typescript
1271
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1272
+ * await getCurrentWindow().setSizeConstraints({ minWidth: 300 });
1273
+ * ```
1274
+ *
1275
+ * @param constraints The logical or physical inner size, or `null` to unset the constraint.
1276
+ * @returns A promise indicating the success or failure of the operation.
1277
+ */
1278
+ async setSizeConstraints(e) {
1279
+ function i(n) {
1280
+ return n ? { Logical: n } : null;
1281
+ }
1282
+ return s("plugin:window|set_size_constraints", {
1283
+ label: this.label,
1284
+ value: {
1285
+ minWidth: i(e == null ? void 0 : e.minWidth),
1286
+ minHeight: i(e == null ? void 0 : e.minHeight),
1287
+ maxWidth: i(e == null ? void 0 : e.maxWidth),
1288
+ maxHeight: i(e == null ? void 0 : e.maxHeight)
1289
+ }
1290
+ });
1291
+ }
1292
+ /**
1293
+ * Sets the window outer position.
1294
+ * @example
1295
+ * ```typescript
1296
+ * import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
1297
+ * await getCurrentWindow().setPosition(new LogicalPosition(600, 500));
1298
+ * ```
1299
+ *
1300
+ * @param position The new position, in logical or physical pixels.
1301
+ * @returns A promise indicating the success or failure of the operation.
1302
+ */
1303
+ async setPosition(e) {
1304
+ return s("plugin:window|set_position", {
1305
+ label: this.label,
1306
+ value: e instanceof b ? e : new b(e)
1307
+ });
1308
+ }
1309
+ /**
1310
+ * Sets the window fullscreen state.
1311
+ * @example
1312
+ * ```typescript
1313
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1314
+ * await getCurrentWindow().setFullscreen(true);
1315
+ * ```
1316
+ *
1317
+ * @param fullscreen Whether the window should go to fullscreen or not.
1318
+ * @returns A promise indicating the success or failure of the operation.
1319
+ */
1320
+ async setFullscreen(e) {
1321
+ return s("plugin:window|set_fullscreen", {
1322
+ label: this.label,
1323
+ value: e
1324
+ });
1325
+ }
1326
+ /**
1327
+ * Bring the window to front and focus.
1328
+ * @example
1329
+ * ```typescript
1330
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1331
+ * await getCurrentWindow().setFocus();
1332
+ * ```
1333
+ *
1334
+ * @returns A promise indicating the success or failure of the operation.
1335
+ */
1336
+ async setFocus() {
1337
+ return s("plugin:window|set_focus", {
1338
+ label: this.label
1339
+ });
1340
+ }
1341
+ /**
1342
+ * Sets the window icon.
1343
+ * @example
1344
+ * ```typescript
1345
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1346
+ * await getCurrentWindow().setIcon('/tauri/awesome.png');
1347
+ * ```
1348
+ *
1349
+ * Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
1350
+ * To enable it, change your Cargo.toml file:
1351
+ * ```toml
1352
+ * [dependencies]
1353
+ * tauri = { version = "...", features = ["...", "image-png"] }
1354
+ * ```
1355
+ *
1356
+ * @param icon Icon bytes or path to the icon file.
1357
+ * @returns A promise indicating the success or failure of the operation.
1358
+ */
1359
+ async setIcon(e) {
1360
+ return s("plugin:window|set_icon", {
1361
+ label: this.label,
1362
+ value: z(e)
1363
+ });
1364
+ }
1365
+ /**
1366
+ * Whether the window icon should be hidden from the taskbar or not.
1367
+ *
1368
+ * #### Platform-specific
1369
+ *
1370
+ * - **macOS:** Unsupported.
1371
+ * @example
1372
+ * ```typescript
1373
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1374
+ * await getCurrentWindow().setSkipTaskbar(true);
1375
+ * ```
1376
+ *
1377
+ * @param skip true to hide window icon, false to show it.
1378
+ * @returns A promise indicating the success or failure of the operation.
1379
+ */
1380
+ async setSkipTaskbar(e) {
1381
+ return s("plugin:window|set_skip_taskbar", {
1382
+ label: this.label,
1383
+ value: e
1384
+ });
1385
+ }
1386
+ /**
1387
+ * Grabs the cursor, preventing it from leaving the window.
1388
+ *
1389
+ * There's no guarantee that the cursor will be hidden. You should
1390
+ * hide it by yourself if you want so.
1391
+ *
1392
+ * #### Platform-specific
1393
+ *
1394
+ * - **Linux:** Unsupported.
1395
+ * - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
1396
+ * @example
1397
+ * ```typescript
1398
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1399
+ * await getCurrentWindow().setCursorGrab(true);
1400
+ * ```
1401
+ *
1402
+ * @param grab `true` to grab the cursor icon, `false` to release it.
1403
+ * @returns A promise indicating the success or failure of the operation.
1404
+ */
1405
+ async setCursorGrab(e) {
1406
+ return s("plugin:window|set_cursor_grab", {
1407
+ label: this.label,
1408
+ value: e
1409
+ });
1410
+ }
1411
+ /**
1412
+ * Modifies the cursor's visibility.
1413
+ *
1414
+ * #### Platform-specific
1415
+ *
1416
+ * - **Windows:** The cursor is only hidden within the confines of the window.
1417
+ * - **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is
1418
+ * outside of the window.
1419
+ * @example
1420
+ * ```typescript
1421
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1422
+ * await getCurrentWindow().setCursorVisible(false);
1423
+ * ```
1424
+ *
1425
+ * @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
1426
+ * @returns A promise indicating the success or failure of the operation.
1427
+ */
1428
+ async setCursorVisible(e) {
1429
+ return s("plugin:window|set_cursor_visible", {
1430
+ label: this.label,
1431
+ value: e
1432
+ });
1433
+ }
1434
+ /**
1435
+ * Modifies the cursor icon of the window.
1436
+ * @example
1437
+ * ```typescript
1438
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1439
+ * await getCurrentWindow().setCursorIcon('help');
1440
+ * ```
1441
+ *
1442
+ * @param icon The new cursor icon.
1443
+ * @returns A promise indicating the success or failure of the operation.
1444
+ */
1445
+ async setCursorIcon(e) {
1446
+ return s("plugin:window|set_cursor_icon", {
1447
+ label: this.label,
1448
+ value: e
1449
+ });
1450
+ }
1451
+ /**
1452
+ * Sets the window background color.
1453
+ *
1454
+ * #### Platform-specific:
1455
+ *
1456
+ * - **Windows:** alpha channel is ignored.
1457
+ * - **iOS / Android:** Unsupported.
1458
+ *
1459
+ * @returns A promise indicating the success or failure of the operation.
1460
+ *
1461
+ * @since 2.1.0
1462
+ */
1463
+ async setBackgroundColor(e) {
1464
+ return s("plugin:window|set_background_color", { color: e });
1465
+ }
1466
+ /**
1467
+ * Changes the position of the cursor in window coordinates.
1468
+ * @example
1469
+ * ```typescript
1470
+ * import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
1471
+ * await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));
1472
+ * ```
1473
+ *
1474
+ * @param position The new cursor position.
1475
+ * @returns A promise indicating the success or failure of the operation.
1476
+ */
1477
+ async setCursorPosition(e) {
1478
+ return s("plugin:window|set_cursor_position", {
1479
+ label: this.label,
1480
+ value: e instanceof b ? e : new b(e)
1481
+ });
1482
+ }
1483
+ /**
1484
+ * Changes the cursor events behavior.
1485
+ *
1486
+ * @example
1487
+ * ```typescript
1488
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1489
+ * await getCurrentWindow().setIgnoreCursorEvents(true);
1490
+ * ```
1491
+ *
1492
+ * @param ignore `true` to ignore the cursor events; `false` to process them as usual.
1493
+ * @returns A promise indicating the success or failure of the operation.
1494
+ */
1495
+ async setIgnoreCursorEvents(e) {
1496
+ return s("plugin:window|set_ignore_cursor_events", {
1497
+ label: this.label,
1498
+ value: e
1499
+ });
1500
+ }
1501
+ /**
1502
+ * Starts dragging the window.
1503
+ * @example
1504
+ * ```typescript
1505
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1506
+ * await getCurrentWindow().startDragging();
1507
+ * ```
1508
+ *
1509
+ * @return A promise indicating the success or failure of the operation.
1510
+ */
1511
+ async startDragging() {
1512
+ return s("plugin:window|start_dragging", {
1513
+ label: this.label
1514
+ });
1515
+ }
1516
+ /**
1517
+ * Starts resize-dragging the window.
1518
+ * @example
1519
+ * ```typescript
1520
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1521
+ * await getCurrentWindow().startResizeDragging();
1522
+ * ```
1523
+ *
1524
+ * @return A promise indicating the success or failure of the operation.
1525
+ */
1526
+ async startResizeDragging(e) {
1527
+ return s("plugin:window|start_resize_dragging", {
1528
+ label: this.label,
1529
+ value: e
1530
+ });
1531
+ }
1532
+ /**
1533
+ * Sets the badge count. It is app wide and not specific to this window.
1534
+ *
1535
+ * #### Platform-specific
1536
+ *
1537
+ * - **Windows**: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
1538
+ *
1539
+ * @example
1540
+ * ```typescript
1541
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1542
+ * await getCurrentWindow().setBadgeCount(5);
1543
+ * ```
1544
+ *
1545
+ * @param count The badge count. Use `undefined` to remove the badge.
1546
+ * @return A promise indicating the success or failure of the operation.
1547
+ */
1548
+ async setBadgeCount(e) {
1549
+ return s("plugin:window|set_badge_count", {
1550
+ label: this.label,
1551
+ value: e
1552
+ });
1553
+ }
1554
+ /**
1555
+ * Sets the badge cont **macOS only**.
1556
+ *
1557
+ * @example
1558
+ * ```typescript
1559
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1560
+ * await getCurrentWindow().setBadgeLabel("Hello");
1561
+ * ```
1562
+ *
1563
+ * @param label The badge label. Use `undefined` to remove the badge.
1564
+ * @return A promise indicating the success or failure of the operation.
1565
+ */
1566
+ async setBadgeLabel(e) {
1567
+ return s("plugin:window|set_badge_label", {
1568
+ label: this.label,
1569
+ value: e
1570
+ });
1571
+ }
1572
+ /**
1573
+ * Sets the overlay icon. **Windows only**
1574
+ * The overlay icon can be set for every window.
1575
+ *
1576
+ *
1577
+ * Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
1578
+ * To enable it, change your Cargo.toml file:
1579
+ *
1580
+ * ```toml
1581
+ * [dependencies]
1582
+ * tauri = { version = "...", features = ["...", "image-png"] }
1583
+ * ```
1584
+ *
1585
+ * @example
1586
+ * ```typescript
1587
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
1588
+ * await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");
1589
+ * ```
1590
+ *
1591
+ * @param icon Icon bytes or path to the icon file. Use `undefined` to remove the overlay icon.
1592
+ * @return A promise indicating the success or failure of the operation.
1593
+ */
1594
+ async setOverlayIcon(e) {
1595
+ return s("plugin:window|set_overlay_icon", {
1596
+ label: this.label,
1597
+ value: e ? z(e) : void 0
1598
+ });
1599
+ }
1600
+ /**
1601
+ * Sets the taskbar progress state.
1602
+ *
1603
+ * #### Platform-specific
1604
+ *
1605
+ * - **Linux / macOS**: Progress bar is app-wide and not specific to this window.
1606
+ * - **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME).
1607
+ *
1608
+ * @example
1609
+ * ```typescript
1610
+ * import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
1611
+ * await getCurrentWindow().setProgressBar({
1612
+ * status: ProgressBarStatus.Normal,
1613
+ * progress: 50,
1614
+ * });
1615
+ * ```
1616
+ *
1617
+ * @return A promise indicating the success or failure of the operation.
1618
+ */
1619
+ async setProgressBar(e) {
1620
+ return s("plugin:window|set_progress_bar", {
1621
+ label: this.label,
1622
+ value: e
1623
+ });
1624
+ }
1625
+ /**
1626
+ * Sets whether the window should be visible on all workspaces or virtual desktops.
1627
+ *
1628
+ * #### Platform-specific
1629
+ *
1630
+ * - **Windows / iOS / Android:** Unsupported.
1631
+ *
1632
+ * @since 2.0.0
1633
+ */
1634
+ async setVisibleOnAllWorkspaces(e) {
1635
+ return s("plugin:window|set_visible_on_all_workspaces", {
1636
+ label: this.label,
1637
+ value: e
1638
+ });
1639
+ }
1640
+ /**
1641
+ * Sets the title bar style. **macOS only**.
1642
+ *
1643
+ * @since 2.0.0
1644
+ */
1645
+ async setTitleBarStyle(e) {
1646
+ return s("plugin:window|set_title_bar_style", {
1647
+ label: this.label,
1648
+ value: e
1649
+ });
1650
+ }
1651
+ /**
1652
+ * Set window theme, pass in `null` or `undefined` to follow system theme
1653
+ *
1654
+ * #### Platform-specific
1655
+ *
1656
+ * - **Linux / macOS**: Theme is app-wide and not specific to this window.
1657
+ * - **iOS / Android:** Unsupported.
1658
+ *
1659
+ * @since 2.0.0
1660
+ */
1661
+ async setTheme(e) {
1662
+ return s("plugin:window|set_theme", {
1663
+ label: this.label,
1664
+ value: e
1665
+ });
1666
+ }
1667
+ // Listeners
1668
+ /**
1669
+ * Listen to window resize.
1670
+ *
1671
+ * @example
1672
+ * ```typescript
1673
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1674
+ * const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
1675
+ * console.log('Window resized', size);
1676
+ * });
1677
+ *
1678
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1679
+ * unlisten();
1680
+ * ```
1681
+ *
1682
+ * @returns A promise resolving to a function to unlisten to the event.
1683
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1684
+ */
1685
+ async onResized(e) {
1686
+ return this.listen(o.WINDOW_RESIZED, (i) => {
1687
+ i.payload = new d(i.payload), e(i);
1688
+ });
1689
+ }
1690
+ /**
1691
+ * Listen to window move.
1692
+ *
1693
+ * @example
1694
+ * ```typescript
1695
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1696
+ * const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
1697
+ * console.log('Window moved', position);
1698
+ * });
1699
+ *
1700
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1701
+ * unlisten();
1702
+ * ```
1703
+ *
1704
+ * @returns A promise resolving to a function to unlisten to the event.
1705
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1706
+ */
1707
+ async onMoved(e) {
1708
+ return this.listen(o.WINDOW_MOVED, (i) => {
1709
+ i.payload = new u(i.payload), e(i);
1710
+ });
1711
+ }
1712
+ /**
1713
+ * Listen to window close requested. Emitted when the user requests to closes the window.
1714
+ *
1715
+ * @example
1716
+ * ```typescript
1717
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1718
+ * import { confirm } from '@tauri-apps/api/dialog';
1719
+ * const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
1720
+ * const confirmed = await confirm('Are you sure?');
1721
+ * if (!confirmed) {
1722
+ * // user did not confirm closing the window; let's prevent it
1723
+ * event.preventDefault();
1724
+ * }
1725
+ * });
1726
+ *
1727
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1728
+ * unlisten();
1729
+ * ```
1730
+ *
1731
+ * @returns A promise resolving to a function to unlisten to the event.
1732
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1733
+ */
1734
+ async onCloseRequested(e) {
1735
+ return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
1736
+ const n = new we(i);
1737
+ await e(n), n.isPreventDefault() || await this.destroy();
1738
+ });
1739
+ }
1740
+ /**
1741
+ * Listen to a file drop event.
1742
+ * The listener is triggered when the user hovers the selected files on the webview,
1743
+ * drops the files or cancels the operation.
1744
+ *
1745
+ * @example
1746
+ * ```typescript
1747
+ * import { getCurrentWindow } from "@tauri-apps/api/webview";
1748
+ * const unlisten = await getCurrentWindow().onDragDropEvent((event) => {
1749
+ * if (event.payload.type === 'over') {
1750
+ * console.log('User hovering', event.payload.position);
1751
+ * } else if (event.payload.type === 'drop') {
1752
+ * console.log('User dropped', event.payload.paths);
1753
+ * } else {
1754
+ * console.log('File drop cancelled');
1755
+ * }
1756
+ * });
1757
+ *
1758
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1759
+ * unlisten();
1760
+ * ```
1761
+ *
1762
+ * @returns A promise resolving to a function to unlisten to the event.
1763
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1764
+ */
1765
+ async onDragDropEvent(e) {
1766
+ const i = await this.listen(o.DRAG_ENTER, (a) => {
1767
+ e({
1768
+ ...a,
1769
+ payload: {
1770
+ type: "enter",
1771
+ paths: a.payload.paths,
1772
+ position: new u(a.payload.position)
1773
+ }
1774
+ });
1775
+ }), n = await this.listen(o.DRAG_OVER, (a) => {
1776
+ e({
1777
+ ...a,
1778
+ payload: {
1779
+ type: "over",
1780
+ position: new u(a.payload.position)
1781
+ }
1782
+ });
1783
+ }), l = await this.listen(o.DRAG_DROP, (a) => {
1784
+ e({
1785
+ ...a,
1786
+ payload: {
1787
+ type: "drop",
1788
+ paths: a.payload.paths,
1789
+ position: new u(a.payload.position)
1790
+ }
1791
+ });
1792
+ }), r = await this.listen(o.DRAG_LEAVE, (a) => {
1793
+ e({ ...a, payload: { type: "leave" } });
1794
+ });
1795
+ return () => {
1796
+ i(), l(), n(), r();
1797
+ };
1798
+ }
1799
+ /**
1800
+ * Listen to window focus change.
1801
+ *
1802
+ * @example
1803
+ * ```typescript
1804
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1805
+ * const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
1806
+ * console.log('Focus changed, window is focused? ' + focused);
1807
+ * });
1808
+ *
1809
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1810
+ * unlisten();
1811
+ * ```
1812
+ *
1813
+ * @returns A promise resolving to a function to unlisten to the event.
1814
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1815
+ */
1816
+ async onFocusChanged(e) {
1817
+ const i = await this.listen(o.WINDOW_FOCUS, (l) => {
1818
+ e({ ...l, payload: !0 });
1819
+ }), n = await this.listen(o.WINDOW_BLUR, (l) => {
1820
+ e({ ...l, payload: !1 });
1821
+ });
1822
+ return () => {
1823
+ i(), n();
1824
+ };
1825
+ }
1826
+ /**
1827
+ * Listen to window scale change. Emitted when the window's scale factor has changed.
1828
+ * The following user actions can cause DPI changes:
1829
+ * - Changing the display's resolution.
1830
+ * - Changing the display's scale factor (e.g. in Control Panel on Windows).
1831
+ * - Moving the window to a display with a different scale factor.
1832
+ *
1833
+ * @example
1834
+ * ```typescript
1835
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1836
+ * const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
1837
+ * console.log('Scale changed', payload.scaleFactor, payload.size);
1838
+ * });
1839
+ *
1840
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1841
+ * unlisten();
1842
+ * ```
1843
+ *
1844
+ * @returns A promise resolving to a function to unlisten to the event.
1845
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1846
+ */
1847
+ async onScaleChanged(e) {
1848
+ return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED, e);
1849
+ }
1850
+ /**
1851
+ * Listen to the system theme change.
1852
+ *
1853
+ * @example
1854
+ * ```typescript
1855
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
1856
+ * const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
1857
+ * console.log('New theme: ' + theme);
1858
+ * });
1859
+ *
1860
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1861
+ * unlisten();
1862
+ * ```
1863
+ *
1864
+ * @returns A promise resolving to a function to unlisten to the event.
1865
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1866
+ */
1867
+ async onThemeChanged(e) {
1868
+ return this.listen(o.WINDOW_THEME_CHANGED, e);
1869
+ }
1870
+ }
1871
+ var M;
1872
+ (function(t) {
1873
+ 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";
1874
+ })(M || (M = {}));
1875
+ var F;
1876
+ (function(t) {
1877
+ t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
1878
+ })(F || (F = {}));
1879
+ function de(t) {
1880
+ return t === null ? null : {
1881
+ name: t.name,
1882
+ scaleFactor: t.scaleFactor,
1883
+ position: new u(t.position),
1884
+ size: new d(t.size)
1885
+ };
1886
+ }
1887
+ async function be() {
1888
+ return s("plugin:window|available_monitors").then((t) => t.map(de));
1889
+ }
1890
+ function J() {
1891
+ return new T(j(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
1892
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
1893
+ skip: !0
1894
+ });
1895
+ }
1896
+ async function B() {
1897
+ return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new T(new P(e.windowLabel, {
1898
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
1899
+ skip: !0
1900
+ }), e.label, {
1901
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
1902
+ skip: !0
1903
+ })));
1904
+ }
1905
+ const x = ["tauri://created", "tauri://error"];
1906
+ class T {
1907
+ /**
1908
+ * Creates a new Webview.
1909
+ * @example
1910
+ * ```typescript
1911
+ * import { Window } from '@tauri-apps/api/window'
1912
+ * import { Webview } from '@tauri-apps/api/webview'
1913
+ * const appWindow = new Window('my-label')
1914
+ * const webview = new Webview(appWindow, 'my-label', {
1915
+ * url: 'https://github.com/tauri-apps/tauri'
1916
+ * });
1917
+ * webview.once('tauri://created', function () {
1918
+ * // webview successfully created
1919
+ * });
1920
+ * webview.once('tauri://error', function (e) {
1921
+ * // an error happened creating the webview
1922
+ * });
1923
+ * ```
1924
+ *
1925
+ * @param window the window to add this webview to.
1926
+ * @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
1927
+ * @returns The {@link Webview} instance to communicate with the webview.
1928
+ */
1929
+ constructor(e, i, n) {
1930
+ this.window = e, this.label = i, this.listeners = /* @__PURE__ */ Object.create(null), n != null && n.skip || s("plugin:webview|create_webview", {
1931
+ windowLabel: e.label,
1932
+ label: i,
1933
+ options: n
1934
+ }).then(async () => this.emit("tauri://created")).catch(async (l) => this.emit("tauri://error", l));
1935
+ }
1936
+ /**
1937
+ * Gets the Webview for the webview associated with the given label.
1938
+ * @example
1939
+ * ```typescript
1940
+ * import { Webview } from '@tauri-apps/api/webview';
1941
+ * const mainWebview = Webview.getByLabel('main');
1942
+ * ```
1943
+ *
1944
+ * @param label The webview label.
1945
+ * @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
1946
+ */
1947
+ static async getByLabel(e) {
1948
+ var i;
1949
+ return (i = (await B()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
1950
+ }
1951
+ /**
1952
+ * Get an instance of `Webview` for the current webview.
1953
+ */
1954
+ static getCurrent() {
1955
+ return J();
1956
+ }
1957
+ /**
1958
+ * Gets a list of instances of `Webview` for all available webviews.
1959
+ */
1960
+ static async getAll() {
1961
+ return B();
1962
+ }
1963
+ /**
1964
+ * Listen to an emitted event on this webview.
1965
+ *
1966
+ * @example
1967
+ * ```typescript
1968
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
1969
+ * const unlisten = await getCurrentWebview().listen<string>('state-changed', (event) => {
1970
+ * console.log(`Got error: ${payload}`);
1971
+ * });
1972
+ *
1973
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
1974
+ * unlisten();
1975
+ * ```
1976
+ *
1977
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
1978
+ * @param handler Event handler.
1979
+ * @returns A promise resolving to a function to unlisten to the event.
1980
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1981
+ */
1982
+ async listen(e, i) {
1983
+ return this._handleTauriEvent(e, i) ? () => {
1984
+ const n = this.listeners[e];
1985
+ n.splice(n.indexOf(i), 1);
1986
+ } : v(e, i, {
1987
+ target: { kind: "Webview", label: this.label }
1988
+ });
1989
+ }
1990
+ /**
1991
+ * Listen to an emitted event on this webview only once.
1992
+ *
1993
+ * @example
1994
+ * ```typescript
1995
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
1996
+ * const unlisten = await getCurrent().once<null>('initialized', (event) => {
1997
+ * console.log(`Webview initialized!`);
1998
+ * });
1999
+ *
2000
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
2001
+ * unlisten();
2002
+ * ```
2003
+ *
2004
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
2005
+ * @param handler Event handler.
2006
+ * @returns A promise resolving to a function to unlisten to the event.
2007
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2008
+ */
2009
+ async once(e, i) {
2010
+ return this._handleTauriEvent(e, i) ? () => {
2011
+ const n = this.listeners[e];
2012
+ n.splice(n.indexOf(i), 1);
2013
+ } : A(e, i, {
2014
+ target: { kind: "Webview", label: this.label }
2015
+ });
2016
+ }
2017
+ /**
2018
+ * Emits an event to all {@link EventTarget|targets}.
2019
+ *
2020
+ * @example
2021
+ * ```typescript
2022
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2023
+ * await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });
2024
+ * ```
2025
+ *
2026
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
2027
+ * @param payload Event payload.
2028
+ */
2029
+ async emit(e, i) {
2030
+ if (x.includes(e)) {
2031
+ for (const n of this.listeners[e] || [])
2032
+ n({
2033
+ event: e,
2034
+ id: -1,
2035
+ payload: i
2036
+ });
2037
+ return;
2038
+ }
2039
+ return L(e, i);
2040
+ }
2041
+ /**
2042
+ * Emits an event to all {@link EventTarget|targets} matching the given target.
2043
+ *
2044
+ * @example
2045
+ * ```typescript
2046
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2047
+ * await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });
2048
+ * ```
2049
+ *
2050
+ * @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
2051
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
2052
+ * @param payload Event payload.
2053
+ */
2054
+ async emitTo(e, i, n) {
2055
+ if (x.includes(i)) {
2056
+ for (const l of this.listeners[i] || [])
2057
+ l({
2058
+ event: i,
2059
+ id: -1,
2060
+ payload: n
2061
+ });
2062
+ return;
2063
+ }
2064
+ return U(e, i, n);
2065
+ }
2066
+ /** @ignore */
2067
+ _handleTauriEvent(e, i) {
2068
+ return x.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2069
+ }
2070
+ // Getters
2071
+ /**
2072
+ * The position of the top-left hand corner of the webview's client area relative to the top-left hand corner of the desktop.
2073
+ * @example
2074
+ * ```typescript
2075
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2076
+ * const position = await getCurrentWebview().position();
2077
+ * ```
2078
+ *
2079
+ * @returns The webview's position.
2080
+ */
2081
+ async position() {
2082
+ return s("plugin:webview|webview_position", {
2083
+ label: this.label
2084
+ }).then((e) => new u(e));
2085
+ }
2086
+ /**
2087
+ * The physical size of the webview's client area.
2088
+ * The client area is the content of the webview, excluding the title bar and borders.
2089
+ * @example
2090
+ * ```typescript
2091
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2092
+ * const size = await getCurrentWebview().size();
2093
+ * ```
2094
+ *
2095
+ * @returns The webview's size.
2096
+ */
2097
+ async size() {
2098
+ return s("plugin:webview|webview_size", {
2099
+ label: this.label
2100
+ }).then((e) => new d(e));
2101
+ }
2102
+ // Setters
2103
+ /**
2104
+ * Closes the webview.
2105
+ * @example
2106
+ * ```typescript
2107
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2108
+ * await getCurrentWebview().close();
2109
+ * ```
2110
+ *
2111
+ * @returns A promise indicating the success or failure of the operation.
2112
+ */
2113
+ async close() {
2114
+ return s("plugin:webview|close", {
2115
+ label: this.label
2116
+ });
2117
+ }
2118
+ /**
2119
+ * Resizes the webview.
2120
+ * @example
2121
+ * ```typescript
2122
+ * import { getCurrent, LogicalSize } from '@tauri-apps/api/webview';
2123
+ * await getCurrentWebview().setSize(new LogicalSize(600, 500));
2124
+ * ```
2125
+ *
2126
+ * @param size The logical or physical size.
2127
+ * @returns A promise indicating the success or failure of the operation.
2128
+ */
2129
+ async setSize(e) {
2130
+ return s("plugin:webview|set_webview_size", {
2131
+ label: this.label,
2132
+ value: e instanceof h ? e : new h(e)
2133
+ });
2134
+ }
2135
+ /**
2136
+ * Sets the webview position.
2137
+ * @example
2138
+ * ```typescript
2139
+ * import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview';
2140
+ * await getCurrentWebview().setPosition(new LogicalPosition(600, 500));
2141
+ * ```
2142
+ *
2143
+ * @param position The new position, in logical or physical pixels.
2144
+ * @returns A promise indicating the success or failure of the operation.
2145
+ */
2146
+ async setPosition(e) {
2147
+ return s("plugin:webview|set_webview_position", {
2148
+ label: this.label,
2149
+ value: e instanceof b ? e : new b(e)
2150
+ });
2151
+ }
2152
+ /**
2153
+ * Bring the webview to front and focus.
2154
+ * @example
2155
+ * ```typescript
2156
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2157
+ * await getCurrentWebview().setFocus();
2158
+ * ```
2159
+ *
2160
+ * @returns A promise indicating the success or failure of the operation.
2161
+ */
2162
+ async setFocus() {
2163
+ return s("plugin:webview|set_webview_focus", {
2164
+ label: this.label
2165
+ });
2166
+ }
2167
+ /**
2168
+ * Hide the webview.
2169
+ * @example
2170
+ * ```typescript
2171
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2172
+ * await getCurrentWebview().hide();
2173
+ * ```
2174
+ *
2175
+ * @returns A promise indicating the success or failure of the operation.
2176
+ */
2177
+ async hide() {
2178
+ return s("plugin:webview|webview_hide", {
2179
+ label: this.label
2180
+ });
2181
+ }
2182
+ /**
2183
+ * Show the webview.
2184
+ * @example
2185
+ * ```typescript
2186
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2187
+ * await getCurrentWebview().show();
2188
+ * ```
2189
+ *
2190
+ * @returns A promise indicating the success or failure of the operation.
2191
+ */
2192
+ async show() {
2193
+ return s("plugin:webview|webview_show", {
2194
+ label: this.label
2195
+ });
2196
+ }
2197
+ /**
2198
+ * Set webview zoom level.
2199
+ * @example
2200
+ * ```typescript
2201
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2202
+ * await getCurrentWebview().setZoom(1.5);
2203
+ * ```
2204
+ *
2205
+ * @returns A promise indicating the success or failure of the operation.
2206
+ */
2207
+ async setZoom(e) {
2208
+ return s("plugin:webview|set_webview_zoom", {
2209
+ label: this.label,
2210
+ value: e
2211
+ });
2212
+ }
2213
+ /**
2214
+ * Moves this webview to the given label.
2215
+ * @example
2216
+ * ```typescript
2217
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2218
+ * await getCurrentWebview().reparent('other-window');
2219
+ * ```
2220
+ *
2221
+ * @returns A promise indicating the success or failure of the operation.
2222
+ */
2223
+ async reparent(e) {
2224
+ return s("plugin:webview|reparent", {
2225
+ label: this.label,
2226
+ window: typeof e == "string" ? e : e.label
2227
+ });
2228
+ }
2229
+ /**
2230
+ * Clears all browsing data for this webview.
2231
+ * @example
2232
+ * ```typescript
2233
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2234
+ * await getCurrentWebview().clearAllBrowsingData();
2235
+ * ```
2236
+ *
2237
+ * @returns A promise indicating the success or failure of the operation.
2238
+ */
2239
+ async clearAllBrowsingData() {
2240
+ return s("plugin:webview|clear_all_browsing_data");
2241
+ }
2242
+ /**
2243
+ * Specify the webview background color.
2244
+ *
2245
+ * #### Platfrom-specific:
2246
+ *
2247
+ * - **macOS / iOS**: Not implemented.
2248
+ * - **Windows**:
2249
+ * - On Windows 7, transparency is not supported and the alpha value will be ignored.
2250
+ * - On Windows higher than 7: translucent colors are not supported so any alpha value other than `0` will be replaced by `255`
2251
+ *
2252
+ * @returns A promise indicating the success or failure of the operation.
2253
+ *
2254
+ * @since 2.1.0
2255
+ */
2256
+ async setBackgroundColor(e) {
2257
+ return s("plugin:webview|set_webview_background_color", { color: e });
2258
+ }
2259
+ // Listeners
2260
+ /**
2261
+ * Listen to a file drop event.
2262
+ * The listener is triggered when the user hovers the selected files on the webview,
2263
+ * drops the files or cancels the operation.
2264
+ *
2265
+ * @example
2266
+ * ```typescript
2267
+ * import { getCurrentWebview } from "@tauri-apps/api/webview";
2268
+ * const unlisten = await getCurrentWebview().onDragDropEvent((event) => {
2269
+ * if (event.payload.type === 'over') {
2270
+ * console.log('User hovering', event.payload.position);
2271
+ * } else if (event.payload.type === 'drop') {
2272
+ * console.log('User dropped', event.payload.paths);
2273
+ * } else {
2274
+ * console.log('File drop cancelled');
2275
+ * }
2276
+ * });
2277
+ *
2278
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
2279
+ * unlisten();
2280
+ * ```
2281
+ *
2282
+ * When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation.
2283
+ * To retrieve the correct drop position, please detach the debugger.
2284
+ *
2285
+ * @returns A promise resolving to a function to unlisten to the event.
2286
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2287
+ */
2288
+ async onDragDropEvent(e) {
2289
+ const i = await this.listen(o.DRAG_ENTER, (a) => {
2290
+ e({
2291
+ ...a,
2292
+ payload: {
2293
+ type: "enter",
2294
+ paths: a.payload.paths,
2295
+ position: new u(a.payload.position)
2296
+ }
2297
+ });
2298
+ }), n = await this.listen(o.DRAG_OVER, (a) => {
2299
+ e({
2300
+ ...a,
2301
+ payload: {
2302
+ type: "over",
2303
+ position: new u(a.payload.position)
2304
+ }
2305
+ });
2306
+ }), l = await this.listen(o.DRAG_DROP, (a) => {
2307
+ e({
2308
+ ...a,
2309
+ payload: {
2310
+ type: "drop",
2311
+ paths: a.payload.paths,
2312
+ position: new u(a.payload.position)
2313
+ }
2314
+ });
2315
+ }), r = await this.listen(o.DRAG_LEAVE, (a) => {
2316
+ e({ ...a, payload: { type: "leave" } });
2317
+ });
2318
+ return () => {
2319
+ i(), l(), n(), r();
2320
+ };
2321
+ }
2322
+ }
2323
+ function Z() {
2324
+ const t = J();
2325
+ return new w(t.label, { skip: !0 });
2326
+ }
2327
+ async function E() {
2328
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new w(e, {
2329
+ // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2330
+ skip: !0
2331
+ })));
2332
+ }
2333
+ class w {
2334
+ /**
2335
+ * Creates a new {@link Window} hosting a {@link Webview}.
2336
+ * @example
2337
+ * ```typescript
2338
+ * import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
2339
+ * const webview = new WebviewWindow('my-label', {
2340
+ * url: 'https://github.com/tauri-apps/tauri'
2341
+ * });
2342
+ * webview.once('tauri://created', function () {
2343
+ * // webview successfully created
2344
+ * });
2345
+ * webview.once('tauri://error', function (e) {
2346
+ * // an error happened creating the webview
2347
+ * });
2348
+ * ```
2349
+ *
2350
+ * @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
2351
+ * @returns The {@link WebviewWindow} instance to communicate with the window and webview.
2352
+ */
2353
+ constructor(e, i = {}) {
2354
+ var n;
2355
+ this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i != null && i.skip || s("plugin:webview|create_webview_window", {
2356
+ options: {
2357
+ ...i,
2358
+ parent: typeof i.parent == "string" ? i.parent : (n = i.parent) === null || n === void 0 ? void 0 : n.label,
2359
+ label: e
2360
+ }
2361
+ }).then(async () => this.emit("tauri://created")).catch(async (l) => this.emit("tauri://error", l));
2362
+ }
2363
+ /**
2364
+ * Gets the Webview for the webview associated with the given label.
2365
+ * @example
2366
+ * ```typescript
2367
+ * import { Webview } from '@tauri-apps/api/webviewWindow';
2368
+ * const mainWebview = Webview.getByLabel('main');
2369
+ * ```
2370
+ *
2371
+ * @param label The webview label.
2372
+ * @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
2373
+ */
2374
+ static async getByLabel(e) {
2375
+ var i;
2376
+ const n = (i = (await E()).find((l) => l.label === e)) !== null && i !== void 0 ? i : null;
2377
+ return n ? new w(n.label, { skip: !0 }) : null;
2378
+ }
2379
+ /**
2380
+ * Get an instance of `Webview` for the current webview.
2381
+ */
2382
+ static getCurrent() {
2383
+ return Z();
2384
+ }
2385
+ /**
2386
+ * Gets a list of instances of `Webview` for all available webviews.
2387
+ */
2388
+ static async getAll() {
2389
+ return E();
2390
+ }
2391
+ /**
2392
+ * Listen to an emitted event on this webivew window.
2393
+ *
2394
+ * @example
2395
+ * ```typescript
2396
+ * import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
2397
+ * const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => {
2398
+ * console.log(`Got error: ${payload}`);
2399
+ * });
2400
+ *
2401
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
2402
+ * unlisten();
2403
+ * ```
2404
+ *
2405
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
2406
+ * @param handler Event handler.
2407
+ * @returns A promise resolving to a function to unlisten to the event.
2408
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2409
+ */
2410
+ async listen(e, i) {
2411
+ return this._handleTauriEvent(e, i) ? () => {
2412
+ const n = this.listeners[e];
2413
+ n.splice(n.indexOf(i), 1);
2414
+ } : v(e, i, {
2415
+ target: { kind: "WebviewWindow", label: this.label }
2416
+ });
2417
+ }
2418
+ /**
2419
+ * Listen to an emitted event on this webview window only once.
2420
+ *
2421
+ * @example
2422
+ * ```typescript
2423
+ * import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
2424
+ * const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => {
2425
+ * console.log(`Webview initialized!`);
2426
+ * });
2427
+ *
2428
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
2429
+ * unlisten();
2430
+ * ```
2431
+ *
2432
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
2433
+ * @param handler Event handler.
2434
+ * @returns A promise resolving to a function to unlisten to the event.
2435
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2436
+ */
2437
+ async once(e, i) {
2438
+ return this._handleTauriEvent(e, i) ? () => {
2439
+ const n = this.listeners[e];
2440
+ n.splice(n.indexOf(i), 1);
2441
+ } : A(e, i, {
2442
+ target: { kind: "WebviewWindow", label: this.label }
2443
+ });
2444
+ }
2445
+ /**
2446
+ * Set the window and webview background color.
2447
+ *
2448
+ * #### Platform-specific:
2449
+ *
2450
+ * - **Android / iOS:** Unsupported for the window layer.
2451
+ * - **macOS / iOS**: Not implemented for the webview layer.
2452
+ * - **Windows**:
2453
+ * - alpha channel is ignored for the window layer.
2454
+ * - On Windows 7, alpha channel is ignored for the webview layer.
2455
+ * - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored.
2456
+ *
2457
+ * @returns A promise indicating the success or failure of the operation.
2458
+ *
2459
+ * @since 2.1.0
2460
+ */
2461
+ async setBackgroundColor(e) {
2462
+ return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
2463
+ }
2464
+ }
2465
+ ye(w, [P, T]);
2466
+ function ye(t, e) {
2467
+ (Array.isArray(e) ? e : [e]).forEach((i) => {
2468
+ Object.getOwnPropertyNames(i.prototype).forEach((n) => {
2469
+ var l;
2470
+ typeof t.prototype == "object" && t.prototype && n in t.prototype || Object.defineProperty(
2471
+ t.prototype,
2472
+ n,
2473
+ // eslint-disable-next-line
2474
+ (l = Object.getOwnPropertyDescriptor(i.prototype, n)) !== null && l !== void 0 ? l : /* @__PURE__ */ Object.create(null)
2475
+ );
2476
+ });
2477
+ });
2478
+ }
2479
+ const pe = (t) => JSON.stringify(t), ge = (t) => JSON.parse(t), W = "drift://action", _e = "tauri://error", fe = "tauri://created", me = (t) => new Error(`Window not found: ${t}`), y = 250, ve = ie.seconds(1), m = (t) => {
2480
+ if (t != null)
2481
+ return {
2482
+ width: Math.max(t.width, y),
2483
+ height: Math.max(t.height, y)
2484
+ };
2485
+ }, De = (t) => {
2486
+ const { size: e, maxSize: i } = t;
2487
+ return { ...t, maxSize: m(i), size: m(e) };
2488
+ }, We = async () => (await be()).map((e) => {
2489
+ const i = I(e.position, e.scaleFactor), n = { width: e.size.width, height: e.size.height };
2490
+ return G.construct(i, n);
2491
+ }), V = async (t) => (await We()).some((i) => G.contains(i, t));
2492
+ class Pe {
2493
+ /**
2494
+ * @param window - The WebviewWindow to use as the underlying engine for this runtime.
2495
+ * This should not be set in 99% of cases. Only use this if you know what you're doing.
2496
+ */
2497
+ constructor(e) {
2498
+ D(this, "win");
2499
+ D(this, "unsubscribe");
2500
+ D(this, "fullscreenPoll", null);
2501
+ this.win = e ?? Z(), this.unsubscribe = {};
2502
+ }
2503
+ async configure() {
2504
+ await this.startFullscreenPoll();
2505
+ }
2506
+ async startFullscreenPoll() {
2507
+ if (te.getOS() !== "macOS") return;
2508
+ let e = (await this.getProps()).fullscreen;
2509
+ this.fullscreenPoll = setInterval(() => {
2510
+ this.win.isFullscreen().then((i) => {
2511
+ i !== e && (e = i, this.emit(
2512
+ {
2513
+ action: g({
2514
+ label: this.win.label,
2515
+ fullscreen: i
2516
+ })
2517
+ },
2518
+ void 0,
2519
+ "WHITELIST"
2520
+ ).catch(console.error));
2521
+ }).catch(console.error);
2522
+ }, ve.milliseconds);
2523
+ }
2524
+ label() {
2525
+ return this.win.label;
2526
+ }
2527
+ isMain() {
2528
+ return this.win.label === ne;
2529
+ }
2530
+ release() {
2531
+ Object.values(this.unsubscribe).forEach((e) => e == null ? void 0 : e()), this.fullscreenPoll != null && clearInterval(this.fullscreenPoll), this.unsubscribe = {};
2532
+ }
2533
+ async emit(e, i, n = this.label()) {
2534
+ const l = pe({ ...e, emitter: n });
2535
+ if (i == null) return await L(W, l);
2536
+ const r = await w.getByLabel(i);
2537
+ if (r == null) throw me(i);
2538
+ await r.emit(W, l);
2539
+ }
2540
+ async subscribe(e) {
2541
+ this.release(), await this.startFullscreenPoll(), this.unsubscribe[W] = await v(
2542
+ W,
2543
+ (n) => e(ge(n.payload))
2544
+ );
2545
+ const i = Oe();
2546
+ for (const { key: n, handler: l, debounce: r } of i)
2547
+ this.unsubscribe[n] = await this.win.listen(
2548
+ n,
2549
+ re(() => {
2550
+ l(this.win).then((a) => {
2551
+ a != null && this.emit({ action: a }, void 0, "WHITELIST").catch(
2552
+ console.error
2553
+ );
2554
+ }).catch(console.error);
2555
+ }, r)
2556
+ );
2557
+ }
2558
+ onCloseRequested(e) {
2559
+ this.win.onCloseRequested((i) => {
2560
+ i.preventDefault(), e();
2561
+ });
2562
+ }
2563
+ async create(e, i) {
2564
+ i = se.copy(i);
2565
+ const { size: n, minSize: l, maxSize: r, position: a, ...$ } = De(i);
2566
+ (n == null ? void 0 : n.width) != null && (n.width = Math.max(n.width, y)), (n == null ? void 0 : n.height) != null && (n.height = Math.max(n.height, y)), (r == null ? void 0 : r.width) != null && (r.width = Math.max(r.width, y)), (r == null ? void 0 : r.height) != null && (r.height = Math.max(r.height, y)), a != null && (await V(a) || (a.x = 0, a.y = 0));
2567
+ try {
2568
+ const p = new w(e, {
2569
+ x: a == null ? void 0 : a.x,
2570
+ y: a == null ? void 0 : a.y,
2571
+ width: n == null ? void 0 : n.width,
2572
+ height: n == null ? void 0 : n.height,
2573
+ minWidth: l == null ? void 0 : l.width,
2574
+ minHeight: l == null ? void 0 : l.height,
2575
+ maxWidth: r == null ? void 0 : r.width,
2576
+ maxHeight: r == null ? void 0 : r.height,
2577
+ titleBarStyle: "overlay",
2578
+ dragDropEnabled: !1,
2579
+ ...$
2580
+ });
2581
+ return await new Promise((K, Q) => {
2582
+ p.once(_e, (Y) => Q(new Error(JSON.stringify(Y.payload)))), p.once(fe, () => K());
2583
+ });
2584
+ } catch (p) {
2585
+ console.error(p);
2586
+ }
2587
+ }
2588
+ async close(e) {
2589
+ const i = await w.getByLabel(e);
2590
+ if (i != null)
2591
+ try {
2592
+ await i.destroy();
2593
+ } catch (n) {
2594
+ console.error(n, e);
2595
+ }
2596
+ else {
2597
+ const n = await E();
2598
+ console.error(
2599
+ "Window not found",
2600
+ e,
2601
+ n.map((l) => l.label)
2602
+ );
2603
+ }
2604
+ }
2605
+ async listLabels() {
2606
+ return (await E()).map((i) => i.label);
2607
+ }
2608
+ async focus() {
2609
+ return await this.win.setFocus();
2610
+ }
2611
+ async setMinimized(e) {
2612
+ return e ? await this.win.minimize() : await this.win.unminimize();
2613
+ }
2614
+ async setMaximized(e) {
2615
+ return e ? await this.win.maximize() : await this.win.unmaximize();
2616
+ }
2617
+ async setVisible(e) {
2618
+ return e ? await this.win.show() : await this.win.hide();
2619
+ }
2620
+ async setFullscreen(e) {
2621
+ await this.win.setFullscreen(e);
2622
+ }
2623
+ async center() {
2624
+ return await this.win.center();
2625
+ }
2626
+ async setPosition(e) {
2627
+ const i = new N(e.x, e.y);
2628
+ await V(e) || (i.x = 0, i.y = 0), await this.win.setPosition(i);
2629
+ }
2630
+ async setSize(e) {
2631
+ e = m(e), await this.win.setSize(new _(e.width, e.height));
2632
+ }
2633
+ async setMinSize(e) {
2634
+ e = m(e), await this.win.setMinSize(new _(e.width, e.height));
2635
+ }
2636
+ async setMaxSize(e) {
2637
+ e = m(e), await this.win.setMaxSize(new _(e.width, e.height));
2638
+ }
2639
+ async setResizable(e) {
2640
+ var i, n;
2641
+ return o.WINDOW_RESIZED in this.unsubscribe && !e && ((n = (i = this.unsubscribe)[o.WINDOW_RESIZED]) == null || n.call(i), delete this.unsubscribe[o.WINDOW_RESIZED]), await this.win.setResizable(e);
2642
+ }
2643
+ async setSkipTaskbar(e) {
2644
+ return await this.win.setSkipTaskbar(e);
2645
+ }
2646
+ async setAlwaysOnTop(e) {
2647
+ return await this.win.setAlwaysOnTop(e);
2648
+ }
2649
+ async setTitle(e) {
2650
+ return await this.win.setTitle(e);
2651
+ }
2652
+ async setDecorations(e) {
2653
+ return await this.win.setDecorations(e);
2654
+ }
2655
+ async getProps() {
2656
+ const e = await this.win.scaleFactor(), i = await this.win.isVisible();
2657
+ return {
2658
+ position: I(await this.win.innerPosition(), e),
2659
+ size: q(await this.win.innerSize(), e),
2660
+ maximized: await this.win.isMaximized(),
2661
+ visible: i,
2662
+ fullscreen: await this.win.isFullscreen()
2663
+ };
2664
+ }
2665
+ }
2666
+ const Oe = () => [
2667
+ {
2668
+ key: o.WINDOW_RESIZED,
2669
+ debounce: 200,
2670
+ handler: async (t) => {
2671
+ const e = await t.scaleFactor(), i = await t.isVisible(), n = {
2672
+ label: t.label,
2673
+ maximized: await t.isMaximized(),
2674
+ visible: i,
2675
+ minimized: !i,
2676
+ position: I(await t.innerPosition(), e),
2677
+ size: q(await t.innerSize(), e)
2678
+ };
2679
+ return g(n);
2680
+ }
2681
+ },
2682
+ {
2683
+ key: o.WINDOW_MOVED,
2684
+ debounce: 200,
2685
+ handler: async (t) => {
2686
+ const e = await (t == null ? void 0 : t.scaleFactor());
2687
+ if (e == null) return null;
2688
+ const i = I(await t.innerPosition(), e), n = await t.isVisible(), l = {
2689
+ label: t.label,
2690
+ visible: n,
2691
+ position: i
2692
+ };
2693
+ return g(l);
2694
+ }
2695
+ },
2696
+ {
2697
+ key: o.WINDOW_BLUR,
2698
+ debounce: 0,
2699
+ handler: async (t) => g({ focus: !1, label: t.label })
2700
+ },
2701
+ {
2702
+ key: o.WINDOW_FOCUS,
2703
+ debounce: 0,
2704
+ handler: async (t) => g({
2705
+ focus: !0,
2706
+ visible: !0,
2707
+ minimized: !1,
2708
+ label: t.label
2709
+ })
2710
+ }
2711
+ ], I = (t, e) => le.scale(t, 1 / e), q = (t, e) => ae.scale(t, 1 / e);
2712
+ export {
2713
+ Pe as TauriRuntime
2714
+ };