tauri-notice-window 1.0.0
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/LICENSE +22 -0
- package/README.md +422 -0
- package/dist/components/NoticeLayout.d.ts +22 -0
- package/dist/components/NoticeLayout.d.ts.map +1 -0
- package/dist/config/noticeConfig.d.ts +12 -0
- package/dist/config/noticeConfig.d.ts.map +1 -0
- package/dist/hooks/useCloseNotice.d.ts +9 -0
- package/dist/hooks/useCloseNotice.d.ts.map +1 -0
- package/dist/hooks/useHideAllNotices.d.ts +8 -0
- package/dist/hooks/useHideAllNotices.d.ts.map +1 -0
- package/dist/hooks/useHideNotice.d.ts +9 -0
- package/dist/hooks/useHideNotice.d.ts.map +1 -0
- package/dist/hooks/useMessageQueue.d.ts +11 -0
- package/dist/hooks/useMessageQueue.d.ts.map +1 -0
- package/dist/hooks/useNoticeWindow.d.ts +9 -0
- package/dist/hooks/useNoticeWindow.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2916 -0
- package/dist/index.js.map +1 -0
- package/dist/stores/messageQueueStore.d.ts +36 -0
- package/dist/stores/messageQueueStore.d.ts.map +1 -0
- package/dist/types/message.d.ts +61 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/utils/db.d.ts +65 -0
- package/dist/utils/db.d.ts.map +1 -0
- package/dist/utils/noticeWindow.d.ts +21 -0
- package/dist/utils/noticeWindow.d.ts.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tauri Notice Window Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# Tauri Notice Window
|
|
2
|
+
|
|
3
|
+
A reusable React library for cross-window notification management in Tauri v2+ applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Cross-Window State Sync**: All Tauri windows (main + notice windows) see the same state via `zustand-sync`
|
|
8
|
+
- **Persistent Queue**: Messages survive app restarts with IndexedDB (Dexie)
|
|
9
|
+
- **One-at-a-Time Display**: Only one notice window shown at a time
|
|
10
|
+
- **Customizable Routes**: Configurable router prefix for notice pages
|
|
11
|
+
- **Type Safety**: Full TypeScript support
|
|
12
|
+
- **Easy Integration**: Simple hooks API
|
|
13
|
+
- **Tauri v2 Ready**: Uses latest Tauri v2 window APIs
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install tauri-notice-window
|
|
19
|
+
# or
|
|
20
|
+
yarn add tauri-notice-window
|
|
21
|
+
# or
|
|
22
|
+
pnpm add tauri-notice-window
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### 1. Initialize the System
|
|
28
|
+
|
|
29
|
+
In your main app component or layout:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { useEffect } from 'react'
|
|
33
|
+
import { initializeNoticeSystem, setNoticeConfig } from 'tauri-notice-window'
|
|
34
|
+
|
|
35
|
+
function App() {
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
// Optional: Configure before initialization
|
|
38
|
+
setNoticeConfig({
|
|
39
|
+
routePrefix: '/notice', // default
|
|
40
|
+
databaseName: 'tauri-notice-db', // default
|
|
41
|
+
defaultWidth: 400, // default width of the notice window
|
|
42
|
+
defaultHeight: 300, // default height of the notice window
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Initialize the system
|
|
46
|
+
initializeNoticeSystem()
|
|
47
|
+
}, [])
|
|
48
|
+
|
|
49
|
+
return <YourApp />
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Show a Notice
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { useNoticeWindow } from 'tauri-notice-window'
|
|
57
|
+
|
|
58
|
+
function SocketHandler() {
|
|
59
|
+
const { showNotice } = useNoticeWindow()
|
|
60
|
+
|
|
61
|
+
const handleMessage = async (data) => {
|
|
62
|
+
await showNotice({
|
|
63
|
+
id: data.id,
|
|
64
|
+
title: data.title,
|
|
65
|
+
type: 'announcement', // lowercase, matches route
|
|
66
|
+
data: data.content,
|
|
67
|
+
min_width: 400,
|
|
68
|
+
min_height: 300,
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return <div>...</div>
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Create Notice Pages
|
|
77
|
+
|
|
78
|
+
Create a route for each message type. For example, `/notice/announcement`:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { NoticeLayout, useCloseNotice } from 'tauri-notice-window'
|
|
82
|
+
|
|
83
|
+
export default function AnnouncementNotice() {
|
|
84
|
+
const { closeNotice } = useCloseNotice()
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<NoticeLayout>
|
|
88
|
+
{(message) => (
|
|
89
|
+
<div className="notice-container">
|
|
90
|
+
<h1>{message.title}</h1>
|
|
91
|
+
<div>{message.data.content}</div>
|
|
92
|
+
<button onClick={closeNotice}>OK</button>
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
</NoticeLayout>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## API Reference
|
|
101
|
+
|
|
102
|
+
### Types
|
|
103
|
+
|
|
104
|
+
#### MessageType
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
interface MessageType {
|
|
108
|
+
id: string // Unique message ID
|
|
109
|
+
title: string // Notice title
|
|
110
|
+
type: string // Message type (lowercase, matches route)
|
|
111
|
+
data: any // Custom data payload
|
|
112
|
+
min_width?: number // Minimum window width
|
|
113
|
+
min_height?: number // Minimum window height
|
|
114
|
+
windowPosition?: WindowPosition // Window position (default: right-bottom)
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### WindowPosition
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
interface WindowPosition {
|
|
122
|
+
x?: number // X coordinate (pixels from left)
|
|
123
|
+
y?: number // Y coordinate (pixels from top)
|
|
124
|
+
position?: 'right-bottom' | 'right-top' | 'left-bottom' | 'left-top' | 'center'
|
|
125
|
+
padding?: number // Padding from screen edges (default: 20px)
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### NoticeConfig
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
interface NoticeConfig {
|
|
133
|
+
routePrefix: string // Route prefix (default: '/notice')
|
|
134
|
+
databaseName: string // Database name (default: 'tauri-notice-db')
|
|
135
|
+
defaultWidth: number // Default window width (default: 400)
|
|
136
|
+
defaultHeight: number // Default window height (default: 300)
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Hooks
|
|
141
|
+
|
|
142
|
+
#### useNoticeWindow()
|
|
143
|
+
|
|
144
|
+
Opens a new notice window.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const { showNotice } = useNoticeWindow()
|
|
148
|
+
await showNotice(message)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### useCloseNotice()
|
|
152
|
+
|
|
153
|
+
Closes the current notice window (call from within notice page).
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const { closeNotice } = useCloseNotice()
|
|
157
|
+
await closeNotice()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### useHideNotice()
|
|
161
|
+
|
|
162
|
+
Hides a specific notice by ID (typically for server-triggered hide events).
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const { hideNotice } = useHideNotice()
|
|
166
|
+
await hideNotice(messageId)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### useHideAllNotices()
|
|
170
|
+
|
|
171
|
+
Clears all pending and active notices.
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const { hideAllNotices } = useHideAllNotices()
|
|
175
|
+
await hideAllNotices()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### useMessageQueue()
|
|
179
|
+
|
|
180
|
+
Access queue state for UI display.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const { queueLength, currentMessage, isProcessing, queue } = useMessageQueue()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Components
|
|
187
|
+
|
|
188
|
+
#### NoticeLayout
|
|
189
|
+
|
|
190
|
+
Wrapper component for notice pages that loads the message and provides it to children.
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
interface NoticeLayoutProps {
|
|
194
|
+
children: (message: MessageType) => ReactNode
|
|
195
|
+
onLoad?: (message: MessageType) => void
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
<NoticeLayout onLoad={(msg) => console.log('Loaded:', msg)}>
|
|
199
|
+
{(message) => <YourCustomUI message={message} />}
|
|
200
|
+
</NoticeLayout>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Functions
|
|
204
|
+
|
|
205
|
+
#### initializeNoticeSystem()
|
|
206
|
+
|
|
207
|
+
Initialize the complete system. Call once during app startup.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
await initializeNoticeSystem()
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### setNoticeConfig()
|
|
214
|
+
|
|
215
|
+
Configure the notice window system.
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
setNoticeConfig({
|
|
219
|
+
routePrefix: '/notifications',
|
|
220
|
+
databaseName: 'my-app-notices',
|
|
221
|
+
defaultWidth: 500,
|
|
222
|
+
defaultHeight: 400,
|
|
223
|
+
})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Routing Setup
|
|
227
|
+
|
|
228
|
+
The library expects routes to match the pattern: `{routePrefix}/{message.type}`
|
|
229
|
+
|
|
230
|
+
### Next.js App Router Example
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
app/
|
|
234
|
+
notice/
|
|
235
|
+
announcement/
|
|
236
|
+
page.tsx
|
|
237
|
+
alert/
|
|
238
|
+
page.tsx
|
|
239
|
+
chat/
|
|
240
|
+
page.tsx
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### React Router Example
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
<Routes>
|
|
247
|
+
<Route path="/notice/announcement" element={<AnnouncementNotice />} />
|
|
248
|
+
<Route path="/notice/alert" element={<AlertNotice />} />
|
|
249
|
+
<Route path="/notice/chat" element={<ChatNotice />} />
|
|
250
|
+
</Routes>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Advanced Usage
|
|
254
|
+
|
|
255
|
+
### Server-Triggered Hide
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { useHideNotice } from 'tauri-notice-window'
|
|
259
|
+
|
|
260
|
+
function SocketHandler() {
|
|
261
|
+
const { hideNotice } = useHideNotice()
|
|
262
|
+
|
|
263
|
+
socket.on('hide_message', async (data) => {
|
|
264
|
+
await hideNotice(data.message_id)
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Logout Cleanup
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import { useHideAllNotices } from 'tauri-notice-window'
|
|
273
|
+
|
|
274
|
+
function LogoutButton() {
|
|
275
|
+
const { hideAllNotices } = useHideAllNotices()
|
|
276
|
+
|
|
277
|
+
const handleLogout = async () => {
|
|
278
|
+
// Clear all notices
|
|
279
|
+
await hideAllNotices()
|
|
280
|
+
|
|
281
|
+
// Clear auth and redirect
|
|
282
|
+
await clearAuth()
|
|
283
|
+
navigate('/login')
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Custom Window Sizing and Positioning
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
// Default: right-bottom with 20px padding
|
|
292
|
+
await showNotice({
|
|
293
|
+
id: '123',
|
|
294
|
+
title: 'Default Position',
|
|
295
|
+
type: 'announcement',
|
|
296
|
+
data: { content: 'Appears at right-bottom' },
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
// Custom size
|
|
300
|
+
await showNotice({
|
|
301
|
+
id: '124',
|
|
302
|
+
title: 'Large Notice',
|
|
303
|
+
type: 'announcement',
|
|
304
|
+
data: { content: 'Important message' },
|
|
305
|
+
min_width: 800,
|
|
306
|
+
min_height: 600,
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
// Position preset: top-right
|
|
310
|
+
await showNotice({
|
|
311
|
+
id: '125',
|
|
312
|
+
title: 'Top Right',
|
|
313
|
+
type: 'alert',
|
|
314
|
+
data: { content: 'Alert message' },
|
|
315
|
+
windowPosition: { position: 'right-top' },
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
// Position preset with custom padding
|
|
319
|
+
await showNotice({
|
|
320
|
+
id: '126',
|
|
321
|
+
title: 'Left Bottom',
|
|
322
|
+
type: 'announcement',
|
|
323
|
+
data: { content: 'Custom padding' },
|
|
324
|
+
windowPosition: {
|
|
325
|
+
position: 'left-bottom',
|
|
326
|
+
padding: 50 // 50px from edges
|
|
327
|
+
},
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
// Custom coordinates
|
|
331
|
+
await showNotice({
|
|
332
|
+
id: '127',
|
|
333
|
+
title: 'Custom Position',
|
|
334
|
+
type: 'announcement',
|
|
335
|
+
data: { content: 'Exact position' },
|
|
336
|
+
windowPosition: {
|
|
337
|
+
x: 100, // 100px from left
|
|
338
|
+
y: 100, // 100px from top
|
|
339
|
+
},
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
// Centered window
|
|
343
|
+
await showNotice({
|
|
344
|
+
id: '128',
|
|
345
|
+
title: 'Centered',
|
|
346
|
+
type: 'announcement',
|
|
347
|
+
data: { content: 'In the middle' },
|
|
348
|
+
windowPosition: { position: 'center' },
|
|
349
|
+
})
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Queue Status Display
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { useMessageQueue } from 'tauri-notice-window'
|
|
356
|
+
|
|
357
|
+
function QueueIndicator() {
|
|
358
|
+
const { queueLength, currentMessage } = useMessageQueue()
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<div>
|
|
362
|
+
{queueLength > 0 && (
|
|
363
|
+
<span>Pending notifications: {queueLength}</span>
|
|
364
|
+
)}
|
|
365
|
+
{currentMessage && (
|
|
366
|
+
<span>Currently showing: {currentMessage.title}</span>
|
|
367
|
+
)}
|
|
368
|
+
</div>
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## How It Works
|
|
374
|
+
|
|
375
|
+
### Cross-Window Synchronization
|
|
376
|
+
|
|
377
|
+
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.
|
|
378
|
+
|
|
379
|
+
```
|
|
380
|
+
Main Window Notice Window 1 Notice Window 2
|
|
381
|
+
| | |
|
|
382
|
+
├── enqueue(msg) ─────────► │ │
|
|
383
|
+
│ │ │
|
|
384
|
+
▼ ▼ ▼
|
|
385
|
+
Zustand Store ◄─────────► localStorage ◄─────────► Zustand Store
|
|
386
|
+
| | |
|
|
387
|
+
▼ ▼ ▼
|
|
388
|
+
State Updated State Updated State Updated
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Message Lifecycle
|
|
392
|
+
|
|
393
|
+
1. **pending**: Message is in queue, waiting to be shown
|
|
394
|
+
2. **showing**: Message window is currently displayed
|
|
395
|
+
3. **shown**: User has acknowledged the message
|
|
396
|
+
4. **hidden**: Server requested to hide the message
|
|
397
|
+
|
|
398
|
+
### Persistence
|
|
399
|
+
|
|
400
|
+
Messages are persisted to IndexedDB via Dexie. On app restart:
|
|
401
|
+
1. Database is initialized
|
|
402
|
+
2. Pending messages are loaded
|
|
403
|
+
3. First message is shown automatically
|
|
404
|
+
|
|
405
|
+
## Requirements
|
|
406
|
+
|
|
407
|
+
- Tauri v2.0+
|
|
408
|
+
- React 19+
|
|
409
|
+
- Modern browsers with IndexedDB support
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
MIT
|
|
414
|
+
|
|
415
|
+
## Contributing
|
|
416
|
+
|
|
417
|
+
Contributions welcome! Please open an issue or PR on GitHub.
|
|
418
|
+
|
|
419
|
+
## Support
|
|
420
|
+
|
|
421
|
+
For issues and questions, please open an issue on GitHub.
|
|
422
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { MessageType } from '../types/message';
|
|
3
|
+
/**
|
|
4
|
+
* Props for NoticeLayout component
|
|
5
|
+
*/
|
|
6
|
+
interface NoticeLayoutProps {
|
|
7
|
+
/**
|
|
8
|
+
* Render function that receives the current message
|
|
9
|
+
*/
|
|
10
|
+
children: (message: MessageType) => ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Optional callback when message is loaded
|
|
13
|
+
*/
|
|
14
|
+
onLoad?: (message: MessageType) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Layout component for notice windows
|
|
18
|
+
* Loads the message from database/URL and provides it to children
|
|
19
|
+
*/
|
|
20
|
+
export declare const NoticeLayout: ({ children, onLoad }: NoticeLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=NoticeLayout.d.ts.map
|
|
@@ -0,0 +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;AAGnD;;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;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CA0EnE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NoticeConfig } from '../types/message';
|
|
2
|
+
/**
|
|
3
|
+
* Update notice window configuration
|
|
4
|
+
* @param newConfig - Partial configuration to merge with current config
|
|
5
|
+
*/
|
|
6
|
+
export declare const setNoticeConfig: (newConfig: Partial<NoticeConfig>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Get current notice window configuration
|
|
9
|
+
* @returns Current configuration object
|
|
10
|
+
*/
|
|
11
|
+
export declare const getNoticeConfig: () => NoticeConfig;
|
|
12
|
+
//# sourceMappingURL=noticeConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noticeConfig.d.ts","sourceRoot":"","sources":["../../src/config/noticeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAYpD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,OAAO,CAAC,YAAY,CAAC,KAAG,IAElE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,YAElC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to close the current notice window
|
|
3
|
+
* Should be called from within a notice window component
|
|
4
|
+
* @returns Object with closeNotice function
|
|
5
|
+
*/
|
|
6
|
+
export declare const useCloseNotice: () => {
|
|
7
|
+
closeNotice: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useCloseNotice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCloseNotice.d.ts","sourceRoot":"","sources":["../../src/hooks/useCloseNotice.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,cAAc;;CAU1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHideAllNotices.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideAllNotices.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;CAY7B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to hide a specific notice by ID
|
|
3
|
+
* Typically used for server-triggered hide events
|
|
4
|
+
* @returns Object with hideNotice function
|
|
5
|
+
*/
|
|
6
|
+
export declare const useHideNotice: () => {
|
|
7
|
+
hideNotice: (messageId: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useHideNotice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHideNotice.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideNotice.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,aAAa;4BAIJ,MAAM;CAgB3B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to access message queue state
|
|
3
|
+
* @returns Queue state information
|
|
4
|
+
*/
|
|
5
|
+
export declare const useMessageQueue: () => {
|
|
6
|
+
queueLength: number;
|
|
7
|
+
currentMessage: import("..").MessageType | null;
|
|
8
|
+
isProcessing: boolean;
|
|
9
|
+
queue: import("..").MessageType[];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useMessageQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMessageQueue.d.ts","sourceRoot":"","sources":["../../src/hooks/useMessageQueue.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;CAY3B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MessageType } from '../types/message';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to open notice windows
|
|
4
|
+
* @returns Object with showNotice function
|
|
5
|
+
*/
|
|
6
|
+
export declare const useNoticeWindow: () => {
|
|
7
|
+
showNotice: (message: MessageType) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useNoticeWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNoticeWindow.d.ts","sourceRoot":"","sources":["../../src/hooks/useNoticeWindow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;;GAGG;AACH,eAAO,MAAM,eAAe;0BAIR,WAAW;CAO9B,CAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("zustand"),he=require("zustand-sync"),be=require("dexie"),g=require("react"),z=require("react/jsx-runtime");let L={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300};const ge=t=>{L={...L,...t}},E=()=>({...L});class ye extends be{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let v=null;const q=()=>{if(!v){const t=E();v=new ye(t.databaseName)}return v},h=()=>v||q(),J=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await h().messages.put(e)},Z=async t=>!!await h().messages.get(t),Y=async()=>await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),pe=async(t,e)=>{await h().messages.update(t,{queueStatus:e})},K=async t=>{await h().messages.update(t,{queueStatus:"shown",isShown:!0})},X=async t=>{await h().messages.update(t,{queueStatus:"hidden"})},ee=async t=>await h().messages.get(t),te=async()=>{await h().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},_e=async t=>{const e=t.map(i=>h().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},fe=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await Z(i.id)||await J(i),!n.queue.some(l=>l.id===i.id)){const l=[...n.queue,i];t({queue:l}),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 pe(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 Y();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await _e(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await te()},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=we.create()(he.syncTabs(fe,{name:"tauri-notice-queue"})),m={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},me=()=>{const t=d(i=>i.enqueue);return{showNotice:g.useCallback(async i=>{await t(i)},[t])}};function ve(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 We(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 S;const w="__TAURI_TO_IPC_KEY__";function Ne(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 De{get rid(){return ve(this,S,"f")}constructor(e){S.set(this,void 0),We(this,S,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}S=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 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 ie(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 ie?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 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 u(this.x*e,this.y*e)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class u{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)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class _{constructor(e){this.position=e}toLogical(e){return this.position instanceof ne?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?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 se(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:Ne(e)}).then(r=>async()=>se(t,r))}async function T(t,e,i){return P(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 W extends De{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:A(e),width:i,height:n}).then(a=>new W(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:A(e)}).then(i=>new W(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new W(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 A(t){return t==null?null:typeof t=="string"?t:t instanceof W?t.rid:t}var R;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(R||(R={}));class ze{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 re(){return new O(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function M(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}const I=["tauri://created","tauri://error"];class O{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 M()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return re()}static async getAll(){return M()}static async getFocusedWindow(){for(const e of await M())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)}:T(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(I.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(I.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 I.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 u(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new u(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:A(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?A(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 u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new ze(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 u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(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 U;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(U||(U={}));var G;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(G||(G={}));var Q;(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"})(Q||(Q={}));var j;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(j||(j={}));function Se(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new y(t.size),workArea:{position:new u(t.workArea.position),size:new y(t.workArea.size)}}}async function Ae(){return s("plugin:window|primary_monitor").then(Se)}function oe(){return new F(re(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function V(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new F(new O(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const C=["tauri://created","tauri://error"];class F{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 V()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return oe()}static async getAll(){return V()}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)}:T(e,i,{target:{kind:"Webview",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 ae(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 le(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 position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new u(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 u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function Pe(){const t=oe();return new f(t.label,{skip:!0})}async function $(){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 $()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new f(n.label,{skip:!0}):null}static getCurrent(){return Pe()}static async getAll(){return $()}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)}:T(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}))}}Oe(f,[O,F]);function Oe(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 N=new Map,xe=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 c=await Ae();c?.size&&(a=c.size.width,r=c.size.height)}catch(c){console.warn("Failed to get monitor info, using defaults:",c)}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=d.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=E(),a=`notice-${e}`,r=`${n.routePrefix}/${t.type}?id=${t.id}`,l=t.min_width||n.defaultWidth,c=t.min_height||n.defaultHeight,{x:B,y:D}=await xe(l,c,t.windowPosition);try{const p=new f(a,{url:r,title:t.title,width:l,height:c,x:B,y:D,resizable:!0,decorations:!0,skipTaskbar:!1,alwaysOnTop:!0});N.set(e,p),i.addActiveWindow(e),p.once("tauri://destroyed",async()=>{N.delete(e),i.removeActiveWindow(e),await K(e),i.clearCurrent()}),console.log(`Created notice window: ${a}`)}catch(p){console.error("Failed to create notice window:",p),i.removeActiveWindow(e),i.clearCurrent()}},x=async t=>{const e=String(t),i=N.get(e);if(i)try{await i.close(),N.delete(e),console.log(`Closed notice window: ${e}`)}catch(n){console.error("Failed to close notice window:",n)}},ce=async()=>{const t=Array.from(N.keys()).map(e=>x(e));await Promise.all(t)},de=()=>{let t=null;d.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,ue(i)):i||(t=null)}),console.log("Notice window system initialized")},ke=()=>{const t=d(i=>i.currentMessage);return{closeNotice:g.useCallback(async()=>{t&&await x(t.id)},[t])}},Me=()=>{const t=d();return{hideNotice:g.useCallback(async i=>{await X(i),await x(i),t.currentMessage?.id===i&&t.clearCurrent()},[t])}},Ie=()=>{const t=d(i=>i.clearOnLogout);return{hideAllNotices:g.useCallback(async()=>{await ce(),await t()},[t])}},Ce=()=>{const t=d(m.queueLength),e=d(m.currentMessage),i=d(m.isProcessing),n=d(m.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Le=({children:t,onLoad:e})=>{const[i,n]=g.useState(null),[a,r]=g.useState(!0),[l,c]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const p=new URLSearchParams(window.location.search).get("id");if(!p){c("No message ID provided"),r(!1);return}const k=await ee(p);if(!k){c("Message not found"),r(!1);return}n(k),r(!1),e&&e(k)}catch(D){console.error("Failed to load message:",D),c("Failed to load message"),r(!1)}})()},[e]),a?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):l||!i?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:l||"Message not found"}):z.jsx(z.Fragment,{children:t(i)})},Re=async()=>{q(),de();const{initializeFromDatabase:t}=d.getState();await t(),console.log("Tauri Notice System initialized")};exports.NoticeLayout=Le;exports.clearPendingMessages=te;exports.closeAllNoticeWindows=ce;exports.closeNoticeWindow=x;exports.createNoticeWindow=ue;exports.getMessage=ee;exports.getNoticeConfig=E;exports.getPendingMessages=Y;exports.hasMessage=Z;exports.initializeDatabase=q;exports.initializeNoticeSystem=Re;exports.initializeNoticeWindowSystem=de;exports.markAsHidden=X;exports.markAsShown=K;exports.messageQueueSelectors=m;exports.saveMessage=J;exports.setNoticeConfig=ge;exports.useCloseNotice=ke;exports.useHideAllNotices=Ie;exports.useHideNotice=Me;exports.useMessageQueue=Ce;exports.useMessageQueueStore=d;exports.useNoticeWindow=me;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|