tauri-notice-window 1.0.21 → 1.0.22
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +165 -165
- package/dist/index.js.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ const ce = "tauri-notice-config", ie = {
|
|
|
22
22
|
// Max height when auto-sizing
|
|
23
23
|
autoSizeTimeout: 3e3
|
|
24
24
|
// Fallback show timeout if measurement fails
|
|
25
|
-
},
|
|
25
|
+
}, de = () => {
|
|
26
26
|
try {
|
|
27
27
|
const t = localStorage.getItem(ce);
|
|
28
28
|
if (t)
|
|
@@ -38,10 +38,10 @@ const ce = "tauri-notice-config", ie = {
|
|
|
38
38
|
console.warn("Failed to save config to localStorage:", e);
|
|
39
39
|
}
|
|
40
40
|
}, at = (t) => {
|
|
41
|
-
const i = { ...
|
|
41
|
+
const i = { ...de(), ...t };
|
|
42
42
|
Ne(i);
|
|
43
|
-
}, B = () =>
|
|
44
|
-
class
|
|
43
|
+
}, B = () => de();
|
|
44
|
+
class xe extends We {
|
|
45
45
|
messages;
|
|
46
46
|
constructor(e) {
|
|
47
47
|
super(e), this.version(1).stores({
|
|
@@ -50,13 +50,13 @@ class De extends We {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
let k = null;
|
|
53
|
-
const
|
|
53
|
+
const we = () => {
|
|
54
54
|
if (!k) {
|
|
55
55
|
const t = B();
|
|
56
|
-
k = new
|
|
56
|
+
k = new xe(t.databaseName);
|
|
57
57
|
}
|
|
58
58
|
return k;
|
|
59
|
-
},
|
|
59
|
+
}, f = () => k || we(), De = async (t) => {
|
|
60
60
|
const e = {
|
|
61
61
|
...t,
|
|
62
62
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -65,28 +65,28 @@ const de = () => {
|
|
|
65
65
|
queueStatus: "pending",
|
|
66
66
|
queuePosition: 0
|
|
67
67
|
};
|
|
68
|
-
await
|
|
69
|
-
}, Me = async (t) => !!await
|
|
70
|
-
const e = await
|
|
68
|
+
await f().messages.put(e);
|
|
69
|
+
}, Me = async (t) => !!await f().messages.get(t), Oe = async (t) => {
|
|
70
|
+
const e = await f().messages.get(t);
|
|
71
71
|
return e?.isShown === !0 || e?.queueStatus === "shown";
|
|
72
|
-
}, Pe = async () => await
|
|
73
|
-
await
|
|
72
|
+
}, Pe = async () => await f().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), Ie = async (t, e) => {
|
|
73
|
+
await f().messages.update(t, { queueStatus: e });
|
|
74
74
|
}, ke = async (t) => {
|
|
75
|
-
await
|
|
75
|
+
await f().messages.update(t, {
|
|
76
76
|
queueStatus: "shown",
|
|
77
77
|
isShown: !0
|
|
78
78
|
});
|
|
79
79
|
}, Ce = async (t) => {
|
|
80
|
-
await
|
|
80
|
+
await f().messages.update(t, {
|
|
81
81
|
queueStatus: "hidden"
|
|
82
82
|
});
|
|
83
|
-
}, he = async (t) => await
|
|
84
|
-
await
|
|
83
|
+
}, he = async (t) => await f().messages.get(t), Le = async (t) => {
|
|
84
|
+
await f().messages.delete(t);
|
|
85
85
|
}, Re = async () => {
|
|
86
|
-
await
|
|
86
|
+
await f().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
87
87
|
}, Te = async (t) => {
|
|
88
88
|
const e = t.map(
|
|
89
|
-
(i) =>
|
|
89
|
+
(i) => f().messages.update(i.id, { queuePosition: i.position })
|
|
90
90
|
);
|
|
91
91
|
await Promise.all(e);
|
|
92
92
|
}, Ee = (t, e) => ({
|
|
@@ -103,9 +103,9 @@ const de = () => {
|
|
|
103
103
|
console.log(`Message ${i.id} was already shown, skipping`);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
if (await Me(i.id) || await
|
|
107
|
-
const
|
|
108
|
-
t({ queue:
|
|
106
|
+
if (await Me(i.id) || await De(i), !n.queue.some((b) => b.id === i.id)) {
|
|
107
|
+
const b = [...n.queue, i];
|
|
108
|
+
t({ queue: b }), await e().persistQueue();
|
|
109
109
|
}
|
|
110
110
|
!n.isProcessing && !n.currentMessage && await e().showNext();
|
|
111
111
|
},
|
|
@@ -211,7 +211,7 @@ const de = () => {
|
|
|
211
211
|
const n = e(), a = String(i);
|
|
212
212
|
return n.activeWindowIds.includes(a);
|
|
213
213
|
}
|
|
214
|
-
}),
|
|
214
|
+
}), d = ve()(
|
|
215
215
|
Se(Ee, {
|
|
216
216
|
name: "tauri-notice-queue"
|
|
217
217
|
})
|
|
@@ -221,7 +221,7 @@ const de = () => {
|
|
|
221
221
|
isProcessing: (t) => t.isProcessing,
|
|
222
222
|
queue: (t) => t.queue
|
|
223
223
|
}, rt = () => {
|
|
224
|
-
const t =
|
|
224
|
+
const t = d((i) => i.enqueue);
|
|
225
225
|
return { showNotice: q(
|
|
226
226
|
async (i) => {
|
|
227
227
|
await t(i);
|
|
@@ -238,7 +238,7 @@ function qe(t, e, i, n, a) {
|
|
|
238
238
|
return e.set(t, i), i;
|
|
239
239
|
}
|
|
240
240
|
var E;
|
|
241
|
-
const
|
|
241
|
+
const y = "__TAURI_TO_IPC_KEY__";
|
|
242
242
|
function Be(t, e = !1) {
|
|
243
243
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
244
244
|
}
|
|
@@ -283,19 +283,19 @@ class j {
|
|
|
283
283
|
* @since 2.0.0
|
|
284
284
|
*/
|
|
285
285
|
toPhysical(e) {
|
|
286
|
-
return new
|
|
286
|
+
return new S(this.width * e, this.height * e);
|
|
287
287
|
}
|
|
288
|
-
[
|
|
288
|
+
[y]() {
|
|
289
289
|
return {
|
|
290
290
|
width: this.width,
|
|
291
291
|
height: this.height
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
toJSON() {
|
|
295
|
-
return this[
|
|
295
|
+
return this[y]();
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
class
|
|
298
|
+
class S {
|
|
299
299
|
constructor(...e) {
|
|
300
300
|
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]);
|
|
301
301
|
}
|
|
@@ -313,17 +313,17 @@ class z {
|
|
|
313
313
|
toLogical(e) {
|
|
314
314
|
return new j(this.width / e, this.height / e);
|
|
315
315
|
}
|
|
316
|
-
[
|
|
316
|
+
[y]() {
|
|
317
317
|
return {
|
|
318
318
|
width: this.width,
|
|
319
319
|
height: this.height
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
322
|
toJSON() {
|
|
323
|
-
return this[
|
|
323
|
+
return this[y]();
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
class
|
|
326
|
+
class v {
|
|
327
327
|
constructor(e) {
|
|
328
328
|
this.size = e;
|
|
329
329
|
}
|
|
@@ -331,9 +331,9 @@ class W {
|
|
|
331
331
|
return this.size instanceof j ? this.size : this.size.toLogical(e);
|
|
332
332
|
}
|
|
333
333
|
toPhysical(e) {
|
|
334
|
-
return this.size instanceof
|
|
334
|
+
return this.size instanceof S ? this.size : this.size.toPhysical(e);
|
|
335
335
|
}
|
|
336
|
-
[
|
|
336
|
+
[y]() {
|
|
337
337
|
return {
|
|
338
338
|
[`${this.size.type}`]: {
|
|
339
339
|
width: this.size.width,
|
|
@@ -342,7 +342,7 @@ class W {
|
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
toJSON() {
|
|
345
|
-
return this[
|
|
345
|
+
return this[y]();
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
class J {
|
|
@@ -367,14 +367,14 @@ class J {
|
|
|
367
367
|
toPhysical(e) {
|
|
368
368
|
return new h(this.x * e, this.y * e);
|
|
369
369
|
}
|
|
370
|
-
[
|
|
370
|
+
[y]() {
|
|
371
371
|
return {
|
|
372
372
|
x: this.x,
|
|
373
373
|
y: this.y
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
376
|
toJSON() {
|
|
377
|
-
return this[
|
|
377
|
+
return this[y]();
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
class h {
|
|
@@ -399,17 +399,17 @@ class h {
|
|
|
399
399
|
toLogical(e) {
|
|
400
400
|
return new J(this.x / e, this.y / e);
|
|
401
401
|
}
|
|
402
|
-
[
|
|
402
|
+
[y]() {
|
|
403
403
|
return {
|
|
404
404
|
x: this.x,
|
|
405
405
|
y: this.y
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
toJSON() {
|
|
409
|
-
return this[
|
|
409
|
+
return this[y]();
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
class
|
|
412
|
+
class x {
|
|
413
413
|
constructor(e) {
|
|
414
414
|
this.position = e;
|
|
415
415
|
}
|
|
@@ -419,7 +419,7 @@ class D {
|
|
|
419
419
|
toPhysical(e) {
|
|
420
420
|
return this.position instanceof h ? this.position : this.position.toPhysical(e);
|
|
421
421
|
}
|
|
422
|
-
[
|
|
422
|
+
[y]() {
|
|
423
423
|
return {
|
|
424
424
|
[`${this.position.type}`]: {
|
|
425
425
|
x: this.position.x,
|
|
@@ -428,13 +428,13 @@ class D {
|
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
430
|
toJSON() {
|
|
431
|
-
return this[
|
|
431
|
+
return this[y]();
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
var
|
|
434
|
+
var c;
|
|
435
435
|
(function(t) {
|
|
436
436
|
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";
|
|
437
|
-
})(
|
|
437
|
+
})(c || (c = {}));
|
|
438
438
|
async function ge(t, e) {
|
|
439
439
|
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
|
|
440
440
|
event: t,
|
|
@@ -800,7 +800,7 @@ class U {
|
|
|
800
800
|
async innerSize() {
|
|
801
801
|
return s("plugin:window|inner_size", {
|
|
802
802
|
label: this.label
|
|
803
|
-
}).then((e) => new
|
|
803
|
+
}).then((e) => new S(e));
|
|
804
804
|
}
|
|
805
805
|
/**
|
|
806
806
|
* The physical size of the entire window.
|
|
@@ -816,7 +816,7 @@ class U {
|
|
|
816
816
|
async outerSize() {
|
|
817
817
|
return s("plugin:window|outer_size", {
|
|
818
818
|
label: this.label
|
|
819
|
-
}).then((e) => new
|
|
819
|
+
}).then((e) => new S(e));
|
|
820
820
|
}
|
|
821
821
|
/**
|
|
822
822
|
* Gets the window's current fullscreen state.
|
|
@@ -1467,7 +1467,7 @@ class U {
|
|
|
1467
1467
|
async setSize(e) {
|
|
1468
1468
|
return s("plugin:window|set_size", {
|
|
1469
1469
|
label: this.label,
|
|
1470
|
-
value: e instanceof
|
|
1470
|
+
value: e instanceof v ? e : new v(e)
|
|
1471
1471
|
});
|
|
1472
1472
|
}
|
|
1473
1473
|
/**
|
|
@@ -1484,7 +1484,7 @@ class U {
|
|
|
1484
1484
|
async setMinSize(e) {
|
|
1485
1485
|
return s("plugin:window|set_min_size", {
|
|
1486
1486
|
label: this.label,
|
|
1487
|
-
value: e instanceof
|
|
1487
|
+
value: e instanceof v ? e : e ? new v(e) : null
|
|
1488
1488
|
});
|
|
1489
1489
|
}
|
|
1490
1490
|
/**
|
|
@@ -1501,7 +1501,7 @@ class U {
|
|
|
1501
1501
|
async setMaxSize(e) {
|
|
1502
1502
|
return s("plugin:window|set_max_size", {
|
|
1503
1503
|
label: this.label,
|
|
1504
|
-
value: e instanceof
|
|
1504
|
+
value: e instanceof v ? e : e ? new v(e) : null
|
|
1505
1505
|
});
|
|
1506
1506
|
}
|
|
1507
1507
|
/**
|
|
@@ -1543,7 +1543,7 @@ class U {
|
|
|
1543
1543
|
async setPosition(e) {
|
|
1544
1544
|
return s("plugin:window|set_position", {
|
|
1545
1545
|
label: this.label,
|
|
1546
|
-
value: e instanceof
|
|
1546
|
+
value: e instanceof x ? e : new x(e)
|
|
1547
1547
|
});
|
|
1548
1548
|
}
|
|
1549
1549
|
/**
|
|
@@ -1755,7 +1755,7 @@ class U {
|
|
|
1755
1755
|
async setCursorPosition(e) {
|
|
1756
1756
|
return s("plugin:window|set_cursor_position", {
|
|
1757
1757
|
label: this.label,
|
|
1758
|
-
value: e instanceof
|
|
1758
|
+
value: e instanceof x ? e : new x(e)
|
|
1759
1759
|
});
|
|
1760
1760
|
}
|
|
1761
1761
|
/**
|
|
@@ -1961,8 +1961,8 @@ class U {
|
|
|
1961
1961
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1962
1962
|
*/
|
|
1963
1963
|
async onResized(e) {
|
|
1964
|
-
return this.listen(
|
|
1965
|
-
i.payload = new
|
|
1964
|
+
return this.listen(c.WINDOW_RESIZED, (i) => {
|
|
1965
|
+
i.payload = new S(i.payload), e(i);
|
|
1966
1966
|
});
|
|
1967
1967
|
}
|
|
1968
1968
|
/**
|
|
@@ -1983,7 +1983,7 @@ class U {
|
|
|
1983
1983
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1984
1984
|
*/
|
|
1985
1985
|
async onMoved(e) {
|
|
1986
|
-
return this.listen(
|
|
1986
|
+
return this.listen(c.WINDOW_MOVED, (i) => {
|
|
1987
1987
|
i.payload = new h(i.payload), e(i);
|
|
1988
1988
|
});
|
|
1989
1989
|
}
|
|
@@ -2010,7 +2010,7 @@ class U {
|
|
|
2010
2010
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2011
2011
|
*/
|
|
2012
2012
|
async onCloseRequested(e) {
|
|
2013
|
-
return this.listen(
|
|
2013
|
+
return this.listen(c.WINDOW_CLOSE_REQUESTED, async (i) => {
|
|
2014
2014
|
const n = new Ue(i);
|
|
2015
2015
|
await e(n), n.isPreventDefault() || await this.destroy();
|
|
2016
2016
|
});
|
|
@@ -2041,7 +2041,7 @@ class U {
|
|
|
2041
2041
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2042
2042
|
*/
|
|
2043
2043
|
async onDragDropEvent(e) {
|
|
2044
|
-
const i = await this.listen(
|
|
2044
|
+
const i = await this.listen(c.DRAG_ENTER, (r) => {
|
|
2045
2045
|
e({
|
|
2046
2046
|
...r,
|
|
2047
2047
|
payload: {
|
|
@@ -2050,7 +2050,7 @@ class U {
|
|
|
2050
2050
|
position: new h(r.payload.position)
|
|
2051
2051
|
}
|
|
2052
2052
|
});
|
|
2053
|
-
}), n = await this.listen(
|
|
2053
|
+
}), n = await this.listen(c.DRAG_OVER, (r) => {
|
|
2054
2054
|
e({
|
|
2055
2055
|
...r,
|
|
2056
2056
|
payload: {
|
|
@@ -2058,7 +2058,7 @@ class U {
|
|
|
2058
2058
|
position: new h(r.payload.position)
|
|
2059
2059
|
}
|
|
2060
2060
|
});
|
|
2061
|
-
}), a = await this.listen(
|
|
2061
|
+
}), a = await this.listen(c.DRAG_DROP, (r) => {
|
|
2062
2062
|
e({
|
|
2063
2063
|
...r,
|
|
2064
2064
|
payload: {
|
|
@@ -2067,7 +2067,7 @@ class U {
|
|
|
2067
2067
|
position: new h(r.payload.position)
|
|
2068
2068
|
}
|
|
2069
2069
|
});
|
|
2070
|
-
}), o = await this.listen(
|
|
2070
|
+
}), o = await this.listen(c.DRAG_LEAVE, (r) => {
|
|
2071
2071
|
e({ ...r, payload: { type: "leave" } });
|
|
2072
2072
|
});
|
|
2073
2073
|
return () => {
|
|
@@ -2092,9 +2092,9 @@ class U {
|
|
|
2092
2092
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2093
2093
|
*/
|
|
2094
2094
|
async onFocusChanged(e) {
|
|
2095
|
-
const i = await this.listen(
|
|
2095
|
+
const i = await this.listen(c.WINDOW_FOCUS, (a) => {
|
|
2096
2096
|
e({ ...a, payload: !0 });
|
|
2097
|
-
}), n = await this.listen(
|
|
2097
|
+
}), n = await this.listen(c.WINDOW_BLUR, (a) => {
|
|
2098
2098
|
e({ ...a, payload: !1 });
|
|
2099
2099
|
});
|
|
2100
2100
|
return () => {
|
|
@@ -2123,7 +2123,7 @@ class U {
|
|
|
2123
2123
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2124
2124
|
*/
|
|
2125
2125
|
async onScaleChanged(e) {
|
|
2126
|
-
return this.listen(
|
|
2126
|
+
return this.listen(c.WINDOW_SCALE_FACTOR_CHANGED, e);
|
|
2127
2127
|
}
|
|
2128
2128
|
/**
|
|
2129
2129
|
* Listen to the system theme change.
|
|
@@ -2143,7 +2143,7 @@ class U {
|
|
|
2143
2143
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2144
2144
|
*/
|
|
2145
2145
|
async onThemeChanged(e) {
|
|
2146
|
-
return this.listen(
|
|
2146
|
+
return this.listen(c.WINDOW_THEME_CHANGED, e);
|
|
2147
2147
|
}
|
|
2148
2148
|
}
|
|
2149
2149
|
var se;
|
|
@@ -2167,10 +2167,10 @@ function $e(t) {
|
|
|
2167
2167
|
name: t.name,
|
|
2168
2168
|
scaleFactor: t.scaleFactor,
|
|
2169
2169
|
position: new h(t.position),
|
|
2170
|
-
size: new
|
|
2170
|
+
size: new S(t.size),
|
|
2171
2171
|
workArea: {
|
|
2172
2172
|
position: new h(t.workArea.position),
|
|
2173
|
-
size: new
|
|
2173
|
+
size: new S(t.workArea.size)
|
|
2174
2174
|
}
|
|
2175
2175
|
};
|
|
2176
2176
|
}
|
|
@@ -2399,7 +2399,7 @@ class Y {
|
|
|
2399
2399
|
async size() {
|
|
2400
2400
|
return s("plugin:webview|webview_size", {
|
|
2401
2401
|
label: this.label
|
|
2402
|
-
}).then((e) => new
|
|
2402
|
+
}).then((e) => new S(e));
|
|
2403
2403
|
}
|
|
2404
2404
|
// Setters
|
|
2405
2405
|
/**
|
|
@@ -2431,7 +2431,7 @@ class Y {
|
|
|
2431
2431
|
async setSize(e) {
|
|
2432
2432
|
return s("plugin:webview|set_webview_size", {
|
|
2433
2433
|
label: this.label,
|
|
2434
|
-
value: e instanceof
|
|
2434
|
+
value: e instanceof v ? e : new v(e)
|
|
2435
2435
|
});
|
|
2436
2436
|
}
|
|
2437
2437
|
/**
|
|
@@ -2448,7 +2448,7 @@ class Y {
|
|
|
2448
2448
|
async setPosition(e) {
|
|
2449
2449
|
return s("plugin:webview|set_webview_position", {
|
|
2450
2450
|
label: this.label,
|
|
2451
|
-
value: e instanceof
|
|
2451
|
+
value: e instanceof x ? e : new x(e)
|
|
2452
2452
|
});
|
|
2453
2453
|
}
|
|
2454
2454
|
/**
|
|
@@ -2604,7 +2604,7 @@ class Y {
|
|
|
2604
2604
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2605
2605
|
*/
|
|
2606
2606
|
async onDragDropEvent(e) {
|
|
2607
|
-
const i = await this.listen(
|
|
2607
|
+
const i = await this.listen(c.DRAG_ENTER, (r) => {
|
|
2608
2608
|
e({
|
|
2609
2609
|
...r,
|
|
2610
2610
|
payload: {
|
|
@@ -2613,7 +2613,7 @@ class Y {
|
|
|
2613
2613
|
position: new h(r.payload.position)
|
|
2614
2614
|
}
|
|
2615
2615
|
});
|
|
2616
|
-
}), n = await this.listen(
|
|
2616
|
+
}), n = await this.listen(c.DRAG_OVER, (r) => {
|
|
2617
2617
|
e({
|
|
2618
2618
|
...r,
|
|
2619
2619
|
payload: {
|
|
@@ -2621,7 +2621,7 @@ class Y {
|
|
|
2621
2621
|
position: new h(r.payload.position)
|
|
2622
2622
|
}
|
|
2623
2623
|
});
|
|
2624
|
-
}), a = await this.listen(
|
|
2624
|
+
}), a = await this.listen(c.DRAG_DROP, (r) => {
|
|
2625
2625
|
e({
|
|
2626
2626
|
...r,
|
|
2627
2627
|
payload: {
|
|
@@ -2630,7 +2630,7 @@ class Y {
|
|
|
2630
2630
|
position: new h(r.payload.position)
|
|
2631
2631
|
}
|
|
2632
2632
|
});
|
|
2633
|
-
}), o = await this.listen(
|
|
2633
|
+
}), o = await this.listen(c.DRAG_LEAVE, (r) => {
|
|
2634
2634
|
e({ ...r, payload: { type: "leave" } });
|
|
2635
2635
|
});
|
|
2636
2636
|
return () => {
|
|
@@ -2638,17 +2638,17 @@ class Y {
|
|
|
2638
2638
|
};
|
|
2639
2639
|
}
|
|
2640
2640
|
}
|
|
2641
|
-
function
|
|
2641
|
+
function A() {
|
|
2642
2642
|
const t = fe();
|
|
2643
|
-
return new
|
|
2643
|
+
return new D(t.label, { skip: !0 });
|
|
2644
2644
|
}
|
|
2645
2645
|
async function ue() {
|
|
2646
|
-
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new
|
|
2646
|
+
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new D(e, {
|
|
2647
2647
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2648
2648
|
skip: !0
|
|
2649
2649
|
})));
|
|
2650
2650
|
}
|
|
2651
|
-
class
|
|
2651
|
+
class D {
|
|
2652
2652
|
/**
|
|
2653
2653
|
* Creates a new {@link Window} hosting a {@link Webview}.
|
|
2654
2654
|
* @example
|
|
@@ -2692,13 +2692,13 @@ class x {
|
|
|
2692
2692
|
static async getByLabel(e) {
|
|
2693
2693
|
var i;
|
|
2694
2694
|
const n = (i = (await ue()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
|
|
2695
|
-
return n ? new
|
|
2695
|
+
return n ? new D(n.label, { skip: !0 }) : null;
|
|
2696
2696
|
}
|
|
2697
2697
|
/**
|
|
2698
2698
|
* Get an instance of `Webview` for the current webview.
|
|
2699
2699
|
*/
|
|
2700
2700
|
static getCurrent() {
|
|
2701
|
-
return
|
|
2701
|
+
return A();
|
|
2702
2702
|
}
|
|
2703
2703
|
/**
|
|
2704
2704
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
@@ -2780,7 +2780,7 @@ class x {
|
|
|
2780
2780
|
return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
|
|
2781
2781
|
}
|
|
2782
2782
|
}
|
|
2783
|
-
Qe(
|
|
2783
|
+
Qe(D, [U, Y]);
|
|
2784
2784
|
function Qe(t, e) {
|
|
2785
2785
|
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
2786
2786
|
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
@@ -2851,7 +2851,7 @@ const L = /* @__PURE__ */ new Map(), Ve = () => navigator.platform.toLowerCase()
|
|
|
2851
2851
|
};
|
|
2852
2852
|
}
|
|
2853
2853
|
}, Ze = async (t) => {
|
|
2854
|
-
const e = String(t.id), i =
|
|
2854
|
+
const e = String(t.id), i = d.getState();
|
|
2855
2855
|
if (i.isWindowActive(e)) {
|
|
2856
2856
|
console.log(`Notice window already open for message: ${e}`);
|
|
2857
2857
|
return;
|
|
@@ -2859,46 +2859,46 @@ const L = /* @__PURE__ */ new Map(), Ve = () => navigator.platform.toLowerCase()
|
|
|
2859
2859
|
const n = B(), a = `notice-${e}`;
|
|
2860
2860
|
let o = `${n.routePrefix}/${t.type}?id=${t.id}`;
|
|
2861
2861
|
je(o) || (console.warn(`Invalid window URL: ${o}. Using fallback 404 page.`), o = n.notFoundUrl || "/404");
|
|
2862
|
-
const r = t.min_width || n.defaultWidth,
|
|
2862
|
+
const r = n.autoSize ?? !0, b = t.min_width || n.defaultWidth, W = r ? n.maxHeight ?? 800 : t.min_height || n.defaultHeight, p = t.decorations ?? n.defaultDecorations ?? !0, M = t.min_height || n.defaultHeight, { x: _, y: O } = await me(b, M, t.windowPosition);
|
|
2863
2863
|
try {
|
|
2864
|
-
const
|
|
2864
|
+
const w = {
|
|
2865
2865
|
url: o,
|
|
2866
2866
|
title: t.title,
|
|
2867
|
-
width:
|
|
2868
|
-
height:
|
|
2869
|
-
x:
|
|
2870
|
-
y:
|
|
2867
|
+
width: b,
|
|
2868
|
+
height: W,
|
|
2869
|
+
x: _,
|
|
2870
|
+
y: O,
|
|
2871
2871
|
resizable: !0,
|
|
2872
2872
|
skipTaskbar: !1,
|
|
2873
2873
|
alwaysOnTop: !0
|
|
2874
2874
|
};
|
|
2875
|
-
|
|
2876
|
-
const
|
|
2877
|
-
L.set(e,
|
|
2875
|
+
r && (w.visible = !1), p ? w.decorations = !0 : Ve() ? (w.decorations = !0, w.titleBarStyle = "overlay", w.hiddenTitle = !0) : (w.decorations = !1, w.transparent = !0);
|
|
2876
|
+
const g = new D(a, w);
|
|
2877
|
+
L.set(e, g), i.addActiveWindow(e);
|
|
2878
2878
|
let l = null;
|
|
2879
2879
|
const m = n.loadTimeout ?? 1e4;
|
|
2880
|
-
!
|
|
2880
|
+
!p && m > 0 && (l = setTimeout(async () => {
|
|
2881
2881
|
console.warn(`Notice window ${a} load timeout - auto closing`);
|
|
2882
2882
|
try {
|
|
2883
|
-
await
|
|
2883
|
+
await g.close();
|
|
2884
2884
|
} catch {
|
|
2885
2885
|
}
|
|
2886
|
-
}, m)),
|
|
2886
|
+
}, m)), g.once("tauri://created", () => {
|
|
2887
2887
|
l && (clearTimeout(l), l = null), console.log(`Notice window created successfully: ${a}`);
|
|
2888
|
-
}),
|
|
2889
|
-
if (console.error(`Notice window error: ${a}`,
|
|
2888
|
+
}), g.once("tauri://error", async (u) => {
|
|
2889
|
+
if (console.error(`Notice window error: ${a}`, u), l && (clearTimeout(l), l = null), !p)
|
|
2890
2890
|
try {
|
|
2891
|
-
await
|
|
2891
|
+
await g.close();
|
|
2892
2892
|
} catch {
|
|
2893
2893
|
}
|
|
2894
|
-
}),
|
|
2894
|
+
}), g.once("tauri://destroyed", async () => {
|
|
2895
2895
|
l && (clearTimeout(l), l = null), L.delete(e), i.removeActiveWindow(e), await i.markMessageAsShown(e), i.clearCurrent();
|
|
2896
|
-
}), console.log(`Created notice window: ${a} (autoSize: ${
|
|
2897
|
-
} catch (
|
|
2898
|
-
console.error("Failed to create notice window:",
|
|
2896
|
+
}), console.log(`Created notice window: ${a} (autoSize: ${r}, visible: ${!r})`);
|
|
2897
|
+
} catch (w) {
|
|
2898
|
+
console.error("Failed to create notice window:", w), i.removeActiveWindow(e), i.clearCurrent();
|
|
2899
2899
|
}
|
|
2900
2900
|
}, K = async (t) => {
|
|
2901
|
-
const e = String(t), i = L.get(e), n =
|
|
2901
|
+
const e = String(t), i = L.get(e), n = d.getState();
|
|
2902
2902
|
if (i)
|
|
2903
2903
|
try {
|
|
2904
2904
|
await i.close(), L.delete(e), n.removeActiveWindow(e), await n.markMessageAsShown(e), n.clearCurrent(), console.log(`Closed notice window: ${e}`);
|
|
@@ -2912,17 +2912,17 @@ const L = /* @__PURE__ */ new Map(), Ve = () => navigator.platform.toLowerCase()
|
|
|
2912
2912
|
await Promise.all(t);
|
|
2913
2913
|
}, Ke = () => {
|
|
2914
2914
|
let t = null;
|
|
2915
|
-
|
|
2915
|
+
d.subscribe((e) => {
|
|
2916
2916
|
const i = e.currentMessage;
|
|
2917
2917
|
i && i !== t ? (t = i, Ze(i)) : i || (t = null);
|
|
2918
2918
|
}), console.log("Notice window system initialized");
|
|
2919
2919
|
}, ot = () => {
|
|
2920
|
-
const t =
|
|
2920
|
+
const t = d((i) => i.currentMessage);
|
|
2921
2921
|
return { closeNotice: q(async () => {
|
|
2922
2922
|
t && await K(t.id);
|
|
2923
2923
|
}, [t]) };
|
|
2924
2924
|
}, lt = () => {
|
|
2925
|
-
const t =
|
|
2925
|
+
const t = d((i) => i.hideMessage);
|
|
2926
2926
|
return { hideNotice: q(
|
|
2927
2927
|
async (i) => {
|
|
2928
2928
|
await t(i), await K(i);
|
|
@@ -2930,124 +2930,124 @@ const L = /* @__PURE__ */ new Map(), Ve = () => navigator.platform.toLowerCase()
|
|
|
2930
2930
|
[t]
|
|
2931
2931
|
) };
|
|
2932
2932
|
}, ut = () => {
|
|
2933
|
-
const t =
|
|
2933
|
+
const t = d((i) => i.clearOnLogout);
|
|
2934
2934
|
return { hideAllNotices: q(async () => {
|
|
2935
2935
|
await Ye(), await t();
|
|
2936
2936
|
}, [t]) };
|
|
2937
2937
|
}, ct = () => {
|
|
2938
|
-
const t =
|
|
2938
|
+
const t = d(T.queueLength), e = d(T.currentMessage), i = d(T.isProcessing), n = d(T.queue);
|
|
2939
2939
|
return {
|
|
2940
2940
|
queueLength: t,
|
|
2941
2941
|
currentMessage: e,
|
|
2942
2942
|
isProcessing: i,
|
|
2943
2943
|
queue: n
|
|
2944
2944
|
};
|
|
2945
|
-
}, _e = ze({ windowReady: !0 }),
|
|
2945
|
+
}, _e = ze({ windowReady: !0 }), dt = () => Ae(_e), Xe = async (t) => {
|
|
2946
2946
|
try {
|
|
2947
|
-
const e = B(), i = e.defaultWidth || 400, n = e.maxHeight ?? 800, a = e.defaultHeight || 300, o = Math.max(a, Math.min(Math.ceil(t), n)), r =
|
|
2947
|
+
const e = B(), i = e.defaultWidth || 400, n = e.maxHeight ?? 800, a = e.defaultHeight || 300, o = Math.max(a, Math.min(Math.ceil(t), n)), r = A();
|
|
2948
2948
|
await r.setSize(new j(i, o));
|
|
2949
|
-
const { x:
|
|
2950
|
-
await r.setPosition(new J(
|
|
2949
|
+
const { x: b, y: W } = await me(i, o);
|
|
2950
|
+
await r.setPosition(new J(b, W)), await r.show(), console.log(`[NoticeLayout] Auto-sized window to ${i}x${o}`);
|
|
2951
2951
|
} catch (e) {
|
|
2952
2952
|
console.error("[NoticeLayout] Failed to auto-size, showing window as-is:", e);
|
|
2953
2953
|
try {
|
|
2954
|
-
await
|
|
2954
|
+
await A().show();
|
|
2955
2955
|
} catch {
|
|
2956
2956
|
}
|
|
2957
2957
|
}
|
|
2958
|
-
},
|
|
2959
|
-
const [n, a] = R(null), [o, r] = R(!0), [
|
|
2958
|
+
}, wt = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2959
|
+
const [n, a] = R(null), [o, r] = R(!0), [b, W] = R(null), [p, M] = R(!1), _ = te(null), O = te(!1), w = B(), g = w.autoSize ?? !0;
|
|
2960
2960
|
return P(() => {
|
|
2961
|
-
|
|
2962
|
-
}, [
|
|
2961
|
+
g || M(!0);
|
|
2962
|
+
}, [g]), P(() => {
|
|
2963
2963
|
(async () => {
|
|
2964
2964
|
try {
|
|
2965
|
-
const
|
|
2966
|
-
if (!
|
|
2967
|
-
|
|
2965
|
+
const u = new URLSearchParams(window.location.search).get("id");
|
|
2966
|
+
if (!u) {
|
|
2967
|
+
W("No message ID provided"), r(!1), setTimeout(async () => {
|
|
2968
2968
|
try {
|
|
2969
|
-
await
|
|
2970
|
-
} catch (
|
|
2971
|
-
console.error("Failed to close window:",
|
|
2969
|
+
await A().close();
|
|
2970
|
+
} catch (z) {
|
|
2971
|
+
console.error("Failed to close window:", z);
|
|
2972
2972
|
}
|
|
2973
2973
|
}, 1e3);
|
|
2974
2974
|
return;
|
|
2975
2975
|
}
|
|
2976
|
-
const
|
|
2977
|
-
if (!
|
|
2978
|
-
console.log(`Message ${
|
|
2976
|
+
const N = await he(u);
|
|
2977
|
+
if (!N) {
|
|
2978
|
+
console.log(`Message ${u} not found in database, closing window`), W("Message not found"), r(!1), setTimeout(async () => {
|
|
2979
2979
|
try {
|
|
2980
|
-
await
|
|
2981
|
-
} catch (
|
|
2982
|
-
console.error("Failed to close window:",
|
|
2980
|
+
await A().close();
|
|
2981
|
+
} catch (z) {
|
|
2982
|
+
console.error("Failed to close window:", z);
|
|
2983
2983
|
}
|
|
2984
2984
|
}, 500);
|
|
2985
2985
|
return;
|
|
2986
2986
|
}
|
|
2987
|
-
a(
|
|
2988
|
-
} catch (
|
|
2989
|
-
console.error("Failed to load message:",
|
|
2987
|
+
a(N), r(!1), e && e(N);
|
|
2988
|
+
} catch (m) {
|
|
2989
|
+
console.error("Failed to load message:", m), W("Failed to load message"), r(!1), setTimeout(async () => {
|
|
2990
2990
|
try {
|
|
2991
|
-
await
|
|
2992
|
-
} catch (
|
|
2993
|
-
console.error("Failed to close window:",
|
|
2991
|
+
await A().close();
|
|
2992
|
+
} catch (u) {
|
|
2993
|
+
console.error("Failed to close window:", u);
|
|
2994
2994
|
}
|
|
2995
2995
|
}, 1e3);
|
|
2996
2996
|
}
|
|
2997
2997
|
})();
|
|
2998
2998
|
}, [e]), P(() => {
|
|
2999
|
-
if (!
|
|
3000
|
-
const
|
|
3001
|
-
const
|
|
3002
|
-
if (!
|
|
3003
|
-
|
|
3004
|
-
const
|
|
3005
|
-
|
|
3006
|
-
const X =
|
|
3007
|
-
console.log(`[NoticeLayout] Measured natural content height: ${ee}px (rect=${X.height}, scroll=${
|
|
2999
|
+
if (!g || !n || p || O.current) return;
|
|
3000
|
+
const l = requestAnimationFrame(() => {
|
|
3001
|
+
const m = requestAnimationFrame(() => {
|
|
3002
|
+
if (!_.current || O.current) return;
|
|
3003
|
+
O.current = !0;
|
|
3004
|
+
const u = document.body, N = u.style.height, z = u.style.overflow;
|
|
3005
|
+
u.style.height = "auto", u.style.overflow = "visible", _.current.offsetHeight;
|
|
3006
|
+
const X = _.current.getBoundingClientRect(), ee = Math.max(X.height, _.current.scrollHeight);
|
|
3007
|
+
console.log(`[NoticeLayout] Measured natural content height: ${ee}px (rect=${X.height}, scroll=${_.current.scrollHeight})`), u.style.height = N, u.style.overflow = z, Xe(ee).then(() => {
|
|
3008
3008
|
M(!0);
|
|
3009
3009
|
});
|
|
3010
3010
|
});
|
|
3011
|
-
return () => cancelAnimationFrame(
|
|
3011
|
+
return () => cancelAnimationFrame(m);
|
|
3012
3012
|
});
|
|
3013
|
-
return () => cancelAnimationFrame(
|
|
3014
|
-
}, [
|
|
3015
|
-
if (!
|
|
3016
|
-
const
|
|
3017
|
-
if (!
|
|
3013
|
+
return () => cancelAnimationFrame(l);
|
|
3014
|
+
}, [g, n, p]), P(() => {
|
|
3015
|
+
if (!g || p) return;
|
|
3016
|
+
const l = w.autoSizeTimeout ?? 3e3, m = setTimeout(async () => {
|
|
3017
|
+
if (!p) {
|
|
3018
3018
|
console.warn("[NoticeLayout] Auto-size timeout reached, showing window as-is");
|
|
3019
3019
|
try {
|
|
3020
|
-
await
|
|
3020
|
+
await A().show();
|
|
3021
3021
|
} catch {
|
|
3022
3022
|
}
|
|
3023
3023
|
M(!0);
|
|
3024
3024
|
}
|
|
3025
|
-
},
|
|
3026
|
-
return () => clearTimeout(
|
|
3027
|
-
}, [
|
|
3025
|
+
}, l);
|
|
3026
|
+
return () => clearTimeout(m);
|
|
3027
|
+
}, [g, p, w.autoSizeTimeout]), P(() => {
|
|
3028
3028
|
if (!n || !i) return;
|
|
3029
|
-
const
|
|
3029
|
+
const l = () => {
|
|
3030
3030
|
i(n);
|
|
3031
3031
|
};
|
|
3032
|
-
return window.addEventListener("beforeunload",
|
|
3032
|
+
return window.addEventListener("beforeunload", l), () => window.removeEventListener("beforeunload", l);
|
|
3033
3033
|
}, [n, i]), o ? /* @__PURE__ */ I("div", { style: {
|
|
3034
3034
|
display: "flex",
|
|
3035
3035
|
justifyContent: "center",
|
|
3036
3036
|
alignItems: "center",
|
|
3037
3037
|
height: "100vh",
|
|
3038
3038
|
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
3039
|
-
}, children: "Loading..." }) :
|
|
3039
|
+
}, children: "Loading..." }) : b ? /* @__PURE__ */ I("div", { style: {
|
|
3040
3040
|
display: "flex",
|
|
3041
3041
|
justifyContent: "center",
|
|
3042
3042
|
alignItems: "center",
|
|
3043
3043
|
height: "100vh",
|
|
3044
3044
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
3045
3045
|
color: "#ef4444"
|
|
3046
|
-
}, children:
|
|
3046
|
+
}, children: b }) : n ? /* @__PURE__ */ I(_e.Provider, { value: { windowReady: p }, children: /* @__PURE__ */ I(
|
|
3047
3047
|
"div",
|
|
3048
3048
|
{
|
|
3049
|
-
ref:
|
|
3050
|
-
style:
|
|
3049
|
+
ref: _,
|
|
3050
|
+
style: p ? { height: "100vh" } : void 0,
|
|
3051
3051
|
children: t(n)
|
|
3052
3052
|
}
|
|
3053
3053
|
) }) : /* @__PURE__ */ I("div", { style: {
|
|
@@ -3059,18 +3059,18 @@ const L = /* @__PURE__ */ new Map(), Ve = () => navigator.platform.toLowerCase()
|
|
|
3059
3059
|
color: "#ef4444"
|
|
3060
3060
|
}, children: "Closing window..." });
|
|
3061
3061
|
}, ht = async () => {
|
|
3062
|
-
|
|
3063
|
-
const { initializeFromDatabase: t } =
|
|
3062
|
+
we(), Ke();
|
|
3063
|
+
const { initializeFromDatabase: t } = d.getState();
|
|
3064
3064
|
await t(), console.log("Tauri Notice System initialized");
|
|
3065
3065
|
}, gt = async (t) => {
|
|
3066
|
-
await
|
|
3066
|
+
await d.getState().deleteMessage(t);
|
|
3067
3067
|
}, yt = async (t) => {
|
|
3068
|
-
await
|
|
3068
|
+
await d.getState().hideMessage(t);
|
|
3069
3069
|
}, bt = async (t) => {
|
|
3070
|
-
await
|
|
3070
|
+
await d.getState().markMessageAsShown(t);
|
|
3071
3071
|
};
|
|
3072
3072
|
export {
|
|
3073
|
-
|
|
3073
|
+
wt as NoticeLayout,
|
|
3074
3074
|
me as calculateWindowPosition,
|
|
3075
3075
|
Ye as closeAllNoticeWindows,
|
|
3076
3076
|
K as closeNoticeWindow,
|
|
@@ -3081,7 +3081,7 @@ export {
|
|
|
3081
3081
|
B as getNoticeConfig,
|
|
3082
3082
|
Pe as getPendingMessages,
|
|
3083
3083
|
yt as hideMessageById,
|
|
3084
|
-
|
|
3084
|
+
we as initializeDatabase,
|
|
3085
3085
|
ht as initializeNoticeSystem,
|
|
3086
3086
|
Ke as initializeNoticeWindowSystem,
|
|
3087
3087
|
bt as markMessageAsShown,
|
|
@@ -3091,8 +3091,8 @@ export {
|
|
|
3091
3091
|
ut as useHideAllNotices,
|
|
3092
3092
|
lt as useHideNotice,
|
|
3093
3093
|
ct as useMessageQueue,
|
|
3094
|
-
|
|
3094
|
+
d as useMessageQueueStore,
|
|
3095
3095
|
rt as useNoticeWindow,
|
|
3096
|
-
|
|
3096
|
+
dt as useNoticeWindowContext
|
|
3097
3097
|
};
|
|
3098
3098
|
//# sourceMappingURL=index.js.map
|