@liascript/devserver 1.1.2--0.12.12 → 1.1.5--0.14.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.
@@ -0,0 +1,64 @@
1
+ on:
2
+ push:
3
+ tags:
4
+ - "*"
5
+
6
+ name: Create Release
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout Code
13
+ uses: actions/checkout@v2
14
+ - name: Setup Node
15
+ uses: actions/setup-node@v2
16
+ with:
17
+ node-version: '14'
18
+ - name: Building Package
19
+ run: |
20
+ npm install -g pkg
21
+
22
+ npm install
23
+ npm run build
24
+ npm run release
25
+ - name: Create Release
26
+ id: create_release
27
+ uses: actions/create-release@v1
28
+ env:
29
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
+ with:
31
+ tag_name: ${{ github.ref }}
32
+ release_name: Release ${{ github.ref }}
33
+ body: |
34
+ Download your OS specific binary from below
35
+ draft: false
36
+ prerelease: false
37
+ - name: Upload Linux Asset
38
+ uses: actions/upload-release-asset@v1
39
+ env:
40
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41
+ with:
42
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
43
+ asset_path: ./release/linux/liascript-devserver
44
+ asset_name: liascript-devserver-linux
45
+ asset_content_type: application/x-executable
46
+ - name: Upload MacOS Asset
47
+ uses: actions/upload-release-asset@v1
48
+ env:
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
+ with:
51
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
52
+ asset_path: ./release/macos/liascript-devserver
53
+ asset_name: liascript-devserver-macos
54
+ asset_content_type: application/octet-stream
55
+ - name: Upload Windows Asset
56
+ uses: actions/upload-release-asset@v1
57
+ env:
58
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
+ with:
60
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
61
+ asset_path: ./release/windows/liascript-devserver.exe
62
+ asset_name: liascript-devserver-win.exe
63
+ asset_content_type: application/vnd.microsoft.portable-executable
64
+
package/README.md CHANGED
@@ -6,6 +6,12 @@ server that can be used locally to preview courses within the browser.
6
6
 
7
7
  ## Install
8
8
 
9
+ You can directly download the latest version for your system from the assets:
10
+
11
+ https://github.com/LiaScript/LiaScript-DevServer/releases/
12
+
13
+ or install it via the NodeJS package manager `npm` ...
14
+
9
15
  ### NodeJS
10
16
 
11
17
  If you haven't installed it yet, you will have to install NodeJS for your
@@ -78,8 +84,8 @@ updated separately, we use two different version, one for the devServer and one
78
84
  for LiaScript.
79
85
 
80
86
  ```text
81
- DevServer: 1.1.2
82
- LiaScript: 0.12.12
87
+ DevServer: 1.1.5
88
+ LiaScript: 0.14.1
83
89
  ```
84
90
 
85
91
  ### `--input`
package/dist/index.js CHANGED
@@ -34,21 +34,12 @@ events.onmessage = (event) => {
34
34
  };
35
35
  </script>`;function y(o,n){u=o||t.join(h,".."),e=n||t.join(u,"node_modules"),m=t.resolve(t.join(e,"reloadsh.js/reloader.browser.js")),g=t.resolve(t.join(e,"@liascript/editor/dist"))}function w(e,o,t){o.writeHead(200,{"Content-Type":"text/event-stream",Connection:"keep-alive","Cache-Control":"no-cache"});let n=`data:
36
36
 
37
- `;o.write(n);let i=Date.now();f.push({id:i,response:o}),e.on("close",()=>{console.log(`${i} Connection closed`),f=f.filter(e=>e.id!==i)})}y(h);const j=o(process.argv.slice(2));function b(){console.log(" _ _ ____ _ _"),console.log("| | (_) __ _/ ___| ___ _ __(_)_ __ | |_"),console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|"),console.log("| |___| | (_| |___) | (__| | | | |_) | |_ "),console.log("|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|"),console.log(" |_|"),console.log()}(j.v||j.version)&&(console.log("DevServer: 1.1.2"),console.log("LiaScript: 0.12.12"),process.exit()),(j.h||j.help)&&(b(),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()),b(),y(j.node_modules);try{!function(e,o,n,i,p,h,f,y){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=r.lstatSync(n);// Is it a directory?
38
- 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",w),_.get("/home*",function(t,n){let i=j.path+"/"+t.params[0],s=r.lstatSync(i);// Is it a directory?
39
- if(s.isDirectory()){let s=r.readdirSync(i).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:r.lstatSync(i+"/"+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){// ------------------------------------
40
- p&&i?r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
37
+ `;o.write(n);let i=Date.now();f.push({id:i,response:o}),e.on("close",()=>{console.log(`${i} Connection closed`),f=f.filter(e=>e.id!==i)})}y(h);const j=o(process.argv.slice(2));function b(){console.log(" _ _ ____ _ _"),console.log("| | (_) __ _/ ___| ___ _ __(_)_ __ | |_"),console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|"),console.log("| |___| | (_| |___) | (__| | | | |_) | |_ "),console.log("|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|"),console.log(" |_|"),console.log()}(j.v||j.version)&&(console.log("DevServer: 1.1.5"),console.log("LiaScript: 0.14.1"),process.exit()),(j.h||j.help)&&(b(),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()),b(),y(j.node_modules);try{!function(e,o,n,i,p,h,f,y){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=r.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",w),_.get("/home*",function(t,n){let i=j.path+"/"+t.params[0],s=r.lstatSync(i);if(s.isDirectory()){let s=r.readdirSync(i).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:r.lstatSync(i+"/"+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&&i?r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
41
38
  <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${i}'></script>
42
39
  ${v}
43
40
  </head>`))}):p?r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='/reloader/reloader.js'></script>
44
41
  ${v}
45
42
  </head>`))}):i?r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${i}'></script>
46
43
  ${v}
47
- </head>`))}):r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`${v}</head>`))})}),// load everything from the liascript folder
48
- _.get("/liascript/*",function(e,o){o.sendFile(e.params[0],{root:g})}),// ignore this one
49
- _.get("/sw.js",function(e,o){}),_.get("/favicon.ico",function(e,o){}),// pass the reloader, to be used for live updates
50
- _.get("/reloader/reloader.js",function(e,o){o.sendFile(m)}),// react to click-events
51
- _.post("/lineGoto",function(e,o){if(y)try{let o=e.body.linenumber,t=e.body.filename;y(o,t)}catch(e){console.warn("lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}")}return o.json({})}),// everything else comes from the current project folder
52
- _.get("/*",s(),function(e,o){o.sendFile(e.originalUrl,{root:j.path})});let b="http://"+o+":"+e;j.path&&j.readme&&(b+="/liascript/index.html?http://"+o+":"+e+"/"+j.readme),f&&j.readme&&(b="https://LiaScript.github.io/course/?http://"+o+":"+e+"/"+j.readme);let x=d(_,p?[t.join(j.path,j.readme||"")]:[]);p&&console.log(`✨ watching for changes on: "${t.join(j.path||"",j.readme||"")}"`),x.on("error",e=>{throw e}),x.listen(e),h&&c(b),console.log("\uD83D\uDCE1 starting server"),console.log(` - local: ${b}`),console.log(` - on your network: ${b.replace(o,a.address())}`)}(j.p||j.port,j.n||j.hostname,j.i||j.input,j.r||j.responsiveVoice||process.env.RESPONSIVE_VOICE_KEY,j.l||j.live,j.o||j.open,j.t||j.test)}catch(e){console.error("Error: ",e.message),process.exit()}console.log("✨ hit Ctrl-c to close the server");//# sourceMappingURL=index.js.map
53
-
44
+ </head>`))}):r.readFile(g+"/index.html","utf8",function(e,t){o.send(t.replace("</head>",`${v}</head>`))})}),_.get("/liascript/*",function(e,o){o.sendFile(e.params[0],{root:g})}),_.get("/sw.js",function(e,o){}),_.get("/favicon.ico",function(e,o){}),_.get("/reloader/reloader.js",function(e,o){o.sendFile(m)}),_.post("/lineGoto",function(e,o){if(y)try{let o=e.body.linenumber,t=e.body.filename;y(o,t)}catch(e){console.warn("lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}")}return o.json({})}),_.get("/*",s(),function(e,o){o.sendFile(e.originalUrl,{root:j.path})});let b="http://"+o+":"+e;j.path&&j.readme&&(b+="/liascript/index.html?http://"+o+":"+e+"/"+j.readme),f&&j.readme&&(b="https://LiaScript.github.io/course/?http://"+o+":"+e+"/"+j.readme);let x=d(_,p?[t.join(j.path,j.readme||"")]:[]);p&&console.log(`\u{2728} watching for changes on: "${t.join(j.path||"",j.readme||"")}"`),x.on("error",e=>{throw e}),x.listen(e),h&&c(b),console.log("\uD83D\uDCE1 starting server"),console.log(` - local: ${b}`),console.log(` - on your network: ${b.replace(o,a.address())}`)}(j.p||j.port,j.n||j.hostname,j.i||j.input,j.r||j.responsiveVoice||process.env.RESPONSIVE_VOICE_KEY,j.l||j.live,j.o||j.open,j.t||j.test)}catch(e){console.error("Error: ",e.message),process.exit()}console.log("✨ hit Ctrl-c to close the server");
54
45
  //# sourceMappingURL=index.js.map
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,GAAA,CAAI,EAAR,IAAA,IAEA,IAAI,EAAU,GAEV,EAAa,GACb,EAAgB,GAEhB,EAAU,EAAE,CAEhB,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,SAAA,CAAU,IALH,CACd,eAAgB,oBAChB,WAAY,aACZ,gBAAiB,UACnB,GAGA,IAAM,EAAO,CAAC;;AAAU,CA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AA,CAAI,oBAAA,CAC9C,EAAK,CAAA,EAAK,EAAK,IAAA,CACf,EAAK,CAAA,EAAK,EAAK,IAAA,CACf,EAAK,CAAA,EAAK,EAAK,IAPjB,CASF,CAAE,MAAO,EAAG,CACV,QAAQ,KAAA,CAAM,UAAW,EAAE,OAA3B,EACA,QAAQ,IAAR,EACF,CAEA,QAAQ,GAAA,CAAI,mC,kC","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(`✨ 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.2\");\n console.log(\"LiaScript: 0.12.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(\"✨ 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.2')\n console.log('LiaScript: 0.12.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 = []\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","linenumber","body","filename","warn","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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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.5\");\n console.log(\"LiaScript: 0.14.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.5')\n console.log('LiaScript: 0.14.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","linenumber","body","filename","warn","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,13 +1,16 @@
1
1
  {
2
2
  "name": "@liascript/devserver",
3
- "version": "1.1.2--0.12.12",
3
+ "version": "1.1.5--0.14.1",
4
4
  "description": "Run a development server for LiaScript locally",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "npx parcel build src/index.ts && npm run shebang && npm run lib",
8
8
  "lib": "tsc --module commonjs -d src/lib.ts --outDir dist",
9
9
  "shebang": "sed -i '1i #!/usr/bin/env node\\n' dist/index.js && chmod +x dist/index.js",
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "release": "npm run release_win && npm run release_linux && npm run release_macos",
11
+ "release_win": "pkg . -t node18-win --output release/windows/liascript-devserver -C GZip",
12
+ "release_linux": "pkg . -t node18-linux --output release/linux/liascript-devserver -C GZip",
13
+ "release_macos": "pkg . -t node18-macos --output release/macos/liascript-devserver -C GZip"
11
14
  },
12
15
  "repository": {
13
16
  "type": "git",
@@ -32,20 +35,20 @@
32
35
  "author": "André Dietrich",
33
36
  "license": "MIT",
34
37
  "dependencies": {
35
- "@liascript/editor": "^1.1.2--0.12.12",
36
- "body-parser": "^1.20.0",
38
+ "@liascript/editor": "^1.1.3--0.14.1",
39
+ "body-parser": "^1.20.2",
37
40
  "cors": "^2.8.5",
38
41
  "dotenv": "^5.0.1",
39
- "express": "^4.17.3",
42
+ "express": "^4.18.2",
40
43
  "express-handlebars": "^5.3.5",
41
- "ip": "^1.1.5",
42
- "minimist": "^1.2.6",
43
- "open": "^8.4.0",
44
+ "ip": "^1.1.8",
45
+ "minimist": "^1.2.8",
46
+ "open": "^8.4.2",
44
47
  "reloadsh.js": "^2.2.1"
45
48
  },
46
49
  "devDependencies": {
47
50
  "@types/express": "^4.17.11",
48
- "parcel": "^2.9.3",
51
+ "parcel": "^2.10.3",
49
52
  "typescript": "^4.6.3"
50
53
  },
51
54
  "engines": {
@@ -56,5 +59,12 @@
56
59
  "context": "node",
57
60
  "optimize": true
58
61
  }
62
+ },
63
+ "pkg": {
64
+ "assets": [
65
+ "node_modules/@liascript/editor/dist/**/*",
66
+ "node_modules/reloadsh.js/reloader.browser.js",
67
+ "views/**/*"
68
+ ]
59
69
  }
60
70
  }
package/views/main.hbs CHANGED
@@ -7,7 +7,7 @@
7
7
  | |___| | (_| |___) | (__| | | | |_) | |_
8
8
  |_____|_|\__,_|____/ \___|_| |_| .__/ \__|
9
9
  |_|
10
- [ DevServer: 1.1.2--0.12.12 ]
10
+ [ DevServer: 1.1.5--0.14.1 ]
11
11
  </pre>
12
12
  </code>
13
13
  </h4>