@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 16.4 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[4669],{54669:(e,t,n)=>{n.r(t),n.d(t,{Editor:()=>D,launcher:()=>I,x11:()=>S});var i=n(28459),r=n(85460),a=n(95788),o=n(32295),c=n(20812),l=n(24620),s=n(19990),u="#eee",d="#458ac9";function f(e,t,n,i,r,a,o){try{var c=e[a](o),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(i,r)}function p(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var a=e.apply(t,n);function o(e){f(a,i,r,o,c,"next",e)}function c(e){f(a,i,r,o,c,"throw",e)}o(void 0)}))}}var m=function(e,t){var n,i,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},b=o.React.memo((function(e){var t,n,i=e.id,r=e.info,a=e.actions,c=e.is_current;function l(){return(l=p((function(e){var t;return m(this,(function(n){return f(e),t=r.get("wid"),a.close_window(i,t),e.stopPropagation(),[2]}))}))).apply(this,arguments)}function f(e){return b.apply(this,arguments)}function b(){return(b=p((function(e){var t;return m(this,(function(n){return a.set_active_id(i),a.set_focused_window_in_frame(i,r.get("wid")),null===(t=a.client)||void 0===t||t.focus(),e.stopPropagation(),[2]}))}))).apply(this,arguments)}return o.React.createElement("div",{onClick:f,style:{display:"inline-block",width:"250px",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",margin:"5px 0 5px 5px",borderRight:"1px solid #aaa",background:c?d:u,color:c?u:d}},(t=c?u:d,n=c?d:u,o.React.createElement("div",{style:{float:"right",backgroundColor:n,color:t,position:"relative",padding:"0 5px"},onClick:function(e){return l.apply(this,arguments)}},o.React.createElement(s.Icon,{name:"times"}))),r.get("icon")?o.React.createElement("img",{height:"20px",style:{paddingRight:"5px"},src:r.get("icon")}):o.React.createElement(s.Icon,{name:"file",style:{height:"20px",paddingRight:"5px"}}),r.get("title"))}),(function(e,t){return e.info.equals(t.info)&&e.is_current===t.is_current&&e.id===t.id})),g=n(4538);function h(e,t,n,i,r,a,o){try{var c=e[a](o),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(i,r)}function y(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var a=e.apply(t,n);function o(e){h(a,i,r,o,c,"next",e)}function c(e){h(a,i,r,o,c,"throw",e)}o(void 0)}))}}var v=function(e,t){var n,i,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},w=o.React.memo((function(e){var t,n=function(){var e=o.ReactDOM.findDOMNode(I.current);$(e).trigger("focus");var t=d.client;null!=t&&t.focus()},i=function(){d.x11_not_idle()},d=e.actions,f=e.name,p=e.id,m=e.desc,h=e.is_current,w=e.font_size,_=e.reload,x=e.editor_settings,k=e.resize,R=(0,o.useIsMountedRef)(),E=(0,o.useRef)(!1),S=(0,o.useRef)(null),I=(0,o.useRef)(null),A=null!==(t=(0,o.useTypedRedux)("account","font_size"))&&void 0!==t?t:14,D=(0,o.useRedux)(f,"windows"),C=(0,o.useRedux)(f,"x11_is_idle"),P=(0,o.useRedux)(f,"disabled"),z=(0,o.useRedux)(f,"config_unknown"),M=(0,c.debounce)((function(){var e=d.client;if(null!=e){var t=m.get("wid");if(null!=t){var n=$(o.ReactDOM.findDOMNode(S.current)),i=n.width(),r=n.height();if(null!=i&&null!=r){var a=w/A;e.resize_window(t,i,r,a)}}}}),200,{leading:!0,trailing:!0});(0,o.useEffect)((function(){d.set_physical_keyboard(x.get("physical_keyboard"),x.get("keyboard_variant"))}),[x.get("physical_keyboard"),x.get("keyboard_variant")]),(0,o.useEffect)((function(){M()}),[k,m.get("font_size"),_]),(0,o.useEffect)((function(){h&&n()}),[h]),(0,o.useEffect)((function(){V()}),[m.get("wid")]),(0,o.useEffect)((function(){E.current||null==m.get("wid")||V()}),[D,m.get("wid")]);var O=(0,o.usePrevious)(D),G=(0,o.useMemo)((function(){var e=m.get("wid");return null==D?void 0:D.getIn([e,"children"],(0,r.Set)())}),[D,m.get("wid")]),T=(0,o.usePrevious)(G);function V(){return X.apply(this,arguments)}function X(){return(X=y((function(){var e,t,n;return v(this,(function(i){switch(i.label){case 0:if(!R.current)return[2];if(e=o.ReactDOM.findDOMNode(S.current),null==(t=d.client))return[2];if(null==(n=m.get("wid")))return E.current=!1,$(e).empty(),[2];i.label=1;case 1:return i.trys.push([1,3,,4]),t.insert_window_in_dom(n,e),[4,q(D.getIn([n,"children"],(0,r.Set)()))];case 2:return i.sent(),[3,4];case 3:return i.sent(),E.current=!1,$(e).empty(),[2];case 4:return M(),E.current=!0,[4,(0,a.delay)(0)];case 5:return i.sent(),R.current&&n===m.get("wid")?(M(),h&&t.focus_window(n),[2]):[2]}}))}))).apply(this,arguments)}function q(e){return L.apply(this,arguments)}function L(){return(L=y((function(e){var t;return v(this,(function(n){switch(n.label){case 0:return null==(t=d.client)?[2]:(e.forEach((function(e){t.insert_child_in_dom(e)})),[4,(0,a.delay)(0)]);case 1:return n.sent(),M(),[2]}}))}))).apply(this,arguments)}if((0,o.useEffect)((function(){null!=D&&O!==D&&E.current&&(G.equals(T)||q(G.subtract(T)))}),[D,O,G,T]),(0,o.useEffect)((function(){if(null!=D){var e=m.get("wid");q(null==D?void 0:D.getIn([e,"children"],(0,r.Set)()))}}),[D,m.get("wid")]),(0,o.useEffect)((function(){var e,t=(e=y((function(){return v(this,(function(e){return[2,(0,g.retry_until_success)({f:y((function(){return v(this,(function(e){if(null==o.ReactDOM.findDOMNode(S.current))throw new Error("x11 window node not yet available");return t=o.ReactDOM.findDOMNode(S.current),$(t).on("contextmenu",(function(){return!1})),[2];var t}))})),max_time:6e4,max_delay:150})]}))})),function(){return e.apply(this,arguments)});return t(),d.set_physical_keyboard(x.get("physical_keyboard"),x.get("keyboard_variant")),function(){E.current=!1}}),[]),null==P||null==z)return o.React.createElement(s.Loading,null);if(P){var N=z?"There is no X11 configuration information available. You might have to restart this project":"";return o.React.createElement("div",{className:"smc-vfill",style:{padding:"100px auto auto auto"}},"X11 is not available for this project. ",N)}return o.React.createElement("div",{className:"smc-vfill",style:{position:"relative"}},function(){if(C)return o.React.createElement("div",{onClick:i,style:{position:"absolute",fontSize:"36pt",color:"white",backgroundColor:"#458ac9",textAlign:"center",width:"100%",height:"100%",cursor:"pointer",zIndex:1,opacity:.7}},"Idle",o.React.createElement("br",null),"(click to resume)")}(),o.React.createElement("div",{style:{borderBottom:"1px solid lightgrey",background:u,display:"inline-flex"}},function(){var e=[];if(null==D)return e;var t=D.keySeq().toJS();t.sort(l.cmp);var n=!0,i=!1,r=void 0;try{for(var a,c=t[Symbol.iterator]();!(n=(a=c.next()).done);n=!0){var s=a.value;D.getIn([s,"parent"])||e.push(o.React.createElement(b,{id:p,key:s,is_current:s===m.get("wid"),info:D.get(s),actions:d}))}}catch(e){i=!0,r=e}finally{try{n||null==c.return||c.return()}finally{if(i)throw r}}return e}()),o.React.createElement("textarea",{style:{opacity:0,position:"absolute",height:0,width:0,top:0},"aria-multiline":"false",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,tabIndex:0,ref:I,onBlur:function(){var e;null!=(e=d.client)&&e.blur()},onPaste:function(e){return function(e){var t=e.clipboardData.getData("Text");return d.paste(p,t),!1}(e)}}),o.React.createElement("div",{className:"smc-vfill",ref:S,style:{position:"relative"},onClick:function(){n()}}))}),(function(e,t){return!(0,l.is_different)(e,t,["id","desc","windows","is_current","resize","reload"])&&e.editor_settings.get("physical_keyboard")==t.editor_settings.get("physical_keyboard")&&e.editor_settings.get("keyboard_variant")==t.editor_settings.get("keyboard_variant")&&e.desc.get("font_size")==t.desc.get("font_size")})),_=n(33667),x=Object.freeze({unknown_test:{icon:"skull-crossbones",desc:"I don't exist, I'm just a test",label:"Unknown App"},drracket:{icon:"scheme",label:"DrRacket",desc:"Racket is a general-purpose programming language as well as the world’s first ecosystem for language-oriented programming."},emacs:{icon:"emacs",desc:"An extensible, customizable, text editor — and more.",label:"Emacs"},gvim:{icon:"vim",desc:"The ubiquitous text editor",label:"Vim"},inkscape:{icon:"inkscape",desc:"Vector graphics editor",label:"Inkscape"},gimp:{icon:"brush",desc:"Image editing",label:"GIMP"},krita:{icon:"brush",desc:"Image editing",label:"Krita"},vscode:{label:"VS Code",command:"code",icon:"vscode",desc:"Visual Studio code"},terminal:{label:"Terminal",command:"gnome-terminal",icon:"terminal",desc:"Command line terminal"},firefox:{icon:"firefox",desc:"A powerful free web browser backed by Mozilla",label:"Firefox"},gitk:{icon:"git",desc:"Explore Git repository in current directory"},gitg:{icon:"git",desc:"GNOME's client to work with Git repositories"},idle:{icon:"python",desc:"Minimalistic Python IDE",label:"IDLE"},okular:{icon:"file-pdf",desc:"PDF reader and annotator (Tools → Review)",label:"Okular"},libreoffice:{icon:"libreoffice",desc:"A powerful office suite (spreadsheet, word processor, presentations, etc. -- open Word, Excel, Powerpoint, etc.)",label:"LibreOffice"},lowriter:{desc:"LibreOffice Writer",icon:"libreoffice",label:"Writer"},localc:{desc:"LibreOffice Calc",icon:"libreoffice",label:"Calc"},loimpress:{desc:"LibreOffice Impress",icon:"libreoffice",label:"Impress"},nteract:{command:"nteract",icon:"cube",desc:"A desktop Jupyter Notebook Client",label:"nteract"},wxmaxima:{icon:"square-root-alt",desc:"A legendary computer algebra system",label:"Maxima"},rstudio:{icon:"r",desc:"An integrated development environment (IDE) for R. RStudio, Inc. is in no way affiliated with CoCalc",label:"RStudio"},octave:{icon:"octave",desc:"Scientific programming largely compatible with Matlab",label:"Octave",command:"octave-gui"},texmacs:{icon:"tex-file",desc:"A wysiwyw (what you see is what you want) editing platform with special features for scientists",label:"TeXMacs"},texstudio:{icon:"tex-file",desc:"An integrated writing environment for creating LaTeX documents",label:"TeXstudio"},openmodelica:{icon:"cogs",desc:"an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage",label:"OpenModelica",command:"OMEdit"},pspp:{icon:"table",desc:"Statistical analysis of sampled data, similar to SPSS",label:"PSPP",command:"psppire"},gnumeric:{icon:"table",desc:"Gnumeric is a spreadsheet, a computer program used to manipulate and analyze numeric data",label:"Gnumeric",command:"gnumeric"},scribus:{icon:"address-card",desc:"a page layout program",command:"scribus",label:"Scribus"},spyder:{command:"spyder",desc:"Spyder is a powerful scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts.",icon:"python",label:"Spyder"},gchempaint:{desc:"GChemPaint is a 2D chemical structures editor.",icon:"atom",label:"GChemPaint"},diffpdf:{desc:"compare two PDF files textually or visually",icon:"copy",label:"DiffPDF"},"massif-visualizer":{desc:"Visualize output generated by Valgrind's massif tool",icon:"areaChart",label:"Massif Visualizer"},kcachegrind:{desc:"Inspect Callgrind (Valgrind) output",icon:"search",label:"KCachegrind"},dia:{desc:"Dia is a program to draw structured diagrams.",icon:"flow-chart",label:"Dia"},pycharm:{command:"pycharm.sh",desc:"A powerful and smart IDE for productive Python development.",icon:"python",label:"PyCharm"},intellij:{label:"IntelliJ IDEA",desc:"A powerful and smart IDE for productive JAVA development.",command:"idea.sh",icon:"lightbulb"},sqlitebrowser:{label:"SQLite",desc:"A high quality, visual, open source tool to create, design, and edit database files compatible with SQLite.",icon:"database"},avogadro:{label:"Avogadro",desc:"An advanced molecule editor and visualizer designed for cross-platform use in computational chemistry, molecular modeling, bioinformatics, materials science, and related areas",icon:"atom"},shotwell:{label:"Shotwell",desc:"Shotwell is a personal photo manager.",icon:"camera"},evince:{label:"Evince",icon:"file-pdf",desc:"A document viewer for PDF, PostScript, DVI, DjVu, ..."},calibre:{label:"Calibre",icon:"book",desc:"A powerful and easy to use e-book manager"},qgis:{label:"QGIS",icon:"qgis",desc:"A user friendly Open Source Geographic Information System."},grass:{label:"GRASS",icon:"grass",desc:"Geographic Resources Analysis Support System"},ds9:{icon:"sun",label:"SAOImage DS9",desc:"An astronomical imaging and data visualization application."},xcas:{icon:"square-root-alt",label:"Xcas",desc:"An interface to perform computer algebra, function graphs, interactive geometry (2-d and 3-d), spreadsheet and statistics, programmation."},"gnome-system-monitor":{icon:"microchip",label:"System Monitor",desc:"Shows you what programs are running and how much processor time, memory, and disk space are being used."},gedit:{icon:"edit",label:"Gedit",desc:"The GNOME text editor"},scilab:{desc:"A free and open source software for engineers & scientists",label:"Scilab",icon:"calculator"},cadabra2:{command:"cadabra2-gtk",icon:"square-root-alt",label:"Cadabra 2",desc:"A field-theory motivated approach to computer algebra"},"vqe-playground":{icon:"atom",label:"VQE Playground",desc:"Gaining intuition about Variational Quantum Eigensolver"},kbibtex:{icon:"tex-file",label:"KBibTeX",desc:"A reference management software primarily for BibTeX"},texmaker:{icon:"tex-file",label:"TeXmaker",desc:"Free cross-platform LaTeX editor since 2003"}}),k=Object.freeze((0,c.sortBy)((0,c.keys)(x),(function(e){return(x[e].label||e).toLowerCase()}))),R=o.React.memo((function(e){var t,n=e.actions,i=e.name,r=(0,o.useRedux)(i,"x11_apps"),a=(0,c.debounce)((function(e){var t=x[e];null!=t&&n.launch(t.command?t.command:e,t.args)}),1e3,{leading:!0,trailing:!1});return o.React.createElement("div",{style:{overflowY:"auto",padding:"5px"}},null==(t=r)?[]:k.filter((function(e){return!1!==t.get(e)})).map((function(e){var t=x[e];if(null!=t){var n=void 0;return null!=t.icon&&(n=o.React.createElement(s.Icon,{name:t.icon,style:{marginRight:"5px"}})),o.React.createElement(_.zx,{key:e,onClick:function(){return a(e)},title:t.desc,style:{margin:"5px"}},n,t.label?t.label:e)}})))}),(function(e,t){return!0})),E=n(96396),S={short:"X11",name:"X11",icon:"window-restore",component:w,buttons:(0,l.set)(["decrease_font_size","increase_font_size","set_zoom","reload","copy","paste","close_and_halt","help","connection_status"])},I={short:"Apps",name:"Applications",icon:"server",component:R,buttons:(0,l.set)([])},A={x11:S,terminal:E.terminal,launcher:I},D=(0,i.J)({format_bar:!1,editor_spec:A,display_name:"X11"})}}]);