tauri-notice-window 1.0.26 → 1.1.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/README.md +73 -0
- package/dist/config/noticeConfig.d.ts.map +1 -1
- package/dist/hooks/useNoticeStack.d.ts +8 -0
- package/dist/hooks/useNoticeStack.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +524 -398
- package/dist/index.js.map +1 -1
- package/dist/stores/noticeStackStore.d.ts +12 -0
- package/dist/stores/noticeStackStore.d.ts.map +1 -0
- package/dist/types/message.d.ts +7 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/stack.d.ts +25 -0
- package/dist/types/stack.d.ts.map +1 -0
- package/dist/utils/noticeStackWindow.d.ts +14 -0
- package/dist/utils/noticeStackWindow.d.ts.map +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -581,6 +581,79 @@ export default function DevNotFound() {
|
|
|
581
581
|
}
|
|
582
582
|
```
|
|
583
583
|
|
|
584
|
+
## Stack Mode (One Window, Multiple Notices)
|
|
585
|
+
|
|
586
|
+
Use stack mode when you want many incoming notices to be shown inside one shared window (instead of opening one window per message).
|
|
587
|
+
|
|
588
|
+
### 1. Configure stack route and window label
|
|
589
|
+
|
|
590
|
+
```typescript
|
|
591
|
+
import { initializeNoticeSystem, setNoticeConfig } from 'tauri-notice-window'
|
|
592
|
+
|
|
593
|
+
setNoticeConfig({
|
|
594
|
+
routePrefix: '/notices',
|
|
595
|
+
stackRoute: '/notices/stack',
|
|
596
|
+
stackWindowLabel: 'notice-stack',
|
|
597
|
+
stackWindowOptions: {
|
|
598
|
+
width: 380,
|
|
599
|
+
height: 520,
|
|
600
|
+
decorations: false,
|
|
601
|
+
resizable: true,
|
|
602
|
+
alwaysOnTop: true,
|
|
603
|
+
},
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
await initializeNoticeSystem()
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### 2. Push notices into the shared stack window
|
|
610
|
+
|
|
611
|
+
```typescript
|
|
612
|
+
import { pushToNoticeStack } from 'tauri-notice-window'
|
|
613
|
+
|
|
614
|
+
socket.on('message', async (message) => {
|
|
615
|
+
await pushToNoticeStack({
|
|
616
|
+
id: String(message.uuid || message.id),
|
|
617
|
+
uuid: message.uuid ? String(message.uuid) : undefined,
|
|
618
|
+
type: message.type,
|
|
619
|
+
routeType: message.type, // Optional: defaults to type
|
|
620
|
+
title: message.title,
|
|
621
|
+
data: message.data,
|
|
622
|
+
})
|
|
623
|
+
})
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### 3. Build the stack page in your app (headless ownership)
|
|
627
|
+
|
|
628
|
+
Create your own UI at the configured route (for example `/notices/stack`) and use the hook:
|
|
629
|
+
|
|
630
|
+
```typescript
|
|
631
|
+
import { useNoticeStack } from 'tauri-notice-window'
|
|
632
|
+
|
|
633
|
+
export default function NoticeStackPage() {
|
|
634
|
+
const { items, total, removeItem, clearAll, closeWindow } = useNoticeStack()
|
|
635
|
+
|
|
636
|
+
return (
|
|
637
|
+
<div>
|
|
638
|
+
<h2>Notifications ({total})</h2>
|
|
639
|
+
<button onClick={clearAll}>Clear All</button>
|
|
640
|
+
<button onClick={closeWindow}>Close</button>
|
|
641
|
+
|
|
642
|
+
{items.map((item) => (
|
|
643
|
+
<div key={item.id}>
|
|
644
|
+
<div>{item.title}</div>
|
|
645
|
+
<button onClick={() => removeItem(item.id)}>Dismiss</button>
|
|
646
|
+
</div>
|
|
647
|
+
))}
|
|
648
|
+
</div>
|
|
649
|
+
)
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### 4. Tauri capability note
|
|
654
|
+
|
|
655
|
+
If your capability already allows `notice-*`, then the default `stackWindowLabel: 'notice-stack'` is already covered.
|
|
656
|
+
|
|
584
657
|
## API Reference
|
|
585
658
|
|
|
586
659
|
### Types
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"noticeConfig.d.ts","sourceRoot":"","sources":["../../src/config/noticeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA0DpD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,OAAO,CAAC,YAAY,CAAC,KAAG,IAIlE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,YAElC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNoticeStack.d.ts","sourceRoot":"","sources":["../../src/hooks/useNoticeStack.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc;;;qBA2BW,MAAM;;;CAmB3C,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const We=require("zustand"),Ne=require("zustand-sync"),ze=require("dexie"),c=require("react"),k=require("react/jsx-runtime"),ce="tauri-notice-config",U={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404",defaultDecorations:!0,loadTimeout:4e3,autoSize:!0,maxWidth:600,maxHeight:800,autoSizeTimeout:3e3},de=()=>{if(typeof window>"u")return U;try{const t=localStorage.getItem(ce);if(t)return{...U,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return U},Ae=t=>{if(!(typeof window>"u"))try{localStorage.setItem(ce,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},xe=t=>{const i={...de(),...t};Ae(i)},D=()=>de();class Me extends ze{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let R=null;const J=()=>{if(!R){const t=D();R=new Me(t.databaseName)}return R},m=()=>R||J(),De=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await m().messages.put(e)},Oe=async t=>!!await m().messages.get(t),Ce=async t=>{const e=await m().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},we=async()=>await m().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),Pe=async(t,e)=>{await m().messages.update(t,{queueStatus:e})},Ie=async t=>{await m().messages.update(t,{queueStatus:"shown",isShown:!0})},ke=async t=>{await m().messages.update(t,{queueStatus:"hidden"})},Z=async t=>await m().messages.get(t),Le=async t=>{await m().messages.delete(t)},Re=async()=>{await m().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},Te=async t=>{const e=t.map(i=>m().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Ee=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await Ce(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await Oe(i.id)||await De(i),!n.queue.some(y=>y.id===i.id)){const y=[...n.queue,i];t({queue:y}),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 Z(n.id)){console.log(`Message ${n.id} was deleted, skipping to next`),await e().showNext();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 we();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,l)=>({id:a.id,position:l}));await Te(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await Re()},removeFromQueue:async i=>{const n=e(),a=n.queue.filter(l=>l.id!==i);t({queue:a}),await e().persistQueue(),n.currentMessage?.id===i&&e().clearCurrent()},deleteMessage:async i=>{await Le(i),await e().removeFromQueue(i)},hideMessage:async i=>{await ke(i),await e().removeFromQueue(i)},markMessageAsShown:async i=>{await Ie(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(l=>l!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),w=We.create()(Ne.syncTabs(Ee,{name:"tauri-notice-queue"})),L={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},qe=()=>{const t=w(i=>i.enqueue);return{showNotice:c.useCallback(async i=>{await t(i)},[t])}};function Fe(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 Be(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 q;const f="__TAURI_TO_IPC_KEY__";function He(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 $e{get rid(){return Fe(this,q,"f")}constructor(e){q.set(this,void 0),Be(this,q,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}q=new WeakMap;class Y{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 N(this.width*e,this.height*e)}[f](){return{width:this.width,height:this.height}}toJSON(){return this[f]()}}class N{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 Y(this.width/e,this.height/e)}[f](){return{width:this.width,height:this.height}}toJSON(){return this[f]()}}class W{constructor(e){this.size=e}toLogical(e){return this.size instanceof Y?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof N?this.size:this.size.toPhysical(e)}[f](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[f]()}}class K{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 g(this.x*e,this.y*e)}[f](){return{x:this.x,y:this.y}}toJSON(){return this[f]()}}class g{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 K(this.x/e,this.y/e)}[f](){return{x:this.x,y:this.y}}toJSON(){return this[f]()}}class M{constructor(e){this.position=e}toLogical(e){return this.position instanceof K?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof g?this.position:this.position.toPhysical(e)}[f](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[f]()}}var d;(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"})(d||(d={}));async function he(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function B(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:He(e)}).then(l=>async()=>he(t,l))}async function X(t,e,i){return B(t,n=>{he(t,n.id),e(n)},i)}async function ge(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ye(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class T extends $e{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:F(e),width:i,height:n}).then(a=>new T(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:F(e)}).then(i=>new T(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new T(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 F(t){return t==null?null:typeof t=="string"?t:t instanceof T?t.rid:t}var V;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(V||(V={}));class Ue{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var ne;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(ne||(ne={}));function be(){return new H(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Q(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new H(e,{skip:!0})))}const G=["tauri://created","tauri://error"];class H{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 Q()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return be()}static async getAll(){return Q()}static async getFocusedWindow(){for(const e of await Q())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)}:B(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)}:X(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(G.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ge(e,i)}async emitTo(e,i,n){if(G.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ye(e,i,n)}_handleTauriEvent(e,i){return G.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 g(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new g(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new N(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new N(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===V.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 W?e:new W(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof W?e:e?new W(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof W?e:e?new W(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 M?e:new M(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:F(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 M?e:new M(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?F(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(d.WINDOW_RESIZED,i=>{i.payload=new N(i.payload),e(i)})}async onMoved(e){return this.listen(d.WINDOW_MOVED,i=>{i.payload=new g(i.payload),e(i)})}async onCloseRequested(e){return this.listen(d.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Ue(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(d.DRAG_ENTER,o=>{e({...o,payload:{type:"enter",paths:o.payload.paths,position:new g(o.payload.position)}})}),n=await this.listen(d.DRAG_OVER,o=>{e({...o,payload:{type:"over",position:new g(o.payload.position)}})}),a=await this.listen(d.DRAG_DROP,o=>{e({...o,payload:{type:"drop",paths:o.payload.paths,position:new g(o.payload.position)}})}),l=await this.listen(d.DRAG_LEAVE,o=>{e({...o,payload:{type:"leave"}})});return()=>{i(),a(),n(),l()}}async onFocusChanged(e){const i=await this.listen(d.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(d.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(d.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(d.WINDOW_THEME_CHANGED,e)}}var se;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(se||(se={}));var ae;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ae||(ae={}));var oe;(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"})(oe||(oe={}));var re;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(re||(re={}));function Qe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new g(t.position),size:new N(t.size),workArea:{position:new g(t.workArea.position),size:new N(t.workArea.size)}}}async function Ge(){return s("plugin:window|primary_monitor").then(Qe)}function pe(){return new ee(be(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function le(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new ee(new H(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const j=["tauri://created","tauri://error"];class ee{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 le()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return pe()}static async getAll(){return le()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:B(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)}:X(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(j.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ge(e,i)}async emitTo(e,i,n){if(j.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ye(e,i,n)}_handleTauriEvent(e,i){return j.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 g(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new N(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 W?e:new W(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof M?e:new M(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(d.DRAG_ENTER,o=>{e({...o,payload:{type:"enter",paths:o.payload.paths,position:new g(o.payload.position)}})}),n=await this.listen(d.DRAG_OVER,o=>{e({...o,payload:{type:"over",position:new g(o.payload.position)}})}),a=await this.listen(d.DRAG_DROP,o=>{e({...o,payload:{type:"drop",paths:o.payload.paths,position:new g(o.payload.position)}})}),l=await this.listen(d.DRAG_LEAVE,o=>{e({...o,payload:{type:"leave"}})});return()=>{i(),a(),n(),l()}}}function A(){const t=pe();return new O(t.label,{skip:!0})}async function ue(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}class O{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 ue()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new O(n.label,{skip:!0}):null}static getCurrent(){return A()}static async getAll(){return ue()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:B(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)}:X(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}))}}je(O,[H,ee]);function je(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 E=new Map,Ve=()=>navigator.platform.toLowerCase().includes("mac")||navigator.userAgent.toLowerCase().includes("mac"),Je=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},fe=async()=>{let t=1920,e=1080;try{const i=await Ge();if(i?.size){const n=i.scaleFactor||1;t=i.size.width/n,e=i.size.height/n}}catch(i){console.warn("Failed to get monitor info, using defaults:",i)}return{screenWidth:t,screenHeight:e}},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};const{screenWidth:a,screenHeight:l}=await fe();switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:l-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:l-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(l-e)/2};default:return{x:a-t-n,y:l-e-n}}},me=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=D(),a=`notice-${e}`;let l=`${n.routePrefix}/${t.type}?id=${t.id}`;Je(l)||(console.warn(`Invalid window URL: ${l}. Using fallback 404 page.`),l=n.notFoundUrl||"/404");const o=n.autoSize??!0,y=t.min_width||n.defaultWidth,_=o?n.maxHeight??800:t.min_height||n.defaultHeight,b=t.decorations??n.defaultDecorations??!0,z=t.min_height||n.defaultHeight,{x:C,y:P}=await te(y,z,t.windowPosition);try{const h={url:l,title:t.title,width:y,height:_,x:C,y:P,resizable:!0,skipTaskbar:!1,alwaysOnTop:!0};o&&(h.visible=!1),b?h.decorations=!0:Ve()?(h.decorations=!0,h.titleBarStyle="overlay",h.hiddenTitle=!0):(h.decorations=!1,h.transparent=!0);const p=new O(a,h);E.set(e,p),i.addActiveWindow(e);let u=null;const v=n.loadTimeout??1e4;!b&&v>0&&(u=setTimeout(async()=>{console.warn(`Notice window ${a} load timeout - auto closing`);try{await p.close()}catch{}},v)),p.once("tauri://created",()=>{u&&(clearTimeout(u),u=null),console.log(`Notice window created successfully: ${a}`)}),p.once("tauri://error",async r=>{if(console.error(`Notice window error: ${a}`,r),u&&(clearTimeout(u),u=null),!b)try{await p.close()}catch{}}),p.once("tauri://destroyed",async()=>{u&&(clearTimeout(u),u=null),E.delete(e),i.removeActiveWindow(e),await i.markMessageAsShown(e),i.clearCurrent()}),console.log(`Created notice window: ${a} (autoSize: ${o}, visible: ${!o})`)}catch(h){console.error("Failed to create notice window:",h),i.removeActiveWindow(e),i.clearCurrent()}},$=async t=>{const e=String(t),i=E.get(e),n=w.getState();if(i)try{await i.close(),E.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)}},_e=async()=>{const t=Array.from(E.keys()).map(e=>$(e));await Promise.all(t)},ve=()=>{let t=null;w.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,me(i)):i||(t=null)}),console.log("Notice window system initialized")},Ze=()=>{const t=w(i=>i.currentMessage);return{closeNotice:c.useCallback(async()=>{t&&await $(t.id)},[t])}},Ye=()=>{const t=w(i=>i.hideMessage);return{hideNotice:c.useCallback(async i=>{await t(i),await $(i)},[t])}},Ke=()=>{const t=w(i=>i.clearOnLogout);return{hideAllNotices:c.useCallback(async()=>{await _e(),await t()},[t])}},Xe=()=>{const t=w(L.queueLength),e=w(L.currentMessage),i=w(L.isProcessing),n=w(L.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Se=c.createContext({windowReady:!0}),et=()=>c.useContext(Se),tt=async t=>{try{const e=D(),i=e.defaultWidth||400,n=e.maxHeight??800,a=e.defaultHeight||300,l=32,o=Math.ceil(t)+l,y=Math.max(a,Math.min(o,n)),_=A();await _.setSize(new Y(i,y));const{x:b,y:z}=await te(i,y);await _.setPosition(new K(b,z)),await _.show(),console.log(`[NoticeLayout] Auto-sized window to ${i}x${y} (content=${Math.ceil(t)}, chrome=${l})`)}catch(e){console.error("[NoticeLayout] Failed to auto-size, showing window as-is:",e);try{await A().show()}catch{}}},it=({children:t,onLoad:e,onClose:i})=>{const[n,a]=c.useState(null),[l,o]=c.useState(!0),[y,_]=c.useState(null),[b,z]=c.useState(!1),C=c.useRef(null),P=c.useRef(!1),h=D(),p=h.autoSize??!0;return c.useEffect(()=>{p||z(!0)},[p]),c.useEffect(()=>{(async()=>{try{const r=new URLSearchParams(window.location.search).get("id");if(!r){_("No message ID provided"),o(!1),setTimeout(async()=>{try{await A().close()}catch(S){console.error("Failed to close window:",S)}},1e3);return}const I=await Z(r);if(!I){console.log(`Message ${r} not found in database, closing window`),_("Message not found"),o(!1),setTimeout(async()=>{try{await A().close()}catch(S){console.error("Failed to close window:",S)}},500);return}a(I),o(!1),e&&e(I)}catch(v){console.error("Failed to load message:",v),_("Failed to load message"),o(!1),setTimeout(async()=>{try{await A().close()}catch(r){console.error("Failed to close window:",r)}},1e3)}})()},[e]),c.useEffect(()=>{if(!p||!n||b||P.current)return;let u;const v=requestAnimationFrame(()=>{u=requestAnimationFrame(()=>{if(!C.current||P.current)return;P.current=!0;const r=C.current,S=D().defaultWidth||400,x={position:r.style.position,top:r.style.top,left:r.style.left,width:r.style.width,height:r.style.height,overflow:r.style.overflow};r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width=`${S}px`,r.style.height="auto",r.style.overflow="visible",r.offsetHeight;const ie=r.scrollHeight;console.log(`[NoticeLayout] Measured content height: ${ie}px (container detached at ${S}px width)`),r.style.position=x.position,r.style.top=x.top,r.style.left=x.left,r.style.width=x.width,r.style.height=x.height,r.style.overflow=x.overflow,tt(ie).then(()=>{z(!0)})})});return()=>{cancelAnimationFrame(v),u!==void 0&&cancelAnimationFrame(u)}},[p,n,b]),c.useEffect(()=>{if(!p||b)return;const u=h.autoSizeTimeout??3e3,v=setTimeout(async()=>{if(!b){console.warn("[NoticeLayout] Auto-size timeout reached, showing window as-is");try{await A().show()}catch{}z(!0)}},u);return()=>clearTimeout(v)},[p,b,h.autoSizeTimeout]),c.useEffect(()=>{if(!n||!i)return;const u=()=>{i(n)};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[n,i]),l?k.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):y?k.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:y}):n?k.jsx(Se.Provider,{value:{windowReady:b},children:k.jsx("div",{ref:C,style:b?{height:"100vh"}:void 0,children:t(n)})}):k.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:"Closing window..."})},nt=async()=>{J(),ve();const{initializeFromDatabase:t}=w.getState();await t(),console.log("Tauri Notice System initialized")},st=async t=>{await w.getState().deleteMessage(t)},at=async t=>{await w.getState().hideMessage(t)},ot=async t=>{await w.getState().markMessageAsShown(t)};exports.NoticeLayout=it;exports.calculateWindowPosition=te;exports.closeAllNoticeWindows=_e;exports.closeNoticeWindow=$;exports.createNoticeWindow=me;exports.deleteMessageById=st;exports.getLogicalScreenSize=fe;exports.getMessage=Z;exports.getNoticeConfig=D;exports.getPendingMessages=we;exports.hideMessageById=at;exports.initializeDatabase=J;exports.initializeNoticeSystem=nt;exports.initializeNoticeWindowSystem=ve;exports.markMessageAsShown=ot;exports.messageQueueSelectors=L;exports.setNoticeConfig=xe;exports.useCloseNotice=Ze;exports.useHideAllNotices=Ke;exports.useHideNotice=Ye;exports.useMessageQueue=Xe;exports.useMessageQueueStore=w;exports.useNoticeWindow=qe;exports.useNoticeWindowContext=et;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ge=require("zustand"),ye=require("zustand-sync"),Oe=require("dexie"),c=require("react"),T=require("react/jsx-runtime"),be="tauri-notice-config",G={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404",defaultDecorations:!0,loadTimeout:4e3,autoSize:!0,maxWidth:600,maxHeight:800,autoSizeTimeout:3e3,stackRoute:"/notice/stack",stackWindowLabel:"notice-stack",stackWindowOptions:{width:380,height:520,decorations:!1,resizable:!0,alwaysOnTop:!0}},pe=()=>{if(typeof window>"u")return G;try{const t=localStorage.getItem(be);if(t)return{...G,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return G},Ce=t=>{if(!(typeof window>"u"))try{localStorage.setItem(be,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},Te=t=>{const i={...pe(),...t};Ce(i)},v=()=>pe();class Pe extends Oe{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let L=null;const K=()=>{if(!L){const t=v();L=new Pe(t.databaseName)}return L},_=()=>L||K(),Le=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await _().messages.put(e)},Re=async t=>!!await _().messages.get(t),Ee=async t=>{const e=await _().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},fe=async()=>await _().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),Fe=async(t,e)=>{await _().messages.update(t,{queueStatus:e})},qe=async t=>{await _().messages.update(t,{queueStatus:"shown",isShown:!0})},Be=async t=>{await _().messages.update(t,{queueStatus:"hidden"})},X=async t=>await _().messages.get(t),He=async t=>{await _().messages.delete(t)},$e=async()=>{await _().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},Ue=async t=>{const e=t.map(i=>_().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Qe=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await Ee(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await Re(i.id)||await Le(i),!n.queue.some(h=>h.id===i.id)){const h=[...n.queue,i];t({queue:h}),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 X(n.id)){console.log(`Message ${n.id} was deleted, skipping to next`),await e().showNext();return}t({currentMessage:n,isProcessing:!0}),await Fe(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 fe();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await Ue(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await $e()},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 He(i),await e().removeFromQueue(i)},hideMessage:async i=>{await Be(i),await e().removeFromQueue(i)},markMessageAsShown:async i=>{await qe(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)}}),g=ge.create()(ye.syncTabs(Qe,{name:"tauri-notice-queue"})),P={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},je=t=>({items:[],addItem:e=>{t(i=>{const n=String(e.id),a=i.items.filter(r=>r.id!==n);return a.push({...e,id:n}),{items:a}})},removeItem:e=>{const i=String(e);t(n=>({items:n.items.filter(a=>a.id!==i)}))},clearAll:()=>{t({items:[]})}}),F=ge.create()(ye.syncTabs(je,{name:"tauri-notice-stack"})),me=()=>{F.getState().clearAll()},_e=t=>{F.getState().removeItem(t)},Ge=()=>{const t=g(i=>i.enqueue);return{showNotice:c.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 Je(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 B;const m="__TAURI_TO_IPC_KEY__";function Ze(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 Ye{get rid(){return Ve(this,B,"f")}constructor(e){B.set(this,void 0),Je(this,B,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}B=new WeakMap;class ee{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 A(this.width*e,this.height*e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}}class A{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 ee(this.width/e,this.height/e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}}class z{constructor(e){this.size=e}toLogical(e){return this.size instanceof ee?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof A?this.size:this.size.toPhysical(e)}[m](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[m]()}}class te{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 p(this.x*e,this.y*e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}}class p{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 te(this.x/e,this.y/e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}}class I{constructor(e){this.position=e}toLogical(e){return this.position instanceof te?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof p?this.position:this.position.toPhysical(e)}[m](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[m]()}}var w;(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"})(w||(w={}));async function ve(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function q(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:Ze(e)}).then(r=>async()=>ve(t,r))}async function $(t,e,i){return q(t,n=>{ve(t,n.id),e(n)},i)}async function ie(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ne(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}const Se=Object.freeze(Object.defineProperty({__proto__:null,get TauriEvent(){return w},emit:ie,emitTo:ne,listen:q,once:$},Symbol.toStringTag,{value:"Module"}));class R extends Ye{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:H(e),width:i,height:n}).then(a=>new R(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:H(e)}).then(i=>new R(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new R(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 H(t){return t==null?null:typeof t=="string"?t:t instanceof R?t.rid:t}var Y;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(Y||(Y={}));class Ke{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var re;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(re||(re={}));function We(){return new U(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function V(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new U(e,{skip:!0})))}const J=["tauri://created","tauri://error"];class U{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 V()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return We()}static async getAll(){return V()}static async getFocusedWindow(){for(const e of await V())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)}:q(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)}:$(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(J.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ie(e,i)}async emitTo(e,i,n){if(J.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ne(e,i,n)}_handleTauriEvent(e,i){return J.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 p(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new p(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new A(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new A(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===Y.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 z?e:new z(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof z?e:e?new z(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof z?e:e?new z(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 I?e:new I(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:H(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 I?e:new I(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?H(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(w.WINDOW_RESIZED,i=>{i.payload=new A(i.payload),e(i)})}async onMoved(e){return this.listen(w.WINDOW_MOVED,i=>{i.payload=new p(i.payload),e(i)})}async onCloseRequested(e){return this.listen(w.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Ke(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(w.DRAG_ENTER,o=>{e({...o,payload:{type:"enter",paths:o.payload.paths,position:new p(o.payload.position)}})}),n=await this.listen(w.DRAG_OVER,o=>{e({...o,payload:{type:"over",position:new p(o.payload.position)}})}),a=await this.listen(w.DRAG_DROP,o=>{e({...o,payload:{type:"drop",paths:o.payload.paths,position:new p(o.payload.position)}})}),r=await this.listen(w.DRAG_LEAVE,o=>{e({...o,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}async onFocusChanged(e){const i=await this.listen(w.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(w.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(w.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(w.WINDOW_THEME_CHANGED,e)}}var le;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(le||(le={}));var ce;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ce||(ce={}));var ue;(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"})(ue||(ue={}));var de;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(de||(de={}));function Xe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new p(t.position),size:new A(t.size),workArea:{position:new p(t.workArea.position),size:new A(t.workArea.size)}}}async function et(){return s("plugin:window|primary_monitor").then(Xe)}function Ne(){return new se(We(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function we(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new se(new U(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const Z=["tauri://created","tauri://error"];class se{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 we()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return Ne()}static async getAll(){return we()}async listen(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 once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:$(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(Z.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ie(e,i)}async emitTo(e,i,n){if(Z.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ne(e,i,n)}_handleTauriEvent(e,i){return Z.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 p(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new A(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 z?e:new z(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof I?e:new I(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(w.DRAG_ENTER,o=>{e({...o,payload:{type:"enter",paths:o.payload.paths,position:new p(o.payload.position)}})}),n=await this.listen(w.DRAG_OVER,o=>{e({...o,payload:{type:"over",position:new p(o.payload.position)}})}),a=await this.listen(w.DRAG_DROP,o=>{e({...o,payload:{type:"drop",paths:o.payload.paths,position:new p(o.payload.position)}})}),r=await this.listen(w.DRAG_LEAVE,o=>{e({...o,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function M(){const t=Ne();return new N(t.label,{skip:!0})}async function he(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new N(e,{skip:!0})))}class N{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 he()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new N(n.label,{skip:!0}):null}static getCurrent(){return M()}static async getAll(){return he()}async listen(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 once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:$(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}))}}tt(N,[U,se]);function tt(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 E=new Map,it=()=>navigator.platform.toLowerCase().includes("mac")||navigator.userAgent.toLowerCase().includes("mac"),nt=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},ke=async()=>{let t=1920,e=1080;try{const i=await et();if(i?.size){const n=i.scaleFactor||1;t=i.size.width/n,e=i.size.height/n}}catch(i){console.warn("Failed to get monitor info, using defaults:",i)}return{screenWidth:t,screenHeight:e}},Q=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};const{screenWidth:a,screenHeight:r}=await ke();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}}},ze=async t=>{const e=String(t.id),i=g.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=v(),a=`notice-${e}`;let r=`${n.routePrefix}/${t.type}?id=${t.id}`;nt(r)||(console.warn(`Invalid window URL: ${r}. Using fallback 404 page.`),r=n.notFoundUrl||"/404");const o=n.autoSize??!0,h=t.min_width||n.defaultWidth,y=o?n.maxHeight??800:t.min_height||n.defaultHeight,d=t.decorations??n.defaultDecorations??!0,S=t.min_height||n.defaultHeight,{x,y:O}=await Q(h,S,t.windowPosition);try{const b={url:r,title:t.title,width:h,height:y,x,y:O,resizable:!0,skipTaskbar:!1,alwaysOnTop:!0};o&&(b.visible=!1),d?b.decorations=!0:it()?(b.decorations=!0,b.titleBarStyle="overlay",b.hiddenTitle=!0):(b.decorations=!1,b.transparent=!0);const f=new N(a,b);E.set(e,f),i.addActiveWindow(e);let u=null;const W=n.loadTimeout??1e4;!d&&W>0&&(u=setTimeout(async()=>{console.warn(`Notice window ${a} load timeout - auto closing`);try{await f.close()}catch{}},W)),f.once("tauri://created",()=>{u&&(clearTimeout(u),u=null),console.log(`Notice window created successfully: ${a}`)}),f.once("tauri://error",async l=>{if(console.error(`Notice window error: ${a}`,l),u&&(clearTimeout(u),u=null),!d)try{await f.close()}catch{}}),f.once("tauri://destroyed",async()=>{u&&(clearTimeout(u),u=null),E.delete(e),i.removeActiveWindow(e),await i.markMessageAsShown(e),i.clearCurrent()}),console.log(`Created notice window: ${a} (autoSize: ${o}, visible: ${!o})`)}catch(b){console.error("Failed to create notice window:",b),i.removeActiveWindow(e),i.clearCurrent()}},j=async t=>{const e=String(t),i=E.get(e),n=g.getState();if(i)try{await i.close(),E.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)}},Ae=async()=>{const t=Array.from(E.keys()).map(e=>j(e));await Promise.all(t)},xe=()=>{let t=null;g.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,ze(i)):i||(t=null)}),console.log("Notice window system initialized")},st=()=>{const t=g(i=>i.currentMessage);return{closeNotice:c.useCallback(async()=>{t&&await j(t.id)},[t])}},at=()=>{const t=g(i=>i.hideMessage);return{hideNotice:c.useCallback(async i=>{await t(i),await j(i)},[t])}},ot=()=>{const t=g(i=>i.clearOnLogout);return{hideAllNotices:c.useCallback(async()=>{await Ae(),await t()},[t])}},rt=()=>{const t=g(P.queueLength),e=g(P.currentMessage),i=g(P.isProcessing),n=g(P.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},ae=()=>typeof window<"u"&&!!window.__TAURI__,lt=async t=>{if(ae())try{const{emit:e}=await Promise.resolve().then(()=>Se);await e(`${t}-update`)}catch{}},Me=async()=>{if(!ae())return;const t=v(),e=t.stackWindowLabel||"notice-stack",i=t.stackRoute||"/notice/stack",n=t.stackWindowOptions||{},a=n.width??380,r=n.height??520,o=n.decorations??!1,h=n.resizable??!0,y=n.alwaysOnTop??!0,d=await N.getByLabel(e);if(d){await d.show(),await d.unminimize();return}const{x:S,y:x}=await Q(a,r,n.position);new N(e,{url:i,title:"Notifications",width:a,height:r,x:S,y:x,decorations:o,resizable:h,alwaysOnTop:y,skipTaskbar:!1})},ct=async t=>{const e={id:String(t.id),uuid:t.uuid?String(t.uuid):void 0,type:t.type,routeType:t.routeType||t.type,title:t.title,data:t.data,receivedAt:t.receivedAt??Date.now()};F.getState().addItem(e);const n=v().stackWindowLabel||"notice-stack";return await lt(n),await Me(),e},De=async()=>{if(!ae())return;const e=v().stackWindowLabel||"notice-stack",i=await N.getByLabel(e);i&&await i.close()},ut=()=>typeof window<"u"&&!!window.__TAURI__,dt=()=>{const t=F(r=>r.items),[,e]=c.useState(0);c.useEffect(()=>{if(!ut())return;let r;const h=v().stackWindowLabel||"notice-stack";return Promise.resolve().then(()=>Se).then(({listen:y})=>y(`${h}-update`,()=>{e(d=>d+1)})).then(y=>{r=y}).catch(()=>{}),()=>r?.()},[]);const i=c.useCallback(r=>{_e(r)},[]),n=c.useCallback(()=>{me()},[]),a=c.useCallback(async()=>{await De()},[]);return{items:t,total:t.length,removeItem:i,clearAll:n,closeWindow:a}},Ie=c.createContext({windowReady:!0}),wt=()=>c.useContext(Ie),ht=async t=>{try{const e=v(),i=e.defaultWidth||400,n=e.maxHeight??800,a=e.defaultHeight||300,r=32,o=Math.ceil(t)+r,h=Math.max(a,Math.min(o,n)),y=M();await y.setSize(new ee(i,h));const{x:d,y:S}=await Q(i,h);await y.setPosition(new te(d,S)),await y.show(),console.log(`[NoticeLayout] Auto-sized window to ${i}x${h} (content=${Math.ceil(t)}, chrome=${r})`)}catch(e){console.error("[NoticeLayout] Failed to auto-size, showing window as-is:",e);try{await M().show()}catch{}}},gt=({children:t,onLoad:e,onClose:i})=>{const[n,a]=c.useState(null),[r,o]=c.useState(!0),[h,y]=c.useState(null),[d,S]=c.useState(!1),x=c.useRef(null),O=c.useRef(!1),b=v(),f=b.autoSize??!0;return c.useEffect(()=>{f||S(!0)},[f]),c.useEffect(()=>{(async()=>{try{const l=new URLSearchParams(window.location.search).get("id");if(!l){y("No message ID provided"),o(!1),setTimeout(async()=>{try{await M().close()}catch(k){console.error("Failed to close window:",k)}},1e3);return}const C=await X(l);if(!C){console.log(`Message ${l} not found in database, closing window`),y("Message not found"),o(!1),setTimeout(async()=>{try{await M().close()}catch(k){console.error("Failed to close window:",k)}},500);return}a(C),o(!1),e&&e(C)}catch(W){console.error("Failed to load message:",W),y("Failed to load message"),o(!1),setTimeout(async()=>{try{await M().close()}catch(l){console.error("Failed to close window:",l)}},1e3)}})()},[e]),c.useEffect(()=>{if(!f||!n||d||O.current)return;let u;const W=requestAnimationFrame(()=>{u=requestAnimationFrame(()=>{if(!x.current||O.current)return;O.current=!0;const l=x.current,k=v().defaultWidth||400,D={position:l.style.position,top:l.style.top,left:l.style.left,width:l.style.width,height:l.style.height,overflow:l.style.overflow};l.style.position="fixed",l.style.top="0",l.style.left="0",l.style.width=`${k}px`,l.style.height="auto",l.style.overflow="visible",l.offsetHeight;const oe=l.scrollHeight;console.log(`[NoticeLayout] Measured content height: ${oe}px (container detached at ${k}px width)`),l.style.position=D.position,l.style.top=D.top,l.style.left=D.left,l.style.width=D.width,l.style.height=D.height,l.style.overflow=D.overflow,ht(oe).then(()=>{S(!0)})})});return()=>{cancelAnimationFrame(W),u!==void 0&&cancelAnimationFrame(u)}},[f,n,d]),c.useEffect(()=>{if(!f||d)return;const u=b.autoSizeTimeout??3e3,W=setTimeout(async()=>{if(!d){console.warn("[NoticeLayout] Auto-size timeout reached, showing window as-is");try{await M().show()}catch{}S(!0)}},u);return()=>clearTimeout(W)},[f,d,b.autoSizeTimeout]),c.useEffect(()=>{if(!n||!i)return;const u=()=>{i(n)};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[n,i]),r?T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):h?T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:h}):n?T.jsx(Ie.Provider,{value:{windowReady:d},children:T.jsx("div",{ref:x,style:d?{height:"100vh"}:void 0,children:t(n)})}):T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:"Closing window..."})},yt=async()=>{K(),xe();const{initializeFromDatabase:t}=g.getState();await t(),console.log("Tauri Notice System initialized")},bt=async t=>{await g.getState().deleteMessage(t)},pt=async t=>{await g.getState().hideMessage(t)},ft=async t=>{await g.getState().markMessageAsShown(t)};exports.NoticeLayout=gt;exports.calculateWindowPosition=Q;exports.clearNoticeStack=me;exports.closeAllNoticeWindows=Ae;exports.closeNoticeStackWindow=De;exports.closeNoticeWindow=j;exports.createNoticeWindow=ze;exports.deleteMessageById=bt;exports.ensureStackWindow=Me;exports.getLogicalScreenSize=ke;exports.getMessage=X;exports.getNoticeConfig=v;exports.getPendingMessages=fe;exports.hideMessageById=pt;exports.initializeDatabase=K;exports.initializeNoticeSystem=yt;exports.initializeNoticeWindowSystem=xe;exports.markMessageAsShown=ft;exports.messageQueueSelectors=P;exports.pushToNoticeStack=ct;exports.removeFromNoticeStack=_e;exports.setNoticeConfig=Te;exports.useCloseNotice=st;exports.useHideAllNotices=ot;exports.useHideNotice=at;exports.useMessageQueue=rt;exports.useMessageQueueStore=g;exports.useNoticeStack=dt;exports.useNoticeStackStore=F;exports.useNoticeWindow=Ge;exports.useNoticeWindowContext=wt;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|