UNPKG

@cocalc/static

Version:

CoCalc's static frontend Webpack-based build system and framework

1 lines 11.4 kB
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[8840],{23595:(e,t,n)=>{n.d(t,{r:()=>i});var r=n(85460),o=n(24620);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.frame_tree_actions=t,this.id=n,this.setState({mode:"escape"});for(var o=0,i=["sel_ids","md_edit_ids"];o<i.length;o++){var l=i[o];this.setState(a({},l,this.get(l,(0,r.Set)()).toSet()))}}var t=e.prototype;return t.get=function(e,t){return this.frame_tree_actions._get_frame_data(this.id,e,t)},t.getIn=function(e,t){if(0!=e.length){if(1==e.length)return this.frame_tree_actions._get_frame_data(this.id,e[0],t);var n=this.frame_tree_actions._get_frame_data(this.id,e[0]);return null!=n&&"function"==typeof n.getIn?n.getIn(e.slice(1),t):t}},t.setState=function(e){this.frame_tree_actions.set_frame_data((0,o.merge)({id:this.id},e))},t.close=function(){(0,o.close)(this)},t.get_cur_cell_index=function(){return this.frame_tree_actions.jupyter_actions.store.get_cell_index(this.get("cur_id"))},t.get_selected_cell_ids=function(){var e={},t=this.get("cur_id");null!=t&&(e[t]=!0);var n=this.get("sel_ids");return null!=n&&n.forEach((function(t){e[t]=!0})),e},t.get_selected_cell_ids_list=function(){var e=this.get_selected_cell_ids(),t=[],n=this.frame_tree_actions.jupyter_actions.store.get("cell_list");return null==n||n.forEach((function(n){e[n]&&t.push(n)})),t},e}()},36651:(e,t,n)=>{n.d(t,{B5:()=>m,Dl:()=>y,M7:()=>v});var r=n(24620),o=n(85460),a=n(32295),i=n(431),l=n(92990);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function _(e,t){return!t||"object"!==p(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function g(e,t){return g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},g(e,t)}function d(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var p=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var h=void 0;function m(e,t){return(0,r.startswith)(e,"sage")?"sage":t}var v={check_select_kernel_init:!1,show_kernel_selector:!1,widgetModelIdState:(0,o.Map)(),cell_list:(0,o.List)(),cells:(0,o.Map)()},y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t)}(u,e);var t,n,a=(t=u,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=f(t);if(n){var o=f(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return _(this,e)});function u(){var e;return s(this,u),(e=a.apply(this,arguments)).get_selected_cell_ids=function(){return e.deprecated("get_selected_cell_ids"),{}},e.get_cell_list=function(){var t;return null!==(t=e.get("cell_list"))&&void 0!==t?t:(0,o.List)()},e.get_selected_cell_ids_list=function(){return e.deprecated("get_selected_cell_ids_list"),[]},e.set_global_clipboard=function(e){h=e},e.get_global_clipboard=function(){return h},e.get_local_storage=function(t){var n=(0,i.sK)(e.name);if(null!=n)try{var o="string"==typeof n?(0,r.from_json)(n):n;if(null!=o)return o[t]}catch(t){(0,i.bV)(e.name)}},e.get_kernel_info=function(t){var n=void 0,r=e.get("kernels");if(null!=r)return r.forEach((function(e){if(e.get("name")===t)return n=e.toJS(),!1})),n},e.get_ipynb=function(t){if(null!=e.get("cells")&&null!=e.get("cell_list")){var n=e.get("cell_list"),r={},o=!0,a=!1,i=void 0;try{for(var u,c=n.toJS()[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var s=u.value,f=e.get_more_output(s);null!=f&&(r[s]=f)}}catch(e){a=!0,i=e}finally{try{o||null==c.return||c.return()}finally{if(a)throw i}}return(0,l.m)({cells:e.get("cells"),cell_list:n,metadata:e.get("metadata"),kernelspec:e.get_kernel_info(e.get("kernel")),language_info:e.get_language_info(),blob_store:t,more_output:r})}},e.get_more_output=function(t){if(e._is_project){null==e._more_output&&(e._more_output={});var n=e._more_output[t];if(null==n)return;for(var r=n.messages,o=0,a=["discarded","truncated"];o<a.length;o++){var i=a[o];if(n[i]){var l=[{text:"truncated"===i?"WARNING: some intermediate output was truncated.\n":"WARNING: ".concat(n[i]," intermediate output ").concat(n[i]>1?"messages were":"message was"," ").concat(i,".\n"),name:"stderr"}];r=r.length>0?l.concat(r).concat(l):l}}return r}var u=e.getIn(["more_output",t,"mesg_list"]);if(null!=u)return u.toJS()},e.get_default_kernel=function(){var t=e.redux.getStore("account");return null!=t?t.getIn(["editor_settings","jupyter","kernel"]):void 0},e.get_kernel_selection=function(e){var t={};return e.filter((function(e){return null!=e.get("language")})).groupBy((function(e){return e.get("language")})).forEach((function(e,n){var o=e.sort((function(e,t){var n=-e.getIn(["metadata","cocalc","priority"],0),o=-t.getIn(["metadata","cocalc","priority"],0);return(0,r.cmp)(n,o)})).first();if(null==o||null==n)return!0;var a=o.get("name");if(null==a)return!0;t[n]=a})),(0,o.Map)(t)},e.get_kernels_by_name_or_language=function(e){var t={},n={};e.map((function(e){var r=e.get("name"),o=e.get("language");null!=r&&(t[r]=e),function(e,t){null==n[e]&&(n[e]=[]),n[e].push(t)}(null==o?"misc":o,e)}));var r=(0,o.OrderedMap)(t).sortBy((function(e,t){return e.get("display_name",e.get("name",t)).toLowerCase()}));return n=(0,o.fromJS)(n).map((function(e,t){return e.sortBy((function(e){return e.get("display_name",e.get("name",t)).toLowerCase()})).map((function(e){return e.get("name")}))})),[r,(0,o.OrderedMap)(n).sortBy((function(e,t){return t.toLowerCase()}))]},e.get_raw_link=function(t){return e.redux.getProjectStore(e.get("project_id")).get_raw_link(t)},e}var p=u.prototype;return p.deprecated=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o,a="DEPRECATED JupyterStore."+e;(o=console).warn.apply(o,[a].concat(d(n)))},p.get_cell_ids_list=function(){return this.get_cell_list().toJS()},p.get_cell_type=function(e){var t=this.unsafe_getIn(["cells",e,"cell_type"],"code");if("markdown"!=t&&"code"!=t&&"raw"!=t)throw Error("invalid cell type ".concat(t," for cell ").concat(e));return t},p.get_cell_index=function(e){var t=this.get("cell_list");if(null==t)throw Error("ordered list of cell id's not known");var n=t.indexOf(e);if(-1===n)throw Error("unknown cell id ".concat(e));return n},p.get_cell_id=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,n=this.get_cell_index(t);n+=e;var r=this.get("cell_list");if(!(null==r||n<0||n>=r.size))return r.get(n)},p.get_language_info=function(){for(var e=0,t=["backend_kernel_info","metadata"];e<t.length;e++){var n=t[e],r=this.unsafe_getIn([n,"language_info"]);if(null!=r)return r}},p.get_cm_mode=function(){var e,t,n=this.get("backend_kernel_info");if(null==n&&(n=this.get("metadata")),null!=(e=null!=n?n.toJS():void 0)&&(null!=e.language_info&&null!=e.language_info.codemirror_mode?t=e.language_info.codemirror_mode:null!=e.language_info&&null!=e.language_info.name?t=e.language_info.name:null!=e.kernelspec&&null!=e.kernelspec.language&&(t=e.kernelspec.language.toLowerCase())),null==t){var r=this.get("kernel");null!=r&&(t=-1!=(r=r.toLowerCase()).indexOf("python")?-1!=r.indexOf("python3")?{name:"python",version:3}:{name:"python",version:2}:-1!=r.indexOf("sage")||-1!=r.indexOf("anaconda")?{name:"python",version:3}:-1!=r.indexOf("octave")?"octave":-1!=r.indexOf("bash")?"shell":-1!=r.indexOf("julia")?"text/x-julia":-1!=r.indexOf("haskell")?"text/x-haskell":-1!=r.indexOf("javascript")?"javascript":-1!=r.indexOf("ir")?"r":-1!=r.indexOf("root")||-1!=r.indexOf("xeus")?"text/x-c++src":-1!=r.indexOf("gap")?"gap":{name:"python",version:3})}return"string"==typeof t&&(t={name:t}),t},p.is_cell_editable=function(e){return this.get_cell_metadata_flag(e,"editable",!0)},p.is_cell_deletable=function(e){return!!this.is_cell_editable(e)&&this.get_cell_metadata_flag(e,"deletable",!0)},p.get_cell_metadata_flag=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.unsafe_getIn(["cells",e,"metadata",t],n)},p.get_kernel_language=function(){return m(this.get("kernel"),this.getIn(["kernel_info","language"]))},p.get_kernel_syntax=function(){var e=this.get_kernel_language();if(e)switch(e=e.toLowerCase()){case"python":case"python3":return"python3";case"r":return"R";case"c++":case"c++17":return"c++";case"javascript":return"JavaScript"}},p.jupyter_kernel_key=function(){var e,t=this;return(e=function(){var e,n,r,o;return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(a){switch(a.label){case 0:return e=t.get("project_id"),n=t.redux.getStore("projects"),[4,t.redux.getStore("customize").getDefaultComputeImage()];case 1:return r=a.sent(),o=n.getIn(["project_map",e,"compute_image"],r),[2,[e,o].join("::")]}}))},function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){c(a,r,o,i,l,"next",e)}function l(e){c(a,r,o,i,l,"throw",e)}i(void 0)}))})()},u}(a.Store)}}]);