@synnaxlabs/drift 0.38.0 → 0.38.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 +1 -1
- package/dist/electron.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +138 -138
- package/dist/react.cjs +1 -1
- package/dist/react.js +32 -32
- package/dist/{selectors-DSYdcjUd.cjs → selectors-CYHEOjO4.cjs} +1 -1
- package/dist/{selectors-CDBV8JlK.js → selectors-DwAh3Dt_.js} +1 -1
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/src/state.d.ts.map +1 -1
- package/dist/src/tauri/index.d.ts.map +1 -1
- package/dist/{state-B6yPmERI.js → state-B8DVhsB5.js} +846 -912
- package/dist/state-Nl_4DIvw.cjs +13 -0
- package/dist/tauri.cjs +1 -1
- package/dist/tauri.js +21 -19
- package/package.json +3 -3
- package/dist/state--TjGqMVk.cjs +0 -13
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 _=(t,e,o)=>B(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./state
|
|
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 _=(t,e,o)=>B(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./state-Nl_4DIvw.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],q=t=>{if(!Z.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},F=[E],U=t=>{if(!F.includes(t))throw new Error(`Event ${t} is not on the list of allowed events`)},$=[S,D],G=t=>{if(!$.includes(t))throw new Error(`Command ${t} is not on the list of allowed commands`)},J=t=>{var e,o,r,l,u,d,m,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:(m=t.maxSize)==null?void 0:m.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}},K=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}},X=({mainWindow:t,createWindow:e})=>{const o=new Map,r=new Map;o.set(h.MAIN_WINDOW,t.id),r.set(t.id,h.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:{...K(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 m=(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)=>{m(i,a,()=>{f({action:h.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(h.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(J(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)})},T="driftAPI",j=()=>{const{ipcRenderer:t,contextBridge:e}=require("electron"),o={send:(r,...l)=>{q(r),t.send(r,...l)},invoke:async(r,...l)=>(G(r),await t.invoke(r,...l)),on:(r,l)=>{U(r),t.on(r,l)}};e.exposeInMainWorld(T,o)},Y=async()=>{if(!(T in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");return await window[T].invoke(D)};class Q{constructor(){_(this,"_label","");_(this,"props",null);_(this,"api");if(!(T in window))throw new Error("Drift API not found. Make sure to call configurePreload in your preload script.");this.api=window[T]}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===h.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=Q;exports.exposeAPI=j;exports.getWindowLabel=Y;exports.listenOnMain=X;
|
package/dist/electron.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 _, r as H } from "./state-
|
|
4
|
+
import { M as _, r as H } from "./state-B8DVhsB5.js";
|
|
5
5
|
import { o as Z } from "./debounce-DOZKRZa9.js";
|
|
6
6
|
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 = [
|
|
7
7
|
E,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@reduxjs/toolkit"),t=require("./state--TjGqMVk.cjs"),f=require("./selectors-DSYdcjUd.cjs"),C=new Error("request for lock canceled");var L=function(i,e,s,o){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(o.next(c))}catch(w){r(w)}}function d(c){try{u(o.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((o=o.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((o,n)=>{const a={resolve:o,reject:n,weight:e,priority:s},r=E(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,o=1,n=0){const[a,r]=yield this.acquire(o,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(o=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),P(this._weightedWaiters[e-1],{resolve:o,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(o=>o.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let s=this._value;s>0;s--){const o=this._weightedWaiters[s-1];if(!o)continue;const n=o.findIndex(a=>a.priority<=e);(n===-1?o:o.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=E(i,o=>e.priority<=o.priority);i.splice(s+1,0,e)}function E(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,o){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(o.next(c))}catch(w){r(w)}}function d(c){try{u(o.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((o=o.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 o=new Map;return i.forEach(n=>{const a=e(n);if(o.has(a)){if(s)return;o.delete(a)}o.set(a,n)}),Array.from(o.values())},V=Object.freeze(Object.defineProperty({__proto__:null,by:F,unique:R},Symbol.toStringTag,{value:"Module"})),T="DA@",I="://",j=(i,e)=>T.concat(e,I,i),Z=i=>{const[e,s]=i.split(I);if(s==null)return[i,""];const[,o]=e.split(T);return[s,o]},b=(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:o,stage:n,key:a,prerenderLabel:r,reserved:l,minimized:d,...u}=i;return u},Q=async(i,e,s,o)=>{const n=(await s.listLabels()).filter(c=>c!==t.MAIN_WINDOW),a=Object.keys(i.windows).filter(c=>c!==t.MAIN_WINDOW);t.group(o,"syncInitial"),t.log(o,"existing windows in runtime",n.sort()),t.log(o,"non-main windows in state",a.sort()),t.groupEnd(o);const r=V.unique([...n,...a]);for(const c of r)!n.includes(c)&&s.isMain()?(t.log(o,"state window not in runtime, creating",c),await k(s,c,i.windows[c],o)):a.includes(c)||(t.log(o,"runtime window not in state, closing",c),await p(s,c,o));const l=s.label(),d=i.windows[l];if(d==null)return;const u={...t.INITIAL_WINDOW_STATE,key:l};await M(u,d,s,o),e(t.runtimeSetWindowProps({label:s.label(),...await s.getProps()}))},X=async(i,e,s,o)=>{t.log(o,"sync",i,e),s.isMain()&&await $(i,e,s,o);const n=i.windows[s.label()],a=e.windows[s.label()];n==null||a==null||await M(n,a,s,o)},M=async(i,e,s,o)=>{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),s.setPosition(t.G.translate(d,{x:1,y:1})),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&&!t._.equals(e.minSize,i.minSize)&&n.push(["minSize",{prev:i.minSize,next:e.minSize},async()=>await s.setMinSize(e.minSize)]),e.maxSize!=null&&!t._.equals(e.maxSize,i.maxSize)&&n.push(["maxSize",{prev:i.maxSize,next:e.maxSize},async()=>await s.setMaxSize(e.maxSize)]),e.size!=null&&!t._.equals(e.size,i.size)&&n.push(["size",{prev:i.size,next:e.size},async()=>await s.setSize(e.size)]),e.position!=null&&!t._.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){t.group(o,`syncCurrent, label: ${s.label()}, key: ${e.key}`);for(const[d,{prev:u,next:c}]of n)t.log(o,d,u,"->",c);t.groupEnd(o);for(const[,,d]of n)await d()}},$=async(i,e,s,o)=>{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)t.log(o,"syncMain","closing",l),l===t.MAIN_WINDOW&&await Promise.all(Object.keys(e.windows).filter(d=>d!==t.MAIN_WINDOW).map(async d=>await p(s,d,o))),await p(s,l,o);if(r&&a.length>0)for(const l of a)await k(s,l,e.windows[l],o)},k=async(i,e,s,o)=>(t.log(o,"createWindow",s),await i.create(e,K(s))),p=async(i,e,s)=>(t.log(s,"closeWindow",e),await i.close(e)),z="[drift] - unexpected undefined action",m="[drift] - unexpected undefined action type",y=i=>{if(i.emitted??(i.emitted=!1),i.action==null)throw console.warn(z,i),new Error(z);if(i.action.type==null||i.action.type.length===0)throw console.warn(m,i),new Error(m)},G=new D,Y=[t.runtimeSetWindowProps.type,t.reloadWindow.type],B=(i,e=!1)=>({getState:s,dispatch:o})=>n=>a=>{let{action:r,emitted:l,emitter:d}=U(a);const u=i.label();y({action:a,emitted:l,emitter:d});const c=t.isDriftAction(r.type);if(c&&t.log(e,"[drift] - middleware",{action:r,emitted:l,emitter:d,host:u}),d===i.label())return;const w=c&&!Y.includes(r.type);let h=null;c&&(h=s().drift,r=t.assignLabel(r,h));const O=n(r),_=w?s().drift:null,v=t.shouldEmit(l,r.type);return G.runExclusive(async()=>{try{h!==null&&_!==null&&await X(h,_,i,e),v&&await i.emit({action:r})}catch(S){t.log(e,"[drift] - ERROR",{error:S.message,action:r,emitted:l,emitter:d,host:u}),o(t.setWindowError({key:u,message:S.message}))}}),O},H=(i,e,s=!1)=>o=>{const n=i!=null?typeof i=="function"?i(o):i:o();return[B(e,s),...n]},J=async({runtime:i,preloadedState:e,middleware:s,debug:o=!1,enablePrerender:n=!0,defaultWindowProps:a,...r})=>{await i.configure();let l;l=A.configureStore({...r,preloadedState:await x(o,i,()=>l,a,e),middleware:H(s,i,o)}),await Q(l.getState().drift,l.dispatch,i,o);const d=i.label();return l.dispatch(t.internalSetInitial({enablePrerender:n,defaultWindowProps:a,debug:o,label:d})),l.dispatch(t.setWindowStage({stage:"created"})),i.onCloseRequested(()=>l==null?void 0:l.dispatch(t.closeWindow({}))),l},x=async(i,e,s,o,n)=>e.isMain()?(await e.subscribe(({action:r,emitter:l,sendState:d})=>{const u=s();if(u==null)return;if(r!=null){y({action:r,emitter:l}),u.dispatch(b(r,l));return}const c=u.getState();d===!0&&e.emit({state:c},l)}),typeof n=="function"?g(o,i,await n()):g(o,i,n)):await new Promise((r,l)=>{(async()=>{try{await e.subscribe(({action:u,emitter:c,state:w})=>{const h=s();if(h==null)return w!=null?r(w):void 0;u!=null&&(y({action:u,emitter:c}),h.dispatch(b(u,c)))}),await e.emit({sendState:!0},t.MAIN_WINDOW)}catch(u){l(u)}})()}),W=J,g=(i,e,s)=>{if(s==null)return s;const o=s[t.SLICE_NAME];return o.config.debug=e??o.config.debug,o.windows=Object.fromEntries(Object.entries(o.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:t.MAIN_WINDOW,SLICE_NAME:t.SLICE_NAME,ZERO_SLICE_STATE:t.ZERO_SLICE_STATE,closeWindow:t.closeWindow,completeProcess:t.completeProcess,configureStore:W,createWindow:t.createWindow,focusWindow:t.focusWindow,reducer:t.reducer,registerProcess:t.registerProcess,reloadWindow:t.reloadWindow,selectSliceState:f.selectSliceState,selectWindow:f.selectWindow,selectWindowAttribute:f.selectWindowAttribute,selectWindowKey:f.selectWindowKey,selectWindowLabel:f.selectWindowLabel,selectWindows:f.selectWindows,setWindowAlwaysOnTop:t.setWindowAlwaysOnTop,setWindowDecorations:t.setWindowDecorations,setWindowFullscreen:t.setWindowFullscreen,setWindowMaxSize:t.setWindowMaxSize,setWindowMaximized:t.setWindowMaximized,setWindowMinSize:t.setWindowMinSize,setWindowMinimized:t.setWindowMinimized,setWindowPosition:t.setWindowPosition,setWindowProps:t.setWindowProps,setWindowResizable:t.setWindowResizable,setWindowSize:t.setWindowSize,setWindowSkipTaskbar:t.setWindowSkipTaskbar,setWindowStage:t.setWindowStage,setWindowTitle:t.setWindowTitle,setWindowVisible:t.setWindowVisible,windowPropsZ:t.windowPropsZ},Symbol.toStringTag,{value:"Module"}));exports.MAIN_WINDOW=t.MAIN_WINDOW;exports.SLICE_NAME=t.SLICE_NAME;exports.ZERO_SLICE_STATE=t.ZERO_SLICE_STATE;exports.closeWindow=t.closeWindow;exports.completeProcess=t.completeProcess;exports.createWindow=t.createWindow;exports.focusWindow=t.focusWindow;exports.reducer=t.reducer;exports.registerProcess=t.registerProcess;exports.reloadWindow=t.reloadWindow;exports.setWindowAlwaysOnTop=t.setWindowAlwaysOnTop;exports.setWindowDecorations=t.setWindowDecorations;exports.setWindowFullscreen=t.setWindowFullscreen;exports.setWindowMaxSize=t.setWindowMaxSize;exports.setWindowMaximized=t.setWindowMaximized;exports.setWindowMinSize=t.setWindowMinSize;exports.setWindowMinimized=t.setWindowMinimized;exports.setWindowPosition=t.setWindowPosition;exports.setWindowProps=t.setWindowProps;exports.setWindowResizable=t.setWindowResizable;exports.setWindowSize=t.setWindowSize;exports.setWindowSkipTaskbar=t.setWindowSkipTaskbar;exports.setWindowStage=t.setWindowStage;exports.setWindowTitle=t.setWindowTitle;exports.setWindowVisible=t.setWindowVisible;exports.windowPropsZ=t.windowPropsZ;exports.selectSliceState=f.selectSliceState;exports.selectWindow=f.selectWindow;exports.selectWindowAttribute=f.selectWindowAttribute;exports.selectWindowKey=f.selectWindowKey;exports.selectWindowLabel=f.selectWindowLabel;exports.selectWindows=f.selectWindows;exports.Drift=ee;exports.configureStore=W;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("@reduxjs/toolkit"),t=require("./state-Nl_4DIvw.cjs"),f=require("./selectors-CYHEOjO4.cjs"),A=new Error("request for lock canceled");var C=function(i,e,s,o){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(o.next(c))}catch(w){r(w)}}function d(c){try{u(o.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((o=o.apply(i,e||[])).next())})};class L{constructor(e,s=A){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((o,n)=>{const a={resolve:o,reject:n,weight:e,priority:s},r=E(this._queue,l=>s<=l.priority);r===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(r+1,0,a)})}runExclusive(e){return C(this,arguments,void 0,function*(s,o=1,n=0){const[a,r]=yield this.acquire(o,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(o=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),N(this._weightedWaiters[e-1],{resolve:o,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(o=>o.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let s=this._value;s>0;s--){const o=this._weightedWaiters[s-1];if(!o)continue;const n=o.findIndex(a=>a.priority<=e);(n===-1?o:o.splice(0,n)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,s){return(this._queue.length===0||this._queue[0].priority<s)&&e<=this._value}}function N(i,e){const s=E(i,o=>e.priority<=o.priority);i.splice(s+1,0,e)}function E(i,e){for(let s=i.length-1;s>=0;s--)if(e(i[s]))return s;return-1}var P=function(i,e,s,o){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(o.next(c))}catch(w){r(w)}}function d(c){try{u(o.throw(c))}catch(w){r(w)}}function u(c){c.done?a(c.value):n(c.value).then(l,d)}u((o=o.apply(i,e||[])).next())})};class q{constructor(e){this._semaphore=new L(1,e)}acquire(){return P(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 D=i=>[...new Set(i)],R=(i,e,s=!0)=>{const o=new Map;return i.forEach(n=>{const a=e(n);if(o.has(a)){if(s)return;o.delete(a)}o.set(a,n)}),Array.from(o.values())},F=Object.freeze(Object.defineProperty({__proto__:null,by:R,unique:D},Symbol.toStringTag,{value:"Module"})),T="DA@",I="://",V=(i,e)=>T.concat(e,I,i),j=i=>{const[e,s]=i.split(I);if(s==null)return[i,""];const[,o]=e.split(T);return[s,o]},b=(i,e)=>({...i,type:V(i.type,e)}),Z=i=>{const[e,s]=j(i.type);return{emitted:s!=null&&s.length>0,emitter:s,action:{...i,type:e}}},U=i=>{const{centerCount:e,processCount:s,focusCount:o,stage:n,key:a,prerenderLabel:r,reserved:l,minimized:d,...u}=i;return u},K=async(i,e,s,o)=>{const n=(await s.listLabels()).filter(c=>c!==t.MAIN_WINDOW),a=Object.keys(i.windows).filter(c=>c!==t.MAIN_WINDOW);t.group(o,"syncInitial"),t.log(o,"existing windows in runtime",n.sort()),t.log(o,"non-main windows in state",a.sort()),t.groupEnd(o);const r=F.unique([...n,...a]);for(const c of r)!n.includes(c)&&s.isMain()?(t.log(o,"state window not in runtime, creating",c),await k(s,c,i.windows[c],o)):a.includes(c)||(t.log(o,"runtime window not in state, closing",c),await p(s,c,o));const l=s.label(),d=i.windows[l];if(d==null)return;const u={...t.INITIAL_WINDOW_STATE,key:l};await M(u,d,s,o),e(t.runtimeSetWindowProps({label:s.label(),...await s.getProps()}))},Q=async(i,e,s,o)=>{t.log(o,"sync",i,e),s.isMain()&&await X(i,e,s,o);const n=i.windows[s.label()],a=e.windows[s.label()];n==null||a==null||await M(n,a,s,o)},M=async(i,e,s,o)=>{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(t.G.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&&!t._.equals(e.minSize,i.minSize)&&n.push(["minSize",{prev:i.minSize,next:e.minSize},async()=>await s.setMinSize(e.minSize)]),e.maxSize!=null&&!t._.equals(e.maxSize,i.maxSize)&&n.push(["maxSize",{prev:i.maxSize,next:e.maxSize},async()=>await s.setMaxSize(e.maxSize)]),e.size!=null&&!t._.equals(e.size,i.size)&&n.push(["size",{prev:i.size,next:e.size},async()=>await s.setSize(e.size)]),e.position!=null&&!t._.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){t.group(o,`syncCurrent, label: ${s.label()}, key: ${e.key}`);for(const[d,{prev:u,next:c}]of n)t.log(o,d,u,"->",c);t.groupEnd(o);for(const[,,d]of n)await d()}},X=async(i,e,s,o)=>{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)t.log(o,"syncMain","closing",l),l===t.MAIN_WINDOW&&await Promise.all(Object.keys(e.windows).filter(d=>d!==t.MAIN_WINDOW).map(async d=>await p(s,d,o))),await p(s,l,o);if(r&&a.length>0)for(const l of a)await k(s,l,e.windows[l],o)},k=async(i,e,s,o)=>(t.log(o,"createWindow",s),await i.create(e,U(s))),p=async(i,e,s)=>(t.log(s,"closeWindow",e),await i.close(e)),z="[drift] - unexpected undefined action",m="[drift] - unexpected undefined action type",y=i=>{if(i.emitted??(i.emitted=!1),i.action==null)throw console.warn(z,i),new Error(z);if(i.action.type==null||i.action.type.length===0)throw console.warn(m,i),new Error(m)},$=new q,G=[t.runtimeSetWindowProps.type,t.reloadWindow.type],Y=(i,e=!1)=>s=>o=>n=>{let{action:a,emitted:r,emitter:l}=Z(n);const d=i.label();y({action:n,emitted:r,emitter:l});const u=t.isDriftAction(a.type);if(u&&t.log(e,"[drift] - middleware",{action:a,emitted:r,emitter:l,host:d}),l===i.label())return;const c=u&&!G.includes(a.type);let w=null;u&&(w=s.getState().drift,a=t.assignLabel(a,w));const h=o(a),_=c?s.getState().drift:null,v=t.shouldEmit(r,a.type);return $.runExclusive(async()=>{try{w!==null&&_!==null&&await Q(w,_,i,e),v&&await i.emit({action:a})}catch(S){t.log(e,"[drift] - ERROR",{error:S.message,action:a,emitted:r,emitter:l,host:d}),s.dispatch(t.setWindowError({key:d,message:S.message}))}}),h},B=(i,e,s=!1)=>o=>{const n=i!=null?typeof i=="function"?i(o):i:o();return[Y(e,s),...n]},H=async({runtime:i,preloadedState:e,middleware:s,debug:o=!1,enablePrerender:n=!0,defaultWindowProps:a,...r})=>{await i.configure();let l;l=O.configureStore({...r,preloadedState:await J(o,i,()=>l,a,e),middleware:B(s,i,o)}),await K(l.getState().drift,l.dispatch,i,o);const d=i.label();return l.dispatch(t.internalSetInitial({enablePrerender:n,defaultWindowProps:a,debug:o,label:d})),l.dispatch(t.setWindowStage({stage:"created"})),i.onCloseRequested(()=>l==null?void 0:l.dispatch(t.closeWindow({}))),l},J=async(i,e,s,o,n)=>e.isMain()?(await e.subscribe(({action:r,emitter:l,sendState:d})=>{const u=s();if(u==null)return;if(r!=null){y({action:r,emitter:l}),u.dispatch(b(r,l));return}const c=u.getState();d===!0&&e.emit({state:c},l)}),typeof n=="function"?g(o,i,await n()):g(o,i,n)):await new Promise((r,l)=>{(async()=>{try{await e.subscribe(({action:u,emitter:c,state:w})=>{const h=s();if(h==null)return w!=null?r(w):void 0;u!=null&&(y({action:u,emitter:c}),h.dispatch(b(u,c)))}),await e.emit({sendState:!0},t.MAIN_WINDOW)}catch(u){l(u)}})()}),W=H,g=(i,e,s)=>{if(s==null)return s;const o=s[t.SLICE_NAME];return o.config.debug=e??o.config.debug,o.windows=Object.fromEntries(Object.entries(o.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},x=Object.freeze(Object.defineProperty({__proto__:null,MAIN_WINDOW:t.MAIN_WINDOW,SLICE_NAME:t.SLICE_NAME,ZERO_SLICE_STATE:t.ZERO_SLICE_STATE,closeWindow:t.closeWindow,completeProcess:t.completeProcess,configureStore:W,createWindow:t.createWindow,focusWindow:t.focusWindow,reducer:t.reducer,registerProcess:t.registerProcess,reloadWindow:t.reloadWindow,selectSliceState:f.selectSliceState,selectWindow:f.selectWindow,selectWindowAttribute:f.selectWindowAttribute,selectWindowKey:f.selectWindowKey,selectWindowLabel:f.selectWindowLabel,selectWindows:f.selectWindows,setWindowAlwaysOnTop:t.setWindowAlwaysOnTop,setWindowDecorations:t.setWindowDecorations,setWindowFullscreen:t.setWindowFullscreen,setWindowMaxSize:t.setWindowMaxSize,setWindowMaximized:t.setWindowMaximized,setWindowMinSize:t.setWindowMinSize,setWindowMinimized:t.setWindowMinimized,setWindowPosition:t.setWindowPosition,setWindowProps:t.setWindowProps,setWindowResizable:t.setWindowResizable,setWindowSize:t.setWindowSize,setWindowSkipTaskbar:t.setWindowSkipTaskbar,setWindowStage:t.setWindowStage,setWindowTitle:t.setWindowTitle,setWindowVisible:t.setWindowVisible,windowPropsZ:t.windowPropsZ},Symbol.toStringTag,{value:"Module"}));exports.MAIN_WINDOW=t.MAIN_WINDOW;exports.SLICE_NAME=t.SLICE_NAME;exports.ZERO_SLICE_STATE=t.ZERO_SLICE_STATE;exports.closeWindow=t.closeWindow;exports.completeProcess=t.completeProcess;exports.createWindow=t.createWindow;exports.focusWindow=t.focusWindow;exports.reducer=t.reducer;exports.registerProcess=t.registerProcess;exports.reloadWindow=t.reloadWindow;exports.setWindowAlwaysOnTop=t.setWindowAlwaysOnTop;exports.setWindowDecorations=t.setWindowDecorations;exports.setWindowFullscreen=t.setWindowFullscreen;exports.setWindowMaxSize=t.setWindowMaxSize;exports.setWindowMaximized=t.setWindowMaximized;exports.setWindowMinSize=t.setWindowMinSize;exports.setWindowMinimized=t.setWindowMinimized;exports.setWindowPosition=t.setWindowPosition;exports.setWindowProps=t.setWindowProps;exports.setWindowResizable=t.setWindowResizable;exports.setWindowSize=t.setWindowSize;exports.setWindowSkipTaskbar=t.setWindowSkipTaskbar;exports.setWindowStage=t.setWindowStage;exports.setWindowTitle=t.setWindowTitle;exports.setWindowVisible=t.setWindowVisible;exports.windowPropsZ=t.windowPropsZ;exports.selectSliceState=f.selectSliceState;exports.selectWindow=f.selectWindow;exports.selectWindowAttribute=f.selectWindowAttribute;exports.selectWindowKey=f.selectWindowKey;exports.selectWindowLabel=f.selectWindowLabel;exports.selectWindows=f.selectWindows;exports.Drift=x;exports.configureStore=W;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { configureStore as
|
|
2
|
-
import { M as
|
|
3
|
-
import { s as
|
|
4
|
-
const
|
|
5
|
-
var
|
|
1
|
+
import { configureStore as j } from "@reduxjs/toolkit";
|
|
2
|
+
import { M as w, g, l as d, a as T, r as E, _ as p, G as F, I as N, b as I, i as V, c as $, s as U, d as Q, e as Z, f as C, h as q, S as M, Z as K, j as X, k as B, m as G, n as Y, o as H, p as J, q as x, t as W, u as ee, v as se, w as ie, x as te, y as ae, z as oe, A as ne, B as le, C as re, D as ce, E as ue, F as fe } from "./state-B8DVhsB5.js";
|
|
3
|
+
import { s as de, a as we, b as he, c as pe, d as ye, e as _e } from "./selectors-DwAh3Dt_.js";
|
|
4
|
+
const be = new Error("request for lock canceled");
|
|
5
|
+
var me = function(i, e, s, t) {
|
|
6
6
|
function a(o) {
|
|
7
7
|
return o instanceof s ? o : new s(function(l) {
|
|
8
8
|
l(o);
|
|
@@ -29,8 +29,8 @@ var ze = function(i, e, s, t) {
|
|
|
29
29
|
u((t = t.apply(i, e || [])).next());
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
-
class
|
|
33
|
-
constructor(e, s =
|
|
32
|
+
class ze {
|
|
33
|
+
constructor(e, s = be) {
|
|
34
34
|
this._value = e, this._cancelError = s, this._queue = [], this._weightedWaiters = [];
|
|
35
35
|
}
|
|
36
36
|
acquire(e = 1, s = 0) {
|
|
@@ -42,7 +42,7 @@ class Se {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
runExclusive(e) {
|
|
45
|
-
return
|
|
45
|
+
return me(this, arguments, void 0, function* (s, t = 1, a = 0) {
|
|
46
46
|
const [o, l] = yield this.acquire(t, a);
|
|
47
47
|
try {
|
|
48
48
|
return yield s(o);
|
|
@@ -55,7 +55,7 @@ class Se {
|
|
|
55
55
|
if (e <= 0)
|
|
56
56
|
throw new Error(`invalid weight ${e}: must be positive`);
|
|
57
57
|
return this._couldLockImmediately(e, s) ? Promise.resolve() : new Promise((t) => {
|
|
58
|
-
this._weightedWaiters[e - 1] || (this._weightedWaiters[e - 1] = []),
|
|
58
|
+
this._weightedWaiters[e - 1] || (this._weightedWaiters[e - 1] = []), Se(this._weightedWaiters[e - 1], { resolve: t, priority: s });
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
isLocked() {
|
|
@@ -110,7 +110,7 @@ class Se {
|
|
|
110
110
|
return (this._queue.length === 0 || this._queue[0].priority < s) && e <= this._value;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Se(i, e) {
|
|
114
114
|
const s = O(i, (t) => e.priority <= t.priority);
|
|
115
115
|
i.splice(s + 1, 0, e);
|
|
116
116
|
}
|
|
@@ -120,7 +120,7 @@ function O(i, e) {
|
|
|
120
120
|
return s;
|
|
121
121
|
return -1;
|
|
122
122
|
}
|
|
123
|
-
var
|
|
123
|
+
var ke = function(i, e, s, t) {
|
|
124
124
|
function a(o) {
|
|
125
125
|
return o instanceof s ? o : new s(function(l) {
|
|
126
126
|
l(o);
|
|
@@ -147,12 +147,12 @@ var ve = function(i, e, s, t) {
|
|
|
147
147
|
u((t = t.apply(i, e || [])).next());
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
|
-
class
|
|
150
|
+
class ve {
|
|
151
151
|
constructor(e) {
|
|
152
|
-
this._semaphore = new
|
|
152
|
+
this._semaphore = new ze(1, e);
|
|
153
153
|
}
|
|
154
154
|
acquire() {
|
|
155
|
-
return
|
|
155
|
+
return ke(this, arguments, void 0, function* (e = 0) {
|
|
156
156
|
const [, s] = yield this._semaphore.acquire(1, e);
|
|
157
157
|
return s;
|
|
158
158
|
});
|
|
@@ -173,7 +173,7 @@ class Te {
|
|
|
173
173
|
return this._semaphore.cancel();
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
const
|
|
176
|
+
const ge = (i) => [...new Set(i)], Te = (i, e, s = !0) => {
|
|
177
177
|
const t = /* @__PURE__ */ new Map();
|
|
178
178
|
return i.forEach((a) => {
|
|
179
179
|
const o = e(a);
|
|
@@ -183,26 +183,26 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
183
183
|
}
|
|
184
184
|
t.set(o, a);
|
|
185
185
|
}), Array.from(t.values());
|
|
186
|
-
},
|
|
186
|
+
}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
187
187
|
__proto__: null,
|
|
188
|
-
by:
|
|
189
|
-
unique:
|
|
190
|
-
}, Symbol.toStringTag, { value: "Module" })), L = "DA@", A = "://",
|
|
188
|
+
by: Te,
|
|
189
|
+
unique: ge
|
|
190
|
+
}, Symbol.toStringTag, { value: "Module" })), L = "DA@", A = "://", Ie = (i, e) => L.concat(e, A, i), Ce = (i) => {
|
|
191
191
|
const [e, s] = i.split(A);
|
|
192
192
|
if (s == null) return [i, ""];
|
|
193
193
|
const [, t] = e.split(L);
|
|
194
194
|
return [s, t];
|
|
195
195
|
}, z = (i, e) => ({
|
|
196
196
|
...i,
|
|
197
|
-
type:
|
|
198
|
-
}),
|
|
199
|
-
const [e, s] =
|
|
197
|
+
type: Ie(i.type, e)
|
|
198
|
+
}), qe = (i) => {
|
|
199
|
+
const [e, s] = Ce(i.type);
|
|
200
200
|
return {
|
|
201
201
|
emitted: s != null && s.length > 0,
|
|
202
202
|
emitter: s,
|
|
203
203
|
action: { ...i, type: e }
|
|
204
204
|
};
|
|
205
|
-
},
|
|
205
|
+
}, Me = (i) => {
|
|
206
206
|
const {
|
|
207
207
|
centerCount: e,
|
|
208
208
|
processCount: s,
|
|
@@ -215,22 +215,22 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
215
215
|
...u
|
|
216
216
|
} = i;
|
|
217
217
|
return u;
|
|
218
|
-
},
|
|
218
|
+
}, Oe = async (i, e, s, t) => {
|
|
219
219
|
const a = (await s.listLabels()).filter(
|
|
220
|
-
(r) => r !==
|
|
221
|
-
), o = Object.keys(i.windows).filter((r) => r !==
|
|
222
|
-
|
|
223
|
-
const l =
|
|
220
|
+
(r) => r !== w
|
|
221
|
+
), o = Object.keys(i.windows).filter((r) => r !== w);
|
|
222
|
+
g(t, "syncInitial"), d(t, "existing windows in runtime", a.sort()), d(t, "non-main windows in state", o.sort()), T(t);
|
|
223
|
+
const l = Ee.unique([...a, ...o]);
|
|
224
224
|
for (const r of l)
|
|
225
225
|
!a.includes(r) && s.isMain() ? (d(t, "state window not in runtime, creating", r), await D(s, r, i.windows[r], t)) : o.includes(r) || (d(t, "runtime window not in state, closing", r), await y(s, r, t));
|
|
226
226
|
const n = s.label(), c = i.windows[n];
|
|
227
227
|
if (c == null) return;
|
|
228
|
-
const u = { ...
|
|
228
|
+
const u = { ...N, key: n };
|
|
229
229
|
await R(u, c, s, t), e(
|
|
230
|
-
|
|
230
|
+
E({ label: s.label(), ...await s.getProps() })
|
|
231
231
|
);
|
|
232
|
-
},
|
|
233
|
-
d(t, "sync", i, e), s.isMain() && await
|
|
232
|
+
}, Le = async (i, e, s, t) => {
|
|
233
|
+
d(t, "sync", i, e), s.isMain() && await Ae(i, e, s, t);
|
|
234
234
|
const a = i.windows[s.label()], o = e.windows[s.label()];
|
|
235
235
|
a == null || o == null || await R(a, o, s, t);
|
|
236
236
|
}, R = async (i, e, s, t) => {
|
|
@@ -246,7 +246,7 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
246
246
|
async () => {
|
|
247
247
|
if (await s.setVisible(e.visible), e.visible === !1) return;
|
|
248
248
|
let c = e.position;
|
|
249
|
-
c ?? (c = (await s.getProps()).position), s.setPosition(
|
|
249
|
+
c ?? (c = (await s.getProps()).position), await s.setPosition(F.translate(c, { x: 1, y: 1 })), await s.setPosition(c);
|
|
250
250
|
}
|
|
251
251
|
]);
|
|
252
252
|
if (o && l && n(), e.skipTaskbar != null && e.skipTaskbar !== i.skipTaskbar && a.push([
|
|
@@ -309,61 +309,61 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
309
309
|
{ prev: i.alwaysOnTop, next: e.alwaysOnTop },
|
|
310
310
|
async () => await s.setAlwaysOnTop(e.alwaysOnTop)
|
|
311
311
|
]), o && !l && n(), a.length !== 0) {
|
|
312
|
-
|
|
312
|
+
g(t, `syncCurrent, label: ${s.label()}, key: ${e.key}`);
|
|
313
313
|
for (const [c, { prev: u, next: r }] of a) d(t, c, u, "->", r);
|
|
314
|
-
|
|
314
|
+
T(t);
|
|
315
315
|
for (const [, , c] of a) await c();
|
|
316
316
|
}
|
|
317
|
-
},
|
|
317
|
+
}, Ae = async (i, e, s, t) => {
|
|
318
318
|
const a = Object.keys(i.windows).filter((n) => !(n in e.windows)), o = Object.keys(e.windows).filter((n) => !(n in i.windows)), l = s.isMain();
|
|
319
319
|
if (l && a.length > 0)
|
|
320
320
|
for (const n of a)
|
|
321
|
-
d(t, "syncMain", "closing", n), n ===
|
|
322
|
-
Object.keys(e.windows).filter((c) => c !==
|
|
321
|
+
d(t, "syncMain", "closing", n), n === w && await Promise.all(
|
|
322
|
+
Object.keys(e.windows).filter((c) => c !== w).map(async (c) => await y(s, c, t))
|
|
323
323
|
), await y(s, n, t);
|
|
324
324
|
if (l && o.length > 0)
|
|
325
325
|
for (const n of o)
|
|
326
326
|
await D(s, n, e.windows[n], t);
|
|
327
|
-
}, D = async (i, e, s, t) => (d(t, "createWindow", s), await i.create(e,
|
|
327
|
+
}, D = async (i, e, s, t) => (d(t, "createWindow", s), await i.create(e, Me(s))), y = async (i, e, s) => (d(s, "closeWindow", e), await i.close(e)), S = "[drift] - unexpected undefined action", k = "[drift] - unexpected undefined action type", _ = (i) => {
|
|
328
328
|
if (i.emitted ?? (i.emitted = !1), i.action == null)
|
|
329
329
|
throw console.warn(S, i), new Error(S);
|
|
330
330
|
if (i.action.type == null || i.action.type.length === 0)
|
|
331
331
|
throw console.warn(k, i), new Error(k);
|
|
332
|
-
},
|
|
333
|
-
let { action:
|
|
334
|
-
const
|
|
335
|
-
_({ action:
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
338
|
-
action:
|
|
339
|
-
emitted:
|
|
340
|
-
emitter:
|
|
341
|
-
host:
|
|
342
|
-
}),
|
|
343
|
-
const
|
|
344
|
-
let
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
332
|
+
}, Re = new ve(), De = [E.type, I.type], Pe = (i, e = !1) => (s) => (t) => (a) => {
|
|
333
|
+
let { action: o, emitted: l, emitter: n } = qe(a);
|
|
334
|
+
const c = i.label();
|
|
335
|
+
_({ action: a, emitted: l, emitter: n });
|
|
336
|
+
const u = V(o.type);
|
|
337
|
+
if (u && d(e, "[drift] - middleware", {
|
|
338
|
+
action: o,
|
|
339
|
+
emitted: l,
|
|
340
|
+
emitter: n,
|
|
341
|
+
host: c
|
|
342
|
+
}), n === i.label()) return;
|
|
343
|
+
const r = u && !De.includes(o.type);
|
|
344
|
+
let f = null;
|
|
345
|
+
u && (f = s.getState().drift, o = $(
|
|
346
|
+
o,
|
|
347
|
+
f
|
|
348
348
|
));
|
|
349
|
-
const
|
|
350
|
-
return
|
|
349
|
+
const h = t(o), b = r ? s.getState().drift : null, P = U(l, o.type);
|
|
350
|
+
return Re.runExclusive(async () => {
|
|
351
351
|
try {
|
|
352
|
-
|
|
352
|
+
f !== null && b !== null && await Le(f, b, i, e), P && await i.emit({ action: o });
|
|
353
353
|
} catch (m) {
|
|
354
354
|
d(e, "[drift] - ERROR", {
|
|
355
355
|
error: m.message,
|
|
356
|
-
action:
|
|
357
|
-
emitted:
|
|
358
|
-
emitter:
|
|
359
|
-
host:
|
|
360
|
-
}),
|
|
356
|
+
action: o,
|
|
357
|
+
emitted: l,
|
|
358
|
+
emitter: n,
|
|
359
|
+
host: c
|
|
360
|
+
}), s.dispatch(Q({ key: c, message: m.message }));
|
|
361
361
|
}
|
|
362
|
-
}),
|
|
363
|
-
},
|
|
362
|
+
}), h;
|
|
363
|
+
}, je = (i, e, s = !1) => (t) => {
|
|
364
364
|
const a = i != null ? typeof i == "function" ? i(t) : i : t();
|
|
365
|
-
return [
|
|
366
|
-
},
|
|
365
|
+
return [Pe(e, s), ...a];
|
|
366
|
+
}, Fe = async ({
|
|
367
367
|
runtime: i,
|
|
368
368
|
preloadedState: e,
|
|
369
369
|
middleware: s,
|
|
@@ -374,22 +374,22 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
374
374
|
}) => {
|
|
375
375
|
await i.configure();
|
|
376
376
|
let n;
|
|
377
|
-
n =
|
|
377
|
+
n = j({
|
|
378
378
|
...l,
|
|
379
|
-
preloadedState: await
|
|
379
|
+
preloadedState: await Ne(
|
|
380
380
|
t,
|
|
381
381
|
i,
|
|
382
382
|
() => n,
|
|
383
383
|
o,
|
|
384
384
|
e
|
|
385
385
|
),
|
|
386
|
-
middleware:
|
|
387
|
-
}), await
|
|
386
|
+
middleware: je(s, i, t)
|
|
387
|
+
}), await Oe(n.getState().drift, n.dispatch, i, t);
|
|
388
388
|
const c = i.label();
|
|
389
389
|
return n.dispatch(
|
|
390
|
-
|
|
390
|
+
Z({ enablePrerender: a, defaultWindowProps: o, debug: t, label: c })
|
|
391
391
|
), n.dispatch(C({ stage: "created" })), i.onCloseRequested(() => n == null ? void 0 : n.dispatch(q({}))), n;
|
|
392
|
-
},
|
|
392
|
+
}, Ne = async (i, e, s, t, a) => e.isMain() ? (await e.subscribe(({ action: l, emitter: n, sendState: c }) => {
|
|
393
393
|
const u = s();
|
|
394
394
|
if (u == null) return;
|
|
395
395
|
if (l != null) {
|
|
@@ -402,90 +402,90 @@ const Ee = (i) => [...new Set(i)], ge = (i, e, s = !0) => {
|
|
|
402
402
|
(async () => {
|
|
403
403
|
try {
|
|
404
404
|
await e.subscribe(({ action: u, emitter: r, state: f }) => {
|
|
405
|
-
const
|
|
406
|
-
if (
|
|
405
|
+
const h = s();
|
|
406
|
+
if (h == null)
|
|
407
407
|
return f != null ? l(f) : void 0;
|
|
408
|
-
u != null && (_({ action: u, emitter: r }),
|
|
409
|
-
}), await e.emit({ sendState: !0 },
|
|
408
|
+
u != null && (_({ action: u, emitter: r }), h.dispatch(z(u, r)));
|
|
409
|
+
}), await e.emit({ sendState: !0 }, w);
|
|
410
410
|
} catch (u) {
|
|
411
411
|
n(u);
|
|
412
412
|
}
|
|
413
413
|
})();
|
|
414
|
-
}),
|
|
414
|
+
}), Ve = Fe, v = (i, e, s) => {
|
|
415
415
|
if (s == null) return s;
|
|
416
416
|
const t = s[M];
|
|
417
417
|
return t.config.debug = e ?? t.config.debug, t.windows = Object.fromEntries(
|
|
418
418
|
Object.entries(t.windows).filter(([, a]) => a.reserved).map(([a, o]) => ((i == null ? void 0 : i.visible) != null && (o.visible = i.visible), o.focusCount = 0, o.centerCount = 0, o.processCount = 0, [a, o]))
|
|
419
419
|
), s;
|
|
420
|
-
},
|
|
420
|
+
}, Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
421
421
|
__proto__: null,
|
|
422
|
-
MAIN_WINDOW:
|
|
422
|
+
MAIN_WINDOW: w,
|
|
423
423
|
SLICE_NAME: M,
|
|
424
|
-
ZERO_SLICE_STATE:
|
|
424
|
+
ZERO_SLICE_STATE: K,
|
|
425
425
|
closeWindow: q,
|
|
426
|
-
completeProcess:
|
|
427
|
-
configureStore:
|
|
428
|
-
createWindow:
|
|
429
|
-
focusWindow:
|
|
430
|
-
reducer:
|
|
431
|
-
registerProcess:
|
|
426
|
+
completeProcess: X,
|
|
427
|
+
configureStore: Ve,
|
|
428
|
+
createWindow: B,
|
|
429
|
+
focusWindow: G,
|
|
430
|
+
reducer: Y,
|
|
431
|
+
registerProcess: H,
|
|
432
432
|
reloadWindow: I,
|
|
433
|
-
selectSliceState:
|
|
434
|
-
selectWindow:
|
|
435
|
-
selectWindowAttribute:
|
|
436
|
-
selectWindowKey:
|
|
437
|
-
selectWindowLabel:
|
|
438
|
-
selectWindows:
|
|
439
|
-
setWindowAlwaysOnTop:
|
|
440
|
-
setWindowDecorations:
|
|
441
|
-
setWindowFullscreen:
|
|
442
|
-
setWindowMaxSize:
|
|
443
|
-
setWindowMaximized:
|
|
444
|
-
setWindowMinSize:
|
|
445
|
-
setWindowMinimized:
|
|
446
|
-
setWindowPosition:
|
|
447
|
-
setWindowProps:
|
|
448
|
-
setWindowResizable:
|
|
449
|
-
setWindowSize:
|
|
450
|
-
setWindowSkipTaskbar:
|
|
433
|
+
selectSliceState: de,
|
|
434
|
+
selectWindow: we,
|
|
435
|
+
selectWindowAttribute: he,
|
|
436
|
+
selectWindowKey: pe,
|
|
437
|
+
selectWindowLabel: ye,
|
|
438
|
+
selectWindows: _e,
|
|
439
|
+
setWindowAlwaysOnTop: J,
|
|
440
|
+
setWindowDecorations: x,
|
|
441
|
+
setWindowFullscreen: W,
|
|
442
|
+
setWindowMaxSize: ee,
|
|
443
|
+
setWindowMaximized: se,
|
|
444
|
+
setWindowMinSize: ie,
|
|
445
|
+
setWindowMinimized: te,
|
|
446
|
+
setWindowPosition: ae,
|
|
447
|
+
setWindowProps: oe,
|
|
448
|
+
setWindowResizable: ne,
|
|
449
|
+
setWindowSize: le,
|
|
450
|
+
setWindowSkipTaskbar: re,
|
|
451
451
|
setWindowStage: C,
|
|
452
|
-
setWindowTitle:
|
|
453
|
-
setWindowVisible:
|
|
454
|
-
windowPropsZ:
|
|
452
|
+
setWindowTitle: ce,
|
|
453
|
+
setWindowVisible: ue,
|
|
454
|
+
windowPropsZ: fe
|
|
455
455
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
456
456
|
export {
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
Ze as Drift,
|
|
458
|
+
w as MAIN_WINDOW,
|
|
459
459
|
M as SLICE_NAME,
|
|
460
|
-
|
|
460
|
+
K as ZERO_SLICE_STATE,
|
|
461
461
|
q as closeWindow,
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
462
|
+
X as completeProcess,
|
|
463
|
+
Ve as configureStore,
|
|
464
|
+
B as createWindow,
|
|
465
|
+
G as focusWindow,
|
|
466
|
+
Y as reducer,
|
|
467
|
+
H as registerProcess,
|
|
468
468
|
I as reloadWindow,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
469
|
+
de as selectSliceState,
|
|
470
|
+
we as selectWindow,
|
|
471
|
+
he as selectWindowAttribute,
|
|
472
|
+
pe as selectWindowKey,
|
|
473
|
+
ye as selectWindowLabel,
|
|
474
|
+
_e as selectWindows,
|
|
475
|
+
J as setWindowAlwaysOnTop,
|
|
476
|
+
x as setWindowDecorations,
|
|
477
|
+
W as setWindowFullscreen,
|
|
478
|
+
ee as setWindowMaxSize,
|
|
479
|
+
se as setWindowMaximized,
|
|
480
|
+
ie as setWindowMinSize,
|
|
481
|
+
te as setWindowMinimized,
|
|
482
|
+
ae as setWindowPosition,
|
|
483
|
+
oe as setWindowProps,
|
|
484
|
+
ne as setWindowResizable,
|
|
485
|
+
le as setWindowSize,
|
|
486
|
+
re as setWindowSkipTaskbar,
|
|
487
487
|
C as setWindowStage,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
ce as setWindowTitle,
|
|
489
|
+
ue as setWindowVisible,
|
|
490
|
+
fe as windowPropsZ
|
|
491
491
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),
|
|
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-CYHEOjO4.cjs"),i=require("./state-Nl_4DIvw.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;
|