tauri-notice-window 1.0.1 → 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,18 +1,33 @@
1
- import { create as ne } from "zustand";
2
- import { syncTabs as se } from "zustand-sync";
3
- import ae from "dexie";
4
- import { useCallback as N, useState as x, useEffect as le } from "react";
5
- import { jsx as I, Fragment as re } from "react/jsx-runtime";
6
- let R = {
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
- };
12
- const Ee = (t) => {
13
- R = { ...R, ...t };
14
- }, $ = () => ({ ...R });
15
- class oe extends ae {
11
+ }, Y = () => {
12
+ try {
13
+ const t = localStorage.getItem(Z);
14
+ if (t)
15
+ return { ...G, ...JSON.parse(t) };
16
+ } catch (t) {
17
+ console.warn("Failed to load config from localStorage:", t);
18
+ }
19
+ return G;
20
+ }, de = (t) => {
21
+ try {
22
+ localStorage.setItem(Z, JSON.stringify(t));
23
+ } catch (e) {
24
+ console.warn("Failed to save config to localStorage:", e);
25
+ }
26
+ }, Be = (t) => {
27
+ const i = { ...Y(), ...t };
28
+ de(i);
29
+ }, K = () => Y();
30
+ class we extends ue {
16
31
  messages;
17
32
  constructor(e) {
18
33
  super(e), this.version(1).stores({
@@ -20,14 +35,14 @@ class oe extends ae {
20
35
  });
21
36
  }
22
37
  }
23
- let f = null;
24
- const J = () => {
25
- if (!f) {
26
- const t = $();
27
- f = new oe(t.databaseName);
28
- }
29
- return f;
30
- }, h = () => f || J(), ue = 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) => {
31
46
  const e = {
32
47
  ...t,
33
48
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -37,25 +52,25 @@ const J = () => {
37
52
  queuePosition: 0
38
53
  };
39
54
  await h().messages.put(e);
40
- }, ce = async (t) => !!await h().messages.get(t), we = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), de = 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) => {
41
56
  await h().messages.update(t, { queueStatus: e });
42
- }, he = async (t) => {
57
+ }, pe = async (t) => {
43
58
  await h().messages.update(t, {
44
59
  queueStatus: "shown",
45
60
  isShown: !0
46
61
  });
47
- }, be = async (t) => {
62
+ }, _e = async (t) => {
48
63
  await h().messages.update(t, {
49
64
  queueStatus: "hidden"
50
65
  });
51
- }, ge = async (t) => await h().messages.get(t), ye = async () => {
66
+ }, fe = async (t) => await h().messages.get(t), me = async () => {
52
67
  await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
53
- }, pe = async (t) => {
68
+ }, ve = async (t) => {
54
69
  const e = t.map(
55
70
  (i) => h().messages.update(i.id, { queuePosition: i.position })
56
71
  );
57
72
  await Promise.all(e);
58
- }, _e = (t, e) => ({
73
+ }, We = (t, e) => ({
59
74
  // Initial state
60
75
  queue: [],
61
76
  currentMessage: null,
@@ -65,7 +80,7 @@ const J = () => {
65
80
  // Enqueue a new message
66
81
  enqueue: async (i) => {
67
82
  const n = e();
68
- if (await ce(i.id) || await ue(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)) {
69
84
  const l = [...n.queue, i];
70
85
  t({ queue: l }), await e().persistQueue();
71
86
  }
@@ -89,7 +104,7 @@ const J = () => {
89
104
  t({
90
105
  currentMessage: n,
91
106
  isProcessing: !0
92
- }), await de(n.id, "showing"), await e().persistQueue();
107
+ }), await ye(n.id, "showing"), await e().persistQueue();
93
108
  },
94
109
  // Clear current message and show next
95
110
  clearCurrent: () => {
@@ -114,7 +129,7 @@ const J = () => {
114
129
  initializeFromDatabase: async () => {
115
130
  if (e().initialized) return;
116
131
  t({ initialized: !0 });
117
- const n = await we();
132
+ const n = await be();
118
133
  n.length > 0 && (t({ queue: n }), await e().showNext());
119
134
  },
120
135
  // Persist queue to database
@@ -123,7 +138,7 @@ const J = () => {
123
138
  id: a.id,
124
139
  position: r
125
140
  }));
126
- await pe(n);
141
+ await ve(n);
127
142
  },
128
143
  // Clear all messages on logout
129
144
  clearOnLogout: async () => {
@@ -133,7 +148,7 @@ const J = () => {
133
148
  isProcessing: !1,
134
149
  activeWindowIds: [],
135
150
  initialized: !1
136
- }), await ye();
151
+ }), await me();
137
152
  },
138
153
  // Add active window ID
139
154
  addActiveWindow: (i) => {
@@ -152,46 +167,46 @@ const J = () => {
152
167
  const n = e(), a = String(i);
153
168
  return n.activeWindowIds.includes(a);
154
169
  }
155
- }), d = ne()(
156
- se(_e, {
170
+ }), w = re()(
171
+ oe(We, {
157
172
  name: "tauri-notice-queue"
158
173
  })
159
- ), D = {
174
+ ), S = {
160
175
  queueLength: (t) => t.queue.length,
161
176
  currentMessage: (t) => t.currentMessage,
162
177
  isProcessing: (t) => t.isProcessing,
163
178
  queue: (t) => t.queue
164
- }, Te = () => {
165
- const t = d((i) => i.enqueue);
166
- return { showNotice: N(
179
+ }, Ge = () => {
180
+ const t = w((i) => i.enqueue);
181
+ return { showNotice: A(
167
182
  async (i) => {
168
183
  await t(i);
169
184
  },
170
185
  [t]
171
186
  ) };
172
187
  };
173
- function fe(t, e, i, n) {
188
+ function De(t, e, i, n) {
174
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");
175
190
  return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
176
191
  }
177
- function me(t, e, i, n, a) {
192
+ function Se(t, e, i, n, a) {
178
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");
179
194
  return e.set(t, i), i;
180
195
  }
181
- var z;
182
- const w = "__TAURI_TO_IPC_KEY__";
183
- function ve(t, e = !1) {
196
+ var N;
197
+ const c = "__TAURI_TO_IPC_KEY__";
198
+ function Ne(t, e = !1) {
184
199
  return window.__TAURI_INTERNALS__.transformCallback(t, e);
185
200
  }
186
201
  async function s(t, e = {}, i) {
187
202
  return window.__TAURI_INTERNALS__.invoke(t, e, i);
188
203
  }
189
- class We {
204
+ class ze {
190
205
  get rid() {
191
- return fe(this, z, "f");
206
+ return De(this, N, "f");
192
207
  }
193
208
  constructor(e) {
194
- z.set(this, void 0), me(this, z, e);
209
+ N.set(this, void 0), Se(this, N, e);
195
210
  }
196
211
  /**
197
212
  * Destroys and cleans up this resource from memory.
@@ -203,8 +218,8 @@ class We {
203
218
  });
204
219
  }
205
220
  }
206
- z = /* @__PURE__ */ new WeakMap();
207
- class Z {
221
+ N = /* @__PURE__ */ new WeakMap();
222
+ class ee {
208
223
  constructor(...e) {
209
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]);
210
225
  }
@@ -224,19 +239,19 @@ class Z {
224
239
  * @since 2.0.0
225
240
  */
226
241
  toPhysical(e) {
227
- return new g(this.width * e, this.height * e);
242
+ return new b(this.width * e, this.height * e);
228
243
  }
229
- [w]() {
244
+ [c]() {
230
245
  return {
231
246
  width: this.width,
232
247
  height: this.height
233
248
  };
234
249
  }
235
250
  toJSON() {
236
- return this[w]();
251
+ return this[c]();
237
252
  }
238
253
  }
239
- class g {
254
+ class b {
240
255
  constructor(...e) {
241
256
  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]);
242
257
  }
@@ -252,29 +267,29 @@ class g {
252
267
  * ```
253
268
  */
254
269
  toLogical(e) {
255
- return new Z(this.width / e, this.height / e);
270
+ return new ee(this.width / e, this.height / e);
256
271
  }
257
- [w]() {
272
+ [c]() {
258
273
  return {
259
274
  width: this.width,
260
275
  height: this.height
261
276
  };
262
277
  }
263
278
  toJSON() {
264
- return this[w]();
279
+ return this[c]();
265
280
  }
266
281
  }
267
- class b {
282
+ class g {
268
283
  constructor(e) {
269
284
  this.size = e;
270
285
  }
271
286
  toLogical(e) {
272
- return this.size instanceof Z ? this.size : this.size.toLogical(e);
287
+ return this.size instanceof ee ? this.size : this.size.toLogical(e);
273
288
  }
274
289
  toPhysical(e) {
275
- return this.size instanceof g ? this.size : this.size.toPhysical(e);
290
+ return this.size instanceof b ? this.size : this.size.toPhysical(e);
276
291
  }
277
- [w]() {
292
+ [c]() {
278
293
  return {
279
294
  [`${this.size.type}`]: {
280
295
  width: this.size.width,
@@ -283,10 +298,10 @@ class b {
283
298
  };
284
299
  }
285
300
  toJSON() {
286
- return this[w]();
301
+ return this[c]();
287
302
  }
288
303
  }
289
- class Y {
304
+ class te {
290
305
  constructor(...e) {
291
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]);
292
307
  }
@@ -308,14 +323,14 @@ class Y {
308
323
  toPhysical(e) {
309
324
  return new u(this.x * e, this.y * e);
310
325
  }
311
- [w]() {
326
+ [c]() {
312
327
  return {
313
328
  x: this.x,
314
329
  y: this.y
315
330
  };
316
331
  }
317
332
  toJSON() {
318
- return this[w]();
333
+ return this[c]();
319
334
  }
320
335
  }
321
336
  class u {
@@ -338,16 +353,16 @@ class u {
338
353
  * @since 2.0.0
339
354
  */
340
355
  toLogical(e) {
341
- return new Y(this.x / e, this.y / e);
356
+ return new te(this.x / e, this.y / e);
342
357
  }
343
- [w]() {
358
+ [c]() {
344
359
  return {
345
360
  x: this.x,
346
361
  y: this.y
347
362
  };
348
363
  }
349
364
  toJSON() {
350
- return this[w]();
365
+ return this[c]();
351
366
  }
352
367
  }
353
368
  class p {
@@ -355,12 +370,12 @@ class p {
355
370
  this.position = e;
356
371
  }
357
372
  toLogical(e) {
358
- return this.position instanceof Y ? this.position : this.position.toLogical(e);
373
+ return this.position instanceof te ? this.position : this.position.toLogical(e);
359
374
  }
360
375
  toPhysical(e) {
361
376
  return this.position instanceof u ? this.position : this.position.toPhysical(e);
362
377
  }
363
- [w]() {
378
+ [c]() {
364
379
  return {
365
380
  [`${this.position.type}`]: {
366
381
  x: this.position.x,
@@ -369,47 +384,47 @@ class p {
369
384
  };
370
385
  }
371
386
  toJSON() {
372
- return this[w]();
387
+ return this[c]();
373
388
  }
374
389
  }
375
390
  var o;
376
391
  (function(t) {
377
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";
378
393
  })(o || (o = {}));
379
- async function K(t, e) {
394
+ async function ie(t, e) {
380
395
  window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
381
396
  event: t,
382
397
  eventId: e
383
398
  });
384
399
  }
385
- async function S(t, e, i) {
400
+ async function O(t, e, i) {
386
401
  var n;
387
402
  const a = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
388
403
  return s("plugin:event|listen", {
389
404
  event: t,
390
405
  target: a,
391
- handler: ve(e)
392
- }).then((r) => async () => K(t, r));
406
+ handler: Ne(e)
407
+ }).then((r) => async () => ie(t, r));
393
408
  }
394
409
  async function E(t, e, i) {
395
- return S(t, (n) => {
396
- K(t, n.id), e(n);
410
+ return O(t, (n) => {
411
+ ie(t, n.id), e(n);
397
412
  }, i);
398
413
  }
399
- async function X(t, e) {
414
+ async function ne(t, e) {
400
415
  await s("plugin:event|emit", {
401
416
  event: t,
402
417
  payload: e
403
418
  });
404
419
  }
405
- async function ee(t, e, i) {
420
+ async function se(t, e, i) {
406
421
  await s("plugin:event|emit_to", {
407
422
  target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
408
423
  event: e,
409
424
  payload: i
410
425
  });
411
426
  }
412
- class m extends We {
427
+ class W extends ze {
413
428
  /**
414
429
  * Creates an Image from a resource ID. For internal use only.
415
430
  *
@@ -421,10 +436,10 @@ class m extends We {
421
436
  /** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
422
437
  static async new(e, i, n) {
423
438
  return s("plugin:image|new", {
424
- rgba: A(e),
439
+ rgba: z(e),
425
440
  width: i,
426
441
  height: n
427
- }).then((a) => new m(a));
442
+ }).then((a) => new W(a));
428
443
  }
429
444
  /**
430
445
  * Creates a new image using the provided bytes by inferring the file format.
@@ -441,8 +456,8 @@ class m extends We {
441
456
  */
442
457
  static async fromBytes(e) {
443
458
  return s("plugin:image|from_bytes", {
444
- bytes: A(e)
445
- }).then((i) => new m(i));
459
+ bytes: z(e)
460
+ }).then((i) => new W(i));
446
461
  }
447
462
  /**
448
463
  * Creates a new image using the provided path.
@@ -457,7 +472,7 @@ class m extends We {
457
472
  * ```
458
473
  */
459
474
  static async fromPath(e) {
460
- 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));
461
476
  }
462
477
  /** Returns the RGBA data for this image, in row-major order from top to bottom. */
463
478
  async rgba() {
@@ -470,14 +485,14 @@ class m extends We {
470
485
  return s("plugin:image|size", { rid: this.rid });
471
486
  }
472
487
  }
473
- function A(t) {
474
- 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;
475
490
  }
476
- var C;
491
+ var R;
477
492
  (function(t) {
478
493
  t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
479
- })(C || (C = {}));
480
- class De {
494
+ })(R || (R = {}));
495
+ class Ae {
481
496
  constructor(e) {
482
497
  this._preventDefault = !1, this.event = e.event, this.id = e.id;
483
498
  }
@@ -488,23 +503,23 @@ class De {
488
503
  return this._preventDefault;
489
504
  }
490
505
  }
491
- var B;
506
+ var U;
492
507
  (function(t) {
493
508
  t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
494
- })(B || (B = {}));
495
- function te() {
509
+ })(U || (U = {}));
510
+ function ae() {
496
511
  return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
497
512
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
498
513
  skip: !0
499
514
  });
500
515
  }
501
- async function k() {
516
+ async function L() {
502
517
  return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
503
518
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
504
519
  skip: !0
505
520
  })));
506
521
  }
507
- const L = ["tauri://created", "tauri://error"];
522
+ const C = ["tauri://created", "tauri://error"];
508
523
  class P {
509
524
  /**
510
525
  * Creates a new Window.
@@ -546,19 +561,19 @@ class P {
546
561
  */
547
562
  static async getByLabel(e) {
548
563
  var i;
549
- 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;
550
565
  }
551
566
  /**
552
567
  * Get an instance of `Window` for the current window.
553
568
  */
554
569
  static getCurrent() {
555
- return te();
570
+ return ae();
556
571
  }
557
572
  /**
558
573
  * Gets a list of instances of `Window` for all available windows.
559
574
  */
560
575
  static async getAll() {
561
- return k();
576
+ return L();
562
577
  }
563
578
  /**
564
579
  * Gets the focused window.
@@ -571,7 +586,7 @@ class P {
571
586
  * @returns The Window instance or `undefined` if there is not any focused window.
572
587
  */
573
588
  static async getFocusedWindow() {
574
- for (const e of await k())
589
+ for (const e of await L())
575
590
  if (await e.isFocused())
576
591
  return e;
577
592
  return null;
@@ -599,7 +614,7 @@ class P {
599
614
  return this._handleTauriEvent(e, i) ? () => {
600
615
  const n = this.listeners[e];
601
616
  n.splice(n.indexOf(i), 1);
602
- } : S(e, i, {
617
+ } : O(e, i, {
603
618
  target: { kind: "Window", label: this.label }
604
619
  });
605
620
  }
@@ -642,7 +657,7 @@ class P {
642
657
  * @param payload Event payload.
643
658
  */
644
659
  async emit(e, i) {
645
- if (L.includes(e)) {
660
+ if (C.includes(e)) {
646
661
  for (const n of this.listeners[e] || [])
647
662
  n({
648
663
  event: e,
@@ -651,7 +666,7 @@ class P {
651
666
  });
652
667
  return;
653
668
  }
654
- return X(e, i);
669
+ return ne(e, i);
655
670
  }
656
671
  /**
657
672
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -666,7 +681,7 @@ class P {
666
681
  * @param payload Event payload.
667
682
  */
668
683
  async emitTo(e, i, n) {
669
- if (L.includes(i)) {
684
+ if (C.includes(i)) {
670
685
  for (const a of this.listeners[i] || [])
671
686
  a({
672
687
  event: i,
@@ -675,11 +690,11 @@ class P {
675
690
  });
676
691
  return;
677
692
  }
678
- return ee(e, i, n);
693
+ return se(e, i, n);
679
694
  }
680
695
  /** @ignore */
681
696
  _handleTauriEvent(e, i) {
682
- return L.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
697
+ return C.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
683
698
  }
684
699
  // Getters
685
700
  /**
@@ -741,7 +756,7 @@ class P {
741
756
  async innerSize() {
742
757
  return s("plugin:window|inner_size", {
743
758
  label: this.label
744
- }).then((e) => new g(e));
759
+ }).then((e) => new b(e));
745
760
  }
746
761
  /**
747
762
  * The physical size of the entire window.
@@ -757,7 +772,7 @@ class P {
757
772
  async outerSize() {
758
773
  return s("plugin:window|outer_size", {
759
774
  label: this.label
760
- }).then((e) => new g(e));
775
+ }).then((e) => new b(e));
761
776
  }
762
777
  /**
763
778
  * Gets the window's current fullscreen state.
@@ -1008,7 +1023,7 @@ class P {
1008
1023
  */
1009
1024
  async requestUserAttention(e) {
1010
1025
  let i = null;
1011
- return e && (e === C.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", {
1012
1027
  label: this.label,
1013
1028
  value: i
1014
1029
  });
@@ -1408,7 +1423,7 @@ class P {
1408
1423
  async setSize(e) {
1409
1424
  return s("plugin:window|set_size", {
1410
1425
  label: this.label,
1411
- value: e instanceof b ? e : new b(e)
1426
+ value: e instanceof g ? e : new g(e)
1412
1427
  });
1413
1428
  }
1414
1429
  /**
@@ -1425,7 +1440,7 @@ class P {
1425
1440
  async setMinSize(e) {
1426
1441
  return s("plugin:window|set_min_size", {
1427
1442
  label: this.label,
1428
- value: e instanceof b ? e : e ? new b(e) : null
1443
+ value: e instanceof g ? e : e ? new g(e) : null
1429
1444
  });
1430
1445
  }
1431
1446
  /**
@@ -1442,7 +1457,7 @@ class P {
1442
1457
  async setMaxSize(e) {
1443
1458
  return s("plugin:window|set_max_size", {
1444
1459
  label: this.label,
1445
- value: e instanceof b ? e : e ? new b(e) : null
1460
+ value: e instanceof g ? e : e ? new g(e) : null
1446
1461
  });
1447
1462
  }
1448
1463
  /**
@@ -1578,7 +1593,7 @@ class P {
1578
1593
  async setIcon(e) {
1579
1594
  return s("plugin:window|set_icon", {
1580
1595
  label: this.label,
1581
- value: A(e)
1596
+ value: z(e)
1582
1597
  });
1583
1598
  }
1584
1599
  /**
@@ -1813,7 +1828,7 @@ class P {
1813
1828
  async setOverlayIcon(e) {
1814
1829
  return s("plugin:window|set_overlay_icon", {
1815
1830
  label: this.label,
1816
- value: e ? A(e) : void 0
1831
+ value: e ? z(e) : void 0
1817
1832
  });
1818
1833
  }
1819
1834
  /**
@@ -1903,7 +1918,7 @@ class P {
1903
1918
  */
1904
1919
  async onResized(e) {
1905
1920
  return this.listen(o.WINDOW_RESIZED, (i) => {
1906
- i.payload = new g(i.payload), e(i);
1921
+ i.payload = new b(i.payload), e(i);
1907
1922
  });
1908
1923
  }
1909
1924
  /**
@@ -1952,7 +1967,7 @@ class P {
1952
1967
  */
1953
1968
  async onCloseRequested(e) {
1954
1969
  return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
1955
- const n = new De(i);
1970
+ const n = new Ae(i);
1956
1971
  await e(n), n.isPreventDefault() || await this.destroy();
1957
1972
  });
1958
1973
  }
@@ -2087,44 +2102,44 @@ class P {
2087
2102
  return this.listen(o.WINDOW_THEME_CHANGED, e);
2088
2103
  }
2089
2104
  }
2090
- var U;
2105
+ var H;
2091
2106
  (function(t) {
2092
2107
  t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
2093
- })(U || (U = {}));
2094
- var G;
2108
+ })(H || (H = {}));
2109
+ var Q;
2095
2110
  (function(t) {
2096
2111
  t.Default = "default", t.FluentOverlay = "fluentOverlay";
2097
- })(G || (G = {}));
2098
- var H;
2112
+ })(Q || (Q = {}));
2113
+ var V;
2099
2114
  (function(t) {
2100
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";
2101
- })(H || (H = {}));
2102
- var Q;
2116
+ })(V || (V = {}));
2117
+ var j;
2103
2118
  (function(t) {
2104
2119
  t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
2105
- })(Q || (Q = {}));
2106
- function ze(t) {
2120
+ })(j || (j = {}));
2121
+ function Oe(t) {
2107
2122
  return t === null ? null : {
2108
2123
  name: t.name,
2109
2124
  scaleFactor: t.scaleFactor,
2110
2125
  position: new u(t.position),
2111
- size: new g(t.size),
2126
+ size: new b(t.size),
2112
2127
  workArea: {
2113
2128
  position: new u(t.workArea.position),
2114
- size: new g(t.workArea.size)
2129
+ size: new b(t.workArea.size)
2115
2130
  }
2116
2131
  };
2117
2132
  }
2118
- async function Ae() {
2119
- return s("plugin:window|primary_monitor").then(ze);
2133
+ async function Pe() {
2134
+ return s("plugin:window|primary_monitor").then(Oe);
2120
2135
  }
2121
- function ie() {
2122
- return new T(te(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2136
+ function le() {
2137
+ return new T(ae(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2123
2138
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2124
2139
  skip: !0
2125
2140
  });
2126
2141
  }
2127
- async function V() {
2142
+ async function $() {
2128
2143
  return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new T(new P(e.windowLabel, {
2129
2144
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2130
2145
  skip: !0
@@ -2189,19 +2204,19 @@ class T {
2189
2204
  */
2190
2205
  static async getByLabel(e) {
2191
2206
  var i;
2192
- 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;
2193
2208
  }
2194
2209
  /**
2195
2210
  * Get an instance of `Webview` for the current webview.
2196
2211
  */
2197
2212
  static getCurrent() {
2198
- return ie();
2213
+ return le();
2199
2214
  }
2200
2215
  /**
2201
2216
  * Gets a list of instances of `Webview` for all available webviews.
2202
2217
  */
2203
2218
  static async getAll() {
2204
- return V();
2219
+ return $();
2205
2220
  }
2206
2221
  /**
2207
2222
  * Listen to an emitted event on this webview.
@@ -2226,7 +2241,7 @@ class T {
2226
2241
  return this._handleTauriEvent(e, i) ? () => {
2227
2242
  const n = this.listeners[e];
2228
2243
  n.splice(n.indexOf(i), 1);
2229
- } : S(e, i, {
2244
+ } : O(e, i, {
2230
2245
  target: { kind: "Webview", label: this.label }
2231
2246
  });
2232
2247
  }
@@ -2279,7 +2294,7 @@ class T {
2279
2294
  });
2280
2295
  return;
2281
2296
  }
2282
- return X(e, i);
2297
+ return ne(e, i);
2283
2298
  }
2284
2299
  /**
2285
2300
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -2304,7 +2319,7 @@ class T {
2304
2319
  });
2305
2320
  return;
2306
2321
  }
2307
- return ee(e, i, n);
2322
+ return se(e, i, n);
2308
2323
  }
2309
2324
  /** @ignore */
2310
2325
  _handleTauriEvent(e, i) {
@@ -2340,7 +2355,7 @@ class T {
2340
2355
  async size() {
2341
2356
  return s("plugin:webview|webview_size", {
2342
2357
  label: this.label
2343
- }).then((e) => new g(e));
2358
+ }).then((e) => new b(e));
2344
2359
  }
2345
2360
  // Setters
2346
2361
  /**
@@ -2372,7 +2387,7 @@ class T {
2372
2387
  async setSize(e) {
2373
2388
  return s("plugin:webview|set_webview_size", {
2374
2389
  label: this.label,
2375
- value: e instanceof b ? e : new b(e)
2390
+ value: e instanceof g ? e : new g(e)
2376
2391
  });
2377
2392
  }
2378
2393
  /**
@@ -2579,11 +2594,11 @@ class T {
2579
2594
  };
2580
2595
  }
2581
2596
  }
2582
- function Ne() {
2583
- const t = ie();
2597
+ function xe() {
2598
+ const t = le();
2584
2599
  return new _(t.label, { skip: !0 });
2585
2600
  }
2586
- async function j() {
2601
+ async function J() {
2587
2602
  return s("plugin:window|get_all_windows").then((t) => t.map((e) => new _(e, {
2588
2603
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2589
2604
  skip: !0
@@ -2632,20 +2647,20 @@ class _ {
2632
2647
  */
2633
2648
  static async getByLabel(e) {
2634
2649
  var i;
2635
- 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;
2636
2651
  return n ? new _(n.label, { skip: !0 }) : null;
2637
2652
  }
2638
2653
  /**
2639
2654
  * Get an instance of `Webview` for the current webview.
2640
2655
  */
2641
2656
  static getCurrent() {
2642
- return Ne();
2657
+ return xe();
2643
2658
  }
2644
2659
  /**
2645
2660
  * Gets a list of instances of `Webview` for all available webviews.
2646
2661
  */
2647
2662
  static async getAll() {
2648
- return j();
2663
+ return J();
2649
2664
  }
2650
2665
  /**
2651
2666
  * Listen to an emitted event on this webivew window.
@@ -2670,7 +2685,7 @@ class _ {
2670
2685
  return this._handleTauriEvent(e, i) ? () => {
2671
2686
  const n = this.listeners[e];
2672
2687
  n.splice(n.indexOf(i), 1);
2673
- } : S(e, i, {
2688
+ } : O(e, i, {
2674
2689
  target: { kind: "WebviewWindow", label: this.label }
2675
2690
  });
2676
2691
  }
@@ -2721,8 +2736,8 @@ class _ {
2721
2736
  return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
2722
2737
  }
2723
2738
  }
2724
- Se(_, [P, T]);
2725
- function Se(t, e) {
2739
+ Ie(_, [P, T]);
2740
+ function Ie(t, e) {
2726
2741
  (Array.isArray(e) ? e : [e]).forEach((i) => {
2727
2742
  Object.getOwnPropertyNames(i.prototype).forEach((n) => {
2728
2743
  var a;
@@ -2735,16 +2750,16 @@ function Se(t, e) {
2735
2750
  });
2736
2751
  });
2737
2752
  }
2738
- const v = /* @__PURE__ */ new Map(), Pe = async (t, e, i) => {
2753
+ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
2739
2754
  const n = i?.padding ?? 20;
2740
2755
  if (i?.x !== void 0 && i?.y !== void 0)
2741
2756
  return { x: i.x, y: i.y };
2742
2757
  let a = 1920, r = 1080;
2743
2758
  try {
2744
- const c = await Ae();
2745
- c?.size && (a = c.size.width, r = c.size.height);
2746
- } catch (c) {
2747
- 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);
2748
2763
  }
2749
2764
  switch (i?.position ?? "right-bottom") {
2750
2765
  case "right-bottom":
@@ -2778,139 +2793,147 @@ const v = /* @__PURE__ */ new Map(), Pe = async (t, e, i) => {
2778
2793
  y: r - e - n
2779
2794
  };
2780
2795
  }
2781
- }, Oe = async (t) => {
2782
- const e = String(t.id), i = d.getState();
2796
+ }, Le = async (t) => {
2797
+ const e = String(t.id), i = w.getState();
2783
2798
  if (i.isWindowActive(e)) {
2784
2799
  console.log(`Notice window already open for message: ${e}`);
2785
2800
  return;
2786
2801
  }
2787
- const n = $(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth, c = t.min_height || n.defaultHeight, { x: F, y: W } = await Pe(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);
2788
2803
  try {
2789
2804
  const y = new _(a, {
2790
2805
  url: r,
2791
2806
  title: t.title,
2792
2807
  width: l,
2793
- height: c,
2794
- x: F,
2795
- y: W,
2808
+ height: d,
2809
+ x: f,
2810
+ y: m,
2796
2811
  resizable: !0,
2797
2812
  decorations: !0,
2798
2813
  skipTaskbar: !1,
2799
2814
  alwaysOnTop: !0
2800
2815
  });
2801
- v.set(e, y), i.addActiveWindow(e), y.once("tauri://destroyed", async () => {
2802
- v.delete(e), i.removeActiveWindow(e), await he(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();
2803
2818
  }), console.log(`Created notice window: ${a}`);
2804
2819
  } catch (y) {
2805
2820
  console.error("Failed to create notice window:", y), i.removeActiveWindow(e), i.clearCurrent();
2806
2821
  }
2807
2822
  }, q = async (t) => {
2808
- const e = String(t), i = v.get(e);
2823
+ const e = String(t), i = D.get(e);
2809
2824
  if (i)
2810
2825
  try {
2811
- 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}`);
2812
2827
  } catch (n) {
2813
2828
  console.error("Failed to close notice window:", n);
2814
2829
  }
2815
- }, xe = async () => {
2816
- const t = Array.from(v.keys()).map(
2830
+ }, Ce = async () => {
2831
+ const t = Array.from(D.keys()).map(
2817
2832
  (e) => q(e)
2818
2833
  );
2819
2834
  await Promise.all(t);
2820
- }, Ie = () => {
2835
+ }, Me = () => {
2821
2836
  let t = null;
2822
- d.subscribe((e) => {
2837
+ w.subscribe((e) => {
2823
2838
  const i = e.currentMessage;
2824
- i && i !== t ? (t = i, Oe(i)) : i || (t = null);
2839
+ i && i !== t ? (t = i, Le(i)) : i || (t = null);
2825
2840
  }), console.log("Notice window system initialized");
2826
- }, qe = () => {
2827
- const t = d((i) => i.currentMessage);
2828
- return { closeNotice: N(async () => {
2841
+ }, Ue = () => {
2842
+ const t = w((i) => i.currentMessage);
2843
+ return { closeNotice: A(async () => {
2829
2844
  t && await q(t.id);
2830
2845
  }, [t]) };
2831
- }, Fe = () => {
2832
- const t = d();
2833
- return { hideNotice: N(
2846
+ }, He = () => {
2847
+ const t = w();
2848
+ return { hideNotice: A(
2834
2849
  async (i) => {
2835
- await be(i), await q(i), t.currentMessage?.id === i && t.clearCurrent();
2850
+ await _e(i), await q(i), t.currentMessage?.id === i && t.clearCurrent();
2836
2851
  },
2837
2852
  [t]
2838
2853
  ) };
2839
- }, Be = () => {
2840
- const t = d((i) => i.clearOnLogout);
2841
- return { hideAllNotices: N(async () => {
2842
- await xe(), await t();
2854
+ }, Qe = () => {
2855
+ const t = w((i) => i.clearOnLogout);
2856
+ return { hideAllNotices: A(async () => {
2857
+ await Ce(), await t();
2843
2858
  }, [t]) };
2844
- }, Ue = () => {
2845
- const t = d(D.queueLength), e = d(D.currentMessage), i = d(D.isProcessing), n = d(D.queue);
2859
+ }, Ve = () => {
2860
+ const t = w(S.queueLength), e = w(S.currentMessage), i = w(S.isProcessing), n = w(S.queue);
2846
2861
  return {
2847
2862
  queueLength: t,
2848
2863
  currentMessage: e,
2849
2864
  isProcessing: i,
2850
2865
  queue: n
2851
2866
  };
2852
- }, Ge = ({ children: t, onLoad: e }) => {
2853
- const [i, n] = x(null), [a, r] = x(!0), [l, c] = x(null);
2854
- return le(() => {
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(() => {
2855
2870
  (async () => {
2856
2871
  try {
2857
- const y = new URLSearchParams(window.location.search).get("id");
2858
- if (!y) {
2859
- 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);
2860
2875
  return;
2861
2876
  }
2862
- const O = await ge(y);
2863
- if (!O) {
2864
- c("Message not found"), r(!1);
2877
+ const x = await fe(F);
2878
+ if (!x) {
2879
+ f("Message not found"), l(!1);
2865
2880
  return;
2866
2881
  }
2867
- n(O), r(!1), e && e(O);
2868
- } catch (W) {
2869
- 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);
2870
2885
  }
2871
2886
  })();
2872
- }, [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: {
2873
2896
  display: "flex",
2874
2897
  justifyContent: "center",
2875
2898
  alignItems: "center",
2876
2899
  height: "100vh",
2877
2900
  fontFamily: "system-ui, -apple-system, sans-serif"
2878
- }, children: "Loading..." }) : l || !i ? /* @__PURE__ */ I("div", { style: {
2901
+ }, children: "Loading..." }) : d || !n ? /* @__PURE__ */ k("div", { style: {
2879
2902
  display: "flex",
2880
2903
  justifyContent: "center",
2881
2904
  alignItems: "center",
2882
2905
  height: "100vh",
2883
2906
  fontFamily: "system-ui, -apple-system, sans-serif",
2884
2907
  color: "#ef4444"
2885
- }, children: l || "Message not found" }) : /* @__PURE__ */ I(re, { children: t(i) });
2886
- }, He = async () => {
2887
- J(), Ie();
2888
- const { initializeFromDatabase: t } = d.getState();
2908
+ }, children: d || "Message not found" }) : /* @__PURE__ */ k(ce, { children: t(n) });
2909
+ }, $e = async () => {
2910
+ X(), Me();
2911
+ const { initializeFromDatabase: t } = w.getState();
2889
2912
  await t(), console.log("Tauri Notice System initialized");
2890
2913
  };
2891
2914
  export {
2892
- Ge as NoticeLayout,
2893
- ye as clearPendingMessages,
2894
- xe as closeAllNoticeWindows,
2915
+ je as NoticeLayout,
2916
+ me as clearPendingMessages,
2917
+ Ce as closeAllNoticeWindows,
2895
2918
  q as closeNoticeWindow,
2896
- Oe as createNoticeWindow,
2897
- ge as getMessage,
2898
- $ as getNoticeConfig,
2899
- we as getPendingMessages,
2900
- ce as hasMessage,
2901
- J as initializeDatabase,
2902
- He as initializeNoticeSystem,
2903
- Ie as initializeNoticeWindowSystem,
2904
- be as markAsHidden,
2905
- he as markAsShown,
2906
- D as messageQueueSelectors,
2907
- ue as saveMessage,
2908
- Ee as setNoticeConfig,
2909
- qe as useCloseNotice,
2910
- Be as useHideAllNotices,
2911
- Fe as useHideNotice,
2912
- Ue as useMessageQueue,
2913
- d as useMessageQueueStore,
2914
- Te as useNoticeWindow
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,
2936
+ w as useMessageQueueStore,
2937
+ Ge as useNoticeWindow
2915
2938
  };
2916
2939
  //# sourceMappingURL=index.js.map