UNPKG

delight

Version:

## How to use

3 lines 6.17 kB
#!/usr/bin/env node module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=9)}([function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("@babel/runtime/regenerator")},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("express")},function(t,e){t.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(t,e){t.exports=require("directory-tree")},function(t,e){t.exports=require("body-parser")},function(t,e){t.exports=require("@babel/traverse")},function(t,e){t.exports=require("@babel/parser")},function(t,e,n){t.exports=n(10)},function(t,e,n){"use strict";n.r(e);var r=n(3),o=n.n(r),s=n(12).default;var i=parseInt(3e3,10);e.default=o()().use((function(t,e){return s.handle(t,e)})).listen(i,(function(){console.log("> App started http://localhost:".concat(i))}))},function(t){t.exports=JSON.parse('{"client":{"css":"/static/css/bundle.4615ef3a.css","js":"/static/js/bundle.4615ef3a.js"},"":{"json":"/..\\\\chunks.json","js":["/css.worker.js","/editor.worker.js","/html.worker.js","/json.worker.js","/static/js/0.93eb137f.chunk.js","/static/js/2.73eb6055.chunk.js","/static/js/3.1dab0744.chunk.js","/static/js/4.c6b536c8.chunk.js","/static/js/5.ebce39fb.chunk.js","/static/js/6.a12c5b6b.chunk.js","/static/js/7.2ab96012.chunk.js","/ts.worker.js"],"ico":"/favicon.ico","txt":["/robots.txt","/static/js/bundle.4615ef3a.js.LICENSE.txt","/ts.worker.js.LICENSE.txt"],"ttf":"/static/media/codicon.4940682e.ttf"}}')},function(t,e,n){"use strict";n.r(e);var r=n(3),o=n.n(r),s=n(6),i=n.n(s),c=n(1),a=n.n(c),u=n(4),l=n.n(u),p=n(0),f=n(5),d=n.n(f),j=n(7),b=n.n(j),v=n(8);function y(t){var e,n,r,o=(n="TSX"===function(t){var e=t.split(".").pop();return"js"===e?"JS":"ts"===e?"TS":"tsx"===e?"TSX":"jsx"===e?"JSX":"UNSUPPORTED"}(e=t)?"typescript":"flow",r=Object(p.readFileSync)(e,"utf-8"),v.parse(r,{sourceType:"module",plugins:["jsx","classProperties","dynamicImport","nullishCoalescingOperator","optionalChaining",n]})),s=[];return b()(o,{FunctionDeclaration:function(e){var n,r;s.push({name:(null===(n=e.node.id)||void 0===n?void 0:n.name)||"",fileName:t,loc:null===(r=e.node.id)||void 0===r?void 0:r.loc})},InterfaceDeclaration:function(e){var n,r;s.push({name:(null===(n=e.node.id)||void 0===n?void 0:n.name)||"",fileName:t,loc:null===(r=e.node.id)||void 0===r?void 0:r.loc})},VariableDeclarator:function(e){var n;s.push({name:e.node.id.name||"",fileName:t,loc:null===(n=e.node.id)||void 0===n?void 0:n.loc})}}),s}var h,m=n(2);function x(){var t=Object(p.readFileSync)(Object(m.join)(process.cwd(),"package.json"),"utf-8"),e=JSON.parse(t);return{docsDirectory:Object(m.join)(process.cwd(),e.codeDocs.directory),rootDirectory:process.cwd()}}h=n(11);var S,w=o()().disable("x-powered-by").use(o.a.static(Object(m.join)(__dirname,"public"))).use(i.a.json()).get("/",(function(t,e){e.send('<!doctype html>\n <html lang="">\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <meta charSet=\'utf-8\' />\n <title>Razzle TypeScript</title>\n <meta name="viewport" content="width=device-width, initial-scale=1">\n '.concat(h.client.css?'<link rel="stylesheet" href="'.concat(h.client.css,'">'):"","\n ").concat('<script src="'.concat(h.client.js,'" defer><\/script>'),'\n </head>\n <body>\n <div id="root"></div>\n </body>\n</html>'))}));(S=w).post("/api/file/getContent",(function(t,e){e.status(200).json({content:Object(p.readFileSync)(t.body.path,"utf-8")})})),S.get("/api/files",(function(t,e){var n=x(),r=d()(n.rootDirectory,{extensions:/\.(ts|js|jsx|tsx)$/,exclude:[/node_modules/,/.git/]});e.status(200).json({files:r})})),S.post("/api/file/getFileSymbols",(function(t,e){var n=y(t.body.path);e.status(200).json({symbol:n})})),S.get("/api/docs",(function(t,e){var n=x(),r=d()(n.docsDirectory,{extensions:/\.json/});e.status(200).json({docs:r})})),S.post("/api/docs/create",function(){var t=l()(a.a.mark((function t(e,n){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Object(p.writeFileSync)(Object(m.join)(e.body.path,e.body.name),"{}"),n.status(200).json({});case 2:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),S.post("/api/doc/save",function(){var t=l()(a.a.mark((function t(e,n){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Object(p.writeFileSync)(e.body.path,JSON.stringify(e.body.content),"utf-8"),n.status(200).json({});case 2:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),S.post("/api/doc",function(){var t=l()(a.a.mark((function t(e,n){var r;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=Object(p.readFileSync)(e.body.path,"utf-8"),n.status(200).json(JSON.parse(r));case 2:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),S.post("/api/file/getFilesSymbols",function(){var t=l()(a.a.mark((function t(e,n){var r,o;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.body.items,o=r.map((function(t){return e=t.path,n=t.name,y(e).find((function(t){return t.name===n}));var e,n})),n.status(200).json(o);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());e.default=w}]); //# sourceMappingURL=server.js.map