@synnaxlabs/drift 0.46.0 → 0.48.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 +3 -3
- package/dist/eslint.config.d.ts +4 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/react.cjs +1 -1
- package/dist/react.js +2 -2
- package/dist/{selectors-D8hS_RlY.js → selectors-DyMwTbxE.js} +1 -1
- package/dist/{selectors-aSH0_uiN.cjs → selectors-KaNE81VG.cjs} +1 -1
- package/dist/src/configureStore.d.ts +13 -14
- package/dist/src/configureStore.d.ts.map +1 -1
- package/dist/state-BEtTdLcx.cjs +28 -0
- package/dist/{state-BY1hJV7i.js → state-BI4Gp9I9.js} +2536 -2410
- package/dist/tauri.cjs +1 -1
- package/dist/tauri.js +79 -70
- package/package.json +19 -24
- package/dist/debounce-BUAIXXZt.cjs +0 -1
- package/dist/debounce-DOZKRZa9.js +0 -9
- package/dist/electron.cjs +0 -1
- package/dist/electron.js +0 -249
- package/dist/src/electron/index.d.ts +0 -49
- package/dist/src/electron/index.d.ts.map +0 -1
- package/dist/state-Zba9U3R-.cjs +0 -28
package/dist/tauri.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./state-Zba9U3R-.cjs"),K=require("./debounce-BUAIXXZt.cjs");function X(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 ee(t,e,i,n,l){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 D;const h="__TAURI_TO_IPC_KEY__";function ie(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 te{get rid(){return X(this,D,"f")}constructor(e){D.set(this,void 0),ee(this,D,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}D=new WeakMap;var r;(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"})(r||(r={}));async function U(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function f(t,e,i){var n;const l=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:l,handler:ie(e)}).then(o=>async()=>U(t,o))}async function R(t,e,i){return f(t,n=>{U(t,n.id),e(n)},i)}async function k(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function G(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}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 b(this.width*e,this.height*e)}[h](){return{width:this.width,height:this.height}}toJSON(){return this[h]()}}class b{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new _(this.width/e,this.height/e)}[h](){return{width:this.width,height:this.height}}toJSON(){return this[h]()}}class w{constructor(e){this.size=e}toLogical(e){return this.size instanceof _?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof b?this.size:this.size.toPhysical(e)}[h](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[h]()}}class N{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new u(this.x*e,this.y*e)}[h](){return{x:this.x,y:this.y}}toJSON(){return this[h]()}}class u{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new N(this.x/e,this.y/e)}[h](){return{x:this.x,y:this.y}}toJSON(){return this[h]()}}class y{constructor(e){this.position=e}toLogical(e){return this.position instanceof N?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[h](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[h]()}}class v extends te{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:z(e),width:i,height:n}).then(l=>new v(l))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:z(e)}).then(i=>new v(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new v(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 z(t){return t==null?null:typeof t=="string"?t:t instanceof v?t.rid:t}var I;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(I||(I={}));class ne{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var T;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(T||(T={}));function H(){return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function E(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new P(e,{skip:!0})))}const x=["tauri://created","tauri://error"];class P{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await E()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return H()}static async getAll(){return E()}static async getFocusedWindow(){for(const e of await E())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(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)}:R(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(x.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return k(e,i)}async emitTo(e,i,n){if(x.includes(i)){for(const l of this.listeners[i]||[])l({event:i,id:-1,payload:n});return}return G(e,i,n)}_handleTauriEvent(e,i){return x.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new u(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new u(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new b(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new b(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===I.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 y?e:new y(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:z(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 y?e:new y(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?z(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(r.WINDOW_RESIZED,i=>{i.payload=new b(i.payload),e(i)})}async onMoved(e){return this.listen(r.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(r.WINDOW_CLOSE_REQUESTED,async i=>{const n=new ne(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(r.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(r.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(r.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),o=await this.listen(r.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),o()}}async onFocusChanged(e){const i=await this.listen(r.WINDOW_FOCUS,l=>{e({...l,payload:!0})}),n=await this.listen(r.WINDOW_BLUR,l=>{e({...l,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(r.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(r.WINDOW_THEME_CHANGED,e)}}var C;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(C||(C={}));var M;(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"})(M||(M={}));var F;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(F||(F={}));function se(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new b(t.size),workArea:{position:new u(t.workArea.position),size:new b(t.workArea.size)}}}async function le(){return s("plugin:window|available_monitors").then(t=>t.map(se))}function j(){return new L(H(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function B(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new L(new P(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const A=["tauri://created","tauri://error"];class L{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await B()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return j()}static async getAll(){return B()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:R(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(A.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return k(e,i)}async emitTo(e,i,n){if(A.includes(i)){for(const l of this.listeners[i]||[])l({event:i,id:-1,payload:n});return}return G(e,i,n)}_handleTauriEvent(e,i){return A.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new u(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new b(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof w?e:new w(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof y?e:new y(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(r.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(r.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(r.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),o=await this.listen(r.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),o()}}}function q(){const t=j();return new d(t.label,{skip:!0})}async function S(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new d(e,{skip:!0})))}class d{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;const n=(i=(await S()).find(l=>l.label===e))!==null&&i!==void 0?i:null;return n?new d(n.label,{skip:!0}):null}static getCurrent(){return q()}static async getAll(){return S()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:R(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}))}}ae(d,[P,L]);function ae(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var l;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(l=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&l!==void 0?l:Object.create(null))})})}const re=t=>JSON.stringify(t),oe=t=>JSON.parse(t),W="drift://action",ue="tauri://error",ce="tauri://created",he=t=>new Error(`Window not found: ${t}`),p=250,we=c.a.seconds(1),m=t=>{if(t!=null)return{width:Math.max(t.width,p),height:Math.max(t.height,p)}},be=t=>{const{size:e,maxSize:i}=t;return{...t,maxSize:m(i),size:m(e)}},de=async()=>(await le()).map(e=>{const i=O(e.position,e.scaleFactor),n={width:e.size.width,height:e.size.height};return c.jt.construct(i,n)}),V=async t=>(await de()).some(i=>c.jt.contains(i,t));class ye{win;unsubscribe;fullscreenPoll=null;constructor(e){this.win=e??q(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll()}async startFullscreenPoll(){if(c.S.getOS()!=="macOS")return;let e=(await this.getProps()).fullscreen;this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(i=>{i!==e&&(e=i,this.emit({action:c.runtimeSetWindowProps({label:this.win.label,fullscreen:i})},void 0,"WHITELIST").catch(console.error))}).catch(console.error)},we.milliseconds)}label(){return this.win.label}isMain(){return this.win.label===c.MAIN_WINDOW}release(){Object.values(this.unsubscribe).forEach(e=>e?.()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.unsubscribe={}}async emit(e,i,n=this.label()){const l=re({...e,emitter:n});if(i==null)return await k(W,l);const o=await d.getByLabel(i);if(o==null)throw he(i);await o.emit(W,l)}async subscribe(e){this.release(),await this.startFullscreenPoll(),this.unsubscribe[W]=await f(W,n=>e(oe(n.payload)));const i=pe();for(const{key:n,handler:l,debounce:o}of i)this.unsubscribe[n]=await this.win.listen(n,K.o(()=>{l(this.win).then(a=>{a!=null&&this.emit({action:a},void 0,"WHITELIST").catch(console.error)}).catch(console.error)},o))}onCloseRequested(e){this.win.onCloseRequested(i=>{i.preventDefault(),e()})}async create(e,i){i=c.T.copy(i);const{size:n,minSize:l,maxSize:o,position:a,...Z}=be(i);n?.width!=null&&(n.width=Math.max(n.width,p)),n?.height!=null&&(n.height=Math.max(n.height,p)),o?.width!=null&&(o.width=Math.max(o.width,p)),o?.height!=null&&(o.height=Math.max(o.height,p)),a!=null&&(await V(a)||(a.x=0,a.y=0));try{const g=new d(e,{x:a?.x,y:a?.y,width:n?.width,height:n?.height,minWidth:l?.width,minHeight:l?.height,maxWidth:o?.width,maxHeight:o?.height,titleBarStyle:"overlay",dragDropEnabled:!1,...Z});return await new Promise(($,Q)=>{g.once(ue,Y=>Q(new Error(JSON.stringify(Y.payload)))),g.once(ce,()=>$())})}catch(g){console.error(g)}}async close(e){const i=await d.getByLabel(e);if(i!=null)try{await i.destroy()}catch(n){console.error(n,e)}else{const n=await S();console.error("Window not found",e,n.map(l=>l.label))}}async listLabels(){return(await S()).map(i=>i.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){const i=new N(e.x,e.y);await V(e)||(i.x=0,i.y=0),await this.win.setPosition(i)}async setSize(e){e=m(e),await this.win.setSize(new _(e.width,e.height))}async setMinSize(e){e=m(e),await this.win.setMinSize(new _(e.width,e.height))}async setMaxSize(e){e=m(e),await this.win.setMaxSize(new _(e.width,e.height))}async setResizable(e){return r.WINDOW_RESIZED in this.unsubscribe&&!e&&(this.unsubscribe[r.WINDOW_RESIZED]?.(),delete this.unsubscribe[r.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(){const e=await this.win.scaleFactor(),i=await this.win.isVisible();return{position:O(await this.win.innerPosition(),e),size:J(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:i,fullscreen:await this.win.isFullscreen()}}}const pe=()=>[{key:r.WINDOW_RESIZED,debounce:200,handler:async t=>{const e=await t.scaleFactor(),i=await t.isVisible(),n={label:t.label,maximized:await t.isMaximized(),visible:i,minimized:!i,position:O(await t.innerPosition(),e),size:J(await t.innerSize(),e)};return c.runtimeSetWindowProps(n)}},{key:r.WINDOW_MOVED,debounce:200,handler:async t=>{const e=await t?.scaleFactor();if(e==null)return null;const i=O(await t.innerPosition(),e),n=await t.isVisible(),l={label:t.label,visible:n,position:i};return c.runtimeSetWindowProps(l)}},{key:r.WINDOW_BLUR,debounce:0,handler:async t=>c.runtimeSetWindowProps({focus:!1,label:t.label})},{key:r.WINDOW_FOCUS,debounce:0,handler:async t=>c.runtimeSetWindowProps({focus:!0,visible:!0,minimized:!1,label:t.label})}],O=(t,e)=>c.Q.scale(t,1/e),J=(t,e)=>c._.scale(t,1/e);exports.TauriRuntime=ye;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./state-BEtTdLcx.cjs"),X=(t,e)=>{let i=null;return e===0?t:(...n)=>{i!==null&&(clearTimeout(i),i=null),i=setTimeout(()=>t(...n),e)}};function ee(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 ie(t,e,i,n,l){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 D;const h="__TAURI_TO_IPC_KEY__";function te(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 ne{get rid(){return ee(this,D,"f")}constructor(e){D.set(this,void 0),ie(this,D,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}D=new WeakMap;var r;(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"})(r||(r={}));async function G(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function f(t,e,i){var n;const l=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:l,handler:te(e)}).then(o=>async()=>G(t,o))}async function R(t,e,i){return f(t,n=>{G(t,n.id),e(n)},i)}async function k(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function H(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}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 b(this.width*e,this.height*e)}[h](){return{width:this.width,height:this.height}}toJSON(){return this[h]()}}class b{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new _(this.width/e,this.height/e)}[h](){return{width:this.width,height:this.height}}toJSON(){return this[h]()}}class w{constructor(e){this.size=e}toLogical(e){return this.size instanceof _?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof b?this.size:this.size.toPhysical(e)}[h](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[h]()}}class N{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new u(this.x*e,this.y*e)}[h](){return{x:this.x,y:this.y}}toJSON(){return this[h]()}}class u{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new N(this.x/e,this.y/e)}[h](){return{x:this.x,y:this.y}}toJSON(){return this[h]()}}class y{constructor(e){this.position=e}toLogical(e){return this.position instanceof N?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[h](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[h]()}}class v extends ne{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:z(e),width:i,height:n}).then(l=>new v(l))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:z(e)}).then(i=>new v(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new v(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 z(t){return t==null?null:typeof t=="string"?t:t instanceof v?t.rid:t}var I;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(I||(I={}));class se{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var T;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(T||(T={}));function j(){return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function E(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new P(e,{skip:!0})))}const x=["tauri://created","tauri://error"];class P{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await E()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return j()}static async getAll(){return E()}static async getFocusedWindow(){for(const e of await E())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(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)}:R(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(x.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return k(e,i)}async emitTo(e,i,n){if(x.includes(i)){for(const l of this.listeners[i]||[])l({event:i,id:-1,payload:n});return}return H(e,i,n)}_handleTauriEvent(e,i){return x.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new u(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new u(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new b(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new b(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===I.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 y?e:new y(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:z(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 y?e:new y(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?z(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(r.WINDOW_RESIZED,i=>{i.payload=new b(i.payload),e(i)})}async onMoved(e){return this.listen(r.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(r.WINDOW_CLOSE_REQUESTED,async i=>{const n=new se(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(r.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(r.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(r.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),o=await this.listen(r.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),o()}}async onFocusChanged(e){const i=await this.listen(r.WINDOW_FOCUS,l=>{e({...l,payload:!0})}),n=await this.listen(r.WINDOW_BLUR,l=>{e({...l,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(r.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(r.WINDOW_THEME_CHANGED,e)}}var C;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(C||(C={}));var M;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(M||(M={}));var F;(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"})(F||(F={}));var B;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(B||(B={}));function le(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new b(t.size),workArea:{position:new u(t.workArea.position),size:new b(t.workArea.size)}}}async function ae(){return s("plugin:window|available_monitors").then(t=>t.map(le))}function J(){return new L(j(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function V(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new L(new P(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const A=["tauri://created","tauri://error"];class L{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await V()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return J()}static async getAll(){return V()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(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)}:R(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(A.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return k(e,i)}async emitTo(e,i,n){if(A.includes(i)){for(const l of this.listeners[i]||[])l({event:i,id:-1,payload:n});return}return H(e,i,n)}_handleTauriEvent(e,i){return A.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new u(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new b(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof w?e:new w(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof y?e:new y(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(r.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(r.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(r.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),o=await this.listen(r.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),o()}}}function q(){const t=J();return new d(t.label,{skip:!0})}async function O(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new d(e,{skip:!0})))}class d{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 l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;const n=(i=(await O()).find(l=>l.label===e))!==null&&i!==void 0?i:null;return n?new d(n.label,{skip:!0}):null}static getCurrent(){return q()}static async getAll(){return O()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:f(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:R(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}))}}re(d,[P,L]);function re(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var l;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(l=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&l!==void 0?l:Object.create(null))})})}const oe=t=>JSON.stringify(t),ue=t=>JSON.parse(t),W="drift://action",ce="tauri://error",he="tauri://created",we=t=>new Error(`Window not found: ${t}`),p=250,be=c.a.seconds(1),m=t=>{if(t!=null)return{width:Math.max(t.width,p),height:Math.max(t.height,p)}},de=t=>{const{size:e,maxSize:i}=t;return{...t,maxSize:m(i),size:m(e)}},ye=async()=>(await ae()).map(e=>{const i=S(e.position,e.scaleFactor),n={width:e.size.width,height:e.size.height};return c.jt.construct(i,n)}),U=async t=>(await ye()).some(i=>c.jt.contains(i,t));class pe{win;unsubscribe;fullscreenPoll=null;constructor(e){this.win=e??q(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll()}async startFullscreenPoll(){if(c.S.getOS()!=="macOS")return;let e=(await this.getProps()).fullscreen;this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(i=>{i!==e&&(e=i,this.emit({action:c.runtimeSetWindowProps({label:this.win.label,fullscreen:i})},void 0,"WHITELIST").catch(console.error))}).catch(console.error)},be.milliseconds)}label(){return this.win.label}isMain(){return this.win.label===c.MAIN_WINDOW}release(){Object.values(this.unsubscribe).forEach(e=>e?.()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.unsubscribe={}}async emit(e,i,n=this.label()){const l=oe({...e,emitter:n});if(i==null)return await k(W,l);const o=await d.getByLabel(i);if(o==null)throw we(i);await o.emit(W,l)}async subscribe(e){this.release(),await this.startFullscreenPoll(),this.unsubscribe[W]=await f(W,n=>e(ue(n.payload)));const i=ge();for(const{key:n,handler:l,debounce:o}of i)this.unsubscribe[n]=await this.win.listen(n,X(()=>{l(this.win).then(a=>{a!=null&&this.emit({action:a},void 0,"WHITELIST").catch(console.error)}).catch(console.error)},o))}onCloseRequested(e){this.win.onCloseRequested(i=>{i.preventDefault(),e()})}async create(e,i){i=c.T.copy(i);const{size:n,minSize:l,maxSize:o,position:a,...$}=de(i);n?.width!=null&&(n.width=Math.max(n.width,p)),n?.height!=null&&(n.height=Math.max(n.height,p)),o?.width!=null&&(o.width=Math.max(o.width,p)),o?.height!=null&&(o.height=Math.max(o.height,p)),a!=null&&(await U(a)||(a.x=0,a.y=0));try{const g=new d(e,{x:a?.x,y:a?.y,width:n?.width,height:n?.height,minWidth:l?.width,minHeight:l?.height,maxWidth:o?.width,maxHeight:o?.height,titleBarStyle:"overlay",dragDropEnabled:!1,...$});return await new Promise((Q,Y)=>{g.once(ce,K=>Y(new Error(JSON.stringify(K.payload)))),g.once(he,()=>Q())})}catch(g){console.error(g)}}async close(e){const i=await d.getByLabel(e);if(i!=null)try{await i.destroy()}catch(n){console.error(n,e)}else{const n=await O();console.error("Window not found",e,n.map(l=>l.label))}}async listLabels(){return(await O()).map(i=>i.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){const i=new N(e.x,e.y);await U(e)||(i.x=0,i.y=0),await this.win.setPosition(i)}async setSize(e){e=m(e),await this.win.setSize(new _(e.width,e.height))}async setMinSize(e){e=m(e),await this.win.setMinSize(new _(e.width,e.height))}async setMaxSize(e){e=m(e),await this.win.setMaxSize(new _(e.width,e.height))}async setResizable(e){return r.WINDOW_RESIZED in this.unsubscribe&&!e&&(this.unsubscribe[r.WINDOW_RESIZED]?.(),delete this.unsubscribe[r.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(){const e=await this.win.scaleFactor(),i=await this.win.isVisible();return{position:S(await this.win.innerPosition(),e),size:Z(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:i,fullscreen:await this.win.isFullscreen()}}}const ge=()=>[{key:r.WINDOW_RESIZED,debounce:200,handler:async t=>{const e=await t.scaleFactor(),i=await t.isVisible(),n={label:t.label,maximized:await t.isMaximized(),visible:i,minimized:!i,position:S(await t.innerPosition(),e),size:Z(await t.innerSize(),e)};return c.runtimeSetWindowProps(n)}},{key:r.WINDOW_MOVED,debounce:200,handler:async t=>{const e=await t?.scaleFactor();if(e==null)return null;const i=S(await t.innerPosition(),e),n=await t.isVisible(),l={label:t.label,visible:n,position:i};return c.runtimeSetWindowProps(l)}},{key:r.WINDOW_BLUR,debounce:0,handler:async t=>c.runtimeSetWindowProps({focus:!1,label:t.label})},{key:r.WINDOW_FOCUS,debounce:0,handler:async t=>c.runtimeSetWindowProps({focus:!0,visible:!0,minimized:!1,label:t.label})}],S=(t,e)=>c.Q.scale(t,1/e),Z=(t,e)=>c._.scale(t,1/e);exports.TauriRuntime=pe;
|
package/dist/tauri.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { G as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { G as ee, H as ie, r as g, M as te, T as ne, _ as se, Q as le, J as G } from "./state-BI4Gp9I9.js";
|
|
2
|
+
const ae = (t, e) => {
|
|
3
|
+
let i = null;
|
|
4
|
+
return e === 0 ? t : (...n) => {
|
|
5
|
+
i !== null && (clearTimeout(i), i = null), i = setTimeout(() => t(...n), e);
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
function re(t, e, i, n) {
|
|
4
9
|
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");
|
|
5
10
|
return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
|
|
6
11
|
}
|
|
7
|
-
function
|
|
12
|
+
function oe(t, e, i, n, l) {
|
|
8
13
|
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");
|
|
9
14
|
return e.set(t, i), i;
|
|
10
15
|
}
|
|
11
16
|
var W;
|
|
12
17
|
const c = "__TAURI_TO_IPC_KEY__";
|
|
13
|
-
function
|
|
18
|
+
function ue(t, e = !1) {
|
|
14
19
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
15
20
|
}
|
|
16
21
|
async function s(t, e = {}, i) {
|
|
17
22
|
return window.__TAURI_INTERNALS__.invoke(t, e, i);
|
|
18
23
|
}
|
|
19
|
-
class
|
|
24
|
+
class ce {
|
|
20
25
|
get rid() {
|
|
21
|
-
return
|
|
26
|
+
return re(this, W, "f");
|
|
22
27
|
}
|
|
23
28
|
constructor(e) {
|
|
24
|
-
W.set(this, void 0),
|
|
29
|
+
W.set(this, void 0), oe(this, W, e);
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Destroys and cleans up this resource from memory.
|
|
@@ -38,24 +43,24 @@ var r;
|
|
|
38
43
|
(function(t) {
|
|
39
44
|
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";
|
|
40
45
|
})(r || (r = {}));
|
|
41
|
-
async function
|
|
46
|
+
async function H(t, e) {
|
|
42
47
|
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
|
|
43
48
|
event: t,
|
|
44
49
|
eventId: e
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
|
-
async function
|
|
52
|
+
async function m(t, e, i) {
|
|
48
53
|
var n;
|
|
49
54
|
const l = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
|
|
50
55
|
return s("plugin:event|listen", {
|
|
51
56
|
event: t,
|
|
52
57
|
target: l,
|
|
53
|
-
handler:
|
|
54
|
-
}).then((o) => async () =>
|
|
58
|
+
handler: ue(e)
|
|
59
|
+
}).then((o) => async () => H(t, o));
|
|
55
60
|
}
|
|
56
61
|
async function R(t, e, i) {
|
|
57
|
-
return
|
|
58
|
-
|
|
62
|
+
return m(t, (n) => {
|
|
63
|
+
H(t, n.id), e(n);
|
|
59
64
|
}, i);
|
|
60
65
|
}
|
|
61
66
|
async function k(t, e) {
|
|
@@ -64,7 +69,7 @@ async function k(t, e) {
|
|
|
64
69
|
payload: e
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
|
-
async function
|
|
72
|
+
async function j(t, e, i) {
|
|
68
73
|
await s("plugin:event|emit_to", {
|
|
69
74
|
target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
|
|
70
75
|
event: e,
|
|
@@ -239,7 +244,7 @@ class d {
|
|
|
239
244
|
return this[c]();
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
|
-
class v extends
|
|
247
|
+
class v extends ce {
|
|
243
248
|
/**
|
|
244
249
|
* Creates an Image from a resource ID. For internal use only.
|
|
245
250
|
*
|
|
@@ -307,7 +312,7 @@ var P;
|
|
|
307
312
|
(function(t) {
|
|
308
313
|
t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
|
|
309
314
|
})(P || (P = {}));
|
|
310
|
-
class
|
|
315
|
+
class he {
|
|
311
316
|
constructor(e) {
|
|
312
317
|
this._preventDefault = !1, this.event = e.event, this.id = e.id;
|
|
313
318
|
}
|
|
@@ -322,7 +327,7 @@ var T;
|
|
|
322
327
|
(function(t) {
|
|
323
328
|
t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
|
|
324
329
|
})(T || (T = {}));
|
|
325
|
-
function
|
|
330
|
+
function J() {
|
|
326
331
|
return new x(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
327
332
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
328
333
|
skip: !0
|
|
@@ -382,7 +387,7 @@ class x {
|
|
|
382
387
|
* Get an instance of `Window` for the current window.
|
|
383
388
|
*/
|
|
384
389
|
static getCurrent() {
|
|
385
|
-
return
|
|
390
|
+
return J();
|
|
386
391
|
}
|
|
387
392
|
/**
|
|
388
393
|
* Gets a list of instances of `Window` for all available windows.
|
|
@@ -429,7 +434,7 @@ class x {
|
|
|
429
434
|
return this._handleTauriEvent(e, i) ? () => {
|
|
430
435
|
const n = this.listeners[e];
|
|
431
436
|
n.splice(n.indexOf(i), 1);
|
|
432
|
-
} :
|
|
437
|
+
} : m(e, i, {
|
|
433
438
|
target: { kind: "Window", label: this.label }
|
|
434
439
|
});
|
|
435
440
|
}
|
|
@@ -505,7 +510,7 @@ class x {
|
|
|
505
510
|
});
|
|
506
511
|
return;
|
|
507
512
|
}
|
|
508
|
-
return
|
|
513
|
+
return j(e, i, n);
|
|
509
514
|
}
|
|
510
515
|
/** @ignore */
|
|
511
516
|
_handleTauriEvent(e, i) {
|
|
@@ -1782,7 +1787,7 @@ class x {
|
|
|
1782
1787
|
*/
|
|
1783
1788
|
async onCloseRequested(e) {
|
|
1784
1789
|
return this.listen(r.WINDOW_CLOSE_REQUESTED, async (i) => {
|
|
1785
|
-
const n = new
|
|
1790
|
+
const n = new he(i);
|
|
1786
1791
|
await e(n), n.isPreventDefault() || await this.destroy();
|
|
1787
1792
|
});
|
|
1788
1793
|
}
|
|
@@ -1923,13 +1928,17 @@ var C;
|
|
|
1923
1928
|
})(C || (C = {}));
|
|
1924
1929
|
var M;
|
|
1925
1930
|
(function(t) {
|
|
1926
|
-
t.
|
|
1931
|
+
t.Default = "default", t.FluentOverlay = "fluentOverlay";
|
|
1927
1932
|
})(M || (M = {}));
|
|
1928
1933
|
var F;
|
|
1929
1934
|
(function(t) {
|
|
1930
|
-
t.
|
|
1935
|
+
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";
|
|
1931
1936
|
})(F || (F = {}));
|
|
1932
|
-
|
|
1937
|
+
var B;
|
|
1938
|
+
(function(t) {
|
|
1939
|
+
t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
|
|
1940
|
+
})(B || (B = {}));
|
|
1941
|
+
function we(t) {
|
|
1933
1942
|
return t === null ? null : {
|
|
1934
1943
|
name: t.name,
|
|
1935
1944
|
scaleFactor: t.scaleFactor,
|
|
@@ -1941,16 +1950,16 @@ function he(t) {
|
|
|
1941
1950
|
}
|
|
1942
1951
|
};
|
|
1943
1952
|
}
|
|
1944
|
-
async function
|
|
1945
|
-
return s("plugin:window|available_monitors").then((t) => t.map(
|
|
1953
|
+
async function be() {
|
|
1954
|
+
return s("plugin:window|available_monitors").then((t) => t.map(we));
|
|
1946
1955
|
}
|
|
1947
|
-
function
|
|
1948
|
-
return new L(
|
|
1956
|
+
function Z() {
|
|
1957
|
+
return new L(J(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
|
|
1949
1958
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
1950
1959
|
skip: !0
|
|
1951
1960
|
});
|
|
1952
1961
|
}
|
|
1953
|
-
async function
|
|
1962
|
+
async function V() {
|
|
1954
1963
|
return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new L(new x(e.windowLabel, {
|
|
1955
1964
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
1956
1965
|
skip: !0
|
|
@@ -2015,19 +2024,19 @@ class L {
|
|
|
2015
2024
|
*/
|
|
2016
2025
|
static async getByLabel(e) {
|
|
2017
2026
|
var i;
|
|
2018
|
-
return (i = (await
|
|
2027
|
+
return (i = (await V()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
2019
2028
|
}
|
|
2020
2029
|
/**
|
|
2021
2030
|
* Get an instance of `Webview` for the current webview.
|
|
2022
2031
|
*/
|
|
2023
2032
|
static getCurrent() {
|
|
2024
|
-
return
|
|
2033
|
+
return Z();
|
|
2025
2034
|
}
|
|
2026
2035
|
/**
|
|
2027
2036
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
2028
2037
|
*/
|
|
2029
2038
|
static async getAll() {
|
|
2030
|
-
return
|
|
2039
|
+
return V();
|
|
2031
2040
|
}
|
|
2032
2041
|
/**
|
|
2033
2042
|
* Listen to an emitted event on this webview.
|
|
@@ -2052,7 +2061,7 @@ class L {
|
|
|
2052
2061
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2053
2062
|
const n = this.listeners[e];
|
|
2054
2063
|
n.splice(n.indexOf(i), 1);
|
|
2055
|
-
} :
|
|
2064
|
+
} : m(e, i, {
|
|
2056
2065
|
target: { kind: "Webview", label: this.label }
|
|
2057
2066
|
});
|
|
2058
2067
|
}
|
|
@@ -2130,7 +2139,7 @@ class L {
|
|
|
2130
2139
|
});
|
|
2131
2140
|
return;
|
|
2132
2141
|
}
|
|
2133
|
-
return
|
|
2142
|
+
return j(e, i, n);
|
|
2134
2143
|
}
|
|
2135
2144
|
/** @ignore */
|
|
2136
2145
|
_handleTauriEvent(e, i) {
|
|
@@ -2405,8 +2414,8 @@ class L {
|
|
|
2405
2414
|
};
|
|
2406
2415
|
}
|
|
2407
2416
|
}
|
|
2408
|
-
function
|
|
2409
|
-
const t =
|
|
2417
|
+
function q() {
|
|
2418
|
+
const t = Z();
|
|
2410
2419
|
return new b(t.label, { skip: !0 });
|
|
2411
2420
|
}
|
|
2412
2421
|
async function O() {
|
|
@@ -2465,7 +2474,7 @@ class b {
|
|
|
2465
2474
|
* Get an instance of `Webview` for the current webview.
|
|
2466
2475
|
*/
|
|
2467
2476
|
static getCurrent() {
|
|
2468
|
-
return
|
|
2477
|
+
return q();
|
|
2469
2478
|
}
|
|
2470
2479
|
/**
|
|
2471
2480
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
@@ -2496,7 +2505,7 @@ class b {
|
|
|
2496
2505
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2497
2506
|
const n = this.listeners[e];
|
|
2498
2507
|
n.splice(n.indexOf(i), 1);
|
|
2499
|
-
} :
|
|
2508
|
+
} : m(e, i, {
|
|
2500
2509
|
target: { kind: "WebviewWindow", label: this.label }
|
|
2501
2510
|
});
|
|
2502
2511
|
}
|
|
@@ -2547,8 +2556,8 @@ class b {
|
|
|
2547
2556
|
return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
|
|
2548
2557
|
}
|
|
2549
2558
|
}
|
|
2550
|
-
|
|
2551
|
-
function
|
|
2559
|
+
de(b, [x, L]);
|
|
2560
|
+
function de(t, e) {
|
|
2552
2561
|
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
2553
2562
|
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
2554
2563
|
var l;
|
|
@@ -2561,7 +2570,7 @@ function be(t, e) {
|
|
|
2561
2570
|
});
|
|
2562
2571
|
});
|
|
2563
2572
|
}
|
|
2564
|
-
const
|
|
2573
|
+
const ye = (t) => JSON.stringify(t), pe = (t) => JSON.parse(t), D = "drift://action", ge = "tauri://error", _e = "tauri://created", ve = (t) => new Error(`Window not found: ${t}`), y = 250, fe = ee.seconds(1), f = (t) => {
|
|
2565
2574
|
if (t != null)
|
|
2566
2575
|
return {
|
|
2567
2576
|
width: Math.max(t.width, y),
|
|
@@ -2569,11 +2578,11 @@ const de = (t) => JSON.stringify(t), ye = (t) => JSON.parse(t), D = "drift://act
|
|
|
2569
2578
|
};
|
|
2570
2579
|
}, me = (t) => {
|
|
2571
2580
|
const { size: e, maxSize: i } = t;
|
|
2572
|
-
return { ...t, maxSize:
|
|
2573
|
-
},
|
|
2581
|
+
return { ...t, maxSize: f(i), size: f(e) };
|
|
2582
|
+
}, De = async () => (await be()).map((e) => {
|
|
2574
2583
|
const i = S(e.position, e.scaleFactor), n = { width: e.size.width, height: e.size.height };
|
|
2575
|
-
return
|
|
2576
|
-
}),
|
|
2584
|
+
return G.construct(i, n);
|
|
2585
|
+
}), U = async (t) => (await De()).some((i) => G.contains(i, t));
|
|
2577
2586
|
class Oe {
|
|
2578
2587
|
win;
|
|
2579
2588
|
unsubscribe;
|
|
@@ -2583,13 +2592,13 @@ class Oe {
|
|
|
2583
2592
|
* This should not be set in 99% of cases. Only use this if you know what you're doing.
|
|
2584
2593
|
*/
|
|
2585
2594
|
constructor(e) {
|
|
2586
|
-
this.win = e ??
|
|
2595
|
+
this.win = e ?? q(), this.unsubscribe = {};
|
|
2587
2596
|
}
|
|
2588
2597
|
async configure() {
|
|
2589
2598
|
await this.startFullscreenPoll();
|
|
2590
2599
|
}
|
|
2591
2600
|
async startFullscreenPoll() {
|
|
2592
|
-
if (
|
|
2601
|
+
if (ie.getOS() !== "macOS") return;
|
|
2593
2602
|
let e = (await this.getProps()).fullscreen;
|
|
2594
2603
|
this.fullscreenPoll != null && clearInterval(this.fullscreenPoll), this.fullscreenPoll = setInterval(() => {
|
|
2595
2604
|
this.win.isFullscreen().then((i) => {
|
|
@@ -2604,34 +2613,34 @@ class Oe {
|
|
|
2604
2613
|
"WHITELIST"
|
|
2605
2614
|
).catch(console.error));
|
|
2606
2615
|
}).catch(console.error);
|
|
2607
|
-
},
|
|
2616
|
+
}, fe.milliseconds);
|
|
2608
2617
|
}
|
|
2609
2618
|
label() {
|
|
2610
2619
|
return this.win.label;
|
|
2611
2620
|
}
|
|
2612
2621
|
isMain() {
|
|
2613
|
-
return this.win.label ===
|
|
2622
|
+
return this.win.label === te;
|
|
2614
2623
|
}
|
|
2615
2624
|
release() {
|
|
2616
2625
|
Object.values(this.unsubscribe).forEach((e) => e?.()), this.fullscreenPoll != null && clearInterval(this.fullscreenPoll), this.unsubscribe = {};
|
|
2617
2626
|
}
|
|
2618
2627
|
async emit(e, i, n = this.label()) {
|
|
2619
|
-
const l =
|
|
2628
|
+
const l = ye({ ...e, emitter: n });
|
|
2620
2629
|
if (i == null) return await k(D, l);
|
|
2621
2630
|
const o = await b.getByLabel(i);
|
|
2622
|
-
if (o == null) throw
|
|
2631
|
+
if (o == null) throw ve(i);
|
|
2623
2632
|
await o.emit(D, l);
|
|
2624
2633
|
}
|
|
2625
2634
|
async subscribe(e) {
|
|
2626
|
-
this.release(), await this.startFullscreenPoll(), this.unsubscribe[D] = await
|
|
2635
|
+
this.release(), await this.startFullscreenPoll(), this.unsubscribe[D] = await m(
|
|
2627
2636
|
D,
|
|
2628
|
-
(n) => e(
|
|
2637
|
+
(n) => e(pe(n.payload))
|
|
2629
2638
|
);
|
|
2630
|
-
const i =
|
|
2639
|
+
const i = We();
|
|
2631
2640
|
for (const { key: n, handler: l, debounce: o } of i)
|
|
2632
2641
|
this.unsubscribe[n] = await this.win.listen(
|
|
2633
2642
|
n,
|
|
2634
|
-
|
|
2643
|
+
ae(() => {
|
|
2635
2644
|
l(this.win).then((a) => {
|
|
2636
2645
|
a != null && this.emit({ action: a }, void 0, "WHITELIST").catch(
|
|
2637
2646
|
console.error
|
|
@@ -2646,9 +2655,9 @@ class Oe {
|
|
|
2646
2655
|
});
|
|
2647
2656
|
}
|
|
2648
2657
|
async create(e, i) {
|
|
2649
|
-
i =
|
|
2650
|
-
const { size: n, minSize: l, maxSize: o, position: a,
|
|
2651
|
-
n?.width != null && (n.width = Math.max(n.width, y)), n?.height != null && (n.height = Math.max(n.height, y)), o?.width != null && (o.width = Math.max(o.width, y)), o?.height != null && (o.height = Math.max(o.height, y)), a != null && (await
|
|
2658
|
+
i = ne.copy(i);
|
|
2659
|
+
const { size: n, minSize: l, maxSize: o, position: a, ...Q } = me(i);
|
|
2660
|
+
n?.width != null && (n.width = Math.max(n.width, y)), n?.height != null && (n.height = Math.max(n.height, y)), o?.width != null && (o.width = Math.max(o.width, y)), o?.height != null && (o.height = Math.max(o.height, y)), a != null && (await U(a) || (a.x = 0, a.y = 0));
|
|
2652
2661
|
try {
|
|
2653
2662
|
const p = new b(e, {
|
|
2654
2663
|
x: a?.x,
|
|
@@ -2661,10 +2670,10 @@ class Oe {
|
|
|
2661
2670
|
maxHeight: o?.height,
|
|
2662
2671
|
titleBarStyle: "overlay",
|
|
2663
2672
|
dragDropEnabled: !1,
|
|
2664
|
-
|
|
2673
|
+
...Q
|
|
2665
2674
|
});
|
|
2666
|
-
return await new Promise((
|
|
2667
|
-
p.once(
|
|
2675
|
+
return await new Promise((Y, K) => {
|
|
2676
|
+
p.once(ge, (X) => K(new Error(JSON.stringify(X.payload)))), p.once(_e, () => Y());
|
|
2668
2677
|
});
|
|
2669
2678
|
} catch (p) {
|
|
2670
2679
|
console.error(p);
|
|
@@ -2710,16 +2719,16 @@ class Oe {
|
|
|
2710
2719
|
}
|
|
2711
2720
|
async setPosition(e) {
|
|
2712
2721
|
const i = new N(e.x, e.y);
|
|
2713
|
-
await
|
|
2722
|
+
await U(e) || (i.x = 0, i.y = 0), await this.win.setPosition(i);
|
|
2714
2723
|
}
|
|
2715
2724
|
async setSize(e) {
|
|
2716
|
-
e =
|
|
2725
|
+
e = f(e), await this.win.setSize(new _(e.width, e.height));
|
|
2717
2726
|
}
|
|
2718
2727
|
async setMinSize(e) {
|
|
2719
|
-
e =
|
|
2728
|
+
e = f(e), await this.win.setMinSize(new _(e.width, e.height));
|
|
2720
2729
|
}
|
|
2721
2730
|
async setMaxSize(e) {
|
|
2722
|
-
e =
|
|
2731
|
+
e = f(e), await this.win.setMaxSize(new _(e.width, e.height));
|
|
2723
2732
|
}
|
|
2724
2733
|
async setResizable(e) {
|
|
2725
2734
|
return r.WINDOW_RESIZED in this.unsubscribe && !e && (this.unsubscribe[r.WINDOW_RESIZED]?.(), delete this.unsubscribe[r.WINDOW_RESIZED]), await this.win.setResizable(e);
|
|
@@ -2740,14 +2749,14 @@ class Oe {
|
|
|
2740
2749
|
const e = await this.win.scaleFactor(), i = await this.win.isVisible();
|
|
2741
2750
|
return {
|
|
2742
2751
|
position: S(await this.win.innerPosition(), e),
|
|
2743
|
-
size:
|
|
2752
|
+
size: $(await this.win.innerSize(), e),
|
|
2744
2753
|
maximized: await this.win.isMaximized(),
|
|
2745
2754
|
visible: i,
|
|
2746
2755
|
fullscreen: await this.win.isFullscreen()
|
|
2747
2756
|
};
|
|
2748
2757
|
}
|
|
2749
2758
|
}
|
|
2750
|
-
const
|
|
2759
|
+
const We = () => [
|
|
2751
2760
|
{
|
|
2752
2761
|
key: r.WINDOW_RESIZED,
|
|
2753
2762
|
debounce: 200,
|
|
@@ -2758,7 +2767,7 @@ const De = () => [
|
|
|
2758
2767
|
visible: i,
|
|
2759
2768
|
minimized: !i,
|
|
2760
2769
|
position: S(await t.innerPosition(), e),
|
|
2761
|
-
size:
|
|
2770
|
+
size: $(await t.innerSize(), e)
|
|
2762
2771
|
};
|
|
2763
2772
|
return g(n);
|
|
2764
2773
|
}
|
|
@@ -2792,7 +2801,7 @@ const De = () => [
|
|
|
2792
2801
|
label: t.label
|
|
2793
2802
|
})
|
|
2794
2803
|
}
|
|
2795
|
-
], S = (t, e) =>
|
|
2804
|
+
], S = (t, e) => le.scale(t, 1 / e), $ = (t, e) => se.scale(t, 1 / e);
|
|
2796
2805
|
export {
|
|
2797
2806
|
Oe as TauriRuntime
|
|
2798
2807
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/drift",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "State synchronization and Redux state synchronization for Tauri Apps",
|
|
5
5
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/drift",
|
|
6
6
|
"type": "module",
|
|
@@ -10,34 +10,33 @@
|
|
|
10
10
|
"tauri",
|
|
11
11
|
"redux",
|
|
12
12
|
"react",
|
|
13
|
-
"electron",
|
|
14
13
|
"application level state"
|
|
15
14
|
],
|
|
16
15
|
"dependencies": {
|
|
17
|
-
"@reduxjs/toolkit": "^2.
|
|
18
|
-
"@tauri-apps/api": "^2.
|
|
16
|
+
"@reduxjs/toolkit": "^2.10.1",
|
|
17
|
+
"@tauri-apps/api": "^2.9.0",
|
|
19
18
|
"async-mutex": "^0.5.0",
|
|
20
19
|
"proxy-memoize": "2.0.3",
|
|
21
|
-
"react": "^19.
|
|
22
|
-
"react-dom": "^19.
|
|
20
|
+
"react": "^19.2.0",
|
|
21
|
+
"react-dom": "^19.2.0",
|
|
23
22
|
"react-redux": "^9.2.0",
|
|
24
|
-
"zod": "^4.1.
|
|
25
|
-
"@synnaxlabs/x": "^0.
|
|
23
|
+
"zod": "^4.1.12",
|
|
24
|
+
"@synnaxlabs/x": "^0.48.0"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@types/react": "^19.
|
|
29
|
-
"@vitejs/plugin-react": "^5.0
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"react": "^19.
|
|
33
|
-
"react-dom": "^19.
|
|
27
|
+
"@types/react": "^19.2.2",
|
|
28
|
+
"@vitejs/plugin-react": "^5.1.0",
|
|
29
|
+
"eslint": "^9.39.1",
|
|
30
|
+
"madge": "^8.0.0",
|
|
31
|
+
"react": "^19.2.0",
|
|
32
|
+
"react-dom": "^19.2.0",
|
|
34
33
|
"react-redux": "^9.2.0",
|
|
35
|
-
"typescript": "^5.9.
|
|
36
|
-
"vite": "^7.1.
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vite": "^7.1.12",
|
|
37
36
|
"vitest": "^3.2.4",
|
|
38
37
|
"@synnaxlabs/tsconfig": "^0.43.0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
38
|
+
"@synnaxlabs/vite-plugin": "^0.43.0",
|
|
39
|
+
"eslint-config-synnaxlabs": "^0.43.0"
|
|
41
40
|
},
|
|
42
41
|
"files": [
|
|
43
42
|
"dist"
|
|
@@ -60,11 +59,6 @@
|
|
|
60
59
|
"types": "./dist/src/tauri/index.d.ts",
|
|
61
60
|
"import": "./dist/tauri.js",
|
|
62
61
|
"require": "./dist/tauri.cjs"
|
|
63
|
-
},
|
|
64
|
-
"./electron": {
|
|
65
|
-
"types": "./dist/src/electron/index.d.ts",
|
|
66
|
-
"import": "./dist/electron.js",
|
|
67
|
-
"require": "./dist/electron.cjs"
|
|
68
62
|
}
|
|
69
63
|
},
|
|
70
64
|
"scripts": {
|
|
@@ -73,6 +67,7 @@
|
|
|
73
67
|
"watch": "tsc --noEmit && vite build --watch",
|
|
74
68
|
"test": "vitest",
|
|
75
69
|
"lint": "eslint",
|
|
76
|
-
"fix": "eslint --fix"
|
|
70
|
+
"fix": "eslint --fix",
|
|
71
|
+
"madge": "madge --circular src"
|
|
77
72
|
}
|
|
78
73
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=(l,u)=>{let t=null;return u===0?l:(...e)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>l(...e),u)}};exports.o=n;
|