tauri-notice-window 1.0.2 → 1.0.3

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/index.js CHANGED
@@ -1,33 +1,33 @@
1
- import { create as ae } from "zustand";
2
- import { syncTabs as le } from "zustand-sync";
3
- import re from "dexie";
4
- import { useCallback as z, useState as x, useEffect as oe } from "react";
5
- import { jsx as I, Fragment as ue } from "react/jsx-runtime";
6
- const $ = "tauri-notice-config", F = {
1
+ import { create as re } from "zustand";
2
+ import { syncTabs as oe } from "zustand-sync";
3
+ import ue from "dexie";
4
+ import { useCallback as A, useState as I, useEffect as B } from "react";
5
+ import { jsx as k, Fragment as ce } from "react/jsx-runtime";
6
+ const Z = "tauri-notice-config", G = {
7
7
  routePrefix: "/notice",
8
8
  databaseName: "tauri-notice-db",
9
9
  defaultWidth: 400,
10
10
  defaultHeight: 300
11
- }, J = () => {
11
+ }, Y = () => {
12
12
  try {
13
- const t = localStorage.getItem($);
13
+ const t = localStorage.getItem(Z);
14
14
  if (t)
15
- return { ...F, ...JSON.parse(t) };
15
+ return { ...G, ...JSON.parse(t) };
16
16
  } catch (t) {
17
17
  console.warn("Failed to load config from localStorage:", t);
18
18
  }
19
- return F;
20
- }, ce = (t) => {
19
+ return G;
20
+ }, de = (t) => {
21
21
  try {
22
- localStorage.setItem($, JSON.stringify(t));
22
+ localStorage.setItem(Z, JSON.stringify(t));
23
23
  } catch (e) {
24
24
  console.warn("Failed to save config to localStorage:", e);
25
25
  }
26
- }, Fe = (t) => {
27
- const i = { ...J(), ...t };
28
- ce(i);
29
- }, Z = () => J();
30
- class de extends re {
26
+ }, Be = (t) => {
27
+ const i = { ...Y(), ...t };
28
+ de(i);
29
+ }, K = () => Y();
30
+ class we extends ue {
31
31
  messages;
32
32
  constructor(e) {
33
33
  super(e), this.version(1).stores({
@@ -35,14 +35,14 @@ class de extends re {
35
35
  });
36
36
  }
37
37
  }
38
- let f = null;
39
- const Y = () => {
40
- if (!f) {
41
- const t = Z();
42
- f = new de(t.databaseName);
43
- }
44
- return f;
45
- }, h = () => f || Y(), we = async (t) => {
38
+ let v = null;
39
+ const X = () => {
40
+ if (!v) {
41
+ const t = K();
42
+ v = new we(t.databaseName);
43
+ }
44
+ return v;
45
+ }, h = () => v || X(), he = async (t) => {
46
46
  const e = {
47
47
  ...t,
48
48
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -52,25 +52,25 @@ const Y = () => {
52
52
  queuePosition: 0
53
53
  };
54
54
  await h().messages.put(e);
55
- }, he = async (t) => !!await h().messages.get(t), ge = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), be = async (t, e) => {
55
+ }, ge = async (t) => !!await h().messages.get(t), be = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), ye = async (t, e) => {
56
56
  await h().messages.update(t, { queueStatus: e });
57
- }, ye = async (t) => {
57
+ }, pe = async (t) => {
58
58
  await h().messages.update(t, {
59
59
  queueStatus: "shown",
60
60
  isShown: !0
61
61
  });
62
- }, pe = async (t) => {
62
+ }, _e = async (t) => {
63
63
  await h().messages.update(t, {
64
64
  queueStatus: "hidden"
65
65
  });
66
- }, _e = async (t) => await h().messages.get(t), fe = async () => {
66
+ }, fe = async (t) => await h().messages.get(t), me = async () => {
67
67
  await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
68
- }, me = async (t) => {
68
+ }, ve = async (t) => {
69
69
  const e = t.map(
70
70
  (i) => h().messages.update(i.id, { queuePosition: i.position })
71
71
  );
72
72
  await Promise.all(e);
73
- }, ve = (t, e) => ({
73
+ }, We = (t, e) => ({
74
74
  // Initial state
75
75
  queue: [],
76
76
  currentMessage: null,
@@ -80,7 +80,7 @@ const Y = () => {
80
80
  // Enqueue a new message
81
81
  enqueue: async (i) => {
82
82
  const n = e();
83
- if (await he(i.id) || await we(i), !n.queue.some((l) => l.id === i.id)) {
83
+ if (await ge(i.id) || await he(i), !n.queue.some((l) => l.id === i.id)) {
84
84
  const l = [...n.queue, i];
85
85
  t({ queue: l }), await e().persistQueue();
86
86
  }
@@ -104,7 +104,7 @@ const Y = () => {
104
104
  t({
105
105
  currentMessage: n,
106
106
  isProcessing: !0
107
- }), await be(n.id, "showing"), await e().persistQueue();
107
+ }), await ye(n.id, "showing"), await e().persistQueue();
108
108
  },
109
109
  // Clear current message and show next
110
110
  clearCurrent: () => {
@@ -129,7 +129,7 @@ const Y = () => {
129
129
  initializeFromDatabase: async () => {
130
130
  if (e().initialized) return;
131
131
  t({ initialized: !0 });
132
- const n = await ge();
132
+ const n = await be();
133
133
  n.length > 0 && (t({ queue: n }), await e().showNext());
134
134
  },
135
135
  // Persist queue to database
@@ -138,7 +138,7 @@ const Y = () => {
138
138
  id: a.id,
139
139
  position: r
140
140
  }));
141
- await me(n);
141
+ await ve(n);
142
142
  },
143
143
  // Clear all messages on logout
144
144
  clearOnLogout: async () => {
@@ -148,7 +148,7 @@ const Y = () => {
148
148
  isProcessing: !1,
149
149
  activeWindowIds: [],
150
150
  initialized: !1
151
- }), await fe();
151
+ }), await me();
152
152
  },
153
153
  // Add active window ID
154
154
  addActiveWindow: (i) => {
@@ -167,46 +167,46 @@ const Y = () => {
167
167
  const n = e(), a = String(i);
168
168
  return n.activeWindowIds.includes(a);
169
169
  }
170
- }), w = ae()(
171
- le(ve, {
170
+ }), w = re()(
171
+ oe(We, {
172
172
  name: "tauri-notice-queue"
173
173
  })
174
- ), D = {
174
+ ), S = {
175
175
  queueLength: (t) => t.queue.length,
176
176
  currentMessage: (t) => t.currentMessage,
177
177
  isProcessing: (t) => t.isProcessing,
178
178
  queue: (t) => t.queue
179
- }, Be = () => {
179
+ }, Ge = () => {
180
180
  const t = w((i) => i.enqueue);
181
- return { showNotice: z(
181
+ return { showNotice: A(
182
182
  async (i) => {
183
183
  await t(i);
184
184
  },
185
185
  [t]
186
186
  ) };
187
187
  };
188
- function We(t, e, i, n) {
188
+ function De(t, e, i, n) {
189
189
  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");
190
190
  return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
191
191
  }
192
- function De(t, e, i, n, a) {
192
+ function Se(t, e, i, n, a) {
193
193
  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");
194
194
  return e.set(t, i), i;
195
195
  }
196
- var S;
197
- const d = "__TAURI_TO_IPC_KEY__";
198
- function Se(t, e = !1) {
196
+ var N;
197
+ const c = "__TAURI_TO_IPC_KEY__";
198
+ function Ne(t, e = !1) {
199
199
  return window.__TAURI_INTERNALS__.transformCallback(t, e);
200
200
  }
201
201
  async function s(t, e = {}, i) {
202
202
  return window.__TAURI_INTERNALS__.invoke(t, e, i);
203
203
  }
204
- class Ne {
204
+ class ze {
205
205
  get rid() {
206
- return We(this, S, "f");
206
+ return De(this, N, "f");
207
207
  }
208
208
  constructor(e) {
209
- S.set(this, void 0), De(this, S, e);
209
+ N.set(this, void 0), Se(this, N, e);
210
210
  }
211
211
  /**
212
212
  * Destroys and cleans up this resource from memory.
@@ -218,8 +218,8 @@ class Ne {
218
218
  });
219
219
  }
220
220
  }
221
- S = /* @__PURE__ */ new WeakMap();
222
- class K {
221
+ N = /* @__PURE__ */ new WeakMap();
222
+ class ee {
223
223
  constructor(...e) {
224
224
  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]);
225
225
  }
@@ -241,14 +241,14 @@ class K {
241
241
  toPhysical(e) {
242
242
  return new b(this.width * e, this.height * e);
243
243
  }
244
- [d]() {
244
+ [c]() {
245
245
  return {
246
246
  width: this.width,
247
247
  height: this.height
248
248
  };
249
249
  }
250
250
  toJSON() {
251
- return this[d]();
251
+ return this[c]();
252
252
  }
253
253
  }
254
254
  class b {
@@ -267,16 +267,16 @@ class b {
267
267
  * ```
268
268
  */
269
269
  toLogical(e) {
270
- return new K(this.width / e, this.height / e);
270
+ return new ee(this.width / e, this.height / e);
271
271
  }
272
- [d]() {
272
+ [c]() {
273
273
  return {
274
274
  width: this.width,
275
275
  height: this.height
276
276
  };
277
277
  }
278
278
  toJSON() {
279
- return this[d]();
279
+ return this[c]();
280
280
  }
281
281
  }
282
282
  class g {
@@ -284,12 +284,12 @@ class g {
284
284
  this.size = e;
285
285
  }
286
286
  toLogical(e) {
287
- return this.size instanceof K ? this.size : this.size.toLogical(e);
287
+ return this.size instanceof ee ? this.size : this.size.toLogical(e);
288
288
  }
289
289
  toPhysical(e) {
290
290
  return this.size instanceof b ? this.size : this.size.toPhysical(e);
291
291
  }
292
- [d]() {
292
+ [c]() {
293
293
  return {
294
294
  [`${this.size.type}`]: {
295
295
  width: this.size.width,
@@ -298,10 +298,10 @@ class g {
298
298
  };
299
299
  }
300
300
  toJSON() {
301
- return this[d]();
301
+ return this[c]();
302
302
  }
303
303
  }
304
- class X {
304
+ class te {
305
305
  constructor(...e) {
306
306
  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]);
307
307
  }
@@ -323,14 +323,14 @@ class X {
323
323
  toPhysical(e) {
324
324
  return new u(this.x * e, this.y * e);
325
325
  }
326
- [d]() {
326
+ [c]() {
327
327
  return {
328
328
  x: this.x,
329
329
  y: this.y
330
330
  };
331
331
  }
332
332
  toJSON() {
333
- return this[d]();
333
+ return this[c]();
334
334
  }
335
335
  }
336
336
  class u {
@@ -353,16 +353,16 @@ class u {
353
353
  * @since 2.0.0
354
354
  */
355
355
  toLogical(e) {
356
- return new X(this.x / e, this.y / e);
356
+ return new te(this.x / e, this.y / e);
357
357
  }
358
- [d]() {
358
+ [c]() {
359
359
  return {
360
360
  x: this.x,
361
361
  y: this.y
362
362
  };
363
363
  }
364
364
  toJSON() {
365
- return this[d]();
365
+ return this[c]();
366
366
  }
367
367
  }
368
368
  class p {
@@ -370,12 +370,12 @@ class p {
370
370
  this.position = e;
371
371
  }
372
372
  toLogical(e) {
373
- return this.position instanceof X ? this.position : this.position.toLogical(e);
373
+ return this.position instanceof te ? this.position : this.position.toLogical(e);
374
374
  }
375
375
  toPhysical(e) {
376
376
  return this.position instanceof u ? this.position : this.position.toPhysical(e);
377
377
  }
378
- [d]() {
378
+ [c]() {
379
379
  return {
380
380
  [`${this.position.type}`]: {
381
381
  x: this.position.x,
@@ -384,47 +384,47 @@ class p {
384
384
  };
385
385
  }
386
386
  toJSON() {
387
- return this[d]();
387
+ return this[c]();
388
388
  }
389
389
  }
390
390
  var o;
391
391
  (function(t) {
392
392
  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";
393
393
  })(o || (o = {}));
394
- async function ee(t, e) {
394
+ async function ie(t, e) {
395
395
  window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
396
396
  event: t,
397
397
  eventId: e
398
398
  });
399
399
  }
400
- async function A(t, e, i) {
400
+ async function O(t, e, i) {
401
401
  var n;
402
402
  const a = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
403
403
  return s("plugin:event|listen", {
404
404
  event: t,
405
405
  target: a,
406
- handler: Se(e)
407
- }).then((r) => async () => ee(t, r));
406
+ handler: Ne(e)
407
+ }).then((r) => async () => ie(t, r));
408
408
  }
409
- async function R(t, e, i) {
410
- return A(t, (n) => {
411
- ee(t, n.id), e(n);
409
+ async function E(t, e, i) {
410
+ return O(t, (n) => {
411
+ ie(t, n.id), e(n);
412
412
  }, i);
413
413
  }
414
- async function te(t, e) {
414
+ async function ne(t, e) {
415
415
  await s("plugin:event|emit", {
416
416
  event: t,
417
417
  payload: e
418
418
  });
419
419
  }
420
- async function ie(t, e, i) {
420
+ async function se(t, e, i) {
421
421
  await s("plugin:event|emit_to", {
422
422
  target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
423
423
  event: e,
424
424
  payload: i
425
425
  });
426
426
  }
427
- class m extends Ne {
427
+ class W extends ze {
428
428
  /**
429
429
  * Creates an Image from a resource ID. For internal use only.
430
430
  *
@@ -436,10 +436,10 @@ class m extends Ne {
436
436
  /** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
437
437
  static async new(e, i, n) {
438
438
  return s("plugin:image|new", {
439
- rgba: N(e),
439
+ rgba: z(e),
440
440
  width: i,
441
441
  height: n
442
- }).then((a) => new m(a));
442
+ }).then((a) => new W(a));
443
443
  }
444
444
  /**
445
445
  * Creates a new image using the provided bytes by inferring the file format.
@@ -456,8 +456,8 @@ class m extends Ne {
456
456
  */
457
457
  static async fromBytes(e) {
458
458
  return s("plugin:image|from_bytes", {
459
- bytes: N(e)
460
- }).then((i) => new m(i));
459
+ bytes: z(e)
460
+ }).then((i) => new W(i));
461
461
  }
462
462
  /**
463
463
  * Creates a new image using the provided path.
@@ -472,7 +472,7 @@ class m extends Ne {
472
472
  * ```
473
473
  */
474
474
  static async fromPath(e) {
475
- return s("plugin:image|from_path", { path: e }).then((i) => new m(i));
475
+ return s("plugin:image|from_path", { path: e }).then((i) => new W(i));
476
476
  }
477
477
  /** Returns the RGBA data for this image, in row-major order from top to bottom. */
478
478
  async rgba() {
@@ -485,14 +485,14 @@ class m extends Ne {
485
485
  return s("plugin:image|size", { rid: this.rid });
486
486
  }
487
487
  }
488
- function N(t) {
489
- return t == null ? null : typeof t == "string" ? t : t instanceof m ? t.rid : t;
488
+ function z(t) {
489
+ return t == null ? null : typeof t == "string" ? t : t instanceof W ? t.rid : t;
490
490
  }
491
- var M;
491
+ var R;
492
492
  (function(t) {
493
493
  t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
494
- })(M || (M = {}));
495
- class ze {
494
+ })(R || (R = {}));
495
+ class Ae {
496
496
  constructor(e) {
497
497
  this._preventDefault = !1, this.event = e.event, this.id = e.id;
498
498
  }
@@ -503,24 +503,24 @@ class ze {
503
503
  return this._preventDefault;
504
504
  }
505
505
  }
506
- var B;
506
+ var U;
507
507
  (function(t) {
508
508
  t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
509
- })(B || (B = {}));
510
- function ne() {
511
- return new O(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
509
+ })(U || (U = {}));
510
+ function ae() {
511
+ return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
512
512
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
513
513
  skip: !0
514
514
  });
515
515
  }
516
- async function k() {
517
- return s("plugin:window|get_all_windows").then((t) => t.map((e) => new O(e, {
516
+ async function L() {
517
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
518
518
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
519
519
  skip: !0
520
520
  })));
521
521
  }
522
522
  const C = ["tauri://created", "tauri://error"];
523
- class O {
523
+ class P {
524
524
  /**
525
525
  * Creates a new Window.
526
526
  * @example
@@ -561,19 +561,19 @@ class O {
561
561
  */
562
562
  static async getByLabel(e) {
563
563
  var i;
564
- return (i = (await k()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
564
+ return (i = (await L()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
565
565
  }
566
566
  /**
567
567
  * Get an instance of `Window` for the current window.
568
568
  */
569
569
  static getCurrent() {
570
- return ne();
570
+ return ae();
571
571
  }
572
572
  /**
573
573
  * Gets a list of instances of `Window` for all available windows.
574
574
  */
575
575
  static async getAll() {
576
- return k();
576
+ return L();
577
577
  }
578
578
  /**
579
579
  * Gets the focused window.
@@ -586,7 +586,7 @@ class O {
586
586
  * @returns The Window instance or `undefined` if there is not any focused window.
587
587
  */
588
588
  static async getFocusedWindow() {
589
- for (const e of await k())
589
+ for (const e of await L())
590
590
  if (await e.isFocused())
591
591
  return e;
592
592
  return null;
@@ -614,7 +614,7 @@ class O {
614
614
  return this._handleTauriEvent(e, i) ? () => {
615
615
  const n = this.listeners[e];
616
616
  n.splice(n.indexOf(i), 1);
617
- } : A(e, i, {
617
+ } : O(e, i, {
618
618
  target: { kind: "Window", label: this.label }
619
619
  });
620
620
  }
@@ -641,7 +641,7 @@ class O {
641
641
  return this._handleTauriEvent(e, i) ? () => {
642
642
  const n = this.listeners[e];
643
643
  n.splice(n.indexOf(i), 1);
644
- } : R(e, i, {
644
+ } : E(e, i, {
645
645
  target: { kind: "Window", label: this.label }
646
646
  });
647
647
  }
@@ -666,7 +666,7 @@ class O {
666
666
  });
667
667
  return;
668
668
  }
669
- return te(e, i);
669
+ return ne(e, i);
670
670
  }
671
671
  /**
672
672
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -690,7 +690,7 @@ class O {
690
690
  });
691
691
  return;
692
692
  }
693
- return ie(e, i, n);
693
+ return se(e, i, n);
694
694
  }
695
695
  /** @ignore */
696
696
  _handleTauriEvent(e, i) {
@@ -1023,7 +1023,7 @@ class O {
1023
1023
  */
1024
1024
  async requestUserAttention(e) {
1025
1025
  let i = null;
1026
- return e && (e === M.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
1026
+ return e && (e === R.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
1027
1027
  label: this.label,
1028
1028
  value: i
1029
1029
  });
@@ -1593,7 +1593,7 @@ class O {
1593
1593
  async setIcon(e) {
1594
1594
  return s("plugin:window|set_icon", {
1595
1595
  label: this.label,
1596
- value: N(e)
1596
+ value: z(e)
1597
1597
  });
1598
1598
  }
1599
1599
  /**
@@ -1828,7 +1828,7 @@ class O {
1828
1828
  async setOverlayIcon(e) {
1829
1829
  return s("plugin:window|set_overlay_icon", {
1830
1830
  label: this.label,
1831
- value: e ? N(e) : void 0
1831
+ value: e ? z(e) : void 0
1832
1832
  });
1833
1833
  }
1834
1834
  /**
@@ -1967,7 +1967,7 @@ class O {
1967
1967
  */
1968
1968
  async onCloseRequested(e) {
1969
1969
  return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
1970
- const n = new ze(i);
1970
+ const n = new Ae(i);
1971
1971
  await e(n), n.isPreventDefault() || await this.destroy();
1972
1972
  });
1973
1973
  }
@@ -2102,23 +2102,23 @@ class O {
2102
2102
  return this.listen(o.WINDOW_THEME_CHANGED, e);
2103
2103
  }
2104
2104
  }
2105
- var G;
2105
+ var H;
2106
2106
  (function(t) {
2107
2107
  t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
2108
- })(G || (G = {}));
2109
- var U;
2108
+ })(H || (H = {}));
2109
+ var Q;
2110
2110
  (function(t) {
2111
2111
  t.Default = "default", t.FluentOverlay = "fluentOverlay";
2112
- })(U || (U = {}));
2113
- var H;
2112
+ })(Q || (Q = {}));
2113
+ var V;
2114
2114
  (function(t) {
2115
2115
  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";
2116
- })(H || (H = {}));
2117
- var Q;
2116
+ })(V || (V = {}));
2117
+ var j;
2118
2118
  (function(t) {
2119
2119
  t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
2120
- })(Q || (Q = {}));
2121
- function Ae(t) {
2120
+ })(j || (j = {}));
2121
+ function Oe(t) {
2122
2122
  return t === null ? null : {
2123
2123
  name: t.name,
2124
2124
  scaleFactor: t.scaleFactor,
@@ -2130,17 +2130,17 @@ function Ae(t) {
2130
2130
  }
2131
2131
  };
2132
2132
  }
2133
- async function Oe() {
2134
- return s("plugin:window|primary_monitor").then(Ae);
2133
+ async function Pe() {
2134
+ return s("plugin:window|primary_monitor").then(Oe);
2135
2135
  }
2136
- function se() {
2137
- return new E(ne(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2136
+ function le() {
2137
+ return new T(ae(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2138
2138
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2139
2139
  skip: !0
2140
2140
  });
2141
2141
  }
2142
- async function V() {
2143
- return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new E(new O(e.windowLabel, {
2142
+ async function $() {
2143
+ return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new T(new P(e.windowLabel, {
2144
2144
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2145
2145
  skip: !0
2146
2146
  }), e.label, {
@@ -2148,8 +2148,8 @@ async function V() {
2148
2148
  skip: !0
2149
2149
  })));
2150
2150
  }
2151
- const L = ["tauri://created", "tauri://error"];
2152
- class E {
2151
+ const M = ["tauri://created", "tauri://error"];
2152
+ class T {
2153
2153
  /**
2154
2154
  * Creates a new Webview.
2155
2155
  * @example
@@ -2204,19 +2204,19 @@ class E {
2204
2204
  */
2205
2205
  static async getByLabel(e) {
2206
2206
  var i;
2207
- return (i = (await V()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
2207
+ return (i = (await $()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
2208
2208
  }
2209
2209
  /**
2210
2210
  * Get an instance of `Webview` for the current webview.
2211
2211
  */
2212
2212
  static getCurrent() {
2213
- return se();
2213
+ return le();
2214
2214
  }
2215
2215
  /**
2216
2216
  * Gets a list of instances of `Webview` for all available webviews.
2217
2217
  */
2218
2218
  static async getAll() {
2219
- return V();
2219
+ return $();
2220
2220
  }
2221
2221
  /**
2222
2222
  * Listen to an emitted event on this webview.
@@ -2241,7 +2241,7 @@ class E {
2241
2241
  return this._handleTauriEvent(e, i) ? () => {
2242
2242
  const n = this.listeners[e];
2243
2243
  n.splice(n.indexOf(i), 1);
2244
- } : A(e, i, {
2244
+ } : O(e, i, {
2245
2245
  target: { kind: "Webview", label: this.label }
2246
2246
  });
2247
2247
  }
@@ -2268,7 +2268,7 @@ class E {
2268
2268
  return this._handleTauriEvent(e, i) ? () => {
2269
2269
  const n = this.listeners[e];
2270
2270
  n.splice(n.indexOf(i), 1);
2271
- } : R(e, i, {
2271
+ } : E(e, i, {
2272
2272
  target: { kind: "Webview", label: this.label }
2273
2273
  });
2274
2274
  }
@@ -2285,7 +2285,7 @@ class E {
2285
2285
  * @param payload Event payload.
2286
2286
  */
2287
2287
  async emit(e, i) {
2288
- if (L.includes(e)) {
2288
+ if (M.includes(e)) {
2289
2289
  for (const n of this.listeners[e] || [])
2290
2290
  n({
2291
2291
  event: e,
@@ -2294,7 +2294,7 @@ class E {
2294
2294
  });
2295
2295
  return;
2296
2296
  }
2297
- return te(e, i);
2297
+ return ne(e, i);
2298
2298
  }
2299
2299
  /**
2300
2300
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -2310,7 +2310,7 @@ class E {
2310
2310
  * @param payload Event payload.
2311
2311
  */
2312
2312
  async emitTo(e, i, n) {
2313
- if (L.includes(i)) {
2313
+ if (M.includes(i)) {
2314
2314
  for (const a of this.listeners[i] || [])
2315
2315
  a({
2316
2316
  event: i,
@@ -2319,11 +2319,11 @@ class E {
2319
2319
  });
2320
2320
  return;
2321
2321
  }
2322
- return ie(e, i, n);
2322
+ return se(e, i, n);
2323
2323
  }
2324
2324
  /** @ignore */
2325
2325
  _handleTauriEvent(e, i) {
2326
- return L.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2326
+ return M.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2327
2327
  }
2328
2328
  // Getters
2329
2329
  /**
@@ -2594,11 +2594,11 @@ class E {
2594
2594
  };
2595
2595
  }
2596
2596
  }
2597
- function Pe() {
2598
- const t = se();
2597
+ function xe() {
2598
+ const t = le();
2599
2599
  return new _(t.label, { skip: !0 });
2600
2600
  }
2601
- async function j() {
2601
+ async function J() {
2602
2602
  return s("plugin:window|get_all_windows").then((t) => t.map((e) => new _(e, {
2603
2603
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2604
2604
  skip: !0
@@ -2647,20 +2647,20 @@ class _ {
2647
2647
  */
2648
2648
  static async getByLabel(e) {
2649
2649
  var i;
2650
- const n = (i = (await j()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
2650
+ const n = (i = (await J()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
2651
2651
  return n ? new _(n.label, { skip: !0 }) : null;
2652
2652
  }
2653
2653
  /**
2654
2654
  * Get an instance of `Webview` for the current webview.
2655
2655
  */
2656
2656
  static getCurrent() {
2657
- return Pe();
2657
+ return xe();
2658
2658
  }
2659
2659
  /**
2660
2660
  * Gets a list of instances of `Webview` for all available webviews.
2661
2661
  */
2662
2662
  static async getAll() {
2663
- return j();
2663
+ return J();
2664
2664
  }
2665
2665
  /**
2666
2666
  * Listen to an emitted event on this webivew window.
@@ -2685,7 +2685,7 @@ class _ {
2685
2685
  return this._handleTauriEvent(e, i) ? () => {
2686
2686
  const n = this.listeners[e];
2687
2687
  n.splice(n.indexOf(i), 1);
2688
- } : A(e, i, {
2688
+ } : O(e, i, {
2689
2689
  target: { kind: "WebviewWindow", label: this.label }
2690
2690
  });
2691
2691
  }
@@ -2712,7 +2712,7 @@ class _ {
2712
2712
  return this._handleTauriEvent(e, i) ? () => {
2713
2713
  const n = this.listeners[e];
2714
2714
  n.splice(n.indexOf(i), 1);
2715
- } : R(e, i, {
2715
+ } : E(e, i, {
2716
2716
  target: { kind: "WebviewWindow", label: this.label }
2717
2717
  });
2718
2718
  }
@@ -2736,8 +2736,8 @@ class _ {
2736
2736
  return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
2737
2737
  }
2738
2738
  }
2739
- xe(_, [O, E]);
2740
- function xe(t, e) {
2739
+ Ie(_, [P, T]);
2740
+ function Ie(t, e) {
2741
2741
  (Array.isArray(e) ? e : [e]).forEach((i) => {
2742
2742
  Object.getOwnPropertyNames(i.prototype).forEach((n) => {
2743
2743
  var a;
@@ -2750,16 +2750,16 @@ function xe(t, e) {
2750
2750
  });
2751
2751
  });
2752
2752
  }
2753
- const v = /* @__PURE__ */ new Map(), Ie = async (t, e, i) => {
2753
+ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
2754
2754
  const n = i?.padding ?? 20;
2755
2755
  if (i?.x !== void 0 && i?.y !== void 0)
2756
2756
  return { x: i.x, y: i.y };
2757
2757
  let a = 1920, r = 1080;
2758
2758
  try {
2759
- const c = await Oe();
2760
- c?.size && (a = c.size.width, r = c.size.height);
2761
- } catch (c) {
2762
- console.warn("Failed to get monitor info, using defaults:", c);
2759
+ const d = await Pe();
2760
+ d?.size && (a = d.size.width, r = d.size.height);
2761
+ } catch (d) {
2762
+ console.warn("Failed to get monitor info, using defaults:", d);
2763
2763
  }
2764
2764
  switch (i?.position ?? "right-bottom") {
2765
2765
  case "right-bottom":
@@ -2793,139 +2793,147 @@ const v = /* @__PURE__ */ new Map(), Ie = async (t, e, i) => {
2793
2793
  y: r - e - n
2794
2794
  };
2795
2795
  }
2796
- }, ke = async (t) => {
2796
+ }, Le = async (t) => {
2797
2797
  const e = String(t.id), i = w.getState();
2798
2798
  if (i.isWindowActive(e)) {
2799
2799
  console.log(`Notice window already open for message: ${e}`);
2800
2800
  return;
2801
2801
  }
2802
- const n = Z(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth, c = t.min_height || n.defaultHeight, { x: q, y: W } = await Ie(l, c, t.windowPosition);
2802
+ const n = K(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth, d = t.min_height || n.defaultHeight, { x: f, y: m } = await ke(l, d, t.windowPosition);
2803
2803
  try {
2804
2804
  const y = new _(a, {
2805
2805
  url: r,
2806
2806
  title: t.title,
2807
2807
  width: l,
2808
- height: c,
2809
- x: q,
2810
- y: W,
2808
+ height: d,
2809
+ x: f,
2810
+ y: m,
2811
2811
  resizable: !0,
2812
2812
  decorations: !0,
2813
2813
  skipTaskbar: !1,
2814
2814
  alwaysOnTop: !0
2815
2815
  });
2816
- v.set(e, y), i.addActiveWindow(e), y.once("tauri://destroyed", async () => {
2817
- v.delete(e), i.removeActiveWindow(e), await ye(e), i.clearCurrent();
2816
+ D.set(e, y), i.addActiveWindow(e), y.once("tauri://destroyed", async () => {
2817
+ D.delete(e), i.removeActiveWindow(e), await pe(e), i.clearCurrent();
2818
2818
  }), console.log(`Created notice window: ${a}`);
2819
2819
  } catch (y) {
2820
2820
  console.error("Failed to create notice window:", y), i.removeActiveWindow(e), i.clearCurrent();
2821
2821
  }
2822
- }, T = async (t) => {
2823
- const e = String(t), i = v.get(e);
2822
+ }, q = async (t) => {
2823
+ const e = String(t), i = D.get(e);
2824
2824
  if (i)
2825
2825
  try {
2826
- await i.close(), v.delete(e), console.log(`Closed notice window: ${e}`);
2826
+ await i.close(), D.delete(e), console.log(`Closed notice window: ${e}`);
2827
2827
  } catch (n) {
2828
2828
  console.error("Failed to close notice window:", n);
2829
2829
  }
2830
2830
  }, Ce = async () => {
2831
- const t = Array.from(v.keys()).map(
2832
- (e) => T(e)
2831
+ const t = Array.from(D.keys()).map(
2832
+ (e) => q(e)
2833
2833
  );
2834
2834
  await Promise.all(t);
2835
- }, Le = () => {
2835
+ }, Me = () => {
2836
2836
  let t = null;
2837
2837
  w.subscribe((e) => {
2838
2838
  const i = e.currentMessage;
2839
- i && i !== t ? (t = i, ke(i)) : i || (t = null);
2839
+ i && i !== t ? (t = i, Le(i)) : i || (t = null);
2840
2840
  }), console.log("Notice window system initialized");
2841
- }, Ge = () => {
2841
+ }, Ue = () => {
2842
2842
  const t = w((i) => i.currentMessage);
2843
- return { closeNotice: z(async () => {
2844
- t && await T(t.id);
2843
+ return { closeNotice: A(async () => {
2844
+ t && await q(t.id);
2845
2845
  }, [t]) };
2846
- }, Ue = () => {
2846
+ }, He = () => {
2847
2847
  const t = w();
2848
- return { hideNotice: z(
2848
+ return { hideNotice: A(
2849
2849
  async (i) => {
2850
- await pe(i), await T(i), t.currentMessage?.id === i && t.clearCurrent();
2850
+ await _e(i), await q(i), t.currentMessage?.id === i && t.clearCurrent();
2851
2851
  },
2852
2852
  [t]
2853
2853
  ) };
2854
- }, He = () => {
2854
+ }, Qe = () => {
2855
2855
  const t = w((i) => i.clearOnLogout);
2856
- return { hideAllNotices: z(async () => {
2856
+ return { hideAllNotices: A(async () => {
2857
2857
  await Ce(), await t();
2858
2858
  }, [t]) };
2859
- }, Qe = () => {
2860
- const t = w(D.queueLength), e = w(D.currentMessage), i = w(D.isProcessing), n = w(D.queue);
2859
+ }, Ve = () => {
2860
+ const t = w(S.queueLength), e = w(S.currentMessage), i = w(S.isProcessing), n = w(S.queue);
2861
2861
  return {
2862
2862
  queueLength: t,
2863
2863
  currentMessage: e,
2864
2864
  isProcessing: i,
2865
2865
  queue: n
2866
2866
  };
2867
- }, Ve = ({ children: t, onLoad: e }) => {
2868
- const [i, n] = x(null), [a, r] = x(!0), [l, c] = x(null);
2869
- return oe(() => {
2867
+ }, je = ({ children: t, onLoad: e, onClose: i }) => {
2868
+ const [n, a] = I(null), [r, l] = I(!0), [d, f] = I(null);
2869
+ return B(() => {
2870
2870
  (async () => {
2871
2871
  try {
2872
- const y = new URLSearchParams(window.location.search).get("id");
2873
- if (!y) {
2874
- c("No message ID provided"), r(!1);
2872
+ const F = new URLSearchParams(window.location.search).get("id");
2873
+ if (!F) {
2874
+ f("No message ID provided"), l(!1);
2875
2875
  return;
2876
2876
  }
2877
- const P = await _e(y);
2878
- if (!P) {
2879
- c("Message not found"), r(!1);
2877
+ const x = await fe(F);
2878
+ if (!x) {
2879
+ f("Message not found"), l(!1);
2880
2880
  return;
2881
2881
  }
2882
- n(P), r(!1), e && e(P);
2883
- } catch (W) {
2884
- console.error("Failed to load message:", W), c("Failed to load message"), r(!1);
2882
+ a(x), l(!1), e && e(x);
2883
+ } catch (y) {
2884
+ console.error("Failed to load message:", y), f("Failed to load message"), l(!1);
2885
2885
  }
2886
2886
  })();
2887
- }, [e]), a ? /* @__PURE__ */ I("div", { style: {
2887
+ }, [e]), B(() => {
2888
+ if (!n || !i) return;
2889
+ const m = () => {
2890
+ i(n);
2891
+ };
2892
+ return window.addEventListener("beforeunload", m), () => {
2893
+ window.removeEventListener("beforeunload", m);
2894
+ };
2895
+ }, [n, i]), r ? /* @__PURE__ */ k("div", { style: {
2888
2896
  display: "flex",
2889
2897
  justifyContent: "center",
2890
2898
  alignItems: "center",
2891
2899
  height: "100vh",
2892
2900
  fontFamily: "system-ui, -apple-system, sans-serif"
2893
- }, children: "Loading..." }) : l || !i ? /* @__PURE__ */ I("div", { style: {
2901
+ }, children: "Loading..." }) : d || !n ? /* @__PURE__ */ k("div", { style: {
2894
2902
  display: "flex",
2895
2903
  justifyContent: "center",
2896
2904
  alignItems: "center",
2897
2905
  height: "100vh",
2898
2906
  fontFamily: "system-ui, -apple-system, sans-serif",
2899
2907
  color: "#ef4444"
2900
- }, children: l || "Message not found" }) : /* @__PURE__ */ I(ue, { children: t(i) });
2901
- }, je = async () => {
2902
- Y(), Le();
2908
+ }, children: d || "Message not found" }) : /* @__PURE__ */ k(ce, { children: t(n) });
2909
+ }, $e = async () => {
2910
+ X(), Me();
2903
2911
  const { initializeFromDatabase: t } = w.getState();
2904
2912
  await t(), console.log("Tauri Notice System initialized");
2905
2913
  };
2906
2914
  export {
2907
- Ve as NoticeLayout,
2908
- fe as clearPendingMessages,
2915
+ je as NoticeLayout,
2916
+ me as clearPendingMessages,
2909
2917
  Ce as closeAllNoticeWindows,
2910
- T as closeNoticeWindow,
2911
- ke as createNoticeWindow,
2912
- _e as getMessage,
2913
- Z as getNoticeConfig,
2914
- ge as getPendingMessages,
2915
- he as hasMessage,
2916
- Y as initializeDatabase,
2917
- je as initializeNoticeSystem,
2918
- Le as initializeNoticeWindowSystem,
2919
- pe as markAsHidden,
2920
- ye as markAsShown,
2921
- D as messageQueueSelectors,
2922
- we as saveMessage,
2923
- Fe as setNoticeConfig,
2924
- Ge as useCloseNotice,
2925
- He as useHideAllNotices,
2926
- Ue as useHideNotice,
2927
- Qe as useMessageQueue,
2918
+ q as closeNoticeWindow,
2919
+ Le as createNoticeWindow,
2920
+ fe as getMessage,
2921
+ K as getNoticeConfig,
2922
+ be as getPendingMessages,
2923
+ ge as hasMessage,
2924
+ X as initializeDatabase,
2925
+ $e as initializeNoticeSystem,
2926
+ Me as initializeNoticeWindowSystem,
2927
+ _e as markAsHidden,
2928
+ pe as markAsShown,
2929
+ S as messageQueueSelectors,
2930
+ he as saveMessage,
2931
+ Be as setNoticeConfig,
2932
+ Ue as useCloseNotice,
2933
+ Qe as useHideAllNotices,
2934
+ He as useHideNotice,
2935
+ Ve as useMessageQueue,
2928
2936
  w as useMessageQueueStore,
2929
- Be as useNoticeWindow
2937
+ Ge as useNoticeWindow
2930
2938
  };
2931
2939
  //# sourceMappingURL=index.js.map