tauri-notice-window 1.0.11 → 1.0.13
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 +27 -2
- package/dist/config/noticeConfig.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +85 -77
- package/dist/index.js.map +1 -1
- package/dist/types/message.d.ts +4 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,8 +8,10 @@ const K = "tauri-notice-config", Q = {
|
|
|
8
8
|
databaseName: "tauri-notice-db",
|
|
9
9
|
defaultWidth: 400,
|
|
10
10
|
defaultHeight: 300,
|
|
11
|
-
notFoundUrl: "/404"
|
|
11
|
+
notFoundUrl: "/404",
|
|
12
12
|
// Default 404 page
|
|
13
|
+
defaultDecorations: !0
|
|
14
|
+
// Show title bar by default
|
|
13
15
|
}, X = () => {
|
|
14
16
|
try {
|
|
15
17
|
const t = localStorage.getItem(K);
|
|
@@ -37,14 +39,14 @@ class ye extends de {
|
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
let
|
|
42
|
+
let W = null;
|
|
41
43
|
const te = () => {
|
|
42
|
-
if (!
|
|
44
|
+
if (!W) {
|
|
43
45
|
const t = ee();
|
|
44
|
-
|
|
46
|
+
W = new ye(t.databaseName);
|
|
45
47
|
}
|
|
46
|
-
return
|
|
47
|
-
},
|
|
48
|
+
return W;
|
|
49
|
+
}, g = () => W || te(), be = async (t) => {
|
|
48
50
|
const e = {
|
|
49
51
|
...t,
|
|
50
52
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -53,28 +55,28 @@ const te = () => {
|
|
|
53
55
|
queueStatus: "pending",
|
|
54
56
|
queuePosition: 0
|
|
55
57
|
};
|
|
56
|
-
await
|
|
57
|
-
}, pe = async (t) => !!await
|
|
58
|
-
const e = await
|
|
58
|
+
await g().messages.put(e);
|
|
59
|
+
}, pe = async (t) => !!await g().messages.get(t), _e = async (t) => {
|
|
60
|
+
const e = await g().messages.get(t);
|
|
59
61
|
return e?.isShown === !0 || e?.queueStatus === "shown";
|
|
60
|
-
}, fe = async () => await
|
|
61
|
-
await
|
|
62
|
+
}, fe = async () => await g().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), me = async (t, e) => {
|
|
63
|
+
await g().messages.update(t, { queueStatus: e });
|
|
62
64
|
}, ve = async (t) => {
|
|
63
|
-
await
|
|
65
|
+
await g().messages.update(t, {
|
|
64
66
|
queueStatus: "shown",
|
|
65
67
|
isShown: !0
|
|
66
68
|
});
|
|
67
69
|
}, We = async (t) => {
|
|
68
|
-
await
|
|
70
|
+
await g().messages.update(t, {
|
|
69
71
|
queueStatus: "hidden"
|
|
70
72
|
});
|
|
71
|
-
}, ie = async (t) => await
|
|
72
|
-
await
|
|
73
|
-
},
|
|
74
|
-
await
|
|
75
|
-
},
|
|
73
|
+
}, ie = async (t) => await g().messages.get(t), Se = async (t) => {
|
|
74
|
+
await g().messages.delete(t);
|
|
75
|
+
}, De = async () => {
|
|
76
|
+
await g().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
77
|
+
}, Ae = async (t) => {
|
|
76
78
|
const e = t.map(
|
|
77
|
-
(i) =>
|
|
79
|
+
(i) => g().messages.update(i.id, { queuePosition: i.position })
|
|
78
80
|
);
|
|
79
81
|
await Promise.all(e);
|
|
80
82
|
}, Ne = (t, e) => ({
|
|
@@ -153,7 +155,7 @@ const te = () => {
|
|
|
153
155
|
id: a.id,
|
|
154
156
|
position: l
|
|
155
157
|
}));
|
|
156
|
-
await
|
|
158
|
+
await Ae(n);
|
|
157
159
|
},
|
|
158
160
|
// Clear all messages on logout
|
|
159
161
|
clearOnLogout: async () => {
|
|
@@ -163,7 +165,7 @@ const te = () => {
|
|
|
163
165
|
isProcessing: !1,
|
|
164
166
|
activeWindowIds: [],
|
|
165
167
|
initialized: !1
|
|
166
|
-
}), await
|
|
168
|
+
}), await De();
|
|
167
169
|
},
|
|
168
170
|
// Remove a specific message from the queue by ID (memory only)
|
|
169
171
|
removeFromQueue: async (i) => {
|
|
@@ -226,7 +228,7 @@ function Me(t, e, i, n, a) {
|
|
|
226
228
|
return e.set(t, i), i;
|
|
227
229
|
}
|
|
228
230
|
var M;
|
|
229
|
-
const
|
|
231
|
+
const h = "__TAURI_TO_IPC_KEY__";
|
|
230
232
|
function Oe(t, e = !1) {
|
|
231
233
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
232
234
|
}
|
|
@@ -271,19 +273,19 @@ class ne {
|
|
|
271
273
|
* @since 2.0.0
|
|
272
274
|
*/
|
|
273
275
|
toPhysical(e) {
|
|
274
|
-
return new
|
|
276
|
+
return new p(this.width * e, this.height * e);
|
|
275
277
|
}
|
|
276
|
-
[
|
|
278
|
+
[h]() {
|
|
277
279
|
return {
|
|
278
280
|
width: this.width,
|
|
279
281
|
height: this.height
|
|
280
282
|
};
|
|
281
283
|
}
|
|
282
284
|
toJSON() {
|
|
283
|
-
return this[
|
|
285
|
+
return this[h]();
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
|
-
class
|
|
288
|
+
class p {
|
|
287
289
|
constructor(...e) {
|
|
288
290
|
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]);
|
|
289
291
|
}
|
|
@@ -301,17 +303,17 @@ class y {
|
|
|
301
303
|
toLogical(e) {
|
|
302
304
|
return new ne(this.width / e, this.height / e);
|
|
303
305
|
}
|
|
304
|
-
[
|
|
306
|
+
[h]() {
|
|
305
307
|
return {
|
|
306
308
|
width: this.width,
|
|
307
309
|
height: this.height
|
|
308
310
|
};
|
|
309
311
|
}
|
|
310
312
|
toJSON() {
|
|
311
|
-
return this[
|
|
313
|
+
return this[h]();
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
|
-
class
|
|
316
|
+
class b {
|
|
315
317
|
constructor(e) {
|
|
316
318
|
this.size = e;
|
|
317
319
|
}
|
|
@@ -319,9 +321,9 @@ class g {
|
|
|
319
321
|
return this.size instanceof ne ? this.size : this.size.toLogical(e);
|
|
320
322
|
}
|
|
321
323
|
toPhysical(e) {
|
|
322
|
-
return this.size instanceof
|
|
324
|
+
return this.size instanceof p ? this.size : this.size.toPhysical(e);
|
|
323
325
|
}
|
|
324
|
-
[
|
|
326
|
+
[h]() {
|
|
325
327
|
return {
|
|
326
328
|
[`${this.size.type}`]: {
|
|
327
329
|
width: this.size.width,
|
|
@@ -330,7 +332,7 @@ class g {
|
|
|
330
332
|
};
|
|
331
333
|
}
|
|
332
334
|
toJSON() {
|
|
333
|
-
return this[
|
|
335
|
+
return this[h]();
|
|
334
336
|
}
|
|
335
337
|
}
|
|
336
338
|
class se {
|
|
@@ -355,14 +357,14 @@ class se {
|
|
|
355
357
|
toPhysical(e) {
|
|
356
358
|
return new w(this.x * e, this.y * e);
|
|
357
359
|
}
|
|
358
|
-
[
|
|
360
|
+
[h]() {
|
|
359
361
|
return {
|
|
360
362
|
x: this.x,
|
|
361
363
|
y: this.y
|
|
362
364
|
};
|
|
363
365
|
}
|
|
364
366
|
toJSON() {
|
|
365
|
-
return this[
|
|
367
|
+
return this[h]();
|
|
366
368
|
}
|
|
367
369
|
}
|
|
368
370
|
class w {
|
|
@@ -387,14 +389,14 @@ class w {
|
|
|
387
389
|
toLogical(e) {
|
|
388
390
|
return new se(this.x / e, this.y / e);
|
|
389
391
|
}
|
|
390
|
-
[
|
|
392
|
+
[h]() {
|
|
391
393
|
return {
|
|
392
394
|
x: this.x,
|
|
393
395
|
y: this.y
|
|
394
396
|
};
|
|
395
397
|
}
|
|
396
398
|
toJSON() {
|
|
397
|
-
return this[
|
|
399
|
+
return this[h]();
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
402
|
class _ {
|
|
@@ -407,7 +409,7 @@ class _ {
|
|
|
407
409
|
toPhysical(e) {
|
|
408
410
|
return this.position instanceof w ? this.position : this.position.toPhysical(e);
|
|
409
411
|
}
|
|
410
|
-
[
|
|
412
|
+
[h]() {
|
|
411
413
|
return {
|
|
412
414
|
[`${this.position.type}`]: {
|
|
413
415
|
x: this.position.x,
|
|
@@ -416,7 +418,7 @@ class _ {
|
|
|
416
418
|
};
|
|
417
419
|
}
|
|
418
420
|
toJSON() {
|
|
419
|
-
return this[
|
|
421
|
+
return this[h]();
|
|
420
422
|
}
|
|
421
423
|
}
|
|
422
424
|
var o;
|
|
@@ -456,7 +458,7 @@ async function le(t, e, i) {
|
|
|
456
458
|
payload: i
|
|
457
459
|
});
|
|
458
460
|
}
|
|
459
|
-
class
|
|
461
|
+
class S extends xe {
|
|
460
462
|
/**
|
|
461
463
|
* Creates an Image from a resource ID. For internal use only.
|
|
462
464
|
*
|
|
@@ -471,7 +473,7 @@ class A extends xe {
|
|
|
471
473
|
rgba: x(e),
|
|
472
474
|
width: i,
|
|
473
475
|
height: n
|
|
474
|
-
}).then((a) => new
|
|
476
|
+
}).then((a) => new S(a));
|
|
475
477
|
}
|
|
476
478
|
/**
|
|
477
479
|
* Creates a new image using the provided bytes by inferring the file format.
|
|
@@ -489,7 +491,7 @@ class A extends xe {
|
|
|
489
491
|
static async fromBytes(e) {
|
|
490
492
|
return s("plugin:image|from_bytes", {
|
|
491
493
|
bytes: x(e)
|
|
492
|
-
}).then((i) => new
|
|
494
|
+
}).then((i) => new S(i));
|
|
493
495
|
}
|
|
494
496
|
/**
|
|
495
497
|
* Creates a new image using the provided path.
|
|
@@ -504,7 +506,7 @@ class A extends xe {
|
|
|
504
506
|
* ```
|
|
505
507
|
*/
|
|
506
508
|
static async fromPath(e) {
|
|
507
|
-
return s("plugin:image|from_path", { path: e }).then((i) => new
|
|
509
|
+
return s("plugin:image|from_path", { path: e }).then((i) => new S(i));
|
|
508
510
|
}
|
|
509
511
|
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
|
510
512
|
async rgba() {
|
|
@@ -518,7 +520,7 @@ class A extends xe {
|
|
|
518
520
|
}
|
|
519
521
|
}
|
|
520
522
|
function x(t) {
|
|
521
|
-
return t == null ? null : typeof t == "string" ? t : t instanceof
|
|
523
|
+
return t == null ? null : typeof t == "string" ? t : t instanceof S ? t.rid : t;
|
|
522
524
|
}
|
|
523
525
|
var q;
|
|
524
526
|
(function(t) {
|
|
@@ -788,7 +790,7 @@ class k {
|
|
|
788
790
|
async innerSize() {
|
|
789
791
|
return s("plugin:window|inner_size", {
|
|
790
792
|
label: this.label
|
|
791
|
-
}).then((e) => new
|
|
793
|
+
}).then((e) => new p(e));
|
|
792
794
|
}
|
|
793
795
|
/**
|
|
794
796
|
* The physical size of the entire window.
|
|
@@ -804,7 +806,7 @@ class k {
|
|
|
804
806
|
async outerSize() {
|
|
805
807
|
return s("plugin:window|outer_size", {
|
|
806
808
|
label: this.label
|
|
807
|
-
}).then((e) => new
|
|
809
|
+
}).then((e) => new p(e));
|
|
808
810
|
}
|
|
809
811
|
/**
|
|
810
812
|
* Gets the window's current fullscreen state.
|
|
@@ -1455,7 +1457,7 @@ class k {
|
|
|
1455
1457
|
async setSize(e) {
|
|
1456
1458
|
return s("plugin:window|set_size", {
|
|
1457
1459
|
label: this.label,
|
|
1458
|
-
value: e instanceof
|
|
1460
|
+
value: e instanceof b ? e : new b(e)
|
|
1459
1461
|
});
|
|
1460
1462
|
}
|
|
1461
1463
|
/**
|
|
@@ -1472,7 +1474,7 @@ class k {
|
|
|
1472
1474
|
async setMinSize(e) {
|
|
1473
1475
|
return s("plugin:window|set_min_size", {
|
|
1474
1476
|
label: this.label,
|
|
1475
|
-
value: e instanceof
|
|
1477
|
+
value: e instanceof b ? e : e ? new b(e) : null
|
|
1476
1478
|
});
|
|
1477
1479
|
}
|
|
1478
1480
|
/**
|
|
@@ -1489,7 +1491,7 @@ class k {
|
|
|
1489
1491
|
async setMaxSize(e) {
|
|
1490
1492
|
return s("plugin:window|set_max_size", {
|
|
1491
1493
|
label: this.label,
|
|
1492
|
-
value: e instanceof
|
|
1494
|
+
value: e instanceof b ? e : e ? new b(e) : null
|
|
1493
1495
|
});
|
|
1494
1496
|
}
|
|
1495
1497
|
/**
|
|
@@ -1950,7 +1952,7 @@ class k {
|
|
|
1950
1952
|
*/
|
|
1951
1953
|
async onResized(e) {
|
|
1952
1954
|
return this.listen(o.WINDOW_RESIZED, (i) => {
|
|
1953
|
-
i.payload = new
|
|
1955
|
+
i.payload = new p(i.payload), e(i);
|
|
1954
1956
|
});
|
|
1955
1957
|
}
|
|
1956
1958
|
/**
|
|
@@ -2155,10 +2157,10 @@ function Ie(t) {
|
|
|
2155
2157
|
name: t.name,
|
|
2156
2158
|
scaleFactor: t.scaleFactor,
|
|
2157
2159
|
position: new w(t.position),
|
|
2158
|
-
size: new
|
|
2160
|
+
size: new p(t.size),
|
|
2159
2161
|
workArea: {
|
|
2160
2162
|
position: new w(t.workArea.position),
|
|
2161
|
-
size: new
|
|
2163
|
+
size: new p(t.workArea.size)
|
|
2162
2164
|
}
|
|
2163
2165
|
};
|
|
2164
2166
|
}
|
|
@@ -2387,7 +2389,7 @@ class B {
|
|
|
2387
2389
|
async size() {
|
|
2388
2390
|
return s("plugin:webview|webview_size", {
|
|
2389
2391
|
label: this.label
|
|
2390
|
-
}).then((e) => new
|
|
2392
|
+
}).then((e) => new p(e));
|
|
2391
2393
|
}
|
|
2392
2394
|
// Setters
|
|
2393
2395
|
/**
|
|
@@ -2419,7 +2421,7 @@ class B {
|
|
|
2419
2421
|
async setSize(e) {
|
|
2420
2422
|
return s("plugin:webview|set_webview_size", {
|
|
2421
2423
|
label: this.label,
|
|
2422
|
-
value: e instanceof
|
|
2424
|
+
value: e instanceof b ? e : new b(e)
|
|
2423
2425
|
});
|
|
2424
2426
|
}
|
|
2425
2427
|
/**
|
|
@@ -2841,25 +2843,31 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2841
2843
|
const n = ee(), a = `notice-${e}`;
|
|
2842
2844
|
let l = `${n.routePrefix}/${t.type}?id=${t.id}`;
|
|
2843
2845
|
Le(l) || (console.warn(`Invalid window URL: ${l}. Using fallback 404 page.`), l = n.notFoundUrl || "/404");
|
|
2844
|
-
const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: m, y:
|
|
2846
|
+
const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, y = t.decorations ?? n.defaultDecorations ?? !0, { x: m, y: A } = await Ee(r, u, t.windowPosition);
|
|
2845
2847
|
try {
|
|
2846
|
-
const
|
|
2848
|
+
const d = new f(a, {
|
|
2847
2849
|
url: l,
|
|
2848
2850
|
title: t.title,
|
|
2849
2851
|
width: r,
|
|
2850
2852
|
height: u,
|
|
2851
2853
|
x: m,
|
|
2852
|
-
y:
|
|
2854
|
+
y: A,
|
|
2853
2855
|
resizable: !0,
|
|
2854
|
-
decorations:
|
|
2856
|
+
decorations: y,
|
|
2857
|
+
transparent: !y,
|
|
2858
|
+
// Enable transparency for borderless windows (macOS fix)
|
|
2859
|
+
visible: y,
|
|
2860
|
+
// Start hidden if no decorations (macOS fix)
|
|
2855
2861
|
skipTaskbar: !1,
|
|
2856
2862
|
alwaysOnTop: !0
|
|
2857
2863
|
});
|
|
2858
|
-
D.set(e,
|
|
2864
|
+
D.set(e, d), i.addActiveWindow(e), y || d.once("tauri://created", async () => {
|
|
2865
|
+
await d.show();
|
|
2866
|
+
}), d.once("tauri://destroyed", async () => {
|
|
2859
2867
|
D.delete(e), i.removeActiveWindow(e), await i.markMessageAsShown(e), i.clearCurrent();
|
|
2860
2868
|
}), console.log(`Created notice window: ${a}`);
|
|
2861
|
-
} catch (
|
|
2862
|
-
console.error("Failed to create notice window:",
|
|
2869
|
+
} catch (d) {
|
|
2870
|
+
console.error("Failed to create notice window:", d), i.removeActiveWindow(e), i.clearCurrent();
|
|
2863
2871
|
}
|
|
2864
2872
|
}, U = async (t) => {
|
|
2865
2873
|
const e = String(t), i = D.get(e), n = c.getState();
|
|
@@ -2907,50 +2915,50 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2907
2915
|
queue: n
|
|
2908
2916
|
};
|
|
2909
2917
|
}, Ye = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2910
|
-
const [n, a] = L(null), [l, r] = L(!0), [u,
|
|
2918
|
+
const [n, a] = L(null), [l, r] = L(!0), [u, y] = L(null);
|
|
2911
2919
|
return G(() => {
|
|
2912
2920
|
(async () => {
|
|
2913
2921
|
try {
|
|
2914
|
-
const
|
|
2915
|
-
if (!
|
|
2916
|
-
|
|
2922
|
+
const d = new URLSearchParams(window.location.search).get("id");
|
|
2923
|
+
if (!d) {
|
|
2924
|
+
y("No message ID provided"), r(!1), setTimeout(async () => {
|
|
2917
2925
|
try {
|
|
2918
2926
|
await O().close();
|
|
2919
|
-
} catch (
|
|
2920
|
-
console.error("Failed to close window:",
|
|
2927
|
+
} catch (v) {
|
|
2928
|
+
console.error("Failed to close window:", v);
|
|
2921
2929
|
}
|
|
2922
2930
|
}, 1e3);
|
|
2923
2931
|
return;
|
|
2924
2932
|
}
|
|
2925
|
-
const C = await ie(
|
|
2933
|
+
const C = await ie(d);
|
|
2926
2934
|
if (!C) {
|
|
2927
|
-
console.log(`Message ${
|
|
2935
|
+
console.log(`Message ${d} not found in database, closing window`), y("Message not found"), r(!1), setTimeout(async () => {
|
|
2928
2936
|
try {
|
|
2929
2937
|
await O().close();
|
|
2930
|
-
} catch (
|
|
2931
|
-
console.error("Failed to close window:",
|
|
2938
|
+
} catch (v) {
|
|
2939
|
+
console.error("Failed to close window:", v);
|
|
2932
2940
|
}
|
|
2933
2941
|
}, 500);
|
|
2934
2942
|
return;
|
|
2935
2943
|
}
|
|
2936
2944
|
a(C), r(!1), e && e(C);
|
|
2937
|
-
} catch (
|
|
2938
|
-
console.error("Failed to load message:",
|
|
2945
|
+
} catch (A) {
|
|
2946
|
+
console.error("Failed to load message:", A), y("Failed to load message"), r(!1), setTimeout(async () => {
|
|
2939
2947
|
try {
|
|
2940
2948
|
await O().close();
|
|
2941
|
-
} catch (
|
|
2942
|
-
console.error("Failed to close window:",
|
|
2949
|
+
} catch (d) {
|
|
2950
|
+
console.error("Failed to close window:", d);
|
|
2943
2951
|
}
|
|
2944
2952
|
}, 1e3);
|
|
2945
2953
|
}
|
|
2946
2954
|
})();
|
|
2947
2955
|
}, [e]), G(() => {
|
|
2948
2956
|
if (!n || !i) return;
|
|
2949
|
-
const
|
|
2957
|
+
const m = () => {
|
|
2950
2958
|
i(n);
|
|
2951
2959
|
};
|
|
2952
|
-
return window.addEventListener("beforeunload",
|
|
2953
|
-
window.removeEventListener("beforeunload",
|
|
2960
|
+
return window.addEventListener("beforeunload", m), () => {
|
|
2961
|
+
window.removeEventListener("beforeunload", m);
|
|
2954
2962
|
};
|
|
2955
2963
|
}, [n, i]), l ? /* @__PURE__ */ N("div", { style: {
|
|
2956
2964
|
display: "flex",
|