tauri-notice-window 1.0.5 → 1.0.7
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 +109 -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 +47 -44
- package/dist/index.js.map +1 -1
- package/dist/utils/db.d.ts +5 -0
- package/dist/utils/db.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export { NoticeLayout } from './components/NoticeLayout';
|
|
|
14
14
|
export { setNoticeConfig, getNoticeConfig } from './config/noticeConfig';
|
|
15
15
|
import { initializeNoticeWindowSystem, createNoticeWindow, closeNoticeWindow, closeAllNoticeWindows } from './utils/noticeWindow';
|
|
16
16
|
export { initializeNoticeWindowSystem, createNoticeWindow, closeNoticeWindow, closeAllNoticeWindows, };
|
|
17
|
-
import { initializeDatabase, saveMessage, hasMessage, isMessageShown, getPendingMessages, getMessage, markAsShown, markAsHidden, clearPendingMessages } from './utils/db';
|
|
18
|
-
export { initializeDatabase, saveMessage, hasMessage, isMessageShown, getPendingMessages, getMessage, markAsShown, markAsHidden, clearPendingMessages, };
|
|
17
|
+
import { initializeDatabase, saveMessage, hasMessage, isMessageShown, getPendingMessages, getMessage, deleteMessageById, markAsShown, markAsHidden, clearPendingMessages } from './utils/db';
|
|
18
|
+
export { initializeDatabase, saveMessage, hasMessage, isMessageShown, getPendingMessages, getMessage, deleteMessageById, markAsShown, markAsHidden, clearPendingMessages, };
|
|
19
19
|
/**
|
|
20
20
|
* Initialize the complete notice window system
|
|
21
21
|
* Call this once during app startup (e.g., in App.tsx or main layout)
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EA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a,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAG/F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACxF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAA;AAGtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGxE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,CAAA;AAED,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,oBAAoB,EACrB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,IAAI,CAY3D,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create as oe } from "zustand";
|
|
2
2
|
import { syncTabs as ue } from "zustand-sync";
|
|
3
3
|
import ce from "dexie";
|
|
4
|
-
import { useCallback as A, useState as
|
|
4
|
+
import { useCallback as A, useState as x, useEffect as B } from "react";
|
|
5
5
|
import { jsx as k, Fragment as de } from "react/jsx-runtime";
|
|
6
6
|
const Z = "tauri-notice-config", G = {
|
|
7
7
|
routePrefix: "/notice",
|
|
@@ -66,7 +66,9 @@ const X = () => {
|
|
|
66
66
|
await h().messages.update(t, {
|
|
67
67
|
queueStatus: "hidden"
|
|
68
68
|
});
|
|
69
|
-
}, me = async (t) => await h().messages.get(t),
|
|
69
|
+
}, me = async (t) => await h().messages.get(t), Ue = async (t) => {
|
|
70
|
+
await h().messages.delete(t);
|
|
71
|
+
}, ve = async () => {
|
|
70
72
|
await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
71
73
|
}, We = async (t) => {
|
|
72
74
|
const e = t.map(
|
|
@@ -183,7 +185,7 @@ const X = () => {
|
|
|
183
185
|
currentMessage: (t) => t.currentMessage,
|
|
184
186
|
isProcessing: (t) => t.isProcessing,
|
|
185
187
|
queue: (t) => t.queue
|
|
186
|
-
},
|
|
188
|
+
}, He = () => {
|
|
187
189
|
const t = d((i) => i.enqueue);
|
|
188
190
|
return { showNotice: A(
|
|
189
191
|
async (i) => {
|
|
@@ -520,13 +522,13 @@ function le() {
|
|
|
520
522
|
skip: !0
|
|
521
523
|
});
|
|
522
524
|
}
|
|
523
|
-
async function
|
|
525
|
+
async function M() {
|
|
524
526
|
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
|
|
525
527
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
526
528
|
skip: !0
|
|
527
529
|
})));
|
|
528
530
|
}
|
|
529
|
-
const
|
|
531
|
+
const C = ["tauri://created", "tauri://error"];
|
|
530
532
|
class P {
|
|
531
533
|
/**
|
|
532
534
|
* Creates a new Window.
|
|
@@ -568,7 +570,7 @@ class P {
|
|
|
568
570
|
*/
|
|
569
571
|
static async getByLabel(e) {
|
|
570
572
|
var i;
|
|
571
|
-
return (i = (await
|
|
573
|
+
return (i = (await M()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
572
574
|
}
|
|
573
575
|
/**
|
|
574
576
|
* Get an instance of `Window` for the current window.
|
|
@@ -580,7 +582,7 @@ class P {
|
|
|
580
582
|
* Gets a list of instances of `Window` for all available windows.
|
|
581
583
|
*/
|
|
582
584
|
static async getAll() {
|
|
583
|
-
return
|
|
585
|
+
return M();
|
|
584
586
|
}
|
|
585
587
|
/**
|
|
586
588
|
* Gets the focused window.
|
|
@@ -593,7 +595,7 @@ class P {
|
|
|
593
595
|
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
594
596
|
*/
|
|
595
597
|
static async getFocusedWindow() {
|
|
596
|
-
for (const e of await
|
|
598
|
+
for (const e of await M())
|
|
597
599
|
if (await e.isFocused())
|
|
598
600
|
return e;
|
|
599
601
|
return null;
|
|
@@ -664,7 +666,7 @@ class P {
|
|
|
664
666
|
* @param payload Event payload.
|
|
665
667
|
*/
|
|
666
668
|
async emit(e, i) {
|
|
667
|
-
if (
|
|
669
|
+
if (C.includes(e)) {
|
|
668
670
|
for (const n of this.listeners[e] || [])
|
|
669
671
|
n({
|
|
670
672
|
event: e,
|
|
@@ -688,7 +690,7 @@ class P {
|
|
|
688
690
|
* @param payload Event payload.
|
|
689
691
|
*/
|
|
690
692
|
async emitTo(e, i, n) {
|
|
691
|
-
if (
|
|
693
|
+
if (C.includes(i)) {
|
|
692
694
|
for (const a of this.listeners[i] || [])
|
|
693
695
|
a({
|
|
694
696
|
event: i,
|
|
@@ -701,7 +703,7 @@ class P {
|
|
|
701
703
|
}
|
|
702
704
|
/** @ignore */
|
|
703
705
|
_handleTauriEvent(e, i) {
|
|
704
|
-
return
|
|
706
|
+
return C.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
705
707
|
}
|
|
706
708
|
// Getters
|
|
707
709
|
/**
|
|
@@ -2137,7 +2139,7 @@ function Pe(t) {
|
|
|
2137
2139
|
}
|
|
2138
2140
|
};
|
|
2139
2141
|
}
|
|
2140
|
-
async function
|
|
2142
|
+
async function Ie() {
|
|
2141
2143
|
return s("plugin:window|primary_monitor").then(Pe);
|
|
2142
2144
|
}
|
|
2143
2145
|
function re() {
|
|
@@ -2155,7 +2157,7 @@ async function $() {
|
|
|
2155
2157
|
skip: !0
|
|
2156
2158
|
})));
|
|
2157
2159
|
}
|
|
2158
|
-
const
|
|
2160
|
+
const L = ["tauri://created", "tauri://error"];
|
|
2159
2161
|
class T {
|
|
2160
2162
|
/**
|
|
2161
2163
|
* Creates a new Webview.
|
|
@@ -2292,7 +2294,7 @@ class T {
|
|
|
2292
2294
|
* @param payload Event payload.
|
|
2293
2295
|
*/
|
|
2294
2296
|
async emit(e, i) {
|
|
2295
|
-
if (
|
|
2297
|
+
if (L.includes(e)) {
|
|
2296
2298
|
for (const n of this.listeners[e] || [])
|
|
2297
2299
|
n({
|
|
2298
2300
|
event: e,
|
|
@@ -2317,7 +2319,7 @@ class T {
|
|
|
2317
2319
|
* @param payload Event payload.
|
|
2318
2320
|
*/
|
|
2319
2321
|
async emitTo(e, i, n) {
|
|
2320
|
-
if (
|
|
2322
|
+
if (L.includes(i)) {
|
|
2321
2323
|
for (const a of this.listeners[i] || [])
|
|
2322
2324
|
a({
|
|
2323
2325
|
event: i,
|
|
@@ -2330,7 +2332,7 @@ class T {
|
|
|
2330
2332
|
}
|
|
2331
2333
|
/** @ignore */
|
|
2332
2334
|
_handleTauriEvent(e, i) {
|
|
2333
|
-
return
|
|
2335
|
+
return L.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
2334
2336
|
}
|
|
2335
2337
|
// Getters
|
|
2336
2338
|
/**
|
|
@@ -2601,7 +2603,7 @@ class T {
|
|
|
2601
2603
|
};
|
|
2602
2604
|
}
|
|
2603
2605
|
}
|
|
2604
|
-
function
|
|
2606
|
+
function xe() {
|
|
2605
2607
|
const t = re();
|
|
2606
2608
|
return new _(t.label, { skip: !0 });
|
|
2607
2609
|
}
|
|
@@ -2661,7 +2663,7 @@ class _ {
|
|
|
2661
2663
|
* Get an instance of `Webview` for the current webview.
|
|
2662
2664
|
*/
|
|
2663
2665
|
static getCurrent() {
|
|
2664
|
-
return
|
|
2666
|
+
return xe();
|
|
2665
2667
|
}
|
|
2666
2668
|
/**
|
|
2667
2669
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
@@ -2757,13 +2759,13 @@ function ke(t, e) {
|
|
|
2757
2759
|
});
|
|
2758
2760
|
});
|
|
2759
2761
|
}
|
|
2760
|
-
const S = /* @__PURE__ */ new Map(),
|
|
2762
|
+
const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
2761
2763
|
const n = i?.padding ?? 20;
|
|
2762
2764
|
if (i?.x !== void 0 && i?.y !== void 0)
|
|
2763
2765
|
return { x: i.x, y: i.y };
|
|
2764
2766
|
let a = 1920, r = 1080;
|
|
2765
2767
|
try {
|
|
2766
|
-
const u = await
|
|
2768
|
+
const u = await Ie();
|
|
2767
2769
|
u?.size && (a = u.size.width, r = u.size.height);
|
|
2768
2770
|
} catch (u) {
|
|
2769
2771
|
console.warn("Failed to get monitor info, using defaults:", u);
|
|
@@ -2800,13 +2802,13 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2800
2802
|
y: r - e - n
|
|
2801
2803
|
};
|
|
2802
2804
|
}
|
|
2803
|
-
},
|
|
2805
|
+
}, Ce = async (t) => {
|
|
2804
2806
|
const e = String(t.id), i = d.getState();
|
|
2805
2807
|
if (i.isWindowActive(e)) {
|
|
2806
2808
|
console.log(`Notice window already open for message: ${e}`);
|
|
2807
2809
|
return;
|
|
2808
2810
|
}
|
|
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
|
|
2811
|
+
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 Me(l, u, t.windowPosition);
|
|
2810
2812
|
try {
|
|
2811
2813
|
const y = new _(a, {
|
|
2812
2814
|
url: r,
|
|
@@ -2834,7 +2836,7 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2834
2836
|
} catch (a) {
|
|
2835
2837
|
console.error("Failed to close notice window:", a);
|
|
2836
2838
|
}
|
|
2837
|
-
},
|
|
2839
|
+
}, Le = async () => {
|
|
2838
2840
|
const t = Array.from(S.keys()).map(
|
|
2839
2841
|
(e) => q(e)
|
|
2840
2842
|
);
|
|
@@ -2843,14 +2845,14 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2843
2845
|
let t = null;
|
|
2844
2846
|
d.subscribe((e) => {
|
|
2845
2847
|
const i = e.currentMessage;
|
|
2846
|
-
i && i !== t ? (t = i,
|
|
2848
|
+
i && i !== t ? (t = i, Ce(i)) : i || (t = null);
|
|
2847
2849
|
}), console.log("Notice window system initialized");
|
|
2848
|
-
},
|
|
2850
|
+
}, Qe = () => {
|
|
2849
2851
|
const t = d((i) => i.currentMessage);
|
|
2850
2852
|
return { closeNotice: A(async () => {
|
|
2851
2853
|
t && await q(t.id);
|
|
2852
2854
|
}, [t]) };
|
|
2853
|
-
},
|
|
2855
|
+
}, Ve = () => {
|
|
2854
2856
|
const t = d();
|
|
2855
2857
|
return { hideNotice: A(
|
|
2856
2858
|
async (i) => {
|
|
@@ -2858,12 +2860,12 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2858
2860
|
},
|
|
2859
2861
|
[t]
|
|
2860
2862
|
) };
|
|
2861
|
-
},
|
|
2863
|
+
}, je = () => {
|
|
2862
2864
|
const t = d((i) => i.clearOnLogout);
|
|
2863
2865
|
return { hideAllNotices: A(async () => {
|
|
2864
|
-
await
|
|
2866
|
+
await Le(), await t();
|
|
2865
2867
|
}, [t]) };
|
|
2866
|
-
},
|
|
2868
|
+
}, $e = () => {
|
|
2867
2869
|
const t = d(D.queueLength), e = d(D.currentMessage), i = d(D.isProcessing), n = d(D.queue);
|
|
2868
2870
|
return {
|
|
2869
2871
|
queueLength: t,
|
|
@@ -2871,8 +2873,8 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2871
2873
|
isProcessing: i,
|
|
2872
2874
|
queue: n
|
|
2873
2875
|
};
|
|
2874
|
-
},
|
|
2875
|
-
const [n, a] =
|
|
2876
|
+
}, Je = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2877
|
+
const [n, a] = x(null), [r, l] = x(!0), [u, f] = x(null);
|
|
2876
2878
|
return B(() => {
|
|
2877
2879
|
(async () => {
|
|
2878
2880
|
try {
|
|
@@ -2881,12 +2883,12 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2881
2883
|
f("No message ID provided"), l(!1);
|
|
2882
2884
|
return;
|
|
2883
2885
|
}
|
|
2884
|
-
const
|
|
2885
|
-
if (!
|
|
2886
|
+
const I = await me(F);
|
|
2887
|
+
if (!I) {
|
|
2886
2888
|
f("Message not found"), l(!1);
|
|
2887
2889
|
return;
|
|
2888
2890
|
}
|
|
2889
|
-
a(
|
|
2891
|
+
a(I), l(!1), e && e(I);
|
|
2890
2892
|
} catch (y) {
|
|
2891
2893
|
console.error("Failed to load message:", y), f("Failed to load message"), l(!1);
|
|
2892
2894
|
}
|
|
@@ -2913,23 +2915,24 @@ const S = /* @__PURE__ */ new Map(), Ce = async (t, e, i) => {
|
|
|
2913
2915
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2914
2916
|
color: "#ef4444"
|
|
2915
2917
|
}, children: u || "Message not found" }) : /* @__PURE__ */ k(de, { children: t(n) });
|
|
2916
|
-
},
|
|
2918
|
+
}, Ze = async () => {
|
|
2917
2919
|
X(), Re();
|
|
2918
2920
|
const { initializeFromDatabase: t } = d.getState();
|
|
2919
2921
|
await t(), console.log("Tauri Notice System initialized");
|
|
2920
2922
|
};
|
|
2921
2923
|
export {
|
|
2922
|
-
|
|
2924
|
+
Je as NoticeLayout,
|
|
2923
2925
|
ve as clearPendingMessages,
|
|
2924
|
-
|
|
2926
|
+
Le as closeAllNoticeWindows,
|
|
2925
2927
|
q as closeNoticeWindow,
|
|
2926
|
-
|
|
2928
|
+
Ce as createNoticeWindow,
|
|
2929
|
+
Ue as deleteMessageById,
|
|
2927
2930
|
me as getMessage,
|
|
2928
2931
|
K as getNoticeConfig,
|
|
2929
2932
|
pe as getPendingMessages,
|
|
2930
2933
|
be as hasMessage,
|
|
2931
2934
|
X as initializeDatabase,
|
|
2932
|
-
|
|
2935
|
+
Ze as initializeNoticeSystem,
|
|
2933
2936
|
Re as initializeNoticeWindowSystem,
|
|
2934
2937
|
ye as isMessageShown,
|
|
2935
2938
|
fe as markAsHidden,
|
|
@@ -2937,11 +2940,11 @@ export {
|
|
|
2937
2940
|
D as messageQueueSelectors,
|
|
2938
2941
|
ge as saveMessage,
|
|
2939
2942
|
Ge as setNoticeConfig,
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2943
|
+
Qe as useCloseNotice,
|
|
2944
|
+
je as useHideAllNotices,
|
|
2945
|
+
Ve as useHideNotice,
|
|
2946
|
+
$e as useMessageQueue,
|
|
2944
2947
|
d as useMessageQueueStore,
|
|
2945
|
-
|
|
2948
|
+
He as useNoticeWindow
|
|
2946
2949
|
};
|
|
2947
2950
|
//# sourceMappingURL=index.js.map
|