@synnaxlabs/drift 0.42.3 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tauri.js CHANGED
@@ -1,31 +1,27 @@
1
- var ee = Object.defineProperty;
2
- var ie = (t, e, i) => e in t ? ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var D = (t, e, i) => ie(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { O as te, S as ne, M as se, _ as le, J as ae, $ as G } from "./window-DwJfMpbK.js";
5
- import { r as g, F as re } from "./state-BX_5GHgM.js";
6
- import { o as oe } from "./debounce-DOZKRZa9.js";
7
- function ue(t, e, i, n) {
8
- if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1
+ import { G as X, H as ee, r as g, M as ie, K as te, _ as ne, J as se, $ as U } from "./state-D41-Dai4.js";
2
+ import { o as le } from "./debounce-DOZKRZa9.js";
3
+ function ae(t, e, i, n) {
4
+ 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
5
  return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
10
6
  }
11
- function ce(t, e, i, n, l) {
7
+ function re(t, e, i, n, l) {
12
8
  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
9
  return e.set(t, i), i;
14
10
  }
15
- var O;
11
+ var W;
16
12
  const c = "__TAURI_TO_IPC_KEY__";
17
- function he(t, e = !1) {
13
+ function oe(t, e = !1) {
18
14
  return window.__TAURI_INTERNALS__.transformCallback(t, e);
19
15
  }
20
16
  async function s(t, e = {}, i) {
21
17
  return window.__TAURI_INTERNALS__.invoke(t, e, i);
22
18
  }
23
- class we {
19
+ class ue {
24
20
  get rid() {
25
- return ue(this, O, "f");
21
+ return ae(this, W, "f");
26
22
  }
27
23
  constructor(e) {
28
- O.set(this, void 0), ce(this, O, e);
24
+ W.set(this, void 0), re(this, W, e);
29
25
  }
30
26
  /**
31
27
  * Destroys and cleans up this resource from memory.
@@ -37,38 +33,38 @@ class we {
37
33
  });
38
34
  }
39
35
  }
40
- O = /* @__PURE__ */ new WeakMap();
41
- var o;
36
+ W = /* @__PURE__ */ new WeakMap();
37
+ var r;
42
38
  (function(t) {
43
39
  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", {
40
+ })(r || (r = {}));
41
+ async function G(t, e) {
42
+ window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
47
43
  event: t,
48
44
  eventId: e
49
45
  });
50
46
  }
51
- async function m(t, e, i) {
47
+ async function f(t, e, i) {
52
48
  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" };
49
+ const l = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
54
50
  return s("plugin:event|listen", {
55
51
  event: t,
56
52
  target: l,
57
- handler: he(e)
58
- }).then((r) => async () => H(t, r));
53
+ handler: oe(e)
54
+ }).then((o) => async () => G(t, o));
59
55
  }
60
56
  async function k(t, e, i) {
61
- return m(t, (n) => {
62
- H(t, n.id), e(n);
57
+ return f(t, (n) => {
58
+ G(t, n.id), e(n);
63
59
  }, i);
64
60
  }
65
- async function L(t, e) {
61
+ async function P(t, e) {
66
62
  await s("plugin:event|emit", {
67
63
  event: t,
68
64
  payload: e
69
65
  });
70
66
  }
71
- async function j(t, e, i) {
67
+ async function H(t, e, i) {
72
68
  await s("plugin:event|emit_to", {
73
69
  target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
74
70
  event: e,
@@ -95,7 +91,7 @@ class _ {
95
91
  * @since 2.0.0
96
92
  */
97
93
  toPhysical(e) {
98
- return new b(this.width * e, this.height * e);
94
+ return new w(this.width * e, this.height * e);
99
95
  }
100
96
  [c]() {
101
97
  return {
@@ -107,7 +103,7 @@ class _ {
107
103
  return this[c]();
108
104
  }
109
105
  }
110
- class b {
106
+ class w {
111
107
  constructor(...e) {
112
108
  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
109
  }
@@ -143,7 +139,7 @@ class h {
143
139
  return this.size instanceof _ ? this.size : this.size.toLogical(e);
144
140
  }
145
141
  toPhysical(e) {
146
- return this.size instanceof b ? this.size : this.size.toPhysical(e);
142
+ return this.size instanceof w ? this.size : this.size.toPhysical(e);
147
143
  }
148
144
  [c]() {
149
145
  return {
@@ -243,7 +239,7 @@ class d {
243
239
  return this[c]();
244
240
  }
245
241
  }
246
- class v extends we {
242
+ class m extends ue {
247
243
  /**
248
244
  * Creates an Image from a resource ID. For internal use only.
249
245
  *
@@ -258,7 +254,7 @@ class v extends we {
258
254
  rgba: z(e),
259
255
  width: i,
260
256
  height: n
261
- }).then((l) => new v(l));
257
+ }).then((l) => new m(l));
262
258
  }
263
259
  /**
264
260
  * Creates a new image using the provided bytes by inferring the file format.
@@ -276,7 +272,7 @@ class v extends we {
276
272
  static async fromBytes(e) {
277
273
  return s("plugin:image|from_bytes", {
278
274
  bytes: z(e)
279
- }).then((i) => new v(i));
275
+ }).then((i) => new m(i));
280
276
  }
281
277
  /**
282
278
  * Creates a new image using the provided path.
@@ -291,7 +287,7 @@ class v extends we {
291
287
  * ```
292
288
  */
293
289
  static async fromPath(e) {
294
- return s("plugin:image|from_path", { path: e }).then((i) => new v(i));
290
+ return s("plugin:image|from_path", { path: e }).then((i) => new m(i));
295
291
  }
296
292
  /** Returns the RGBA data for this image, in row-major order from top to bottom. */
297
293
  async rgba() {
@@ -305,13 +301,13 @@ class v extends we {
305
301
  }
306
302
  }
307
303
  function z(t) {
308
- return t == null ? null : typeof t == "string" ? t : t instanceof v ? t.rid : t;
304
+ return t == null ? null : typeof t == "string" ? t : t instanceof m ? t.rid : t;
309
305
  }
310
- var A;
306
+ var R;
311
307
  (function(t) {
312
308
  t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
313
- })(A || (A = {}));
314
- class be {
309
+ })(R || (R = {}));
310
+ class ce {
315
311
  constructor(e) {
316
312
  this._preventDefault = !1, this.event = e.event, this.id = e.id;
317
313
  }
@@ -326,20 +322,20 @@ var T;
326
322
  (function(t) {
327
323
  t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
328
324
  })(T || (T = {}));
329
- function J() {
330
- return new S(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
325
+ function j() {
326
+ return new x(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
331
327
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
332
328
  skip: !0
333
329
  });
334
330
  }
335
- async function x() {
336
- return s("plugin:window|get_all_windows").then((t) => t.map((e) => new S(e, {
331
+ async function E() {
332
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new x(e, {
337
333
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
338
334
  skip: !0
339
335
  })));
340
336
  }
341
- const P = ["tauri://created", "tauri://error"];
342
- class S {
337
+ const A = ["tauri://created", "tauri://error"];
338
+ class x {
343
339
  /**
344
340
  * Creates a new Window.
345
341
  * @example
@@ -359,7 +355,7 @@ class S {
359
355
  */
360
356
  constructor(e, i = {}) {
361
357
  var n;
362
- this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i != null && i.skip || s("plugin:window|create", {
358
+ this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i?.skip || s("plugin:window|create", {
363
359
  options: {
364
360
  ...i,
365
361
  parent: typeof i.parent == "string" ? i.parent : (n = i.parent) === null || n === void 0 ? void 0 : n.label,
@@ -380,19 +376,19 @@ class S {
380
376
  */
381
377
  static async getByLabel(e) {
382
378
  var i;
383
- return (i = (await x()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
379
+ return (i = (await E()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
384
380
  }
385
381
  /**
386
382
  * Get an instance of `Window` for the current window.
387
383
  */
388
384
  static getCurrent() {
389
- return J();
385
+ return j();
390
386
  }
391
387
  /**
392
388
  * Gets a list of instances of `Window` for all available windows.
393
389
  */
394
390
  static async getAll() {
395
- return x();
391
+ return E();
396
392
  }
397
393
  /**
398
394
  * Gets the focused window.
@@ -405,7 +401,7 @@ class S {
405
401
  * @returns The Window instance or `undefined` if there is not any focused window.
406
402
  */
407
403
  static async getFocusedWindow() {
408
- for (const e of await x())
404
+ for (const e of await E())
409
405
  if (await e.isFocused())
410
406
  return e;
411
407
  return null;
@@ -433,7 +429,7 @@ class S {
433
429
  return this._handleTauriEvent(e, i) ? () => {
434
430
  const n = this.listeners[e];
435
431
  n.splice(n.indexOf(i), 1);
436
- } : m(e, i, {
432
+ } : f(e, i, {
437
433
  target: { kind: "Window", label: this.label }
438
434
  });
439
435
  }
@@ -476,7 +472,7 @@ class S {
476
472
  * @param payload Event payload.
477
473
  */
478
474
  async emit(e, i) {
479
- if (P.includes(e)) {
475
+ if (A.includes(e)) {
480
476
  for (const n of this.listeners[e] || [])
481
477
  n({
482
478
  event: e,
@@ -485,7 +481,7 @@ class S {
485
481
  });
486
482
  return;
487
483
  }
488
- return L(e, i);
484
+ return P(e, i);
489
485
  }
490
486
  /**
491
487
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -500,7 +496,7 @@ class S {
500
496
  * @param payload Event payload.
501
497
  */
502
498
  async emitTo(e, i, n) {
503
- if (P.includes(i)) {
499
+ if (A.includes(i)) {
504
500
  for (const l of this.listeners[i] || [])
505
501
  l({
506
502
  event: i,
@@ -509,11 +505,11 @@ class S {
509
505
  });
510
506
  return;
511
507
  }
512
- return j(e, i, n);
508
+ return H(e, i, n);
513
509
  }
514
510
  /** @ignore */
515
511
  _handleTauriEvent(e, i) {
516
- return P.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
512
+ return A.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
517
513
  }
518
514
  // Getters
519
515
  /**
@@ -575,7 +571,7 @@ class S {
575
571
  async innerSize() {
576
572
  return s("plugin:window|inner_size", {
577
573
  label: this.label
578
- }).then((e) => new b(e));
574
+ }).then((e) => new w(e));
579
575
  }
580
576
  /**
581
577
  * The physical size of the entire window.
@@ -591,7 +587,7 @@ class S {
591
587
  async outerSize() {
592
588
  return s("plugin:window|outer_size", {
593
589
  label: this.label
594
- }).then((e) => new b(e));
590
+ }).then((e) => new w(e));
595
591
  }
596
592
  /**
597
593
  * Gets the window's current fullscreen state.
@@ -842,7 +838,7 @@ class S {
842
838
  */
843
839
  async requestUserAttention(e) {
844
840
  let i = null;
845
- return e && (e === A.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
841
+ return e && (e === R.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
846
842
  label: this.label,
847
843
  value: i
848
844
  });
@@ -1297,10 +1293,10 @@ class S {
1297
1293
  return s("plugin:window|set_size_constraints", {
1298
1294
  label: this.label,
1299
1295
  value: {
1300
- minWidth: i(e == null ? void 0 : e.minWidth),
1301
- minHeight: i(e == null ? void 0 : e.minHeight),
1302
- maxWidth: i(e == null ? void 0 : e.maxWidth),
1303
- maxHeight: i(e == null ? void 0 : e.maxHeight)
1296
+ minWidth: i(e?.minWidth),
1297
+ minHeight: i(e?.minHeight),
1298
+ maxWidth: i(e?.maxWidth),
1299
+ maxHeight: i(e?.maxHeight)
1304
1300
  }
1305
1301
  });
1306
1302
  }
@@ -1698,8 +1694,8 @@ class S {
1698
1694
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1699
1695
  */
1700
1696
  async onResized(e) {
1701
- return this.listen(o.WINDOW_RESIZED, (i) => {
1702
- i.payload = new b(i.payload), e(i);
1697
+ return this.listen(r.WINDOW_RESIZED, (i) => {
1698
+ i.payload = new w(i.payload), e(i);
1703
1699
  });
1704
1700
  }
1705
1701
  /**
@@ -1720,7 +1716,7 @@ class S {
1720
1716
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1721
1717
  */
1722
1718
  async onMoved(e) {
1723
- return this.listen(o.WINDOW_MOVED, (i) => {
1719
+ return this.listen(r.WINDOW_MOVED, (i) => {
1724
1720
  i.payload = new u(i.payload), e(i);
1725
1721
  });
1726
1722
  }
@@ -1747,8 +1743,8 @@ class S {
1747
1743
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1748
1744
  */
1749
1745
  async onCloseRequested(e) {
1750
- return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
1751
- const n = new be(i);
1746
+ return this.listen(r.WINDOW_CLOSE_REQUESTED, async (i) => {
1747
+ const n = new ce(i);
1752
1748
  await e(n), n.isPreventDefault() || await this.destroy();
1753
1749
  });
1754
1750
  }
@@ -1778,7 +1774,7 @@ class S {
1778
1774
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1779
1775
  */
1780
1776
  async onDragDropEvent(e) {
1781
- const i = await this.listen(o.DRAG_ENTER, (a) => {
1777
+ const i = await this.listen(r.DRAG_ENTER, (a) => {
1782
1778
  e({
1783
1779
  ...a,
1784
1780
  payload: {
@@ -1787,7 +1783,7 @@ class S {
1787
1783
  position: new u(a.payload.position)
1788
1784
  }
1789
1785
  });
1790
- }), n = await this.listen(o.DRAG_OVER, (a) => {
1786
+ }), n = await this.listen(r.DRAG_OVER, (a) => {
1791
1787
  e({
1792
1788
  ...a,
1793
1789
  payload: {
@@ -1795,7 +1791,7 @@ class S {
1795
1791
  position: new u(a.payload.position)
1796
1792
  }
1797
1793
  });
1798
- }), l = await this.listen(o.DRAG_DROP, (a) => {
1794
+ }), l = await this.listen(r.DRAG_DROP, (a) => {
1799
1795
  e({
1800
1796
  ...a,
1801
1797
  payload: {
@@ -1804,11 +1800,11 @@ class S {
1804
1800
  position: new u(a.payload.position)
1805
1801
  }
1806
1802
  });
1807
- }), r = await this.listen(o.DRAG_LEAVE, (a) => {
1803
+ }), o = await this.listen(r.DRAG_LEAVE, (a) => {
1808
1804
  e({ ...a, payload: { type: "leave" } });
1809
1805
  });
1810
1806
  return () => {
1811
- i(), l(), n(), r();
1807
+ i(), l(), n(), o();
1812
1808
  };
1813
1809
  }
1814
1810
  /**
@@ -1829,9 +1825,9 @@ class S {
1829
1825
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1830
1826
  */
1831
1827
  async onFocusChanged(e) {
1832
- const i = await this.listen(o.WINDOW_FOCUS, (l) => {
1828
+ const i = await this.listen(r.WINDOW_FOCUS, (l) => {
1833
1829
  e({ ...l, payload: !0 });
1834
- }), n = await this.listen(o.WINDOW_BLUR, (l) => {
1830
+ }), n = await this.listen(r.WINDOW_BLUR, (l) => {
1835
1831
  e({ ...l, payload: !1 });
1836
1832
  });
1837
1833
  return () => {
@@ -1860,7 +1856,7 @@ class S {
1860
1856
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1861
1857
  */
1862
1858
  async onScaleChanged(e) {
1863
- return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED, e);
1859
+ return this.listen(r.WINDOW_SCALE_FACTOR_CHANGED, e);
1864
1860
  }
1865
1861
  /**
1866
1862
  * Listen to the system theme change.
@@ -1880,40 +1876,44 @@ class S {
1880
1876
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1881
1877
  */
1882
1878
  async onThemeChanged(e) {
1883
- return this.listen(o.WINDOW_THEME_CHANGED, e);
1879
+ return this.listen(r.WINDOW_THEME_CHANGED, e);
1884
1880
  }
1885
1881
  }
1886
- var M;
1882
+ var C;
1887
1883
  (function(t) {
1888
1884
  t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
1889
- })(M || (M = {}));
1890
- var F;
1885
+ })(C || (C = {}));
1886
+ var M;
1891
1887
  (function(t) {
1892
1888
  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";
1893
- })(F || (F = {}));
1894
- var B;
1889
+ })(M || (M = {}));
1890
+ var F;
1895
1891
  (function(t) {
1896
1892
  t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
1897
- })(B || (B = {}));
1898
- function de(t) {
1893
+ })(F || (F = {}));
1894
+ function he(t) {
1899
1895
  return t === null ? null : {
1900
1896
  name: t.name,
1901
1897
  scaleFactor: t.scaleFactor,
1902
1898
  position: new u(t.position),
1903
- size: new b(t.size)
1899
+ size: new w(t.size),
1900
+ workArea: {
1901
+ position: new u(t.workArea.position),
1902
+ size: new w(t.workArea.size)
1903
+ }
1904
1904
  };
1905
1905
  }
1906
- async function ye() {
1907
- return s("plugin:window|available_monitors").then((t) => t.map(de));
1906
+ async function we() {
1907
+ return s("plugin:window|available_monitors").then((t) => t.map(he));
1908
1908
  }
1909
- function Z() {
1910
- return new C(J(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
1909
+ function J() {
1910
+ return new L(j(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
1911
1911
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
1912
1912
  skip: !0
1913
1913
  });
1914
1914
  }
1915
- async function V() {
1916
- return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new C(new S(e.windowLabel, {
1915
+ async function B() {
1916
+ return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new L(new x(e.windowLabel, {
1917
1917
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
1918
1918
  skip: !0
1919
1919
  }), e.label, {
@@ -1921,8 +1921,8 @@ async function V() {
1921
1921
  skip: !0
1922
1922
  })));
1923
1923
  }
1924
- const R = ["tauri://created", "tauri://error"];
1925
- class C {
1924
+ const I = ["tauri://created", "tauri://error"];
1925
+ class L {
1926
1926
  /**
1927
1927
  * Creates a new Webview.
1928
1928
  * @example
@@ -1930,14 +1930,24 @@ class C {
1930
1930
  * import { Window } from '@tauri-apps/api/window'
1931
1931
  * import { Webview } from '@tauri-apps/api/webview'
1932
1932
  * const appWindow = new Window('my-label')
1933
- * const webview = new Webview(appWindow, 'my-label', {
1934
- * url: 'https://github.com/tauri-apps/tauri'
1935
- * });
1936
- * webview.once('tauri://created', function () {
1937
- * // webview successfully created
1938
- * });
1939
- * webview.once('tauri://error', function (e) {
1940
- * // an error happened creating the webview
1933
+ *
1934
+ * appWindow.once('tauri://created', async function() {
1935
+ * const webview = new Webview(appWindow, 'my-label', {
1936
+ * url: 'https://github.com/tauri-apps/tauri',
1937
+ *
1938
+ * // create a webview with specific logical position and size
1939
+ * x: 0,
1940
+ * y: 0,
1941
+ * width: 800,
1942
+ * height: 600,
1943
+ * });
1944
+ *
1945
+ * webview.once('tauri://created', function () {
1946
+ * // webview successfully created
1947
+ * });
1948
+ * webview.once('tauri://error', function (e) {
1949
+ * // an error happened creating the webview
1950
+ * });
1941
1951
  * });
1942
1952
  * ```
1943
1953
  *
@@ -1946,10 +1956,12 @@ class C {
1946
1956
  * @returns The {@link Webview} instance to communicate with the webview.
1947
1957
  */
1948
1958
  constructor(e, i, n) {
1949
- this.window = e, this.label = i, this.listeners = /* @__PURE__ */ Object.create(null), n != null && n.skip || s("plugin:webview|create_webview", {
1959
+ this.window = e, this.label = i, this.listeners = /* @__PURE__ */ Object.create(null), n?.skip || s("plugin:webview|create_webview", {
1950
1960
  windowLabel: e.label,
1951
- label: i,
1952
- options: n
1961
+ options: {
1962
+ ...n,
1963
+ label: i
1964
+ }
1953
1965
  }).then(async () => this.emit("tauri://created")).catch(async (l) => this.emit("tauri://error", l));
1954
1966
  }
1955
1967
  /**
@@ -1965,19 +1977,19 @@ class C {
1965
1977
  */
1966
1978
  static async getByLabel(e) {
1967
1979
  var i;
1968
- return (i = (await V()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
1980
+ return (i = (await B()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
1969
1981
  }
1970
1982
  /**
1971
1983
  * Get an instance of `Webview` for the current webview.
1972
1984
  */
1973
1985
  static getCurrent() {
1974
- return Z();
1986
+ return J();
1975
1987
  }
1976
1988
  /**
1977
1989
  * Gets a list of instances of `Webview` for all available webviews.
1978
1990
  */
1979
1991
  static async getAll() {
1980
- return V();
1992
+ return B();
1981
1993
  }
1982
1994
  /**
1983
1995
  * Listen to an emitted event on this webview.
@@ -2002,7 +2014,7 @@ class C {
2002
2014
  return this._handleTauriEvent(e, i) ? () => {
2003
2015
  const n = this.listeners[e];
2004
2016
  n.splice(n.indexOf(i), 1);
2005
- } : m(e, i, {
2017
+ } : f(e, i, {
2006
2018
  target: { kind: "Webview", label: this.label }
2007
2019
  });
2008
2020
  }
@@ -2046,7 +2058,7 @@ class C {
2046
2058
  * @param payload Event payload.
2047
2059
  */
2048
2060
  async emit(e, i) {
2049
- if (R.includes(e)) {
2061
+ if (I.includes(e)) {
2050
2062
  for (const n of this.listeners[e] || [])
2051
2063
  n({
2052
2064
  event: e,
@@ -2055,7 +2067,7 @@ class C {
2055
2067
  });
2056
2068
  return;
2057
2069
  }
2058
- return L(e, i);
2070
+ return P(e, i);
2059
2071
  }
2060
2072
  /**
2061
2073
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -2071,7 +2083,7 @@ class C {
2071
2083
  * @param payload Event payload.
2072
2084
  */
2073
2085
  async emitTo(e, i, n) {
2074
- if (R.includes(i)) {
2086
+ if (I.includes(i)) {
2075
2087
  for (const l of this.listeners[i] || [])
2076
2088
  l({
2077
2089
  event: i,
@@ -2080,11 +2092,11 @@ class C {
2080
2092
  });
2081
2093
  return;
2082
2094
  }
2083
- return j(e, i, n);
2095
+ return H(e, i, n);
2084
2096
  }
2085
2097
  /** @ignore */
2086
2098
  _handleTauriEvent(e, i) {
2087
- return R.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2099
+ return I.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2088
2100
  }
2089
2101
  // Getters
2090
2102
  /**
@@ -2116,7 +2128,7 @@ class C {
2116
2128
  async size() {
2117
2129
  return s("plugin:webview|webview_size", {
2118
2130
  label: this.label
2119
- }).then((e) => new b(e));
2131
+ }).then((e) => new w(e));
2120
2132
  }
2121
2133
  // Setters
2122
2134
  /**
@@ -2183,6 +2195,22 @@ class C {
2183
2195
  label: this.label
2184
2196
  });
2185
2197
  }
2198
+ /**
2199
+ * Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes.
2200
+ * @example
2201
+ * ```typescript
2202
+ * import { getCurrentWebview } from '@tauri-apps/api/webview';
2203
+ * await getCurrentWebview().setAutoResize(true);
2204
+ * ```
2205
+ *
2206
+ * @returns A promise indicating the success or failure of the operation.
2207
+ */
2208
+ async setAutoResize(e) {
2209
+ return s("plugin:webview|set_webview_auto_resize", {
2210
+ label: this.label,
2211
+ value: e
2212
+ });
2213
+ }
2186
2214
  /**
2187
2215
  * Hide the webview.
2188
2216
  * @example
@@ -2305,7 +2333,7 @@ class C {
2305
2333
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2306
2334
  */
2307
2335
  async onDragDropEvent(e) {
2308
- const i = await this.listen(o.DRAG_ENTER, (a) => {
2336
+ const i = await this.listen(r.DRAG_ENTER, (a) => {
2309
2337
  e({
2310
2338
  ...a,
2311
2339
  payload: {
@@ -2314,7 +2342,7 @@ class C {
2314
2342
  position: new u(a.payload.position)
2315
2343
  }
2316
2344
  });
2317
- }), n = await this.listen(o.DRAG_OVER, (a) => {
2345
+ }), n = await this.listen(r.DRAG_OVER, (a) => {
2318
2346
  e({
2319
2347
  ...a,
2320
2348
  payload: {
@@ -2322,7 +2350,7 @@ class C {
2322
2350
  position: new u(a.payload.position)
2323
2351
  }
2324
2352
  });
2325
- }), l = await this.listen(o.DRAG_DROP, (a) => {
2353
+ }), l = await this.listen(r.DRAG_DROP, (a) => {
2326
2354
  e({
2327
2355
  ...a,
2328
2356
  payload: {
@@ -2331,25 +2359,25 @@ class C {
2331
2359
  position: new u(a.payload.position)
2332
2360
  }
2333
2361
  });
2334
- }), r = await this.listen(o.DRAG_LEAVE, (a) => {
2362
+ }), o = await this.listen(r.DRAG_LEAVE, (a) => {
2335
2363
  e({ ...a, payload: { type: "leave" } });
2336
2364
  });
2337
2365
  return () => {
2338
- i(), l(), n(), r();
2366
+ i(), l(), n(), o();
2339
2367
  };
2340
2368
  }
2341
2369
  }
2342
- function q() {
2343
- const t = Z();
2344
- return new w(t.label, { skip: !0 });
2370
+ function Z() {
2371
+ const t = J();
2372
+ return new b(t.label, { skip: !0 });
2345
2373
  }
2346
- async function E() {
2347
- return s("plugin:window|get_all_windows").then((t) => t.map((e) => new w(e, {
2374
+ async function O() {
2375
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new b(e, {
2348
2376
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2349
2377
  skip: !0
2350
2378
  })));
2351
2379
  }
2352
- class w {
2380
+ class b {
2353
2381
  /**
2354
2382
  * Creates a new {@link Window} hosting a {@link Webview}.
2355
2383
  * @example
@@ -2371,7 +2399,7 @@ class w {
2371
2399
  */
2372
2400
  constructor(e, i = {}) {
2373
2401
  var n;
2374
- this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i != null && i.skip || s("plugin:webview|create_webview_window", {
2402
+ this.label = e, this.listeners = /* @__PURE__ */ Object.create(null), i?.skip || s("plugin:webview|create_webview_window", {
2375
2403
  options: {
2376
2404
  ...i,
2377
2405
  parent: typeof i.parent == "string" ? i.parent : (n = i.parent) === null || n === void 0 ? void 0 : n.label,
@@ -2392,20 +2420,20 @@ class w {
2392
2420
  */
2393
2421
  static async getByLabel(e) {
2394
2422
  var i;
2395
- const n = (i = (await E()).find((l) => l.label === e)) !== null && i !== void 0 ? i : null;
2396
- return n ? new w(n.label, { skip: !0 }) : null;
2423
+ const n = (i = (await O()).find((l) => l.label === e)) !== null && i !== void 0 ? i : null;
2424
+ return n ? new b(n.label, { skip: !0 }) : null;
2397
2425
  }
2398
2426
  /**
2399
2427
  * Get an instance of `Webview` for the current webview.
2400
2428
  */
2401
2429
  static getCurrent() {
2402
- return q();
2430
+ return Z();
2403
2431
  }
2404
2432
  /**
2405
2433
  * Gets a list of instances of `Webview` for all available webviews.
2406
2434
  */
2407
2435
  static async getAll() {
2408
- return E();
2436
+ return O();
2409
2437
  }
2410
2438
  /**
2411
2439
  * Listen to an emitted event on this webivew window.
@@ -2430,7 +2458,7 @@ class w {
2430
2458
  return this._handleTauriEvent(e, i) ? () => {
2431
2459
  const n = this.listeners[e];
2432
2460
  n.splice(n.indexOf(i), 1);
2433
- } : m(e, i, {
2461
+ } : f(e, i, {
2434
2462
  target: { kind: "WebviewWindow", label: this.label }
2435
2463
  });
2436
2464
  }
@@ -2481,8 +2509,8 @@ class w {
2481
2509
  return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
2482
2510
  }
2483
2511
  }
2484
- pe(w, [S, C]);
2485
- function pe(t, e) {
2512
+ be(b, [x, L]);
2513
+ function be(t, e) {
2486
2514
  (Array.isArray(e) ? e : [e]).forEach((i) => {
2487
2515
  Object.getOwnPropertyNames(i.prototype).forEach((n) => {
2488
2516
  var l;
@@ -2495,35 +2523,35 @@ function pe(t, e) {
2495
2523
  });
2496
2524
  });
2497
2525
  }
2498
- const ge = (t) => JSON.stringify(t), _e = (t) => JSON.parse(t), W = "drift://action", ve = "tauri://error", fe = "tauri://created", me = (t) => new Error(`Window not found: ${t}`), y = 250, De = te.seconds(1), f = (t) => {
2526
+ const de = (t) => JSON.stringify(t), ye = (t) => JSON.parse(t), D = "drift://action", pe = "tauri://error", ge = "tauri://created", _e = (t) => new Error(`Window not found: ${t}`), y = 250, me = X.seconds(1), v = (t) => {
2499
2527
  if (t != null)
2500
2528
  return {
2501
2529
  width: Math.max(t.width, y),
2502
2530
  height: Math.max(t.height, y)
2503
2531
  };
2504
- }, We = (t) => {
2532
+ }, ve = (t) => {
2505
2533
  const { size: e, maxSize: i } = t;
2506
- return { ...t, maxSize: f(i), size: f(e) };
2507
- }, Oe = async () => (await ye()).map((e) => {
2508
- const i = I(e.position, e.scaleFactor), n = { width: e.size.width, height: e.size.height };
2509
- return G.construct(i, n);
2510
- }), U = async (t) => (await Oe()).some((i) => G.contains(i, t));
2511
- class Pe {
2534
+ return { ...t, maxSize: v(i), size: v(e) };
2535
+ }, fe = async () => (await we()).map((e) => {
2536
+ const i = S(e.position, e.scaleFactor), n = { width: e.size.width, height: e.size.height };
2537
+ return U.construct(i, n);
2538
+ }), V = async (t) => (await fe()).some((i) => U.contains(i, t));
2539
+ class Oe {
2540
+ win;
2541
+ unsubscribe;
2542
+ fullscreenPoll = null;
2512
2543
  /**
2513
2544
  * @param window - The WebviewWindow to use as the underlying engine for this runtime.
2514
2545
  * This should not be set in 99% of cases. Only use this if you know what you're doing.
2515
2546
  */
2516
2547
  constructor(e) {
2517
- D(this, "win");
2518
- D(this, "unsubscribe");
2519
- D(this, "fullscreenPoll", null);
2520
- this.win = e ?? q(), this.unsubscribe = {};
2548
+ this.win = e ?? Z(), this.unsubscribe = {};
2521
2549
  }
2522
2550
  async configure() {
2523
2551
  await this.startFullscreenPoll();
2524
2552
  }
2525
2553
  async startFullscreenPoll() {
2526
- if (ne.getOS() !== "macOS") return;
2554
+ if (ee.getOS() !== "macOS") return;
2527
2555
  let e = (await this.getProps()).fullscreen;
2528
2556
  this.fullscreenPoll = setInterval(() => {
2529
2557
  this.win.isFullscreen().then((i) => {
@@ -2538,40 +2566,40 @@ class Pe {
2538
2566
  "WHITELIST"
2539
2567
  ).catch(console.error));
2540
2568
  }).catch(console.error);
2541
- }, De.milliseconds);
2569
+ }, me.milliseconds);
2542
2570
  }
2543
2571
  label() {
2544
2572
  return this.win.label;
2545
2573
  }
2546
2574
  isMain() {
2547
- return this.win.label === se;
2575
+ return this.win.label === ie;
2548
2576
  }
2549
2577
  release() {
2550
- Object.values(this.unsubscribe).forEach((e) => e == null ? void 0 : e()), this.fullscreenPoll != null && clearInterval(this.fullscreenPoll), this.unsubscribe = {};
2578
+ Object.values(this.unsubscribe).forEach((e) => e?.()), this.fullscreenPoll != null && clearInterval(this.fullscreenPoll), this.unsubscribe = {};
2551
2579
  }
2552
2580
  async emit(e, i, n = this.label()) {
2553
- const l = ge({ ...e, emitter: n });
2554
- if (i == null) return await L(W, l);
2555
- const r = await w.getByLabel(i);
2556
- if (r == null) throw me(i);
2557
- await r.emit(W, l);
2581
+ const l = de({ ...e, emitter: n });
2582
+ if (i == null) return await P(D, l);
2583
+ const o = await b.getByLabel(i);
2584
+ if (o == null) throw _e(i);
2585
+ await o.emit(D, l);
2558
2586
  }
2559
2587
  async subscribe(e) {
2560
- this.release(), await this.startFullscreenPoll(), this.unsubscribe[W] = await m(
2561
- W,
2562
- (n) => e(_e(n.payload))
2588
+ this.release(), await this.startFullscreenPoll(), this.unsubscribe[D] = await f(
2589
+ D,
2590
+ (n) => e(ye(n.payload))
2563
2591
  );
2564
- const i = ze();
2565
- for (const { key: n, handler: l, debounce: r } of i)
2592
+ const i = De();
2593
+ for (const { key: n, handler: l, debounce: o } of i)
2566
2594
  this.unsubscribe[n] = await this.win.listen(
2567
2595
  n,
2568
- oe(() => {
2596
+ le(() => {
2569
2597
  l(this.win).then((a) => {
2570
2598
  a != null && this.emit({ action: a }, void 0, "WHITELIST").catch(
2571
2599
  console.error
2572
2600
  );
2573
2601
  }).catch(console.error);
2574
- }, r)
2602
+ }, o)
2575
2603
  );
2576
2604
  }
2577
2605
  onCloseRequested(e) {
@@ -2580,32 +2608,32 @@ class Pe {
2580
2608
  });
2581
2609
  }
2582
2610
  async create(e, i) {
2583
- i = re.copy(i);
2584
- const { size: n, minSize: l, maxSize: r, position: a, ...Q } = We(i);
2585
- (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 U(a) || (a.x = 0, a.y = 0));
2611
+ i = te.copy(i);
2612
+ const { size: n, minSize: l, maxSize: o, position: a, ...$ } = ve(i);
2613
+ n?.width != null && (n.width = Math.max(n.width, y)), n?.height != null && (n.height = Math.max(n.height, y)), o?.width != null && (o.width = Math.max(o.width, y)), o?.height != null && (o.height = Math.max(o.height, y)), a != null && (await V(a) || (a.x = 0, a.y = 0));
2586
2614
  try {
2587
- const p = new w(e, {
2588
- x: a == null ? void 0 : a.x,
2589
- y: a == null ? void 0 : a.y,
2590
- width: n == null ? void 0 : n.width,
2591
- height: n == null ? void 0 : n.height,
2592
- minWidth: l == null ? void 0 : l.width,
2593
- minHeight: l == null ? void 0 : l.height,
2594
- maxWidth: r == null ? void 0 : r.width,
2595
- maxHeight: r == null ? void 0 : r.height,
2615
+ const p = new b(e, {
2616
+ x: a?.x,
2617
+ y: a?.y,
2618
+ width: n?.width,
2619
+ height: n?.height,
2620
+ minWidth: l?.width,
2621
+ minHeight: l?.height,
2622
+ maxWidth: o?.width,
2623
+ maxHeight: o?.height,
2596
2624
  titleBarStyle: "overlay",
2597
2625
  dragDropEnabled: !1,
2598
- ...Q
2626
+ ...$
2599
2627
  });
2600
- return await new Promise((Y, K) => {
2601
- p.once(ve, (X) => K(new Error(JSON.stringify(X.payload)))), p.once(fe, () => Y());
2628
+ return await new Promise((K, Q) => {
2629
+ p.once(pe, (Y) => Q(new Error(JSON.stringify(Y.payload)))), p.once(ge, () => K());
2602
2630
  });
2603
2631
  } catch (p) {
2604
2632
  console.error(p);
2605
2633
  }
2606
2634
  }
2607
2635
  async close(e) {
2608
- const i = await w.getByLabel(e);
2636
+ const i = await b.getByLabel(e);
2609
2637
  if (i != null)
2610
2638
  try {
2611
2639
  await i.destroy();
@@ -2613,7 +2641,7 @@ class Pe {
2613
2641
  console.error(n, e);
2614
2642
  }
2615
2643
  else {
2616
- const n = await E();
2644
+ const n = await O();
2617
2645
  console.error(
2618
2646
  "Window not found",
2619
2647
  e,
@@ -2622,7 +2650,7 @@ class Pe {
2622
2650
  }
2623
2651
  }
2624
2652
  async listLabels() {
2625
- return (await E()).map((i) => i.label);
2653
+ return (await O()).map((i) => i.label);
2626
2654
  }
2627
2655
  async focus() {
2628
2656
  return await this.win.setFocus();
@@ -2644,20 +2672,19 @@ class Pe {
2644
2672
  }
2645
2673
  async setPosition(e) {
2646
2674
  const i = new N(e.x, e.y);
2647
- await U(e) || (i.x = 0, i.y = 0), await this.win.setPosition(i);
2675
+ await V(e) || (i.x = 0, i.y = 0), await this.win.setPosition(i);
2648
2676
  }
2649
2677
  async setSize(e) {
2650
- e = f(e), await this.win.setSize(new _(e.width, e.height));
2678
+ e = v(e), await this.win.setSize(new _(e.width, e.height));
2651
2679
  }
2652
2680
  async setMinSize(e) {
2653
- e = f(e), await this.win.setMinSize(new _(e.width, e.height));
2681
+ e = v(e), await this.win.setMinSize(new _(e.width, e.height));
2654
2682
  }
2655
2683
  async setMaxSize(e) {
2656
- e = f(e), await this.win.setMaxSize(new _(e.width, e.height));
2684
+ e = v(e), await this.win.setMaxSize(new _(e.width, e.height));
2657
2685
  }
2658
2686
  async setResizable(e) {
2659
- var i, n;
2660
- 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);
2687
+ return r.WINDOW_RESIZED in this.unsubscribe && !e && (this.unsubscribe[r.WINDOW_RESIZED]?.(), delete this.unsubscribe[r.WINDOW_RESIZED]), await this.win.setResizable(e);
2661
2688
  }
2662
2689
  async setSkipTaskbar(e) {
2663
2690
  return await this.win.setSkipTaskbar(e);
@@ -2674,17 +2701,17 @@ class Pe {
2674
2701
  async getProps() {
2675
2702
  const e = await this.win.scaleFactor(), i = await this.win.isVisible();
2676
2703
  return {
2677
- position: I(await this.win.innerPosition(), e),
2678
- size: $(await this.win.innerSize(), e),
2704
+ position: S(await this.win.innerPosition(), e),
2705
+ size: q(await this.win.innerSize(), e),
2679
2706
  maximized: await this.win.isMaximized(),
2680
2707
  visible: i,
2681
2708
  fullscreen: await this.win.isFullscreen()
2682
2709
  };
2683
2710
  }
2684
2711
  }
2685
- const ze = () => [
2712
+ const De = () => [
2686
2713
  {
2687
- key: o.WINDOW_RESIZED,
2714
+ key: r.WINDOW_RESIZED,
2688
2715
  debounce: 200,
2689
2716
  handler: async (t) => {
2690
2717
  const e = await t.scaleFactor(), i = await t.isVisible(), n = {
@@ -2692,19 +2719,19 @@ const ze = () => [
2692
2719
  maximized: await t.isMaximized(),
2693
2720
  visible: i,
2694
2721
  minimized: !i,
2695
- position: I(await t.innerPosition(), e),
2696
- size: $(await t.innerSize(), e)
2722
+ position: S(await t.innerPosition(), e),
2723
+ size: q(await t.innerSize(), e)
2697
2724
  };
2698
2725
  return g(n);
2699
2726
  }
2700
2727
  },
2701
2728
  {
2702
- key: o.WINDOW_MOVED,
2729
+ key: r.WINDOW_MOVED,
2703
2730
  debounce: 200,
2704
2731
  handler: async (t) => {
2705
- const e = await (t == null ? void 0 : t.scaleFactor());
2732
+ const e = await t?.scaleFactor();
2706
2733
  if (e == null) return null;
2707
- const i = I(await t.innerPosition(), e), n = await t.isVisible(), l = {
2734
+ const i = S(await t.innerPosition(), e), n = await t.isVisible(), l = {
2708
2735
  label: t.label,
2709
2736
  visible: n,
2710
2737
  position: i
@@ -2713,12 +2740,12 @@ const ze = () => [
2713
2740
  }
2714
2741
  },
2715
2742
  {
2716
- key: o.WINDOW_BLUR,
2743
+ key: r.WINDOW_BLUR,
2717
2744
  debounce: 0,
2718
2745
  handler: async (t) => g({ focus: !1, label: t.label })
2719
2746
  },
2720
2747
  {
2721
- key: o.WINDOW_FOCUS,
2748
+ key: r.WINDOW_FOCUS,
2722
2749
  debounce: 0,
2723
2750
  handler: async (t) => g({
2724
2751
  focus: !0,
@@ -2727,7 +2754,7 @@ const ze = () => [
2727
2754
  label: t.label
2728
2755
  })
2729
2756
  }
2730
- ], I = (t, e) => ae.scale(t, 1 / e), $ = (t, e) => le.scale(t, 1 / e);
2757
+ ], S = (t, e) => se.scale(t, 1 / e), q = (t, e) => ne.scale(t, 1 / e);
2731
2758
  export {
2732
- Pe as TauriRuntime
2759
+ Oe as TauriRuntime
2733
2760
  };