tauri-notice-window 1.0.7 → 1.0.8
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 +403 -0
- 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 +56 -44
- package/dist/index.js.map +1 -1
- package/dist/types/message.d.ts +2 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,20 +3,22 @@ import { syncTabs as ue } from "zustand-sync";
|
|
|
3
3
|
import ce from "dexie";
|
|
4
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
|
-
const Z = "tauri-notice-config",
|
|
6
|
+
const Z = "tauri-notice-config", U = {
|
|
7
7
|
routePrefix: "/notice",
|
|
8
8
|
databaseName: "tauri-notice-db",
|
|
9
9
|
defaultWidth: 400,
|
|
10
|
-
defaultHeight: 300
|
|
10
|
+
defaultHeight: 300,
|
|
11
|
+
notFoundUrl: "/404"
|
|
12
|
+
// Default 404 page
|
|
11
13
|
}, Y = () => {
|
|
12
14
|
try {
|
|
13
15
|
const t = localStorage.getItem(Z);
|
|
14
16
|
if (t)
|
|
15
|
-
return { ...
|
|
17
|
+
return { ...U, ...JSON.parse(t) };
|
|
16
18
|
} catch (t) {
|
|
17
19
|
console.warn("Failed to load config from localStorage:", t);
|
|
18
20
|
}
|
|
19
|
-
return
|
|
21
|
+
return U;
|
|
20
22
|
}, we = (t) => {
|
|
21
23
|
try {
|
|
22
24
|
localStorage.setItem(Z, JSON.stringify(t));
|
|
@@ -66,7 +68,7 @@ const X = () => {
|
|
|
66
68
|
await h().messages.update(t, {
|
|
67
69
|
queueStatus: "hidden"
|
|
68
70
|
});
|
|
69
|
-
}, me = async (t) => await h().messages.get(t),
|
|
71
|
+
}, me = async (t) => await h().messages.get(t), He = async (t) => {
|
|
70
72
|
await h().messages.delete(t);
|
|
71
73
|
}, ve = async () => {
|
|
72
74
|
await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
@@ -185,7 +187,7 @@ const X = () => {
|
|
|
185
187
|
currentMessage: (t) => t.currentMessage,
|
|
186
188
|
isProcessing: (t) => t.isProcessing,
|
|
187
189
|
queue: (t) => t.queue
|
|
188
|
-
},
|
|
190
|
+
}, Ve = () => {
|
|
189
191
|
const t = d((i) => i.enqueue);
|
|
190
192
|
return { showNotice: A(
|
|
191
193
|
async (i) => {
|
|
@@ -512,23 +514,23 @@ class Oe {
|
|
|
512
514
|
return this._preventDefault;
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
|
-
var
|
|
517
|
+
var G;
|
|
516
518
|
(function(t) {
|
|
517
519
|
t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
|
|
518
|
-
})(
|
|
520
|
+
})(G || (G = {}));
|
|
519
521
|
function le() {
|
|
520
522
|
return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
521
523
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
522
524
|
skip: !0
|
|
523
525
|
});
|
|
524
526
|
}
|
|
525
|
-
async function
|
|
527
|
+
async function L() {
|
|
526
528
|
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
|
|
527
529
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
528
530
|
skip: !0
|
|
529
531
|
})));
|
|
530
532
|
}
|
|
531
|
-
const
|
|
533
|
+
const M = ["tauri://created", "tauri://error"];
|
|
532
534
|
class P {
|
|
533
535
|
/**
|
|
534
536
|
* Creates a new Window.
|
|
@@ -570,7 +572,7 @@ class P {
|
|
|
570
572
|
*/
|
|
571
573
|
static async getByLabel(e) {
|
|
572
574
|
var i;
|
|
573
|
-
return (i = (await
|
|
575
|
+
return (i = (await L()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
574
576
|
}
|
|
575
577
|
/**
|
|
576
578
|
* Get an instance of `Window` for the current window.
|
|
@@ -582,7 +584,7 @@ class P {
|
|
|
582
584
|
* Gets a list of instances of `Window` for all available windows.
|
|
583
585
|
*/
|
|
584
586
|
static async getAll() {
|
|
585
|
-
return
|
|
587
|
+
return L();
|
|
586
588
|
}
|
|
587
589
|
/**
|
|
588
590
|
* Gets the focused window.
|
|
@@ -595,7 +597,7 @@ class P {
|
|
|
595
597
|
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
596
598
|
*/
|
|
597
599
|
static async getFocusedWindow() {
|
|
598
|
-
for (const e of await
|
|
600
|
+
for (const e of await L())
|
|
599
601
|
if (await e.isFocused())
|
|
600
602
|
return e;
|
|
601
603
|
return null;
|
|
@@ -666,7 +668,7 @@ class P {
|
|
|
666
668
|
* @param payload Event payload.
|
|
667
669
|
*/
|
|
668
670
|
async emit(e, i) {
|
|
669
|
-
if (
|
|
671
|
+
if (M.includes(e)) {
|
|
670
672
|
for (const n of this.listeners[e] || [])
|
|
671
673
|
n({
|
|
672
674
|
event: e,
|
|
@@ -690,7 +692,7 @@ class P {
|
|
|
690
692
|
* @param payload Event payload.
|
|
691
693
|
*/
|
|
692
694
|
async emitTo(e, i, n) {
|
|
693
|
-
if (
|
|
695
|
+
if (M.includes(i)) {
|
|
694
696
|
for (const a of this.listeners[i] || [])
|
|
695
697
|
a({
|
|
696
698
|
event: i,
|
|
@@ -703,7 +705,7 @@ class P {
|
|
|
703
705
|
}
|
|
704
706
|
/** @ignore */
|
|
705
707
|
_handleTauriEvent(e, i) {
|
|
706
|
-
return
|
|
708
|
+
return M.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
707
709
|
}
|
|
708
710
|
// Getters
|
|
709
711
|
/**
|
|
@@ -2115,14 +2117,14 @@ var H;
|
|
|
2115
2117
|
(function(t) {
|
|
2116
2118
|
t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
|
|
2117
2119
|
})(H || (H = {}));
|
|
2118
|
-
var
|
|
2120
|
+
var V;
|
|
2119
2121
|
(function(t) {
|
|
2120
2122
|
t.Default = "default", t.FluentOverlay = "fluentOverlay";
|
|
2121
|
-
})(
|
|
2122
|
-
var
|
|
2123
|
+
})(V || (V = {}));
|
|
2124
|
+
var Q;
|
|
2123
2125
|
(function(t) {
|
|
2124
2126
|
t.AppearanceBased = "appearanceBased", t.Light = "light", t.Dark = "dark", t.MediumLight = "mediumLight", t.UltraDark = "ultraDark", t.Titlebar = "titlebar", t.Selection = "selection", t.Menu = "menu", t.Popover = "popover", t.Sidebar = "sidebar", t.HeaderView = "headerView", t.Sheet = "sheet", t.WindowBackground = "windowBackground", t.HudWindow = "hudWindow", t.FullScreenUI = "fullScreenUI", t.Tooltip = "tooltip", t.ContentBackground = "contentBackground", t.UnderWindowBackground = "underWindowBackground", t.UnderPageBackground = "underPageBackground", t.Mica = "mica", t.Blur = "blur", t.Acrylic = "acrylic", t.Tabbed = "tabbed", t.TabbedDark = "tabbedDark", t.TabbedLight = "tabbedLight";
|
|
2125
|
-
})(
|
|
2127
|
+
})(Q || (Q = {}));
|
|
2126
2128
|
var j;
|
|
2127
2129
|
(function(t) {
|
|
2128
2130
|
t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
|
|
@@ -2157,7 +2159,7 @@ async function $() {
|
|
|
2157
2159
|
skip: !0
|
|
2158
2160
|
})));
|
|
2159
2161
|
}
|
|
2160
|
-
const
|
|
2162
|
+
const C = ["tauri://created", "tauri://error"];
|
|
2161
2163
|
class T {
|
|
2162
2164
|
/**
|
|
2163
2165
|
* Creates a new Webview.
|
|
@@ -2294,7 +2296,7 @@ class T {
|
|
|
2294
2296
|
* @param payload Event payload.
|
|
2295
2297
|
*/
|
|
2296
2298
|
async emit(e, i) {
|
|
2297
|
-
if (
|
|
2299
|
+
if (C.includes(e)) {
|
|
2298
2300
|
for (const n of this.listeners[e] || [])
|
|
2299
2301
|
n({
|
|
2300
2302
|
event: e,
|
|
@@ -2319,7 +2321,7 @@ class T {
|
|
|
2319
2321
|
* @param payload Event payload.
|
|
2320
2322
|
*/
|
|
2321
2323
|
async emitTo(e, i, n) {
|
|
2322
|
-
if (
|
|
2324
|
+
if (C.includes(i)) {
|
|
2323
2325
|
for (const a of this.listeners[i] || [])
|
|
2324
2326
|
a({
|
|
2325
2327
|
event: i,
|
|
@@ -2332,7 +2334,7 @@ class T {
|
|
|
2332
2334
|
}
|
|
2333
2335
|
/** @ignore */
|
|
2334
2336
|
_handleTauriEvent(e, i) {
|
|
2335
|
-
return
|
|
2337
|
+
return C.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
2336
2338
|
}
|
|
2337
2339
|
// Getters
|
|
2338
2340
|
/**
|
|
@@ -2759,7 +2761,14 @@ function ke(t, e) {
|
|
|
2759
2761
|
});
|
|
2760
2762
|
});
|
|
2761
2763
|
}
|
|
2762
|
-
const S = /* @__PURE__ */ new Map(),
|
|
2764
|
+
const S = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
2765
|
+
if (!t || t.trim() === "") return !1;
|
|
2766
|
+
try {
|
|
2767
|
+
return !!(t.startsWith("/") || t.startsWith("http://") || t.startsWith("https://") || t.startsWith("tauri://"));
|
|
2768
|
+
} catch {
|
|
2769
|
+
return !1;
|
|
2770
|
+
}
|
|
2771
|
+
}, Me = async (t, e, i) => {
|
|
2763
2772
|
const n = i?.padding ?? 20;
|
|
2764
2773
|
if (i?.x !== void 0 && i?.y !== void 0)
|
|
2765
2774
|
return { x: i.x, y: i.y };
|
|
@@ -2808,7 +2817,10 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2808
2817
|
console.log(`Notice window already open for message: ${e}`);
|
|
2809
2818
|
return;
|
|
2810
2819
|
}
|
|
2811
|
-
const n = K(), a = `notice-${e}
|
|
2820
|
+
const n = K(), a = `notice-${e}`;
|
|
2821
|
+
let r = `${n.routePrefix}/${t.type}?id=${t.id}`;
|
|
2822
|
+
Le(r) || (console.warn(`Invalid window URL: ${r}. Using fallback 404 page.`), r = n.notFoundUrl || "/404");
|
|
2823
|
+
const l = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: f, y: m } = await Me(l, u, t.windowPosition);
|
|
2812
2824
|
try {
|
|
2813
2825
|
const y = new _(a, {
|
|
2814
2826
|
url: r,
|
|
@@ -2836,12 +2848,12 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2836
2848
|
} catch (a) {
|
|
2837
2849
|
console.error("Failed to close notice window:", a);
|
|
2838
2850
|
}
|
|
2839
|
-
},
|
|
2851
|
+
}, Re = async () => {
|
|
2840
2852
|
const t = Array.from(S.keys()).map(
|
|
2841
2853
|
(e) => q(e)
|
|
2842
2854
|
);
|
|
2843
2855
|
await Promise.all(t);
|
|
2844
|
-
},
|
|
2856
|
+
}, Ee = () => {
|
|
2845
2857
|
let t = null;
|
|
2846
2858
|
d.subscribe((e) => {
|
|
2847
2859
|
const i = e.currentMessage;
|
|
@@ -2852,7 +2864,7 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2852
2864
|
return { closeNotice: A(async () => {
|
|
2853
2865
|
t && await q(t.id);
|
|
2854
2866
|
}, [t]) };
|
|
2855
|
-
},
|
|
2867
|
+
}, je = () => {
|
|
2856
2868
|
const t = d();
|
|
2857
2869
|
return { hideNotice: A(
|
|
2858
2870
|
async (i) => {
|
|
@@ -2860,12 +2872,12 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2860
2872
|
},
|
|
2861
2873
|
[t]
|
|
2862
2874
|
) };
|
|
2863
|
-
},
|
|
2875
|
+
}, $e = () => {
|
|
2864
2876
|
const t = d((i) => i.clearOnLogout);
|
|
2865
2877
|
return { hideAllNotices: A(async () => {
|
|
2866
|
-
await
|
|
2878
|
+
await Re(), await t();
|
|
2867
2879
|
}, [t]) };
|
|
2868
|
-
},
|
|
2880
|
+
}, Je = () => {
|
|
2869
2881
|
const t = d(D.queueLength), e = d(D.currentMessage), i = d(D.isProcessing), n = d(D.queue);
|
|
2870
2882
|
return {
|
|
2871
2883
|
queueLength: t,
|
|
@@ -2873,7 +2885,7 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2873
2885
|
isProcessing: i,
|
|
2874
2886
|
queue: n
|
|
2875
2887
|
};
|
|
2876
|
-
},
|
|
2888
|
+
}, Ze = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2877
2889
|
const [n, a] = x(null), [r, l] = x(!0), [u, f] = x(null);
|
|
2878
2890
|
return B(() => {
|
|
2879
2891
|
(async () => {
|
|
@@ -2915,25 +2927,25 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
|
|
|
2915
2927
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2916
2928
|
color: "#ef4444"
|
|
2917
2929
|
}, children: u || "Message not found" }) : /* @__PURE__ */ k(de, { children: t(n) });
|
|
2918
|
-
},
|
|
2919
|
-
X(),
|
|
2930
|
+
}, Ye = async () => {
|
|
2931
|
+
X(), Ee();
|
|
2920
2932
|
const { initializeFromDatabase: t } = d.getState();
|
|
2921
2933
|
await t(), console.log("Tauri Notice System initialized");
|
|
2922
2934
|
};
|
|
2923
2935
|
export {
|
|
2924
|
-
|
|
2936
|
+
Ze as NoticeLayout,
|
|
2925
2937
|
ve as clearPendingMessages,
|
|
2926
|
-
|
|
2938
|
+
Re as closeAllNoticeWindows,
|
|
2927
2939
|
q as closeNoticeWindow,
|
|
2928
2940
|
Ce as createNoticeWindow,
|
|
2929
|
-
|
|
2941
|
+
He as deleteMessageById,
|
|
2930
2942
|
me as getMessage,
|
|
2931
2943
|
K as getNoticeConfig,
|
|
2932
2944
|
pe as getPendingMessages,
|
|
2933
2945
|
be as hasMessage,
|
|
2934
2946
|
X as initializeDatabase,
|
|
2935
|
-
|
|
2936
|
-
|
|
2947
|
+
Ye as initializeNoticeSystem,
|
|
2948
|
+
Ee as initializeNoticeWindowSystem,
|
|
2937
2949
|
ye as isMessageShown,
|
|
2938
2950
|
fe as markAsHidden,
|
|
2939
2951
|
ee as markAsShown,
|
|
@@ -2941,10 +2953,10 @@ export {
|
|
|
2941
2953
|
ge as saveMessage,
|
|
2942
2954
|
Ge as setNoticeConfig,
|
|
2943
2955
|
Qe as useCloseNotice,
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2956
|
+
$e as useHideAllNotices,
|
|
2957
|
+
je as useHideNotice,
|
|
2958
|
+
Je as useMessageQueue,
|
|
2947
2959
|
d as useMessageQueueStore,
|
|
2948
|
-
|
|
2960
|
+
Ve as useNoticeWindow
|
|
2949
2961
|
};
|
|
2950
2962
|
//# sourceMappingURL=index.js.map
|