@liascript/devserver 1.1.24--0.15.12 → 1.1.26--0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,8 +84,8 @@ updated separately, we use two different version, one for the devServer and one
84
84
  for LiaScript.
85
85
 
86
86
  ```text
87
- DevServer: 1.1.24
88
- LiaScript: 0.15.12
87
+ DevServer: 1.1.26
88
+ LiaScript: 0.16.1
89
89
  ```
90
90
 
91
91
  ### `--input`
package/dist/index.js CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ #!/usr/bin/env node
4
+
5
+ #!/usr/bin/env node
6
+
3
7
  var e,o=require("minimist"),t=require("path"),n=require("dotenv"),r=require("express"),i=require("fs"),s=require("cors"),l=require("express-handlebars"),a=require("ip"),c=require("open"),p=require("body-parser"),d=require("reloadsh.js"),h=t.resolve(__dirname,"../src");n.config();const _=r();_.use(p.json());var u="",g="",m="",f=[];const v=`<script>
4
8
  if (!window.LIA) {
5
9
  window.LIA = {}
@@ -34,7 +38,7 @@ events.onmessage = (event) => {
34
38
  };
35
39
  </script>`;function w(o,n){u=o||t.join(h,".."),e=n||t.join(u,"node_modules"),g=t.resolve(t.join(e,"reloadsh.js/reloader.browser.js")),m=t.resolve(t.join(e,"@liascript/editor/dist"))}function y(e,o,t){o.writeHead(200,{"Content-Type":"text/event-stream",Connection:"keep-alive","Cache-Control":"no-cache"});let n=`data:
36
40
 
37
- `;o.write(n);let r=Date.now();f.push({id:r,response:o}),e.on("close",()=>{console.log(`${r} Connection closed`),f=f.filter(e=>e.id!==r)})}w(h);const j=o(process.argv.slice(2));function x(){console.log(" _ _ ____ _ _"),console.log("| | (_) __ _/ ___| ___ _ __(_)_ __ | |_"),console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|"),console.log("| |___| | (_| |___) | (__| | | | |_) | |_ "),console.log("|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|"),console.log(" |_|"),console.log()}(j.v||j.version)&&(console.log("DevServer: 1.1.24"),console.log("LiaScript: 0.15.12"),process.exit()),(j.h||j.help)&&(x(),console.log("-h --help show this help"),console.log("-v --version show version information"),console.log("-i --input input README.md file or folder (default: .)"),console.log("-n --hostname hostname of your server (default: localhost)"),console.log("-p --port used port number (default: 3000)"),console.log("-l --live do live reload on file change"),console.log("-o --open open in default browser"),console.log("-t --test test online on https://LiaScript.github.io"),console.log(),console.log("-r --responsiveVoice add optional responsiveVoice support,"),console.log(" or pass your own responsiveVoice key."),console.log(" Adding this feature might slow down"),console.log(" the reloading speed."),console.log(" For more information visit:"),console.log(" https://responsivevoice.org"),process.exit()),x(),w(j.node_modules);try{!function(e,o,n,r,p,h,f,w){e=e||3e3,o=o||"localhost",h=h||!1,p=p||!1,f=f||!1;var j={path:n=n||".",readme:void 0};if(n){let e=i.lstatSync(n);e.isDirectory()?j.path=n:e.isFile()&&(j.path=t.dirname(n),j.readme=t.basename(n))}_.set("view engine","hbs"),_.engine("hbs",l({layoutsDir:t.resolve(t.join(u,"views/layouts")),defaultLayout:"main",extname:"hbs"})),_.set("views",t.resolve(t.join(u,"views"))),_.get("/",function(e,o){o.redirect("/home")}),_.get("/gotoLine",y),_.get("/home*",function(t,n){let r=j.path+"/"+t.params[0],s=i.lstatSync(r);if(s.isDirectory()){let s=i.readdirSync(r).filter(e=>"."!==e[0]),l="/home",a=t.params[0].split("/").filter(e=>""!==e),c=[];for(let e=0;e<a.length;e++)l+="/"+a[e],c.push({name:a[e],href:l});n.render("main",{layout:"index",path:c,file:s.map(n=>({name:n,href:`http://${o}:${e}/home${t.params[0]}/${n}`,isDirectory:i.lstatSync(r+"/"+n).isDirectory()})).sort((e,o)=>e.isDirectory&&!o.isDirectory?-1:!e.isDirectory&&o.isDirectory?1:e.name.toLocaleLowerCase()<o.name.toLocaleLowerCase()?-1:1)})}else s.isFile()?t.params[0].toLocaleLowerCase().endsWith(".md")?f?n.redirect(`https://LiaScript.github.io/course/?http://${o}:${e}/${t.params[0]}`):n.redirect(`/liascript/index.html?http://${o}:${e}/${t.params[0]}`):n.sendFile(t.params[0],{root:j.path}):n.send("ups, something went wrong")}),_.get("/liascript/",function(e,o){o.redirect("/liascript/index.html")}),_.get("/liascript/index.html",function(e,o){p&&r?i.readFile(m+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
41
+ `;o.write(n);let r=Date.now();f.push({id:r,response:o}),e.on("close",()=>{console.log(`${r} Connection closed`),f=f.filter(e=>e.id!==r)})}w(h);const j=o(process.argv.slice(2));function x(){console.log(" _ _ ____ _ _"),console.log("| | (_) __ _/ ___| ___ _ __(_)_ __ | |_"),console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|"),console.log("| |___| | (_| |___) | (__| | | | |_) | |_ "),console.log("|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|"),console.log(" |_|"),console.log()}(j.v||j.version)&&(console.log("DevServer: 1.1.26"),console.log("LiaScript: 0.16.1"),process.exit()),(j.h||j.help)&&(x(),console.log("-h --help show this help"),console.log("-v --version show version information"),console.log("-i --input input README.md file or folder (default: .)"),console.log("-n --hostname hostname of your server (default: localhost)"),console.log("-p --port used port number (default: 3000)"),console.log("-l --live do live reload on file change"),console.log("-o --open open in default browser"),console.log("-t --test test online on https://LiaScript.github.io"),console.log(),console.log("-r --responsiveVoice add optional responsiveVoice support,"),console.log(" or pass your own responsiveVoice key."),console.log(" Adding this feature might slow down"),console.log(" the reloading speed."),console.log(" For more information visit:"),console.log(" https://responsivevoice.org"),process.exit()),x(),w(j.node_modules);try{!function(e,o,n,r,p,h,f,w){e=e||3e3,o=o||"localhost",h=h||!1,p=p||!1,f=f||!1;var j={path:n=n||".",readme:void 0};if(n){let e=i.lstatSync(n);e.isDirectory()?j.path=n:e.isFile()&&(j.path=t.dirname(n),j.readme=t.basename(n))}_.set("view engine","hbs"),_.engine("hbs",l({layoutsDir:t.resolve(t.join(u,"views/layouts")),defaultLayout:"main",extname:"hbs"})),_.set("views",t.resolve(t.join(u,"views"))),_.get("/",function(e,o){o.redirect("/home")}),_.get("/gotoLine",y),_.get("/home*",function(t,n){let r=j.path+"/"+t.params[0],s=i.lstatSync(r);if(s.isDirectory()){let s=i.readdirSync(r).filter(e=>"."!==e[0]),l="/home",a=t.params[0].split("/").filter(e=>""!==e),c=[];for(let e=0;e<a.length;e++)l+="/"+a[e],c.push({name:a[e],href:l});n.render("main",{layout:"index",path:c,file:s.map(n=>({name:n,href:`http://${o}:${e}/home${t.params[0]}/${n}`,isDirectory:i.lstatSync(r+"/"+n).isDirectory()})).sort((e,o)=>e.isDirectory&&!o.isDirectory?-1:!e.isDirectory&&o.isDirectory?1:e.name.toLocaleLowerCase()<o.name.toLocaleLowerCase()?-1:1)})}else s.isFile()?t.params[0].toLocaleLowerCase().endsWith(".md")?f?n.redirect(`https://LiaScript.github.io/course/?http://${o}:${e}/${t.params[0]}`):n.redirect(`/liascript/index.html?http://${o}:${e}/${t.params[0]}`):n.sendFile(t.params[0],{root:j.path}):n.send("ups, something went wrong")}),_.get("/liascript/",function(e,o){o.redirect("/liascript/index.html")}),_.get("/liascript/index.html",function(e,o){p&&r?i.readFile(m+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
38
42
  <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${r}'></script>
39
43
  ${v}
40
44
  </head>`))}):p?i.readFile(m+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"A,IEgBI,E,E,Q,Y,E,Q,Q,E,Q,U,E,Q,W,E,Q,M,E,Q,Q,E,Q,sB,E,Q,M,E,Q,Q,E,Q,e,E,Q,e,E,E,O,C,U,UAhBJ,EAAA,MAAA,GAYA,MAAM,EAA2B,IACjC,EAAI,GAAG,CAAC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AE,EAAS,CAAC,EAC/C,QAAQ,GAAG,CACT,CAAC,sBAAsB,EAAE,EAAS,OAAO,CAAC,EAAU,EAAA,OAAA,IAAc,CAAC,CAIvE,ED3UI,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,QAAQ,CACvB,EAAK,CAAC,EAAI,EAAK,KAAK,CACpB,EAAK,CAAC,EAAI,EAAK,eAAe,EAAI,QAAQ,GAAG,CAAC,oBAAoB,CAClE,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,IAAI,CAEvB,CAAE,MAAO,EAAG,CACV,QAAQ,KAAK,CAAC,UAAW,EAAE,OAAO,EAClC,QAAQ,IAAI,EACd,CAEA,QAAQ,GAAG,CAAC","sources":["<anon>","src/index.ts","src/lib.ts"],"sourcesContent":["var $aRKkE$minimist = require(\"minimist\");\nvar $aRKkE$path = require(\"path\");\nvar $aRKkE$dotenv = require(\"dotenv\");\nvar $aRKkE$express = require(\"express\");\nvar $aRKkE$fs = require(\"fs\");\nvar $aRKkE$cors = require(\"cors\");\nvar $aRKkE$expresshandlebars = require(\"express-handlebars\");\nvar $aRKkE$ip = require(\"ip\");\nvar $aRKkE$open = require(\"open\");\nvar $aRKkE$bodyparser = require(\"body-parser\");\nvar $aRKkE$reloadshjs = require(\"reloadsh.js\");\n\n\n\n\n\nvar $f14dee9e17222834$var$$parcel$__dirname = $aRKkE$path.resolve(__dirname, \"../src\");\n\n$aRKkE$dotenv.config();\n\n\n\n\n\nconst $f14dee9e17222834$var$app = $aRKkE$express();\n$f14dee9e17222834$var$app.use($aRKkE$bodyparser.json());\nvar $f14dee9e17222834$var$dirname = \"\";\nvar $f14dee9e17222834$var$node_modules;\nvar $f14dee9e17222834$var$reloadPath = \"\";\nvar $f14dee9e17222834$var$liascriptPath = \"\";\nvar $f14dee9e17222834$var$clients = [];\nconst $f14dee9e17222834$var$gotoScript = `<script>\nif (!window.LIA) {\n window.LIA = {}\n}\n\nvar filename__ = document.location.search.replace(\"?\"+document.location.origin, \"\")\n\nwindow.LIA.lineGoto = function(linenumber) {\n fetch(\"/lineGoto\", {\n method: \"POST\",\n headers: {'Content-Type': 'application/json'}, \n body: JSON.stringify({\n \"linenumber\": linenumber,\n \"filename\": filename__\n })\n }).then(res => {\n console.log(\"Goto line\", linenumber);\n });\n}\n\nconst events = new EventSource('/gotoLine');\nevents.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data);\n if (data.filename == filename__) {\n console.log(\"goto line:\", data.linenumber);\n window.LIA.gotoLine(data.linenumber)\n }\n } catch (e) {\n console.warn(\"gotoLine failed\")\n }\n};\n</script>`;\nvar $f14dee9e17222834$var$serverPointer;\n$f14dee9e17222834$export$2cd8252107eb640b($f14dee9e17222834$var$$parcel$__dirname);\nfunction $f14dee9e17222834$export$2cd8252107eb640b(serverPath, nodeModulesPath) {\n $f14dee9e17222834$var$dirname = serverPath || $aRKkE$path.join($f14dee9e17222834$var$$parcel$__dirname, \"..\");\n $f14dee9e17222834$var$node_modules = nodeModulesPath || $aRKkE$path.join($f14dee9e17222834$var$dirname, \"node_modules\");\n $f14dee9e17222834$var$reloadPath = $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$node_modules, \"reloadsh.js/reloader.browser.js\"));\n $f14dee9e17222834$var$liascriptPath = $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$node_modules, \"@liascript/editor/dist\"));\n}\n\nfunction $f14dee9e17222834$export$b3571188c770cc5a(port, hostname, input, responsiveVoice, liveReload, openInBrowser, testOnline, gotoCallback) {\n port = port || 3000;\n hostname = hostname || \"localhost\";\n openInBrowser = openInBrowser || false;\n input = input || \".\";\n liveReload = liveReload || false;\n testOnline = testOnline || false;\n var project = {\n path: input,\n readme: undefined\n };\n if (input) {\n const stats = $aRKkE$fs.lstatSync(input);\n // Is it a directory?\n if (stats.isDirectory()) project.path = input;\n else if (stats.isFile()) {\n project.path = $aRKkE$path.dirname(input);\n project.readme = $aRKkE$path.basename(input);\n }\n }\n $f14dee9e17222834$var$app.set(\"view engine\", \"hbs\");\n $f14dee9e17222834$var$app.engine(\"hbs\", $aRKkE$expresshandlebars({\n layoutsDir: $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$dirname, \"views/layouts\")),\n defaultLayout: \"main\",\n extname: \"hbs\"\n }));\n $f14dee9e17222834$var$app.set(\"views\", $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$dirname, \"views\")));\n $f14dee9e17222834$var$app.get(\"/\", function(req, res) {\n res.redirect(\"/home\");\n });\n $f14dee9e17222834$var$app.get(\"/gotoLine\", $f14dee9e17222834$var$eventsHandler);\n $f14dee9e17222834$var$app.get(\"/home*\", function(req, res) {\n const currentPath = project.path + \"/\" + req.params[0];\n const stats = $aRKkE$fs.lstatSync(currentPath);\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = $aRKkE$fs.readdirSync(currentPath).filter((e)=>{\n return e[0] !== \".\";\n });\n let basePath = \"/home\";\n let pathNames = req.params[0].split(\"/\").filter((e)=>{\n return e !== \"\";\n });\n let paths = [];\n for(let i = 0; i < pathNames.length; i++){\n basePath += \"/\" + pathNames[i];\n paths.push({\n name: pathNames[i],\n href: basePath\n });\n }\n res.render(\"main\", {\n layout: \"index\",\n path: paths,\n file: files.map((file)=>{\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: $aRKkE$fs.lstatSync(currentPath + \"/\" + file).isDirectory()\n };\n }).sort((a, b)=>{\n if (a.isDirectory && !b.isDirectory) return -1;\n else if (!a.isDirectory && b.isDirectory) return 1;\n else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) return -1;\n else return 1;\n }\n return 0;\n })\n });\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith(\".md\")) {\n if (testOnline) res.redirect(`https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`);\n else res.redirect(`/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`);\n } else res.sendFile(req.params[0], {\n root: project.path\n });\n } else res.send(\"ups, something went wrong\");\n });\n $f14dee9e17222834$var$app.get(\"/liascript/\", function(req, res) {\n res.redirect(\"/liascript/index.html\");\n });\n $f14dee9e17222834$var$app.get(\"/liascript/index.html\", function(req, res) {\n // ------------------------------------\n if (liveReload && responsiveVoice) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else if (liveReload) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='/reloader/reloader.js'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else if (responsiveVoice) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `${$f14dee9e17222834$var$gotoScript}</head>`));\n });\n });\n // load everything from the liascript folder\n $f14dee9e17222834$var$app.get(\"/liascript/*\", function(req, res) {\n res.sendFile(req.params[0], {\n root: $f14dee9e17222834$var$liascriptPath\n });\n });\n // ignore this one\n $f14dee9e17222834$var$app.get(\"/sw.js\", function(req, res) {});\n $f14dee9e17222834$var$app.get(\"/favicon.ico\", function(req, res) {});\n // pass the reloader, to be used for live updates\n $f14dee9e17222834$var$app.get(\"/reloader/reloader.js\", function(req, res) {\n res.sendFile($f14dee9e17222834$var$reloadPath);\n });\n // react to click-events\n $f14dee9e17222834$var$app.post(\"/lineGoto\", function(req, res) {\n if (gotoCallback) try {\n const linenumber = req.body.linenumber;\n const filename = req.body.filename;\n gotoCallback(linenumber, filename);\n } catch (e) {\n console.warn(\"lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}\");\n }\n return res.json({});\n });\n // everything else comes from the current project folder\n $f14dee9e17222834$var$app.get(\"/*\", $aRKkE$cors(), function(req, res) {\n res.sendFile(req.originalUrl, {\n root: project.path\n });\n });\n let localURL = \"http://\" + hostname + \":\" + port;\n if (project.path && project.readme) localURL += \"/liascript/index.html?http://\" + hostname + \":\" + port + \"/\" + project.readme;\n if (testOnline && project.readme) localURL = \"https://LiaScript.github.io/course/?http://\" + hostname + \":\" + port + \"/\" + project.readme;\n const server = $aRKkE$reloadshjs($f14dee9e17222834$var$app, liveReload ? [\n $aRKkE$path.join(project.path, project.readme || \"\")\n ] : []);\n if (liveReload) console.log(`\\u{2728} watching for changes on: \"${$aRKkE$path.join(project.path || \"\", project.readme || \"\")}\"`);\n server.on(\"error\", (e)=>{\n throw e;\n });\n server.listen(port);\n if (openInBrowser) $aRKkE$open(localURL);\n console.log(\"\\uD83D\\uDCE1 starting server\");\n console.log(` - local: ${localURL}`);\n console.log(` - on your network: ${localURL.replace(hostname, $aRKkE$ip.address())}`);\n $f14dee9e17222834$var$serverPointer = server;\n}\nfunction $f14dee9e17222834$export$fa6813432f753b0d() {\n if ($f14dee9e17222834$var$serverPointer) $f14dee9e17222834$var$serverPointer.close();\n}\nfunction $f14dee9e17222834$export$5d5b784f9a618ec3(linenumber, filename) {\n $f14dee9e17222834$var$clients.forEach((client)=>client.response.write(`data: ${JSON.stringify({\n linenumber: linenumber,\n filename: filename\n })}\\n\\n`));\n}\nfunction $f14dee9e17222834$var$eventsHandler(request, response, next) {\n const headers = {\n \"Content-Type\": \"text/event-stream\",\n Connection: \"keep-alive\",\n \"Cache-Control\": \"no-cache\"\n };\n response.writeHead(200, headers);\n const data = `data: \\n\\n`;\n response.write(data);\n const clientId = Date.now();\n const newClient = {\n id: clientId,\n response: response\n };\n $f14dee9e17222834$var$clients.push(newClient);\n request.on(\"close\", ()=>{\n console.log(`${clientId} Connection closed`);\n $f14dee9e17222834$var$clients = $f14dee9e17222834$var$clients.filter((client)=>client.id !== clientId);\n });\n}\n\n\n\nconst $71fcc9ea54afc905$var$argv = $aRKkE$minimist(process.argv.slice(2));\nfunction $71fcc9ea54afc905$var$liascript() {\n console.log(\" _ _ ____ _ _\");\n console.log(\"| | (_) __ _/ ___| ___ _ __(_)_ __ | |_\");\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\");\n console.log(\"| |___| | (_| |___) | (__| | | | |_) | |_ \");\n console.log(\"|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|\");\n console.log(\" |_|\");\n console.log();\n}\nif ($71fcc9ea54afc905$var$argv.v || $71fcc9ea54afc905$var$argv.version) {\n console.log(\"DevServer: 1.1.24\");\n console.log(\"LiaScript: 0.15.12\");\n process.exit();\n}\nif ($71fcc9ea54afc905$var$argv.h || $71fcc9ea54afc905$var$argv.help) {\n $71fcc9ea54afc905$var$liascript();\n console.log(\"-h --help show this help\");\n console.log(\"-v --version show version information\");\n console.log(\"-i --input input README.md file or folder (default: .)\");\n console.log(\"-n --hostname hostname of your server (default: localhost)\");\n console.log(\"-p --port used port number (default: 3000)\");\n console.log(\"-l --live do live reload on file change\");\n console.log(\"-o --open open in default browser\");\n console.log(\"-t --test test online on https://LiaScript.github.io\");\n console.log();\n console.log(\"-r --responsiveVoice add optional responsiveVoice support,\");\n console.log(\" or pass your own responsiveVoice key.\");\n console.log(\" Adding this feature might slow down\");\n console.log(\" the reloading speed.\");\n console.log(\" For more information visit:\");\n console.log(\" https://responsivevoice.org\");\n process.exit();\n}\n$71fcc9ea54afc905$var$liascript();\n$f14dee9e17222834$export$2cd8252107eb640b($71fcc9ea54afc905$var$argv.node_modules);\ntry {\n $f14dee9e17222834$export$b3571188c770cc5a($71fcc9ea54afc905$var$argv.p || $71fcc9ea54afc905$var$argv.port, $71fcc9ea54afc905$var$argv.n || $71fcc9ea54afc905$var$argv.hostname, $71fcc9ea54afc905$var$argv.i || $71fcc9ea54afc905$var$argv.input, $71fcc9ea54afc905$var$argv.r || $71fcc9ea54afc905$var$argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY, $71fcc9ea54afc905$var$argv.l || $71fcc9ea54afc905$var$argv.live, $71fcc9ea54afc905$var$argv.o || $71fcc9ea54afc905$var$argv.open, $71fcc9ea54afc905$var$argv.t || $71fcc9ea54afc905$var$argv.test);\n} catch (e) {\n console.error(\"Error: \", e.message);\n process.exit();\n}\nconsole.log(\"\\u2728 hit Ctrl-c to close the server\");\n\n\n//# sourceMappingURL=index.js.map\n","const argv = require('minimist')(process.argv.slice(2))\n\nimport * as server from './lib'\n\nfunction liascript() {\n console.log(' _ _ ____ _ _')\n console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_')\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\")\n console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ')\n console.log('|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|')\n console.log(' |_|')\n console.log()\n}\n\nif (argv.v || argv.version) {\n console.log('DevServer: 1.1.24')\n console.log('LiaScript: 0.15.12')\n process.exit()\n}\n\nif (argv.h || argv.help) {\n liascript()\n\n console.log('-h --help show this help')\n console.log('-v --version show version information')\n console.log('-i --input input README.md file or folder (default: .)')\n console.log('-n --hostname hostname of your server (default: localhost)')\n console.log('-p --port used port number (default: 3000)')\n console.log('-l --live do live reload on file change')\n console.log('-o --open open in default browser')\n console.log('-t --test test online on https://LiaScript.github.io')\n console.log()\n console.log('-r --responsiveVoice add optional responsiveVoice support,')\n console.log(' or pass your own responsiveVoice key.')\n console.log(' Adding this feature might slow down')\n console.log(' the reloading speed.')\n console.log(' For more information visit:')\n console.log(' https://responsivevoice.org')\n\n process.exit()\n}\n\nliascript()\n\nserver.init(argv.node_modules)\n\ntry {\n server.start(\n argv.p || argv.port,\n argv.n || argv.hostname,\n argv.i || argv.input,\n argv.r || argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY,\n argv.l || argv.live,\n argv.o || argv.open,\n argv.t || argv.test\n )\n} catch (e) {\n console.error('Error: ', e.message)\n process.exit()\n}\n\nconsole.log('✨ hit Ctrl-c to close the server')\n","require('dotenv').config()\nimport * as express from 'express'\n\nimport * as fs from 'fs'\nimport * as path from 'path'\n\nconst cors = require('cors')\nconst handlebars = require('express-handlebars')\nconst ip = require('ip')\nconst open = require('open')\nconst bodyParser = require('body-parser')\n\nconst app: express.Application = express()\napp.use(bodyParser.json())\n\nvar dirname = ''\nvar node_modules\nvar reloadPath = ''\nvar liascriptPath = ''\n\nvar clients: any[] = []\n\nconst gotoScript = `<script>\nif (!window.LIA) {\n window.LIA = {}\n}\n\nvar filename__ = document.location.search.replace(\"?\"+document.location.origin, \"\")\n\nwindow.LIA.lineGoto = function(linenumber) {\n fetch(\"/lineGoto\", {\n method: \"POST\",\n headers: {'Content-Type': 'application/json'}, \n body: JSON.stringify({\n \"linenumber\": linenumber,\n \"filename\": filename__\n })\n }).then(res => {\n console.log(\"Goto line\", linenumber);\n });\n}\n\nconst events = new EventSource('/gotoLine');\nevents.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data);\n if (data.filename == filename__) {\n console.log(\"goto line:\", data.linenumber);\n window.LIA.gotoLine(data.linenumber)\n }\n } catch (e) {\n console.warn(\"gotoLine failed\")\n }\n};\n</script>`\n\nvar serverPointer: any\n\ninit(__dirname)\n\nexport function init(serverPath?: string, nodeModulesPath?: string) {\n dirname = serverPath || path.join(__dirname, '..')\n\n node_modules = nodeModulesPath || path.join(dirname, 'node_modules')\n\n reloadPath = path.resolve(\n path.join(node_modules, 'reloadsh.js/reloader.browser.js')\n )\n\n liascriptPath = path.resolve(\n path.join(node_modules, '@liascript/editor/dist')\n )\n}\n\nexport function start(\n port?: number,\n hostname?: string,\n input?: string,\n responsiveVoice?: string,\n liveReload?: boolean,\n openInBrowser?: boolean,\n testOnline?: boolean,\n gotoCallback?: (linenumber: number, filename: string) => void\n) {\n port = port || 3000\n hostname = hostname || 'localhost'\n openInBrowser = openInBrowser || false\n input = input || '.'\n liveReload = liveReload || false\n testOnline = testOnline || false\n\n var project: {\n path: string\n readme?: string\n } = {\n path: input,\n readme: undefined,\n }\n\n if (input) {\n const stats = fs.lstatSync(input)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n project.path = input\n } else if (stats.isFile()) {\n project.path = path.dirname(input)\n project.readme = path.basename(input)\n }\n }\n\n app.set('view engine', 'hbs')\n app.engine(\n 'hbs',\n handlebars({\n layoutsDir: path.resolve(path.join(dirname, 'views/layouts')),\n defaultLayout: 'main',\n extname: 'hbs',\n })\n )\n app.set('views', path.resolve(path.join(dirname, 'views')))\n\n app.get('/', function (req: express.Request, res: express.Response) {\n res.redirect('/home')\n })\n\n app.get('/gotoLine', eventsHandler)\n\n app.get('/home*', function (req: express.Request, res: express.Response) {\n const currentPath = project.path + '/' + req.params[0]\n\n const stats = fs.lstatSync(currentPath)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = fs.readdirSync(currentPath).filter((e: string) => {\n return e[0] !== '.'\n })\n\n let basePath = '/home'\n let pathNames = req.params[0].split('/').filter((e: string) => {\n return e !== ''\n })\n\n let paths: { name: string; href: string }[] = []\n for (let i = 0; i < pathNames.length; i++) {\n basePath += '/' + pathNames[i]\n paths.push({ name: pathNames[i], href: basePath })\n }\n\n res.render('main', {\n layout: 'index',\n path: paths,\n file: files\n .map((file: string) => {\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: fs.lstatSync(currentPath + '/' + file).isDirectory(),\n }\n })\n .sort(\n (\n a: {\n name: string\n href: string\n isDirectory: boolean\n },\n b: {\n name: string\n href: string\n isDirectory: boolean\n }\n ) => {\n if (a.isDirectory && !b.isDirectory) {\n return -1\n } else if (!a.isDirectory && b.isDirectory) {\n return 1\n } else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {\n return -1\n } else {\n return 1\n }\n }\n return 0\n }\n ),\n })\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith('.md')) {\n if (testOnline) {\n res.redirect(\n `https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`\n )\n } else {\n res.redirect(\n `/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`\n )\n }\n } else {\n res.sendFile(req.params[0], { root: project.path })\n }\n } else {\n res.send('ups, something went wrong')\n }\n })\n\n app.get(\n '/liascript/',\n function (req: express.Request, res: express.Response) {\n res.redirect('/liascript/index.html')\n }\n )\n\n app.get(\n '/liascript/index.html',\n function (req: express.Request, res: express.Response) {\n // ------------------------------------\n if (liveReload && responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (liveReload) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(data.replace('</head>', `${gotoScript}</head>`))\n }\n )\n }\n }\n )\n\n // load everything from the liascript folder\n app.get(\n '/liascript/*',\n function (req: express.Request, res: express.Response) {\n res.sendFile(req.params[0], { root: liascriptPath })\n }\n )\n // ignore this one\n app.get('/sw.js', function (req: express.Request, res: express.Response) {})\n app.get(\n '/favicon.ico',\n function (req: express.Request, res: express.Response) {}\n )\n\n // pass the reloader, to be used for live updates\n app.get(\n '/reloader/reloader.js',\n function (req: express.Request, res: express.Response) {\n res.sendFile(reloadPath)\n }\n )\n\n // react to click-events\n app.post('/lineGoto', function (req: express.Request, res: express.Response) {\n if (gotoCallback) {\n try {\n const linenumber = req.body.linenumber\n const filename = req.body.filename\n gotoCallback(linenumber, filename)\n } catch (e) {\n console.warn(\n \"lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}\"\n )\n }\n }\n return res.json({})\n })\n\n // everything else comes from the current project folder\n app.get('/*', cors(), function (req: express.Request, res: express.Response) {\n res.sendFile(req.originalUrl, { root: project.path })\n })\n\n let localURL = 'http://' + hostname + ':' + port\n\n if (project.path && project.readme) {\n localURL +=\n '/liascript/index.html?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n if (testOnline && project.readme) {\n localURL =\n 'https://LiaScript.github.io/course/?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n const server = require('reloadsh.js')(\n app,\n liveReload ? [path.join(project.path, project.readme || '')] : []\n )\n\n if (liveReload) {\n console.log(\n `✨ watching for changes on: \"${path.join(\n project.path || '',\n project.readme || ''\n )}\"`\n )\n }\n\n server.on('error', (e: any) => {\n throw e\n })\n\n server.listen(port)\n\n if (openInBrowser) {\n open(localURL)\n }\n\n console.log('📡 starting server')\n console.log(` - local: ${localURL}`)\n console.log(\n ` - on your network: ${localURL.replace(hostname, ip.address())}`\n )\n\n serverPointer = server\n}\n\nexport function stop() {\n if (serverPointer) {\n serverPointer.close()\n }\n}\n\nexport function gotoLine(linenumber: number, filename: string) {\n clients.forEach((client) =>\n client.response.write(\n `data: ${JSON.stringify({\n linenumber: linenumber,\n filename: filename,\n })}\\n\\n`\n )\n )\n}\n\nfunction eventsHandler(\n request: express.Request,\n response: express.Response,\n next: any\n) {\n const headers = {\n 'Content-Type': 'text/event-stream',\n Connection: 'keep-alive',\n 'Cache-Control': 'no-cache',\n }\n response.writeHead(200, headers)\n\n const data = `data: \\n\\n`\n\n response.write(data)\n\n const clientId = Date.now()\n\n const newClient = {\n id: clientId,\n response,\n }\n\n clients.push(newClient)\n\n request.on('close', () => {\n console.log(`${clientId} Connection closed`)\n clients = clients.filter((client) => client.id !== clientId)\n })\n}\n"],"names":["$f14dee9e17222834$var$node_modules","$aRKkE$minimist","require","$aRKkE$path","$aRKkE$dotenv","$aRKkE$express","$aRKkE$fs","$aRKkE$cors","$aRKkE$expresshandlebars","$aRKkE$ip","$aRKkE$open","$aRKkE$bodyparser","$aRKkE$reloadshjs","$f14dee9e17222834$var$$parcel$__dirname","resolve","__dirname","config","$f14dee9e17222834$var$app","use","json","$f14dee9e17222834$var$dirname","$f14dee9e17222834$var$reloadPath","$f14dee9e17222834$var$liascriptPath","$f14dee9e17222834$var$clients","$f14dee9e17222834$var$gotoScript","$f14dee9e17222834$export$2cd8252107eb640b","serverPath","nodeModulesPath","join","$f14dee9e17222834$var$eventsHandler","request","response","next","writeHead","Connection","data","write","clientId","Date","now","push","id","on","console","log","filter","client","$71fcc9ea54afc905$var$argv","process","argv","slice","$71fcc9ea54afc905$var$liascript","v","version","exit","h","help","node_modules","$f14dee9e17222834$export$b3571188c770cc5a","port","hostname","input","responsiveVoice","liveReload","openInBrowser","testOnline","gotoCallback","project","path","readme","undefined","stats","lstatSync","isDirectory","isFile","dirname","basename","set","engine","layoutsDir","defaultLayout","extname","get","req","res","redirect","currentPath","params","files","readdirSync","e","basePath","pathNames","split","paths","i","length","name","href","render","layout","file","map","sort","a","b","toLocaleLowerCase","endsWith","sendFile","root","send","readFile","err","replace","post","originalUrl","localURL","server","listen","address","p","n","r","env","RESPONSIVE_VOICE_KEY","l","live","o","open","t","test","error","message"],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":"A,IEgBI,E,E,Q,Y,E,Q,Q,E,Q,U,E,Q,W,E,Q,M,E,Q,Q,E,Q,sB,E,Q,M,E,Q,Q,E,Q,e,E,Q,e,E,E,O,C,U,UAhBJ,EAAA,MAAA,GAYA,MAAM,EAA2B,IACjC,EAAI,GAAG,CAAC,EAAR,IAAA,IAEA,IAAI,EAAU,GAEV,EAAa,GACb,EAAgB,GAEhB,EAAiB,EAAE,CAEvB,MAAM,EAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgCX,CAAC,CAMH,SAAS,EAAK,CAAmB,CAAE,CAAwB,EAChE,EAAU,GAAc,EAAA,IAAA,CAAU,EAAW,MAE7C,EAAe,GAAmB,EAAA,IAAA,CAAU,EAAS,gBAErD,EAAa,EAAA,OAAA,CACX,EAAA,IAAA,CAAU,EAAc,oCAG1B,EAAgB,EAAA,OAAA,CACd,EAAA,IAAA,CAAU,EAAc,0BAE5B,CAsUA,SAAS,EACP,CAAwB,CACxB,CAA0B,CAC1B,CAAS,EAOT,EAAS,SAAS,CAAC,IALH,CACd,eAAgB,oBAChB,WAAY,aACZ,gBAAiB,UACnB,GAGA,IAAM,EAAO,CAAC;;AAAU,CAAC,CAEzB,EAAS,KAAK,CAAC,GAEf,IAAM,EAAW,KAAK,GAAG,GAOzB,EAAQ,IAAI,CALM,CAChB,GAAI,EACJ,SAAA,CACF,GAIA,EAAQ,EAAE,CAAC,QAAS,KAClB,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAS,kBAAkB,CAAC,EAC3C,EAAU,EAAQ,MAAM,CAAC,AAAC,GAAW,EAAO,EAAE,GAAK,EACrD,EACF,CAjXA,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S,EACb,EACA,EAAa,CAAC,EAAA,IAAA,CAAU,EAAQ,IAAI,CAAE,EAAQ,MAAM,EAAI,IAAI,CAAG,EAAE,EAG/D,GACF,QAAQ,GAAG,CACT,CAAC,mCAA4B,EAAE,EAAA,IAAA,CAC7B,EAAQ,IAAI,EAAI,GAChB,EAAQ,MAAM,EAAI,IAClB,CAAC,CAAC,EAIR,EAAO,EAAE,CAAC,QAAS,AAAC,IAClB,MAAM,CACR,GAEA,EAAO,MAAM,CAAC,GAEV,GACF,EAAK,GAGP,QAAQ,GAAG,CAAC,gCACZ,QAAQ,GAAG,CAAC,CAAC,sBAAsB,EAAE,EAAS,CAAC,EAC/C,QAAQ,GAAG,CACT,CAAC,sBAAsB,EAAE,EAAS,OAAO,CAAC,EAAU,EAAA,OAAA,IAAc,CAAC,CAIvE,ED3UI,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,QAAQ,CACvB,EAAK,CAAC,EAAI,EAAK,KAAK,CACpB,EAAK,CAAC,EAAI,EAAK,eAAe,EAAI,QAAQ,GAAG,CAAC,oBAAoB,CAClE,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,IAAI,CACnB,EAAK,CAAC,EAAI,EAAK,IAAI,CAEvB,CAAE,MAAO,EAAG,CACV,QAAQ,KAAK,CAAC,UAAW,EAAE,OAAO,EAClC,QAAQ,IAAI,EACd,CAEA,QAAQ,GAAG,CAAC","sources":["<anon>","src/index.ts","src/lib.ts"],"sourcesContent":["var $aRKkE$minimist = require(\"minimist\");\nvar $aRKkE$path = require(\"path\");\nvar $aRKkE$dotenv = require(\"dotenv\");\nvar $aRKkE$express = require(\"express\");\nvar $aRKkE$fs = require(\"fs\");\nvar $aRKkE$cors = require(\"cors\");\nvar $aRKkE$expresshandlebars = require(\"express-handlebars\");\nvar $aRKkE$ip = require(\"ip\");\nvar $aRKkE$open = require(\"open\");\nvar $aRKkE$bodyparser = require(\"body-parser\");\nvar $aRKkE$reloadshjs = require(\"reloadsh.js\");\n\n\n\n\n\nvar $f14dee9e17222834$var$$parcel$__dirname = $aRKkE$path.resolve(__dirname, \"../src\");\n\n$aRKkE$dotenv.config();\n\n\n\n\n\nconst $f14dee9e17222834$var$app = $aRKkE$express();\n$f14dee9e17222834$var$app.use($aRKkE$bodyparser.json());\nvar $f14dee9e17222834$var$dirname = \"\";\nvar $f14dee9e17222834$var$node_modules;\nvar $f14dee9e17222834$var$reloadPath = \"\";\nvar $f14dee9e17222834$var$liascriptPath = \"\";\nvar $f14dee9e17222834$var$clients = [];\nconst $f14dee9e17222834$var$gotoScript = `<script>\nif (!window.LIA) {\n window.LIA = {}\n}\n\nvar filename__ = document.location.search.replace(\"?\"+document.location.origin, \"\")\n\nwindow.LIA.lineGoto = function(linenumber) {\n fetch(\"/lineGoto\", {\n method: \"POST\",\n headers: {'Content-Type': 'application/json'}, \n body: JSON.stringify({\n \"linenumber\": linenumber,\n \"filename\": filename__\n })\n }).then(res => {\n console.log(\"Goto line\", linenumber);\n });\n}\n\nconst events = new EventSource('/gotoLine');\nevents.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data);\n if (data.filename == filename__) {\n console.log(\"goto line:\", data.linenumber);\n window.LIA.gotoLine(data.linenumber)\n }\n } catch (e) {\n console.warn(\"gotoLine failed\")\n }\n};\n</script>`;\nvar $f14dee9e17222834$var$serverPointer;\n$f14dee9e17222834$export$2cd8252107eb640b($f14dee9e17222834$var$$parcel$__dirname);\nfunction $f14dee9e17222834$export$2cd8252107eb640b(serverPath, nodeModulesPath) {\n $f14dee9e17222834$var$dirname = serverPath || $aRKkE$path.join($f14dee9e17222834$var$$parcel$__dirname, \"..\");\n $f14dee9e17222834$var$node_modules = nodeModulesPath || $aRKkE$path.join($f14dee9e17222834$var$dirname, \"node_modules\");\n $f14dee9e17222834$var$reloadPath = $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$node_modules, \"reloadsh.js/reloader.browser.js\"));\n $f14dee9e17222834$var$liascriptPath = $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$node_modules, \"@liascript/editor/dist\"));\n}\n\nfunction $f14dee9e17222834$export$b3571188c770cc5a(port, hostname, input, responsiveVoice, liveReload, openInBrowser, testOnline, gotoCallback) {\n port = port || 3000;\n hostname = hostname || \"localhost\";\n openInBrowser = openInBrowser || false;\n input = input || \".\";\n liveReload = liveReload || false;\n testOnline = testOnline || false;\n var project = {\n path: input,\n readme: undefined\n };\n if (input) {\n const stats = $aRKkE$fs.lstatSync(input);\n // Is it a directory?\n if (stats.isDirectory()) project.path = input;\n else if (stats.isFile()) {\n project.path = $aRKkE$path.dirname(input);\n project.readme = $aRKkE$path.basename(input);\n }\n }\n $f14dee9e17222834$var$app.set(\"view engine\", \"hbs\");\n $f14dee9e17222834$var$app.engine(\"hbs\", $aRKkE$expresshandlebars({\n layoutsDir: $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$dirname, \"views/layouts\")),\n defaultLayout: \"main\",\n extname: \"hbs\"\n }));\n $f14dee9e17222834$var$app.set(\"views\", $aRKkE$path.resolve($aRKkE$path.join($f14dee9e17222834$var$dirname, \"views\")));\n $f14dee9e17222834$var$app.get(\"/\", function(req, res) {\n res.redirect(\"/home\");\n });\n $f14dee9e17222834$var$app.get(\"/gotoLine\", $f14dee9e17222834$var$eventsHandler);\n $f14dee9e17222834$var$app.get(\"/home*\", function(req, res) {\n const currentPath = project.path + \"/\" + req.params[0];\n const stats = $aRKkE$fs.lstatSync(currentPath);\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = $aRKkE$fs.readdirSync(currentPath).filter((e)=>{\n return e[0] !== \".\";\n });\n let basePath = \"/home\";\n let pathNames = req.params[0].split(\"/\").filter((e)=>{\n return e !== \"\";\n });\n let paths = [];\n for(let i = 0; i < pathNames.length; i++){\n basePath += \"/\" + pathNames[i];\n paths.push({\n name: pathNames[i],\n href: basePath\n });\n }\n res.render(\"main\", {\n layout: \"index\",\n path: paths,\n file: files.map((file)=>{\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: $aRKkE$fs.lstatSync(currentPath + \"/\" + file).isDirectory()\n };\n }).sort((a, b)=>{\n if (a.isDirectory && !b.isDirectory) return -1;\n else if (!a.isDirectory && b.isDirectory) return 1;\n else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) return -1;\n else return 1;\n }\n return 0;\n })\n });\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith(\".md\")) {\n if (testOnline) res.redirect(`https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`);\n else res.redirect(`/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`);\n } else res.sendFile(req.params[0], {\n root: project.path\n });\n } else res.send(\"ups, something went wrong\");\n });\n $f14dee9e17222834$var$app.get(\"/liascript/\", function(req, res) {\n res.redirect(\"/liascript/index.html\");\n });\n $f14dee9e17222834$var$app.get(\"/liascript/index.html\", function(req, res) {\n // ------------------------------------\n if (liveReload && responsiveVoice) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else if (liveReload) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='/reloader/reloader.js'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else if (responsiveVoice) $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${$f14dee9e17222834$var$gotoScript}\n </head>`));\n });\n else $aRKkE$fs.readFile($f14dee9e17222834$var$liascriptPath + \"/index.html\", \"utf8\", function(err, data) {\n res.send(data.replace(\"</head>\", `${$f14dee9e17222834$var$gotoScript}</head>`));\n });\n });\n // load everything from the liascript folder\n $f14dee9e17222834$var$app.get(\"/liascript/*\", function(req, res) {\n res.sendFile(req.params[0], {\n root: $f14dee9e17222834$var$liascriptPath\n });\n });\n // ignore this one\n $f14dee9e17222834$var$app.get(\"/sw.js\", function(req, res) {});\n $f14dee9e17222834$var$app.get(\"/favicon.ico\", function(req, res) {});\n // pass the reloader, to be used for live updates\n $f14dee9e17222834$var$app.get(\"/reloader/reloader.js\", function(req, res) {\n res.sendFile($f14dee9e17222834$var$reloadPath);\n });\n // react to click-events\n $f14dee9e17222834$var$app.post(\"/lineGoto\", function(req, res) {\n if (gotoCallback) try {\n const linenumber = req.body.linenumber;\n const filename = req.body.filename;\n gotoCallback(linenumber, filename);\n } catch (e) {\n console.warn(\"lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}\");\n }\n return res.json({});\n });\n // everything else comes from the current project folder\n $f14dee9e17222834$var$app.get(\"/*\", $aRKkE$cors(), function(req, res) {\n res.sendFile(req.originalUrl, {\n root: project.path\n });\n });\n let localURL = \"http://\" + hostname + \":\" + port;\n if (project.path && project.readme) localURL += \"/liascript/index.html?http://\" + hostname + \":\" + port + \"/\" + project.readme;\n if (testOnline && project.readme) localURL = \"https://LiaScript.github.io/course/?http://\" + hostname + \":\" + port + \"/\" + project.readme;\n const server = $aRKkE$reloadshjs($f14dee9e17222834$var$app, liveReload ? [\n $aRKkE$path.join(project.path, project.readme || \"\")\n ] : []);\n if (liveReload) console.log(`\\u{2728} watching for changes on: \"${$aRKkE$path.join(project.path || \"\", project.readme || \"\")}\"`);\n server.on(\"error\", (e)=>{\n throw e;\n });\n server.listen(port);\n if (openInBrowser) $aRKkE$open(localURL);\n console.log(\"\\uD83D\\uDCE1 starting server\");\n console.log(` - local: ${localURL}`);\n console.log(` - on your network: ${localURL.replace(hostname, $aRKkE$ip.address())}`);\n $f14dee9e17222834$var$serverPointer = server;\n}\nfunction $f14dee9e17222834$export$fa6813432f753b0d() {\n if ($f14dee9e17222834$var$serverPointer) $f14dee9e17222834$var$serverPointer.close();\n}\nfunction $f14dee9e17222834$export$5d5b784f9a618ec3(linenumber, filename) {\n $f14dee9e17222834$var$clients.forEach((client)=>client.response.write(`data: ${JSON.stringify({\n linenumber: linenumber,\n filename: filename\n })}\\n\\n`));\n}\nfunction $f14dee9e17222834$var$eventsHandler(request, response, next) {\n const headers = {\n \"Content-Type\": \"text/event-stream\",\n Connection: \"keep-alive\",\n \"Cache-Control\": \"no-cache\"\n };\n response.writeHead(200, headers);\n const data = `data: \\n\\n`;\n response.write(data);\n const clientId = Date.now();\n const newClient = {\n id: clientId,\n response: response\n };\n $f14dee9e17222834$var$clients.push(newClient);\n request.on(\"close\", ()=>{\n console.log(`${clientId} Connection closed`);\n $f14dee9e17222834$var$clients = $f14dee9e17222834$var$clients.filter((client)=>client.id !== clientId);\n });\n}\n\n\n\nconst $71fcc9ea54afc905$var$argv = $aRKkE$minimist(process.argv.slice(2));\nfunction $71fcc9ea54afc905$var$liascript() {\n console.log(\" _ _ ____ _ _\");\n console.log(\"| | (_) __ _/ ___| ___ _ __(_)_ __ | |_\");\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\");\n console.log(\"| |___| | (_| |___) | (__| | | | |_) | |_ \");\n console.log(\"|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|\");\n console.log(\" |_|\");\n console.log();\n}\nif ($71fcc9ea54afc905$var$argv.v || $71fcc9ea54afc905$var$argv.version) {\n console.log(\"DevServer: 1.1.26\");\n console.log(\"LiaScript: 0.16.1\");\n process.exit();\n}\nif ($71fcc9ea54afc905$var$argv.h || $71fcc9ea54afc905$var$argv.help) {\n $71fcc9ea54afc905$var$liascript();\n console.log(\"-h --help show this help\");\n console.log(\"-v --version show version information\");\n console.log(\"-i --input input README.md file or folder (default: .)\");\n console.log(\"-n --hostname hostname of your server (default: localhost)\");\n console.log(\"-p --port used port number (default: 3000)\");\n console.log(\"-l --live do live reload on file change\");\n console.log(\"-o --open open in default browser\");\n console.log(\"-t --test test online on https://LiaScript.github.io\");\n console.log();\n console.log(\"-r --responsiveVoice add optional responsiveVoice support,\");\n console.log(\" or pass your own responsiveVoice key.\");\n console.log(\" Adding this feature might slow down\");\n console.log(\" the reloading speed.\");\n console.log(\" For more information visit:\");\n console.log(\" https://responsivevoice.org\");\n process.exit();\n}\n$71fcc9ea54afc905$var$liascript();\n$f14dee9e17222834$export$2cd8252107eb640b($71fcc9ea54afc905$var$argv.node_modules);\ntry {\n $f14dee9e17222834$export$b3571188c770cc5a($71fcc9ea54afc905$var$argv.p || $71fcc9ea54afc905$var$argv.port, $71fcc9ea54afc905$var$argv.n || $71fcc9ea54afc905$var$argv.hostname, $71fcc9ea54afc905$var$argv.i || $71fcc9ea54afc905$var$argv.input, $71fcc9ea54afc905$var$argv.r || $71fcc9ea54afc905$var$argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY, $71fcc9ea54afc905$var$argv.l || $71fcc9ea54afc905$var$argv.live, $71fcc9ea54afc905$var$argv.o || $71fcc9ea54afc905$var$argv.open, $71fcc9ea54afc905$var$argv.t || $71fcc9ea54afc905$var$argv.test);\n} catch (e) {\n console.error(\"Error: \", e.message);\n process.exit();\n}\nconsole.log(\"\\u2728 hit Ctrl-c to close the server\");\n\n\n//# sourceMappingURL=index.js.map\n","const argv = require('minimist')(process.argv.slice(2))\n\nimport * as server from './lib'\n\nfunction liascript() {\n console.log(' _ _ ____ _ _')\n console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_')\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\")\n console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ')\n console.log('|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|')\n console.log(' |_|')\n console.log()\n}\n\nif (argv.v || argv.version) {\n console.log('DevServer: 1.1.26')\n console.log('LiaScript: 0.16.1')\n process.exit()\n}\n\nif (argv.h || argv.help) {\n liascript()\n\n console.log('-h --help show this help')\n console.log('-v --version show version information')\n console.log('-i --input input README.md file or folder (default: .)')\n console.log('-n --hostname hostname of your server (default: localhost)')\n console.log('-p --port used port number (default: 3000)')\n console.log('-l --live do live reload on file change')\n console.log('-o --open open in default browser')\n console.log('-t --test test online on https://LiaScript.github.io')\n console.log()\n console.log('-r --responsiveVoice add optional responsiveVoice support,')\n console.log(' or pass your own responsiveVoice key.')\n console.log(' Adding this feature might slow down')\n console.log(' the reloading speed.')\n console.log(' For more information visit:')\n console.log(' https://responsivevoice.org')\n\n process.exit()\n}\n\nliascript()\n\nserver.init(argv.node_modules)\n\ntry {\n server.start(\n argv.p || argv.port,\n argv.n || argv.hostname,\n argv.i || argv.input,\n argv.r || argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY,\n argv.l || argv.live,\n argv.o || argv.open,\n argv.t || argv.test\n )\n} catch (e) {\n console.error('Error: ', e.message)\n process.exit()\n}\n\nconsole.log('✨ hit Ctrl-c to close the server')\n","require('dotenv').config()\nimport * as express from 'express'\n\nimport * as fs from 'fs'\nimport * as path from 'path'\n\nconst cors = require('cors')\nconst handlebars = require('express-handlebars')\nconst ip = require('ip')\nconst open = require('open')\nconst bodyParser = require('body-parser')\n\nconst app: express.Application = express()\napp.use(bodyParser.json())\n\nvar dirname = ''\nvar node_modules\nvar reloadPath = ''\nvar liascriptPath = ''\n\nvar clients: any[] = []\n\nconst gotoScript = `<script>\nif (!window.LIA) {\n window.LIA = {}\n}\n\nvar filename__ = document.location.search.replace(\"?\"+document.location.origin, \"\")\n\nwindow.LIA.lineGoto = function(linenumber) {\n fetch(\"/lineGoto\", {\n method: \"POST\",\n headers: {'Content-Type': 'application/json'}, \n body: JSON.stringify({\n \"linenumber\": linenumber,\n \"filename\": filename__\n })\n }).then(res => {\n console.log(\"Goto line\", linenumber);\n });\n}\n\nconst events = new EventSource('/gotoLine');\nevents.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data);\n if (data.filename == filename__) {\n console.log(\"goto line:\", data.linenumber);\n window.LIA.gotoLine(data.linenumber)\n }\n } catch (e) {\n console.warn(\"gotoLine failed\")\n }\n};\n</script>`\n\nvar serverPointer: any\n\ninit(__dirname)\n\nexport function init(serverPath?: string, nodeModulesPath?: string) {\n dirname = serverPath || path.join(__dirname, '..')\n\n node_modules = nodeModulesPath || path.join(dirname, 'node_modules')\n\n reloadPath = path.resolve(\n path.join(node_modules, 'reloadsh.js/reloader.browser.js')\n )\n\n liascriptPath = path.resolve(\n path.join(node_modules, '@liascript/editor/dist')\n )\n}\n\nexport function start(\n port?: number,\n hostname?: string,\n input?: string,\n responsiveVoice?: string,\n liveReload?: boolean,\n openInBrowser?: boolean,\n testOnline?: boolean,\n gotoCallback?: (linenumber: number, filename: string) => void\n) {\n port = port || 3000\n hostname = hostname || 'localhost'\n openInBrowser = openInBrowser || false\n input = input || '.'\n liveReload = liveReload || false\n testOnline = testOnline || false\n\n var project: {\n path: string\n readme?: string\n } = {\n path: input,\n readme: undefined,\n }\n\n if (input) {\n const stats = fs.lstatSync(input)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n project.path = input\n } else if (stats.isFile()) {\n project.path = path.dirname(input)\n project.readme = path.basename(input)\n }\n }\n\n app.set('view engine', 'hbs')\n app.engine(\n 'hbs',\n handlebars({\n layoutsDir: path.resolve(path.join(dirname, 'views/layouts')),\n defaultLayout: 'main',\n extname: 'hbs',\n })\n )\n app.set('views', path.resolve(path.join(dirname, 'views')))\n\n app.get('/', function (req: express.Request, res: express.Response) {\n res.redirect('/home')\n })\n\n app.get('/gotoLine', eventsHandler)\n\n app.get('/home*', function (req: express.Request, res: express.Response) {\n const currentPath = project.path + '/' + req.params[0]\n\n const stats = fs.lstatSync(currentPath)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = fs.readdirSync(currentPath).filter((e: string) => {\n return e[0] !== '.'\n })\n\n let basePath = '/home'\n let pathNames = req.params[0].split('/').filter((e: string) => {\n return e !== ''\n })\n\n let paths: { name: string; href: string }[] = []\n for (let i = 0; i < pathNames.length; i++) {\n basePath += '/' + pathNames[i]\n paths.push({ name: pathNames[i], href: basePath })\n }\n\n res.render('main', {\n layout: 'index',\n path: paths,\n file: files\n .map((file: string) => {\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: fs.lstatSync(currentPath + '/' + file).isDirectory(),\n }\n })\n .sort(\n (\n a: {\n name: string\n href: string\n isDirectory: boolean\n },\n b: {\n name: string\n href: string\n isDirectory: boolean\n }\n ) => {\n if (a.isDirectory && !b.isDirectory) {\n return -1\n } else if (!a.isDirectory && b.isDirectory) {\n return 1\n } else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {\n return -1\n } else {\n return 1\n }\n }\n return 0\n }\n ),\n })\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith('.md')) {\n if (testOnline) {\n res.redirect(\n `https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`\n )\n } else {\n res.redirect(\n `/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`\n )\n }\n } else {\n res.sendFile(req.params[0], { root: project.path })\n }\n } else {\n res.send('ups, something went wrong')\n }\n })\n\n app.get(\n '/liascript/',\n function (req: express.Request, res: express.Response) {\n res.redirect('/liascript/index.html')\n }\n )\n\n app.get(\n '/liascript/index.html',\n function (req: express.Request, res: express.Response) {\n // ------------------------------------\n if (liveReload && responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (liveReload) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n ${gotoScript}\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(data.replace('</head>', `${gotoScript}</head>`))\n }\n )\n }\n }\n )\n\n // load everything from the liascript folder\n app.get(\n '/liascript/*',\n function (req: express.Request, res: express.Response) {\n res.sendFile(req.params[0], { root: liascriptPath })\n }\n )\n // ignore this one\n app.get('/sw.js', function (req: express.Request, res: express.Response) {})\n app.get(\n '/favicon.ico',\n function (req: express.Request, res: express.Response) {}\n )\n\n // pass the reloader, to be used for live updates\n app.get(\n '/reloader/reloader.js',\n function (req: express.Request, res: express.Response) {\n res.sendFile(reloadPath)\n }\n )\n\n // react to click-events\n app.post('/lineGoto', function (req: express.Request, res: express.Response) {\n if (gotoCallback) {\n try {\n const linenumber = req.body.linenumber\n const filename = req.body.filename\n gotoCallback(linenumber, filename)\n } catch (e) {\n console.warn(\n \"lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}\"\n )\n }\n }\n return res.json({})\n })\n\n // everything else comes from the current project folder\n app.get('/*', cors(), function (req: express.Request, res: express.Response) {\n res.sendFile(req.originalUrl, { root: project.path })\n })\n\n let localURL = 'http://' + hostname + ':' + port\n\n if (project.path && project.readme) {\n localURL +=\n '/liascript/index.html?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n if (testOnline && project.readme) {\n localURL =\n 'https://LiaScript.github.io/course/?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n const server = require('reloadsh.js')(\n app,\n liveReload ? [path.join(project.path, project.readme || '')] : []\n )\n\n if (liveReload) {\n console.log(\n `✨ watching for changes on: \"${path.join(\n project.path || '',\n project.readme || ''\n )}\"`\n )\n }\n\n server.on('error', (e: any) => {\n throw e\n })\n\n server.listen(port)\n\n if (openInBrowser) {\n open(localURL)\n }\n\n console.log('📡 starting server')\n console.log(` - local: ${localURL}`)\n console.log(\n ` - on your network: ${localURL.replace(hostname, ip.address())}`\n )\n\n serverPointer = server\n}\n\nexport function stop() {\n if (serverPointer) {\n serverPointer.close()\n }\n}\n\nexport function gotoLine(linenumber: number, filename: string) {\n clients.forEach((client) =>\n client.response.write(\n `data: ${JSON.stringify({\n linenumber: linenumber,\n filename: filename,\n })}\\n\\n`\n )\n )\n}\n\nfunction eventsHandler(\n request: express.Request,\n response: express.Response,\n next: any\n) {\n const headers = {\n 'Content-Type': 'text/event-stream',\n Connection: 'keep-alive',\n 'Cache-Control': 'no-cache',\n }\n response.writeHead(200, headers)\n\n const data = `data: \\n\\n`\n\n response.write(data)\n\n const clientId = Date.now()\n\n const newClient = {\n id: clientId,\n response,\n }\n\n clients.push(newClient)\n\n request.on('close', () => {\n console.log(`${clientId} Connection closed`)\n clients = clients.filter((client) => client.id !== clientId)\n })\n}\n"],"names":["$f14dee9e17222834$var$node_modules","$aRKkE$minimist","require","$aRKkE$path","$aRKkE$dotenv","$aRKkE$express","$aRKkE$fs","$aRKkE$cors","$aRKkE$expresshandlebars","$aRKkE$ip","$aRKkE$open","$aRKkE$bodyparser","$aRKkE$reloadshjs","$f14dee9e17222834$var$$parcel$__dirname","resolve","__dirname","config","$f14dee9e17222834$var$app","use","json","$f14dee9e17222834$var$dirname","$f14dee9e17222834$var$reloadPath","$f14dee9e17222834$var$liascriptPath","$f14dee9e17222834$var$clients","$f14dee9e17222834$var$gotoScript","$f14dee9e17222834$export$2cd8252107eb640b","serverPath","nodeModulesPath","join","$f14dee9e17222834$var$eventsHandler","request","response","next","writeHead","Connection","data","write","clientId","Date","now","push","id","on","console","log","filter","client","$71fcc9ea54afc905$var$argv","process","argv","slice","$71fcc9ea54afc905$var$liascript","v","version","exit","h","help","node_modules","$f14dee9e17222834$export$b3571188c770cc5a","port","hostname","input","responsiveVoice","liveReload","openInBrowser","testOnline","gotoCallback","project","path","readme","undefined","stats","lstatSync","isDirectory","isFile","dirname","basename","set","engine","layoutsDir","defaultLayout","extname","get","req","res","redirect","currentPath","params","files","readdirSync","e","basePath","pathNames","split","paths","i","length","name","href","render","layout","file","map","sort","a","b","toLocaleLowerCase","endsWith","sendFile","root","send","readFile","err","replace","post","originalUrl","localURL","server","listen","address","p","n","r","env","RESPONSIVE_VOICE_KEY","l","live","o","open","t","test","error","message"],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liascript/devserver",
3
- "version": "1.1.24--0.15.12",
3
+ "version": "1.1.26--0.16.1",
4
4
  "description": "Run a development server for LiaScript locally",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "author": "André Dietrich",
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@liascript/editor": "^1.1.7--0.15.12",
38
+ "@liascript/editor": "^1.1.7--0.16.1",
39
39
  "body-parser": "^1.20.2",
40
40
  "cors": "^2.8.5",
41
41
  "dotenv": "^5.0.1",
@@ -48,6 +48,7 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/express": "^4.17.11",
51
+ "@types/node": "^22.7.3",
51
52
  "parcel": "^2.10.3",
52
53
  "typescript": "^4.6.3"
53
54
  },
package/views/main.hbs CHANGED
@@ -7,7 +7,7 @@
7
7
  | |___| | (_| |___) | (__| | | | |_) | |_
8
8
  |_____|_|\__,_|____/ \___|_| |_| .__/ \__|
9
9
  |_|
10
- [ DevServer: 1.1.24--0.15.12 ]
10
+ [ DevServer: 1.1.26--0.16.1 ]
11
11
  </pre>
12
12
  </code>
13
13
  </h4>