tauri-notice-window 1.0.8 → 1.0.10
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 +159 -67
- package/dist/components/NoticeLayout.d.ts.map +1 -1
- package/dist/hooks/useHideNotice.d.ts.map +1 -1
- 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 +331 -292
- package/dist/index.js.map +1 -1
- package/dist/stores/messageQueueStore.d.ts +4 -0
- package/dist/stores/messageQueueStore.d.ts.map +1 -1
- package/dist/utils/db.d.ts +2 -1
- package/dist/utils/db.d.ts.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@ A reusable React library for cross-window notification management in Tauri v2+ a
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Cross-Window State Sync**: All Tauri windows (main + notice windows) see the same state via `zustand-sync`
|
|
8
|
-
- **
|
|
8
|
+
- **Zustand-First Architecture**: Zustand store is the single source of truth at runtime
|
|
9
|
+
- **Persistent Queue**: IndexedDB (Dexie) used only for cold storage (app restarts)
|
|
10
|
+
- **Clean Data Flow**: Store → Database (one-way dependency, no circular dependencies)
|
|
9
11
|
- **One-at-a-Time Display**: Only one notice window shown at a time
|
|
10
12
|
- **Customizable Routes**: Configurable router prefix for notice pages
|
|
11
13
|
- **URL Validation & 404 Fallback**: Automatic validation with customizable error pages for invalid routes
|
|
@@ -710,114 +712,84 @@ setNoticeConfig({
|
|
|
710
712
|
|
|
711
713
|
**URL Validation:** Before creating a WebviewWindow, the library validates the window URL. If the URL is invalid (empty, malformed, or doesn't start with `/`, `http://`, `https://`, or `tauri://`), it automatically falls back to the `notFoundUrl` and logs a warning.
|
|
712
714
|
|
|
713
|
-
###
|
|
715
|
+
### Store Methods (Recommended)
|
|
714
716
|
|
|
715
|
-
|
|
717
|
+
All operations should go through the Zustand store for consistency:
|
|
716
718
|
|
|
717
|
-
####
|
|
719
|
+
#### store.deleteMessage()
|
|
718
720
|
|
|
719
|
-
|
|
721
|
+
Delete a message completely (from both memory and database).
|
|
720
722
|
|
|
721
723
|
```typescript
|
|
722
|
-
import {
|
|
724
|
+
import { useMessageQueueStore } from 'tauri-notice-window'
|
|
723
725
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
title: 'Notice',
|
|
727
|
-
type: 'announcement',
|
|
728
|
-
data: { content: 'Message content' }
|
|
729
|
-
})
|
|
726
|
+
const store = useMessageQueueStore.getState()
|
|
727
|
+
await store.deleteMessage('123') // Removes from store AND database
|
|
730
728
|
```
|
|
731
729
|
|
|
732
|
-
####
|
|
730
|
+
#### store.hideMessage()
|
|
733
731
|
|
|
734
|
-
|
|
732
|
+
Hide a message (marks as hidden and removes from queue).
|
|
735
733
|
|
|
736
734
|
```typescript
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
const message = await getMessage('123')
|
|
735
|
+
const store = useMessageQueueStore.getState()
|
|
736
|
+
await store.hideMessage('123') // Marks hidden in DB, removes from queue
|
|
740
737
|
```
|
|
741
738
|
|
|
742
|
-
####
|
|
739
|
+
#### store.removeFromQueue()
|
|
743
740
|
|
|
744
|
-
|
|
741
|
+
Remove a message from queue (memory only, persists position changes).
|
|
745
742
|
|
|
746
743
|
```typescript
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
await deleteMessageById('123')
|
|
744
|
+
const store = useMessageQueueStore.getState()
|
|
745
|
+
await store.removeFromQueue('123') // Updates queue positions in DB
|
|
750
746
|
```
|
|
751
747
|
|
|
752
|
-
####
|
|
748
|
+
#### store.markMessageAsShown()
|
|
753
749
|
|
|
754
|
-
|
|
750
|
+
Mark a message as shown in database.
|
|
755
751
|
|
|
756
752
|
```typescript
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
const exists = await hasMessage('123')
|
|
753
|
+
const store = useMessageQueueStore.getState()
|
|
754
|
+
await store.markMessageAsShown('123') // Prevents re-showing
|
|
760
755
|
```
|
|
761
756
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
Check if a message was already shown.
|
|
765
|
-
|
|
766
|
-
```typescript
|
|
767
|
-
import { isMessageShown } from 'tauri-notice-window'
|
|
757
|
+
### Database Utilities (Low-Level)
|
|
768
758
|
|
|
769
|
-
|
|
770
|
-
```
|
|
759
|
+
⚠️ **Warning:** Direct database access bypasses the store. Only use these for advanced scenarios where you need to query historical data. For all mutations, use store methods above.
|
|
771
760
|
|
|
772
|
-
####
|
|
761
|
+
#### initializeDatabase()
|
|
773
762
|
|
|
774
|
-
|
|
763
|
+
Initialize the database (called automatically by `initializeNoticeSystem()`).
|
|
775
764
|
|
|
776
765
|
```typescript
|
|
777
|
-
import {
|
|
766
|
+
import { initializeDatabase } from 'tauri-notice-window'
|
|
778
767
|
|
|
779
|
-
const
|
|
768
|
+
const db = initializeDatabase()
|
|
780
769
|
```
|
|
781
770
|
|
|
782
|
-
####
|
|
771
|
+
#### getMessage()
|
|
783
772
|
|
|
784
|
-
|
|
773
|
+
Retrieve a message by ID.
|
|
785
774
|
|
|
786
775
|
```typescript
|
|
787
|
-
import {
|
|
776
|
+
import { getMessage } from 'tauri-notice-window'
|
|
788
777
|
|
|
789
|
-
await
|
|
778
|
+
const message = await getMessage('123')
|
|
790
779
|
```
|
|
791
780
|
|
|
792
|
-
#### markAsShown()
|
|
793
|
-
|
|
794
|
-
Mark a message as shown.
|
|
795
|
-
|
|
796
|
-
```typescript
|
|
797
|
-
import { markAsShown } from 'tauri-notice-window'
|
|
798
781
|
|
|
799
|
-
await markAsShown('123')
|
|
800
|
-
```
|
|
801
782
|
|
|
802
|
-
####
|
|
783
|
+
#### getPendingMessages()
|
|
803
784
|
|
|
804
|
-
|
|
785
|
+
Get all pending messages.
|
|
805
786
|
|
|
806
787
|
```typescript
|
|
807
|
-
import {
|
|
788
|
+
import { getPendingMessages } from 'tauri-notice-window'
|
|
808
789
|
|
|
809
|
-
await
|
|
790
|
+
const pending = await getPendingMessages()
|
|
810
791
|
```
|
|
811
792
|
|
|
812
|
-
#### clearPendingMessages()
|
|
813
|
-
|
|
814
|
-
Clear all pending and showing messages.
|
|
815
|
-
|
|
816
|
-
```typescript
|
|
817
|
-
import { clearPendingMessages } from 'tauri-notice-window'
|
|
818
|
-
|
|
819
|
-
await clearPendingMessages()
|
|
820
|
-
```
|
|
821
793
|
|
|
822
794
|
## Routing Setup
|
|
823
795
|
|
|
@@ -848,6 +820,72 @@ app/
|
|
|
848
820
|
|
|
849
821
|
## Advanced Usage
|
|
850
822
|
|
|
823
|
+
### Message Deletion and Queue Management
|
|
824
|
+
|
|
825
|
+
All message operations should go through the Zustand store to maintain consistency.
|
|
826
|
+
|
|
827
|
+
```typescript
|
|
828
|
+
import { useNoticeWindow, useMessageQueueStore } from 'tauri-notice-window'
|
|
829
|
+
|
|
830
|
+
function NoticeManager() {
|
|
831
|
+
const { showNotice } = useNoticeWindow()
|
|
832
|
+
const store = useMessageQueueStore.getState()
|
|
833
|
+
|
|
834
|
+
// Example 1: Delete a message from the queue
|
|
835
|
+
const handleDeleteMessage = async () => {
|
|
836
|
+
await showNotice({ id: '1', title: 'First', type: 'announcement', data: {} })
|
|
837
|
+
await showNotice({ id: '2', title: 'Second', type: 'announcement', data: {} })
|
|
838
|
+
await showNotice({ id: '3', title: 'Third', type: 'announcement', data: {} })
|
|
839
|
+
|
|
840
|
+
// Delete message '2' from queue via store
|
|
841
|
+
await store.deleteMessage('2')
|
|
842
|
+
// Result: Message removed from queue and database
|
|
843
|
+
// Console output: "Message 2 was deleted, skipping to next"
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// Example 2: Delete the currently displayed message
|
|
847
|
+
const handleDeleteCurrent = async () => {
|
|
848
|
+
await showNotice({ id: '4', title: 'Current', type: 'announcement', data: {} })
|
|
849
|
+
// Window for message '4' is now open
|
|
850
|
+
|
|
851
|
+
// Delete via store
|
|
852
|
+
await store.deleteMessage('4')
|
|
853
|
+
// Result: Window closes, next message shows automatically
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// Example 3: Remove from queue without deleting from DB
|
|
857
|
+
const handleRemoveFromQueue = async () => {
|
|
858
|
+
await store.removeFromQueue('5') // Only removes from runtime queue
|
|
859
|
+
// Message still exists in DB for historical queries
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// Example 4: Hide a message (server-triggered)
|
|
863
|
+
const handleHideMessage = async () => {
|
|
864
|
+
await store.hideMessage('6') // Marks as hidden + removes from queue
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
**How it works:**
|
|
870
|
+
1. **Store methods** handle both memory (Zustand) and persistence (IndexedDB)
|
|
871
|
+
2. `deleteMessage()` removes from both queue and database
|
|
872
|
+
3. If deleted message is currently shown, window closes automatically
|
|
873
|
+
4. Queue position changes are persisted to database
|
|
874
|
+
5. Before showing any message, system verifies it exists in database
|
|
875
|
+
6. **Safety Layer:** `NoticeLayout` component auto-closes if message is missing
|
|
876
|
+
|
|
877
|
+
**Key Difference from Old API:**
|
|
878
|
+
```typescript
|
|
879
|
+
// ❌ OLD: Direct database access (bypassed store, caused circular deps)
|
|
880
|
+
import { deleteMessageById } from 'tauri-notice-window'
|
|
881
|
+
await deleteMessageById('123') // Only deleted from DB, not from queue
|
|
882
|
+
|
|
883
|
+
// ✅ NEW: Store-first approach (clean, consistent)
|
|
884
|
+
import { useMessageQueueStore } from 'tauri-notice-window'
|
|
885
|
+
const store = useMessageQueueStore.getState()
|
|
886
|
+
await store.deleteMessage('123') // Updates both store and database
|
|
887
|
+
```
|
|
888
|
+
|
|
851
889
|
### Server-Triggered Hide
|
|
852
890
|
|
|
853
891
|
```typescript
|
|
@@ -968,6 +1006,45 @@ function QueueIndicator() {
|
|
|
968
1006
|
|
|
969
1007
|
## How It Works
|
|
970
1008
|
|
|
1009
|
+
### Architecture: Zustand-First Design
|
|
1010
|
+
|
|
1011
|
+
This library follows a **clean, one-way data flow** architecture:
|
|
1012
|
+
|
|
1013
|
+
```
|
|
1014
|
+
┌─────────────────────────────────────────────────────┐
|
|
1015
|
+
│ Runtime (While App is Running) │
|
|
1016
|
+
│ │
|
|
1017
|
+
│ ┌──────────────────────────────────────┐ │
|
|
1018
|
+
│ │ Zustand Store (Source of Truth) │ │
|
|
1019
|
+
│ │ - Queue state │ │
|
|
1020
|
+
│ │ - Current message │ │
|
|
1021
|
+
│ │ - Processing status │ │
|
|
1022
|
+
│ └──────────────┬───────────────────────┘ │
|
|
1023
|
+
│ │ │
|
|
1024
|
+
│ │ Persists to ↓ │
|
|
1025
|
+
│ │ │
|
|
1026
|
+
│ ┌──────────────▼───────────────────────┐ │
|
|
1027
|
+
│ │ IndexedDB (Dexie) │ │
|
|
1028
|
+
│ │ - Dumb storage layer │ │
|
|
1029
|
+
│ │ - No business logic │ │
|
|
1030
|
+
│ │ - Only for cold starts │ │
|
|
1031
|
+
│ └──────────────────────────────────────┘ │
|
|
1032
|
+
└─────────────────────────────────────────────────────┘
|
|
1033
|
+
|
|
1034
|
+
┌─────────────────────────────────────────────────────┐
|
|
1035
|
+
│ Cold Start (App Restart) │
|
|
1036
|
+
│ │
|
|
1037
|
+
│ IndexedDB ────loads───► Zustand Store │
|
|
1038
|
+
│ (Back to runtime mode) │
|
|
1039
|
+
└─────────────────────────────────────────────────────┘
|
|
1040
|
+
```
|
|
1041
|
+
|
|
1042
|
+
**Key Principles:**
|
|
1043
|
+
1. **Zustand is the boss** - All operations go through the store
|
|
1044
|
+
2. **Database is dumb** - Pure storage functions, no knowledge of store
|
|
1045
|
+
3. **One-way flow** - Store writes to DB, DB never touches store
|
|
1046
|
+
4. **No circular dependencies** - Clean module boundaries
|
|
1047
|
+
|
|
971
1048
|
### Cross-Window Synchronization
|
|
972
1049
|
|
|
973
1050
|
The library uses `zustand-sync` to synchronize state across all Tauri windows via localStorage. When you enqueue a message in the main window, all notice windows see the update in real-time.
|
|
@@ -982,6 +1059,9 @@ Zustand Store ◄─────────► localStorage ◄─────
|
|
|
982
1059
|
| | |
|
|
983
1060
|
▼ ▼ ▼
|
|
984
1061
|
State Updated State Updated State Updated
|
|
1062
|
+
│ │
|
|
1063
|
+
└─────── Persists to IndexedDB ────────────────────┘
|
|
1064
|
+
(for cold starts only)
|
|
985
1065
|
```
|
|
986
1066
|
|
|
987
1067
|
### Message Lifecycle
|
|
@@ -991,12 +1071,24 @@ State Updated State Updated State Updated
|
|
|
991
1071
|
3. **shown**: User has acknowledged the message
|
|
992
1072
|
4. **hidden**: Server requested to hide the message
|
|
993
1073
|
|
|
994
|
-
### Persistence
|
|
1074
|
+
### Persistence Strategy
|
|
995
1075
|
|
|
996
|
-
|
|
1076
|
+
**At Runtime:**
|
|
1077
|
+
- All state lives in Zustand store (in-memory)
|
|
1078
|
+
- Store automatically persists changes to IndexedDB
|
|
1079
|
+
- Database is just a backup, not actively queried
|
|
1080
|
+
|
|
1081
|
+
**On App Restart:**
|
|
997
1082
|
1. Database is initialized
|
|
998
|
-
2. Pending messages are loaded
|
|
1083
|
+
2. Pending messages are loaded into Zustand store
|
|
999
1084
|
3. First message is shown automatically
|
|
1085
|
+
4. Back to runtime mode (Zustand is now the truth)
|
|
1086
|
+
|
|
1087
|
+
**Why This Design?**
|
|
1088
|
+
- **Performance**: No database queries during normal operation
|
|
1089
|
+
- **Simplicity**: Single source of truth eliminates sync bugs
|
|
1090
|
+
- **Clean Code**: No circular dependencies, predictable data flow
|
|
1091
|
+
- **Reliability**: Database only used for cold storage
|
|
1000
1092
|
|
|
1001
1093
|
## Requirements
|
|
1002
1094
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD;;GAEG;AACH,UAAU,iBAAiB;IACzB;;OAEG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAA;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACvC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;CACzC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,+BAA+B,iBAAiB,4CAoI5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHideNotice.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideNotice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useHideNotice.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideNotice.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,aAAa;4BAIJ,MAAM;CAW3B,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("zustand"),pe=require("zustand-sync"),_e=require("dexie"),g=require("react"),z=require("react/jsx-runtime"),Y="tauri-notice-config",G={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404"},K=()=>{try{const t=localStorage.getItem(Y);if(t)return{...G,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return G},fe=t=>{try{localStorage.setItem(Y,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},me=t=>{const i={...K(),...t};fe(i)},E=()=>K();class ve extends _e{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let S=null;const q=()=>{if(!S){const t=E();S=new ve(t.databaseName)}return S},h=()=>S||q(),X=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await h().messages.put(e)},ee=async t=>!!await h().messages.get(t),te=async t=>{const e=await h().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},ie=async()=>await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),We=async(t,e)=>{await h().messages.update(t,{queueStatus:e})},T=async t=>{await h().messages.update(t,{queueStatus:"shown",isShown:!0})},ne=async t=>{await h().messages.update(t,{queueStatus:"hidden"})},se=async t=>await h().messages.get(t),Se=async t=>{await h().messages.delete(t)},ae=async()=>{await h().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},Ne=async t=>{const e=t.map(i=>h().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},De=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await te(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await ee(i.id)||await X(i),!n.queue.some(u=>u.id===i.id)){const u=[...n.queue,i];t({queue:u}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}t({currentMessage:n,isProcessing:!0}),await We(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await ie();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await Ne(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await ae()},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(r=>r!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),d=ye.create()(pe.syncTabs(De,{name:"tauri-notice-queue"})),W={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},ze=()=>{const t=d(i=>i.enqueue);return{showNotice:g.useCallback(async i=>{await t(i)},[t])}};function Ae(t,e,i,n){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");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function Oe(t,e,i,n,a){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");return e.set(t,i),i}var A;const w="__TAURI_TO_IPC_KEY__";function Pe(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class Me{get rid(){return Ae(this,A,"f")}constructor(e){A.set(this,void 0),Oe(this,A,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}A=new WeakMap;class le{constructor(...e){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])}toPhysical(e){return new y(this.width*e,this.height*e)}[w](){return{width:this.width,height:this.height}}toJSON(){return this[w]()}}class y{constructor(...e){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])}toLogical(e){return new le(this.width/e,this.height/e)}[w](){return{width:this.width,height:this.height}}toJSON(){return this[w]()}}class b{constructor(e){this.size=e}toLogical(e){return this.size instanceof le?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof y?this.size:this.size.toPhysical(e)}[w](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[w]()}}class re{constructor(...e){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])}toPhysical(e){return new c(this.x*e,this.y*e)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class c{constructor(...e){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])}toLogical(e){return new re(this.x/e,this.y/e)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class _{constructor(e){this.position=e}toLogical(e){return this.position instanceof re?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof c?this.position:this.position.toPhysical(e)}[w](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[w]()}}var o;(function(t){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"})(o||(o={}));async function oe(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function P(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:Pe(e)}).then(r=>async()=>oe(t,r))}async function F(t,e,i){return P(t,n=>{oe(t,n.id),e(n)},i)}async function ue(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ce(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class N extends Me{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:O(e),width:i,height:n}).then(a=>new N(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:O(e)}).then(i=>new N(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new N(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function O(t){return t==null?null:typeof t=="string"?t:t instanceof N?t.rid:t}var R;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(R||(R={}));class Ie{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var H;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(H||(H={}));function de(){return new M(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function k(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new M(e,{skip:!0})))}const C=["tauri://created","tauri://error"];class M{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await k()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return de()}static async getAll(){return k()}static async getFocusedWindow(){for(const e of await k())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(C.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ue(e,i)}async emitTo(e,i,n){if(C.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ce(e,i,n)}_handleTauriEvent(e,i){return C.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new c(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new c(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new y(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new y(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===R.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof b?e:new b(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof b?e:e?new b(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof b?e:e?new b(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:O(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?O(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(o.WINDOW_RESIZED,i=>{i.payload=new y(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new c(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Ie(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new c(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new c(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new c(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var Q;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(Q||(Q={}));var j;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(j||(j={}));var V;(function(t){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"})(V||(V={}));var $;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})($||($={}));function xe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new c(t.position),size:new y(t.size),workArea:{position:new c(t.workArea.position),size:new y(t.workArea.size)}}}async function ke(){return s("plugin:window|primary_monitor").then(xe)}function we(){return new B(de(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function J(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new B(new M(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const L=["tauri://created","tauri://error"];class B{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await J()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return we()}static async getAll(){return J()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(L.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ue(e,i)}async emitTo(e,i,n){if(L.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ce(e,i,n)}_handleTauriEvent(e,i){return L.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new c(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new y(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof b?e:new b(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new c(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new c(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new c(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function Ce(){const t=we();return new f(t.label,{skip:!0})}async function Z(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new f(e,{skip:!0})))}class f{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await Z()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new f(n.label,{skip:!0}):null}static getCurrent(){return Ce()}static async getAll(){return Z()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}Le(f,[M,B]);function Le(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const D=new Map,Re=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},Ee=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};let a=1920,r=1080;try{const u=await ke();u?.size&&(a=u.size.width,r=u.size.height)}catch(u){console.warn("Failed to get monitor info, using defaults:",u)}switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:r-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:r-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(r-e)/2};default:return{x:a-t-n,y:r-e-n}}},he=async t=>{const e=String(t.id),i=d.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=E(),a=`notice-${e}`;let r=`${n.routePrefix}/${t.type}?id=${t.id}`;Re(r)||(console.warn(`Invalid window URL: ${r}. Using fallback 404 page.`),r=n.notFoundUrl||"/404");const l=t.min_width||n.defaultWidth,u=t.min_height||n.defaultHeight,{x:m,y:v}=await Ee(l,u,t.windowPosition);try{const p=new f(a,{url:r,title:t.title,width:l,height:u,x:m,y:v,resizable:!0,decorations:!0,skipTaskbar:!1,alwaysOnTop:!0});D.set(e,p),i.addActiveWindow(e),p.once("tauri://destroyed",async()=>{D.delete(e),i.removeActiveWindow(e),await T(e),i.clearCurrent()}),console.log(`Created notice window: ${a}`)}catch(p){console.error("Failed to create notice window:",p),i.removeActiveWindow(e),i.clearCurrent()}},I=async t=>{const e=String(t),i=D.get(e),n=d.getState();if(i)try{await i.close(),D.delete(e),n.removeActiveWindow(e),await T(e),n.clearCurrent(),console.log(`Closed notice window: ${e}`)}catch(a){console.error("Failed to close notice window:",a)}},ge=async()=>{const t=Array.from(D.keys()).map(e=>I(e));await Promise.all(t)},be=()=>{let t=null;d.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,he(i)):i||(t=null)}),console.log("Notice window system initialized")},qe=()=>{const t=d(i=>i.currentMessage);return{closeNotice:g.useCallback(async()=>{t&&await I(t.id)},[t])}},Te=()=>{const t=d();return{hideNotice:g.useCallback(async i=>{await ne(i),await I(i),t.currentMessage?.id===i&&t.clearCurrent()},[t])}},Fe=()=>{const t=d(i=>i.clearOnLogout);return{hideAllNotices:g.useCallback(async()=>{await ge(),await t()},[t])}},Be=()=>{const t=d(W.queueLength),e=d(W.currentMessage),i=d(W.isProcessing),n=d(W.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Ue=({children:t,onLoad:e,onClose:i})=>{const[n,a]=g.useState(null),[r,l]=g.useState(!0),[u,m]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const U=new URLSearchParams(window.location.search).get("id");if(!U){m("No message ID provided"),l(!1);return}const x=await se(U);if(!x){m("Message not found"),l(!1);return}a(x),l(!1),e&&e(x)}catch(p){console.error("Failed to load message:",p),m("Failed to load message"),l(!1)}})()},[e]),g.useEffect(()=>{if(!n||!i)return;const v=()=>{i(n)};return window.addEventListener("beforeunload",v),()=>{window.removeEventListener("beforeunload",v)}},[n,i]),r?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):u||!n?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:u||"Message not found"}):z.jsx(z.Fragment,{children:t(n)})},Ge=async()=>{q(),be();const{initializeFromDatabase:t}=d.getState();await t(),console.log("Tauri Notice System initialized")};exports.NoticeLayout=Ue;exports.clearPendingMessages=ae;exports.closeAllNoticeWindows=ge;exports.closeNoticeWindow=I;exports.createNoticeWindow=he;exports.deleteMessageById=Se;exports.getMessage=se;exports.getNoticeConfig=E;exports.getPendingMessages=ie;exports.hasMessage=ee;exports.initializeDatabase=q;exports.initializeNoticeSystem=Ge;exports.initializeNoticeWindowSystem=be;exports.isMessageShown=te;exports.markAsHidden=ne;exports.markAsShown=T;exports.messageQueueSelectors=W;exports.saveMessage=X;exports.setNoticeConfig=me;exports.useCloseNotice=qe;exports.useHideAllNotices=Fe;exports.useHideNotice=Te;exports.useMessageQueue=Be;exports.useMessageQueueStore=d;exports.useNoticeWindow=ze;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("zustand"),he=require("zustand-sync"),ge=require("dexie"),g=require("react"),N=require("react/jsx-runtime"),X="tauri-notice-config",H={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404"},ee=()=>{try{const t=localStorage.getItem(X);if(t)return{...H,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return H},ye=t=>{try{localStorage.setItem(X,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},be=t=>{const i={...ee(),...t};ye(i)},F=()=>ee();class pe extends ge{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let z=null;const B=()=>{if(!z){const t=F();z=new pe(t.databaseName)}return z},h=()=>z||B(),_e=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await h().messages.put(e)},fe=async t=>!!await h().messages.get(t),me=async t=>{const e=await h().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},te=async()=>await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),ve=async(t,e)=>{await h().messages.update(t,{queueStatus:e})},We=async t=>{await h().messages.update(t,{queueStatus:"shown",isShown:!0})},Se=async t=>{await h().messages.update(t,{queueStatus:"hidden"})},U=async t=>await h().messages.get(t),Ne=async t=>{await h().messages.delete(t)},De=async()=>{await h().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},ze=async t=>{const e=t.map(i=>h().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Ae=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await me(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await fe(i.id)||await _e(i),!n.queue.some(u=>u.id===i.id)){const u=[...n.queue,i];t({queue:u}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}if(!await U(n.id)){console.log(`Message ${n.id} was deleted, skipping to next`),await e().showNext();return}t({currentMessage:n,isProcessing:!0}),await ve(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await te();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await ze(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await De()},removeFromQueue:async i=>{const n=e(),a=n.queue.filter(r=>r.id!==i);t({queue:a}),await e().persistQueue(),n.currentMessage?.id===i&&e().clearCurrent()},deleteMessage:async i=>{await Ne(i),await e().removeFromQueue(i)},hideMessage:async i=>{await Se(i),await e().removeFromQueue(i)},markMessageAsShown:async i=>{await We(i)},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(r=>r!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),w=de.create()(he.syncTabs(Ae,{name:"tauri-notice-queue"})),D={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},xe=()=>{const t=w(i=>i.enqueue);return{showNotice:g.useCallback(async i=>{await t(i)},[t])}};function Oe(t,e,i,n){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");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function Me(t,e,i,n,a){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");return e.set(t,i),i}var O;const d="__TAURI_TO_IPC_KEY__";function Pe(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class ke{get rid(){return Oe(this,O,"f")}constructor(e){O.set(this,void 0),Me(this,O,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}O=new WeakMap;class ie{constructor(...e){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])}toPhysical(e){return new b(this.width*e,this.height*e)}[d](){return{width:this.width,height:this.height}}toJSON(){return this[d]()}}class b{constructor(...e){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])}toLogical(e){return new ie(this.width/e,this.height/e)}[d](){return{width:this.width,height:this.height}}toJSON(){return this[d]()}}class y{constructor(e){this.size=e}toLogical(e){return this.size instanceof ie?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof b?this.size:this.size.toPhysical(e)}[d](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[d]()}}class ne{constructor(...e){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])}toPhysical(e){return new c(this.x*e,this.y*e)}[d](){return{x:this.x,y:this.y}}toJSON(){return this[d]()}}class c{constructor(...e){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])}toLogical(e){return new ne(this.x/e,this.y/e)}[d](){return{x:this.x,y:this.y}}toJSON(){return this[d]()}}class f{constructor(e){this.position=e}toLogical(e){return this.position instanceof ne?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof c?this.position:this.position.toPhysical(e)}[d](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[d]()}}var o;(function(t){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"})(o||(o={}));async function se(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function k(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:Pe(e)}).then(r=>async()=>se(t,r))}async function Q(t,e,i){return k(t,n=>{se(t,n.id),e(n)},i)}async function ae(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function le(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class A extends ke{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:P(e),width:i,height:n}).then(a=>new A(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:P(e)}).then(i=>new A(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new A(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function P(t){return t==null?null:typeof t=="string"?t:t instanceof A?t.rid:t}var q;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(q||(q={}));class Ce{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var j;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(j||(j={}));function re(){return new C(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function E(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new C(e,{skip:!0})))}const R=["tauri://created","tauri://error"];class C{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await E()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return re()}static async getAll(){return E()}static async getFocusedWindow(){for(const e of await E())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:k(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Q(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(R.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ae(e,i)}async emitTo(e,i,n){if(R.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return le(e,i,n)}_handleTauriEvent(e,i){return R.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new c(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new c(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new b(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new b(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===q.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof y?e:new y(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof y?e:e?new y(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof y?e:e?new y(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof f?e:new f(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:P(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof f?e:new f(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?P(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(o.WINDOW_RESIZED,i=>{i.payload=new b(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new c(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Ce(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new c(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new c(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new c(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var V;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(V||(V={}));var $;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})($||($={}));var J;(function(t){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"})(J||(J={}));var Z;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(Z||(Z={}));function Ie(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new c(t.position),size:new b(t.size),workArea:{position:new c(t.workArea.position),size:new b(t.workArea.size)}}}async function Le(){return s("plugin:window|primary_monitor").then(Ie)}function oe(){return new G(re(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function Y(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new G(new C(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const T=["tauri://created","tauri://error"];class G{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await Y()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return oe()}static async getAll(){return Y()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:k(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Q(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(T.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ae(e,i)}async emitTo(e,i,n){if(T.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return le(e,i,n)}_handleTauriEvent(e,i){return T.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new c(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new b(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof y?e:new y(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof f?e:new f(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new c(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new c(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new c(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function M(){const t=oe();return new m(t.label,{skip:!0})}async function K(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new m(e,{skip:!0})))}class m{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await K()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new m(n.label,{skip:!0}):null}static getCurrent(){return M()}static async getAll(){return K()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:k(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Q(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}Ee(m,[C,G]);function Ee(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const x=new Map,Re=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},Te=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};let a=1920,r=1080;try{const u=await Le();u?.size&&(a=u.size.width,r=u.size.height)}catch(u){console.warn("Failed to get monitor info, using defaults:",u)}switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:r-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:r-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(r-e)/2};default:return{x:a-t-n,y:r-e-n}}},ue=async t=>{const e=String(t.id),i=w.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=F(),a=`notice-${e}`;let r=`${n.routePrefix}/${t.type}?id=${t.id}`;Re(r)||(console.warn(`Invalid window URL: ${r}. Using fallback 404 page.`),r=n.notFoundUrl||"/404");const l=t.min_width||n.defaultWidth,u=t.min_height||n.defaultHeight,{x:v,y:W}=await Te(l,u,t.windowPosition);try{const p=new m(a,{url:r,title:t.title,width:l,height:u,x:v,y:W,resizable:!0,decorations:!0,skipTaskbar:!1,alwaysOnTop:!0});x.set(e,p),i.addActiveWindow(e),p.once("tauri://destroyed",async()=>{x.delete(e),i.removeActiveWindow(e),await i.markMessageAsShown(e),i.clearCurrent()}),console.log(`Created notice window: ${a}`)}catch(p){console.error("Failed to create notice window:",p),i.removeActiveWindow(e),i.clearCurrent()}},I=async t=>{const e=String(t),i=x.get(e),n=w.getState();if(i)try{await i.close(),x.delete(e),n.removeActiveWindow(e),await n.markMessageAsShown(e),n.clearCurrent(),console.log(`Closed notice window: ${e}`)}catch(a){console.error("Failed to close notice window:",a)}},ce=async()=>{const t=Array.from(x.keys()).map(e=>I(e));await Promise.all(t)},we=()=>{let t=null;w.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,ue(i)):i||(t=null)}),console.log("Notice window system initialized")},qe=()=>{const t=w(i=>i.currentMessage);return{closeNotice:g.useCallback(async()=>{t&&await I(t.id)},[t])}},Fe=()=>{const t=w(i=>i.hideMessage);return{hideNotice:g.useCallback(async i=>{await t(i),await I(i)},[t])}},Be=()=>{const t=w(i=>i.clearOnLogout);return{hideAllNotices:g.useCallback(async()=>{await ce(),await t()},[t])}},Ue=()=>{const t=w(D.queueLength),e=w(D.currentMessage),i=w(D.isProcessing),n=w(D.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Qe=({children:t,onLoad:e,onClose:i})=>{const[n,a]=g.useState(null),[r,l]=g.useState(!0),[u,v]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const _=new URLSearchParams(window.location.search).get("id");if(!_){v("No message ID provided"),l(!1),setTimeout(async()=>{try{await M().close()}catch(S){console.error("Failed to close window:",S)}},1e3);return}const L=await U(_);if(!L){console.log(`Message ${_} not found in database, closing window`),v("Message not found"),l(!1),setTimeout(async()=>{try{await M().close()}catch(S){console.error("Failed to close window:",S)}},500);return}a(L),l(!1),e&&e(L)}catch(p){console.error("Failed to load message:",p),v("Failed to load message"),l(!1),setTimeout(async()=>{try{await M().close()}catch(_){console.error("Failed to close window:",_)}},1e3)}})()},[e]),g.useEffect(()=>{if(!n||!i)return;const W=()=>{i(n)};return window.addEventListener("beforeunload",W),()=>{window.removeEventListener("beforeunload",W)}},[n,i]),r?N.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):u?N.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:u}):n?N.jsx(N.Fragment,{children:t(n)}):N.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:"Closing window..."})},Ge=async()=>{B(),we();const{initializeFromDatabase:t}=w.getState();await t(),console.log("Tauri Notice System initialized")};exports.NoticeLayout=Qe;exports.closeAllNoticeWindows=ce;exports.closeNoticeWindow=I;exports.createNoticeWindow=ue;exports.getMessage=U;exports.getNoticeConfig=F;exports.getPendingMessages=te;exports.initializeDatabase=B;exports.initializeNoticeSystem=Ge;exports.initializeNoticeWindowSystem=we;exports.messageQueueSelectors=D;exports.setNoticeConfig=be;exports.useCloseNotice=qe;exports.useHideAllNotices=Be;exports.useHideNotice=Fe;exports.useMessageQueue=Ue;exports.useMessageQueueStore=w;exports.useNoticeWindow=xe;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|