@synnaxlabs/drift 0.42.0 → 0.42.1

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/electron.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var R=Object.defineProperty;var B=(t,e,o)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var m=(t,e,o)=>B(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./window-DLsE0-fP.cjs"),q=require("./state-Ckw4CzST.cjs"),H=require("./debounce-BUAIXXZt.cjs"),E="drift://action",p="drift://create",w="drift://focus",b="drift://close",I="drift://set-minimized",N="drift://set-maximized",z="drift://set-visible",y="drift://set-fullscreen",M="drift://center",O="drift://set-position",A="drift://set-size",g="drift://set-min-size",V="drift://set-max-size",x="drift://set-resizable",W="drift://set-skip-taskbar",P="drift://set-always-on-top",k="drift://set-title",L="drift://set-decorations",S="drift://get-props",D="drift://get-label",Z=[E,p,w,b,I,N,z,y,M,O,A,g,V,x,W,P,k,L,S],F=t=>{if(!Z.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},U=[E],$=t=>{if(!U.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},G=[S,D],J=t=>{if(!G.includes(t))throw new Error(`Command ${t} is not on the list of allowed commands`)},K=t=>{var e,o,r,l,u,d,T,f;return{x:(e=t.position)==null?void 0:e.x,y:(o=t.position)==null?void 0:o.y,width:(r=t.size)==null?void 0:r.width,height:(l=t.size)==null?void 0:l.height,center:t.center,minHeight:(u=t.minSize)==null?void 0:u.height,minWidth:(d=t.minSize)==null?void 0:d.width,maxHeight:(T=t.maxSize)==null?void 0:T.height,maxWidth:(f=t.maxSize)==null?void 0:f.width,resizable:t.resizable,fullscreen:t.fullscreen,skipTaskbar:t.skipTaskbar,title:t.title,show:t.visible,transparent:t.transparent,alwaysOnTop:t.alwaysOnTop}},X=t=>{const[e,o]=t.getSize(),[r,l]=t.getPosition();return{size:{width:e,height:o},position:{x:r,y:l},minimized:t.isMinimized(),maximized:t.isMaximized(),fullscreen:t.isFullScreen(),visible:t.isVisible(),resizable:t.isResizable(),skipTaskbar:!1,title:t.getTitle(),alwaysOnTop:t.isAlwaysOnTop(),decorations:!1}},j=({mainWindow:t,createWindow:e})=>{const o=new Map,r=new Map;o.set(_.MAIN_WINDOW,t.id),r.set(t.id,_.MAIN_WINDOW);const{ipcMain:l,BrowserWindow:u}=require("electron"),d=(s,i)=>l.on(s,(n,a)=>{const c=u.fromWebContents(n.sender);c!=null&&i(c,a)});l.on(b,(s,i)=>{const n=o.get(i);if(n==null)return;const a=u.fromId(n);a!=null&&(a.close(),o.delete(i),r.delete(n))}),l.handle(S,s=>{const i=u.fromWebContents(s.sender);return i==null?void 0:{...X(i),label:r.get(i.id)}}),l.handle(D,s=>{const i=u.fromWebContents(s.sender);if(i!=null)return r.get(i.id)});const T=(s,i,n)=>{s.on(i,H.o(n,500))},f=s=>{var i;for(const n of r.keys())(i=u.fromId(n))==null||i.webContents.send(E,s)},C=(s,i)=>{const n=(a,c)=>{T(i,a,()=>{f({action:q.runtimeSetWindowProps({label:s,...c(i)}),emitter:"WHITELIST"})})};n("resize",a=>{const[c,v]=a.getSize();return{size:{width:c,height:v}}}),n("move",()=>{const[a,c]=i.getPosition();return{position:{x:a,y:c}}}),n("minimize",()=>({minimized:!0})),n("restore",()=>({minimized:!1})),n("maximize",()=>({maximized:!0})),n("unmaximize",()=>({maximized:!1})),n("enter-full-screen",a=>(a.setWindowButtonVisibility(!0),{fullscreen:!0})),n("leave-full-screen",()=>(i.setWindowButtonVisibility(!1),{fullscreen:!1}))};C(_.MAIN_WINDOW,t),d(w,s=>s.focus()),d(I,s=>s.minimize()),d(N,s=>s.maximize()),d(z,(s,i)=>i?s.show():s.hide()),d(y,s=>s.setFullScreen(!0)),d(M,s=>s.center()),d(O,(s,{x:i,y:n})=>{s.setPosition(Math.round(i),Math.round(n))}),d(A,(s,{width:i,height:n})=>{s.setSize(Math.round(i),Math.round(n))}),d(g,(s,{width:i,height:n})=>s.setMinimumSize(Math.round(i),Math.round(n))),d(V,(s,{width:i,height:n})=>s.setMaximumSize(Math.round(i),Math.round(n))),d(x,(s,i)=>s.setResizable(i)),d(W,(s,i)=>s.setSkipTaskbar(i)),d(P,(s,i)=>s.setAlwaysOnTop(i)),d(k,(s,i)=>s.setTitle(i)),l.on(p,(s,i,n)=>{const a=e(K(n));o.set(i,a.id),r.set(a.id,i),C(i,a)}),l.on(E,(s,i,n)=>{if(i==null)return;if(n==null)return f(i);const a=o.get(n);if(a==null)return;const c=u.fromId(a);c!=null&&c.webContents.send(E,i)})},h="driftAPI",Y=()=>{const{ipcRenderer:t,contextBridge:e}=require("electron"),o={send:(r,...l)=>{F(r),t.send(r,...l)},invoke:async(r,...l)=>(J(r),await t.invoke(r,...l)),on:(r,l)=>{$(r),t.on(r,l)}};e.exposeInMainWorld(h,o)},Q=async()=>{if(!(h in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");return await window[h].invoke(D)};class ee{constructor(){m(this,"_label","");m(this,"props",null);m(this,"api");if(!(h in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");this.api=window[h]}async configure(){const{label:e,...o}=await this.api.invoke(S);this._label=e,this.props=o}label(){return this._label}isMain(){return this._label===_.MAIN_WINDOW}release(){}async emit(e,o){this.api.send(E,{...e,emitter:this.label()},o)}async subscribe(e){this.api.on(E,(o,r)=>e(r))}onCloseRequested(){}async create(e,o){this.api.send(p,e,JSON.parse(JSON.stringify(o)))}async close(e){this.api.send(b,e)}async listLabels(){return[]}async focus(){this.api.send(w)}async setMinimized(e){this.api.send(I,e)}async setMaximized(e){this.api.send(N,e)}async setVisible(e){this.api.send(z,e)}async setFullscreen(e){this.api.send(y,e)}async center(){this.api.send(M)}async setPosition(e){this.api.send(O,e)}async setSize(e){this.api.send(A,e)}async setMinSize(e){this.api.send(g,e)}async setMaxSize(e){this.api.send(V,e)}async setResizable(e){this.api.send(x,e)}async setSkipTaskbar(e){this.api.send(W,e)}async setAlwaysOnTop(e){this.api.send(P,e)}async setTitle(e){this.api.send(k,e)}async setDecorations(e){this.api.send(L,e)}async getProps(){if(this.props!=null)return this.props;throw new Error("Window not found")}}exports.ElectronRuntime=ee;exports.exposeAPI=Y;exports.getWindowLabel=Q;exports.listenOnMain=j;
1
+ "use strict";var R=Object.defineProperty;var B=(t,e,o)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var m=(t,e,o)=>B(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./window-DLsE0-fP.cjs"),q=require("./state-Cl8us-b9.cjs"),H=require("./debounce-BUAIXXZt.cjs"),E="drift://action",p="drift://create",w="drift://focus",b="drift://close",I="drift://set-minimized",N="drift://set-maximized",z="drift://set-visible",y="drift://set-fullscreen",M="drift://center",O="drift://set-position",A="drift://set-size",g="drift://set-min-size",V="drift://set-max-size",x="drift://set-resizable",W="drift://set-skip-taskbar",P="drift://set-always-on-top",k="drift://set-title",L="drift://set-decorations",S="drift://get-props",D="drift://get-label",Z=[E,p,w,b,I,N,z,y,M,O,A,g,V,x,W,P,k,L,S],F=t=>{if(!Z.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},U=[E],$=t=>{if(!U.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},G=[S,D],J=t=>{if(!G.includes(t))throw new Error(`Command ${t} is not on the list of allowed commands`)},K=t=>{var e,o,r,l,u,d,T,f;return{x:(e=t.position)==null?void 0:e.x,y:(o=t.position)==null?void 0:o.y,width:(r=t.size)==null?void 0:r.width,height:(l=t.size)==null?void 0:l.height,center:t.center,minHeight:(u=t.minSize)==null?void 0:u.height,minWidth:(d=t.minSize)==null?void 0:d.width,maxHeight:(T=t.maxSize)==null?void 0:T.height,maxWidth:(f=t.maxSize)==null?void 0:f.width,resizable:t.resizable,fullscreen:t.fullscreen,skipTaskbar:t.skipTaskbar,title:t.title,show:t.visible,transparent:t.transparent,alwaysOnTop:t.alwaysOnTop}},X=t=>{const[e,o]=t.getSize(),[r,l]=t.getPosition();return{size:{width:e,height:o},position:{x:r,y:l},minimized:t.isMinimized(),maximized:t.isMaximized(),fullscreen:t.isFullScreen(),visible:t.isVisible(),resizable:t.isResizable(),skipTaskbar:!1,title:t.getTitle(),alwaysOnTop:t.isAlwaysOnTop(),decorations:!1}},j=({mainWindow:t,createWindow:e})=>{const o=new Map,r=new Map;o.set(_.MAIN_WINDOW,t.id),r.set(t.id,_.MAIN_WINDOW);const{ipcMain:l,BrowserWindow:u}=require("electron"),d=(s,i)=>l.on(s,(n,a)=>{const c=u.fromWebContents(n.sender);c!=null&&i(c,a)});l.on(b,(s,i)=>{const n=o.get(i);if(n==null)return;const a=u.fromId(n);a!=null&&(a.close(),o.delete(i),r.delete(n))}),l.handle(S,s=>{const i=u.fromWebContents(s.sender);return i==null?void 0:{...X(i),label:r.get(i.id)}}),l.handle(D,s=>{const i=u.fromWebContents(s.sender);if(i!=null)return r.get(i.id)});const T=(s,i,n)=>{s.on(i,H.o(n,500))},f=s=>{var i;for(const n of r.keys())(i=u.fromId(n))==null||i.webContents.send(E,s)},C=(s,i)=>{const n=(a,c)=>{T(i,a,()=>{f({action:q.runtimeSetWindowProps({label:s,...c(i)}),emitter:"WHITELIST"})})};n("resize",a=>{const[c,v]=a.getSize();return{size:{width:c,height:v}}}),n("move",()=>{const[a,c]=i.getPosition();return{position:{x:a,y:c}}}),n("minimize",()=>({minimized:!0})),n("restore",()=>({minimized:!1})),n("maximize",()=>({maximized:!0})),n("unmaximize",()=>({maximized:!1})),n("enter-full-screen",a=>(a.setWindowButtonVisibility(!0),{fullscreen:!0})),n("leave-full-screen",()=>(i.setWindowButtonVisibility(!1),{fullscreen:!1}))};C(_.MAIN_WINDOW,t),d(w,s=>s.focus()),d(I,s=>s.minimize()),d(N,s=>s.maximize()),d(z,(s,i)=>i?s.show():s.hide()),d(y,s=>s.setFullScreen(!0)),d(M,s=>s.center()),d(O,(s,{x:i,y:n})=>{s.setPosition(Math.round(i),Math.round(n))}),d(A,(s,{width:i,height:n})=>{s.setSize(Math.round(i),Math.round(n))}),d(g,(s,{width:i,height:n})=>s.setMinimumSize(Math.round(i),Math.round(n))),d(V,(s,{width:i,height:n})=>s.setMaximumSize(Math.round(i),Math.round(n))),d(x,(s,i)=>s.setResizable(i)),d(W,(s,i)=>s.setSkipTaskbar(i)),d(P,(s,i)=>s.setAlwaysOnTop(i)),d(k,(s,i)=>s.setTitle(i)),l.on(p,(s,i,n)=>{const a=e(K(n));o.set(i,a.id),r.set(a.id,i),C(i,a)}),l.on(E,(s,i,n)=>{if(i==null)return;if(n==null)return f(i);const a=o.get(n);if(a==null)return;const c=u.fromId(a);c!=null&&c.webContents.send(E,i)})},h="driftAPI",Y=()=>{const{ipcRenderer:t,contextBridge:e}=require("electron"),o={send:(r,...l)=>{F(r),t.send(r,...l)},invoke:async(r,...l)=>(J(r),await t.invoke(r,...l)),on:(r,l)=>{$(r),t.on(r,l)}};e.exposeInMainWorld(h,o)},Q=async()=>{if(!(h in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");return await window[h].invoke(D)};class ee{constructor(){m(this,"_label","");m(this,"props",null);m(this,"api");if(!(h in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");this.api=window[h]}async configure(){const{label:e,...o}=await this.api.invoke(S);this._label=e,this.props=o}label(){return this._label}isMain(){return this._label===_.MAIN_WINDOW}release(){}async emit(e,o){this.api.send(E,{...e,emitter:this.label()},o)}async subscribe(e){this.api.on(E,(o,r)=>e(r))}onCloseRequested(){}async create(e,o){this.api.send(p,e,JSON.parse(JSON.stringify(o)))}async close(e){this.api.send(b,e)}async listLabels(){return[]}async focus(){this.api.send(w)}async setMinimized(e){this.api.send(I,e)}async setMaximized(e){this.api.send(N,e)}async setVisible(e){this.api.send(z,e)}async setFullscreen(e){this.api.send(y,e)}async center(){this.api.send(M)}async setPosition(e){this.api.send(O,e)}async setSize(e){this.api.send(A,e)}async setMinSize(e){this.api.send(g,e)}async setMaxSize(e){this.api.send(V,e)}async setResizable(e){this.api.send(x,e)}async setSkipTaskbar(e){this.api.send(W,e)}async setAlwaysOnTop(e){this.api.send(P,e)}async setTitle(e){this.api.send(k,e)}async setDecorations(e){this.api.send(L,e)}async getProps(){if(this.props!=null)return this.props;throw new Error("Window not found")}}exports.ElectronRuntime=ee;exports.exposeAPI=Y;exports.getWindowLabel=Q;exports.listenOnMain=j;
package/dist/electron.js CHANGED
@@ -2,7 +2,7 @@ var R = Object.defineProperty;
2
2
  var B = (t, e, o) => e in t ? R(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
3
  var m = (t, e, o) => B(t, typeof e != "symbol" ? e + "" : e, o);
4
4
  import { M as _ } from "./window-BIbHrbtA.js";
5
- import { r as H } from "./state-D8a0PvFs.js";
5
+ import { r as H } from "./state-BOplmOQD.js";
6
6
  import { o as Z } from "./debounce-DOZKRZa9.js";
7
7
  const E = "drift://action", S = "drift://create", w = "drift://focus", z = "drift://close", b = "drift://set-minimized", y = "drift://set-maximized", I = "drift://set-visible", N = "drift://set-fullscreen", M = "drift://center", O = "drift://set-position", g = "drift://set-size", A = "drift://set-min-size", V = "drift://set-max-size", x = "drift://set-resizable", k = "drift://set-skip-taskbar", C = "drift://set-always-on-top", P = "drift://set-title", L = "drift://set-decorations", p = "drift://get-props", W = "drift://get-label", F = [
8
8
  E,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@reduxjs/toolkit"),o=require("./state-Ckw4CzST.cjs"),f=require("./window-DLsE0-fP.cjs"),h=require("./selectors-jksTA_U1.cjs"),C=new Error("request for lock canceled");var L=function(i,e,s,t){function n(a){return a instanceof s?a:new s(function(r){r(a)})}return new(s||(s=Promise))(function(a,r){function l(c){try{u(t.next(c))}catch(w){r(w)}}function d(c){try{u(t.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((t=t.apply(i,e||[])).next())})};class N{constructor(e,s=C){this._value=e,this._cancelError=s,this._queue=[],this._weightedWaiters=[]}acquire(e=1,s=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,n)=>{const a={resolve:t,reject:n,weight:e,priority:s},r=T(this._queue,l=>s<=l.priority);r===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(r+1,0,a)})}runExclusive(e){return L(this,arguments,void 0,function*(s,t=1,n=0){const[a,r]=yield this.acquire(t,n);try{return yield s(a)}finally{r()}})}waitForUnlock(e=1,s=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,s)?Promise.resolve():new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),P(this._weightedWaiters[e-1],{resolve:t,priority:s})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const s=this._value;this._value-=e.weight,e.resolve([s,this._newReleaser(e.weight)])}_newReleaser(e){let s=!1;return()=>{s||(s=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const s=this._weightedWaiters[e-1];s&&(s.forEach(t=>t.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let s=this._value;s>0;s--){const t=this._weightedWaiters[s-1];if(!t)continue;const n=t.findIndex(a=>a.priority<=e);(n===-1?t:t.splice(0,n)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,s){return(this._queue.length===0||this._queue[0].priority<s)&&e<=this._value}}function P(i,e){const s=T(i,t=>e.priority<=t.priority);i.splice(s+1,0,e)}function T(i,e){for(let s=i.length-1;s>=0;s--)if(e(i[s]))return s;return-1}var q=function(i,e,s,t){function n(a){return a instanceof s?a:new s(function(r){r(a)})}return new(s||(s=Promise))(function(a,r){function l(c){try{u(t.next(c))}catch(w){r(w)}}function d(c){try{u(t.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((t=t.apply(i,e||[])).next())})};class D{constructor(e){this._semaphore=new N(1,e)}acquire(){return q(this,arguments,void 0,function*(e=0){const[,s]=yield this._semaphore.acquire(1,e);return s})}runExclusive(e,s=0){return this._semaphore.runExclusive(()=>e(),1,s)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const R=i=>[...new Set(i)],F=(i,e,s=!0)=>{const t=new Map;return i.forEach(n=>{const a=e(n);if(t.has(a)){if(s)return;t.delete(a)}t.set(a,n)}),Array.from(t.values())},V=Object.freeze(Object.defineProperty({__proto__:null,by:F,unique:R},Symbol.toStringTag,{value:"Module"})),I="DA@",M="://",j=(i,e)=>I.concat(e,M,i),Z=i=>{const[e,s]=i.split(M);if(s==null)return[i,""];const[,t]=e.split(I);return[s,t]},z=(i,e)=>({...i,type:j(i.type,e)}),U=i=>{const[e,s]=Z(i.type);return{emitted:s!=null&&s.length>0,emitter:s,action:{...i,type:e}}},K=i=>{const{centerCount:e,processCount:s,focusCount:t,stage:n,key:a,prerenderLabel:r,reserved:l,minimized:d,...u}=i;return u},Q=async(i,e,s,t)=>{const n=(await s.listLabels()).filter(c=>c!==f.MAIN_WINDOW),a=Object.keys(i.windows).filter(c=>c!==f.MAIN_WINDOW);o.group(t,"syncInitial"),o.log(t,"existing windows in runtime",n.sort()),o.log(t,"non-main windows in state",a.sort()),o.groupEnd(t);const r=V.unique([...n,...a]);for(const c of r)!n.includes(c)&&s.isMain()?(o.log(t,"state window not in runtime, creating",c),await v(s,c,i.windows[c],t)):a.includes(c)||(o.log(t,"runtime window not in state, closing",c),await y(s,c,t));const l=s.label(),d=i.windows[l];if(d==null)return;const u={...f.INITIAL_WINDOW_STATE};await k(u,d,s,t),e(o.runtimeSetWindowProps({label:s.label(),...await s.getProps()}))},X=async(i,e,s,t)=>{o.log(t,"sync",i,e),s.isMain()&&await $(i,e,s,t);const n=i.windows[s.label()],a=e.windows[s.label()];n==null||a==null||await k(n,a,s,t)},k=async(i,e,s,t)=>{const n=[];e.title!=null&&e.title!==i.title&&n.push(["title",{prev:i.title,next:e.title},async()=>s.setTitle(e.title)]);const a=e.visible!=null&&e.visible!==i.visible,r=e.visible===!1,l=()=>n.push(["visible",{prev:i.visible,next:e.visible},async()=>{if(await s.setVisible(e.visible),e.visible===!1)return;let d=e.position;d??(d=(await s.getProps()).position),await s.setPosition(f.J.translate(d,{x:1,y:1})),await s.setPosition(d)}]);if(a&&r&&l(),e.skipTaskbar!=null&&e.skipTaskbar!==i.skipTaskbar&&n.push(["skipTaskbar",{prev:i.skipTaskbar,next:e.skipTaskbar},async()=>await s.setSkipTaskbar(e.skipTaskbar)]),e.maximized!=null&&e.maximized!==i.maximized&&n.push(["maximized",{prev:i.maximized,next:e.maximized},async()=>await s.setMaximized(e.maximized)]),e.fullscreen!=null&&e.fullscreen!==i.fullscreen&&n.push(["fullscreen",{prev:i.fullscreen,next:e.fullscreen},async()=>await s.setFullscreen(e.fullscreen)]),e.centerCount!==i.centerCount&&n.push(["center",{prev:i.centerCount,next:e.centerCount},async()=>s.center()]),e.minimized!=null&&e.minimized!==i.minimized&&n.push(["minimized",{prev:i.minimized,next:e.minimized},async()=>await s.setMinimized(e.minimized)]),e.resizable!=null&&e.resizable!==i.resizable&&n.push(["resizable",{prev:i.resizable,next:e.resizable},async()=>await s.setResizable(e.resizable)]),e.minSize!=null&&!f._.equals(e.minSize,i.minSize)&&n.push(["minSize",{prev:i.minSize,next:e.minSize},async()=>await s.setMinSize(e.minSize)]),e.maxSize!=null&&!f._.equals(e.maxSize,i.maxSize)&&n.push(["maxSize",{prev:i.maxSize,next:e.maxSize},async()=>await s.setMaxSize(e.maxSize)]),e.size!=null&&!f._.equals(e.size,i.size)&&n.push(["size",{prev:i.size,next:e.size},async()=>await s.setSize(e.size)]),e.position!=null&&!f._.equals(e.position,i.position)&&n.push(["position",{prev:i.position,next:e.position},async()=>await s.setPosition(e.position)]),e.focusCount!==i.focusCount&&n.push(["setVisible",{prev:i.visible,next:e.visible},async()=>await s.setVisible(!0)],["focus",{prev:i.focusCount,next:e.focusCount},async()=>await s.focus()]),e.decorations!=null&&e.decorations!==i.decorations&&n.push(["decorations",{prev:i.decorations,next:e.decorations},async()=>await s.setDecorations(e.decorations)]),e.alwaysOnTop!=null&&e.alwaysOnTop!==i.alwaysOnTop&&n.push(["alwaysOnTop",{prev:i.alwaysOnTop,next:e.alwaysOnTop},async()=>await s.setAlwaysOnTop(e.alwaysOnTop)]),a&&!r&&l(),n.length!==0){o.group(t,`syncCurrent, label: ${s.label()}, key: ${e.key}`);for(const[d,{prev:u,next:c}]of n)o.log(t,d,u,"->",c);o.groupEnd(t);for(const[,,d]of n)await d()}},$=async(i,e,s,t)=>{const n=Object.keys(i.windows).filter(l=>!(l in e.windows)),a=Object.keys(e.windows).filter(l=>!(l in i.windows)),r=s.isMain();if(r&&n.length>0)for(const l of n)o.log(t,"syncMain","closing",l),l===f.MAIN_WINDOW&&await Promise.all(Object.keys(e.windows).filter(d=>d!==f.MAIN_WINDOW).map(async d=>await y(s,d,t))),await y(s,l,t);if(r&&a.length>0)for(const l of a)await v(s,l,e.windows[l],t)},v=async(i,e,s,t)=>(o.log(t,"createWindow",s),await i.create(e,K(s))),y=async(i,e,s)=>(o.log(s,"closeWindow",e),await i.close(e)),m="[drift] - unexpected undefined action",g="[drift] - unexpected undefined action type",_=i=>{if(i.emitted??(i.emitted=!1),i.action==null)throw console.warn(m,i),new Error(m);if(i.action.type==null||i.action.type.length===0)throw console.warn(g,i),new Error(g)},J=new D,Y=[o.runtimeSetWindowProps.type,o.reloadWindow.type],B=(i,e=!1)=>s=>t=>n=>{let{action:a,emitted:r,emitter:l}=U(n);const d=i.label();_({action:n,emitted:r,emitter:l});const u=o.isDriftAction(a.type);if(u&&o.log(e,"[drift] - middleware",{action:a,emitted:r,emitter:l,host:d}),l===i.label())return;const c=u&&!Y.includes(a.type);let w=null;u&&(w=s.getState().drift,a=o.assignLabel(a,w));const p=t(a),S=c?s.getState().drift:null,O=o.shouldEmit(r,a.type);return J.runExclusive(async()=>{try{w!==null&&S!==null&&await X(w,S,i,e),O&&await i.emit({action:a})}catch(b){o.log(e,"[drift] - ERROR",{error:b.message,action:a,emitted:r,emitter:l,host:d}),s.dispatch(o.setWindowError({key:d,message:b.message}))}}),p},G=(i,e,s=!1)=>t=>{const n=i!=null?typeof i=="function"?i(t):i:t();return[B(e,s),...n]},H=async({runtime:i,preloadedState:e,middleware:s,debug:t=!1,enablePrerender:n=!0,defaultWindowProps:a,...r})=>{await i.configure();let l;l=A.configureStore({...r,preloadedState:await x(t,i,()=>l,a,e),middleware:G(s,i,t)}),await Q(l.getState().drift,l.dispatch,i,t);const d=i.label();return l.dispatch(o.internalSetInitial({enablePrerender:n,defaultWindowProps:a,debug:t,label:d})),l.dispatch(o.setWindowStage({stage:"created"})),i.onCloseRequested(()=>l==null?void 0:l.dispatch(o.closeWindow({}))),l},x=async(i,e,s,t,n)=>e.isMain()?(await e.subscribe(({action:r,emitter:l,sendState:d})=>{const u=s();if(u==null)return;if(r!=null){_({action:r,emitter:l}),u.dispatch(z(r,l));return}const c=u.getState();d===!0&&e.emit({state:c},l)}),typeof n=="function"?E(t,i,await n()):E(t,i,n)):await new Promise((r,l)=>{(async()=>{try{await e.subscribe(({action:u,emitter:c,state:w})=>{const p=s();if(p==null)return w!=null?r(w):void 0;u!=null&&(_({action:u,emitter:c}),p.dispatch(z(u,c)))}),await e.emit({sendState:!0},f.MAIN_WINDOW)}catch(u){l(u)}})()}),W=H,E=(i,e,s)=>{if(s==null)return s;const t=s[o.SLICE_NAME];return t.config.debug=e??t.config.debug,t.windows=Object.fromEntries(Object.entries(t.windows).filter(([,n])=>n.reserved).map(([n,a])=>((i==null?void 0:i.visible)!=null&&(a.visible=i.visible),a.focusCount=0,a.centerCount=0,a.processCount=0,[n,a]))),s},ee=Object.freeze(Object.defineProperty({__proto__:null,MAIN_WINDOW:f.MAIN_WINDOW,SLICE_NAME:o.SLICE_NAME,ZERO_SLICE_STATE:o.ZERO_SLICE_STATE,closeWindow:o.closeWindow,completeProcess:o.completeProcess,configureStore:W,createWindow:o.createWindow,focusWindow:o.focusWindow,reducer:o.reducer,registerProcess:o.registerProcess,reloadWindow:o.reloadWindow,selectSliceState:h.selectSliceState,selectWindow:h.selectWindow,selectWindowAttribute:h.selectWindowAttribute,selectWindowKey:h.selectWindowKey,selectWindowLabel:h.selectWindowLabel,selectWindows:h.selectWindows,setWindowAlwaysOnTop:o.setWindowAlwaysOnTop,setWindowDecorations:o.setWindowDecorations,setWindowFullscreen:o.setWindowFullscreen,setWindowMaxSize:o.setWindowMaxSize,setWindowMaximized:o.setWindowMaximized,setWindowMinSize:o.setWindowMinSize,setWindowMinimized:o.setWindowMinimized,setWindowPosition:o.setWindowPosition,setWindowProps:o.setWindowProps,setWindowResizable:o.setWindowResizable,setWindowSize:o.setWindowSize,setWindowSkipTaskbar:o.setWindowSkipTaskbar,setWindowStage:o.setWindowStage,setWindowTitle:o.setWindowTitle,setWindowVisible:o.setWindowVisible,windowPropsZ:f.windowPropsZ},Symbol.toStringTag,{value:"Module"}));exports.SLICE_NAME=o.SLICE_NAME;exports.ZERO_SLICE_STATE=o.ZERO_SLICE_STATE;exports.closeWindow=o.closeWindow;exports.completeProcess=o.completeProcess;exports.createWindow=o.createWindow;exports.focusWindow=o.focusWindow;exports.reducer=o.reducer;exports.registerProcess=o.registerProcess;exports.reloadWindow=o.reloadWindow;exports.setWindowAlwaysOnTop=o.setWindowAlwaysOnTop;exports.setWindowDecorations=o.setWindowDecorations;exports.setWindowFullscreen=o.setWindowFullscreen;exports.setWindowMaxSize=o.setWindowMaxSize;exports.setWindowMaximized=o.setWindowMaximized;exports.setWindowMinSize=o.setWindowMinSize;exports.setWindowMinimized=o.setWindowMinimized;exports.setWindowPosition=o.setWindowPosition;exports.setWindowProps=o.setWindowProps;exports.setWindowResizable=o.setWindowResizable;exports.setWindowSize=o.setWindowSize;exports.setWindowSkipTaskbar=o.setWindowSkipTaskbar;exports.setWindowStage=o.setWindowStage;exports.setWindowTitle=o.setWindowTitle;exports.setWindowVisible=o.setWindowVisible;exports.MAIN_WINDOW=f.MAIN_WINDOW;exports.windowPropsZ=f.windowPropsZ;exports.selectSliceState=h.selectSliceState;exports.selectWindow=h.selectWindow;exports.selectWindowAttribute=h.selectWindowAttribute;exports.selectWindowKey=h.selectWindowKey;exports.selectWindowLabel=h.selectWindowLabel;exports.selectWindows=h.selectWindows;exports.Drift=ee;exports.configureStore=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@reduxjs/toolkit"),o=require("./state-Cl8us-b9.cjs"),f=require("./window-DLsE0-fP.cjs"),h=require("./selectors-jksTA_U1.cjs"),C=new Error("request for lock canceled");var L=function(i,e,s,t){function n(a){return a instanceof s?a:new s(function(r){r(a)})}return new(s||(s=Promise))(function(a,r){function l(c){try{u(t.next(c))}catch(w){r(w)}}function d(c){try{u(t.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((t=t.apply(i,e||[])).next())})};class N{constructor(e,s=C){this._value=e,this._cancelError=s,this._queue=[],this._weightedWaiters=[]}acquire(e=1,s=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,n)=>{const a={resolve:t,reject:n,weight:e,priority:s},r=T(this._queue,l=>s<=l.priority);r===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(r+1,0,a)})}runExclusive(e){return L(this,arguments,void 0,function*(s,t=1,n=0){const[a,r]=yield this.acquire(t,n);try{return yield s(a)}finally{r()}})}waitForUnlock(e=1,s=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,s)?Promise.resolve():new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),P(this._weightedWaiters[e-1],{resolve:t,priority:s})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const s=this._value;this._value-=e.weight,e.resolve([s,this._newReleaser(e.weight)])}_newReleaser(e){let s=!1;return()=>{s||(s=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const s=this._weightedWaiters[e-1];s&&(s.forEach(t=>t.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let s=this._value;s>0;s--){const t=this._weightedWaiters[s-1];if(!t)continue;const n=t.findIndex(a=>a.priority<=e);(n===-1?t:t.splice(0,n)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,s){return(this._queue.length===0||this._queue[0].priority<s)&&e<=this._value}}function P(i,e){const s=T(i,t=>e.priority<=t.priority);i.splice(s+1,0,e)}function T(i,e){for(let s=i.length-1;s>=0;s--)if(e(i[s]))return s;return-1}var q=function(i,e,s,t){function n(a){return a instanceof s?a:new s(function(r){r(a)})}return new(s||(s=Promise))(function(a,r){function l(c){try{u(t.next(c))}catch(w){r(w)}}function d(c){try{u(t.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((t=t.apply(i,e||[])).next())})};class D{constructor(e){this._semaphore=new N(1,e)}acquire(){return q(this,arguments,void 0,function*(e=0){const[,s]=yield this._semaphore.acquire(1,e);return s})}runExclusive(e,s=0){return this._semaphore.runExclusive(()=>e(),1,s)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const R=i=>[...new Set(i)],F=(i,e,s=!0)=>{const t=new Map;return i.forEach(n=>{const a=e(n);if(t.has(a)){if(s)return;t.delete(a)}t.set(a,n)}),Array.from(t.values())},V=Object.freeze(Object.defineProperty({__proto__:null,by:F,unique:R},Symbol.toStringTag,{value:"Module"})),I="DA@",M="://",j=(i,e)=>I.concat(e,M,i),Z=i=>{const[e,s]=i.split(M);if(s==null)return[i,""];const[,t]=e.split(I);return[s,t]},z=(i,e)=>({...i,type:j(i.type,e)}),U=i=>{const[e,s]=Z(i.type);return{emitted:s!=null&&s.length>0,emitter:s,action:{...i,type:e}}},K=i=>{const{centerCount:e,processCount:s,focusCount:t,stage:n,key:a,prerenderLabel:r,reserved:l,minimized:d,...u}=i;return u},Q=async(i,e,s,t)=>{const n=(await s.listLabels()).filter(c=>c!==f.MAIN_WINDOW),a=Object.keys(i.windows).filter(c=>c!==f.MAIN_WINDOW);o.group(t,"syncInitial"),o.log(t,"existing windows in runtime",n.sort()),o.log(t,"non-main windows in state",a.sort()),o.groupEnd(t);const r=V.unique([...n,...a]);for(const c of r)!n.includes(c)&&s.isMain()?(o.log(t,"state window not in runtime, creating",c),await v(s,c,i.windows[c],t)):a.includes(c)||(o.log(t,"runtime window not in state, closing",c),await y(s,c,t));const l=s.label(),d=i.windows[l];if(d==null)return;const u={...f.INITIAL_WINDOW_STATE};await k(u,d,s,t),e(o.runtimeSetWindowProps({label:s.label(),...await s.getProps()}))},X=async(i,e,s,t)=>{o.log(t,"sync",i,e),s.isMain()&&await $(i,e,s,t);const n=i.windows[s.label()],a=e.windows[s.label()];n==null||a==null||await k(n,a,s,t)},k=async(i,e,s,t)=>{const n=[];e.title!=null&&e.title!==i.title&&n.push(["title",{prev:i.title,next:e.title},async()=>s.setTitle(e.title)]);const a=e.visible!=null&&e.visible!==i.visible,r=e.visible===!1,l=()=>n.push(["visible",{prev:i.visible,next:e.visible},async()=>{if(await s.setVisible(e.visible),e.visible===!1)return;let d=e.position;d??(d=(await s.getProps()).position),await s.setPosition(f.J.translate(d,{x:1,y:1})),await s.setPosition(d)}]);if(a&&r&&l(),e.skipTaskbar!=null&&e.skipTaskbar!==i.skipTaskbar&&n.push(["skipTaskbar",{prev:i.skipTaskbar,next:e.skipTaskbar},async()=>await s.setSkipTaskbar(e.skipTaskbar)]),e.maximized!=null&&e.maximized!==i.maximized&&n.push(["maximized",{prev:i.maximized,next:e.maximized},async()=>await s.setMaximized(e.maximized)]),e.fullscreen!=null&&e.fullscreen!==i.fullscreen&&n.push(["fullscreen",{prev:i.fullscreen,next:e.fullscreen},async()=>await s.setFullscreen(e.fullscreen)]),e.centerCount!==i.centerCount&&n.push(["center",{prev:i.centerCount,next:e.centerCount},async()=>s.center()]),e.minimized!=null&&e.minimized!==i.minimized&&n.push(["minimized",{prev:i.minimized,next:e.minimized},async()=>await s.setMinimized(e.minimized)]),e.resizable!=null&&e.resizable!==i.resizable&&n.push(["resizable",{prev:i.resizable,next:e.resizable},async()=>await s.setResizable(e.resizable)]),e.minSize!=null&&!f._.equals(e.minSize,i.minSize)&&n.push(["minSize",{prev:i.minSize,next:e.minSize},async()=>await s.setMinSize(e.minSize)]),e.maxSize!=null&&!f._.equals(e.maxSize,i.maxSize)&&n.push(["maxSize",{prev:i.maxSize,next:e.maxSize},async()=>await s.setMaxSize(e.maxSize)]),e.size!=null&&!f._.equals(e.size,i.size)&&n.push(["size",{prev:i.size,next:e.size},async()=>await s.setSize(e.size)]),e.position!=null&&!f._.equals(e.position,i.position)&&n.push(["position",{prev:i.position,next:e.position},async()=>await s.setPosition(e.position)]),e.focusCount!==i.focusCount&&n.push(["setVisible",{prev:i.visible,next:e.visible},async()=>await s.setVisible(!0)],["focus",{prev:i.focusCount,next:e.focusCount},async()=>await s.focus()]),e.decorations!=null&&e.decorations!==i.decorations&&n.push(["decorations",{prev:i.decorations,next:e.decorations},async()=>await s.setDecorations(e.decorations)]),e.alwaysOnTop!=null&&e.alwaysOnTop!==i.alwaysOnTop&&n.push(["alwaysOnTop",{prev:i.alwaysOnTop,next:e.alwaysOnTop},async()=>await s.setAlwaysOnTop(e.alwaysOnTop)]),a&&!r&&l(),n.length!==0){o.group(t,`syncCurrent, label: ${s.label()}, key: ${e.key}`);for(const[d,{prev:u,next:c}]of n)o.log(t,d,u,"->",c);o.groupEnd(t);for(const[,,d]of n)await d()}},$=async(i,e,s,t)=>{const n=Object.keys(i.windows).filter(l=>!(l in e.windows)),a=Object.keys(e.windows).filter(l=>!(l in i.windows)),r=s.isMain();if(r&&n.length>0)for(const l of n)o.log(t,"syncMain","closing",l),l===f.MAIN_WINDOW&&await Promise.all(Object.keys(e.windows).filter(d=>d!==f.MAIN_WINDOW).map(async d=>await y(s,d,t))),await y(s,l,t);if(r&&a.length>0)for(const l of a)await v(s,l,e.windows[l],t)},v=async(i,e,s,t)=>(o.log(t,"createWindow",s),await i.create(e,K(s))),y=async(i,e,s)=>(o.log(s,"closeWindow",e),await i.close(e)),m="[drift] - unexpected undefined action",g="[drift] - unexpected undefined action type",_=i=>{if(i.emitted??(i.emitted=!1),i.action==null)throw console.warn(m,i),new Error(m);if(i.action.type==null||i.action.type.length===0)throw console.warn(g,i),new Error(g)},J=new D,Y=[o.runtimeSetWindowProps.type,o.reloadWindow.type],B=(i,e=!1)=>s=>t=>n=>{let{action:a,emitted:r,emitter:l}=U(n);const d=i.label();_({action:n,emitted:r,emitter:l});const u=o.isDriftAction(a.type);if(u&&o.log(e,"[drift] - middleware",{action:a,emitted:r,emitter:l,host:d}),l===i.label())return;const c=u&&!Y.includes(a.type);let w=null;u&&(w=s.getState().drift,a=o.assignLabel(a,w));const p=t(a),S=c?s.getState().drift:null,O=o.shouldEmit(r,a.type);return J.runExclusive(async()=>{try{w!==null&&S!==null&&await X(w,S,i,e),O&&await i.emit({action:a})}catch(b){o.log(e,"[drift] - ERROR",{error:b.message,action:a,emitted:r,emitter:l,host:d}),s.dispatch(o.setWindowError({key:d,message:b.message}))}}),p},G=(i,e,s=!1)=>t=>{const n=i!=null?typeof i=="function"?i(t):i:t();return[B(e,s),...n]},H=async({runtime:i,preloadedState:e,middleware:s,debug:t=!1,enablePrerender:n=!0,defaultWindowProps:a,...r})=>{await i.configure();let l;l=A.configureStore({...r,preloadedState:await x(t,i,()=>l,a,e),middleware:G(s,i,t)}),await Q(l.getState().drift,l.dispatch,i,t);const d=i.label();return l.dispatch(o.internalSetInitial({enablePrerender:n,defaultWindowProps:a,debug:t,label:d})),l.dispatch(o.setWindowStage({stage:"created"})),i.onCloseRequested(()=>l==null?void 0:l.dispatch(o.closeWindow({}))),l},x=async(i,e,s,t,n)=>e.isMain()?(await e.subscribe(({action:r,emitter:l,sendState:d})=>{const u=s();if(u==null)return;if(r!=null){_({action:r,emitter:l}),u.dispatch(z(r,l));return}const c=u.getState();d===!0&&e.emit({state:c},l)}),typeof n=="function"?E(t,i,await n()):E(t,i,n)):await new Promise((r,l)=>{(async()=>{try{await e.subscribe(({action:u,emitter:c,state:w})=>{const p=s();if(p==null)return w!=null?r(w):void 0;u!=null&&(_({action:u,emitter:c}),p.dispatch(z(u,c)))}),await e.emit({sendState:!0},f.MAIN_WINDOW)}catch(u){l(u)}})()}),W=H,E=(i,e,s)=>{if(s==null)return s;const t=s[o.SLICE_NAME];return t.config.debug=e??t.config.debug,t.windows=Object.fromEntries(Object.entries(t.windows).filter(([,n])=>n.reserved).map(([n,a])=>((i==null?void 0:i.visible)!=null&&(a.visible=i.visible),a.focusCount=0,a.centerCount=0,a.processCount=0,[n,a]))),s},ee=Object.freeze(Object.defineProperty({__proto__:null,MAIN_WINDOW:f.MAIN_WINDOW,SLICE_NAME:o.SLICE_NAME,ZERO_SLICE_STATE:o.ZERO_SLICE_STATE,closeWindow:o.closeWindow,completeProcess:o.completeProcess,configureStore:W,createWindow:o.createWindow,focusWindow:o.focusWindow,reducer:o.reducer,registerProcess:o.registerProcess,reloadWindow:o.reloadWindow,selectSliceState:h.selectSliceState,selectWindow:h.selectWindow,selectWindowAttribute:h.selectWindowAttribute,selectWindowKey:h.selectWindowKey,selectWindowLabel:h.selectWindowLabel,selectWindows:h.selectWindows,setWindowAlwaysOnTop:o.setWindowAlwaysOnTop,setWindowDecorations:o.setWindowDecorations,setWindowFullscreen:o.setWindowFullscreen,setWindowMaxSize:o.setWindowMaxSize,setWindowMaximized:o.setWindowMaximized,setWindowMinSize:o.setWindowMinSize,setWindowMinimized:o.setWindowMinimized,setWindowPosition:o.setWindowPosition,setWindowProps:o.setWindowProps,setWindowResizable:o.setWindowResizable,setWindowSize:o.setWindowSize,setWindowSkipTaskbar:o.setWindowSkipTaskbar,setWindowStage:o.setWindowStage,setWindowTitle:o.setWindowTitle,setWindowVisible:o.setWindowVisible,windowPropsZ:f.windowPropsZ},Symbol.toStringTag,{value:"Module"}));exports.SLICE_NAME=o.SLICE_NAME;exports.ZERO_SLICE_STATE=o.ZERO_SLICE_STATE;exports.closeWindow=o.closeWindow;exports.completeProcess=o.completeProcess;exports.createWindow=o.createWindow;exports.focusWindow=o.focusWindow;exports.reducer=o.reducer;exports.registerProcess=o.registerProcess;exports.reloadWindow=o.reloadWindow;exports.setWindowAlwaysOnTop=o.setWindowAlwaysOnTop;exports.setWindowDecorations=o.setWindowDecorations;exports.setWindowFullscreen=o.setWindowFullscreen;exports.setWindowMaxSize=o.setWindowMaxSize;exports.setWindowMaximized=o.setWindowMaximized;exports.setWindowMinSize=o.setWindowMinSize;exports.setWindowMinimized=o.setWindowMinimized;exports.setWindowPosition=o.setWindowPosition;exports.setWindowProps=o.setWindowProps;exports.setWindowResizable=o.setWindowResizable;exports.setWindowSize=o.setWindowSize;exports.setWindowSkipTaskbar=o.setWindowSkipTaskbar;exports.setWindowStage=o.setWindowStage;exports.setWindowTitle=o.setWindowTitle;exports.setWindowVisible=o.setWindowVisible;exports.MAIN_WINDOW=f.MAIN_WINDOW;exports.windowPropsZ=f.windowPropsZ;exports.selectSliceState=h.selectSliceState;exports.selectWindow=h.selectWindow;exports.selectWindowAttribute=h.selectWindowAttribute;exports.selectWindowKey=h.selectWindowKey;exports.selectWindowLabel=h.selectWindowLabel;exports.selectWindows=h.selectWindows;exports.Drift=ee;exports.configureStore=W;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { configureStore as j } from "@reduxjs/toolkit";
2
- import { g, l as d, a as T, r as E, b as I, i as N, c as F, s as V, d as $, e as U, f as C, h as q, S as M, Z as Q, j as Z, k as K, m as X, n as B, o as J, p as Y, q as G, t as H, u as x, v as W, w as ee, x as se, y as ie, z as te, A as ae, B as oe, C as ne, D as le, E as re } from "./state-D8a0PvFs.js";
2
+ import { g, l as d, a as T, r as E, b as I, i as N, c as F, s as V, d as $, e as U, f as C, h as q, S as M, Z as Q, j as Z, k as K, m as X, n as B, o as J, p as Y, q as G, t as H, u as x, v as W, w as ee, x as se, y as ie, z as te, A as ae, B as oe, C as ne, D as le, E as re } from "./state-BOplmOQD.js";
3
3
  import { M as w, _ as p, J as ce, I as ue, w as fe } from "./window-BIbHrbtA.js";
4
4
  import { s as de, a as we, b as he, c as pe, d as ye, e as _e } from "./selectors--wDYbFAe.js";
5
5
  const be = new Error("request for lock canceled");
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),u=require("react-redux"),a=require("proxy-memoize"),d=require("./selectors-jksTA_U1.cjs"),i=require("./state-Ckw4CzST.cjs"),y=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindow(s,e)),[e])),w=()=>u.useSelector(n.useCallback(a.memoize(d.selectWindows),[])),S=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindowKey(s,e)),[e])),W=(e,s)=>u.useSelector(n.useCallback(a.memoize(t=>d.selectWindowAttribute(t,e,s)),[e,s])),m=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null);n.useEffect(()=>{if(t==null)return;const{stage:r}=t;if(r==="created"&&c.current==null){const l=e();l!=null&&(c.current=l),o(i.registerProcess({key:t.key}))}else(r==="closing"||r==="reloading")&&c.current!=null&&(c.current(),c.current=null,o(i.completeProcess({key:t.key})))},[t])},h=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null),r=n.useRef(!1);n.useEffect(()=>{if(t==null)return;const{stage:l}=t;if(l==="created"&&c.current==null)r.current=!0,e().then(f=>{c.current=f??(async()=>{}),o(i.registerProcess({key:t.key}))}).catch(console.error).finally(()=>{r.current=!1});else if((l==="closing"||l==="reloading")&&c.current!=null){const f=c.current;c.current=null,f().then(()=>{c.current=null}).catch(console.error).finally(()=>{o(i.completeProcess({key:t.key}))})}},[t])},g=({store:e,emptyContent:s=null,children:t})=>{const[o,c]=n.useState(null),[r,l]=n.useState(null);if(r!=null)throw l(null),r;return o==null?(e instanceof Promise?e.then(c).catch(l):c(e),s):n.createElement(u.Provider,{store:o},t)};exports.Provider=g;exports.useAsyncWindowLifecycle=h;exports.useSelectWindow=y;exports.useSelectWindowAttribute=W;exports.useSelectWindowKey=S;exports.useSelectWindows=w;exports.useWindowLifecycle=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),u=require("react-redux"),a=require("proxy-memoize"),d=require("./selectors-jksTA_U1.cjs"),i=require("./state-Cl8us-b9.cjs"),y=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindow(s,e)),[e])),w=()=>u.useSelector(n.useCallback(a.memoize(d.selectWindows),[])),S=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindowKey(s,e)),[e])),W=(e,s)=>u.useSelector(n.useCallback(a.memoize(t=>d.selectWindowAttribute(t,e,s)),[e,s])),m=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null);n.useEffect(()=>{if(t==null)return;const{stage:r}=t;if(r==="created"&&c.current==null){const l=e();l!=null&&(c.current=l),o(i.registerProcess({key:t.key}))}else(r==="closing"||r==="reloading")&&c.current!=null&&(c.current(),c.current=null,o(i.completeProcess({key:t.key})))},[t])},h=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null),r=n.useRef(!1);n.useEffect(()=>{if(t==null)return;const{stage:l}=t;if(l==="created"&&c.current==null)r.current=!0,e().then(f=>{c.current=f??(async()=>{}),o(i.registerProcess({key:t.key}))}).catch(console.error).finally(()=>{r.current=!1});else if((l==="closing"||l==="reloading")&&c.current!=null){const f=c.current;c.current=null,f().then(()=>{c.current=null}).catch(console.error).finally(()=>{o(i.completeProcess({key:t.key}))})}},[t])},g=({store:e,emptyContent:s=null,children:t})=>{const[o,c]=n.useState(null),[r,l]=n.useState(null);if(r!=null)throw l(null),r;return o==null?(e instanceof Promise?e.then(c).catch(l):c(e),s):n.createElement(u.Provider,{store:o},t)};exports.Provider=g;exports.useAsyncWindowLifecycle=h;exports.useSelectWindow=y;exports.useSelectWindowAttribute=W;exports.useSelectWindowKey=S;exports.useSelectWindows=w;exports.useWindowLifecycle=m;
package/dist/react.js CHANGED
@@ -2,7 +2,7 @@ import { useCallback as l, useRef as f, useEffect as m, useState as d, createEle
2
2
  import { useSelector as u, useDispatch as y, Provider as g } from "react-redux";
3
3
  import { memoize as i } from "proxy-memoize";
4
4
  import { a as k, e as S, c as P, b as v } from "./selectors--wDYbFAe.js";
5
- import { o as w, j as p } from "./state-D8a0PvFs.js";
5
+ import { o as w, j as p } from "./state-BOplmOQD.js";
6
6
  const h = (e) => u(
7
7
  l(
8
8
  i((r) => k(r, e)),
@@ -0,0 +1,406 @@
1
+ import { createSlice as R } from "@reduxjs/toolkit";
2
+ import { o as W, O as _, M as f, I as v, P as A, a as O, L as S, $ as p, J as k } from "./window-BIbHrbtA.js";
3
+ const y = (e = !1, ...n) => {
4
+ e && console.log(...n);
5
+ }, D = (e = !1, ...n) => {
6
+ e && console.group(...n);
7
+ }, z = (e) => {
8
+ e && console.groupEnd();
9
+ }, x = (e, n, t = ".") => {
10
+ const o = e.split(t);
11
+ return o.map((s, r) => {
12
+ const i = n(s, r, o);
13
+ return i == null ? null : typeof i == "string" ? i : i.join(t);
14
+ }).filter((s) => s != null).join(t);
15
+ }, j = (e, n, t = { optional: !1, separator: "." }) => {
16
+ t.separator ?? (t.separator = ".");
17
+ const { optional: o, getter: s = (a, l) => a[l] } = t, r = n.split(t.separator);
18
+ if (r.length === 1 && r[0] === "") return e;
19
+ let i = e;
20
+ for (const a of r) {
21
+ const l = s(i, a);
22
+ if (l == null) {
23
+ if (o) return null;
24
+ throw new Error(`Path ${n} does not exist. ${a} is null`);
25
+ }
26
+ i = l;
27
+ }
28
+ return i;
29
+ }, N = (e, n, t) => {
30
+ const o = n.split(".");
31
+ let s = e;
32
+ for (let r = 0; r < o.length - 1; r++) {
33
+ const i = o[r];
34
+ s[i] ?? (s[i] = {}), s = s[i];
35
+ }
36
+ try {
37
+ s[o[o.length - 1]] = t;
38
+ } catch (r) {
39
+ throw console.error("failed to set value", t, "at path", n, "on object", e), r;
40
+ }
41
+ }, $ = (e, n) => {
42
+ const t = n.split(".");
43
+ let o = e;
44
+ for (let s = 0; s < t.length - 1; s++) {
45
+ const r = t[s];
46
+ if (o[r] == null) return;
47
+ o = o[r];
48
+ }
49
+ if (Array.isArray(o)) {
50
+ const s = parseInt(t[t.length - 1]);
51
+ if (isNaN(s)) return;
52
+ o.splice(s, 1);
53
+ return;
54
+ }
55
+ delete o[t[t.length - 1]];
56
+ }, q = (e, n) => {
57
+ const t = e.split(".");
58
+ return n < 0 ? t[t.length + n] : t[n];
59
+ }, K = (e, n) => {
60
+ try {
61
+ return j(e, n), !0;
62
+ } catch {
63
+ return !1;
64
+ }
65
+ }, F = (e, n) => {
66
+ if (n.length === 0) return !0;
67
+ const t = e.split("."), o = n.split(".");
68
+ if (o.length > t.length) return !1;
69
+ for (let s = 0; s < o.length; s++) {
70
+ const r = t[s], i = o[s];
71
+ if (i !== "*" && r !== i)
72
+ return !1;
73
+ }
74
+ return !0;
75
+ }, V = (e) => JSON.parse(JSON.stringify(e)), Z = (e, ...n) => (n.forEach((t) => {
76
+ let o = e;
77
+ const s = t.split(".");
78
+ s.forEach((r, i) => {
79
+ i === s.length - 1 ? delete o[r] : r in o && (o = o[r]);
80
+ });
81
+ }), e), J = (e, n, t = "") => {
82
+ const o = {}, s = (r, i, a) => {
83
+ if (typeof r != typeof i || r === null || i === null) {
84
+ o[a] = [r, i];
85
+ return;
86
+ }
87
+ if (typeof r == "object" && typeof i == "object")
88
+ if (Array.isArray(r) && Array.isArray(i)) {
89
+ if (r.length !== i.length) {
90
+ o[a] = [r, i];
91
+ return;
92
+ }
93
+ for (let l = 0; l < r.length; l++) s(r[l], i[l], `${a}[${l}]`);
94
+ } else
95
+ (/* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])).forEach((l) => {
96
+ s(r[l], i[l], a !== "" ? `${a}.${l}` : l);
97
+ });
98
+ else r !== i && (o[a] = [r, i]);
99
+ };
100
+ return s(e, n, t), o;
101
+ }, h = (e, n) => {
102
+ const t = Array.isArray(e), o = Array.isArray(n);
103
+ if (t !== o) return !1;
104
+ if (t && o) {
105
+ const i = e, a = n;
106
+ if (i.length !== a.length) return !1;
107
+ for (let l = 0; l < i.length; l++) if (!h(i[l], a[l])) return !1;
108
+ return !0;
109
+ }
110
+ if (e == null || n == null || typeof e != "object" || typeof n != "object")
111
+ return e === n;
112
+ if ("equals" in e) return e.equals(n);
113
+ const s = Object.keys(e), r = Object.keys(n);
114
+ if (s.length !== r.length) return !1;
115
+ for (const i of s) {
116
+ const a = e[i], l = n[i];
117
+ if (typeof a == "object" && typeof l == "object") {
118
+ if (!h(a, l)) return !1;
119
+ } else if (a !== l) return !1;
120
+ }
121
+ return !0;
122
+ }, L = (e, n) => {
123
+ if (typeof e != "object" || e == null) return e === n;
124
+ const t = Object.keys(e), o = Object.keys(n);
125
+ if (o.length > t.length) return !1;
126
+ for (const s of o) {
127
+ const r = e[s], i = n[s];
128
+ if (typeof r == "object" && typeof i == "object") {
129
+ if (!L(r, i)) return !1;
130
+ } else if (r !== i) return !1;
131
+ }
132
+ return !0;
133
+ }, m = (e, ...n) => {
134
+ if (n.length === 0) return e;
135
+ const t = n.shift();
136
+ if (W(e) && W(t))
137
+ for (const o in t)
138
+ try {
139
+ W(t[o]) ? (o in e || Object.assign(e, { [o]: {} }), m(e[o], t[o])) : Object.assign(e, { [o]: t[o] });
140
+ } catch (s) {
141
+ throw s instanceof TypeError ? new TypeError(`.${o}: ${s.message}`) : s;
142
+ }
143
+ return m(e, ...n);
144
+ }, B = (e, n, t) => {
145
+ const o = (s, r, i) => {
146
+ var a, l;
147
+ if (((a = i.def) == null ? void 0 : a.type) === "union")
148
+ return i.def.options.reduce(
149
+ (d, w) => o(d, r, w),
150
+ s
151
+ );
152
+ if (((l = i.def) == null ? void 0 : l.type) === "intersection") {
153
+ const d = o(s, r, i.def.left);
154
+ return o(d, r, i.def.right);
155
+ }
156
+ for (const d in r) {
157
+ const w = r[d], g = i == null ? void 0 : i.shape;
158
+ if (g != null && g[d]) {
159
+ const E = g[d].safeParse(w);
160
+ E.success && (s[d] = E.data);
161
+ } else typeof w == "object" && !Array.isArray(w) && w !== null && i && i.shape && i.shape[d] && (s[d] || (s[d] = {}), o(s[d], w, i.shape[d]));
162
+ }
163
+ return s;
164
+ };
165
+ return o({ ...e }, n, t);
166
+ }, I = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
167
+ __proto__: null,
168
+ copy: V,
169
+ deleteD: Z,
170
+ difference: J,
171
+ element: q,
172
+ equal: h,
173
+ get: j,
174
+ has: K,
175
+ override: m,
176
+ overrideValidItems: B,
177
+ partialEqual: L,
178
+ pathsMatch: F,
179
+ remove: $,
180
+ set: N,
181
+ transformPath: x
182
+ }, Symbol.toStringTag, { value: "Module" })), H = _.milliseconds(50), T = () => setTimeout(() => window.location.reload(), H.milliseconds), U = {
183
+ label: f,
184
+ config: {
185
+ enablePrerender: !0,
186
+ debug: !1,
187
+ defaultWindowProps: {}
188
+ },
189
+ windows: {
190
+ main: {
191
+ ...v,
192
+ key: f,
193
+ reserved: !0
194
+ }
195
+ },
196
+ labelKeys: {
197
+ main: f
198
+ },
199
+ keyLabels: {
200
+ main: f
201
+ }
202
+ }, ve = (e, n) => {
203
+ if (e.type === me.type)
204
+ return n.label !== f || (e.payload.label = S.create(), e.payload.prerenderLabel = S.create()), e;
205
+ if ("label" in e.payload) return e;
206
+ let t = n.label;
207
+ const o = e.payload;
208
+ return o.key != null && (o.key in n.windows ? t = o.key : t = n.keyLabels[o.key]), e.payload = { ...e.payload, label: t }, e;
209
+ }, c = (e) => (n, t) => {
210
+ if (!("label" in t.payload)) throw new Error("Missing label");
211
+ e(n, t);
212
+ }, u = (e, n = !1) => c((t, o) => {
213
+ let s = n;
214
+ const r = t.windows[o.payload.label];
215
+ if (r != null) {
216
+ if (o.payload.value != null) s = o.payload.value;
217
+ else {
218
+ const i = r[e];
219
+ i != null && (s = !i);
220
+ }
221
+ t.windows[o.payload.label] = { ...r, [e]: s };
222
+ }
223
+ }), b = (e, n = !1) => (t, o) => {
224
+ const s = t.windows[o.payload.label];
225
+ s != null && (t.windows[o.payload.label] = {
226
+ ...s,
227
+ [e]: s[e] + (n ? -1 : 1)
228
+ });
229
+ }, X = (e) => Object.values(e.windows).some((n) => n.key === A && !n.reserved), C = "drift", Y = (e, n, t) => e.position != null && e.size != null && n == null ? p.topLeft(
230
+ p.positionInCenter(
231
+ p.construct(k.ZERO, t ?? k.ZERO),
232
+ p.construct(e.position, e.size)
233
+ )
234
+ ) : n, G = (e, { payload: n }) => {
235
+ if (n.key === A) return;
236
+ const { key: t, label: o, prerenderLabel: s } = n;
237
+ if (o == null || s == null)
238
+ throw new Error("[drift] - bug - missing label and prerender label");
239
+ console.log(e.config.debug), D(e.config.debug, "reducer create window");
240
+ const r = e.windows.main;
241
+ if (n.position = Y(r, n.position, n.size), t in e.keyLabels) {
242
+ y(e.config.debug, "window already exists, un-minimize and focus it");
243
+ const l = e.keyLabels[n.key];
244
+ e.windows[l].visible = !0, e.windows[l].focusCount += 1, e.windows[l].minimized = !1, e.windows[l].position = n.position, z(e.config.debug);
245
+ return;
246
+ }
247
+ const [i, a] = Object.entries(e.windows).find(
248
+ ([, l]) => !l.reserved
249
+ ) ?? [null, null];
250
+ i != null ? (y(e.config.debug, "using available pre-rendered window"), e.windows[i] = {
251
+ ...a,
252
+ visible: !0,
253
+ reserved: !0,
254
+ focusCount: 1,
255
+ focus: !0,
256
+ ...n
257
+ }, e.labelKeys[i] = n.key, e.keyLabels[n.key] = i) : (y(e.config.debug, "creating new window"), e.windows[o] = {
258
+ ...e.config.defaultWindowProps,
259
+ ...v,
260
+ ...n,
261
+ reserved: !0
262
+ }, e.labelKeys[o] = t, e.keyLabels[t] = o), e.config.enablePrerender && !X(e) && (y(e.config.debug, "creating pre-render window"), e.windows[s] = I.copy({
263
+ ...e.config.defaultWindowProps,
264
+ ...O
265
+ })), z(e.config.debug);
266
+ }, Q = c((e, n) => {
267
+ const t = e.windows[n.payload.label];
268
+ t != null && (t.stage = n.payload.stage);
269
+ }), ee = c(
270
+ (e, { payload: { label: n } }) => {
271
+ const t = e.windows[n];
272
+ t == null || t.processCount > 0 || (t.stage = "closing", delete e.windows[n], delete e.labelKeys[n], delete e.keyLabels[t.key]);
273
+ }
274
+ ), ne = c((e, n) => {
275
+ const t = e.windows[n.payload.label];
276
+ t == null || t.processCount > 0 || (t.stage = "reloading", T());
277
+ }), te = c(
278
+ b("processCount")
279
+ ), oe = c((e, n) => {
280
+ b("processCount", !0)(e, n);
281
+ const t = e.windows[n.payload.label];
282
+ t != null && t.processCount === 0 && (t.stage === "reloading" ? T() : (e.windows[n.payload.label].visible = !1, delete e.windows[n.payload.label], delete e.labelKeys[n.payload.label], delete e.keyLabels[t.key]));
283
+ }), ie = (e, n) => {
284
+ const t = e.windows[n.payload.key];
285
+ t != null && (t.error = n.payload.message);
286
+ }, se = c((e, n) => {
287
+ const t = e.windows[n.payload.label];
288
+ t != null && (t.visible !== !0 && (t.visible = !0), b("focusCount")(e, n));
289
+ }), re = u("minimized"), le = u("maximized"), ae = u("visible", !0), de = u("fullscreen", !0), ce = c(
290
+ b("centerCount")
291
+ ), ue = c((e, n) => {
292
+ e.windows[n.payload.label].position = n.payload.position;
293
+ }), we = c((e, n) => {
294
+ e.windows[n.payload.label].size = n.payload.size;
295
+ }), fe = c((e, n) => {
296
+ e.windows[n.payload.label].minSize = n.payload.size;
297
+ }), pe = c((e, n) => {
298
+ e.windows[n.payload.label].maxSize = n.payload.size;
299
+ }), ye = u("resizable"), be = u("skipTaskbar"), ge = u("alwaysOnTop"), We = c((e, n) => {
300
+ e.windows[n.payload.label].title = n.payload.title;
301
+ }), Se = u("decorations"), P = (e, n) => {
302
+ const t = e.windows[n.payload.label];
303
+ I.partialEqual(t, n.payload) || (e.windows[n.payload.label] = { ...t, ...n.payload });
304
+ }, he = (e, n) => {
305
+ if (e.config = { ...e.config, ...n.payload }, e.label = n.payload.label, e.label === f && e.config.enablePrerender) {
306
+ const t = S.create();
307
+ e.windows[t] = {
308
+ ...e.config.defaultWindowProps,
309
+ ...O
310
+ };
311
+ }
312
+ }, M = R({
313
+ name: C,
314
+ initialState: U,
315
+ reducers: {
316
+ internalSetInitial: he,
317
+ createWindow: G,
318
+ setWindowStage: Q,
319
+ closeWindow: ee,
320
+ registerProcess: te,
321
+ completeProcess: oe,
322
+ setWindowError: ie,
323
+ focusWindow: se,
324
+ reloadWindow: ne,
325
+ setWindowMinimized: re,
326
+ setWindowMaximized: le,
327
+ setWindowVisible: ae,
328
+ setWindowFullscreen: de,
329
+ centerWindow: ce,
330
+ setWindowPosition: ue,
331
+ setWindowSize: we,
332
+ setWindowMinSize: fe,
333
+ setWindowMaxSize: pe,
334
+ setWindowResizable: ye,
335
+ setWindowSkipTaskbar: be,
336
+ setWindowAlwaysOnTop: ge,
337
+ setWindowTitle: We,
338
+ setWindowDecorations: Se,
339
+ runtimeSetWindowProps: P,
340
+ setWindowProps: P
341
+ }
342
+ }), {
343
+ actions: {
344
+ runtimeSetWindowProps: Ae,
345
+ setWindowProps: Oe,
346
+ createWindow: me,
347
+ internalSetInitial: Ee,
348
+ setWindowStage: je,
349
+ closeWindow: Le,
350
+ registerProcess: Ie,
351
+ completeProcess: Te,
352
+ setWindowError: Ce,
353
+ focusWindow: Me,
354
+ reloadWindow: Re,
355
+ setWindowMinimized: _e,
356
+ setWindowMaximized: De,
357
+ setWindowVisible: xe,
358
+ setWindowFullscreen: Ne,
359
+ centerWindow: $e,
360
+ setWindowPosition: qe,
361
+ setWindowSize: Ke,
362
+ setWindowMinSize: Fe,
363
+ setWindowMaxSize: Ve,
364
+ setWindowResizable: Ze,
365
+ setWindowSkipTaskbar: Je,
366
+ setWindowAlwaysOnTop: Be,
367
+ setWindowTitle: He,
368
+ setWindowDecorations: Ue
369
+ }
370
+ } = M, Xe = M.reducer, Ye = (e) => e.startsWith(C), ke = [Ee.type], Ge = (e, n) => !e && !ke.includes(n);
371
+ export {
372
+ Ze as A,
373
+ Ke as B,
374
+ Je as C,
375
+ He as D,
376
+ xe as E,
377
+ I as F,
378
+ C as S,
379
+ U as Z,
380
+ z as a,
381
+ Re as b,
382
+ ve as c,
383
+ Ce as d,
384
+ Ee as e,
385
+ je as f,
386
+ D as g,
387
+ Le as h,
388
+ Ye as i,
389
+ Te as j,
390
+ me as k,
391
+ y as l,
392
+ Me as m,
393
+ Xe as n,
394
+ Ie as o,
395
+ Be as p,
396
+ Ue as q,
397
+ Ae as r,
398
+ Ge as s,
399
+ Ne as t,
400
+ Ve as u,
401
+ De as v,
402
+ Fe as w,
403
+ _e as x,
404
+ qe as y,
405
+ Oe as z
406
+ };
@@ -0,0 +1 @@
1
+ "use strict";const _=require("@reduxjs/toolkit"),a=require("./window-DLsE0-fP.cjs"),p=(e=!1,...n)=>{e&&console.log(...n)},A=(e=!1,...n)=>{e&&console.group(...n)},y=e=>{e&&console.groupEnd()},v=(e,n,t=".")=>{const o=e.split(t);return o.map((r,s)=>{const i=n(r,s,o);return i==null?null:typeof i=="string"?i:i.join(t)}).filter(r=>r!=null).join(t)},k=(e,n,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:o,getter:r=(d,l)=>d[l]}=t,s=n.split(t.separator);if(s.length===1&&s[0]==="")return e;let i=e;for(const d of s){const l=r(i,d);if(l==null){if(o)return null;throw new Error(`Path ${n} does not exist. ${d} is null`)}i=l}return i},D=(e,n,t)=>{const o=n.split(".");let r=e;for(let s=0;s<o.length-1;s++){const i=o[s];r[i]??(r[i]={}),r=r[i]}try{r[o[o.length-1]]=t}catch(s){throw console.error("failed to set value",t,"at path",n,"on object",e),s}},M=(e,n)=>{const t=n.split(".");let o=e;for(let r=0;r<t.length-1;r++){const s=t[r];if(o[s]==null)return;o=o[s]}if(Array.isArray(o)){const r=parseInt(t[t.length-1]);if(isNaN(r))return;o.splice(r,1);return}delete o[t[t.length-1]]},j=(e,n)=>{const t=e.split(".");return n<0?t[t.length+n]:t[n]},R=(e,n)=>{try{return k(e,n),!0}catch{return!1}},C=(e,n)=>{if(n.length===0)return!0;const t=e.split("."),o=n.split(".");if(o.length>t.length)return!1;for(let r=0;r<o.length;r++){const s=t[r],i=o[r];if(i!=="*"&&s!==i)return!1}return!0},x=e=>JSON.parse(JSON.stringify(e)),$=(e,...n)=>(n.forEach(t=>{let o=e;const r=t.split(".");r.forEach((s,i)=>{i===r.length-1?delete o[s]:s in o&&(o=o[s])})}),e),q=(e,n,t="")=>{const o={},r=(s,i,d)=>{if(typeof s!=typeof i||s===null||i===null){o[d]=[s,i];return}if(typeof s=="object"&&typeof i=="object")if(Array.isArray(s)&&Array.isArray(i)){if(s.length!==i.length){o[d]=[s,i];return}for(let l=0;l<s.length;l++)r(s[l],i[l],`${d}[${l}]`)}else new Set([...Object.keys(s),...Object.keys(i)]).forEach(l=>{r(s[l],i[l],d!==""?`${d}.${l}`:l)});else s!==i&&(o[d]=[s,i])};return r(e,n,t),o},g=(e,n)=>{const t=Array.isArray(e),o=Array.isArray(n);if(t!==o)return!1;if(t&&o){const i=e,d=n;if(i.length!==d.length)return!1;for(let l=0;l<i.length;l++)if(!g(i[l],d[l]))return!1;return!0}if(e==null||n==null||typeof e!="object"||typeof n!="object")return e===n;if("equals"in e)return e.equals(n);const r=Object.keys(e),s=Object.keys(n);if(r.length!==s.length)return!1;for(const i of r){const d=e[i],l=n[i];if(typeof d=="object"&&typeof l=="object"){if(!g(d,l))return!1}else if(d!==l)return!1}return!0},z=(e,n)=>{if(typeof e!="object"||e==null)return e===n;const t=Object.keys(e),o=Object.keys(n);if(o.length>t.length)return!1;for(const r of o){const s=e[r],i=n[r];if(typeof s=="object"&&typeof i=="object"){if(!z(s,i))return!1}else if(s!==i)return!1}return!0},S=(e,...n)=>{if(n.length===0)return e;const t=n.shift();if(a.o(e)&&a.o(t))for(const o in t)try{a.o(t[o])?(o in e||Object.assign(e,{[o]:{}}),S(e[o],t[o])):Object.assign(e,{[o]:t[o]})}catch(r){throw r instanceof TypeError?new TypeError(`.${o}: ${r.message}`):r}return S(e,...n)},K=(e,n,t)=>{const o=(r,s,i)=>{var d,l;if(((d=i.def)==null?void 0:d.type)==="union")return i.def.options.reduce((c,f)=>o(c,s,f),r);if(((l=i.def)==null?void 0:l.type)==="intersection"){const c=o(r,s,i.def.left);return o(c,s,i.def.right)}for(const c in s){const f=s[c],b=i==null?void 0:i.shape;if(b!=null&&b[c]){const m=b[c].safeParse(f);m.success&&(r[c]=m.data)}else typeof f=="object"&&!Array.isArray(f)&&f!==null&&i&&i.shape&&i.shape[c]&&(r[c]||(r[c]={}),o(r[c],f,i.shape[c]))}return r};return o({...e},n,t)},E=Object.freeze(Object.defineProperty({__proto__:null,copy:x,deleteD:$,difference:q,element:j,equal:g,get:k,has:R,override:S,overrideValidItems:K,partialEqual:z,pathsMatch:C,remove:M,set:D,transformPath:v},Symbol.toStringTag,{value:"Module"})),F=a.O.milliseconds(50),O=()=>setTimeout(()=>window.location.reload(),F.milliseconds),P={label:a.MAIN_WINDOW,config:{enablePrerender:!0,debug:!1,defaultWindowProps:{}},windows:{main:{...a.INITIAL_WINDOW_STATE,key:a.MAIN_WINDOW,reserved:!0}},labelKeys:{main:a.MAIN_WINDOW},keyLabels:{main:a.MAIN_WINDOW}},V=(e,n)=>{if(e.type===N.type)return n.label!==a.MAIN_WINDOW||(e.payload.label=a.Lt.create(),e.payload.prerenderLabel=a.Lt.create()),e;if("label"in e.payload)return e;let t=n.label;const o=e.payload;return o.key!=null&&(o.key in n.windows?t=o.key:t=n.keyLabels[o.key]),e.payload={...e.payload,label:t},e},u=e=>(n,t)=>{if(!("label"in t.payload))throw new Error("Missing label");e(n,t)},w=(e,n=!1)=>u((t,o)=>{let r=n;const s=t.windows[o.payload.label];if(s!=null){if(o.payload.value!=null)r=o.payload.value;else{const i=s[e];i!=null&&(r=!i)}t.windows[o.payload.label]={...s,[e]:r}}}),W=(e,n=!1)=>(t,o)=>{const r=t.windows[o.payload.label];r!=null&&(t.windows[o.payload.label]={...r,[e]:r[e]+(n?-1:1)})},J=e=>Object.values(e.windows).some(n=>n.key===a.PRERENDER_WINDOW&&!n.reserved),h="drift",Z=(e,n,t)=>e.position!=null&&e.size!=null&&n==null?a.$t.topLeft(a.$t.positionInCenter(a.$t.construct(a.J.ZERO,t??a.J.ZERO),a.$t.construct(e.position,e.size))):n,B=(e,{payload:n})=>{if(n.key===a.PRERENDER_WINDOW)return;const{key:t,label:o,prerenderLabel:r}=n;if(o==null||r==null)throw new Error("[drift] - bug - missing label and prerender label");console.log(e.config.debug),A(e.config.debug,"reducer create window");const s=e.windows.main;if(n.position=Z(s,n.position,n.size),t in e.keyLabels){p(e.config.debug,"window already exists, un-minimize and focus it");const l=e.keyLabels[n.key];e.windows[l].visible=!0,e.windows[l].focusCount+=1,e.windows[l].minimized=!1,e.windows[l].position=n.position,y(e.config.debug);return}const[i,d]=Object.entries(e.windows).find(([,l])=>!l.reserved)??[null,null];i!=null?(p(e.config.debug,"using available pre-rendered window"),e.windows[i]={...d,visible:!0,reserved:!0,focusCount:1,focus:!0,...n},e.labelKeys[i]=n.key,e.keyLabels[n.key]=i):(p(e.config.debug,"creating new window"),e.windows[o]={...e.config.defaultWindowProps,...a.INITIAL_WINDOW_STATE,...n,reserved:!0},e.labelKeys[o]=t,e.keyLabels[t]=o),e.config.enablePrerender&&!J(e)&&(p(e.config.debug,"creating pre-render window"),e.windows[r]=E.copy({...e.config.defaultWindowProps,...a.INITIAL_PRERENDER_WINDOW_STATE})),y(e.config.debug)},H=u((e,n)=>{const t=e.windows[n.payload.label];t!=null&&(t.stage=n.payload.stage)}),U=u((e,{payload:{label:n}})=>{const t=e.windows[n];t==null||t.processCount>0||(t.stage="closing",delete e.windows[n],delete e.labelKeys[n],delete e.keyLabels[t.key])}),X=u((e,n)=>{const t=e.windows[n.payload.label];t==null||t.processCount>0||(t.stage="reloading",O())}),Y=u(W("processCount")),G=u((e,n)=>{W("processCount",!0)(e,n);const t=e.windows[n.payload.label];t!=null&&t.processCount===0&&(t.stage==="reloading"?O():(e.windows[n.payload.label].visible=!1,delete e.windows[n.payload.label],delete e.labelKeys[n.payload.label],delete e.keyLabels[t.key]))}),Q=(e,n)=>{const t=e.windows[n.payload.key];t!=null&&(t.error=n.payload.message)},ee=u((e,n)=>{const t=e.windows[n.payload.label];t!=null&&(t.visible!==!0&&(t.visible=!0),W("focusCount")(e,n))}),ne=w("minimized"),te=w("maximized"),oe=w("visible",!0),ie=w("fullscreen",!0),re=u(W("centerCount")),se=u((e,n)=>{e.windows[n.payload.label].position=n.payload.position}),le=u((e,n)=>{e.windows[n.payload.label].size=n.payload.size}),ae=u((e,n)=>{e.windows[n.payload.label].minSize=n.payload.size}),de=u((e,n)=>{e.windows[n.payload.label].maxSize=n.payload.size}),ce=w("resizable"),ue=w("skipTaskbar"),we=w("alwaysOnTop"),fe=u((e,n)=>{e.windows[n.payload.label].title=n.payload.title}),pe=w("decorations"),I=(e,n)=>{const t=e.windows[n.payload.label];E.partialEqual(t,n.payload)||(e.windows[n.payload.label]={...t,...n.payload})},We=(e,n)=>{if(e.config={...e.config,...n.payload},e.label=n.payload.label,e.label===a.MAIN_WINDOW&&e.config.enablePrerender){const t=a.Lt.create();e.windows[t]={...e.config.defaultWindowProps,...a.INITIAL_PRERENDER_WINDOW_STATE}}},T=_.createSlice({name:h,initialState:P,reducers:{internalSetInitial:We,createWindow:B,setWindowStage:H,closeWindow:U,registerProcess:Y,completeProcess:G,setWindowError:Q,focusWindow:ee,reloadWindow:X,setWindowMinimized:ne,setWindowMaximized:te,setWindowVisible:oe,setWindowFullscreen:ie,centerWindow:re,setWindowPosition:se,setWindowSize:le,setWindowMinSize:ae,setWindowMaxSize:de,setWindowResizable:ce,setWindowSkipTaskbar:ue,setWindowAlwaysOnTop:we,setWindowTitle:fe,setWindowDecorations:pe,runtimeSetWindowProps:I,setWindowProps:I}}),{actions:{runtimeSetWindowProps:be,setWindowProps:ye,createWindow:N,internalSetInitial:L,setWindowStage:ge,closeWindow:Se,registerProcess:Ee,completeProcess:he,setWindowError:me,focusWindow:Ie,reloadWindow:Ae,setWindowMinimized:ke,setWindowMaximized:ze,setWindowVisible:Oe,setWindowFullscreen:Pe,centerWindow:Ke,setWindowPosition:Te,setWindowSize:Ne,setWindowMinSize:Le,setWindowMaxSize:_e,setWindowResizable:ve,setWindowSkipTaskbar:De,setWindowAlwaysOnTop:Me,setWindowTitle:je,setWindowDecorations:Re}}=T,Ce=T.reducer,xe=e=>e.startsWith(h),$e=[L.type],qe=(e,n)=>!e&&!$e.includes(n);exports.SLICE_NAME=h;exports.ZERO_SLICE_STATE=P;exports.assignLabel=V;exports.closeWindow=Se;exports.completeProcess=he;exports.createWindow=N;exports.focusWindow=Ie;exports.group=A;exports.groupEnd=y;exports.internalSetInitial=L;exports.isDriftAction=xe;exports.log=p;exports.reducer=Ce;exports.registerProcess=Ee;exports.reloadWindow=Ae;exports.runtimeSetWindowProps=be;exports.setWindowAlwaysOnTop=Me;exports.setWindowDecorations=Re;exports.setWindowError=me;exports.setWindowFullscreen=Pe;exports.setWindowMaxSize=_e;exports.setWindowMaximized=ze;exports.setWindowMinSize=Le;exports.setWindowMinimized=ke;exports.setWindowPosition=Te;exports.setWindowProps=ye;exports.setWindowResizable=ve;exports.setWindowSize=Ne;exports.setWindowSkipTaskbar=De;exports.setWindowStage=ge;exports.setWindowTitle=je;exports.setWindowVisible=Oe;exports.shouldEmit=qe;exports.x=E;
package/dist/tauri.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ee=Object.defineProperty;var ie=(t,e,i)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var D=(t,e,i)=>ie(t,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./window-DLsE0-fP.cjs"),y=require("./state-Ckw4CzST.cjs"),te=require("./debounce-BUAIXXZt.cjs");function ne(t,e,i,n){if(typeof e=="function"?t!==e||!0:!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 se(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 S;const c="__TAURI_TO_IPC_KEY__";function le(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 ae{get rid(){return ne(this,S,"f")}constructor(e){S.set(this,void 0),se(this,S,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}S=new WeakMap;var o;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(o||(o={}));async function H(t,e){await s("plugin:event|unlisten",{event:t,eventId:e})}async function W(t,e,i){var n;const l=typeof(i==null?void 0:i.target)=="string"?{kind:"AnyLabel",label:i.target}:(n=i==null?void 0:i.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:l,handler:le(e)}).then(r=>async()=>H(t,r))}async function L(t,e,i){return W(t,n=>{H(t,n.id),e(n)},i)}async function N(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function j(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class v{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 d(this.width*e,this.height*e)}[c](){return{width:this.width,height:this.height}}toJSON(){return this[c]()}}class d{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 v(this.width/e,this.height/e)}[c](){return{width:this.width,height:this.height}}toJSON(){return this[c]()}}class h{constructor(e){this.size=e}toLogical(e){return this.size instanceof v?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof d?this.size:this.size.toPhysical(e)}[c](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[c]()}}class T{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)}[c](){return{x:this.x,y:this.y}}toJSON(){return this[c]()}}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 T(this.x/e,this.y/e)}[c](){return{x:this.x,y:this.y}}toJSON(){return this[c]()}}class p{constructor(e){this.position=e}toLogical(e){return this.position instanceof T?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[c](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[c]()}}class m extends ae{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 m(l))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:z(e)}).then(i=>new m(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new m(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 m?t.rid:t}var x;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(x||(x={}));class re{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var M;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(M||(M={}));function q(){return new I(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function R(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new I(e,{skip:!0})))}const A=["tauri://created","tauri://error"];class I{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i!=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 R()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return q()}static async getAll(){return R()}static async getFocusedWindow(){for(const e of await R())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)}:W(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)}:L(e,i,{target:{kind:"Window",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 N(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 j(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 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 d(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new d(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===x.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 h?e:new h(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof h?e:e?new h(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof h?e:e?new h(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==null?void 0:e.minWidth),minHeight:i(e==null?void 0:e.minHeight),maxWidth:i(e==null?void 0:e.maxWidth),maxHeight:i(e==null?void 0:e.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof p?e:new p(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}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 p?e:new p(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(o.WINDOW_RESIZED,i=>{i.payload=new d(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new re(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(o.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(o.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,l=>{e({...l,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,l=>{e({...l,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var F;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(F||(F={}));var B;(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"})(B||(B={}));var V;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(V||(V={}));function oe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new d(t.size)}}async function ue(){return s("plugin:window|available_monitors").then(t=>t.map(oe))}function J(){return new C(q(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function U(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new C(new I(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const k=["tauri://created","tauri://error"];class C{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n!=null&&n.skip||s("plugin:webview|create_webview",{windowLabel:e.label,label:i,options:n}).then(async()=>this.emit("tauri://created")).catch(async l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await U()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return J()}static async getAll(){return U()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:W(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)}:L(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(k.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return N(e,i)}async emitTo(e,i,n){if(k.includes(i)){for(const l of this.listeners[i]||[])l({event:i,id:-1,payload:n});return}return j(e,i,n)}_handleTauriEvent(e,i){return k.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 d(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 h?e:new h(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof p?e:new p(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(o.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(o.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),r()}}}function Z(){const t=J();return new w(t.label,{skip:!0})}async function P(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new w(e,{skip:!0})))}class w{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i!=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 P()).find(l=>l.label===e))!==null&&i!==void 0?i:null;return n?new w(n.label,{skip:!0}):null}static getCurrent(){return Z()}static async getAll(){return P()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:W(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)}:L(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}))}}ce(w,[I,C]);function ce(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 he=t=>JSON.stringify(t),we=t=>JSON.parse(t),O="drift://action",de="tauri://error",be="tauri://created",ye=t=>new Error(`Window not found: ${t}`),g=250,pe=b.O.seconds(1),f=t=>{if(t!=null)return{width:Math.max(t.width,g),height:Math.max(t.height,g)}},ge=t=>{const{size:e,maxSize:i}=t;return{...t,maxSize:f(i),size:f(e)}},_e=async()=>(await ue()).map(e=>{const i=E(e.position,e.scaleFactor),n={width:e.size.width,height:e.size.height};return b.$t.construct(i,n)}),G=async t=>(await _e()).some(i=>b.$t.contains(i,t));class ve{constructor(e){D(this,"win");D(this,"unsubscribe");D(this,"fullscreenPoll",null);this.win=e??Z(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll()}async startFullscreenPoll(){if(b.S.getOS()!=="macOS")return;let e=(await this.getProps()).fullscreen;this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(i=>{i!==e&&(e=i,this.emit({action:y.runtimeSetWindowProps({label:this.win.label,fullscreen:i})},void 0,"WHITELIST").catch(console.error))}).catch(console.error)},pe.milliseconds)}label(){return this.win.label}isMain(){return this.win.label===b.MAIN_WINDOW}release(){Object.values(this.unsubscribe).forEach(e=>e==null?void 0:e()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.unsubscribe={}}async emit(e,i,n=this.label()){const l=he({...e,emitter:n});if(i==null)return await N(O,l);const r=await w.getByLabel(i);if(r==null)throw ye(i);await r.emit(O,l)}async subscribe(e){this.release(),await this.startFullscreenPoll(),this.unsubscribe[O]=await W(O,n=>e(we(n.payload)));const i=me();for(const{key:n,handler:l,debounce:r}of i)this.unsubscribe[n]=await this.win.listen(n,te.o(()=>{l(this.win).then(a=>{a!=null&&this.emit({action:a},void 0,"WHITELIST").catch(console.error)}).catch(console.error)},r))}onCloseRequested(e){this.win.onCloseRequested(i=>{i.preventDefault(),e()})}async create(e,i){i=y._.copy(i);const{size:n,minSize:l,maxSize:r,position:a,...Q}=ge(i);(n==null?void 0:n.width)!=null&&(n.width=Math.max(n.width,g)),(n==null?void 0:n.height)!=null&&(n.height=Math.max(n.height,g)),(r==null?void 0:r.width)!=null&&(r.width=Math.max(r.width,g)),(r==null?void 0:r.height)!=null&&(r.height=Math.max(r.height,g)),a!=null&&(await G(a)||(a.x=0,a.y=0));try{const _=new w(e,{x:a==null?void 0:a.x,y:a==null?void 0:a.y,width:n==null?void 0:n.width,height:n==null?void 0:n.height,minWidth:l==null?void 0:l.width,minHeight:l==null?void 0:l.height,maxWidth:r==null?void 0:r.width,maxHeight:r==null?void 0:r.height,titleBarStyle:"overlay",dragDropEnabled:!1,...Q});return await new Promise((Y,K)=>{_.once(de,X=>K(new Error(JSON.stringify(X.payload)))),_.once(be,()=>Y())})}catch(_){console.error(_)}}async close(e){const i=await w.getByLabel(e);if(i!=null)try{await i.destroy()}catch(n){console.error(n,e)}else{const n=await P();console.error("Window not found",e,n.map(l=>l.label))}}async listLabels(){return(await P()).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 T(e.x,e.y);await G(e)||(i.x=0,i.y=0),await this.win.setPosition(i)}async setSize(e){e=f(e),await this.win.setSize(new v(e.width,e.height))}async setMinSize(e){e=f(e),await this.win.setMinSize(new v(e.width,e.height))}async setMaxSize(e){e=f(e),await this.win.setMaxSize(new v(e.width,e.height))}async setResizable(e){var i,n;return o.WINDOW_RESIZED in this.unsubscribe&&!e&&((n=(i=this.unsubscribe)[o.WINDOW_RESIZED])==null||n.call(i),delete this.unsubscribe[o.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:E(await this.win.innerPosition(),e),size:$(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:i,fullscreen:await this.win.isFullscreen()}}}const me=()=>[{key:o.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:E(await t.innerPosition(),e),size:$(await t.innerSize(),e)};return y.runtimeSetWindowProps(n)}},{key:o.WINDOW_MOVED,debounce:200,handler:async t=>{const e=await(t==null?void 0:t.scaleFactor());if(e==null)return null;const i=E(await t.innerPosition(),e),n=await t.isVisible(),l={label:t.label,visible:n,position:i};return y.runtimeSetWindowProps(l)}},{key:o.WINDOW_BLUR,debounce:0,handler:async t=>y.runtimeSetWindowProps({focus:!1,label:t.label})},{key:o.WINDOW_FOCUS,debounce:0,handler:async t=>y.runtimeSetWindowProps({focus:!0,visible:!0,minimized:!1,label:t.label})}],E=(t,e)=>b.J.scale(t,1/e),$=(t,e)=>b._.scale(t,1/e);exports.TauriRuntime=ve;
1
+ "use strict";var ee=Object.defineProperty;var ie=(t,e,i)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var D=(t,e,i)=>ie(t,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./window-DLsE0-fP.cjs"),y=require("./state-Cl8us-b9.cjs"),te=require("./debounce-BUAIXXZt.cjs");function ne(t,e,i,n){if(typeof e=="function"?t!==e||!0:!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 se(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 S;const c="__TAURI_TO_IPC_KEY__";function le(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 ae{get rid(){return ne(this,S,"f")}constructor(e){S.set(this,void 0),se(this,S,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}S=new WeakMap;var o;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(o||(o={}));async function H(t,e){await s("plugin:event|unlisten",{event:t,eventId:e})}async function W(t,e,i){var n;const l=typeof(i==null?void 0:i.target)=="string"?{kind:"AnyLabel",label:i.target}:(n=i==null?void 0:i.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:l,handler:le(e)}).then(r=>async()=>H(t,r))}async function L(t,e,i){return W(t,n=>{H(t,n.id),e(n)},i)}async function N(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function j(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class v{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 d(this.width*e,this.height*e)}[c](){return{width:this.width,height:this.height}}toJSON(){return this[c]()}}class d{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 v(this.width/e,this.height/e)}[c](){return{width:this.width,height:this.height}}toJSON(){return this[c]()}}class h{constructor(e){this.size=e}toLogical(e){return this.size instanceof v?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof d?this.size:this.size.toPhysical(e)}[c](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[c]()}}class T{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)}[c](){return{x:this.x,y:this.y}}toJSON(){return this[c]()}}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 T(this.x/e,this.y/e)}[c](){return{x:this.x,y:this.y}}toJSON(){return this[c]()}}class p{constructor(e){this.position=e}toLogical(e){return this.position instanceof T?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[c](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[c]()}}class m extends ae{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 m(l))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:z(e)}).then(i=>new m(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new m(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 m?t.rid:t}var k;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(k||(k={}));class re{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var M;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(M||(M={}));function q(){return new I(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function R(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new I(e,{skip:!0})))}const x=["tauri://created","tauri://error"];class I{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i!=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 R()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return q()}static async getAll(){return R()}static async getFocusedWindow(){for(const e of await R())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)}:W(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)}:L(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 N(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 j(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 d(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new d(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===k.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 h?e:new h(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof h?e:e?new h(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof h?e:e?new h(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==null?void 0:e.minWidth),minHeight:i(e==null?void 0:e.minHeight),maxWidth:i(e==null?void 0:e.maxWidth),maxHeight:i(e==null?void 0:e.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof p?e:new p(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}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 p?e:new p(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(o.WINDOW_RESIZED,i=>{i.payload=new d(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new re(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(o.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(o.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,l=>{e({...l,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,l=>{e({...l,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var F;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(F||(F={}));var B;(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"})(B||(B={}));var V;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(V||(V={}));function oe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new d(t.size)}}async function ue(){return s("plugin:window|available_monitors").then(t=>t.map(oe))}function J(){return new C(q(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function U(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new C(new I(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const A=["tauri://created","tauri://error"];class C{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n!=null&&n.skip||s("plugin:webview|create_webview",{windowLabel:e.label,label:i,options:n}).then(async()=>this.emit("tauri://created")).catch(async l=>this.emit("tauri://error",l))}static async getByLabel(e){var i;return(i=(await U()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return J()}static async getAll(){return U()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:W(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)}:L(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 N(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 j(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 d(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 h?e:new h(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof p?e:new p(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new u(a.payload.position)}})}),n=await this.listen(o.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new u(a.payload.position)}})}),l=await this.listen(o.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new u(a.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{i(),l(),n(),r()}}}function Z(){const t=J();return new w(t.label,{skip:!0})}async function P(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new w(e,{skip:!0})))}class w{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i!=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 P()).find(l=>l.label===e))!==null&&i!==void 0?i:null;return n?new w(n.label,{skip:!0}):null}static getCurrent(){return Z()}static async getAll(){return P()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:W(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)}:L(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}))}}ce(w,[I,C]);function ce(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 he=t=>JSON.stringify(t),we=t=>JSON.parse(t),O="drift://action",de="tauri://error",be="tauri://created",ye=t=>new Error(`Window not found: ${t}`),g=250,pe=b.O.seconds(1),f=t=>{if(t!=null)return{width:Math.max(t.width,g),height:Math.max(t.height,g)}},ge=t=>{const{size:e,maxSize:i}=t;return{...t,maxSize:f(i),size:f(e)}},_e=async()=>(await ue()).map(e=>{const i=E(e.position,e.scaleFactor),n={width:e.size.width,height:e.size.height};return b.$t.construct(i,n)}),G=async t=>(await _e()).some(i=>b.$t.contains(i,t));class ve{constructor(e){D(this,"win");D(this,"unsubscribe");D(this,"fullscreenPoll",null);this.win=e??Z(),this.unsubscribe={}}async configure(){await this.startFullscreenPoll()}async startFullscreenPoll(){if(b.S.getOS()!=="macOS")return;let e=(await this.getProps()).fullscreen;this.fullscreenPoll=setInterval(()=>{this.win.isFullscreen().then(i=>{i!==e&&(e=i,this.emit({action:y.runtimeSetWindowProps({label:this.win.label,fullscreen:i})},void 0,"WHITELIST").catch(console.error))}).catch(console.error)},pe.milliseconds)}label(){return this.win.label}isMain(){return this.win.label===b.MAIN_WINDOW}release(){Object.values(this.unsubscribe).forEach(e=>e==null?void 0:e()),this.fullscreenPoll!=null&&clearInterval(this.fullscreenPoll),this.unsubscribe={}}async emit(e,i,n=this.label()){const l=he({...e,emitter:n});if(i==null)return await N(O,l);const r=await w.getByLabel(i);if(r==null)throw ye(i);await r.emit(O,l)}async subscribe(e){this.release(),await this.startFullscreenPoll(),this.unsubscribe[O]=await W(O,n=>e(we(n.payload)));const i=me();for(const{key:n,handler:l,debounce:r}of i)this.unsubscribe[n]=await this.win.listen(n,te.o(()=>{l(this.win).then(a=>{a!=null&&this.emit({action:a},void 0,"WHITELIST").catch(console.error)}).catch(console.error)},r))}onCloseRequested(e){this.win.onCloseRequested(i=>{i.preventDefault(),e()})}async create(e,i){i=y.x.copy(i);const{size:n,minSize:l,maxSize:r,position:a,...Q}=ge(i);(n==null?void 0:n.width)!=null&&(n.width=Math.max(n.width,g)),(n==null?void 0:n.height)!=null&&(n.height=Math.max(n.height,g)),(r==null?void 0:r.width)!=null&&(r.width=Math.max(r.width,g)),(r==null?void 0:r.height)!=null&&(r.height=Math.max(r.height,g)),a!=null&&(await G(a)||(a.x=0,a.y=0));try{const _=new w(e,{x:a==null?void 0:a.x,y:a==null?void 0:a.y,width:n==null?void 0:n.width,height:n==null?void 0:n.height,minWidth:l==null?void 0:l.width,minHeight:l==null?void 0:l.height,maxWidth:r==null?void 0:r.width,maxHeight:r==null?void 0:r.height,titleBarStyle:"overlay",dragDropEnabled:!1,...Q});return await new Promise((Y,K)=>{_.once(de,X=>K(new Error(JSON.stringify(X.payload)))),_.once(be,()=>Y())})}catch(_){console.error(_)}}async close(e){const i=await w.getByLabel(e);if(i!=null)try{await i.destroy()}catch(n){console.error(n,e)}else{const n=await P();console.error("Window not found",e,n.map(l=>l.label))}}async listLabels(){return(await P()).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 T(e.x,e.y);await G(e)||(i.x=0,i.y=0),await this.win.setPosition(i)}async setSize(e){e=f(e),await this.win.setSize(new v(e.width,e.height))}async setMinSize(e){e=f(e),await this.win.setMinSize(new v(e.width,e.height))}async setMaxSize(e){e=f(e),await this.win.setMaxSize(new v(e.width,e.height))}async setResizable(e){var i,n;return o.WINDOW_RESIZED in this.unsubscribe&&!e&&((n=(i=this.unsubscribe)[o.WINDOW_RESIZED])==null||n.call(i),delete this.unsubscribe[o.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:E(await this.win.innerPosition(),e),size:$(await this.win.innerSize(),e),maximized:await this.win.isMaximized(),visible:i,fullscreen:await this.win.isFullscreen()}}}const me=()=>[{key:o.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:E(await t.innerPosition(),e),size:$(await t.innerSize(),e)};return y.runtimeSetWindowProps(n)}},{key:o.WINDOW_MOVED,debounce:200,handler:async t=>{const e=await(t==null?void 0:t.scaleFactor());if(e==null)return null;const i=E(await t.innerPosition(),e),n=await t.isVisible(),l={label:t.label,visible:n,position:i};return y.runtimeSetWindowProps(l)}},{key:o.WINDOW_BLUR,debounce:0,handler:async t=>y.runtimeSetWindowProps({focus:!1,label:t.label})},{key:o.WINDOW_FOCUS,debounce:0,handler:async t=>y.runtimeSetWindowProps({focus:!0,visible:!0,minimized:!1,label:t.label})}],E=(t,e)=>b.J.scale(t,1/e),$=(t,e)=>b._.scale(t,1/e);exports.TauriRuntime=ve;
package/dist/tauri.js CHANGED
@@ -2,7 +2,7 @@ var ee = Object.defineProperty;
2
2
  var ie = (t, e, i) => e in t ? ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
3
  var D = (t, e, i) => ie(t, typeof e != "symbol" ? e + "" : e, i);
4
4
  import { O as te, S as ne, M as se, _ as le, J as ae, $ as G } from "./window-BIbHrbtA.js";
5
- import { r as g, _ as re } from "./state-D8a0PvFs.js";
5
+ import { r as g, F as re } from "./state-BOplmOQD.js";
6
6
  import { o as oe } from "./debounce-DOZKRZa9.js";
7
7
  function ue(t, e, i, n) {
8
8
  if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -332,13 +332,13 @@ function J() {
332
332
  skip: !0
333
333
  });
334
334
  }
335
- async function P() {
335
+ async function x() {
336
336
  return s("plugin:window|get_all_windows").then((t) => t.map((e) => new S(e, {
337
337
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
338
338
  skip: !0
339
339
  })));
340
340
  }
341
- const R = ["tauri://created", "tauri://error"];
341
+ const P = ["tauri://created", "tauri://error"];
342
342
  class S {
343
343
  /**
344
344
  * Creates a new Window.
@@ -380,7 +380,7 @@ class S {
380
380
  */
381
381
  static async getByLabel(e) {
382
382
  var i;
383
- return (i = (await P()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
383
+ return (i = (await x()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
384
384
  }
385
385
  /**
386
386
  * Get an instance of `Window` for the current window.
@@ -392,7 +392,7 @@ class S {
392
392
  * Gets a list of instances of `Window` for all available windows.
393
393
  */
394
394
  static async getAll() {
395
- return P();
395
+ return x();
396
396
  }
397
397
  /**
398
398
  * Gets the focused window.
@@ -405,7 +405,7 @@ class S {
405
405
  * @returns The Window instance or `undefined` if there is not any focused window.
406
406
  */
407
407
  static async getFocusedWindow() {
408
- for (const e of await P())
408
+ for (const e of await x())
409
409
  if (await e.isFocused())
410
410
  return e;
411
411
  return null;
@@ -476,7 +476,7 @@ class S {
476
476
  * @param payload Event payload.
477
477
  */
478
478
  async emit(e, i) {
479
- if (R.includes(e)) {
479
+ if (P.includes(e)) {
480
480
  for (const n of this.listeners[e] || [])
481
481
  n({
482
482
  event: e,
@@ -500,7 +500,7 @@ class S {
500
500
  * @param payload Event payload.
501
501
  */
502
502
  async emitTo(e, i, n) {
503
- if (R.includes(i)) {
503
+ if (P.includes(i)) {
504
504
  for (const l of this.listeners[i] || [])
505
505
  l({
506
506
  event: i,
@@ -513,7 +513,7 @@ class S {
513
513
  }
514
514
  /** @ignore */
515
515
  _handleTauriEvent(e, i) {
516
- return R.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
516
+ return P.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
517
517
  }
518
518
  // Getters
519
519
  /**
@@ -1921,7 +1921,7 @@ async function V() {
1921
1921
  skip: !0
1922
1922
  })));
1923
1923
  }
1924
- const x = ["tauri://created", "tauri://error"];
1924
+ const R = ["tauri://created", "tauri://error"];
1925
1925
  class C {
1926
1926
  /**
1927
1927
  * Creates a new Webview.
@@ -2046,7 +2046,7 @@ class C {
2046
2046
  * @param payload Event payload.
2047
2047
  */
2048
2048
  async emit(e, i) {
2049
- if (x.includes(e)) {
2049
+ if (R.includes(e)) {
2050
2050
  for (const n of this.listeners[e] || [])
2051
2051
  n({
2052
2052
  event: e,
@@ -2071,7 +2071,7 @@ class C {
2071
2071
  * @param payload Event payload.
2072
2072
  */
2073
2073
  async emitTo(e, i, n) {
2074
- if (x.includes(i)) {
2074
+ if (R.includes(i)) {
2075
2075
  for (const l of this.listeners[i] || [])
2076
2076
  l({
2077
2077
  event: i,
@@ -2084,7 +2084,7 @@ class C {
2084
2084
  }
2085
2085
  /** @ignore */
2086
2086
  _handleTauriEvent(e, i) {
2087
- return x.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2087
+ return R.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2088
2088
  }
2089
2089
  // Getters
2090
2090
  /**
@@ -2508,7 +2508,7 @@ const ge = (t) => JSON.stringify(t), _e = (t) => JSON.parse(t), W = "drift://act
2508
2508
  const i = I(e.position, e.scaleFactor), n = { width: e.size.width, height: e.size.height };
2509
2509
  return G.construct(i, n);
2510
2510
  }), U = async (t) => (await Oe()).some((i) => G.contains(i, t));
2511
- class Re {
2511
+ class Pe {
2512
2512
  /**
2513
2513
  * @param window - The WebviewWindow to use as the underlying engine for this runtime.
2514
2514
  * This should not be set in 99% of cases. Only use this if you know what you're doing.
@@ -2729,5 +2729,5 @@ const ze = () => [
2729
2729
  }
2730
2730
  ], I = (t, e) => ae.scale(t, 1 / e), $ = (t, e) => le.scale(t, 1 / e);
2731
2731
  export {
2732
- Re as TauriRuntime
2732
+ Pe as TauriRuntime
2733
2733
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/drift",
3
- "version": "0.42.0",
3
+ "version": "0.42.1",
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",
@@ -22,7 +22,7 @@
22
22
  "react-dom": "^19.1.0",
23
23
  "react-redux": "^9.2.0",
24
24
  "zod": "^4.0.0-beta",
25
- "@synnaxlabs/x": "0.42.0"
25
+ "@synnaxlabs/x": "0.42.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^19.1.0",
@@ -36,8 +36,8 @@
36
36
  "vite": "^6.2.5",
37
37
  "vitest": "^3.1.1",
38
38
  "@synnaxlabs/tsconfig": "0.0.2",
39
- "@synnaxlabs/vite-plugin": "0.0.1",
40
- "eslint-config-synnaxlabs": "0.0.1"
39
+ "eslint-config-synnaxlabs": "0.0.1",
40
+ "@synnaxlabs/vite-plugin": "0.0.1"
41
41
  },
42
42
  "files": [
43
43
  "dist"
@@ -1 +0,0 @@
1
- "use strict";const N=require("@reduxjs/toolkit"),d=require("./window-DLsE0-fP.cjs"),w=(e=!1,...n)=>{e&&console.log(...n)},m=(e=!1,...n)=>{e&&console.group(...n)},W=e=>{e&&console.groupEnd()},_=(e,n,o=".")=>{const t=e.split(o);return t.map((i,l)=>{const r=n(i,l,t);return r==null?null:typeof r=="string"?r:r.join(o)}).filter(i=>i!=null).join(o)},I=(e,n,o={optional:!1,separator:"."})=>{o.separator??(o.separator=".");const{optional:t,getter:i=(a,s)=>a[s]}=o,l=n.split(o.separator);if(l.length===1&&l[0]==="")return e;let r=e;for(const a of l){const s=i(r,a);if(s==null){if(t)return null;throw new Error(`Path ${n} does not exist. ${a} is null`)}r=s}return r},L=(e,n,o)=>{const t=n.split(".");let i=e;for(let l=0;l<t.length-1;l++){const r=t[l];i[r]??(i[r]={}),i=i[r]}try{i[t[t.length-1]]=o}catch(l){throw console.error("failed to set value",o,"at path",n,"on object",e),l}},D=(e,n)=>{const o=n.split(".");let t=e;for(let i=0;i<o.length-1;i++){const l=o[i];if(t[l]==null)return;t=t[l]}if(Array.isArray(t)){const i=parseInt(o[o.length-1]);if(isNaN(i))return;t.splice(i,1);return}delete t[o[o.length-1]]},M=(e,n)=>{const o=e.split(".");return n<0?o[o.length+n]:o[n]},j=(e,n)=>{try{return I(e,n),!0}catch{return!1}},R=(e,n)=>{if(n.length===0)return!0;const o=e.split("."),t=n.split(".");if(t.length>o.length)return!1;for(let i=0;i<t.length;i++){const l=o[i],r=t[i];if(r!=="*"&&l!==r)return!1}return!0},v=e=>JSON.parse(JSON.stringify(e)),C=(e,...n)=>(n.forEach(o=>{let t=e;const i=o.split(".");i.forEach((l,r)=>{r===i.length-1?delete t[l]:l in t&&(t=t[l])})}),e),$=(e,n,o="")=>{const t={},i=(l,r,a)=>{if(typeof l!=typeof r||l===null||r===null){t[a]=[l,r];return}if(typeof l=="object"&&typeof r=="object")if(Array.isArray(l)&&Array.isArray(r)){if(l.length!==r.length){t[a]=[l,r];return}for(let s=0;s<l.length;s++)i(l[s],r[s],`${a}[${s}]`)}else new Set([...Object.keys(l),...Object.keys(r)]).forEach(s=>{i(l[s],r[s],a!==""?`${a}.${s}`:s)});else l!==r&&(t[a]=[l,r])};return i(e,n,o),t},b=(e,n)=>{const o=Array.isArray(e),t=Array.isArray(n);if(o!==t)return!1;if(o&&t){const r=e,a=n;if(r.length!==a.length)return!1;for(let s=0;s<r.length;s++)if(!b(r[s],a[s]))return!1;return!0}if(e==null||n==null||typeof e!="object"||typeof n!="object")return e===n;if("equals"in e)return e.equals(n);const i=Object.keys(e),l=Object.keys(n);if(i.length!==l.length)return!1;for(const r of i){const a=e[r],s=n[r];if(typeof a=="object"&&typeof s=="object"){if(!b(a,s))return!1}else if(a!==s)return!1}return!0},k=(e,n)=>{if(typeof e!="object"||e==null)return e===n;const o=Object.keys(e),t=Object.keys(n);if(t.length>o.length)return!1;for(const i of t){const l=e[i],r=n[i];if(typeof l=="object"&&typeof r=="object"){if(!k(l,r))return!1}else if(l!==r)return!1}return!0},y=(e,...n)=>{if(n.length===0)return e;const o=n.shift();if(d.o(e)&&d.o(o))for(const t in o)try{d.o(o[t])?(t in e||Object.assign(e,{[t]:{}}),y(e[t],o[t])):Object.assign(e,{[t]:o[t]})}catch(i){throw i instanceof TypeError?new TypeError(`.${t}: ${i.message}`):i}return y(e,...n)},x=(e,n,o)=>{const t=(i,l,r)=>{for(const a in l){const s=l[a],p=r.shape;if(p!=null&&p[a]){const E=p[a].safeParse(s);E.success&&(i[a]=E.data)}else typeof s=="object"&&!Array.isArray(s)&&s!==null&&r&&r.shape&&r.shape[a]&&(i[a]||(i[a]={}),t(i[a],s,r.shape[a]))}return i};return t({...e},n,o)},g=Object.freeze(Object.defineProperty({__proto__:null,copy:v,deleteD:C,difference:$,element:M,equal:b,get:I,has:j,override:y,overrideValidItems:x,partialEqual:k,pathsMatch:R,remove:D,set:L,transformPath:_},Symbol.toStringTag,{value:"Module"})),q=d.O.milliseconds(50),z=()=>setTimeout(()=>window.location.reload(),q.milliseconds),A={label:d.MAIN_WINDOW,config:{enablePrerender:!0,debug:!1,defaultWindowProps:{}},windows:{main:{...d.INITIAL_WINDOW_STATE,key:d.MAIN_WINDOW,reserved:!0}},labelKeys:{main:d.MAIN_WINDOW},keyLabels:{main:d.MAIN_WINDOW}},F=(e,n)=>{if(e.type===P.type)return n.label!==d.MAIN_WINDOW||(e.payload.label=d.Lt.create(),e.payload.prerenderLabel=d.Lt.create()),e;if("label"in e.payload)return e;let o=n.label;const t=e.payload;return t.key!=null&&(t.key in n.windows?o=t.key:o=n.keyLabels[t.key]),e.payload={...e.payload,label:o},e},c=e=>(n,o)=>{if(!("label"in o.payload))throw new Error("Missing label");e(n,o)},u=(e,n=!1)=>c((o,t)=>{let i=n;const l=o.windows[t.payload.label];if(l!=null){if(t.payload.value!=null)i=t.payload.value;else{const r=l[e];r!=null&&(i=!r)}o.windows[t.payload.label]={...l,[e]:i}}}),f=(e,n=!1)=>(o,t)=>{const i=o.windows[t.payload.label];i!=null&&(o.windows[t.payload.label]={...i,[e]:i[e]+(n?-1:1)})},K=e=>Object.values(e.windows).some(n=>n.key===d.PRERENDER_WINDOW&&!n.reserved),S="drift",V=(e,n,o)=>e.position!=null&&e.size!=null&&n==null?d.$t.topLeft(d.$t.positionInCenter(d.$t.construct(d.J.ZERO,o??d.J.ZERO),d.$t.construct(e.position,e.size))):n,J=(e,{payload:n})=>{if(n.key===d.PRERENDER_WINDOW)return;const{key:o,label:t,prerenderLabel:i}=n;if(t==null||i==null)throw new Error("[drift] - bug - missing label and prerender label");console.log(e.config.debug),m(e.config.debug,"reducer create window");const l=e.windows.main;if(n.position=V(l,n.position,n.size),o in e.keyLabels){w(e.config.debug,"window already exists, un-minimize and focus it");const s=e.keyLabels[n.key];e.windows[s].visible=!0,e.windows[s].focusCount+=1,e.windows[s].minimized=!1,e.windows[s].position=n.position,W(e.config.debug);return}const[r,a]=Object.entries(e.windows).find(([,s])=>!s.reserved)??[null,null];r!=null?(w(e.config.debug,"using available pre-rendered window"),e.windows[r]={...a,visible:!0,reserved:!0,focusCount:1,focus:!0,...n},e.labelKeys[r]=n.key,e.keyLabels[n.key]=r):(w(e.config.debug,"creating new window"),e.windows[t]={...e.config.defaultWindowProps,...d.INITIAL_WINDOW_STATE,...n,reserved:!0},e.labelKeys[t]=o,e.keyLabels[o]=t),e.config.enablePrerender&&!K(e)&&(w(e.config.debug,"creating pre-render window"),e.windows[i]=g.copy({...e.config.defaultWindowProps,...d.INITIAL_PRERENDER_WINDOW_STATE})),W(e.config.debug)},Z=c((e,n)=>{const o=e.windows[n.payload.label];o!=null&&(o.stage=n.payload.stage)}),B=c((e,{payload:{label:n}})=>{const o=e.windows[n];o==null||o.processCount>0||(o.stage="closing",delete e.windows[n],delete e.labelKeys[n],delete e.keyLabels[o.key])}),H=c((e,n)=>{const o=e.windows[n.payload.label];o==null||o.processCount>0||(o.stage="reloading",z())}),U=c(f("processCount")),X=c((e,n)=>{f("processCount",!0)(e,n);const o=e.windows[n.payload.label];o!=null&&o.processCount===0&&(o.stage==="reloading"?z():(e.windows[n.payload.label].visible=!1,delete e.windows[n.payload.label],delete e.labelKeys[n.payload.label],delete e.keyLabels[o.key]))}),Y=(e,n)=>{const o=e.windows[n.payload.key];o!=null&&(o.error=n.payload.message)},G=c((e,n)=>{const o=e.windows[n.payload.label];o!=null&&(o.visible!==!0&&(o.visible=!0),f("focusCount")(e,n))}),Q=u("minimized"),ee=u("maximized"),ne=u("visible",!0),oe=u("fullscreen",!0),te=c(f("centerCount")),ie=c((e,n)=>{e.windows[n.payload.label].position=n.payload.position}),re=c((e,n)=>{e.windows[n.payload.label].size=n.payload.size}),le=c((e,n)=>{e.windows[n.payload.label].minSize=n.payload.size}),se=c((e,n)=>{e.windows[n.payload.label].maxSize=n.payload.size}),ae=u("resizable"),de=u("skipTaskbar"),ce=u("alwaysOnTop"),ue=c((e,n)=>{e.windows[n.payload.label].title=n.payload.title}),we=u("decorations"),h=(e,n)=>{const o=e.windows[n.payload.label];g.partialEqual(o,n.payload)||(e.windows[n.payload.label]={...o,...n.payload})},fe=(e,n)=>{if(e.config={...e.config,...n.payload},e.label=n.payload.label,e.label===d.MAIN_WINDOW&&e.config.enablePrerender){const o=d.Lt.create();e.windows[o]={...e.config.defaultWindowProps,...d.INITIAL_PRERENDER_WINDOW_STATE}}},O=N.createSlice({name:S,initialState:A,reducers:{internalSetInitial:fe,createWindow:J,setWindowStage:Z,closeWindow:B,registerProcess:U,completeProcess:X,setWindowError:Y,focusWindow:G,reloadWindow:H,setWindowMinimized:Q,setWindowMaximized:ee,setWindowVisible:ne,setWindowFullscreen:oe,centerWindow:te,setWindowPosition:ie,setWindowSize:re,setWindowMinSize:le,setWindowMaxSize:se,setWindowResizable:ae,setWindowSkipTaskbar:de,setWindowAlwaysOnTop:ce,setWindowTitle:ue,setWindowDecorations:we,runtimeSetWindowProps:h,setWindowProps:h}}),{actions:{runtimeSetWindowProps:pe,setWindowProps:We,createWindow:P,internalSetInitial:T,setWindowStage:be,closeWindow:ye,registerProcess:ge,completeProcess:Se,setWindowError:Ee,focusWindow:he,reloadWindow:me,setWindowMinimized:Ie,setWindowMaximized:ke,setWindowVisible:ze,setWindowFullscreen:Ae,centerWindow:xe,setWindowPosition:Oe,setWindowSize:Pe,setWindowMinSize:Te,setWindowMaxSize:Ne,setWindowResizable:_e,setWindowSkipTaskbar:Le,setWindowAlwaysOnTop:De,setWindowTitle:Me,setWindowDecorations:je}}=O,Re=O.reducer,ve=e=>e.startsWith(S),Ce=[T.type],$e=(e,n)=>!e&&!Ce.includes(n);exports.SLICE_NAME=S;exports.ZERO_SLICE_STATE=A;exports._=g;exports.assignLabel=F;exports.closeWindow=ye;exports.completeProcess=Se;exports.createWindow=P;exports.focusWindow=he;exports.group=m;exports.groupEnd=W;exports.internalSetInitial=T;exports.isDriftAction=ve;exports.log=w;exports.reducer=Re;exports.registerProcess=ge;exports.reloadWindow=me;exports.runtimeSetWindowProps=pe;exports.setWindowAlwaysOnTop=De;exports.setWindowDecorations=je;exports.setWindowError=Ee;exports.setWindowFullscreen=Ae;exports.setWindowMaxSize=Ne;exports.setWindowMaximized=ke;exports.setWindowMinSize=Te;exports.setWindowMinimized=Ie;exports.setWindowPosition=Oe;exports.setWindowProps=We;exports.setWindowResizable=_e;exports.setWindowSize=Pe;exports.setWindowSkipTaskbar=Le;exports.setWindowStage=be;exports.setWindowTitle=Me;exports.setWindowVisible=ze;exports.shouldEmit=$e;
@@ -1,396 +0,0 @@
1
- import { createSlice as C } from "@reduxjs/toolkit";
2
- import { o as b, O as M, M as u, I as z, P, a as O, L as g, $ as w, J as m } from "./window-BIbHrbtA.js";
3
- const f = (e = !1, ...n) => {
4
- e && console.log(...n);
5
- }, R = (e = !1, ...n) => {
6
- e && console.group(...n);
7
- }, k = (e) => {
8
- e && console.groupEnd();
9
- }, _ = (e, n, o = ".") => {
10
- const t = e.split(o);
11
- return t.map((i, s) => {
12
- const r = n(i, s, t);
13
- return r == null ? null : typeof r == "string" ? r : r.join(o);
14
- }).filter((i) => i != null).join(o);
15
- }, A = (e, n, o = { optional: !1, separator: "." }) => {
16
- o.separator ?? (o.separator = ".");
17
- const { optional: t, getter: i = (a, l) => a[l] } = o, s = n.split(o.separator);
18
- if (s.length === 1 && s[0] === "") return e;
19
- let r = e;
20
- for (const a of s) {
21
- const l = i(r, a);
22
- if (l == null) {
23
- if (t) return null;
24
- throw new Error(`Path ${n} does not exist. ${a} is null`);
25
- }
26
- r = l;
27
- }
28
- return r;
29
- }, D = (e, n, o) => {
30
- const t = n.split(".");
31
- let i = e;
32
- for (let s = 0; s < t.length - 1; s++) {
33
- const r = t[s];
34
- i[r] ?? (i[r] = {}), i = i[r];
35
- }
36
- try {
37
- i[t[t.length - 1]] = o;
38
- } catch (s) {
39
- throw console.error("failed to set value", o, "at path", n, "on object", e), s;
40
- }
41
- }, N = (e, n) => {
42
- const o = n.split(".");
43
- let t = e;
44
- for (let i = 0; i < o.length - 1; i++) {
45
- const s = o[i];
46
- if (t[s] == null) return;
47
- t = t[s];
48
- }
49
- if (Array.isArray(t)) {
50
- const i = parseInt(o[o.length - 1]);
51
- if (isNaN(i)) return;
52
- t.splice(i, 1);
53
- return;
54
- }
55
- delete t[o[o.length - 1]];
56
- }, $ = (e, n) => {
57
- const o = e.split(".");
58
- return n < 0 ? o[o.length + n] : o[n];
59
- }, x = (e, n) => {
60
- try {
61
- return A(e, n), !0;
62
- } catch {
63
- return !1;
64
- }
65
- }, q = (e, n) => {
66
- if (n.length === 0) return !0;
67
- const o = e.split("."), t = n.split(".");
68
- if (t.length > o.length) return !1;
69
- for (let i = 0; i < t.length; i++) {
70
- const s = o[i], r = t[i];
71
- if (r !== "*" && s !== r)
72
- return !1;
73
- }
74
- return !0;
75
- }, K = (e) => JSON.parse(JSON.stringify(e)), F = (e, ...n) => (n.forEach((o) => {
76
- let t = e;
77
- const i = o.split(".");
78
- i.forEach((s, r) => {
79
- r === i.length - 1 ? delete t[s] : s in t && (t = t[s]);
80
- });
81
- }), e), V = (e, n, o = "") => {
82
- const t = {}, i = (s, r, a) => {
83
- if (typeof s != typeof r || s === null || r === null) {
84
- t[a] = [s, r];
85
- return;
86
- }
87
- if (typeof s == "object" && typeof r == "object")
88
- if (Array.isArray(s) && Array.isArray(r)) {
89
- if (s.length !== r.length) {
90
- t[a] = [s, r];
91
- return;
92
- }
93
- for (let l = 0; l < s.length; l++) i(s[l], r[l], `${a}[${l}]`);
94
- } else
95
- (/* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(r)])).forEach((l) => {
96
- i(s[l], r[l], a !== "" ? `${a}.${l}` : l);
97
- });
98
- else s !== r && (t[a] = [s, r]);
99
- };
100
- return i(e, n, o), t;
101
- }, W = (e, n) => {
102
- const o = Array.isArray(e), t = Array.isArray(n);
103
- if (o !== t) return !1;
104
- if (o && t) {
105
- const r = e, a = n;
106
- if (r.length !== a.length) return !1;
107
- for (let l = 0; l < r.length; l++) if (!W(r[l], a[l])) return !1;
108
- return !0;
109
- }
110
- if (e == null || n == null || typeof e != "object" || typeof n != "object")
111
- return e === n;
112
- if ("equals" in e) return e.equals(n);
113
- const i = Object.keys(e), s = Object.keys(n);
114
- if (i.length !== s.length) return !1;
115
- for (const r of i) {
116
- const a = e[r], l = n[r];
117
- if (typeof a == "object" && typeof l == "object") {
118
- if (!W(a, l)) return !1;
119
- } else if (a !== l) return !1;
120
- }
121
- return !0;
122
- }, j = (e, n) => {
123
- if (typeof e != "object" || e == null) return e === n;
124
- const o = Object.keys(e), t = Object.keys(n);
125
- if (t.length > o.length) return !1;
126
- for (const i of t) {
127
- const s = e[i], r = n[i];
128
- if (typeof s == "object" && typeof r == "object") {
129
- if (!j(s, r)) return !1;
130
- } else if (s !== r) return !1;
131
- }
132
- return !0;
133
- }, S = (e, ...n) => {
134
- if (n.length === 0) return e;
135
- const o = n.shift();
136
- if (b(e) && b(o))
137
- for (const t in o)
138
- try {
139
- b(o[t]) ? (t in e || Object.assign(e, { [t]: {} }), S(e[t], o[t])) : Object.assign(e, { [t]: o[t] });
140
- } catch (i) {
141
- throw i instanceof TypeError ? new TypeError(`.${t}: ${i.message}`) : i;
142
- }
143
- return S(e, ...n);
144
- }, Z = (e, n, o) => {
145
- const t = (i, s, r) => {
146
- for (const a in s) {
147
- const l = s[a], y = r.shape;
148
- if (y != null && y[a]) {
149
- const h = y[a].safeParse(l);
150
- h.success && (i[a] = h.data);
151
- } else typeof l == "object" && !Array.isArray(l) && l !== null && r && r.shape && r.shape[a] && (i[a] || (i[a] = {}), t(i[a], l, r.shape[a]));
152
- }
153
- return i;
154
- };
155
- return t({ ...e }, n, o);
156
- }, v = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
157
- __proto__: null,
158
- copy: K,
159
- deleteD: F,
160
- difference: V,
161
- element: $,
162
- equal: W,
163
- get: A,
164
- has: x,
165
- override: S,
166
- overrideValidItems: Z,
167
- partialEqual: j,
168
- pathsMatch: q,
169
- remove: N,
170
- set: D,
171
- transformPath: _
172
- }, Symbol.toStringTag, { value: "Module" })), J = M.milliseconds(50), L = () => setTimeout(() => window.location.reload(), J.milliseconds), B = {
173
- label: u,
174
- config: {
175
- enablePrerender: !0,
176
- debug: !1,
177
- defaultWindowProps: {}
178
- },
179
- windows: {
180
- main: {
181
- ...z,
182
- key: u,
183
- reserved: !0
184
- }
185
- },
186
- labelKeys: {
187
- main: u
188
- },
189
- keyLabels: {
190
- main: u
191
- }
192
- }, ze = (e, n) => {
193
- if (e.type === Se.type)
194
- return n.label !== u || (e.payload.label = g.create(), e.payload.prerenderLabel = g.create()), e;
195
- if ("label" in e.payload) return e;
196
- let o = n.label;
197
- const t = e.payload;
198
- return t.key != null && (t.key in n.windows ? o = t.key : o = n.keyLabels[t.key]), e.payload = { ...e.payload, label: o }, e;
199
- }, d = (e) => (n, o) => {
200
- if (!("label" in o.payload)) throw new Error("Missing label");
201
- e(n, o);
202
- }, c = (e, n = !1) => d((o, t) => {
203
- let i = n;
204
- const s = o.windows[t.payload.label];
205
- if (s != null) {
206
- if (t.payload.value != null) i = t.payload.value;
207
- else {
208
- const r = s[e];
209
- r != null && (i = !r);
210
- }
211
- o.windows[t.payload.label] = { ...s, [e]: i };
212
- }
213
- }), p = (e, n = !1) => (o, t) => {
214
- const i = o.windows[t.payload.label];
215
- i != null && (o.windows[t.payload.label] = {
216
- ...i,
217
- [e]: i[e] + (n ? -1 : 1)
218
- });
219
- }, H = (e) => Object.values(e.windows).some((n) => n.key === P && !n.reserved), T = "drift", U = (e, n, o) => e.position != null && e.size != null && n == null ? w.topLeft(
220
- w.positionInCenter(
221
- w.construct(m.ZERO, o ?? m.ZERO),
222
- w.construct(e.position, e.size)
223
- )
224
- ) : n, X = (e, { payload: n }) => {
225
- if (n.key === P) return;
226
- const { key: o, label: t, prerenderLabel: i } = n;
227
- if (t == null || i == null)
228
- throw new Error("[drift] - bug - missing label and prerender label");
229
- console.log(e.config.debug), R(e.config.debug, "reducer create window");
230
- const s = e.windows.main;
231
- if (n.position = U(s, n.position, n.size), o in e.keyLabels) {
232
- f(e.config.debug, "window already exists, un-minimize and focus it");
233
- const l = e.keyLabels[n.key];
234
- e.windows[l].visible = !0, e.windows[l].focusCount += 1, e.windows[l].minimized = !1, e.windows[l].position = n.position, k(e.config.debug);
235
- return;
236
- }
237
- const [r, a] = Object.entries(e.windows).find(
238
- ([, l]) => !l.reserved
239
- ) ?? [null, null];
240
- r != null ? (f(e.config.debug, "using available pre-rendered window"), e.windows[r] = {
241
- ...a,
242
- visible: !0,
243
- reserved: !0,
244
- focusCount: 1,
245
- focus: !0,
246
- ...n
247
- }, e.labelKeys[r] = n.key, e.keyLabels[n.key] = r) : (f(e.config.debug, "creating new window"), e.windows[t] = {
248
- ...e.config.defaultWindowProps,
249
- ...z,
250
- ...n,
251
- reserved: !0
252
- }, e.labelKeys[t] = o, e.keyLabels[o] = t), e.config.enablePrerender && !H(e) && (f(e.config.debug, "creating pre-render window"), e.windows[i] = v.copy({
253
- ...e.config.defaultWindowProps,
254
- ...O
255
- })), k(e.config.debug);
256
- }, Y = d((e, n) => {
257
- const o = e.windows[n.payload.label];
258
- o != null && (o.stage = n.payload.stage);
259
- }), G = d(
260
- (e, { payload: { label: n } }) => {
261
- const o = e.windows[n];
262
- o == null || o.processCount > 0 || (o.stage = "closing", delete e.windows[n], delete e.labelKeys[n], delete e.keyLabels[o.key]);
263
- }
264
- ), Q = d((e, n) => {
265
- const o = e.windows[n.payload.label];
266
- o == null || o.processCount > 0 || (o.stage = "reloading", L());
267
- }), ee = d(
268
- p("processCount")
269
- ), ne = d((e, n) => {
270
- p("processCount", !0)(e, n);
271
- const o = e.windows[n.payload.label];
272
- o != null && o.processCount === 0 && (o.stage === "reloading" ? L() : (e.windows[n.payload.label].visible = !1, delete e.windows[n.payload.label], delete e.labelKeys[n.payload.label], delete e.keyLabels[o.key]));
273
- }), oe = (e, n) => {
274
- const o = e.windows[n.payload.key];
275
- o != null && (o.error = n.payload.message);
276
- }, te = d((e, n) => {
277
- const o = e.windows[n.payload.label];
278
- o != null && (o.visible !== !0 && (o.visible = !0), p("focusCount")(e, n));
279
- }), ie = c("minimized"), re = c("maximized"), se = c("visible", !0), le = c("fullscreen", !0), ae = d(
280
- p("centerCount")
281
- ), de = d((e, n) => {
282
- e.windows[n.payload.label].position = n.payload.position;
283
- }), ce = d((e, n) => {
284
- e.windows[n.payload.label].size = n.payload.size;
285
- }), ue = d((e, n) => {
286
- e.windows[n.payload.label].minSize = n.payload.size;
287
- }), we = d((e, n) => {
288
- e.windows[n.payload.label].maxSize = n.payload.size;
289
- }), fe = c("resizable"), pe = c("skipTaskbar"), ye = c("alwaysOnTop"), be = d((e, n) => {
290
- e.windows[n.payload.label].title = n.payload.title;
291
- }), ge = c("decorations"), E = (e, n) => {
292
- const o = e.windows[n.payload.label];
293
- v.partialEqual(o, n.payload) || (e.windows[n.payload.label] = { ...o, ...n.payload });
294
- }, We = (e, n) => {
295
- if (e.config = { ...e.config, ...n.payload }, e.label = n.payload.label, e.label === u && e.config.enablePrerender) {
296
- const o = g.create();
297
- e.windows[o] = {
298
- ...e.config.defaultWindowProps,
299
- ...O
300
- };
301
- }
302
- }, I = C({
303
- name: T,
304
- initialState: B,
305
- reducers: {
306
- internalSetInitial: We,
307
- createWindow: X,
308
- setWindowStage: Y,
309
- closeWindow: G,
310
- registerProcess: ee,
311
- completeProcess: ne,
312
- setWindowError: oe,
313
- focusWindow: te,
314
- reloadWindow: Q,
315
- setWindowMinimized: ie,
316
- setWindowMaximized: re,
317
- setWindowVisible: se,
318
- setWindowFullscreen: le,
319
- centerWindow: ae,
320
- setWindowPosition: de,
321
- setWindowSize: ce,
322
- setWindowMinSize: ue,
323
- setWindowMaxSize: we,
324
- setWindowResizable: fe,
325
- setWindowSkipTaskbar: pe,
326
- setWindowAlwaysOnTop: ye,
327
- setWindowTitle: be,
328
- setWindowDecorations: ge,
329
- runtimeSetWindowProps: E,
330
- setWindowProps: E
331
- }
332
- }), {
333
- actions: {
334
- runtimeSetWindowProps: Pe,
335
- setWindowProps: Oe,
336
- createWindow: Se,
337
- internalSetInitial: he,
338
- setWindowStage: Ae,
339
- closeWindow: je,
340
- registerProcess: ve,
341
- completeProcess: Le,
342
- setWindowError: Te,
343
- focusWindow: Ie,
344
- reloadWindow: Ce,
345
- setWindowMinimized: Me,
346
- setWindowMaximized: Re,
347
- setWindowVisible: _e,
348
- setWindowFullscreen: De,
349
- centerWindow: Ne,
350
- setWindowPosition: $e,
351
- setWindowSize: xe,
352
- setWindowMinSize: qe,
353
- setWindowMaxSize: Ke,
354
- setWindowResizable: Fe,
355
- setWindowSkipTaskbar: Ve,
356
- setWindowAlwaysOnTop: Ze,
357
- setWindowTitle: Je,
358
- setWindowDecorations: Be
359
- }
360
- } = I, He = I.reducer, Ue = (e) => e.startsWith(T), me = [he.type], Xe = (e, n) => !e && !me.includes(n);
361
- export {
362
- Fe as A,
363
- xe as B,
364
- Ve as C,
365
- Je as D,
366
- _e as E,
367
- T as S,
368
- B as Z,
369
- v as _,
370
- k as a,
371
- Ce as b,
372
- ze as c,
373
- Te as d,
374
- he as e,
375
- Ae as f,
376
- R as g,
377
- je as h,
378
- Ue as i,
379
- Le as j,
380
- Se as k,
381
- f as l,
382
- Ie as m,
383
- He as n,
384
- ve as o,
385
- Ze as p,
386
- Be as q,
387
- Pe as r,
388
- Xe as s,
389
- De as t,
390
- Ke as u,
391
- Re as v,
392
- qe as w,
393
- Me as x,
394
- $e as y,
395
- Oe as z
396
- };