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.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Window position configuration
3
+ */
4
+ export interface WindowPosition {
5
+ /** X coordinate (pixels from left edge) */
6
+ x?: number;
7
+ /** Y coordinate (pixels from top edge) */
8
+ y?: number;
9
+ /** Position preset: 'right-bottom' | 'right-top' | 'left-bottom' | 'left-top' | 'center' */
10
+ position?: 'right-bottom' | 'right-top' | 'left-bottom' | 'left-top' | 'center';
11
+ /** Padding from screen edges in pixels (default: 20) */
12
+ padding?: number;
13
+ }
14
+ /**
15
+ * Core message interface for notice windows
16
+ */
17
+ export interface MessageType {
18
+ /** Unique identifier for the message */
19
+ id: string;
20
+ /** Title of the notification */
21
+ title: string;
22
+ /** Type of message (lowercase), matches router path */
23
+ type: string;
24
+ /** Custom data payload for rendering */
25
+ data: any;
26
+ /** Minimum width for the notice window */
27
+ min_width?: number;
28
+ /** Minimum height for the notice window */
29
+ min_height?: number;
30
+ /** Window position configuration (default: right-bottom with 20px padding) */
31
+ windowPosition?: WindowPosition;
32
+ }
33
+ /**
34
+ * Extended message interface for database storage
35
+ */
36
+ export interface StoredMessage extends MessageType {
37
+ /** ISO timestamp when message was saved */
38
+ timestamp: string;
39
+ /** Whether the message has been read */
40
+ isRead: boolean;
41
+ /** Whether the message has been shown */
42
+ isShown: boolean;
43
+ /** Current queue status */
44
+ queueStatus: 'pending' | 'showing' | 'shown' | 'hidden';
45
+ /** Position in the queue (0-based) */
46
+ queuePosition: number;
47
+ }
48
+ /**
49
+ * Configuration options for notice windows
50
+ */
51
+ export interface NoticeConfig {
52
+ /** Router prefix for notice pages (default: '/notice') */
53
+ routePrefix: string;
54
+ /** Database name for persistence (default: 'tauri-notice-db') */
55
+ databaseName: string;
56
+ /** Default window width if not specified in message */
57
+ defaultWidth: number;
58
+ /** Default window height if not specified in message */
59
+ defaultHeight: number;
60
+ }
61
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,0CAA0C;IAC1C,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,cAAc,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC/E,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,IAAI,EAAE,GAAG,CAAA;IACT,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,cAAc,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAA;IACf,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,2BAA2B;IAC3B,WAAW,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;IACvD,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAA;IACnB,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAA;IACpB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAA;IACpB,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAA;CACtB"}
@@ -0,0 +1,65 @@
1
+ import Dexie, { type Table } from 'dexie';
2
+ import type { MessageType, StoredMessage } from '../types/message';
3
+ /**
4
+ * Dexie database for message persistence
5
+ */
6
+ declare class NoticeDatabase extends Dexie {
7
+ messages: Table<StoredMessage, string>;
8
+ constructor(databaseName: string);
9
+ }
10
+ /**
11
+ * Initialize the database with the configured name
12
+ */
13
+ export declare const initializeDatabase: () => NoticeDatabase;
14
+ /**
15
+ * Save a new message to the database
16
+ * @param message - Message to save
17
+ */
18
+ export declare const saveMessage: (message: MessageType) => Promise<void>;
19
+ /**
20
+ * Check if a message exists in the database
21
+ * @param id - Message ID to check
22
+ * @returns True if message exists
23
+ */
24
+ export declare const hasMessage: (id: string) => Promise<boolean>;
25
+ /**
26
+ * Get all pending messages sorted by queue position
27
+ * @returns Array of pending messages
28
+ */
29
+ export declare const getPendingMessages: () => Promise<StoredMessage[]>;
30
+ /**
31
+ * Update the queue status of a message
32
+ * @param id - Message ID
33
+ * @param status - New queue status
34
+ */
35
+ export declare const updateQueueStatus: (id: string, status: StoredMessage["queueStatus"]) => Promise<void>;
36
+ /**
37
+ * Mark a message as shown
38
+ * @param id - Message ID
39
+ */
40
+ export declare const markAsShown: (id: string) => Promise<void>;
41
+ /**
42
+ * Mark a message as hidden (server-triggered hide)
43
+ * @param id - Message ID
44
+ */
45
+ export declare const markAsHidden: (id: string) => Promise<void>;
46
+ /**
47
+ * Get a message by ID
48
+ * @param id - Message ID
49
+ * @returns The stored message or undefined
50
+ */
51
+ export declare const getMessage: (id: string) => Promise<StoredMessage | undefined>;
52
+ /**
53
+ * Clear all pending and showing messages
54
+ */
55
+ export declare const clearPendingMessages: () => Promise<void>;
56
+ /**
57
+ * Update queue positions for multiple messages
58
+ * @param messages - Array of messages with their positions
59
+ */
60
+ export declare const updateQueuePositions: (messages: Array<{
61
+ id: string;
62
+ position: number;
63
+ }>) => Promise<void>;
64
+ export {};
65
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/utils/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,KAAK,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGlE;;GAEG;AACH,cAAM,cAAe,SAAQ,KAAK;IAChC,QAAQ,EAAG,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;gBAE3B,YAAY,EAAE,MAAM;CAMjC;AAID;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAO,cAMrC,CAAA;AAYD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAUpE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAG5D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,aAAa,EAAE,CAKlE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,IAAI,MAAM,EACV,QAAQ,aAAa,CAAC,aAAa,CAAC,KACnC,OAAO,CAAC,IAAI,CAEd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAK1D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAI3D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAE9E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,IAAI,CAKzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,KAChD,OAAO,CAAC,IAAI,CAKd,CAAA"}
@@ -0,0 +1,21 @@
1
+ import type { MessageType } from '../types/message';
2
+ /**
3
+ * Create a new notice window for the given message
4
+ * @param message - Message to display in the window
5
+ */
6
+ export declare const createNoticeWindow: (message: MessageType) => Promise<void>;
7
+ /**
8
+ * Close a specific notice window by message ID
9
+ * @param messageId - ID of the message whose window should be closed
10
+ */
11
+ export declare const closeNoticeWindow: (messageId: string) => Promise<void>;
12
+ /**
13
+ * Close all active notice windows
14
+ */
15
+ export declare const closeAllNoticeWindows: () => Promise<void>;
16
+ /**
17
+ * Initialize the notice window system
18
+ * Sets up store subscription to auto-create windows when currentMessage changes
19
+ */
20
+ export declare const initializeNoticeWindowSystem: () => void;
21
+ //# sourceMappingURL=noticeWindow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noticeWindow.d.ts","sourceRoot":"","sources":["../../src/utils/noticeWindow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAA;AAsFnE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAU,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CA4D3E,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,WAAW,MAAM,KAAG,OAAO,CAAC,IAAI,CAavE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAa,OAAO,CAAC,IAAI,CAK1D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAO,IAiB/C,CAAA"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "tauri-notice-window",
3
+ "version": "1.0.0",
4
+ "description": "A reusable React library for cross-window notification management in Tauri v2+ applications",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "vite build && tsc --emitDeclarationOnly --outDir dist",
21
+ "dev": "vite build --watch",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "tauri",
26
+ "react",
27
+ "notification",
28
+ "window",
29
+ "queue",
30
+ "zustand",
31
+ "cross-window"
32
+ ],
33
+ "author": "",
34
+ "license": "MIT",
35
+ "peerDependencies": {
36
+ "react": "^19.2.0",
37
+ "react-dom": "^19.2.0"
38
+ },
39
+ "dependencies": {
40
+ "@tauri-apps/api": "^2.9.0",
41
+ "dexie": "^4.2.1",
42
+ "zustand": "^5.0.8",
43
+ "zustand-sync": "^0.2.3"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^24.9.1",
47
+ "@types/react": "^19.2.2",
48
+ "@types/react-dom": "^19.2.2",
49
+ "typescript": "^5.9.3",
50
+ "vite": "^7.1.12",
51
+ "vite-plugin-dts": "^4.5.4"
52
+ }
53
+ }