Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@team-chatt/window-manager

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@team-chatt/window-manager - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

dist/close.15db31ae.svg

1289

dist/main.js

@@ -1,12 +0,1277 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"));else if("function"==typeof define&&define.amd)define(["react","prop-types"],t);else{var n="object"==typeof exports?t(require("react"),require("prop-types")):t(e.React,e.PropTypes);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(function(e,t){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=17)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){var o;
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(this&&this[o]||o);else if(Array.isArray(o))e.push(r.apply(this,o));else if("object"===i)for(var a in o)n.call(o,a)&&o[a]&&e.push(this&&this[a]||a)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()},function(e,t,n){e.exports={"file-grid":"file-grid--1BGOO","file-grid--row":"file-grid--row--Da16I","file-grid--column":"file-grid--column--2Otzt"}},function(e,t,n){e.exports={"file-grid-item":"file-grid-item--_0fiq","file-grid-item_inner":"file-grid-item_inner--1MCIk","file-grid-item_icon":"file-grid-item_icon--1GOHW","file-grid-item_label":"file-grid-item_label--3FSa2","file-grid-item--light":"file-grid-item--light--e24lp","file-grid-item--dark":"file-grid-item--dark--3xDRl"}},function(e,t,n){e.exports={desktop:"desktop--2U5pg",desktop_items:"desktop_items--3tDWi",desktop_background:"desktop_background--11u5_"}},function(e,t,n){e.exports={taskbar:"taskbar--Ap6Iu"}},function(e,t,n){e.exports={"taskbar-button":"taskbar-button--MzJmj","taskbar-button--borderless":"taskbar-button--borderless--f8oH7","taskbar-button--active":"taskbar-button--active--2SrnT"}},function(e,t,n){e.exports={"window-manager":"window-manager--KrBjA","window-manager_layer-group":"window-manager_layer-group--Yt68A","window-manager_layer":"window-manager_layer--YHnOX"}},function(e,t,n){var o;
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var a=r.apply(null,o);a&&e.push(a)}else if("object"===i)for(var s in o)n.call(o,s)&&o[s]&&e.push(s)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()},function(e,t,n){e.exports={bsod:"bsod--1H_0P",bsod_column:"bsod_column--4A5cn"}},function(e,t,n){e.exports={window:"window--13ujq","window--focused":"window--focused--2-nSM",window_header:"window_header--1A5sM",window_title:"window_title--DWigu",window_buttons:"window_buttons--2k5ol",window_body:"window_body--2TbKa","window-button":"window-button--2A-WI","window-button--close":"window-button--close--X4miR"}},function(e,t){e.exports="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiICB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC00LDEyKSI+CiAgICAgIDxwYXRoIGZpbGw9IiNmZmZmZmYiIGQ9Ik0yMCwxNEg0VjEwSDIwIiAvPgogICA8L2c+Cjwvc3ZnPg=="},function(e,t){e.exports="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiICB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgIDxwYXRoIGZpbGw9IiNmZmZmZmYiIGQ9Ik0xOSw2LjQxTDE3LjU5LDVMMTIsMTAuNTlMNi40MSw1TDUsNi40MUwxMC41OSwxMkw1LDE3LjU5TDYuNDEsMTlMMTIsMTMuNDFMMTcuNTksMTlMMTksMTcuNTlMMTMuNDEsMTJMMTksNi40MVoiIC8+Cjwvc3ZnPg=="},function(e,t,n){e.exports={outline:"outline--7Bks2","outline--animate":"outline--animate--PlkLC"}},function(e,t,n){e.exports={"window-frame":"window-frame--1e6t8","window-frame_shadow":"window-frame_shadow--3vWl4","appear--enter":"appear--enter--OGbDx","appear--enter-active":"appear--enter-active--Z7uiF","appear--enter-done":"appear--enter-done--2Vnuw"}},function(e,t,n){e.exports={"file-grid-item":"file-grid-item--AGvUH","file-grid-item_origin":"file-grid-item_origin--2YABG"}},function(e,t,n){"use strict";n.r(t),n.d(t,"WindowManager",(function(){return Ce})),n.d(t,"WMWindow",(function(){return je})),n.d(t,"WMTaskbarButton",(function(){return xe})),n.d(t,"WMFileGridItem",(function(){return Re})),n.d(t,"useWindowState",(function(){return Ue})),n.d(t,"useWMWindowState",(function(){return Ue})),n.d(t,"useWMWindowElement",(function(){return ke})),n.d(t,"WMFileGrid",(function(){return p})),n.d(t,"WMAnimationContainer",(function(){return Z})),n.d(t,"BSOD",(function(){return J})),n.d(t,"BSODErrorBoundary",(function(){return X}));var o=n(0),r=n.n(o),i=n(1),a=n.n(i),s=n(3),c=n.n(s),u=n(2),d=n.n(u);const l=d.a.bind(c.a),m=Object(o.createContext)(),p=({children:e,layout:t,color:n})=>r.a.createElement(m.Provider,{value:n},r.a.createElement("div",{className:l("file-grid",{"file-grid--row":"row"===t,"file-grid--column":"column"===t})},e));p.propTypes={children:a.a.node,layout:a.a.oneOf(["row","column"]),color:a.a.oneOf(["light","dark"])},p.defaultProps={layout:"row",color:"dark"};var w=n(4),b=n.n(w);const f=d.a.bind(b.a),g=({onDoubleClick:e,icon:t,label:n})=>{const i=Object(o.useContext)(m);return r.a.createElement("button",{className:f("file-grid-item",{"file-grid-item--light":"light"===i,"file-grid-item--dark":"dark"===i}),onDoubleClick:e,onKeyDown:t=>{"Enter"===t.key&&e(t)}},r.a.createElement("div",{className:f("file-grid-item_inner")},r.a.createElement("img",{className:f("file-grid-item_icon"),src:t,draggable:"false"}),r.a.createElement("span",{className:f("file-grid-item_label")},n)))};g.propTypes={onDoubleClick:a.a.func,icon:a.a.string,label:a.a.node};var v=n(5),y=n.n(v);const E=d.a.bind(y.a),h=({background:e,children:t})=>r.a.createElement("div",{className:E("desktop")},r.a.createElement("div",{className:E("desktop_background"),style:{backgroundImage:`url(${e})`}}),t);var M=n(6),k=n.n(M);const j=d.a.bind(k.a),x=({children:e})=>r.a.createElement("div",{className:j("taskbar")},e);var O=n(7),C=n.n(O);const D=d.a.bind(C.a),I=({name:e,active:t,borderless:n,children:o,disabled:i,onClick:a,onMouseDown:s,onMouseUp:c,onMouseLeave:u,onKeyDown:d,onKeyUp:l,onFocus:m,onBlur:p})=>r.a.createElement("button",{name:e,className:D("taskbar-button",{"taskbar-button--active":t,"taskbar-button--borderless":n}),disabled:i,onClick:a,onMouseDown:s,onMouseUp:c,onMouseLeave:u,onKeyDown:d,onKeyUp:l,onFocus:m,onBlur:p},o);I.propTypes={name:a.a.string,active:a.a.bool,borderless:a.a.bool,children:a.a.node.isRequired,disabled:a.a.bool,onClick:a.a.func,onMouseDown:a.a.func,onMouseUp:a.a.func,onMouseLeave:a.a.func,onKeyDown:a.a.func,onKeyUp:a.a.func,onFocus:a.a.func,onBlur:a.a.func};var N=n(8),_=n.n(N);const R=d.a.bind(_.a),L=({background:e,windowItems:t,desktopItems:n,taskbarItems:o,taskbarExtras:i})=>r.a.createElement("div",{className:R("window-manager")},r.a.createElement("div",{className:R("window-manager_layer-group")},r.a.createElement("div",{className:R("window-manager_layer")},r.a.createElement(h,{background:e},r.a.createElement(p,{layout:"column",color:"light"},n))),r.a.createElement("div",{className:R("window-manager_layer")},t)),r.a.createElement(x,null,o,i));class S{constructor(){this._promise=new Promise(e=>{this._resolve=e})}static create(){return new S}resolve(...e){this._resolve(...e)}then(...e){return this._promise.then(...e)}catch(...e){return this._promise.catch(...e)}}var T=S.create;var W=()=>new Promise(e=>window.requestAnimationFrame(e));class A{constructor(){this.map=new Map}ensureKey(e){return this.map.has(e)||this.map.set(e,T()),this.map.get(e)}async get(e){return Promise.race([this.ensureKey(e),W().then(()=>!1)])}async set(e,t){this.ensureKey(e).resolve(t),await W(),this.map.delete(e)}}class z{constructor(){this.inMap=new A,this.outMap=new A}static create(){return new z}async in(e,t){return this.inMap.set(e,t),this.outMap.get(e)}async out(e,t){return this.outMap.set(e,t),this.inMap.get(e)}}const F=z.create,P=r.a.createContext(),Z=({children:e})=>{const[t]=Object(o.useState)(F);return r.a.createElement(P.Provider,{value:t},e)},B=(e,t,n,r)=>{Object(o.useLayoutEffect)(()=>t?n(e.current):r(e.current),[t])};var H=n(9),G=n.n(H);var U=e=>(...t)=>{const n=e(...t);let o=!1;return(async()=>{for await(const e of n)if(o)break})(),()=>{o=!0}};const K=e=>{const[t,n]=Object(o.useState)([]);var r;return[t,U((r={setup:()=>n([e]),run:()=>n([e,e+"-active"]),teardown:()=>n([e,e+"-done"])},async function*(e){r.setup(),yield await W(),r.run(),yield await new Promise(t=>e.addEventListener("transitionend",t,{once:!0})),r.teardown()}))]},V=(e,t,n)=>{const[o,r]=K("enter"),[i,a]=K("exit");return B(e,t,r,a),((e,t)=>G()(e.map(e=>t[e])))([...o,...i],n)};var Y=n(10),q=n.n(Y);const Q=d.a.bind(q.a),J=({error:e})=>r.a.createElement("div",{className:Q("bsod")},r.a.createElement("div",{className:Q("bsod_column")},r.a.createElement("h2",null,"Error"),r.a.createElement("pre",null,"An exception has occurred and the application cannot continue"),r.a.createElement("pre",null,e&&e.stack)));class X extends o.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){const{children:e}=this.props,{error:t}=this.state;return t?r.a.createElement(J,{error:t}):e}}const $={left:0,top:0},ee=()=>{};var te=n(11),ne=n.n(te),oe=n(12),re=n.n(oe),ie=n(13),ae=n.n(ie);const se=d.a.bind(ne.a),ce=({title:e,children:t,className:n,isFocused:i,onMinimize:a,onClose:s,onDragStart:c,onDrag:u,onDragEnd:d})=>{const l=(({onDragStart:e=ee,onDrag:t=ee,onDragEnd:n=ee})=>{const[r,i]=Object(o.useState)($),[a,s]=Object(o.useState)(!1),c=Object(o.useCallback)(({clientX:t,clientY:n,button:o})=>{2!==o&&(s(!0),i({left:t,top:n}),e())},[]),u=Object(o.useCallback)(({clientX:e,clientY:n})=>{const o={left:e-r.left,top:n-r.top};t(o)},[r,t]),d=Object(o.useCallback)(()=>{s(!1),n()},[n]);return Object(o.useEffect)(()=>{if(a)return window.addEventListener("mousemove",u),window.addEventListener("mouseup",d),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",d)}},[a,u,d]),c})({onDragStart:c,onDrag:u,onDragEnd:d});return r.a.createElement("div",{className:se(n,"window",{"window--focused":i})},r.a.createElement("div",{className:se("window_header"),onMouseDown:l},r.a.createElement("span",{className:se("window_title")},e),r.a.createElement("div",{className:se("window_buttons")},r.a.createElement("button",{onClick:a,className:se("window-button","window-button--minimize"),name:"minimize window"},r.a.createElement("img",{src:re.a,alt:""})),r.a.createElement("button",{onClick:s,className:se("window-button","window-button--close"),name:"close window"},r.a.createElement("img",{src:ae.a,alt:""})))),r.a.createElement("div",{className:se("window_body")},t))};var ue=n(14),de=n.n(ue);const le=d.a.bind(de.a),me=Object(o.forwardRef)(({animate:e,rect:t},n)=>{const o={top:t.top,left:t.left,bottom:t.bottom,right:t.right},i=le("outline",{"outline--animate":e});return r.a.createElement("div",{ref:n,className:i,style:o})});me.propTypes={animate:a.a.bool,rect:a.a.shape({top:a.a.number.isRequired,left:a.a.number.isRequired,bottom:a.a.number.isRequired,right:a.a.number.isRequired}).isRequired};const pe={left:0,top:0,right:0,bottom:0},we=(e,t)=>({top:e.top-t.top,left:e.left-t.left,bottom:-(e.bottom-t.bottom),right:-(e.right-t.right)}),be=async function*(){},fe=(e,t)=>{const[n,r]=Object(o.useState)(pe),[i,a]=Object(o.useState)(!1);return((e,t,n,r,i)=>{const a=Object(o.useContext)(P);B(t,n,U((async function*(){const n=await a.in(e,t.current);yield,n&&(yield*r(n,t.current))})),U((async function*(){const n=await a.out(e,t.current);yield,n&&(yield*i(t.current,n))}))),Object(o.useEffect)(()=>()=>{a.out(e,(e=>{const t=e.getBoundingClientRect();return{getBoundingClientRect:()=>t}})(t.current))},[])})(e,t,!0,(e=>async function*(t,n){e.setup(t,n),await W(),yield,e.run(t,n),await new Promise(e=>n.addEventListener("transitionend",e)),yield,e.teardown(t,n)})({setup:(e,t)=>{r(((e,t)=>{const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return we(n,o)})(e,t)),a(!1)},run:()=>{r(pe),a(!0)},teardown:()=>{a(!1)}}),be),{rect:n,isAnimating:i}},ge=({id:e})=>{const t=Object(o.useRef)(),{isAnimating:n,rect:i}=fe(e,t);return r.a.createElement(me,{ref:t,rect:i,animate:n})};var ve=n(15),ye=n.n(ve);const Ee=d.a.bind(ye.a),he={enter:Ee("appear--enter"),"enter-active":Ee("appear--enter-active"),"enter-done":Ee("appear--enter-done")},Me=Object(o.createContext)(),ke=()=>Object(o.useContext)(Me),je=({id:e,title:t,children:n,order:i,position:a,dimensions:s,isFocused:c,onMinimize:u,onClose:d,onFocus:l,onBlur:m,onMove:p})=>{const w=Object(o.useRef)(),b=V(w,!0,he),f=Object(o.useRef)();((e,{isFocused:t,onFocus:n,onBlur:r})=>{const i=Object(o.useRef)();i.current=t,Object(o.useEffect)(()=>{t&&!e.current.contains(document.activeElement)&&e.current.focus({preventScroll:!0})},[t]),Object(o.useEffect)(()=>{const t=()=>{window.setTimeout(()=>{const t=e.current&&e.current.contains(document.activeElement)||e.current===document.activeElement,o=i.current;o&&!t&&r(),!o&&t&&n()},0)};return document.addEventListener("focusout",t),document.addEventListener("focusin",t),()=>{document.removeEventListener("focusout",t),document.removeEventListener("focusin",t)}},[])})(f,{isFocused:c,onFocus:l,onBlur:m});const{onDragStart:g,onDrag:v,onDragEnd:y}=((e,t)=>{const n=Object(o.useRef)(),r=Object(o.useRef)();n.current=e;const[i,a]=Object(o.useState)(!1);return{isDragging:i,onDragStart:Object(o.useCallback)(()=>{r.current=n.current,a(!0)},[]),onDrag:Object(o.useCallback)(e=>{const n={top:r.current.top+e.top,left:r.current.left+e.left};t(n)},[t]),onDragEnd:Object(o.useCallback)(()=>{a(!1)},[])}})(a,p),E={zIndex:i,...a,...s};return r.a.createElement(Me.Provider,{value:f},r.a.createElement("div",{className:Ee("window-frame"),style:E,ref:f,tabIndex:"0"},r.a.createElement(ce,{className:b,title:t,isFocused:c,onMinimize:u,onClose:d,onDragStart:g,onDrag:v,onDragEnd:y},n),r.a.createElement(ge,{id:e}),r.a.createElement("div",{ref:w,className:Ee("window-frame_shadow",b)})))},xe=({id:e,active:t,hasOutline:n,onClick:o,children:i})=>r.a.createElement(I,{active:t,onClick:o},i,n&&r.a.createElement(ge,{id:e})),Oe=Object(o.createContext)(),Ce=({background:e,windows:t,desktopItems:n,taskbarExtras:o})=>{const i=t.map(({id:e,title:t,content:n,state:o,actions:i})=>"open"===o.visibility&&r.a.createElement(je,{key:e,id:e,title:t,order:o.order,position:o.position,dimensions:o.dimensions,isFocused:o.isFocused,onMinimize:i.minimize,onClose:i.close,onFocus:i.focus,onBlur:i.blur,onMove:i.move},n)),a=t.map(({id:e,title:n,state:o,actions:i})=>"closed"!==o.visibility&&r.a.createElement(xe,{key:e,id:e,active:"open"===o.visibility&&o.isFocused,hasOutline:"minimized"===o.visibility,onClick:"open"===o.visibility&&o.order===t.length?i.minimize:i.open},n));return r.a.createElement(X,null,r.a.createElement(Z,null,r.a.createElement(Oe.Provider,{value:t},r.a.createElement(L,{background:e,desktopItems:n,windowItems:i,taskbarItems:a,taskbarExtras:o}))))};var De=n(16),Ie=n.n(De);const Ne=d.a.bind(Ie.a),_e={state:{}},Re=({icon:e,label:t,id:n,onDoubleClick:i})=>{const a="closed"===(Object(o.useContext)(Oe).find(e=>e.id===n)||_e).state.visibility;return r.a.createElement("div",{className:Ne("file-grid-item")},r.a.createElement(g,{icon:e,label:t,onDoubleClick:i}),r.a.createElement("div",{className:Ne("file-grid-item_origin")},a&&r.a.createElement(ge,{id:n})))},Le={get:e=>e,set:(e,t)=>t,name:"id"},Se=(e,t)=>({get:n=>t.get(e.get(n)),set:(n,o)=>{const r=e.get(n);return e.set(n,t.set(r,o))},name:`${e.name} ${t.name}`}),Te=(...e)=>{const t=e.map(e=>{return"number"==typeof e?{get:e=>e[n],set:(e,t)=>{const o=[...e];return o[n]=t,o},name:`[${n=e}]`}:{get:e=>e[t],set:(e,n)=>({...e,[t]:n}),name:"."+(t=e)};var t,n}).reduce(Se,Le);return o=void 0,{get:e=>{try{return n.get(e)}catch(e){return o}},set:(n=t).set,name:`safe(${n.name})`};var n,o},We=(e,t)=>n=>e.set(n,t(e.get(n)));var Ae=(e,t)=>n=>n===e?t:n<e&&n<t||n>e&&n>t?n:t>e?n-1:t<e?n+1:n;const ze=(e,t)=>Object.keys(e).map((e,n)=>{const o=Te(e);return We(o,o=>t(e,o,n))}).reduce((e,t)=>t(e),e),Fe=e=>{const t=Object.entries(e),[n]=t.filter(([,e])=>"open"===e.visibility).sort(([,e],[,t])=>e.order-t.order).pop()||[];return n},Pe=(e,t,n)=>({position:{top:50+50*n,left:200+100*n},visibility:"closed",...t,order:n+1}),Ze=e=>ze(e,Pe),Be=(e,t)=>t.type.startsWith("window.")?Ge(e,t):t.type.startsWith("top.")?He(e,t):e,He=(e,{type:t,id:n,window:o,newState:r})=>{const i=Te(n);switch(t){case"top.create":{const t=Object.keys(e).length,n=(e=>{const t=Fe(e)||-1,n=Te(t,"position").get(e);return n?{left:n.left+40,top:n.top+20}:{left:200,top:100}})(e),r=Pe(0,{position:n,...o},t);return i.set(e,r)}case"top.destroy":{const t={...e};return delete t[n],t}case"top.focusNext":{const t=Fe(e);return t?Te(t,"isFocused").set(e,!0):e}case"top.reset":return Ze(r)}},Ge=(e,{type:t,id:n,position:o})=>{const r=Te(n,"visibility"),i=Te(n,"position"),a=Te(n,"isFocused");switch(t){case"window.open":return r.set(e,"open");case"window.minimize":return r.set(e,"minimized");case"window.close":return r.set(e,"closed");case"window.focus":return a.set(e,!0);case"window.blur":return a.set(e,!1);case"window.move":return We(i,e=>({...e,...o}))(e);case"window.bringToFront":return((e,t)=>n=>{const o=We(Te("order"),Ae(e,t));return ze(n,(e,t)=>o(t))})(e[n].order,Object.keys(e).length)(e)}},Ue=e=>{const[t,n]=Object(o.useReducer)(Be,e,Ze),r=e=>({open:()=>{n({type:"window.open",id:e}),n({type:"window.bringToFront",id:e}),n({type:"window.focus",id:e})},focus:()=>{n({type:"window.bringToFront",id:e}),n({type:"window.focus",id:e})},close:()=>{n({type:"window.close",id:e}),n({type:"window.blur",id:e}),n({type:"top.focusNext"})},minimize:()=>{n({type:"window.minimize",id:e}),n({type:"top.focusNext"})},blur:()=>n({type:"window.blur",id:e}),move:t=>n({type:"window.move",id:e,position:t})}),i=(e,o)=>{void 0===t[e]&&n({type:"top.create",id:e,window:o})},a=Object.keys(t).length,s={createWindow:i,destroyWindow:e=>{void 0!==t[e]&&(n({type:"top.destroy",id:e}),n({type:"top.focusNext"}))},openWindow:async(e,n)=>{void 0===t[e]?(i(e,n),setTimeout(()=>{r(e).open()},0)):r(e).open()},closeWindow:e=>{void 0!==t[e]&&r(e).close()},reset:e=>{n({type:"top.reset",newState:e})},window:Object(o.useMemo)(()=>ze(t,r),[a])};return[t,s]}}])}));
//# sourceMappingURL=main.js.map
require("./main.css");
var $h2LML$react = require("react");
var $h2LML$classnamesbind = require("classnames/bind");
var $h2LML$classnames = require("classnames");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "WindowManager", () => $c258afc3093d5e8c$export$adf2d320ba0a3b0a);
$parcel$export(module.exports, "WMWindow", () => $e283ee4fda1ee4d6$export$43e5451677e635a1);
$parcel$export(module.exports, "WMTaskbarButton", () => $813cadf7f2d083c4$export$26c38373364bc34f);
$parcel$export(module.exports, "WMFileGridItem", () => $4c891e30bb3bb31c$export$a7ddab7342148340);
$parcel$export(module.exports, "useWindowState", () => $b90f838243d23e43$export$e90db8474c899249);
$parcel$export(module.exports, "useWMWindowState", () => $b90f838243d23e43$export$e90db8474c899249);
$parcel$export(module.exports, "useWMWindowElement", () => $e283ee4fda1ee4d6$export$294f6348bdcc9088);
$parcel$export(module.exports, "WMFileGrid", () => $3ee7d7d2f01ea667$export$ca445ff2f74d7dc4);
$parcel$export(module.exports, "WMAnimationContainer", () => $34f94af2bed9eb6d$export$557862fe160c66da);
$parcel$export(module.exports, "BSOD", () => $205ffae133300ada$export$dc0c0737d677cc31);
$parcel$export(module.exports, "BSODErrorBoundary", () => $aa189c2703590f33$export$6cb3cf5e69636f5b);
var $f4e75fb075d43b13$exports = {};
$parcel$export($f4e75fb075d43b13$exports, "file-grid", () => $f4e75fb075d43b13$export$2e26dfe0b6a642df, (v) => $f4e75fb075d43b13$export$2e26dfe0b6a642df = v);
$parcel$export($f4e75fb075d43b13$exports, "file-grid--row", () => $f4e75fb075d43b13$export$81006fccc5d061c0, (v) => $f4e75fb075d43b13$export$81006fccc5d061c0 = v);
$parcel$export($f4e75fb075d43b13$exports, "file-grid--column", () => $f4e75fb075d43b13$export$31d059c8d9ad6352, (v) => $f4e75fb075d43b13$export$31d059c8d9ad6352 = v);
var $f4e75fb075d43b13$export$2e26dfe0b6a642df;
var $f4e75fb075d43b13$export$81006fccc5d061c0;
var $f4e75fb075d43b13$export$31d059c8d9ad6352;
$f4e75fb075d43b13$export$2e26dfe0b6a642df = "file-grid__file-grid--tspqZ";
$f4e75fb075d43b13$export$81006fccc5d061c0 = "file-grid__file-grid--row--VY4rw";
$f4e75fb075d43b13$export$31d059c8d9ad6352 = "file-grid__file-grid--column--6HZTo";
const $3ee7d7d2f01ea667$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($f4e75fb075d43b13$exports)));
const $3ee7d7d2f01ea667$var$FileGridContext = /*#__PURE__*/ $h2LML$react.createContext('dark');
const $3ee7d7d2f01ea667$export$d0e4f69f25eb306d = ()=>$h2LML$react.useContext($3ee7d7d2f01ea667$var$FileGridContext)
;
const $3ee7d7d2f01ea667$export$ca445ff2f74d7dc4 = ({ children: children , layout: layout , color: color })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($3ee7d7d2f01ea667$var$FileGridContext.Provider, {
value: color
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $3ee7d7d2f01ea667$var$cx('file-grid', {
'file-grid--row': layout === 'row',
'file-grid--column': layout === 'column'
})
}, children))
;
$3ee7d7d2f01ea667$export$ca445ff2f74d7dc4.defaultProps = {
layout: 'row',
color: 'dark'
};
var $0d5ea133898ce235$exports = {};
$parcel$export($0d5ea133898ce235$exports, "file-grid-item", () => $0d5ea133898ce235$export$93ca51b974c6acbc, (v) => $0d5ea133898ce235$export$93ca51b974c6acbc = v);
$parcel$export($0d5ea133898ce235$exports, "file-grid-item_inner", () => $0d5ea133898ce235$export$a2894d8480a53147, (v) => $0d5ea133898ce235$export$a2894d8480a53147 = v);
$parcel$export($0d5ea133898ce235$exports, "file-grid-item_icon", () => $0d5ea133898ce235$export$5e856cbb2a93c4ca, (v) => $0d5ea133898ce235$export$5e856cbb2a93c4ca = v);
$parcel$export($0d5ea133898ce235$exports, "file-grid-item_label", () => $0d5ea133898ce235$export$347fe9213cab5b39, (v) => $0d5ea133898ce235$export$347fe9213cab5b39 = v);
$parcel$export($0d5ea133898ce235$exports, "file-grid-item--light", () => $0d5ea133898ce235$export$dd7dc9f494227eca, (v) => $0d5ea133898ce235$export$dd7dc9f494227eca = v);
$parcel$export($0d5ea133898ce235$exports, "file-grid-item--dark", () => $0d5ea133898ce235$export$2fd5d37b581bb296, (v) => $0d5ea133898ce235$export$2fd5d37b581bb296 = v);
var $0d5ea133898ce235$export$93ca51b974c6acbc;
var $0d5ea133898ce235$export$a2894d8480a53147;
var $0d5ea133898ce235$export$5e856cbb2a93c4ca;
var $0d5ea133898ce235$export$347fe9213cab5b39;
var $0d5ea133898ce235$export$dd7dc9f494227eca;
var $0d5ea133898ce235$export$2fd5d37b581bb296;
$0d5ea133898ce235$export$93ca51b974c6acbc = "file-grid-item__file-grid-item--SZtpe";
$0d5ea133898ce235$export$a2894d8480a53147 = "file-grid-item__file-grid-item_inner--FT78Q";
$0d5ea133898ce235$export$5e856cbb2a93c4ca = "file-grid-item__file-grid-item_icon--P9dMd";
$0d5ea133898ce235$export$347fe9213cab5b39 = "file-grid-item__file-grid-item_label--a0tar";
$0d5ea133898ce235$export$dd7dc9f494227eca = "file-grid-item__file-grid-item--light--zd0lP";
$0d5ea133898ce235$export$2fd5d37b581bb296 = "file-grid-item__file-grid-item--dark--gDblV";
const $a9c01d33525102d4$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($0d5ea133898ce235$exports)));
const $a9c01d33525102d4$export$866a6d2f7b9e9934 = ({ onDoubleClick: onDoubleClick , icon: icon , label: label })=>{
const color = $3ee7d7d2f01ea667$export$d0e4f69f25eb306d();
const onKeyDown = (e)=>{
if (e.key === 'Enter') onDoubleClick(e);
};
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("button", {
className: $a9c01d33525102d4$var$cx('file-grid-item', {
'file-grid-item--light': color === 'light',
'file-grid-item--dark': color === 'dark'
}),
onDoubleClick: onDoubleClick,
onKeyDown: onKeyDown
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $a9c01d33525102d4$var$cx('file-grid-item_inner')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("img", {
className: $a9c01d33525102d4$var$cx('file-grid-item_icon'),
src: icon,
draggable: "false"
}), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("span", {
className: $a9c01d33525102d4$var$cx('file-grid-item_label')
}, label))));
};
var $162002db9445e593$exports = {};
$parcel$export($162002db9445e593$exports, "desktop", () => $162002db9445e593$export$4239d699c596afd, (v) => $162002db9445e593$export$4239d699c596afd = v);
$parcel$export($162002db9445e593$exports, "desktop_items", () => $162002db9445e593$export$a7e1badc3ffdb908, (v) => $162002db9445e593$export$a7e1badc3ffdb908 = v);
$parcel$export($162002db9445e593$exports, "desktop_background", () => $162002db9445e593$export$bb51055feb57200a, (v) => $162002db9445e593$export$bb51055feb57200a = v);
var $162002db9445e593$export$4239d699c596afd;
var $162002db9445e593$export$a7e1badc3ffdb908;
var $162002db9445e593$export$bb51055feb57200a;
$162002db9445e593$export$4239d699c596afd = "desktop__desktop--J1iXS";
$162002db9445e593$export$a7e1badc3ffdb908 = "desktop__desktop_items--RKd1e";
$162002db9445e593$export$bb51055feb57200a = "desktop__desktop_background--eY3HG";
const $ccd60c5ed90e42e5$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($162002db9445e593$exports)));
const $ccd60c5ed90e42e5$export$eb8deef317734844 = ({ background: background , children: children })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ccd60c5ed90e42e5$var$cx('desktop')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ccd60c5ed90e42e5$var$cx('desktop_background'),
style: {
backgroundImage: `url(${background})`
}
}), children)
;
var $00a95d366c563b48$exports = {};
$parcel$export($00a95d366c563b48$exports, "taskbar", () => $00a95d366c563b48$export$35bfc2a2f38871b1, (v) => $00a95d366c563b48$export$35bfc2a2f38871b1 = v);
var $00a95d366c563b48$export$35bfc2a2f38871b1;
$00a95d366c563b48$export$35bfc2a2f38871b1 = "taskbar__taskbar--oaN6s";
const $535b7ef48dc67cc2$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($00a95d366c563b48$exports)));
const $535b7ef48dc67cc2$export$8ae1e4ec05622c33 = ({ children: children })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $535b7ef48dc67cc2$var$cx('taskbar')
}, children)
;
var $d7f91dd3b276ef91$exports = {};
$parcel$export($d7f91dd3b276ef91$exports, "taskbar-button", () => $d7f91dd3b276ef91$export$275ce94382092f55, (v) => $d7f91dd3b276ef91$export$275ce94382092f55 = v);
$parcel$export($d7f91dd3b276ef91$exports, "taskbar-button--active", () => $d7f91dd3b276ef91$export$caef103454e68219, (v) => $d7f91dd3b276ef91$export$caef103454e68219 = v);
var $d7f91dd3b276ef91$export$275ce94382092f55;
var $d7f91dd3b276ef91$export$caef103454e68219;
$d7f91dd3b276ef91$export$275ce94382092f55 = "taskbar-button__taskbar-button--S7fY7";
$d7f91dd3b276ef91$export$caef103454e68219 = "taskbar-button__taskbar-button--active--BdLtY";
const $d1e68489e9730228$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($d7f91dd3b276ef91$exports)));
const $d1e68489e9730228$export$6bb819c6035e3410 = ({ active: active , children: children , disabled: disabled , onClick: onClick , onKeyDown: onKeyDown , onFocus: onFocus , onBlur: onBlur })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("button", {
className: $d1e68489e9730228$var$cx('taskbar-button', {
'taskbar-button--active': active
}),
disabled: disabled,
onClick: onClick,
onKeyDown: onKeyDown,
onFocus: onFocus,
onBlur: onBlur
}, children)
;
var $d2b20113a9c9b9ef$exports = {};
$parcel$export($d2b20113a9c9b9ef$exports, "window-manager", () => $d2b20113a9c9b9ef$export$1c81a1f101b29e51, (v) => $d2b20113a9c9b9ef$export$1c81a1f101b29e51 = v);
$parcel$export($d2b20113a9c9b9ef$exports, "window-manager_layer-group", () => $d2b20113a9c9b9ef$export$f0afc6985b858597, (v) => $d2b20113a9c9b9ef$export$f0afc6985b858597 = v);
$parcel$export($d2b20113a9c9b9ef$exports, "window-manager_layer", () => $d2b20113a9c9b9ef$export$df71cb89c912f783, (v) => $d2b20113a9c9b9ef$export$df71cb89c912f783 = v);
var $d2b20113a9c9b9ef$export$1c81a1f101b29e51;
var $d2b20113a9c9b9ef$export$f0afc6985b858597;
var $d2b20113a9c9b9ef$export$df71cb89c912f783;
$d2b20113a9c9b9ef$export$1c81a1f101b29e51 = "manager__window-manager--5c80l";
$d2b20113a9c9b9ef$export$f0afc6985b858597 = "manager__window-manager_layer-group--zMiSo";
$d2b20113a9c9b9ef$export$df71cb89c912f783 = "manager__window-manager_layer--kdFkk";
const $ed9b35847880079a$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($d2b20113a9c9b9ef$exports)));
const $ed9b35847880079a$export$d0d38e7dec7a1a61 = ({ background: background , windowItems: windowItems , desktopItems: desktopItems , taskbarItems: taskbarItems , taskbarExtras: taskbarExtras , })=>{
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ed9b35847880079a$var$cx('window-manager')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ed9b35847880079a$var$cx('window-manager_layer-group')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ed9b35847880079a$var$cx('window-manager_layer')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($ccd60c5ed90e42e5$export$eb8deef317734844, {
background: background
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($3ee7d7d2f01ea667$export$ca445ff2f74d7dc4, {
layout: "column",
color: "light"
}, desktopItems))), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $ed9b35847880079a$var$cx('window-manager_layer')
}, windowItems)), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($535b7ef48dc67cc2$export$8ae1e4ec05622c33, null, taskbarItems, taskbarExtras)));
};
class $f9662873ea344300$var$Deferred {
constructor(){
this._promise = new Promise((resolve)=>{
this._resolve = resolve;
});
}
static create() {
return new $f9662873ea344300$var$Deferred();
}
resolve(t) {
this._resolve(t);
}
then(...args) {
return this._promise.then(...args);
}
catch(...args) {
return this._promise.catch(...args);
}
}
const $f9662873ea344300$export$260e5c0943f31606 = ()=>$f9662873ea344300$var$Deferred.create()
;
const $5ed9a67701f9c360$export$2cef06c20297c17d = ()=>new Promise((resolve)=>window.requestAnimationFrame(resolve)
)
;
const $5ed9a67701f9c360$export$5c069c93d2b7493f = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms)
)
;
class $0e4dfbc588c680e3$var$AsyncMap {
constructor(){
this.map = new Map();
}
ensureKey(key) {
if (!this.map.has(key)) this.map.set(key, $f9662873ea344300$export$260e5c0943f31606());
return this.map.get(key);
}
async get(key) {
return Promise.race([
this.ensureKey(key),
$5ed9a67701f9c360$export$2cef06c20297c17d().then(()=>false
)
]);
}
async set(key, value) {
this.ensureKey(key).resolve(value);
await $5ed9a67701f9c360$export$2cef06c20297c17d();
this.map.delete(key);
}
}
class $0e4dfbc588c680e3$var$AnimationCoordinator {
constructor(){
this.inMap = new $0e4dfbc588c680e3$var$AsyncMap();
this.outMap = new $0e4dfbc588c680e3$var$AsyncMap();
}
static create() {
return new $0e4dfbc588c680e3$var$AnimationCoordinator();
}
async in(id, ref) {
this.inMap.set(id, ref);
return this.outMap.get(id);
}
async out(id, ref) {
this.outMap.set(id, ref);
return this.inMap.get(id);
}
}
const $0e4dfbc588c680e3$export$e4025cc975cafdc9 = ()=>$0e4dfbc588c680e3$var$AnimationCoordinator.create()
;
const $9c1fb146ebe278c1$export$51b34a29d7ff02d4 = ($parcel$interopDefault($h2LML$react)).createContext($0e4dfbc588c680e3$export$e4025cc975cafdc9());
const $34f94af2bed9eb6d$export$557862fe160c66da = ({ children: children })=>{
const [animationCoordinator] = $h2LML$react.useState(()=>$0e4dfbc588c680e3$export$e4025cc975cafdc9()
);
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($9c1fb146ebe278c1$export$51b34a29d7ff02d4.Provider, {
value: animationCoordinator
}, children));
};
const $f48dc641d0f6dc88$export$9e2608686d4ad846 = (ref, inProp, animateIn, animateOut)=>{
const runEnter = ()=>animateIn(ref.current)
;
const runExit = ()=>animateOut(ref.current)
;
$h2LML$react.useLayoutEffect(()=>inProp ? runEnter() : runExit()
, [
inProp
]);
};
const $35aece96251a326d$export$2b3f67d9cc2b5274 = (process)=>(...args)=>{
const gen = process(...args);
let canceled = false;
const run = async ()=>{
// eslint-disable-next-line no-unused-vars
for await (const unused of gen){
if (canceled) break;
}
};
run();
return ()=>{
canceled = true;
};
}
;
const $bb7f118a5aa1501f$var$stagedAnimation = (animation)=>async function*(el) {
animation.setup();
yield await $5ed9a67701f9c360$export$2cef06c20297c17d();
animation.run();
yield await new Promise((resolve)=>el.addEventListener('transitionend', resolve, {
once: true
})
);
animation.teardown();
}
;
const $bb7f118a5aa1501f$var$useAnimationState = (name)=>{
const [animationState, setAnimationState] = $h2LML$react.useState([]);
const runAnimation = $35aece96251a326d$export$2b3f67d9cc2b5274($bb7f118a5aa1501f$var$stagedAnimation({
setup: ()=>setAnimationState([
name
])
,
run: ()=>setAnimationState([
name,
`${name}-active`
])
,
teardown: ()=>setAnimationState([
name,
`${name}-done`
])
}));
return [
animationState,
runAnimation
];
};
const $bb7f118a5aa1501f$var$mapClassNames = (classNames, mapping)=>($parcel$interopDefault($h2LML$classnames))(classNames.map((name)=>mapping[name]
))
;
const $bb7f118a5aa1501f$export$ae8d212693adc0e9 = (ref, inProp, mapping)=>{
const [inState, runAnimationIn] = $bb7f118a5aa1501f$var$useAnimationState('enter');
const [outState, runAnimationOut] = $bb7f118a5aa1501f$var$useAnimationState('exit');
$f48dc641d0f6dc88$export$9e2608686d4ad846(ref, inProp, runAnimationIn, runAnimationOut);
return $bb7f118a5aa1501f$var$mapClassNames([
...inState,
...outState
], mapping);
};
const $fdcf8b9b67968cb5$var$makeSurrogate = (el)=>{
const rect = el.getBoundingClientRect();
return {
getBoundingClientRect: ()=>rect
};
};
const $fdcf8b9b67968cb5$export$a5308ae47b238330 = (id, ref, inProp, receive, send)=>{
const animationCoordinator = $h2LML$react.useContext($9c1fb146ebe278c1$export$51b34a29d7ff02d4);
const animateIn = async function*() {
const matched = await animationCoordinator.in(id, ref.current);
yield;
if (matched) yield* receive(matched, ref.current);
};
const animateOut = async function*() {
const matched = await animationCoordinator.out(id, ref.current);
yield;
if (matched) yield* send(ref.current, matched);
};
$f48dc641d0f6dc88$export$9e2608686d4ad846(ref, inProp, $35aece96251a326d$export$2b3f67d9cc2b5274(animateIn), $35aece96251a326d$export$2b3f67d9cc2b5274(animateOut));
$h2LML$react.useEffect(()=>{
return ()=>{
animationCoordinator.out(id, $fdcf8b9b67968cb5$var$makeSurrogate(ref.current));
};
}, []);
};
var $cd7f9742dbb02af5$exports = {};
$parcel$export($cd7f9742dbb02af5$exports, "bsod", () => $cd7f9742dbb02af5$export$1a88e1a01b9d8583, (v) => $cd7f9742dbb02af5$export$1a88e1a01b9d8583 = v);
$parcel$export($cd7f9742dbb02af5$exports, "bsod_column", () => $cd7f9742dbb02af5$export$55d9dc03fa6d898c, (v) => $cd7f9742dbb02af5$export$55d9dc03fa6d898c = v);
var $cd7f9742dbb02af5$export$1a88e1a01b9d8583;
var $cd7f9742dbb02af5$export$55d9dc03fa6d898c;
$cd7f9742dbb02af5$export$1a88e1a01b9d8583 = "bsod__bsod--HIwKo";
$cd7f9742dbb02af5$export$55d9dc03fa6d898c = "bsod__bsod_column--9qrrP";
const $205ffae133300ada$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($cd7f9742dbb02af5$exports)));
const $205ffae133300ada$export$dc0c0737d677cc31 = ({ error: error })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $205ffae133300ada$var$cx('bsod')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $205ffae133300ada$var$cx('bsod_column')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("h2", null, "Error"), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("pre", null, "An exception has occurred and the application cannot continue"), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("pre", null, error && error.stack)))
;
class $aa189c2703590f33$export$6cb3cf5e69636f5b extends $h2LML$react.Component {
constructor(props){
super(props);
this.state = {
error: null
};
}
static getDerivedStateFromError(error) {
return {
error: error
};
}
render() {
const { children: children } = this.props;
const { error: error } = this.state;
if (error) return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($205ffae133300ada$export$dc0c0737d677cc31, {
error: error
}));
return children;
}
}
const $2ae85fedbc9ab040$var$ORIGIN = {
left: 0,
top: 0
};
const $2ae85fedbc9ab040$var$noop = ()=>{
};
const $2ae85fedbc9ab040$export$7941f8aafa4b6021 = ({ onDragStart: onDragStart = $2ae85fedbc9ab040$var$noop , onDrag: onDrag = $2ae85fedbc9ab040$var$noop , onDragEnd: onDragEnd = $2ae85fedbc9ab040$var$noop })=>{
const [dragOrigin, setDragOrigin] = $h2LML$react.useState($2ae85fedbc9ab040$var$ORIGIN);
const [isDragging, setIsDragging] = $h2LML$react.useState(false);
const handleMouseDown = $h2LML$react.useCallback(({ clientX: clientX , clientY: clientY , button: button })=>{
if (button === 2) return; // ignore right clicks
setIsDragging(true);
setDragOrigin({
left: clientX,
top: clientY
});
onDragStart();
}, []);
const handleMouseMove = $h2LML$react.useCallback(({ clientX: clientX , clientY: clientY })=>{
const offset = {
left: clientX - dragOrigin.left,
top: clientY - dragOrigin.top
};
onDrag(offset);
}, [
dragOrigin,
onDrag
]);
const handleMouseUp = $h2LML$react.useCallback(()=>{
setIsDragging(false);
onDragEnd();
}, [
onDragEnd
]);
$h2LML$react.useEffect(()=>{
if (isDragging) {
window.addEventListener('mousemove', handleMouseMove);
window.addEventListener('mouseup', handleMouseUp);
return ()=>{
window.removeEventListener('mousemove', handleMouseMove);
window.removeEventListener('mouseup', handleMouseUp);
};
}
}, [
isDragging,
handleMouseMove,
handleMouseUp
]);
return handleMouseDown;
};
var $c208ba7961c41a34$exports = {};
$parcel$export($c208ba7961c41a34$exports, "window", () => $c208ba7961c41a34$export$8291e5b88f90ce4, (v) => $c208ba7961c41a34$export$8291e5b88f90ce4 = v);
$parcel$export($c208ba7961c41a34$exports, "window--focused", () => $c208ba7961c41a34$export$9603ac62ef99b998, (v) => $c208ba7961c41a34$export$9603ac62ef99b998 = v);
$parcel$export($c208ba7961c41a34$exports, "window_header", () => $c208ba7961c41a34$export$8c8536aaf36d09aa, (v) => $c208ba7961c41a34$export$8c8536aaf36d09aa = v);
$parcel$export($c208ba7961c41a34$exports, "window_title", () => $c208ba7961c41a34$export$a519a803e850ee3d, (v) => $c208ba7961c41a34$export$a519a803e850ee3d = v);
$parcel$export($c208ba7961c41a34$exports, "window_buttons", () => $c208ba7961c41a34$export$5603b08b28264549, (v) => $c208ba7961c41a34$export$5603b08b28264549 = v);
$parcel$export($c208ba7961c41a34$exports, "window_body", () => $c208ba7961c41a34$export$3f8b3ae8de787dfe, (v) => $c208ba7961c41a34$export$3f8b3ae8de787dfe = v);
$parcel$export($c208ba7961c41a34$exports, "window-button", () => $c208ba7961c41a34$export$dd6a2613ce6e88c1, (v) => $c208ba7961c41a34$export$dd6a2613ce6e88c1 = v);
$parcel$export($c208ba7961c41a34$exports, "window-button--close", () => $c208ba7961c41a34$export$536dd4da38e780db, (v) => $c208ba7961c41a34$export$536dd4da38e780db = v);
var $c208ba7961c41a34$export$8291e5b88f90ce4;
var $c208ba7961c41a34$export$9603ac62ef99b998;
var $c208ba7961c41a34$export$8c8536aaf36d09aa;
var $c208ba7961c41a34$export$a519a803e850ee3d;
var $c208ba7961c41a34$export$5603b08b28264549;
var $c208ba7961c41a34$export$3f8b3ae8de787dfe;
var $c208ba7961c41a34$export$dd6a2613ce6e88c1;
var $c208ba7961c41a34$export$536dd4da38e780db;
$c208ba7961c41a34$export$8291e5b88f90ce4 = "window__window--y4bO6";
$c208ba7961c41a34$export$9603ac62ef99b998 = "window__window--focused--Jn-x3";
$c208ba7961c41a34$export$8c8536aaf36d09aa = "window__window_header--Pv0Gi";
$c208ba7961c41a34$export$a519a803e850ee3d = "window__window_title--YQbxS";
$c208ba7961c41a34$export$5603b08b28264549 = "window__window_buttons--I1YRO";
$c208ba7961c41a34$export$3f8b3ae8de787dfe = "window__window_body--NYfLu";
$c208ba7961c41a34$export$dd6a2613ce6e88c1 = "window__window-button--wGOpm";
$c208ba7961c41a34$export$536dd4da38e780db = "window__window-button--close--8d8qm";
var $11abc30deac6a33a$exports = {};
$11abc30deac6a33a$exports = new URL("minimize.c0977952.svg", "file:" + __filename).toString();
var $31a575acb2ee8291$exports = {};
$31a575acb2ee8291$exports = new URL("close.15db31ae.svg", "file:" + __filename).toString();
const $4fdba04c08cdf9c4$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($c208ba7961c41a34$exports)));
const $4fdba04c08cdf9c4$export$cec157cbbbaf65c9 = ({ title: title , children: children , className: className , isFocused: isFocused , onMinimize: onMinimize , onClose: onClose , onDragStart: onDragStart , onDrag: onDrag , onDragEnd: onDragEnd , })=>{
const handleMouseDown = $2ae85fedbc9ab040$export$7941f8aafa4b6021({
onDragStart: onDragStart,
onDrag: onDrag,
onDragEnd: onDragEnd
});
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4fdba04c08cdf9c4$var$cx(className, 'window', {
'window--focused': isFocused
})
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4fdba04c08cdf9c4$var$cx('window_header'),
onMouseDown: handleMouseDown
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("span", {
className: $4fdba04c08cdf9c4$var$cx('window_title')
}, title), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4fdba04c08cdf9c4$var$cx('window_buttons')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("button", {
onClick: onMinimize,
className: $4fdba04c08cdf9c4$var$cx('window-button', 'window-button--minimize'),
name: "minimize window"
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("img", {
src: (/*@__PURE__*/$parcel$interopDefault($11abc30deac6a33a$exports)),
alt: ""
})), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("button", {
onClick: onClose,
className: $4fdba04c08cdf9c4$var$cx('window-button', 'window-button--close'),
name: "close window"
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("img", {
src: (/*@__PURE__*/$parcel$interopDefault($31a575acb2ee8291$exports)),
alt: ""
})))), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4fdba04c08cdf9c4$var$cx('window_body')
}, children)));
};
var $e585b77193e9427c$exports = {};
$parcel$export($e585b77193e9427c$exports, "outline", () => $e585b77193e9427c$export$f9258c55612cbed7, (v) => $e585b77193e9427c$export$f9258c55612cbed7 = v);
$parcel$export($e585b77193e9427c$exports, "outline--animate", () => $e585b77193e9427c$export$879f368dc91e9265, (v) => $e585b77193e9427c$export$879f368dc91e9265 = v);
var $e585b77193e9427c$export$f9258c55612cbed7;
var $e585b77193e9427c$export$879f368dc91e9265;
$e585b77193e9427c$export$f9258c55612cbed7 = "outline__outline--YKbro";
$e585b77193e9427c$export$879f368dc91e9265 = "outline__outline--animate---rrxh";
const $ca57d89897de8c57$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($e585b77193e9427c$exports)));
const $ca57d89897de8c57$export$5beeae30d1389e5 = /*#__PURE__*/ $h2LML$react.forwardRef(({ animate: animate , rect: rect }, ref)=>{
const style = {
top: rect.top,
left: rect.left,
bottom: rect.bottom,
right: rect.right
};
const className = $ca57d89897de8c57$var$cx('outline', {
'outline--animate': animate
});
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
ref: ref,
className: className,
style: style
}));
});
const $7925615b8f2d8caa$var$originRect = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
const $7925615b8f2d8caa$var$flipRect = (from, to)=>{
const fromRect = from.getBoundingClientRect();
const toRect = to.getBoundingClientRect();
return $7925615b8f2d8caa$var$flipPosition(fromRect, toRect);
};
const $7925615b8f2d8caa$var$flipPosition = (from, to)=>({
top: from.top - to.top,
left: from.left - to.left,
bottom: -(from.bottom - to.bottom),
right: -(from.right - to.right)
})
;
const $7925615b8f2d8caa$var$makeCSSAnimation = (anim)=>async function*(from, to) {
anim.setup(from, to);
await $5ed9a67701f9c360$export$2cef06c20297c17d();
yield;
anim.run(from, to);
await new Promise((resolve)=>to.addEventListener('transitionend', resolve)
);
yield;
anim.teardown(from, to);
}
;
const $7925615b8f2d8caa$var$noAnimation = async function*() {
};
const $7925615b8f2d8caa$export$aec62708974f5120 = (id, ref)=>{
const [rect, setRect] = $h2LML$react.useState($7925615b8f2d8caa$var$originRect);
const [isAnimating, setIsAnimating] = $h2LML$react.useState(false);
const receive = $7925615b8f2d8caa$var$makeCSSAnimation({
setup: (from, to)=>{
setRect($7925615b8f2d8caa$var$flipRect(from, to));
setIsAnimating(false);
},
run: ()=>{
setRect($7925615b8f2d8caa$var$originRect);
setIsAnimating(true);
},
teardown: ()=>{
setIsAnimating(false);
}
});
const send = $7925615b8f2d8caa$var$noAnimation;
$fdcf8b9b67968cb5$export$a5308ae47b238330(id, ref, true, receive, send);
return {
rect: rect,
isAnimating: isAnimating
};
};
const $20babce056a2968f$export$863c38976eba89cc = ({ id: id })=>{
const ref = $h2LML$react.useRef();
const { isAnimating: isAnimating , rect: rect } = $7925615b8f2d8caa$export$aec62708974f5120(id, ref);
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($ca57d89897de8c57$export$5beeae30d1389e5, {
ref: ref,
rect: rect,
animate: isAnimating
}));
};
const $2ee973651bece2a9$export$38441178cfd1716f = (position, onMove)=>{
const positionRef = $h2LML$react.useRef({
top: 0,
left: 0
});
const startPositionRef = $h2LML$react.useRef({
top: 0,
left: 0
});
positionRef.current = position;
const [isDragging, setIsDragging] = $h2LML$react.useState(false);
const onDragStart = $h2LML$react.useCallback(()=>{
startPositionRef.current = positionRef.current;
setIsDragging(true);
}, []);
const onDrag = $h2LML$react.useCallback((offset)=>{
const newPosition = {
top: startPositionRef.current.top + offset.top,
left: startPositionRef.current.left + offset.left
};
onMove(newPosition);
}, [
onMove
]);
const onDragEnd = $h2LML$react.useCallback(()=>{
setIsDragging(false);
}, []);
return {
isDragging: isDragging,
onDragStart: onDragStart,
onDrag: onDrag,
onDragEnd: onDragEnd
};
};
const $e3153b0325b2973f$export$e838b63e89f8751e = (ref, { isFocused: isFocused1 , onFocus: onFocus , onBlur: onBlur })=>{
const isFocusedRef = $h2LML$react.useRef();
isFocusedRef.current = isFocused1;
$h2LML$react.useEffect(()=>{
if (isFocused1 && !ref.current.contains(document.activeElement)) ref.current.focus({
preventScroll: true
});
}, [
isFocused1
]);
$h2LML$react.useEffect(()=>{
const handleFocus = ()=>{
window.setTimeout(()=>{
const isActive = ref.current && ref.current.contains(document.activeElement) || ref.current === document.activeElement;
const isFocused = isFocusedRef.current;
if (isFocused && !isActive) onBlur();
if (!isFocused && isActive) onFocus();
}, 0);
};
document.addEventListener('focusout', handleFocus);
document.addEventListener('focusin', handleFocus);
return ()=>{
document.removeEventListener('focusout', handleFocus);
document.removeEventListener('focusin', handleFocus);
};
}, []);
};
var $98d730a5c42353a6$exports = {};
$parcel$export($98d730a5c42353a6$exports, "window-frame", () => $98d730a5c42353a6$export$3a0a6dfa6a4e4319, (v) => $98d730a5c42353a6$export$3a0a6dfa6a4e4319 = v);
$parcel$export($98d730a5c42353a6$exports, "window-frame_shadow", () => $98d730a5c42353a6$export$57c4b1fd480ab43f, (v) => $98d730a5c42353a6$export$57c4b1fd480ab43f = v);
$parcel$export($98d730a5c42353a6$exports, "appear--enter", () => $98d730a5c42353a6$export$f64bfac272cd33e, (v) => $98d730a5c42353a6$export$f64bfac272cd33e = v);
$parcel$export($98d730a5c42353a6$exports, "appear--enter-active", () => $98d730a5c42353a6$export$50e79a129e99555e, (v) => $98d730a5c42353a6$export$50e79a129e99555e = v);
$parcel$export($98d730a5c42353a6$exports, "appear--enter-done", () => $98d730a5c42353a6$export$c65f9181e6303a22, (v) => $98d730a5c42353a6$export$c65f9181e6303a22 = v);
var $98d730a5c42353a6$export$3a0a6dfa6a4e4319;
var $98d730a5c42353a6$export$57c4b1fd480ab43f;
var $98d730a5c42353a6$export$f64bfac272cd33e;
var $98d730a5c42353a6$export$50e79a129e99555e;
var $98d730a5c42353a6$export$c65f9181e6303a22;
$98d730a5c42353a6$export$3a0a6dfa6a4e4319 = "window__window-frame--pIlOD";
$98d730a5c42353a6$export$57c4b1fd480ab43f = "window__window-frame_shadow---3f2s";
$98d730a5c42353a6$export$f64bfac272cd33e = "window__appear--enter--xV8pX";
$98d730a5c42353a6$export$50e79a129e99555e = "window__appear--enter-active--w--dR";
$98d730a5c42353a6$export$c65f9181e6303a22 = "window__appear--enter-done--vjySE";
const $e283ee4fda1ee4d6$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($98d730a5c42353a6$exports)));
const $e283ee4fda1ee4d6$var$transitionClassNames = {
enter: $e283ee4fda1ee4d6$var$cx('appear--enter'),
'enter-active': $e283ee4fda1ee4d6$var$cx('appear--enter-active'),
'enter-done': $e283ee4fda1ee4d6$var$cx('appear--enter-done')
};
const $e283ee4fda1ee4d6$var$WindowElementContext = /*#__PURE__*/ $h2LML$react.createContext(null);
const $e283ee4fda1ee4d6$export$294f6348bdcc9088 = ()=>$h2LML$react.useContext($e283ee4fda1ee4d6$var$WindowElementContext)
;
const $e283ee4fda1ee4d6$export$43e5451677e635a1 = ({ id: id , title: title , children: children , order: order , position: position , dimensions: dimensions , isFocused: isFocused , onMinimize: onMinimize , onClose: onClose , onFocus: onFocus , onBlur: onBlur , onMove: onMove , })=>{
const shadowRef = $h2LML$react.useRef(null);
const transitionClassName = $bb7f118a5aa1501f$export$ae8d212693adc0e9(shadowRef, true, $e283ee4fda1ee4d6$var$transitionClassNames);
const frameRef = $h2LML$react.useRef(null);
$e3153b0325b2973f$export$e838b63e89f8751e(frameRef, {
isFocused: isFocused,
onFocus: onFocus,
onBlur: onBlur
});
const { onDragStart: onDragStart , onDrag: onDrag , onDragEnd: onDragEnd } = $2ee973651bece2a9$export$38441178cfd1716f(position, onMove);
const style = {
zIndex: order,
...position,
...dimensions
};
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($e283ee4fda1ee4d6$var$WindowElementContext.Provider, {
value: frameRef
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $e283ee4fda1ee4d6$var$cx('window-frame'),
style: style,
ref: frameRef,
tabIndex: 0
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($4fdba04c08cdf9c4$export$cec157cbbbaf65c9, {
className: transitionClassName,
title: title,
isFocused: isFocused,
onMinimize: onMinimize,
onClose: onClose,
onDragStart: onDragStart,
onDrag: onDrag,
onDragEnd: onDragEnd
}, children), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($20babce056a2968f$export$863c38976eba89cc, {
id: id
}), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
ref: shadowRef,
className: $e283ee4fda1ee4d6$var$cx('window-frame_shadow', transitionClassName)
}))));
};
const $813cadf7f2d083c4$export$26c38373364bc34f = ({ id: id , active: active , hasOutline: hasOutline , onClick: onClick , children: children })=>/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($d1e68489e9730228$export$6bb819c6035e3410, {
active: active,
onClick: onClick
}, children, hasOutline && /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($20babce056a2968f$export$863c38976eba89cc, {
id: id
}))
;
const $c258afc3093d5e8c$var$WindowContext = /*#__PURE__*/ $h2LML$react.createContext([]);
const $c258afc3093d5e8c$export$a057ee0dd56761df = ()=>$h2LML$react.useContext($c258afc3093d5e8c$var$WindowContext)
;
const $c258afc3093d5e8c$export$adf2d320ba0a3b0a = ({ background: background , windows: windows , desktopItems: desktopItems , taskbarExtras: taskbarExtras , })=>{
const windowItems = windows.map(({ id: id , title: title , content: content , state: state , actions: actions })=>state.visibility === 'open' && /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($e283ee4fda1ee4d6$export$43e5451677e635a1, {
key: id,
id: id,
title: title,
order: state.order,
position: state.position,
dimensions: state.dimensions,
isFocused: state.isFocused,
onMinimize: actions.minimize,
onClose: actions.close,
onFocus: actions.focus,
onBlur: actions.blur,
onMove: actions.move
}, content)
);
const taskbarItems = windows.map(({ id: id , title: title , state: state , actions: actions })=>state.visibility !== 'closed' && /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($813cadf7f2d083c4$export$26c38373364bc34f, {
key: id,
id: id,
active: state.visibility === 'open' && state.isFocused,
hasOutline: state.visibility === 'minimized',
onClick: state.visibility === 'open' && state.order === windows.length ? actions.minimize : actions.open
}, title)
);
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($aa189c2703590f33$export$6cb3cf5e69636f5b, null, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($34f94af2bed9eb6d$export$557862fe160c66da, null, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($c258afc3093d5e8c$var$WindowContext.Provider, {
value: windows
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($ed9b35847880079a$export$d0d38e7dec7a1a61, {
background: background,
desktopItems: desktopItems,
windowItems: windowItems,
taskbarItems: taskbarItems,
taskbarExtras: taskbarExtras
})))));
};
var $ddf5d621e5fd7db0$exports = {};
$parcel$export($ddf5d621e5fd7db0$exports, "file-grid-item", () => $ddf5d621e5fd7db0$export$93ca51b974c6acbc, (v) => $ddf5d621e5fd7db0$export$93ca51b974c6acbc = v);
$parcel$export($ddf5d621e5fd7db0$exports, "file-grid-item_origin", () => $ddf5d621e5fd7db0$export$ce608489d13ca3c3, (v) => $ddf5d621e5fd7db0$export$ce608489d13ca3c3 = v);
var $ddf5d621e5fd7db0$export$93ca51b974c6acbc;
var $ddf5d621e5fd7db0$export$ce608489d13ca3c3;
$ddf5d621e5fd7db0$export$93ca51b974c6acbc = "file-grid-item__file-grid-item--uIz4v";
$ddf5d621e5fd7db0$export$ce608489d13ca3c3 = "file-grid-item__file-grid-item_origin--SOFz4";
const $4c891e30bb3bb31c$var$cx = ($parcel$interopDefault($h2LML$classnamesbind)).bind((/*@__PURE__*/$parcel$interopDefault($ddf5d621e5fd7db0$exports)));
const $4c891e30bb3bb31c$var$defaultWindow = {
state: {
}
};
const $4c891e30bb3bb31c$export$a7ddab7342148340 = ({ icon: icon , label: label , id: id , onDoubleClick: onDoubleClick })=>{
const windows = $c258afc3093d5e8c$export$a057ee0dd56761df();
const window1 = windows.find((window)=>window.id === id
) || $4c891e30bb3bb31c$var$defaultWindow;
const hasOutline = window1.state.visibility === 'closed';
return(/*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4c891e30bb3bb31c$var$cx('file-grid-item')
}, /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($a9c01d33525102d4$export$866a6d2f7b9e9934, {
icon: icon,
label: label,
onDoubleClick: onDoubleClick
}), /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement("div", {
className: $4c891e30bb3bb31c$var$cx('file-grid-item_origin')
}, hasOutline && /*#__PURE__*/ ($parcel$interopDefault($h2LML$react)).createElement($20babce056a2968f$export$863c38976eba89cc, {
id: id
}))));
};
const $a1c61b324e886fbe$export$1bbd4b845414c3cc = {
get: (s)=>s
,
set: (s, x)=>x
,
delete: ()=>undefined
,
name: 'id'
};
const $a1c61b324e886fbe$export$a3be6efeaa85b08e = (i)=>({
get: (s)=>s[i]
,
set: (s, x)=>{
const clone = [
...s
];
clone[i] = x;
return clone;
},
delete: (s)=>{
const clone = [
...s
];
delete clone[i];
return clone;
},
name: `[${i}]`
})
;
const $a1c61b324e886fbe$export$42023809cd21ee92 = (p)=>({
get: (s)=>s[p]
,
set: (s, x)=>({
...s,
[p]: x
})
,
delete: (s)=>{
const clone = {
...s
};
delete clone[p];
return clone;
},
name: `.${p}`
})
;
const $a1c61b324e886fbe$export$f5c3e419c6a355ce = (l1, l2)=>({
get: (s)=>l2.get(l1.get(s))
,
set: (s, x)=>{
const inner = l1.get(s);
return l1.set(s, l2.set(inner, x));
},
delete: (s)=>{
const inner = l1.get(s);
return l1.set(s, l2.delete(inner));
},
name: `${l1.name} ${l2.name}`
})
;
const $a1c61b324e886fbe$export$562de9a8737f7052 = {
get: ()=>undefined
,
set: (s)=>s
,
delete: ()=>undefined
,
name: 'empty'
};
const $a1c61b324e886fbe$export$f596f87d298b2ac9 = (lens, d)=>({
get: (s)=>{
try {
return lens.get(s);
} catch (e) {
return d;
}
},
set: lens.set,
delete: lens.delete,
name: `safe(${lens.name})`
})
;
const $a1c61b324e886fbe$export$947c7c20609239eb = (...args)=>{
const path = args.map((l)=>typeof l === 'number' ? $a1c61b324e886fbe$export$a3be6efeaa85b08e(l) : $a1c61b324e886fbe$export$42023809cd21ee92(l)
).reduce($a1c61b324e886fbe$export$f5c3e419c6a355ce, $a1c61b324e886fbe$export$1bbd4b845414c3cc);
return $a1c61b324e886fbe$export$f596f87d298b2ac9(path, undefined);
};
const $a1c61b324e886fbe$export$24c5629188499cc3 = (first, ...lenses)=>lenses.reduce($a1c61b324e886fbe$export$f5c3e419c6a355ce, first)
;
const $a1c61b324e886fbe$export$cba09f9e3d3e58eb = (lens, f)=>(s)=>lens.set(s, f(lens.get(s)))
;
const $3b0877d500587ccd$export$fc77a6137e3f91c = (from, to)=>(index)=>{
if (index === from) return to;
if (index < from && index < to) return index;
if (index > from && index > to) return index;
if (to > from) return index - 1;
if (to < from) return index + 1;
return index;
}
;
const $b90f838243d23e43$var$mapObject = (obj, f1)=>{
const app = (key, i)=>{
const lens = $a1c61b324e886fbe$export$947c7c20609239eb(key);
return $a1c61b324e886fbe$export$cba09f9e3d3e58eb(lens, (value)=>f1(key, value, i)
);
};
return Object.keys(obj).map(app).reduce((acc, f)=>f(acc)
, obj);
};
const $b90f838243d23e43$var$topWindow = (state)=>{
const windows = Object.entries(state);
const [topId] = windows.filter(([, window])=>window.visibility === 'open'
).sort(([, window1], [, window2])=>window1.order - window2.order
).pop() || [];
return topId;
};
const $b90f838243d23e43$var$reorderWindows = (from, to)=>(state)=>{
const reorderWindow = $a1c61b324e886fbe$export$cba09f9e3d3e58eb($a1c61b324e886fbe$export$947c7c20609239eb('order'), $3b0877d500587ccd$export$fc77a6137e3f91c(from, to));
return $b90f838243d23e43$var$mapObject(state, (key, window)=>reorderWindow(window)
);
}
;
const $b90f838243d23e43$var$autoPosition = (state)=>{
const topId = $b90f838243d23e43$var$topWindow(state) || -1;
const topPosition = $a1c61b324e886fbe$export$947c7c20609239eb(topId, 'position').get(state);
return topPosition ? {
left: topPosition.left + 40,
top: topPosition.top + 20
} : {
left: 200,
top: 100
};
};
const $b90f838243d23e43$var$initializeWindow = (key, window, i)=>({
position: {
top: 50 + i * 50,
left: 200 + i * 100
},
visibility: 'closed',
isFocused: false,
...window,
order: i + 1
})
;
const $b90f838243d23e43$var$initialize = (state)=>$b90f838243d23e43$var$mapObject(state, $b90f838243d23e43$var$initializeWindow)
;
const $b90f838243d23e43$var$reducer = (state, action)=>{
if (action.type.startsWith('window.')) return $b90f838243d23e43$var$windowReducer(state, action);
if (action.type.startsWith('top.')) return $b90f838243d23e43$var$topReducer(state, action);
return state;
};
const $b90f838243d23e43$var$topReducer = (state, { type: type , id: id , window: window , newState: newState })=>{
const windowLens = $a1c61b324e886fbe$export$947c7c20609239eb(id);
switch(type){
case 'top.create':
{
const order = Object.keys(state).length;
const position = $b90f838243d23e43$var$autoPosition(state);
const newWindow = $b90f838243d23e43$var$initializeWindow(id, {
position: position,
...window
}, order);
return windowLens.set(state, newWindow);
}
case 'top.destroy':
{
const newState = {
...state
};
delete newState[id];
return newState;
}
case 'top.focusNext':
{
const topId = $b90f838243d23e43$var$topWindow(state);
return topId ? $a1c61b324e886fbe$export$947c7c20609239eb(topId, 'isFocused').set(state, true) : state;
}
case 'top.reset':
return $b90f838243d23e43$var$initialize(newState);
}
};
const $b90f838243d23e43$var$windowReducer = (state, action)=>{
const visibilityLens = $a1c61b324e886fbe$export$947c7c20609239eb(action.id, 'visibility');
const positionLens = $a1c61b324e886fbe$export$947c7c20609239eb(action.id, 'position');
const focusLens = $a1c61b324e886fbe$export$947c7c20609239eb(action.id, 'isFocused');
switch(action.type){
case 'window.open':
return visibilityLens.set(state, 'open');
case 'window.minimize':
return visibilityLens.set(state, 'minimized');
case 'window.close':
return visibilityLens.set(state, 'closed');
case 'window.focus':
return focusLens.set(state, true);
case 'window.blur':
return focusLens.set(state, false);
case 'window.move':
return $a1c61b324e886fbe$export$cba09f9e3d3e58eb(positionLens, (oldPosition)=>({
...oldPosition,
...action.position
})
)(state);
case 'window.bringToFront':
{
const from = state[action.id].order;
const to = Object.keys(state).length;
return $b90f838243d23e43$var$reorderWindows(from, to)(state);
}
}
};
const $b90f838243d23e43$export$e90db8474c899249 = (initialState)=>{
const [state1, dispatch] = $h2LML$react.useReducer($b90f838243d23e43$var$reducer, initialState, $b90f838243d23e43$var$initialize);
// Window actions
const windowActions = (id)=>({
open: ()=>{
dispatch({
type: 'window.open',
id: id
});
dispatch({
type: 'window.bringToFront',
id: id
});
dispatch({
type: 'window.focus',
id: id
});
},
focus: ()=>{
dispatch({
type: 'window.bringToFront',
id: id
});
dispatch({
type: 'window.focus',
id: id
});
},
close: ()=>{
dispatch({
type: 'window.close',
id: id
});
dispatch({
type: 'window.blur',
id: id
});
dispatch({
type: 'top.focusNext'
});
},
minimize: ()=>{
dispatch({
type: 'window.minimize',
id: id
});
dispatch({
type: 'top.focusNext'
});
},
blur: ()=>dispatch({
type: 'window.blur',
id: id
})
,
move: (position)=>dispatch({
type: 'window.move',
id: id,
position: position
})
})
;
// Top-level actions
const createWindow = (id, window)=>{
if (state1[id] === undefined) dispatch({
type: 'top.create',
id: id,
window: window
});
};
const destroyWindow = (id)=>{
if (state1[id] !== undefined) {
dispatch({
type: 'top.destroy',
id: id
});
dispatch({
type: 'top.focusNext'
});
}
};
const openWindow = async (id, window)=>{
if (state1[id] === undefined) {
createWindow(id, window);
setTimeout(()=>{
windowActions(id).open();
}, 0);
} else windowActions(id).open();
};
const closeWindow = (id)=>{
if (state1[id] !== undefined) windowActions(id).close();
};
const reset = (state)=>{
dispatch({
type: 'top.reset',
newState: state
});
};
const numWindows = Object.keys(state1).length;
const actions = {
createWindow: createWindow,
destroyWindow: destroyWindow,
openWindow: openWindow,
closeWindow: closeWindow,
reset: reset,
window: $h2LML$react.useMemo(()=>$b90f838243d23e43$var$mapObject(state1, windowActions)
, [
numWindows
])
};
return [
state1,
actions
];
};
//# sourceMappingURL=main.js.map

60

package.json

@@ -7,5 +7,8 @@ {

},
"version": "0.12.1",
"version": "0.12.2",
"description": "Throwback Windows-XP style react components",
"source": "src/index.ts",
"main": "dist/main.js",
"module": "dist/module.js",
"types": "dist/types.d.ts",
"files": [

@@ -15,5 +18,6 @@ "dist/**/*"

"scripts": {
"start": "webpack-dev-server --mode development --config webpack.example.config.js --open --port 4500",
"build": "webpack --mode production",
"prepare": "npm run build"
"start": "parcel ./example/index.html --port 4500",
"build": "parcel build ./src/index.ts",
"clean": "rm -rf ./dist",
"prepare": "npm run clean && npm run build"
},

@@ -23,40 +27,28 @@ "author": "Matt Kaemmerer <matthew.kaemmerer@gmail.com>",

"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-module-resolver": "^3.2.0",
"css-loader": "^3.2.0",
"eslint": "^6.5.1",
"eslint-loader": "^3.0.2",
"eslint-plugin-react": "^7.16.0",
"file-loader": "^4.2.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.1.0",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.12.0",
"postcss-preset-env": "^6.7.0",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-svg-loader": "^3.0.3",
"sass-loader": "^8.0.0",
"url-loader": "^2.2.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.8.2"
"@parcel/config-default": "^2.0.1",
"@parcel/packager-ts": "^2.3.1",
"@parcel/transformer-sass": "^2.3.1",
"@parcel/transformer-typescript-types": "^2.3.1",
"@types/react": "^16.12.0",
"normalize-scss": "^7.0.0",
"parcel": "^2.3.1",
"postcss": "^8.4",
"postcss-modules": "^4.3.0",
"postcss-preset-env": "^7.2.3",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"typescript": "^4.4.4"
},
"dependencies": {
"classnames": "^2.2.5",
"normalize-scss": "^7.0.0",
"open-color": "^1.7.0",
"postcss-loader": "^3.0.0",
"style-loader": "^1.0.1"
"open-color": "^1.7.0"
},
"peerDependencies": {
"prop-types": "^15.6.0",
"react": "^16.10.2",
"react": "^16.12.0",
"typeface-roboto": "^0.0.75"
},
"alias": {
"window-manager": "./src/index.ts"
},
"browserslist": "last 2 Chrome versions, last 2 Safari versions, last 2 Firefox versions"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc