@liascript/devserver 1.1.1--0.10.16 → 1.1.1--0.10.21
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 +1 -1
- package/dist/index.js +88 -88
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/views/main.hbs +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
var $9KXPr$minimist = require("minimist");
|
|
4
|
+
var $9KXPr$path = require("path");
|
|
4
5
|
var $9KXPr$dotenv = require("dotenv");
|
|
5
6
|
var $9KXPr$express = require("express");
|
|
6
7
|
var $9KXPr$fs = require("fs");
|
|
7
|
-
var $9KXPr$path = require("path");
|
|
8
8
|
var $9KXPr$cors = require("cors");
|
|
9
9
|
var $9KXPr$expresshandlebars = require("express-handlebars");
|
|
10
10
|
var $9KXPr$ip = require("ip");
|
|
11
11
|
var $9KXPr$open = require("open");
|
|
12
|
-
var $9KXPr$reloadshjs = require("reloadsh.js");
|
|
13
12
|
var $9KXPr$bodyparser = require("body-parser");
|
|
13
|
+
var $9KXPr$reloadshjs = require("reloadsh.js");
|
|
14
|
+
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
var $dbf4313da36ea993$var$__dirname1 = $9KXPr$path.resolve(__dirname, "../src");
|
|
18
20
|
|
|
19
21
|
$9KXPr$dotenv.config();
|
|
20
22
|
|
|
@@ -24,10 +26,10 @@ $9KXPr$dotenv.config();
|
|
|
24
26
|
|
|
25
27
|
const $dbf4313da36ea993$var$app = $9KXPr$express();
|
|
26
28
|
$dbf4313da36ea993$var$app.use($9KXPr$bodyparser.json());
|
|
27
|
-
var $dbf4313da36ea993$var$dirname =
|
|
29
|
+
var $dbf4313da36ea993$var$dirname = "";
|
|
28
30
|
var $dbf4313da36ea993$var$node_modules;
|
|
29
|
-
var $dbf4313da36ea993$var$reloadPath =
|
|
30
|
-
var $dbf4313da36ea993$var$liascriptPath =
|
|
31
|
+
var $dbf4313da36ea993$var$reloadPath = "";
|
|
32
|
+
var $dbf4313da36ea993$var$liascriptPath = "";
|
|
31
33
|
var $dbf4313da36ea993$var$clients = [];
|
|
32
34
|
const $dbf4313da36ea993$var$gotoScript = `<script>
|
|
33
35
|
if (!window.LIA) {
|
|
@@ -63,19 +65,19 @@ events.onmessage = (event) => {
|
|
|
63
65
|
};
|
|
64
66
|
</script>`;
|
|
65
67
|
var $dbf4313da36ea993$var$serverPointer;
|
|
66
|
-
$dbf4313da36ea993$export$2cd8252107eb640b(
|
|
68
|
+
$dbf4313da36ea993$export$2cd8252107eb640b($dbf4313da36ea993$var$__dirname1);
|
|
67
69
|
function $dbf4313da36ea993$export$2cd8252107eb640b(serverPath, nodeModulesPath) {
|
|
68
|
-
$dbf4313da36ea993$var$dirname = serverPath || $9KXPr$path.join(
|
|
69
|
-
$dbf4313da36ea993$var$node_modules = nodeModulesPath || $9KXPr$path.join($dbf4313da36ea993$var$dirname,
|
|
70
|
-
$dbf4313da36ea993$var$reloadPath = $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$node_modules,
|
|
71
|
-
$dbf4313da36ea993$var$liascriptPath = $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$node_modules,
|
|
70
|
+
$dbf4313da36ea993$var$dirname = serverPath || $9KXPr$path.join($dbf4313da36ea993$var$__dirname1, "..");
|
|
71
|
+
$dbf4313da36ea993$var$node_modules = nodeModulesPath || $9KXPr$path.join($dbf4313da36ea993$var$dirname, "node_modules");
|
|
72
|
+
$dbf4313da36ea993$var$reloadPath = $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$node_modules, "reloadsh.js/reloader.browser.js"));
|
|
73
|
+
$dbf4313da36ea993$var$liascriptPath = $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$node_modules, "@liascript/editor/dist"));
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
function $dbf4313da36ea993$export$b3571188c770cc5a(port, hostname, input, responsiveVoice, liveReload, openInBrowser, testOnline, gotoCallback) {
|
|
75
77
|
port = port || 3000;
|
|
76
|
-
hostname = hostname ||
|
|
78
|
+
hostname = hostname || "localhost";
|
|
77
79
|
openInBrowser = openInBrowser || false;
|
|
78
|
-
input = input ||
|
|
80
|
+
input = input || ".";
|
|
79
81
|
liveReload = liveReload || false;
|
|
80
82
|
testOnline = testOnline || false;
|
|
81
83
|
var project = {
|
|
@@ -91,45 +93,45 @@ function $dbf4313da36ea993$export$b3571188c770cc5a(port, hostname, input, respon
|
|
|
91
93
|
project.readme = $9KXPr$path.basename(input);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
$dbf4313da36ea993$var$app.set(
|
|
95
|
-
$dbf4313da36ea993$var$app.engine(
|
|
96
|
-
layoutsDir: $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$dirname,
|
|
97
|
-
defaultLayout:
|
|
98
|
-
extname:
|
|
96
|
+
$dbf4313da36ea993$var$app.set("view engine", "hbs");
|
|
97
|
+
$dbf4313da36ea993$var$app.engine("hbs", $9KXPr$expresshandlebars({
|
|
98
|
+
layoutsDir: $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$dirname, "views/layouts")),
|
|
99
|
+
defaultLayout: "main",
|
|
100
|
+
extname: "hbs"
|
|
99
101
|
}));
|
|
100
|
-
$dbf4313da36ea993$var$app.set(
|
|
101
|
-
$dbf4313da36ea993$var$app.get(
|
|
102
|
-
res.redirect(
|
|
102
|
+
$dbf4313da36ea993$var$app.set("views", $9KXPr$path.resolve($9KXPr$path.join($dbf4313da36ea993$var$dirname, "views")));
|
|
103
|
+
$dbf4313da36ea993$var$app.get("/", function(req, res) {
|
|
104
|
+
res.redirect("/home");
|
|
103
105
|
});
|
|
104
|
-
$dbf4313da36ea993$var$app.get(
|
|
105
|
-
$dbf4313da36ea993$var$app.get(
|
|
106
|
-
const currentPath = project.path +
|
|
106
|
+
$dbf4313da36ea993$var$app.get("/gotoLine", $dbf4313da36ea993$var$eventsHandler);
|
|
107
|
+
$dbf4313da36ea993$var$app.get("/home*", function(req, res) {
|
|
108
|
+
const currentPath = project.path + "/" + req.params[0];
|
|
107
109
|
const stats = $9KXPr$fs.lstatSync(currentPath);
|
|
108
110
|
// Is it a directory?
|
|
109
111
|
if (stats.isDirectory()) {
|
|
110
112
|
const files = $9KXPr$fs.readdirSync(currentPath).filter((e)=>{
|
|
111
|
-
return e[0] !==
|
|
113
|
+
return e[0] !== ".";
|
|
112
114
|
});
|
|
113
|
-
let basePath =
|
|
114
|
-
let pathNames = req.params[0].split(
|
|
115
|
-
return e !==
|
|
115
|
+
let basePath = "/home";
|
|
116
|
+
let pathNames = req.params[0].split("/").filter((e)=>{
|
|
117
|
+
return e !== "";
|
|
116
118
|
});
|
|
117
119
|
let paths = [];
|
|
118
120
|
for(let i = 0; i < pathNames.length; i++){
|
|
119
|
-
basePath +=
|
|
121
|
+
basePath += "/" + pathNames[i];
|
|
120
122
|
paths.push({
|
|
121
123
|
name: pathNames[i],
|
|
122
124
|
href: basePath
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
|
-
res.render(
|
|
126
|
-
layout:
|
|
127
|
+
res.render("main", {
|
|
128
|
+
layout: "index",
|
|
127
129
|
path: paths,
|
|
128
130
|
file: files.map((file)=>{
|
|
129
131
|
return {
|
|
130
132
|
name: file,
|
|
131
133
|
href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,
|
|
132
|
-
isDirectory: $9KXPr$fs.lstatSync(currentPath +
|
|
134
|
+
isDirectory: $9KXPr$fs.lstatSync(currentPath + "/" + file).isDirectory()
|
|
133
135
|
};
|
|
134
136
|
}).sort((a, b)=>{
|
|
135
137
|
if (a.isDirectory && !b.isDirectory) return -1;
|
|
@@ -142,54 +144,54 @@ function $dbf4313da36ea993$export$b3571188c770cc5a(port, hostname, input, respon
|
|
|
142
144
|
})
|
|
143
145
|
});
|
|
144
146
|
} else if (stats.isFile()) {
|
|
145
|
-
if (req.params[0].toLocaleLowerCase().endsWith(
|
|
147
|
+
if (req.params[0].toLocaleLowerCase().endsWith(".md")) {
|
|
146
148
|
if (testOnline) res.redirect(`https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`);
|
|
147
149
|
else res.redirect(`/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`);
|
|
148
150
|
} else res.sendFile(req.params[0], {
|
|
149
151
|
root: project.path
|
|
150
152
|
});
|
|
151
|
-
} else res.send(
|
|
153
|
+
} else res.send("ups, something went wrong");
|
|
152
154
|
});
|
|
153
|
-
$dbf4313da36ea993$var$app.get(
|
|
154
|
-
res.redirect(
|
|
155
|
+
$dbf4313da36ea993$var$app.get("/liascript/", function(req, res) {
|
|
156
|
+
res.redirect("/liascript/index.html");
|
|
155
157
|
});
|
|
156
|
-
$dbf4313da36ea993$var$app.get(
|
|
158
|
+
$dbf4313da36ea993$var$app.get("/liascript/index.html", function(req, res) {
|
|
157
159
|
// ------------------------------------
|
|
158
|
-
if (liveReload && responsiveVoice) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath +
|
|
159
|
-
res.send(data.replace(
|
|
160
|
+
if (liveReload && responsiveVoice) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath + "/index.html", "utf8", function(err, data) {
|
|
161
|
+
res.send(data.replace("</head>", `<script type='text/javascript' src='/reloader/reloader.js'></script>
|
|
160
162
|
<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>
|
|
161
163
|
${$dbf4313da36ea993$var$gotoScript}
|
|
162
164
|
</head>`));
|
|
163
165
|
});
|
|
164
|
-
else if (liveReload) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath +
|
|
165
|
-
res.send(data.replace(
|
|
166
|
+
else if (liveReload) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath + "/index.html", "utf8", function(err, data) {
|
|
167
|
+
res.send(data.replace("</head>", `<script type='text/javascript' src='/reloader/reloader.js'></script>
|
|
166
168
|
${$dbf4313da36ea993$var$gotoScript}
|
|
167
169
|
</head>`));
|
|
168
170
|
});
|
|
169
|
-
else if (responsiveVoice) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath +
|
|
170
|
-
res.send(data.replace(
|
|
171
|
+
else if (responsiveVoice) $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath + "/index.html", "utf8", function(err, data) {
|
|
172
|
+
res.send(data.replace("</head>", `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>
|
|
171
173
|
${$dbf4313da36ea993$var$gotoScript}
|
|
172
174
|
</head>`));
|
|
173
175
|
});
|
|
174
|
-
else $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath +
|
|
175
|
-
res.send(data.replace(
|
|
176
|
+
else $9KXPr$fs.readFile($dbf4313da36ea993$var$liascriptPath + "/index.html", "utf8", function(err, data) {
|
|
177
|
+
res.send(data.replace("</head>", `${$dbf4313da36ea993$var$gotoScript}</head>`));
|
|
176
178
|
});
|
|
177
179
|
});
|
|
178
180
|
// load everything from the liascript folder
|
|
179
|
-
$dbf4313da36ea993$var$app.get(
|
|
181
|
+
$dbf4313da36ea993$var$app.get("/liascript/*", function(req, res) {
|
|
180
182
|
res.sendFile(req.params[0], {
|
|
181
183
|
root: $dbf4313da36ea993$var$liascriptPath
|
|
182
184
|
});
|
|
183
185
|
});
|
|
184
186
|
// ignore this one
|
|
185
|
-
$dbf4313da36ea993$var$app.get(
|
|
186
|
-
$dbf4313da36ea993$var$app.get(
|
|
187
|
+
$dbf4313da36ea993$var$app.get("/sw.js", function(req, res) {});
|
|
188
|
+
$dbf4313da36ea993$var$app.get("/favicon.ico", function(req, res) {});
|
|
187
189
|
// pass the reloader, to be used for live updates
|
|
188
|
-
$dbf4313da36ea993$var$app.get(
|
|
190
|
+
$dbf4313da36ea993$var$app.get("/reloader/reloader.js", function(req, res) {
|
|
189
191
|
res.sendFile($dbf4313da36ea993$var$reloadPath);
|
|
190
192
|
});
|
|
191
193
|
// react to click-events
|
|
192
|
-
$dbf4313da36ea993$var$app.post(
|
|
194
|
+
$dbf4313da36ea993$var$app.post("/lineGoto", function(req, res) {
|
|
193
195
|
if (gotoCallback) try {
|
|
194
196
|
const linenumber = req.body.linenumber;
|
|
195
197
|
const filename = req.body.filename;
|
|
@@ -200,24 +202,24 @@ function $dbf4313da36ea993$export$b3571188c770cc5a(port, hostname, input, respon
|
|
|
200
202
|
return res.json({});
|
|
201
203
|
});
|
|
202
204
|
// everything else comes from the current project folder
|
|
203
|
-
$dbf4313da36ea993$var$app.get(
|
|
205
|
+
$dbf4313da36ea993$var$app.get("/*", $9KXPr$cors(), function(req, res) {
|
|
204
206
|
res.sendFile(req.originalUrl, {
|
|
205
207
|
root: project.path
|
|
206
208
|
});
|
|
207
209
|
});
|
|
208
|
-
let localURL =
|
|
209
|
-
if (project.path && project.readme) localURL +=
|
|
210
|
-
if (testOnline && project.readme) localURL =
|
|
210
|
+
let localURL = "http://" + hostname + ":" + port;
|
|
211
|
+
if (project.path && project.readme) localURL += "/liascript/index.html?http://" + hostname + ":" + port + "/" + project.readme;
|
|
212
|
+
if (testOnline && project.readme) localURL = "https://LiaScript.github.io/course/?http://" + hostname + ":" + port + "/" + project.readme;
|
|
211
213
|
const server = $9KXPr$reloadshjs($dbf4313da36ea993$var$app, liveReload ? [
|
|
212
|
-
$9KXPr$path.join(project.path, project.readme ||
|
|
214
|
+
$9KXPr$path.join(project.path, project.readme || "")
|
|
213
215
|
] : []);
|
|
214
|
-
if (liveReload) console.log(`✨ watching for changes on: "${$9KXPr$path.join(project.path ||
|
|
215
|
-
server.on(
|
|
216
|
+
if (liveReload) console.log(`✨ watching for changes on: "${$9KXPr$path.join(project.path || "", project.readme || "")}"`);
|
|
217
|
+
server.on("error", (e)=>{
|
|
216
218
|
throw e;
|
|
217
219
|
});
|
|
218
220
|
server.listen(port);
|
|
219
221
|
if (openInBrowser) $9KXPr$open(localURL);
|
|
220
|
-
console.log(
|
|
222
|
+
console.log("\uD83D\uDCE1 starting server");
|
|
221
223
|
console.log(` - local: ${localURL}`);
|
|
222
224
|
console.log(` - on your network: ${localURL.replace(hostname, $9KXPr$ip.address())}`);
|
|
223
225
|
$dbf4313da36ea993$var$serverPointer = server;
|
|
@@ -229,14 +231,13 @@ function $dbf4313da36ea993$export$5d5b784f9a618ec3(linenumber, filename) {
|
|
|
229
231
|
$dbf4313da36ea993$var$clients.forEach((client)=>client.response.write(`data: ${JSON.stringify({
|
|
230
232
|
linenumber: linenumber,
|
|
231
233
|
filename: filename
|
|
232
|
-
})}\n\n`)
|
|
233
|
-
);
|
|
234
|
+
})}\n\n`));
|
|
234
235
|
}
|
|
235
236
|
function $dbf4313da36ea993$var$eventsHandler(request, response, next) {
|
|
236
237
|
const headers = {
|
|
237
|
-
|
|
238
|
-
Connection:
|
|
239
|
-
|
|
238
|
+
"Content-Type": "text/event-stream",
|
|
239
|
+
Connection: "keep-alive",
|
|
240
|
+
"Cache-Control": "no-cache"
|
|
240
241
|
};
|
|
241
242
|
response.writeHead(200, headers);
|
|
242
243
|
const data = `data: \n\n`;
|
|
@@ -247,10 +248,9 @@ function $dbf4313da36ea993$var$eventsHandler(request, response, next) {
|
|
|
247
248
|
response: response
|
|
248
249
|
};
|
|
249
250
|
$dbf4313da36ea993$var$clients.push(newClient);
|
|
250
|
-
request.on(
|
|
251
|
+
request.on("close", ()=>{
|
|
251
252
|
console.log(`${clientId} Connection closed`);
|
|
252
|
-
$dbf4313da36ea993$var$clients = $dbf4313da36ea993$var$clients.filter((client)=>client.id !== clientId
|
|
253
|
-
);
|
|
253
|
+
$dbf4313da36ea993$var$clients = $dbf4313da36ea993$var$clients.filter((client)=>client.id !== clientId);
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -258,36 +258,36 @@ function $dbf4313da36ea993$var$eventsHandler(request, response, next) {
|
|
|
258
258
|
|
|
259
259
|
const $aa3bf3164f10b283$var$argv = $9KXPr$minimist(process.argv.slice(2));
|
|
260
260
|
function $aa3bf3164f10b283$var$liascript() {
|
|
261
|
-
console.log(
|
|
262
|
-
console.log(
|
|
261
|
+
console.log(" _ _ ____ _ _");
|
|
262
|
+
console.log("| | (_) __ _/ ___| ___ _ __(_)_ __ | |_");
|
|
263
263
|
console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|");
|
|
264
|
-
console.log(
|
|
265
|
-
console.log(
|
|
266
|
-
console.log(
|
|
264
|
+
console.log("| |___| | (_| |___) | (__| | | | |_) | |_ ");
|
|
265
|
+
console.log("|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|");
|
|
266
|
+
console.log(" |_|");
|
|
267
267
|
console.log();
|
|
268
268
|
}
|
|
269
269
|
if ($aa3bf3164f10b283$var$argv.v || $aa3bf3164f10b283$var$argv.version) {
|
|
270
|
-
console.log(
|
|
271
|
-
console.log(
|
|
270
|
+
console.log("DevServer: 1.1.1");
|
|
271
|
+
console.log("LiaScript: 0.10.21");
|
|
272
272
|
process.exit();
|
|
273
273
|
}
|
|
274
274
|
if ($aa3bf3164f10b283$var$argv.h || $aa3bf3164f10b283$var$argv.help) {
|
|
275
275
|
$aa3bf3164f10b283$var$liascript();
|
|
276
|
-
console.log(
|
|
277
|
-
console.log(
|
|
278
|
-
console.log(
|
|
279
|
-
console.log(
|
|
280
|
-
console.log(
|
|
281
|
-
console.log(
|
|
282
|
-
console.log(
|
|
283
|
-
console.log(
|
|
276
|
+
console.log("-h --help show this help");
|
|
277
|
+
console.log("-v --version show version information");
|
|
278
|
+
console.log("-i --input input README.md file or folder (default: .)");
|
|
279
|
+
console.log("-n --hostname hostname of your server (default: localhost)");
|
|
280
|
+
console.log("-p --port used port number (default: 3000)");
|
|
281
|
+
console.log("-l --live do live reload on file change");
|
|
282
|
+
console.log("-o --open open in default browser");
|
|
283
|
+
console.log("-t --test test online on https://LiaScript.github.io");
|
|
284
284
|
console.log();
|
|
285
|
-
console.log(
|
|
286
|
-
console.log(
|
|
287
|
-
console.log(
|
|
288
|
-
console.log(
|
|
289
|
-
console.log(
|
|
290
|
-
console.log(
|
|
285
|
+
console.log("-r --responsiveVoice add optional responsiveVoice support,");
|
|
286
|
+
console.log(" or pass your own responsiveVoice key.");
|
|
287
|
+
console.log(" Adding this feature might slow down");
|
|
288
|
+
console.log(" the reloading speed.");
|
|
289
|
+
console.log(" For more information visit:");
|
|
290
|
+
console.log(" https://responsivevoice.org");
|
|
291
291
|
process.exit();
|
|
292
292
|
}
|
|
293
293
|
$aa3bf3164f10b283$var$liascript();
|
|
@@ -295,10 +295,10 @@ $dbf4313da36ea993$export$2cd8252107eb640b($aa3bf3164f10b283$var$argv.node_module
|
|
|
295
295
|
try {
|
|
296
296
|
$dbf4313da36ea993$export$b3571188c770cc5a($aa3bf3164f10b283$var$argv.p || $aa3bf3164f10b283$var$argv.port, $aa3bf3164f10b283$var$argv.n || $aa3bf3164f10b283$var$argv.hostname, $aa3bf3164f10b283$var$argv.i || $aa3bf3164f10b283$var$argv.input, $aa3bf3164f10b283$var$argv.r || $aa3bf3164f10b283$var$argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY, $aa3bf3164f10b283$var$argv.l || $aa3bf3164f10b283$var$argv.live, $aa3bf3164f10b283$var$argv.o || $aa3bf3164f10b283$var$argv.open, $aa3bf3164f10b283$var$argv.t || $aa3bf3164f10b283$var$argv.test);
|
|
297
297
|
} catch (e) {
|
|
298
|
-
console.error(
|
|
298
|
+
console.error("Error: ", e.message);
|
|
299
299
|
process.exit();
|
|
300
300
|
}
|
|
301
|
-
console.log(
|
|
301
|
+
console.log("\u2728 hit Ctrl-c to close the server");
|
|
302
302
|
|
|
303
303
|
|
|
304
304
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;ACAA;;;;AAA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OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,IAAI,EAAE;CACf;AAED,OAAO,CAAC,GAAG,CAAC,oCAAkC,CAAC","sources":["src/index.ts","src/lib.ts"],"sourcesContent":["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.1')\n console.log('LiaScript: 0.10.16')\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":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;ACAA;;;;;;AAAA,oBAAwB,EAAE;;;;;;AAY1B,MAAM,yBAAG,GAAwB,cAAO,EAAE;AAC1C,yBAAG,CAAC,GAAG,CAAC,sBAAe,EAAE,CAAC;AAE1B,IAAI,6BAAO,GAAG,EAAE;AAChB,IAAI,kCAAY;AAChB,IAAI,gCAAU,GAAG,EAAE;AACnB,IAAI,mCAAa,GAAG,EAAE;AAEtB,IAAI,6BAAO,GAAG,EAAE;AAEhB,MAAM,gCAAU,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgCX,CAAC;AAEV,IAAI,mCAAa,AAAK;AAEtB,yCAAI,CAAC,gCAAS,CAAC;AAER,SAAS,yCAAI,CAAC,UAAmB,EAAE,eAAwB,EAAE;IAClE,6BAAO,GAAG,UAAU,IAAI,gBAAS,CAAC,gCAAS,EAAE,IAAI,CAAC;IAElD,kCAAY,GAAG,eAAe,IAAI,gBAAS,CAAC,6BAAO,EAAE,cAAc,CAAC;IAEpE,gCAAU,GAAG,mBAAY,CACvB,gBAAS,CAAC,kCAAY,EAAE,iCAAiC,CAAC,CAC3D;IAED,mCAAa,GAAG,mBAAY,CAC1B,gBAAS,CAAC,kCAAY,EAAE,wBAAwB,CAAC,CAClD;CACF;;AAEM,SAAS,yCAAK,CACnB,IAAa,EACb,QAAiB,EACjB,KAAc,EACd,eAAwB,EACxB,UAAoB,EACpB,aAAuB,EACvB,UAAoB,EACpB,YAA6D,EAC7D;IACA,IAAI,GAAG,IAAI,IAAI,IAAI;IACnB,QAAQ,GAAG,QAAQ,IAAI,WAAW;IAClC,aAAa,GAAG,aAAa,IAAI,KAAK;IACtC,KAAK,GAAG,KAAK,IAAI,GAAG;IACpB,UAAU,GAAG,UAAU,IAAI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CAAC,IAAI,EACnB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,EACnB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,CACpB;CACF,CAAC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,IAAI,EAAE;CACf;AAED,OAAO,CAAC,GAAG,CAAC,uCAAkC,CAAC","sources":["src/index.ts","src/lib.ts"],"sourcesContent":["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.1')\n console.log('LiaScript: 0.10.21')\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":[],"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.1--0.10.
|
|
3
|
+
"version": "1.1.1--0.10.21",
|
|
4
4
|
"description": "Run a development server for LiaScript locally",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"author": "André Dietrich",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@liascript/editor": "^1.1.0--0.10.
|
|
35
|
+
"@liascript/editor": "^1.1.0--0.10.21",
|
|
36
36
|
"body-parser": "^1.20.0",
|
|
37
37
|
"cors": "^2.8.5",
|
|
38
38
|
"dotenv": "^5.0.1",
|