tauri-notice-window 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +163 -155
- package/dist/index.js.map +1 -1
- package/dist/stores/messageQueueStore.d.ts.map +1 -1
- package/dist/utils/db.d.ts +6 -0
- package/dist/utils/db.d.ts.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
import { syncTabs as
|
|
3
|
-
import
|
|
1
|
+
import { create as oe } from "zustand";
|
|
2
|
+
import { syncTabs as ue } from "zustand-sync";
|
|
3
|
+
import ce from "dexie";
|
|
4
4
|
import { useCallback as A, useState as I, useEffect as B } from "react";
|
|
5
|
-
import { jsx as k, Fragment as
|
|
5
|
+
import { jsx as k, Fragment as de } from "react/jsx-runtime";
|
|
6
6
|
const Z = "tauri-notice-config", G = {
|
|
7
7
|
routePrefix: "/notice",
|
|
8
8
|
databaseName: "tauri-notice-db",
|
|
@@ -17,17 +17,17 @@ const Z = "tauri-notice-config", G = {
|
|
|
17
17
|
console.warn("Failed to load config from localStorage:", t);
|
|
18
18
|
}
|
|
19
19
|
return G;
|
|
20
|
-
},
|
|
20
|
+
}, we = (t) => {
|
|
21
21
|
try {
|
|
22
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
|
-
},
|
|
26
|
+
}, Ge = (t) => {
|
|
27
27
|
const i = { ...Y(), ...t };
|
|
28
|
-
|
|
28
|
+
we(i);
|
|
29
29
|
}, K = () => Y();
|
|
30
|
-
class
|
|
30
|
+
class he extends ce {
|
|
31
31
|
messages;
|
|
32
32
|
constructor(e) {
|
|
33
33
|
super(e), this.version(1).stores({
|
|
@@ -39,10 +39,10 @@ let v = null;
|
|
|
39
39
|
const X = () => {
|
|
40
40
|
if (!v) {
|
|
41
41
|
const t = K();
|
|
42
|
-
v = new
|
|
42
|
+
v = new he(t.databaseName);
|
|
43
43
|
}
|
|
44
44
|
return v;
|
|
45
|
-
}, h = () => v || X(),
|
|
45
|
+
}, h = () => v || X(), ge = async (t) => {
|
|
46
46
|
const e = {
|
|
47
47
|
...t,
|
|
48
48
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -52,25 +52,28 @@ const X = () => {
|
|
|
52
52
|
queuePosition: 0
|
|
53
53
|
};
|
|
54
54
|
await h().messages.put(e);
|
|
55
|
-
},
|
|
55
|
+
}, be = async (t) => !!await h().messages.get(t), ye = async (t) => {
|
|
56
|
+
const e = await h().messages.get(t);
|
|
57
|
+
return e?.isShown === !0 || e?.queueStatus === "shown";
|
|
58
|
+
}, pe = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), _e = async (t, e) => {
|
|
56
59
|
await h().messages.update(t, { queueStatus: e });
|
|
57
|
-
},
|
|
60
|
+
}, ee = async (t) => {
|
|
58
61
|
await h().messages.update(t, {
|
|
59
62
|
queueStatus: "shown",
|
|
60
63
|
isShown: !0
|
|
61
64
|
});
|
|
62
|
-
},
|
|
65
|
+
}, fe = async (t) => {
|
|
63
66
|
await h().messages.update(t, {
|
|
64
67
|
queueStatus: "hidden"
|
|
65
68
|
});
|
|
66
|
-
},
|
|
69
|
+
}, me = async (t) => await h().messages.get(t), ve = async () => {
|
|
67
70
|
await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
68
|
-
},
|
|
71
|
+
}, We = async (t) => {
|
|
69
72
|
const e = t.map(
|
|
70
73
|
(i) => h().messages.update(i.id, { queuePosition: i.position })
|
|
71
74
|
);
|
|
72
75
|
await Promise.all(e);
|
|
73
|
-
},
|
|
76
|
+
}, Se = (t, e) => ({
|
|
74
77
|
// Initial state
|
|
75
78
|
queue: [],
|
|
76
79
|
currentMessage: null,
|
|
@@ -80,9 +83,13 @@ const X = () => {
|
|
|
80
83
|
// Enqueue a new message
|
|
81
84
|
enqueue: async (i) => {
|
|
82
85
|
const n = e();
|
|
83
|
-
if (await
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
if (await ye(i.id)) {
|
|
87
|
+
console.log(`Message ${i.id} was already shown, skipping`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (await be(i.id) || await ge(i), !n.queue.some((u) => u.id === i.id)) {
|
|
91
|
+
const u = [...n.queue, i];
|
|
92
|
+
t({ queue: u }), await e().persistQueue();
|
|
86
93
|
}
|
|
87
94
|
!n.isProcessing && !n.currentMessage && await e().showNext();
|
|
88
95
|
},
|
|
@@ -104,7 +111,7 @@ const X = () => {
|
|
|
104
111
|
t({
|
|
105
112
|
currentMessage: n,
|
|
106
113
|
isProcessing: !0
|
|
107
|
-
}), await
|
|
114
|
+
}), await _e(n.id, "showing"), await e().persistQueue();
|
|
108
115
|
},
|
|
109
116
|
// Clear current message and show next
|
|
110
117
|
clearCurrent: () => {
|
|
@@ -129,7 +136,7 @@ const X = () => {
|
|
|
129
136
|
initializeFromDatabase: async () => {
|
|
130
137
|
if (e().initialized) return;
|
|
131
138
|
t({ initialized: !0 });
|
|
132
|
-
const n = await
|
|
139
|
+
const n = await pe();
|
|
133
140
|
n.length > 0 && (t({ queue: n }), await e().showNext());
|
|
134
141
|
},
|
|
135
142
|
// Persist queue to database
|
|
@@ -138,7 +145,7 @@ const X = () => {
|
|
|
138
145
|
id: a.id,
|
|
139
146
|
position: r
|
|
140
147
|
}));
|
|
141
|
-
await
|
|
148
|
+
await We(n);
|
|
142
149
|
},
|
|
143
150
|
// Clear all messages on logout
|
|
144
151
|
clearOnLogout: async () => {
|
|
@@ -148,7 +155,7 @@ const X = () => {
|
|
|
148
155
|
isProcessing: !1,
|
|
149
156
|
activeWindowIds: [],
|
|
150
157
|
initialized: !1
|
|
151
|
-
}), await
|
|
158
|
+
}), await ve();
|
|
152
159
|
},
|
|
153
160
|
// Add active window ID
|
|
154
161
|
addActiveWindow: (i) => {
|
|
@@ -167,17 +174,17 @@ const X = () => {
|
|
|
167
174
|
const n = e(), a = String(i);
|
|
168
175
|
return n.activeWindowIds.includes(a);
|
|
169
176
|
}
|
|
170
|
-
}),
|
|
171
|
-
|
|
177
|
+
}), d = oe()(
|
|
178
|
+
ue(Se, {
|
|
172
179
|
name: "tauri-notice-queue"
|
|
173
180
|
})
|
|
174
|
-
),
|
|
181
|
+
), D = {
|
|
175
182
|
queueLength: (t) => t.queue.length,
|
|
176
183
|
currentMessage: (t) => t.currentMessage,
|
|
177
184
|
isProcessing: (t) => t.isProcessing,
|
|
178
185
|
queue: (t) => t.queue
|
|
179
|
-
},
|
|
180
|
-
const t =
|
|
186
|
+
}, Ue = () => {
|
|
187
|
+
const t = d((i) => i.enqueue);
|
|
181
188
|
return { showNotice: A(
|
|
182
189
|
async (i) => {
|
|
183
190
|
await t(i);
|
|
@@ -189,24 +196,24 @@ function De(t, e, i, n) {
|
|
|
189
196
|
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
197
|
return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
|
|
191
198
|
}
|
|
192
|
-
function
|
|
199
|
+
function Ne(t, e, i, n, a) {
|
|
193
200
|
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
201
|
return e.set(t, i), i;
|
|
195
202
|
}
|
|
196
203
|
var N;
|
|
197
|
-
const
|
|
198
|
-
function
|
|
204
|
+
const w = "__TAURI_TO_IPC_KEY__";
|
|
205
|
+
function ze(t, e = !1) {
|
|
199
206
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
200
207
|
}
|
|
201
208
|
async function s(t, e = {}, i) {
|
|
202
209
|
return window.__TAURI_INTERNALS__.invoke(t, e, i);
|
|
203
210
|
}
|
|
204
|
-
class
|
|
211
|
+
class Ae {
|
|
205
212
|
get rid() {
|
|
206
213
|
return De(this, N, "f");
|
|
207
214
|
}
|
|
208
215
|
constructor(e) {
|
|
209
|
-
N.set(this, void 0),
|
|
216
|
+
N.set(this, void 0), Ne(this, N, e);
|
|
210
217
|
}
|
|
211
218
|
/**
|
|
212
219
|
* Destroys and cleans up this resource from memory.
|
|
@@ -219,7 +226,7 @@ class ze {
|
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
N = /* @__PURE__ */ new WeakMap();
|
|
222
|
-
class
|
|
229
|
+
class te {
|
|
223
230
|
constructor(...e) {
|
|
224
231
|
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
232
|
}
|
|
@@ -241,14 +248,14 @@ class ee {
|
|
|
241
248
|
toPhysical(e) {
|
|
242
249
|
return new b(this.width * e, this.height * e);
|
|
243
250
|
}
|
|
244
|
-
[
|
|
251
|
+
[w]() {
|
|
245
252
|
return {
|
|
246
253
|
width: this.width,
|
|
247
254
|
height: this.height
|
|
248
255
|
};
|
|
249
256
|
}
|
|
250
257
|
toJSON() {
|
|
251
|
-
return this[
|
|
258
|
+
return this[w]();
|
|
252
259
|
}
|
|
253
260
|
}
|
|
254
261
|
class b {
|
|
@@ -267,16 +274,16 @@ class b {
|
|
|
267
274
|
* ```
|
|
268
275
|
*/
|
|
269
276
|
toLogical(e) {
|
|
270
|
-
return new
|
|
277
|
+
return new te(this.width / e, this.height / e);
|
|
271
278
|
}
|
|
272
|
-
[
|
|
279
|
+
[w]() {
|
|
273
280
|
return {
|
|
274
281
|
width: this.width,
|
|
275
282
|
height: this.height
|
|
276
283
|
};
|
|
277
284
|
}
|
|
278
285
|
toJSON() {
|
|
279
|
-
return this[
|
|
286
|
+
return this[w]();
|
|
280
287
|
}
|
|
281
288
|
}
|
|
282
289
|
class g {
|
|
@@ -284,12 +291,12 @@ class g {
|
|
|
284
291
|
this.size = e;
|
|
285
292
|
}
|
|
286
293
|
toLogical(e) {
|
|
287
|
-
return this.size instanceof
|
|
294
|
+
return this.size instanceof te ? this.size : this.size.toLogical(e);
|
|
288
295
|
}
|
|
289
296
|
toPhysical(e) {
|
|
290
297
|
return this.size instanceof b ? this.size : this.size.toPhysical(e);
|
|
291
298
|
}
|
|
292
|
-
[
|
|
299
|
+
[w]() {
|
|
293
300
|
return {
|
|
294
301
|
[`${this.size.type}`]: {
|
|
295
302
|
width: this.size.width,
|
|
@@ -298,10 +305,10 @@ class g {
|
|
|
298
305
|
};
|
|
299
306
|
}
|
|
300
307
|
toJSON() {
|
|
301
|
-
return this[
|
|
308
|
+
return this[w]();
|
|
302
309
|
}
|
|
303
310
|
}
|
|
304
|
-
class
|
|
311
|
+
class ie {
|
|
305
312
|
constructor(...e) {
|
|
306
313
|
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
314
|
}
|
|
@@ -321,19 +328,19 @@ class te {
|
|
|
321
328
|
* @since 2.0.0
|
|
322
329
|
*/
|
|
323
330
|
toPhysical(e) {
|
|
324
|
-
return new
|
|
331
|
+
return new c(this.x * e, this.y * e);
|
|
325
332
|
}
|
|
326
|
-
[
|
|
333
|
+
[w]() {
|
|
327
334
|
return {
|
|
328
335
|
x: this.x,
|
|
329
336
|
y: this.y
|
|
330
337
|
};
|
|
331
338
|
}
|
|
332
339
|
toJSON() {
|
|
333
|
-
return this[
|
|
340
|
+
return this[w]();
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
|
-
class
|
|
343
|
+
class c {
|
|
337
344
|
constructor(...e) {
|
|
338
345
|
this.type = "Physical", e.length === 1 ? "Physical" in e[0] ? (this.x = e[0].Physical.x, this.y = e[0].Physical.y) : (this.x = e[0].x, this.y = e[0].y) : (this.x = e[0], this.y = e[1]);
|
|
339
346
|
}
|
|
@@ -353,16 +360,16 @@ class u {
|
|
|
353
360
|
* @since 2.0.0
|
|
354
361
|
*/
|
|
355
362
|
toLogical(e) {
|
|
356
|
-
return new
|
|
363
|
+
return new ie(this.x / e, this.y / e);
|
|
357
364
|
}
|
|
358
|
-
[
|
|
365
|
+
[w]() {
|
|
359
366
|
return {
|
|
360
367
|
x: this.x,
|
|
361
368
|
y: this.y
|
|
362
369
|
};
|
|
363
370
|
}
|
|
364
371
|
toJSON() {
|
|
365
|
-
return this[
|
|
372
|
+
return this[w]();
|
|
366
373
|
}
|
|
367
374
|
}
|
|
368
375
|
class p {
|
|
@@ -370,12 +377,12 @@ class p {
|
|
|
370
377
|
this.position = e;
|
|
371
378
|
}
|
|
372
379
|
toLogical(e) {
|
|
373
|
-
return this.position instanceof
|
|
380
|
+
return this.position instanceof ie ? this.position : this.position.toLogical(e);
|
|
374
381
|
}
|
|
375
382
|
toPhysical(e) {
|
|
376
|
-
return this.position instanceof
|
|
383
|
+
return this.position instanceof c ? this.position : this.position.toPhysical(e);
|
|
377
384
|
}
|
|
378
|
-
[
|
|
385
|
+
[w]() {
|
|
379
386
|
return {
|
|
380
387
|
[`${this.position.type}`]: {
|
|
381
388
|
x: this.position.x,
|
|
@@ -384,14 +391,14 @@ class p {
|
|
|
384
391
|
};
|
|
385
392
|
}
|
|
386
393
|
toJSON() {
|
|
387
|
-
return this[
|
|
394
|
+
return this[w]();
|
|
388
395
|
}
|
|
389
396
|
}
|
|
390
397
|
var o;
|
|
391
398
|
(function(t) {
|
|
392
399
|
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
400
|
})(o || (o = {}));
|
|
394
|
-
async function
|
|
401
|
+
async function ne(t, e) {
|
|
395
402
|
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
|
|
396
403
|
event: t,
|
|
397
404
|
eventId: e
|
|
@@ -403,28 +410,28 @@ async function O(t, e, i) {
|
|
|
403
410
|
return s("plugin:event|listen", {
|
|
404
411
|
event: t,
|
|
405
412
|
target: a,
|
|
406
|
-
handler:
|
|
407
|
-
}).then((r) => async () =>
|
|
413
|
+
handler: ze(e)
|
|
414
|
+
}).then((r) => async () => ne(t, r));
|
|
408
415
|
}
|
|
409
416
|
async function E(t, e, i) {
|
|
410
417
|
return O(t, (n) => {
|
|
411
|
-
|
|
418
|
+
ne(t, n.id), e(n);
|
|
412
419
|
}, i);
|
|
413
420
|
}
|
|
414
|
-
async function
|
|
421
|
+
async function se(t, e) {
|
|
415
422
|
await s("plugin:event|emit", {
|
|
416
423
|
event: t,
|
|
417
424
|
payload: e
|
|
418
425
|
});
|
|
419
426
|
}
|
|
420
|
-
async function
|
|
427
|
+
async function ae(t, e, i) {
|
|
421
428
|
await s("plugin:event|emit_to", {
|
|
422
429
|
target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
|
|
423
430
|
event: e,
|
|
424
431
|
payload: i
|
|
425
432
|
});
|
|
426
433
|
}
|
|
427
|
-
class W extends
|
|
434
|
+
class W extends Ae {
|
|
428
435
|
/**
|
|
429
436
|
* Creates an Image from a resource ID. For internal use only.
|
|
430
437
|
*
|
|
@@ -492,7 +499,7 @@ var R;
|
|
|
492
499
|
(function(t) {
|
|
493
500
|
t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
|
|
494
501
|
})(R || (R = {}));
|
|
495
|
-
class
|
|
502
|
+
class Oe {
|
|
496
503
|
constructor(e) {
|
|
497
504
|
this._preventDefault = !1, this.event = e.event, this.id = e.id;
|
|
498
505
|
}
|
|
@@ -507,19 +514,19 @@ var U;
|
|
|
507
514
|
(function(t) {
|
|
508
515
|
t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
|
|
509
516
|
})(U || (U = {}));
|
|
510
|
-
function
|
|
517
|
+
function le() {
|
|
511
518
|
return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
512
519
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
513
520
|
skip: !0
|
|
514
521
|
});
|
|
515
522
|
}
|
|
516
|
-
async function
|
|
523
|
+
async function C() {
|
|
517
524
|
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
|
|
518
525
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
519
526
|
skip: !0
|
|
520
527
|
})));
|
|
521
528
|
}
|
|
522
|
-
const
|
|
529
|
+
const L = ["tauri://created", "tauri://error"];
|
|
523
530
|
class P {
|
|
524
531
|
/**
|
|
525
532
|
* Creates a new Window.
|
|
@@ -561,19 +568,19 @@ class P {
|
|
|
561
568
|
*/
|
|
562
569
|
static async getByLabel(e) {
|
|
563
570
|
var i;
|
|
564
|
-
return (i = (await
|
|
571
|
+
return (i = (await C()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
565
572
|
}
|
|
566
573
|
/**
|
|
567
574
|
* Get an instance of `Window` for the current window.
|
|
568
575
|
*/
|
|
569
576
|
static getCurrent() {
|
|
570
|
-
return
|
|
577
|
+
return le();
|
|
571
578
|
}
|
|
572
579
|
/**
|
|
573
580
|
* Gets a list of instances of `Window` for all available windows.
|
|
574
581
|
*/
|
|
575
582
|
static async getAll() {
|
|
576
|
-
return
|
|
583
|
+
return C();
|
|
577
584
|
}
|
|
578
585
|
/**
|
|
579
586
|
* Gets the focused window.
|
|
@@ -586,7 +593,7 @@ class P {
|
|
|
586
593
|
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
587
594
|
*/
|
|
588
595
|
static async getFocusedWindow() {
|
|
589
|
-
for (const e of await
|
|
596
|
+
for (const e of await C())
|
|
590
597
|
if (await e.isFocused())
|
|
591
598
|
return e;
|
|
592
599
|
return null;
|
|
@@ -657,7 +664,7 @@ class P {
|
|
|
657
664
|
* @param payload Event payload.
|
|
658
665
|
*/
|
|
659
666
|
async emit(e, i) {
|
|
660
|
-
if (
|
|
667
|
+
if (L.includes(e)) {
|
|
661
668
|
for (const n of this.listeners[e] || [])
|
|
662
669
|
n({
|
|
663
670
|
event: e,
|
|
@@ -666,7 +673,7 @@ class P {
|
|
|
666
673
|
});
|
|
667
674
|
return;
|
|
668
675
|
}
|
|
669
|
-
return
|
|
676
|
+
return se(e, i);
|
|
670
677
|
}
|
|
671
678
|
/**
|
|
672
679
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -681,7 +688,7 @@ class P {
|
|
|
681
688
|
* @param payload Event payload.
|
|
682
689
|
*/
|
|
683
690
|
async emitTo(e, i, n) {
|
|
684
|
-
if (
|
|
691
|
+
if (L.includes(i)) {
|
|
685
692
|
for (const a of this.listeners[i] || [])
|
|
686
693
|
a({
|
|
687
694
|
event: i,
|
|
@@ -690,11 +697,11 @@ class P {
|
|
|
690
697
|
});
|
|
691
698
|
return;
|
|
692
699
|
}
|
|
693
|
-
return
|
|
700
|
+
return ae(e, i, n);
|
|
694
701
|
}
|
|
695
702
|
/** @ignore */
|
|
696
703
|
_handleTauriEvent(e, i) {
|
|
697
|
-
return
|
|
704
|
+
return L.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
698
705
|
}
|
|
699
706
|
// Getters
|
|
700
707
|
/**
|
|
@@ -725,7 +732,7 @@ class P {
|
|
|
725
732
|
async innerPosition() {
|
|
726
733
|
return s("plugin:window|inner_position", {
|
|
727
734
|
label: this.label
|
|
728
|
-
}).then((e) => new
|
|
735
|
+
}).then((e) => new c(e));
|
|
729
736
|
}
|
|
730
737
|
/**
|
|
731
738
|
* The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
|
|
@@ -740,7 +747,7 @@ class P {
|
|
|
740
747
|
async outerPosition() {
|
|
741
748
|
return s("plugin:window|outer_position", {
|
|
742
749
|
label: this.label
|
|
743
|
-
}).then((e) => new
|
|
750
|
+
}).then((e) => new c(e));
|
|
744
751
|
}
|
|
745
752
|
/**
|
|
746
753
|
* The physical size of the window's client area.
|
|
@@ -1940,7 +1947,7 @@ class P {
|
|
|
1940
1947
|
*/
|
|
1941
1948
|
async onMoved(e) {
|
|
1942
1949
|
return this.listen(o.WINDOW_MOVED, (i) => {
|
|
1943
|
-
i.payload = new
|
|
1950
|
+
i.payload = new c(i.payload), e(i);
|
|
1944
1951
|
});
|
|
1945
1952
|
}
|
|
1946
1953
|
/**
|
|
@@ -1967,7 +1974,7 @@ class P {
|
|
|
1967
1974
|
*/
|
|
1968
1975
|
async onCloseRequested(e) {
|
|
1969
1976
|
return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
|
|
1970
|
-
const n = new
|
|
1977
|
+
const n = new Oe(i);
|
|
1971
1978
|
await e(n), n.isPreventDefault() || await this.destroy();
|
|
1972
1979
|
});
|
|
1973
1980
|
}
|
|
@@ -2003,7 +2010,7 @@ class P {
|
|
|
2003
2010
|
payload: {
|
|
2004
2011
|
type: "enter",
|
|
2005
2012
|
paths: l.payload.paths,
|
|
2006
|
-
position: new
|
|
2013
|
+
position: new c(l.payload.position)
|
|
2007
2014
|
}
|
|
2008
2015
|
});
|
|
2009
2016
|
}), n = await this.listen(o.DRAG_OVER, (l) => {
|
|
@@ -2011,7 +2018,7 @@ class P {
|
|
|
2011
2018
|
...l,
|
|
2012
2019
|
payload: {
|
|
2013
2020
|
type: "over",
|
|
2014
|
-
position: new
|
|
2021
|
+
position: new c(l.payload.position)
|
|
2015
2022
|
}
|
|
2016
2023
|
});
|
|
2017
2024
|
}), a = await this.listen(o.DRAG_DROP, (l) => {
|
|
@@ -2020,7 +2027,7 @@ class P {
|
|
|
2020
2027
|
payload: {
|
|
2021
2028
|
type: "drop",
|
|
2022
2029
|
paths: l.payload.paths,
|
|
2023
|
-
position: new
|
|
2030
|
+
position: new c(l.payload.position)
|
|
2024
2031
|
}
|
|
2025
2032
|
});
|
|
2026
2033
|
}), r = await this.listen(o.DRAG_LEAVE, (l) => {
|
|
@@ -2118,23 +2125,23 @@ var j;
|
|
|
2118
2125
|
(function(t) {
|
|
2119
2126
|
t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
|
|
2120
2127
|
})(j || (j = {}));
|
|
2121
|
-
function
|
|
2128
|
+
function Pe(t) {
|
|
2122
2129
|
return t === null ? null : {
|
|
2123
2130
|
name: t.name,
|
|
2124
2131
|
scaleFactor: t.scaleFactor,
|
|
2125
|
-
position: new
|
|
2132
|
+
position: new c(t.position),
|
|
2126
2133
|
size: new b(t.size),
|
|
2127
2134
|
workArea: {
|
|
2128
|
-
position: new
|
|
2135
|
+
position: new c(t.workArea.position),
|
|
2129
2136
|
size: new b(t.workArea.size)
|
|
2130
2137
|
}
|
|
2131
2138
|
};
|
|
2132
2139
|
}
|
|
2133
|
-
async function
|
|
2134
|
-
return s("plugin:window|primary_monitor").then(
|
|
2140
|
+
async function xe() {
|
|
2141
|
+
return s("plugin:window|primary_monitor").then(Pe);
|
|
2135
2142
|
}
|
|
2136
|
-
function
|
|
2137
|
-
return new T(
|
|
2143
|
+
function re() {
|
|
2144
|
+
return new T(le(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
|
|
2138
2145
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2139
2146
|
skip: !0
|
|
2140
2147
|
});
|
|
@@ -2210,7 +2217,7 @@ class T {
|
|
|
2210
2217
|
* Get an instance of `Webview` for the current webview.
|
|
2211
2218
|
*/
|
|
2212
2219
|
static getCurrent() {
|
|
2213
|
-
return
|
|
2220
|
+
return re();
|
|
2214
2221
|
}
|
|
2215
2222
|
/**
|
|
2216
2223
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
@@ -2294,7 +2301,7 @@ class T {
|
|
|
2294
2301
|
});
|
|
2295
2302
|
return;
|
|
2296
2303
|
}
|
|
2297
|
-
return
|
|
2304
|
+
return se(e, i);
|
|
2298
2305
|
}
|
|
2299
2306
|
/**
|
|
2300
2307
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -2319,7 +2326,7 @@ class T {
|
|
|
2319
2326
|
});
|
|
2320
2327
|
return;
|
|
2321
2328
|
}
|
|
2322
|
-
return
|
|
2329
|
+
return ae(e, i, n);
|
|
2323
2330
|
}
|
|
2324
2331
|
/** @ignore */
|
|
2325
2332
|
_handleTauriEvent(e, i) {
|
|
@@ -2339,7 +2346,7 @@ class T {
|
|
|
2339
2346
|
async position() {
|
|
2340
2347
|
return s("plugin:webview|webview_position", {
|
|
2341
2348
|
label: this.label
|
|
2342
|
-
}).then((e) => new
|
|
2349
|
+
}).then((e) => new c(e));
|
|
2343
2350
|
}
|
|
2344
2351
|
/**
|
|
2345
2352
|
* The physical size of the webview's client area.
|
|
@@ -2566,7 +2573,7 @@ class T {
|
|
|
2566
2573
|
payload: {
|
|
2567
2574
|
type: "enter",
|
|
2568
2575
|
paths: l.payload.paths,
|
|
2569
|
-
position: new
|
|
2576
|
+
position: new c(l.payload.position)
|
|
2570
2577
|
}
|
|
2571
2578
|
});
|
|
2572
2579
|
}), n = await this.listen(o.DRAG_OVER, (l) => {
|
|
@@ -2574,7 +2581,7 @@ class T {
|
|
|
2574
2581
|
...l,
|
|
2575
2582
|
payload: {
|
|
2576
2583
|
type: "over",
|
|
2577
|
-
position: new
|
|
2584
|
+
position: new c(l.payload.position)
|
|
2578
2585
|
}
|
|
2579
2586
|
});
|
|
2580
2587
|
}), a = await this.listen(o.DRAG_DROP, (l) => {
|
|
@@ -2583,7 +2590,7 @@ class T {
|
|
|
2583
2590
|
payload: {
|
|
2584
2591
|
type: "drop",
|
|
2585
2592
|
paths: l.payload.paths,
|
|
2586
|
-
position: new
|
|
2593
|
+
position: new c(l.payload.position)
|
|
2587
2594
|
}
|
|
2588
2595
|
});
|
|
2589
2596
|
}), r = await this.listen(o.DRAG_LEAVE, (l) => {
|
|
@@ -2594,8 +2601,8 @@ class T {
|
|
|
2594
2601
|
};
|
|
2595
2602
|
}
|
|
2596
2603
|
}
|
|
2597
|
-
function
|
|
2598
|
-
const t =
|
|
2604
|
+
function Ie() {
|
|
2605
|
+
const t = re();
|
|
2599
2606
|
return new _(t.label, { skip: !0 });
|
|
2600
2607
|
}
|
|
2601
2608
|
async function J() {
|
|
@@ -2654,7 +2661,7 @@ class _ {
|
|
|
2654
2661
|
* Get an instance of `Webview` for the current webview.
|
|
2655
2662
|
*/
|
|
2656
2663
|
static getCurrent() {
|
|
2657
|
-
return
|
|
2664
|
+
return Ie();
|
|
2658
2665
|
}
|
|
2659
2666
|
/**
|
|
2660
2667
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
@@ -2736,8 +2743,8 @@ class _ {
|
|
|
2736
2743
|
return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
|
|
2737
2744
|
}
|
|
2738
2745
|
}
|
|
2739
|
-
|
|
2740
|
-
function
|
|
2746
|
+
ke(_, [P, T]);
|
|
2747
|
+
function ke(t, e) {
|
|
2741
2748
|
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
2742
2749
|
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
2743
2750
|
var a;
|
|
@@ -2750,16 +2757,16 @@ function Ie(t, e) {
|
|
|
2750
2757
|
});
|
|
2751
2758
|
});
|
|
2752
2759
|
}
|
|
2753
|
-
const
|
|
2760
|
+
const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
2754
2761
|
const n = i?.padding ?? 20;
|
|
2755
2762
|
if (i?.x !== void 0 && i?.y !== void 0)
|
|
2756
2763
|
return { x: i.x, y: i.y };
|
|
2757
2764
|
let a = 1920, r = 1080;
|
|
2758
2765
|
try {
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
} catch (
|
|
2762
|
-
console.warn("Failed to get monitor info, using defaults:",
|
|
2766
|
+
const u = await xe();
|
|
2767
|
+
u?.size && (a = u.size.width, r = u.size.height);
|
|
2768
|
+
} catch (u) {
|
|
2769
|
+
console.warn("Failed to get monitor info, using defaults:", u);
|
|
2763
2770
|
}
|
|
2764
2771
|
switch (i?.position ?? "right-bottom") {
|
|
2765
2772
|
case "right-bottom":
|
|
@@ -2794,18 +2801,18 @@ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
|
|
|
2794
2801
|
};
|
|
2795
2802
|
}
|
|
2796
2803
|
}, Le = async (t) => {
|
|
2797
|
-
const e = String(t.id), i =
|
|
2804
|
+
const e = String(t.id), i = d.getState();
|
|
2798
2805
|
if (i.isWindowActive(e)) {
|
|
2799
2806
|
console.log(`Notice window already open for message: ${e}`);
|
|
2800
2807
|
return;
|
|
2801
2808
|
}
|
|
2802
|
-
const n = K(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth,
|
|
2809
|
+
const n = K(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: f, y: m } = await Ce(l, u, t.windowPosition);
|
|
2803
2810
|
try {
|
|
2804
2811
|
const y = new _(a, {
|
|
2805
2812
|
url: r,
|
|
2806
2813
|
title: t.title,
|
|
2807
2814
|
width: l,
|
|
2808
|
-
height:
|
|
2815
|
+
height: u,
|
|
2809
2816
|
x: f,
|
|
2810
2817
|
y: m,
|
|
2811
2818
|
resizable: !0,
|
|
@@ -2813,59 +2820,59 @@ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
|
|
|
2813
2820
|
skipTaskbar: !1,
|
|
2814
2821
|
alwaysOnTop: !0
|
|
2815
2822
|
});
|
|
2816
|
-
|
|
2817
|
-
|
|
2823
|
+
S.set(e, y), i.addActiveWindow(e), y.once("tauri://destroyed", async () => {
|
|
2824
|
+
S.delete(e), i.removeActiveWindow(e), await ee(e), i.clearCurrent();
|
|
2818
2825
|
}), console.log(`Created notice window: ${a}`);
|
|
2819
2826
|
} catch (y) {
|
|
2820
2827
|
console.error("Failed to create notice window:", y), i.removeActiveWindow(e), i.clearCurrent();
|
|
2821
2828
|
}
|
|
2822
2829
|
}, q = async (t) => {
|
|
2823
|
-
const e = String(t), i =
|
|
2830
|
+
const e = String(t), i = S.get(e), n = d.getState();
|
|
2824
2831
|
if (i)
|
|
2825
2832
|
try {
|
|
2826
|
-
await i.close(),
|
|
2827
|
-
} catch (
|
|
2828
|
-
console.error("Failed to close notice window:",
|
|
2833
|
+
await i.close(), S.delete(e), n.removeActiveWindow(e), await ee(e), n.clearCurrent(), console.log(`Closed notice window: ${e}`);
|
|
2834
|
+
} catch (a) {
|
|
2835
|
+
console.error("Failed to close notice window:", a);
|
|
2829
2836
|
}
|
|
2830
|
-
},
|
|
2831
|
-
const t = Array.from(
|
|
2837
|
+
}, Me = async () => {
|
|
2838
|
+
const t = Array.from(S.keys()).map(
|
|
2832
2839
|
(e) => q(e)
|
|
2833
2840
|
);
|
|
2834
2841
|
await Promise.all(t);
|
|
2835
|
-
},
|
|
2842
|
+
}, Re = () => {
|
|
2836
2843
|
let t = null;
|
|
2837
|
-
|
|
2844
|
+
d.subscribe((e) => {
|
|
2838
2845
|
const i = e.currentMessage;
|
|
2839
2846
|
i && i !== t ? (t = i, Le(i)) : i || (t = null);
|
|
2840
2847
|
}), console.log("Notice window system initialized");
|
|
2841
|
-
},
|
|
2842
|
-
const t =
|
|
2848
|
+
}, He = () => {
|
|
2849
|
+
const t = d((i) => i.currentMessage);
|
|
2843
2850
|
return { closeNotice: A(async () => {
|
|
2844
2851
|
t && await q(t.id);
|
|
2845
2852
|
}, [t]) };
|
|
2846
|
-
},
|
|
2847
|
-
const t =
|
|
2853
|
+
}, Qe = () => {
|
|
2854
|
+
const t = d();
|
|
2848
2855
|
return { hideNotice: A(
|
|
2849
2856
|
async (i) => {
|
|
2850
|
-
await
|
|
2857
|
+
await fe(i), await q(i), t.currentMessage?.id === i && t.clearCurrent();
|
|
2851
2858
|
},
|
|
2852
2859
|
[t]
|
|
2853
2860
|
) };
|
|
2854
|
-
},
|
|
2855
|
-
const t =
|
|
2861
|
+
}, Ve = () => {
|
|
2862
|
+
const t = d((i) => i.clearOnLogout);
|
|
2856
2863
|
return { hideAllNotices: A(async () => {
|
|
2857
|
-
await
|
|
2864
|
+
await Me(), await t();
|
|
2858
2865
|
}, [t]) };
|
|
2859
|
-
},
|
|
2860
|
-
const t =
|
|
2866
|
+
}, je = () => {
|
|
2867
|
+
const t = d(D.queueLength), e = d(D.currentMessage), i = d(D.isProcessing), n = d(D.queue);
|
|
2861
2868
|
return {
|
|
2862
2869
|
queueLength: t,
|
|
2863
2870
|
currentMessage: e,
|
|
2864
2871
|
isProcessing: i,
|
|
2865
2872
|
queue: n
|
|
2866
2873
|
};
|
|
2867
|
-
},
|
|
2868
|
-
const [n, a] = I(null), [r, l] = I(!0), [
|
|
2874
|
+
}, $e = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2875
|
+
const [n, a] = I(null), [r, l] = I(!0), [u, f] = I(null);
|
|
2869
2876
|
return B(() => {
|
|
2870
2877
|
(async () => {
|
|
2871
2878
|
try {
|
|
@@ -2874,7 +2881,7 @@ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
|
|
|
2874
2881
|
f("No message ID provided"), l(!1);
|
|
2875
2882
|
return;
|
|
2876
2883
|
}
|
|
2877
|
-
const x = await
|
|
2884
|
+
const x = await me(F);
|
|
2878
2885
|
if (!x) {
|
|
2879
2886
|
f("Message not found"), l(!1);
|
|
2880
2887
|
return;
|
|
@@ -2898,42 +2905,43 @@ const D = /* @__PURE__ */ new Map(), ke = async (t, e, i) => {
|
|
|
2898
2905
|
alignItems: "center",
|
|
2899
2906
|
height: "100vh",
|
|
2900
2907
|
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
2901
|
-
}, children: "Loading..." }) :
|
|
2908
|
+
}, children: "Loading..." }) : u || !n ? /* @__PURE__ */ k("div", { style: {
|
|
2902
2909
|
display: "flex",
|
|
2903
2910
|
justifyContent: "center",
|
|
2904
2911
|
alignItems: "center",
|
|
2905
2912
|
height: "100vh",
|
|
2906
2913
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2907
2914
|
color: "#ef4444"
|
|
2908
|
-
}, children:
|
|
2909
|
-
},
|
|
2910
|
-
X(),
|
|
2911
|
-
const { initializeFromDatabase: t } =
|
|
2915
|
+
}, children: u || "Message not found" }) : /* @__PURE__ */ k(de, { children: t(n) });
|
|
2916
|
+
}, Je = async () => {
|
|
2917
|
+
X(), Re();
|
|
2918
|
+
const { initializeFromDatabase: t } = d.getState();
|
|
2912
2919
|
await t(), console.log("Tauri Notice System initialized");
|
|
2913
2920
|
};
|
|
2914
2921
|
export {
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2922
|
+
$e as NoticeLayout,
|
|
2923
|
+
ve as clearPendingMessages,
|
|
2924
|
+
Me as closeAllNoticeWindows,
|
|
2918
2925
|
q as closeNoticeWindow,
|
|
2919
2926
|
Le as createNoticeWindow,
|
|
2920
|
-
|
|
2927
|
+
me as getMessage,
|
|
2921
2928
|
K as getNoticeConfig,
|
|
2922
|
-
|
|
2923
|
-
|
|
2929
|
+
pe as getPendingMessages,
|
|
2930
|
+
be as hasMessage,
|
|
2924
2931
|
X as initializeDatabase,
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2932
|
+
Je as initializeNoticeSystem,
|
|
2933
|
+
Re as initializeNoticeWindowSystem,
|
|
2934
|
+
ye as isMessageShown,
|
|
2935
|
+
fe as markAsHidden,
|
|
2936
|
+
ee as markAsShown,
|
|
2937
|
+
D as messageQueueSelectors,
|
|
2938
|
+
ge as saveMessage,
|
|
2939
|
+
Ge as setNoticeConfig,
|
|
2940
|
+
He as useCloseNotice,
|
|
2941
|
+
Ve as useHideAllNotices,
|
|
2942
|
+
Qe as useHideNotice,
|
|
2943
|
+
je as useMessageQueue,
|
|
2944
|
+
d as useMessageQueueStore,
|
|
2945
|
+
Ue as useNoticeWindow
|
|
2938
2946
|
};
|
|
2939
2947
|
//# sourceMappingURL=index.js.map
|