@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 9.79 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[9749],{69749:(t,e,n)=>{n.r(e),n.d(e,{Actions:()=>R});var r=n(56160),o=n(20812),i=n(85460),u=n(4538),c=n(38198),a=n(24620),s=n(94873);function l(t,e,n,r,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void n(t)}c.done?e(a):Promise.resolve(a).then(r,o)}function f(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function u(t){l(i,r,o,u,c,"next",t)}function c(t){l(i,r,o,u,c,"throw",t)}u(void 0)}))}}var _=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},d=(0,r.reuseInFlight)((function(t,e,n,r){return h.apply(this,arguments)}));function h(){return(h=f((function(t,e,n,r){var o,i,u;return _(this,(function(c){switch(c.label){case 0:return o=(0,a.path_split)(e),i=o.tail,u=n.indexOf("self_contained")>=0||n.indexOf("output:")>=0?"rmarkdown::render('".concat(i,"', output_format = NULL, run_pandoc = TRUE)"):"rmarkdown::render('".concat(i,"', output_format = NULL, run_pandoc = TRUE, output_options = list(self_contained = FALSE))"),[4,(0,s.GL)({timeout:240,bash:!0,command:"Rscript",args:["-e",u],env:{MPLBACKEND:"Agg"},project_id:t,path:o.head,err_on_exit:!1,aggregate:{value:r}})];case 1:return[2,c.sent()]}}))}))).apply(this,arguments)}var p=n(1527),y=n(32295),b=n(11737);function v(t,e,n,r,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void n(t)}c.done?e(a):Promise.resolve(a).then(r,o)}function m(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function u(t){v(i,r,o,u,c,"next",t)}function c(t){v(i,r,o,u,c,"throw",t)}u(void 0)}))}}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function w(t,e,n){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=k(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}},w(t,e,n||t)}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function x(t,e){return!e||"object"!==O(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function S(t,e){return S=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},S(t,e)}var O=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};var P=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},R=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&S(t,e)}(s,t);var e,n,c=(e=s,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(t){return!1}}(),function(){var t,r=k(e);if(n){var o=k(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return x(this,t)});function s(){var t;return g(this,s),(t=c.apply(this,arguments))._last_rmd_hash=null,t.is_building=!1,t}var l=s.prototype;return l._init2=function(){w(k(s.prototype),"_init2",this).call(this),this.is_public||(this._syncstring.once("ready",this._init_rmd_converter.bind(this)),this._check_produced_files(),this.setState({custom_pdf_error_message:'\nTo create a PDF document from R Markdown, you specify the `pdf_document` output format in the\nYAML metadata by putting this code at the top of your file:\n\n```\n---\ntitle: "My Document"\nauthor: CoCalc User\ndate: Sept 27, 2019\noutput: pdf_document\n---\n```\n\nWithin a document that generates PDF output, you can use raw LaTeX, and even define LaTeX macros.\n\nOnce you make the above change, the HTML output will no longer be updated. If you would\nlike to switch back to HTML output, delete the output line or replace it with\n```\noutput: html_document\n```\n'}))},l.do_implicit_builds=function(){var t=this.redux.getStore("account");return null==t||!!t.getIn(["editor_settings","build_on_save"])},l._init_rmd_converter=function(){var t,e=this;this.run_rmd_converter=(0,o.debounce)((t=m((function(t){return P(this,(function(n){switch(n.label){case 0:return[4,e._run_rmd_converter(t)];case 1:return[2,n.sent()]}}))})),function(e){return t.apply(this,arguments)}),5e3,{leading:!0,trailing:!1});var n=this,i=(0,r.reuseInFlight)(m((function(){var t;return P(this,(function(e){switch(e.label){case 0:return n.do_implicit_builds()?null==n._syncstring?[2]:(t=n._syncstring.hash_of_saved_version(),n._last_rmd_hash==t?[3,2]:(n._last_rmd_hash=t,[4,n.run_rmd_converter()])):[2];case 1:e.sent(),e.label=2;case 2:return[2]}}))})));this._syncstring.on("save-to-disk",i),this._syncstring.on("after-change",i),this.run_rmd_converter()},l.build=function(t){var e=this;return m((function(){var n;return P(this,(function(r){switch(r.label){case 0:if(t&&(n=e._get_cm(t))&&n.focus(),e.is_building)return[2];e.is_building=!0,r.label=1;case 1:return r.trys.push([1,,4,5]),[4,e.redux.getEditorActions(e.project_id,e.path).save(!1)];case 2:return r.sent(),[4,e.run_rmd_converter(Date.now())];case 3:return r.sent(),[3,5];case 4:return e.is_building=!1,[7];case 5:return[2]}}))}))()},l._check_produced_files=function(){var t=this;return m((function(){var e,n,r,o,c,s,l,f,_;return P(this,(function(d){switch(d.label){case 0:return e=function(e,n){var r=n[e],o=(0,b.l)(t.path,r);s.some((function(t){return t.get("name")===(0,a.path_split)(o).tail}))&&(l=l.add(r))},null==(n=y.redux.getProjectActions(t.project_id))?[2]:(r=(0,a.path_split)(t.path).head,[4,(0,u.callback2)(n.fetch_directory_listing,{path:r})]);case 1:if(d.sent(),null==(o=n.get_store()))return[2];if(null==(c=o.get("directory_listings")))return[2];if(null==(s=c.get(r)))return[2];for(l=(0,i.Set)(),f=0,_=["pdf","html","nb.html"];f<_.length;f++)e(f,_);return t.setState({derived_file_types:l}),[2]}}))}))()},l.set_log=function(t){this.setState({build_err:null==t?void 0:t.stderr.trim(),build_log:null==t?void 0:t.stdout.trim(),build_exit:null==t?void 0:t.exit_code})},l._run_rmd_converter=function(t){var e=this;return m((function(){var n,r,o,i,u,c,a;return P(this,(function(s){switch(s.label){case 0:if(null==e._syncstring||"ready"!=e._syncstring.get_state())return[2];if(null==e._last_rmd_hash&&(e._last_rmd_hash=e._syncstring.hash_of_saved_version()),null==(n=e._syncstring.to_str()))return[2];e.set_status("Running RMarkdown..."),e.setState({building:!0}),e.set_error(""),e.setState({build_log:"",build_err:""}),r="",o=void 0,s.label=1;case 1:return s.trys.push([1,6,7,8]),i=(0,p.markdown_to_html_frontmatter)(n),u=i.frontmatter,c=i.html,r=c,[4,d(e.project_id,e.path,u,t||e._last_rmd_hash)];case 2:return o=s.sent(),e.set_log(o),null!=o&&0==o.exit_code?[3,3]:(e.set_error("Error compiling RMarkdown. Please check the Build Log!"),[3,5]);case 3:return e.reload(),[4,e._check_produced_files()];case 4:s.sent(),s.label=5;case 5:return[3,8];case 6:return a=s.sent(),e.set_error(a,"monospace"),e.set_log(o),[2];case 7:return e.set_status(""),e.setState({building:!1}),[7];case 8:return e.setState({value:r}),[2]}}))}))()},l._raw_default_frame_tree=function(){return this.is_public?{type:"cm"}:{direction:"col",type:"node",first:{type:"cm"},second:{type:"node",direction:"row",first:{type:"iframe"},second:{type:"build"},pos:.8}}},l.reload=function(t,e){var n=this;e=e||Date.now(),["iframe","pdfjs_canvas","markdown"].forEach((function(t){return n.set_reload(t,e)}))},l.delete_trailing_whitespace=function(){},s}(c.Actions)}}]);