@synnaxlabs/drift 0.55.0 → 0.56.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/dist/drift.cjs +1 -1
- package/dist/drift.js +79 -79
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/{selectors-BXRepCOf.cjs → selectors-CTO0z-Ti.cjs} +1 -1
- package/dist/{selectors-BJDn7YrO.js → selectors-Ce7v7pQ7.js} +1 -1
- package/dist/{state-B0AhlJI7.js → state-CK9lLOo9.js} +40 -40
- package/dist/{state-CynG0Zxv.cjs → state-j_OGVu9F.cjs} +1 -1
- package/dist/tauri.cjs +1 -1
- package/dist/tauri.js +292 -286
- package/dist/{window-Cuphmj99.js → window-BXogI37G.js} +4578 -3738
- package/dist/window-DTPpKYT1.cjs +75 -0
- package/package.json +19 -19
- package/dist/window-CXsPQtRu.cjs +0 -50
package/dist/tauri.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./window-CXsPQtRu.cjs`),t=require(`./state-CynG0Zxv.cjs`);function n(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function r(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var i,a=`__TAURI_TO_IPC_KEY__`;function o(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function s(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var c=class{get rid(){return n(this,i,`f`)}constructor(e){i.set(this,void 0),r(this,i,e,`f`)}async close(){return s(`plugin:resources|close`,{rid:this.rid})}};i=new WeakMap;var l;(function(e){e.WINDOW_RESIZED=`tauri://resize`,e.WINDOW_MOVED=`tauri://move`,e.WINDOW_CLOSE_REQUESTED=`tauri://close-requested`,e.WINDOW_DESTROYED=`tauri://destroyed`,e.WINDOW_FOCUS=`tauri://focus`,e.WINDOW_BLUR=`tauri://blur`,e.WINDOW_SCALE_FACTOR_CHANGED=`tauri://scale-change`,e.WINDOW_THEME_CHANGED=`tauri://theme-changed`,e.WINDOW_CREATED=`tauri://window-created`,e.WEBVIEW_CREATED=`tauri://webview-created`,e.DRAG_ENTER=`tauri://drag-enter`,e.DRAG_OVER=`tauri://drag-over`,e.DRAG_DROP=`tauri://drag-drop`,e.DRAG_LEAVE=`tauri://drag-leave`})(l||={});async function u(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await s(`plugin:event|unlisten`,{event:e,eventId:t})}async function d(e,t,n){return s(`plugin:event|listen`,{event:e,target:typeof n?.target==`string`?{kind:`AnyLabel`,label:n.target}:n?.target??{kind:`Any`},handler:o(t)}).then(t=>async()=>u(e,t))}async function f(e,t,n){return d(e,n=>{u(e,n.id),t(n)},n)}async function p(e,t){await s(`plugin:event|emit`,{event:e,payload:t})}async function m(e,t,n){await s(`plugin:event|emit_to`,{target:typeof e==`string`?{kind:`AnyLabel`,label:e}:e,event:t,payload:n})}var h=class{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 g(this.width*e,this.height*e)}[a](){return{width:this.width,height:this.height}}toJSON(){return this[a]()}},g=class{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 h(this.width/e,this.height/e)}[a](){return{width:this.width,height:this.height}}toJSON(){return this[a]()}},_=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof h?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof g?this.size:this.size.toPhysical(e)}[a](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[a]()}},v=class{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 y(this.x*e,this.y*e)}[a](){return{x:this.x,y:this.y}}toJSON(){return this[a]()}},y=class{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 v(this.x/e,this.y/e)}[a](){return{x:this.x,y:this.y}}toJSON(){return this[a]()}},b=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof v?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof y?this.position:this.position.toPhysical(e)}[a](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[a]()}},x=class e extends c{constructor(e){super(e)}static async new(t,n,r){return s(`plugin:image|new`,{rgba:S(t),width:n,height:r}).then(t=>new e(t))}static async fromBytes(t){return s(`plugin:image|from_bytes`,{bytes:S(t)}).then(t=>new e(t))}static async fromPath(t){return s(`plugin:image|from_path`,{path:t}).then(t=>new e(t))}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 S(e){return e==null?null:typeof e==`string`?e:e instanceof x?e.rid:e}var C;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(C||={});var w=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},T;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(T||={});function E(){return new k(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function D(){return s(`plugin:window|get_all_windows`).then(e=>e.map(e=>new k(e,{skip:!0})))}var O=[`tauri://created`,`tauri://error`],k=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||s(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await D()).find(t=>t.label===e)??null}static getCurrent(){return E()}static async getAll(){return D()}static async getFocusedWindow(){for(let e of await D())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(O.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return p(e,t)}async emitTo(e,t,n){if(O.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return m(e,t,n)}_handleTauriEvent(e,t){return O.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!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 y(e))}async outerPosition(){return s(`plugin:window|outer_position`,{label:this.label}).then(e=>new y(e))}async innerSize(){return s(`plugin:window|inner_size`,{label:this.label}).then(e=>new g(e))}async outerSize(){return s(`plugin:window|outer_size`,{label:this.label}).then(e=>new g(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 t=null;return e&&(t=e===C.Critical?{type:`Critical`}:{type:`Informational`}),s(`plugin:window|request_user_attention`,{label:this.label,value:t})}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 _?e:new _(e)})}async setMinSize(e){return s(`plugin:window|set_min_size`,{label:this.label,value:e instanceof _?e:e?new _(e):null})}async setMaxSize(e){return s(`plugin:window|set_max_size`,{label:this.label,value:e instanceof _?e:e?new _(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return s(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return s(`plugin:window|set_position`,{label:this.label,value:e instanceof b?e:new b(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:S(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 b?e:new b(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?S(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(l.WINDOW_RESIZED,t=>{t.payload=new g(t.payload),e(t)})}async onMoved(e){return this.listen(l.WINDOW_MOVED,t=>{t.payload=new y(t.payload),e(t)})}async onCloseRequested(e){return this.listen(l.WINDOW_CLOSE_REQUESTED,async t=>{let n=new w(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(l.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new y(t.payload.position)}})}),n=await this.listen(l.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new y(t.payload.position)}})}),r=await this.listen(l.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new y(t.payload.position)}})}),i=await this.listen(l.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(l.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(l.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(l.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(l.WINDOW_THEME_CHANGED,e)}},A;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(A||={});var ee;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(ee||={});var te;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(te||={});var ne;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(ne||={});function j(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:new y(e.position),size:new g(e.size),workArea:{position:new y(e.workArea.position),size:new g(e.workArea.size)}}}async function M(){return s(`plugin:window|available_monitors`).then(e=>e.map(j))}function N(){return new I(E(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function P(){return s(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new I(new k(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var F=[`tauri://created`,`tauri://error`],I=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||s(`plugin:webview|create_webview`,{windowLabel:e.label,options:{...n,label:t}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await P()).find(t=>t.label===e)??null}static getCurrent(){return N()}static async getAll(){return P()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`Webview`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(F.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return p(e,t)}async emitTo(e,t,n){if(F.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return m(e,t,n)}_handleTauriEvent(e,t){return F.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return s(`plugin:webview|webview_position`,{label:this.label}).then(e=>new y(e))}async size(){return s(`plugin:webview|webview_size`,{label:this.label}).then(e=>new g(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 _?e:new _(e)})}async setPosition(e){return s(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof b?e:new b(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){let t=await this.listen(l.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new y(t.payload.position)}})}),n=await this.listen(l.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new y(t.payload.position)}})}),r=await this.listen(l.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new y(t.payload.position)}})}),i=await this.listen(l.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function L(){return new z(N().label,{skip:!0})}async function R(){return s(`plugin:window|get_all_windows`).then(e=>e.map(e=>new z(e,{skip:!0})))}var z=class e{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||s(`plugin:webview|create_webview_window`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(t){let n=(await R()).find(e=>e.label===t)??null;return n?new e(n.label,{skip:!0}):null}static getCurrent(){return L()}static async getAll(){return R()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`WebviewWindow`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{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}))}};B(z,[k,I]);function B(e,t){(Array.isArray(t)?t:[t]).forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{typeof e.prototype==`object`&&e.prototype&&n in e.prototype||Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)??Object.create(null))})})}var V=e=>JSON.stringify(e),H=e=>JSON.parse(e),U=`drift://action`,W=`tauri://error`,G=`tauri://created`,K=e=>Error(`Window not found: ${e}`),q=250,J=e.s.seconds(1),Y=e.s.seconds(1),X=e=>{if(e!=null)return{width:Math.max(e.width,q),height:Math.max(e.height,q)}},re=e=>{let{size:t,maxSize:n}=e;return{...e,maxSize:X(n),size:X(t)}},ie=async()=>(await M()).map(t=>{let n=Q(t.position,t.scaleFactor),r={width:t.size.width,height:t.size.height};return e.f.construct(n,r)}),Z=async t=>(await ie()).some(n=>e.f.contains(n,t)),ae=class{win;unsubscribe;fullscreenPoll=null;monitorChangePoll=null;constructor(e){this.win=e??L(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll(),this.startMonitorChangePoll()}async startFullscreenPoll(){if(e.m.getOS()!==`macOS`)return;let n=(await this.getProps()).fullscreen;this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(e=>{e!==n&&(n=e,this.emit({action:t.p({label:this.win.label,fullscreen:e})},void 0,`WHITELIST`).catch(console.error))}).catch(console.error)},J.milliseconds)}startMonitorChangePoll(){e.m.getOS()!==`macOS`&&(this.monitorChangePoll!=null&&clearInterval(this.monitorChangePoll),this.monitorChangePoll=setInterval(()=>{this.repositionIfOffScreen().catch(console.error)},Y.milliseconds))}async repositionIfOffScreen(){if(await this.win.isMinimized())return;let e=await this.win.scaleFactor();await Z(Q(await this.win.innerPosition(),e))||await this.win.center()}label(){return this.win.label}isMain(){return this.win.label===e.r}release(){Object.values(this.unsubscribe).forEach(e=>e?.()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.monitorChangePoll!=null&&clearInterval(this.monitorChangePoll),this.unsubscribe={}}async emit(e,t,n=this.label()){let r=V({...e,emitter:n});if(t==null)return await p(U,r);let i=await z.getByLabel(t);if(i==null)throw K(t);await i.emit(U,r)}async subscribe(t){this.release(),await this.startFullscreenPoll(),this.startMonitorChangePoll(),this.unsubscribe[U]=await d(U,e=>t(H(e.payload)));let n=oe();for(let{key:t,handler:r,debounce:i}of n)this.unsubscribe[t]=await this.win.listen(t,e.l(()=>{r(this.win).then(e=>{e!=null&&this.emit({action:e},void 0,`WHITELIST`).catch(console.error)}).catch(console.error)},i))}onCloseRequested(e){this.win.onCloseRequested(t=>{t.preventDefault(),e()})}async create(t,n){n=e.c.copy(n);let{size:r,minSize:i,maxSize:a,position:o,...s}=re(n);r?.width!=null&&(r.width=Math.max(r.width,q)),r?.height!=null&&(r.height=Math.max(r.height,q)),a?.width!=null&&(a.width=Math.max(a.width,q)),a?.height!=null&&(a.height=Math.max(a.height,q)),o!=null&&(await Z(o)||(o.x=0,o.y=0));try{let e=new z(t,{x:o?.x,y:o?.y,width:r?.width,height:r?.height,minWidth:i?.width,minHeight:i?.height,maxWidth:a?.width,maxHeight:a?.height,titleBarStyle:`overlay`,dragDropEnabled:!1,...s});return await new Promise((t,n)=>{e.once(W,e=>n(Error(JSON.stringify(e.payload)))),e.once(G,()=>t())})}catch(e){console.error(e)}}async close(e){let t=await z.getByLabel(e);if(t!=null)try{await t.destroy()}catch(t){console.error(t,e)}else{let t=await R();console.error(`Window not found`,e,t.map(e=>e.label))}}async listLabels(){return(await R()).map(e=>e.label)}async focus(){return await this.win.setFocus()}async setMinimized(e){return e?await this.win.minimize():await this.win.unminimize()}async setMaximized(e){return e?await this.win.maximize():await this.win.unmaximize()}async setVisible(e){return e?await this.win.show():await this.win.hide()}async setFullscreen(e){await this.win.setFullscreen(e)}async center(){return await this.win.center()}async setPosition(e){let t=new v(e.x,e.y);await Z(e)||(t.x=0,t.y=0),await this.win.setPosition(t)}async setSize(e){e=X(e),await this.win.setSize(new h(e.width,e.height))}async setMinSize(e){e=X(e),await this.win.setMinSize(new h(e.width,e.height))}async setMaxSize(e){e=X(e),await this.win.setMaxSize(new h(e.width,e.height))}async setResizable(e){return l.WINDOW_RESIZED in this.unsubscribe&&!e&&(this.unsubscribe[l.WINDOW_RESIZED]?.(),delete this.unsubscribe[l.WINDOW_RESIZED]),await this.win.setResizable(e)}async setSkipTaskbar(e){return await this.win.setSkipTaskbar(e)}async setAlwaysOnTop(e){return await this.win.setAlwaysOnTop(e)}async setTitle(e){return await this.win.setTitle(e)}async setDecorations(e){return await this.win.setDecorations(e)}async getProps(){let e=await this.win.scaleFactor(),t=await this.win.isVisible();return{position:Q(await this.win.innerPosition(),e),size:$(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:t,fullscreen:await this.win.isFullscreen()}}},oe=()=>[{key:l.WINDOW_RESIZED,debounce:200,handler:async e=>{let n=await e.scaleFactor(),r=await e.isVisible();return t.p({label:e.label,maximized:await e.isMaximized(),visible:r,minimized:!r,position:Q(await e.innerPosition(),n),size:$(await e.innerSize(),n)})}},{key:l.WINDOW_MOVED,debounce:200,handler:async e=>{let n=await e?.scaleFactor();if(n==null)return null;let r=Q(await e.innerPosition(),n),i=await e.isVisible();return t.p({label:e.label,visible:i,position:r})}},{key:l.WINDOW_BLUR,debounce:0,handler:async e=>t.p({focus:!1,label:e.label})},{key:l.WINDOW_FOCUS,debounce:0,handler:async e=>t.p({focus:!0,visible:!0,minimized:!1,label:e.label})}],Q=(t,n)=>e.u.scale(t,1/n),$=(t,n)=>e.p.scale(t,1/n);exports.TauriRuntime=ae;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./window-DTPpKYT1.cjs`),t=require(`./state-j_OGVu9F.cjs`);function n(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function r(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var i,a=`__TAURI_TO_IPC_KEY__`;function o(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function s(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var c=class{get rid(){return n(this,i,`f`)}constructor(e){i.set(this,void 0),r(this,i,e,`f`)}async close(){return s(`plugin:resources|close`,{rid:this.rid})}};i=new WeakMap;var l;(function(e){e.WINDOW_RESIZED=`tauri://resize`,e.WINDOW_MOVED=`tauri://move`,e.WINDOW_CLOSE_REQUESTED=`tauri://close-requested`,e.WINDOW_DESTROYED=`tauri://destroyed`,e.WINDOW_FOCUS=`tauri://focus`,e.WINDOW_BLUR=`tauri://blur`,e.WINDOW_SCALE_FACTOR_CHANGED=`tauri://scale-change`,e.WINDOW_THEME_CHANGED=`tauri://theme-changed`,e.WINDOW_CREATED=`tauri://window-created`,e.WINDOW_SUSPENDED=`tauri://suspended`,e.WINDOW_RESUMED=`tauri://resumed`,e.WEBVIEW_CREATED=`tauri://webview-created`,e.DRAG_ENTER=`tauri://drag-enter`,e.DRAG_OVER=`tauri://drag-over`,e.DRAG_DROP=`tauri://drag-drop`,e.DRAG_LEAVE=`tauri://drag-leave`})(l||={});async function u(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await s(`plugin:event|unlisten`,{event:e,eventId:t})}async function d(e,t,n){return s(`plugin:event|listen`,{event:e,target:typeof n?.target==`string`?{kind:`AnyLabel`,label:n.target}:n?.target??{kind:`Any`},handler:o(t)}).then(t=>async()=>u(e,t))}async function f(e,t,n){return d(e,n=>{u(e,n.id),t(n)},n)}async function p(e,t){await s(`plugin:event|emit`,{event:e,payload:t})}async function m(e,t,n){await s(`plugin:event|emit_to`,{target:typeof e==`string`?{kind:`AnyLabel`,label:e}:e,event:t,payload:n})}var h=class{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 g(this.width*e,this.height*e)}[a](){return{width:this.width,height:this.height}}toJSON(){return this[a]()}},g=class{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 h(this.width/e,this.height/e)}[a](){return{width:this.width,height:this.height}}toJSON(){return this[a]()}},_=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof h?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof g?this.size:this.size.toPhysical(e)}[a](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[a]()}},v=class{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 y(this.x*e,this.y*e)}[a](){return{x:this.x,y:this.y}}toJSON(){return this[a]()}},y=class{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 v(this.x/e,this.y/e)}[a](){return{x:this.x,y:this.y}}toJSON(){return this[a]()}},b=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof v?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof y?this.position:this.position.toPhysical(e)}[a](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[a]()}},x=class e extends c{constructor(e){super(e)}static async new(t,n,r){return s(`plugin:image|new`,{rgba:S(t),width:n,height:r}).then(t=>new e(t))}static async fromBytes(t){return s(`plugin:image|from_bytes`,{bytes:S(t)}).then(t=>new e(t))}static async fromPath(t){return s(`plugin:image|from_path`,{path:t}).then(t=>new e(t))}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 S(e){return e==null?null:typeof e==`string`?e:e instanceof x?e.rid:e}var C;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(C||={});var w=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},T;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(T||={});function E(){return new k(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function D(){return s(`plugin:window|get_all_windows`).then(e=>e.map(e=>new k(e,{skip:!0})))}var O=[`tauri://created`,`tauri://error`],k=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||s(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await D()).find(t=>t.label===e)??null}static getCurrent(){return E()}static async getAll(){return D()}static async getFocusedWindow(){for(let e of await D())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(O.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return p(e,t)}async emitTo(e,t,n){if(O.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return m(e,t,n)}_handleTauriEvent(e,t){return O.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!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 y(e))}async outerPosition(){return s(`plugin:window|outer_position`,{label:this.label}).then(e=>new y(e))}async innerSize(){return s(`plugin:window|inner_size`,{label:this.label}).then(e=>new g(e))}async outerSize(){return s(`plugin:window|outer_size`,{label:this.label}).then(e=>new g(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 activityName(){return s(`plugin:window|activity_name`,{label:this.label})}async sceneIdentifier(){return s(`plugin:window|scene_identifier`,{label:this.label})}async center(){return s(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===C.Critical?{type:`Critical`}:{type:`Informational`}),s(`plugin:window|request_user_attention`,{label:this.label,value:t})}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 _?e:new _(e)})}async setMinSize(e){return s(`plugin:window|set_min_size`,{label:this.label,value:e instanceof _?e:e?new _(e):null})}async setMaxSize(e){return s(`plugin:window|set_max_size`,{label:this.label,value:e instanceof _?e:e?new _(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return s(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return s(`plugin:window|set_position`,{label:this.label,value:e instanceof b?e:new b(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:S(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 b?e:new b(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?S(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(l.WINDOW_RESIZED,t=>{t.payload=new g(t.payload),e(t)})}async onMoved(e){return this.listen(l.WINDOW_MOVED,t=>{t.payload=new y(t.payload),e(t)})}async onCloseRequested(e){return this.listen(l.WINDOW_CLOSE_REQUESTED,async t=>{let n=new w(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(l.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new y(t.payload.position)}})}),n=await this.listen(l.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new y(t.payload.position)}})}),r=await this.listen(l.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new y(t.payload.position)}})}),i=await this.listen(l.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(l.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(l.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(l.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(l.WINDOW_THEME_CHANGED,e)}},A;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(A||={});var ee;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(ee||={});var te;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(te||={});var ne;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(ne||={});function j(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:new y(e.position),size:new g(e.size),workArea:{position:new y(e.workArea.position),size:new g(e.workArea.size)}}}async function M(){return s(`plugin:window|available_monitors`).then(e=>e.map(j))}function N(){return new I(E(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function P(){return s(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new I(new k(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var F=[`tauri://created`,`tauri://error`],I=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||s(`plugin:webview|create_webview`,{windowLabel:e.label,options:{...n,label:t}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await P()).find(t=>t.label===e)??null}static getCurrent(){return N()}static async getAll(){return P()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`Webview`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(F.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return p(e,t)}async emitTo(e,t,n){if(F.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return m(e,t,n)}_handleTauriEvent(e,t){return F.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return s(`plugin:webview|webview_position`,{label:this.label}).then(e=>new y(e))}async size(){return s(`plugin:webview|webview_size`,{label:this.label}).then(e=>new g(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 _?e:new _(e)})}async setPosition(e){return s(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof b?e:new b(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){let t=await this.listen(l.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new y(t.payload.position)}})}),n=await this.listen(l.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new y(t.payload.position)}})}),r=await this.listen(l.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new y(t.payload.position)}})}),i=await this.listen(l.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function L(){return new z(N().label,{skip:!0})}async function R(){return s(`plugin:window|get_all_windows`).then(e=>e.map(e=>new z(e,{skip:!0})))}var z=class e{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||s(`plugin:webview|create_webview_window`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(t){let n=(await R()).find(e=>e.label===t)??null;return n?new e(n.label,{skip:!0}):null}static getCurrent(){return L()}static async getAll(){return R()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:d(e,t,{target:{kind:`WebviewWindow`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:f(e,t,{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}))}};B(z,[k,I]);function B(e,t){(Array.isArray(t)?t:[t]).forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{typeof e.prototype==`object`&&e.prototype&&n in e.prototype||Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)??Object.create(null))})})}var V=e=>JSON.stringify(e),H=e=>JSON.parse(e),U=`drift://action`,W=`tauri://error`,G=`tauri://created`,K=e=>Error(`Window not found: ${e}`),q=250,J=e.l.seconds(1),Y=e.l.seconds(1),X=e=>{if(e!=null)return{width:Math.max(e.width,q),height:Math.max(e.height,q)}},re=e=>{let{size:t,maxSize:n}=e;return{...e,maxSize:X(n),size:X(t)}},ie=async()=>(await M()).map(t=>{let n=Q(t.position,t.scaleFactor),r={width:t.size.width,height:t.size.height};return e.c.construct(n,r)}),Z=async t=>(await ie()).some(n=>e.c.contains(n,t)),ae=class{win;unsubscribe;fullscreenPoll=null;monitorChangePoll=null;constructor(e){this.win=e??L(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll(),this.startMonitorChangePoll()}async startFullscreenPoll(){if(e.s.getOS()!==`macOS`)return;let n=(await this.getProps()).fullscreen;this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(e=>{e!==n&&(n=e,this.emit({action:t.p({label:this.win.label,fullscreen:e})},void 0,`WHITELIST`).catch(console.error))}).catch(console.error)},J.milliseconds)}startMonitorChangePoll(){e.s.getOS()!==`macOS`&&(this.monitorChangePoll!=null&&clearInterval(this.monitorChangePoll),this.monitorChangePoll=setInterval(()=>{this.repositionIfOffScreen().catch(console.error)},Y.milliseconds))}async repositionIfOffScreen(){if(await this.win.isMinimized())return;let e=await this.win.scaleFactor();await Z(Q(await this.win.innerPosition(),e))||await this.win.center()}label(){return this.win.label}isMain(){return this.win.label===e.r}release(){Object.values(this.unsubscribe).forEach(e=>e?.()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.monitorChangePoll!=null&&clearInterval(this.monitorChangePoll),this.unsubscribe={}}async emit(e,t,n=this.label()){let r=V({...e,emitter:n});if(t==null)return await p(U,r);let i=await z.getByLabel(t);if(i==null)throw K(t);await i.emit(U,r)}async subscribe(t){this.release(),await this.startFullscreenPoll(),this.startMonitorChangePoll(),this.unsubscribe[U]=await d(U,e=>t(H(e.payload)));let n=oe();for(let{key:t,handler:r,debounce:i}of n)this.unsubscribe[t]=await this.win.listen(t,e.f(()=>{r(this.win).then(e=>{e!=null&&this.emit({action:e},void 0,`WHITELIST`).catch(console.error)}).catch(console.error)},i))}onCloseRequested(e){this.win.onCloseRequested(t=>{t.preventDefault(),e()})}async create(t,n){n=e.u.copy(n);let{size:r,minSize:i,maxSize:a,position:o,...s}=re(n);r?.width!=null&&(r.width=Math.max(r.width,q)),r?.height!=null&&(r.height=Math.max(r.height,q)),a?.width!=null&&(a.width=Math.max(a.width,q)),a?.height!=null&&(a.height=Math.max(a.height,q)),o!=null&&(await Z(o)||(o.x=0,o.y=0));try{let e=new z(t,{x:o?.x,y:o?.y,width:r?.width,height:r?.height,minWidth:i?.width,minHeight:i?.height,maxWidth:a?.width,maxHeight:a?.height,titleBarStyle:`overlay`,dragDropEnabled:!1,...s});return await new Promise((t,n)=>{e.once(W,e=>n(Error(JSON.stringify(e.payload)))),e.once(G,()=>t())})}catch(e){console.error(e)}}async close(e){let t=await z.getByLabel(e);if(t!=null)try{await t.destroy()}catch(t){console.error(t,e)}else{let t=await R();console.error(`Window not found`,e,t.map(e=>e.label))}}async listLabels(){return(await R()).map(e=>e.label)}async focus(){return await this.win.setFocus()}async setMinimized(e){return e?await this.win.minimize():await this.win.unminimize()}async setMaximized(e){return e?await this.win.maximize():await this.win.unmaximize()}async setVisible(e){return e?await this.win.show():await this.win.hide()}async setFullscreen(e){await this.win.setFullscreen(e)}async center(){return await this.win.center()}async setPosition(e){let t=new v(e.x,e.y);await Z(e)||(t.x=0,t.y=0),await this.win.setPosition(t)}async setSize(e){e=X(e),await this.win.setSize(new h(e.width,e.height))}async setMinSize(e){e=X(e),await this.win.setMinSize(new h(e.width,e.height))}async setMaxSize(e){e=X(e),await this.win.setMaxSize(new h(e.width,e.height))}async setResizable(e){return l.WINDOW_RESIZED in this.unsubscribe&&!e&&(this.unsubscribe[l.WINDOW_RESIZED]?.(),delete this.unsubscribe[l.WINDOW_RESIZED]),await this.win.setResizable(e)}async setSkipTaskbar(e){return await this.win.setSkipTaskbar(e)}async setAlwaysOnTop(e){return await this.win.setAlwaysOnTop(e)}async setTitle(e){return await this.win.setTitle(e)}async setDecorations(e){return await this.win.setDecorations(e)}async getProps(){let e=await this.win.scaleFactor(),t=await this.win.isVisible();return{position:Q(await this.win.innerPosition(),e),size:$(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:t,fullscreen:await this.win.isFullscreen()}}},oe=()=>[{key:l.WINDOW_RESIZED,debounce:200,handler:async e=>{let n=await e.scaleFactor(),r=await e.isVisible();return t.p({label:e.label,maximized:await e.isMaximized(),visible:r,minimized:!r,position:Q(await e.innerPosition(),n),size:$(await e.innerSize(),n)})}},{key:l.WINDOW_MOVED,debounce:200,handler:async e=>{let n=await e?.scaleFactor();if(n==null)return null;let r=Q(await e.innerPosition(),n),i=await e.isVisible();return t.p({label:e.label,visible:i,position:r})}},{key:l.WINDOW_BLUR,debounce:0,handler:async e=>t.p({focus:!1,label:e.label})},{key:l.WINDOW_FOCUS,debounce:0,handler:async e=>t.p({focus:!0,visible:!0,minimized:!1,label:e.label})}],Q=(t,n)=>e.d.scale(t,1/n),$=(t,n)=>e.m.scale(t,1/n);exports.TauriRuntime=ae;
|