@synnaxlabs/drift 0.42.0 → 0.42.3

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-Bj8OM9F9.cjs"),q=require("./state-xseZCh_u.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
@@ -1,8 +1,8 @@
1
1
  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
- import { M as _ } from "./window-BIbHrbtA.js";
5
- import { r as H } from "./state-D8a0PvFs.js";
4
+ import { M as _ } from "./window-DwJfMpbK.js";
5
+ import { r as H } from "./state-BX_5GHgM.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-xseZCh_u.cjs"),f=require("./window-Bj8OM9F9.cjs"),h=require("./selectors-CGCIf0Ac.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,7 +1,7 @@
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";
3
- import { M as w, _ as p, J as ce, I as ue, w as fe } from "./window-BIbHrbtA.js";
4
- import { s as de, a as we, b as he, c as pe, d as ye, e as _e } from "./selectors--wDYbFAe.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-BX_5GHgM.js";
3
+ import { M as w, _ as p, J as ce, I as ue, w as fe } from "./window-DwJfMpbK.js";
4
+ import { s as de, a as we, b as he, c as pe, d as ye, e as _e } from "./selectors-B00IQPYW.js";
5
5
  const be = new Error("request for lock canceled");
6
6
  var me = function(i, e, s, t) {
7
7
  function a(o) {
package/dist/noop.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./window-DLsE0-fP.cjs");class s{async configure(){}isMain(){return!0}label(){return e.MAIN_WINDOW}async emit(){}async subscribe(){}onCloseRequested(){}async listLabels(){return[e.MAIN_WINDOW]}async create(){}async close(){}async focus(){}async setMinimized(){}async setMaximized(){}async setVisible(){}async setFullscreen(){}async center(){}async setPosition(){}async setSize(){}async setMinSize(){}async setMaxSize(){}async setResizable(){}async setSkipTaskbar(){}async setAlwaysOnTop(){}async setTitle(){}async setDecorations(){}async getProps(){return{visible:!0,focus:!0,maximized:!1,minimized:!1,fullscreen:!1,position:{x:0,y:0},size:{width:800,height:600}}}}exports.NoopRuntime=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./window-Bj8OM9F9.cjs");class s{async configure(){}isMain(){return!0}label(){return e.MAIN_WINDOW}async emit(){}async subscribe(){}onCloseRequested(){}async listLabels(){return[e.MAIN_WINDOW]}async create(){}async close(){}async focus(){}async setMinimized(){}async setMaximized(){}async setVisible(){}async setFullscreen(){}async center(){}async setPosition(){}async setSize(){}async setMinSize(){}async setMaxSize(){}async setResizable(){}async setSkipTaskbar(){}async setAlwaysOnTop(){}async setTitle(){}async setDecorations(){}async getProps(){return{visible:!0,focus:!0,maximized:!1,minimized:!1,fullscreen:!1,position:{x:0,y:0},size:{width:800,height:600}}}}exports.NoopRuntime=s;
package/dist/noop.js CHANGED
@@ -1,4 +1,4 @@
1
- import { M as s } from "./window-BIbHrbtA.js";
1
+ import { M as s } from "./window-DwJfMpbK.js";
2
2
  class a {
3
3
  async configure() {
4
4
  }
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-CGCIf0Ac.cjs"),i=require("./state-xseZCh_u.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
@@ -1,8 +1,8 @@
1
1
  import { useCallback as l, useRef as f, useEffect as m, useState as d, createElement as W } from "react";
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
- 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";
4
+ import { a as k, e as S, c as P, b as v } from "./selectors-B00IQPYW.js";
5
+ import { o as w, j as p } from "./state-BX_5GHgM.js";
6
6
  const h = (e) => u(
7
7
  l(
8
8
  i((r) => k(r, e)),
@@ -1,4 +1,4 @@
1
- import { M as i } from "./window-BIbHrbtA.js";
1
+ import { M as i } from "./window-DwJfMpbK.js";
2
2
  const l = (n) => n.drift, a = (n) => Object.values(l(n).windows), r = (n, e) => {
3
3
  const t = l(n);
4
4
  if (e == null) return t.windows[t.label];
@@ -1 +1 @@
1
- "use strict";const i=require("./window-DLsE0-fP.cjs"),s=n=>n.drift,r=n=>Object.values(s(n).windows),c=(n,e)=>{const t=s(n);if(e==null)return t.windows[t.label];let l=t.windows[e];if(l!=null)return l;const o=t.keyLabels[e];return l=t.windows[o],l==null&&e!=null?null:l??t.windows[t.label]},w=(n,e)=>{const t=s(n);if(e==null)return t.labelKeys[t.label];const l=t.labelKeys[e];return l==null&&e==i.MAIN_WINDOW?i.MAIN_WINDOW:l},d=(n,e,t)=>{var l;return((l=c(n,e))==null?void 0:l[t])??null},u=(n,e)=>s(n).keyLabels[e];exports.selectSliceState=s;exports.selectWindow=c;exports.selectWindowAttribute=d;exports.selectWindowKey=w;exports.selectWindowLabel=u;exports.selectWindows=r;
1
+ "use strict";const i=require("./window-Bj8OM9F9.cjs"),s=n=>n.drift,r=n=>Object.values(s(n).windows),c=(n,e)=>{const t=s(n);if(e==null)return t.windows[t.label];let l=t.windows[e];if(l!=null)return l;const o=t.keyLabels[e];return l=t.windows[o],l==null&&e!=null?null:l??t.windows[t.label]},w=(n,e)=>{const t=s(n);if(e==null)return t.labelKeys[t.label];const l=t.labelKeys[e];return l==null&&e==i.MAIN_WINDOW?i.MAIN_WINDOW:l},d=(n,e,t)=>{var l;return((l=c(n,e))==null?void 0:l[t])??null},u=(n,e)=>s(n).keyLabels[e];exports.selectSliceState=s;exports.selectWindow=c;exports.selectWindowAttribute=d;exports.selectWindowKey=w;exports.selectWindowLabel=u;exports.selectWindows=r;
@@ -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-DwJfMpbK.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-Bj8OM9F9.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;