FIx wrong single quote setting

This commit is contained in:
Luc 2024-05-30 09:40:28 +08:00
parent e2afd80a3b
commit d26f7af54e
9 changed files with 816 additions and 817 deletions

View File

@ -3,8 +3,7 @@
"tabWidth": 4, "tabWidth": 4,
"useTabs": false, "useTabs": false,
"semi": true, "semi": true,
"singleQuote": true, "singleQuote": false,
"jsxSingleQuote": false,
"trailingComma": "es5", "trailingComma": "es5",
"bracketSpacing": true, "bracketSpacing": true,
"bracketSameLine": false, "bracketSameLine": false,

View File

@ -1,80 +1,80 @@
let path = require('path'); let path = require("path");
const fs = require('fs'); const fs = require("fs");
const { createReadStream, createWriteStream } = require('fs'); const { createReadStream, createWriteStream } = require("fs");
const { createGzip } = require('zlib'); const { createGzip } = require("zlib");
const chalk = require('chalk'); const chalk = require("chalk");
let distPath = path.normalize(__dirname + '/../dist/'); let distPath = path.normalize(__dirname + "/../dist/");
let srcPath = path.normalize(__dirname + '/../assets/'); let srcPath = path.normalize(__dirname + "/../assets/");
let headerPath = path.normalize( let headerPath = path.normalize(
__dirname + '/../../esp3d/src/modules/http/favicon.h' __dirname + "/../../esp3d/src/modules/http/favicon.h"
); );
const convertToC = (filepath) => { const convertToC = (filepath) => {
console.log(chalk.yellow('Converting bin to text file')); console.log(chalk.yellow("Converting bin to text file"));
//Cleaning files //Cleaning files
if (fs.existsSync(distPath + 'out.tmp')) fs.rmSync(distPath + 'out.tmp'); if (fs.existsSync(distPath + "out.tmp")) fs.rmSync(distPath + "out.tmp");
if (fs.existsSync(distPath + 'favicon.h')) if (fs.existsSync(distPath + "favicon.h"))
fs.rmSync(distPath + 'favicon.h'); fs.rmSync(distPath + "favicon.h");
const data = new Uint8Array(fs.readFileSync(filepath, { flag: 'r' })); const data = new Uint8Array(fs.readFileSync(filepath, { flag: "r" }));
console.log('data size is ', data.length); console.log("data size is ", data.length);
let out = '#define favicon_size ' + data.length + '\n'; let out = "#define favicon_size " + data.length + "\n";
out += 'const unsigned char favicon[' + data.length + '] PROGMEM = {\n '; out += "const unsigned char favicon[" + data.length + "] PROGMEM = {\n ";
let nb = 0; let nb = 0;
data.forEach((byte, index) => { data.forEach((byte, index) => {
out += out +=
' 0x' + " 0x" +
(byte.toString(16).length == 1 ? '0' : '') + (byte.toString(16).length == 1 ? "0" : "") +
byte.toString(16); byte.toString(16);
if (index < data.length - 1) out += ','; if (index < data.length - 1) out += ",";
if (nb == 15) { if (nb == 15) {
out += '\n '; out += "\n ";
nb = 0; nb = 0;
} else { } else {
nb++; nb++;
} }
}); });
out += '\n};\n'; out += "\n};\n";
fs.writeFileSync(distPath + 'out.tmp', out); fs.writeFileSync(distPath + "out.tmp", out);
//Check conversion //Check conversion
if (fs.existsSync(distPath + 'out.tmp')) { if (fs.existsSync(distPath + "out.tmp")) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Conversion failed')); console.log(chalk.red("[error]Conversion failed"));
return; return;
} }
//Format header file //Format header file
console.log(chalk.yellow('Building header')); console.log(chalk.yellow("Building header"));
fs.writeFileSync( fs.writeFileSync(
distPath + 'favicon.h', distPath + "favicon.h",
fs.readFileSync(srcPath + 'header.txt') fs.readFileSync(srcPath + "header.txt")
); );
let bin2cfile = fs.readFileSync(distPath + 'out.tmp').toString(); let bin2cfile = fs.readFileSync(distPath + "out.tmp").toString();
fs.appendFileSync(distPath + 'favicon.h', bin2cfile); fs.appendFileSync(distPath + "favicon.h", bin2cfile);
fs.appendFileSync( fs.appendFileSync(
distPath + 'favicon.h', distPath + "favicon.h",
fs.readFileSync(srcPath + 'footer.txt') fs.readFileSync(srcPath + "footer.txt")
); );
//Check format result //Check format result
if (fs.existsSync(distPath + 'favicon.h')) { if (fs.existsSync(distPath + "favicon.h")) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Conversion failed')); console.log(chalk.red("[error]Conversion failed"));
return; return;
} }
//Move file to src //Move file to src
console.log(chalk.yellow('Overwriting header in sources')); console.log(chalk.yellow("Overwriting header in sources"));
fs.writeFileSync(headerPath, fs.readFileSync(distPath + 'favicon.h')); fs.writeFileSync(headerPath, fs.readFileSync(distPath + "favicon.h"));
if (fs.existsSync(headerPath)) { if (fs.existsSync(headerPath)) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Overwriting failed')); console.log(chalk.red("[error]Overwriting failed"));
return; return;
} }
}; };
@ -85,10 +85,10 @@ const compressFile = (filePath, targetPath) => {
stream stream
.pipe(createGzip(targetPath)) .pipe(createGzip(targetPath))
.pipe(createWriteStream(targetPath)) .pipe(createWriteStream(targetPath))
.on('finish', () => { .on("finish", () => {
console.log(`Successfully compressed at ${targetPath}`); console.log(`Successfully compressed at ${targetPath}`);
convertToC(targetPath); convertToC(targetPath);
}); });
}; };
compressFile(srcPath + 'favicon.ico', distPath + 'favicon.ico.gz'); compressFile(srcPath + "favicon.ico", distPath + "favicon.ico.gz");

View File

@ -1,76 +1,76 @@
let path = require('path'); let path = require("path");
const fs = require('fs'); const fs = require("fs");
const child_process = require('child_process'); const child_process = require("child_process");
const chalk = require('chalk'); const chalk = require("chalk");
let distPath = path.normalize(__dirname + '/../dist/'); let distPath = path.normalize(__dirname + "/../dist/");
let srcPath = path.normalize(__dirname + '/../src/'); let srcPath = path.normalize(__dirname + "/../src/");
let headerPath = path.normalize( let headerPath = path.normalize(
__dirname + '/../../esp3d/src/modules/http/embedded.h' __dirname + "/../../esp3d/src/modules/http/embedded.h"
); );
console.log(chalk.yellow('Converting bin to text file')); console.log(chalk.yellow("Converting bin to text file"));
//Cleaning files //Cleaning files
if (fs.existsSync(distPath + 'out.tmp')) fs.rmSync(distPath + 'out.tmp'); if (fs.existsSync(distPath + "out.tmp")) fs.rmSync(distPath + "out.tmp");
if (fs.existsSync(distPath + 'embedded.h')) fs.rmSync(distPath + 'embedded.h'); if (fs.existsSync(distPath + "embedded.h")) fs.rmSync(distPath + "embedded.h");
const data = new Uint8Array( const data = new Uint8Array(
fs.readFileSync(distPath + 'index.html.gz', { flag: 'r' }) fs.readFileSync(distPath + "index.html.gz", { flag: "r" })
); );
console.log('data size is ', data.length); console.log("data size is ", data.length);
let out = '#define tool_html_gz_size ' + data.length + '\n'; let out = "#define tool_html_gz_size " + data.length + "\n";
out += 'const unsigned char tool_html_gz[' + data.length + '] PROGMEM = {\n '; out += "const unsigned char tool_html_gz[" + data.length + "] PROGMEM = {\n ";
let nb = 0; let nb = 0;
data.forEach((byte, index) => { data.forEach((byte, index) => {
out += out +=
' 0x' + (byte.toString(16).length == 1 ? '0' : '') + byte.toString(16); " 0x" + (byte.toString(16).length == 1 ? "0" : "") + byte.toString(16);
if (index < data.length - 1) out += ','; if (index < data.length - 1) out += ",";
if (nb == 15) { if (nb == 15) {
out += '\n '; out += "\n ";
nb = 0; nb = 0;
} else { } else {
nb++; nb++;
} }
}); });
out += '\n};\n'; out += "\n};\n";
fs.writeFileSync(distPath + 'out.tmp', out); fs.writeFileSync(distPath + "out.tmp", out);
//Check conversion //Check conversion
if (fs.existsSync(distPath + 'out.tmp')) { if (fs.existsSync(distPath + "out.tmp")) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Conversion failed')); console.log(chalk.red("[error]Conversion failed"));
return; return;
} }
//Format header file //Format header file
console.log(chalk.yellow('Building header')); console.log(chalk.yellow("Building header"));
fs.writeFileSync( fs.writeFileSync(
distPath + 'embedded.h', distPath + "embedded.h",
fs.readFileSync(srcPath + 'header.txt') fs.readFileSync(srcPath + "header.txt")
); );
let bin2cfile = fs.readFileSync(distPath + 'out.tmp').toString(); let bin2cfile = fs.readFileSync(distPath + "out.tmp").toString();
fs.appendFileSync(distPath + 'embedded.h', bin2cfile); fs.appendFileSync(distPath + "embedded.h", bin2cfile);
fs.appendFileSync( fs.appendFileSync(
distPath + 'embedded.h', distPath + "embedded.h",
fs.readFileSync(srcPath + 'footer.txt') fs.readFileSync(srcPath + "footer.txt")
); );
//Check format result //Check format result
if (fs.existsSync(distPath + 'embedded.h')) { if (fs.existsSync(distPath + "embedded.h")) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Conversion failed')); console.log(chalk.red("[error]Conversion failed"));
return; return;
} }
//Move file to src //Move file to src
console.log(chalk.yellow('Overwriting header in sources')); console.log(chalk.yellow("Overwriting header in sources"));
fs.writeFileSync(headerPath, fs.readFileSync(distPath + 'embedded.h')); fs.writeFileSync(headerPath, fs.readFileSync(distPath + "embedded.h"));
if (fs.existsSync(headerPath)) { if (fs.existsSync(headerPath)) {
console.log(chalk.green('[ok]')); console.log(chalk.green("[ok]"));
} else { } else {
console.log(chalk.red('[error]Overwriting failed')); console.log(chalk.red("[error]Overwriting failed"));
return; return;
} }

View File

@ -1,7 +1,7 @@
const path = require('path'); const path = require("path");
const { createReadStream, createWriteStream } = require('fs'); const { createReadStream, createWriteStream } = require("fs");
const { createGzip } = require('zlib'); const { createGzip } = require("zlib");
const faviconPath = path.normalize(__dirname + '/../assets/favicon.ico'); const faviconPath = path.normalize(__dirname + "/../assets/favicon.ico");
// Create a gzip function for reusable purpose // Create a gzip function for reusable purpose
const compressFile = (filePath) => { const compressFile = (filePath) => {
@ -9,7 +9,7 @@ const compressFile = (filePath) => {
stream stream
.pipe(createGzip()) .pipe(createGzip())
.pipe(createWriteStream(`${filePath}.gz`)) .pipe(createWriteStream(`${filePath}.gz`))
.on('finish', () => .on("finish", () =>
console.log(`Successfully compressed the file at ${filePath}`) console.log(`Successfully compressed the file at ${filePath}`)
); );
}; };

View File

@ -1,7 +1,7 @@
const express = require('express'); const express = require("express");
const chalk = require('chalk'); const chalk = require("chalk");
let path = require('path'); let path = require("path");
const fs = require('fs'); const fs = require("fs");
const port = 8080; const port = 8080;
/* /*
* Web Server for development * Web Server for development
@ -10,19 +10,19 @@ const port = 8080;
const wscolor = chalk.cyan; const wscolor = chalk.cyan;
const expresscolor = chalk.green; const expresscolor = chalk.green;
const commandcolor = chalk.white; const commandcolor = chalk.white;
const WebSocket = require('ws'); const WebSocket = require("ws");
let currentID = 0; let currentID = 0;
const app = express(); const app = express();
const fileUpload = require('express-fileupload'); const fileUpload = require("express-fileupload");
let serverpath = path.normalize(__dirname + '/../server/public/'); let serverpath = path.normalize(__dirname + "/../server/public/");
let sdpath = path.normalize(__dirname + '/../server/sd/'); let sdpath = path.normalize(__dirname + "/../server/sd/");
let WebSocketServer = require('ws').Server, let WebSocketServer = require("ws").Server,
wss = new WebSocketServer({ wss = new WebSocketServer({
port: 81, port: 81,
handleProtocols: function (protocol) { handleProtocols: function (protocol) {
console.log('protocol received from client ' + protocol); console.log("protocol received from client " + protocol);
return 'webui-v3'; return "webui-v3";
return null; return null;
}, },
}); });
@ -45,442 +45,442 @@ function SendBinary(text) {
}); });
} }
app.post('/login', function (req, res) { app.post("/login", function (req, res) {
res.send(''); res.send("");
return; return;
}); });
app.get('/config', function (req, res) { app.get("/config", function (req, res) {
res.send( res.send(
'chip id: 56398\nCPU Freq: 240 Mhz<br/>' + "chip id: 56398\nCPU Freq: 240 Mhz<br/>" +
'CPU Temp: 58.3 C<br/>' + "CPU Temp: 58.3 C<br/>" +
'free mem: 212.36 KB<br/>' + "free mem: 212.36 KB<br/>" +
'SDK: v3.2.3-14-gd3e562907<br/>' + "SDK: v3.2.3-14-gd3e562907<br/>" +
'flash size: 4.00 MB<br/>' + "flash size: 4.00 MB<br/>" +
'size for update: 1.87 MB<br/>' + "size for update: 1.87 MB<br/>" +
'FS type: LittleFS<br/>' + "FS type: LittleFS<br/>" +
'FS usage: 104.00 KB/192.00 KB<br/>' + "FS usage: 104.00 KB/192.00 KB<br/>" +
'baud: 115200<br/>' + "baud: 115200<br/>" +
'sleep mode: none<br/>' + "sleep mode: none<br/>" +
'wifi: ON<br/>' + "wifi: ON<br/>" +
'hostname: esp3d<br/>' + "hostname: esp3d<br/>" +
'HTTP port: 80<br/>' + "HTTP port: 80<br/>" +
'Telnet port: 23<br/>' + "Telnet port: 23<br/>" +
'WebDav port: 8383<br/>' + "WebDav port: 8383<br/>" +
'sta: ON<br/>' + "sta: ON<br/>" +
'mac: 80:7D:3A:C4:4E:DC<br/>' + "mac: 80:7D:3A:C4:4E:DC<br/>" +
'SSID: WIFI_OFFICE_A2G<br/>' + "SSID: WIFI_OFFICE_A2G<br/>" +
'signal: 100 %<br/>' + "signal: 100 %<br/>" +
'phy mode: 11n<br/>' + "phy mode: 11n<br/>" +
'channel: 11<br/>' + "channel: 11<br/>" +
'ip mode: dhcp<br/>' + "ip mode: dhcp<br/>" +
'ip: 192.168.1.61<br/>' + "ip: 192.168.1.61<br/>" +
'gw: 192.168.1.1<br/>' + "gw: 192.168.1.1<br/>" +
'msk: 255.255.255.0<br/>' + "msk: 255.255.255.0<br/>" +
'DNS: 192.168.1.1<br/>' + "DNS: 192.168.1.1<br/>" +
'ap: OFF<br/>' + "ap: OFF<br/>" +
'mac: 80:7D:3A:C4:4E:DD<br/>' + "mac: 80:7D:3A:C4:4E:DD<br/>" +
'serial: ON<br/>' + "serial: ON<br/>" +
'notification: OFF<br/>' + "notification: OFF<br/>" +
'Target Fw: repetier<br/>' + "Target Fw: repetier<br/>" +
'FW ver: 3.0.0.a91<br/>' + "FW ver: 3.0.0.a91<br/>" +
'FW arch: ESP32 ' "FW arch: ESP32 "
); );
return; return;
}); });
app.get('/command', function (req, res) { app.get("/command", function (req, res) {
console.log(commandcolor(`[server]/command params: ${req.query.cmd}`)); console.log(commandcolor(`[server]/command params: ${req.query.cmd}`));
let url = req.query.cmd; let url = req.query.cmd;
if (url.startsWith('[ESP800]json')) { if (url.startsWith("[ESP800]json")) {
res.json({ res.json({
cmd: '800', cmd: "800",
status: 'ok', status: "ok",
data: { data: {
FWVersion: '3.0.0.a28', FWVersion: "3.0.0.a28",
FWTarget: 40, FWTarget: 40,
SDConnection: 'none', SDConnection: "none",
Authentication: 'Disabled', Authentication: "Disabled",
WebCommunication: 'Synchronous', WebCommunication: "Synchronous",
WebSocketIP: 'localhost', WebSocketIP: "localhost",
WebSocketPort: '81', WebSocketPort: "81",
Hostname: 'esp3d', Hostname: "esp3d",
WiFiMode: 'STA', WiFiMode: "STA",
WebUpdate: 'Enabled', WebUpdate: "Enabled",
FlashFileSystem: 'LittleFs', FlashFileSystem: "LittleFs",
HostPath: '/', HostPath: "/",
Time: 'none', Time: "none",
Cam_ID: '4', Cam_ID: "4",
Cam_name: 'ESP32 Cam', Cam_name: "ESP32 Cam",
}, },
}); });
return; return;
} }
if (url.indexOf('ESP111') != -1) { if (url.indexOf("ESP111") != -1) {
res.send('192.168.1.111'); res.send("192.168.1.111");
return; return;
} }
if (url.indexOf('ESP420') != -1) { if (url.indexOf("ESP420") != -1) {
res.json({ res.json({
Status: [ Status: [
{ id: 'chip id', value: '38078' }, { id: "chip id", value: "38078" },
{ id: 'CPU Freq', value: '240 Mhz' }, { id: "CPU Freq", value: "240 Mhz" },
{ id: 'CPU Temp', value: '50.6 C' }, { id: "CPU Temp", value: "50.6 C" },
{ id: 'free mem', value: '217.50 KB' }, { id: "free mem", value: "217.50 KB" },
{ id: 'SDK', value: 'v3.3.1-61-g367c3c09c' }, { id: "SDK", value: "v3.3.1-61-g367c3c09c" },
{ id: 'flash size', value: '4.00 MB' }, { id: "flash size", value: "4.00 MB" },
{ id: 'size for update', value: '1.87 MB' }, { id: "size for update", value: "1.87 MB" },
{ id: 'FS type', value: 'SPIFFS' }, { id: "FS type", value: "SPIFFS" },
{ id: 'FS usage', value: '39.95 KB/169.38 KB' }, { id: "FS usage", value: "39.95 KB/169.38 KB" },
{ id: 'baud', value: '115200' }, { id: "baud", value: "115200" },
{ id: 'sleep mode', value: 'none' }, { id: "sleep mode", value: "none" },
{ id: 'wifi', value: 'ON' }, { id: "wifi", value: "ON" },
{ id: 'hostname', value: 'esp3d' }, { id: "hostname", value: "esp3d" },
{ id: 'HTTP port', value: '80' }, { id: "HTTP port", value: "80" },
{ id: 'Telnet port', value: '23' }, { id: "Telnet port", value: "23" },
{ id: 'Ftp ports', value: '21, 20, 55600' }, { id: "Ftp ports", value: "21, 20, 55600" },
{ id: 'sta', value: 'ON' }, { id: "sta", value: "ON" },
{ id: 'mac', value: '30:AE:A4:21:BE:94' }, { id: "mac", value: "30:AE:A4:21:BE:94" },
{ id: 'SSID', value: 'WIFI_OFFICE_B2G' }, { id: "SSID", value: "WIFI_OFFICE_B2G" },
{ id: 'signal', value: '100 %' }, { id: "signal", value: "100 %" },
{ id: 'phy mode', value: '11n' }, { id: "phy mode", value: "11n" },
{ id: 'channel', value: '2' }, { id: "channel", value: "2" },
{ id: 'ip mode', value: 'dhcp' }, { id: "ip mode", value: "dhcp" },
{ id: 'ip', value: '192.168.1.43' }, { id: "ip", value: "192.168.1.43" },
{ id: 'gw', value: '192.168.1.1' }, { id: "gw", value: "192.168.1.1" },
{ id: 'msk', value: '255.255.255.0' }, { id: "msk", value: "255.255.255.0" },
{ id: 'DNS', value: '192.168.1.1' }, { id: "DNS", value: "192.168.1.1" },
{ id: 'ap', value: 'OFF' }, { id: "ap", value: "OFF" },
{ id: 'mac', value: '30:AE:A4:21:BE:95' }, { id: "mac", value: "30:AE:A4:21:BE:95" },
{ id: 'serial', value: 'ON' }, { id: "serial", value: "ON" },
{ id: 'notification', value: 'OFF' }, { id: "notification", value: "OFF" },
{ id: 'FW ver', value: '3.0.0.a28' }, { id: "FW ver", value: "3.0.0.a28" },
{ id: 'FW arch', value: 'ESP32' }, { id: "FW arch", value: "ESP32" },
], ],
}); });
return; return;
} }
if (url.indexOf('ESP410') != -1) { if (url.indexOf("ESP410") != -1) {
res.json({ res.json({
AP_LIST: [ AP_LIST: [
{ {
SSID: 'HP-Setup>71-M277 LaserJet', SSID: "HP-Setup>71-M277 LaserJet",
SIGNAL: '92', SIGNAL: "92",
IS_PROTECTED: '0', IS_PROTECTED: "0",
}, },
{ SSID: 'WIFI_OFFICE_B2G', SIGNAL: '88', IS_PROTECTED: '1' }, { SSID: "WIFI_OFFICE_B2G", SIGNAL: "88", IS_PROTECTED: "1" },
{ SSID: 'NETGEAR70', SIGNAL: '66', IS_PROTECTED: '1' }, { SSID: "NETGEAR70", SIGNAL: "66", IS_PROTECTED: "1" },
{ SSID: 'ZenFone6&#39;luc', SIGNAL: '48', IS_PROTECTED: '1' }, { SSID: "ZenFone6&#39;luc", SIGNAL: "48", IS_PROTECTED: "1" },
{ SSID: 'Livebox-EF01', SIGNAL: '20', IS_PROTECTED: '1' }, { SSID: "Livebox-EF01", SIGNAL: "20", IS_PROTECTED: "1" },
{ SSID: 'orange', SIGNAL: '20', IS_PROTECTED: '0' }, { SSID: "orange", SIGNAL: "20", IS_PROTECTED: "0" },
], ],
}); });
return; return;
} }
if (url.indexOf('ESP400') != -1) { if (url.indexOf("ESP400") != -1) {
res.json({ res.json({
Settings: [ Settings: [
{ {
F: 'network/network', F: "network/network",
P: '130', P: "130",
T: 'S', T: "S",
V: 'esp3d', V: "esp3d",
H: 'hostname', H: "hostname",
S: '32', S: "32",
M: '1', M: "1",
}, },
{ {
F: 'network/network', F: "network/network",
P: '0', P: "0",
T: 'B', T: "B",
V: '1', V: "1",
H: 'radio mode', H: "radio mode",
O: [{ none: '0' }, { sta: '1' }, { ap: '2' }], O: [{ none: "0" }, { sta: "1" }, { ap: "2" }],
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '1', P: "1",
T: 'S', T: "S",
V: 'WIFI_OFFICE_B2G', V: "WIFI_OFFICE_B2G",
S: '32', S: "32",
H: 'SSID', H: "SSID",
M: '1', M: "1",
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '34', P: "34",
T: 'S', T: "S",
N: '1', N: "1",
V: '********', V: "********",
S: '64', S: "64",
H: 'pwd', H: "pwd",
M: '8', M: "8",
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '99', P: "99",
T: 'B', T: "B",
V: '1', V: "1",
H: 'ip mode', H: "ip mode",
O: [{ dhcp: '1' }, { static: '0' }], O: [{ dhcp: "1" }, { static: "0" }],
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '100', P: "100",
T: 'A', T: "A",
V: '192.168.0.1', V: "192.168.0.1",
H: 'ip', H: "ip",
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '108', P: "108",
T: 'A', T: "A",
V: '192.168.0.1', V: "192.168.0.1",
H: 'gw', H: "gw",
}, },
{ {
F: 'network/sta', F: "network/sta",
P: '104', P: "104",
T: 'A', T: "A",
V: '255.255.255.0', V: "255.255.255.0",
H: 'msk', H: "msk",
}, },
{ {
F: 'network/ap', F: "network/ap",
P: '218', P: "218",
T: 'S', T: "S",
V: 'ESP3D', V: "ESP3D",
S: '32', S: "32",
H: 'SSID', H: "SSID",
M: '1', M: "1",
}, },
{ {
F: 'network/ap', F: "network/ap",
P: '251', P: "251",
T: 'S', T: "S",
N: '1', N: "1",
V: '********', V: "********",
S: '64', S: "64",
H: 'pwd', H: "pwd",
M: '8', M: "8",
}, },
{ {
F: 'network/ap', F: "network/ap",
P: '316', P: "316",
T: 'A', T: "A",
V: '192.168.0.1', V: "192.168.0.1",
H: 'ip', H: "ip",
}, },
{ {
F: 'network/ap', F: "network/ap",
P: '118', P: "118",
T: 'B', T: "B",
V: '11', V: "11",
H: 'channel', H: "channel",
O: [ O: [
{ 1: '1' }, { 1: "1" },
{ 2: '2' }, { 2: "2" },
{ 3: '3' }, { 3: "3" },
{ 4: '4' }, { 4: "4" },
{ 5: '5' }, { 5: "5" },
{ 6: '6' }, { 6: "6" },
{ 7: '7' }, { 7: "7" },
{ 8: '8' }, { 8: "8" },
{ 9: '9' }, { 9: "9" },
{ 10: '10' }, { 10: "10" },
{ 11: '11' }, { 11: "11" },
{ 12: '12' }, { 12: "12" },
{ 13: '13' }, { 13: "13" },
{ 14: '14' }, { 14: "14" },
], ],
}, },
{ {
F: 'service/http', F: "service/http",
P: '328', P: "328",
T: 'B', T: "B",
V: '1', V: "1",
H: 'enable', H: "enable",
O: [{ no: '0' }, { yes: '1' }], O: [{ no: "0" }, { yes: "1" }],
}, },
{ {
F: 'service/http', F: "service/http",
P: '121', P: "121",
T: 'I', T: "I",
V: '80', V: "80",
H: 'port', H: "port",
S: '65001', S: "65001",
M: '1', M: "1",
}, },
{ {
F: 'service/telnetp', F: "service/telnetp",
P: '329', P: "329",
T: 'B', T: "B",
V: '1', V: "1",
H: 'enable', H: "enable",
O: [{ no: '0' }, { yes: '1' }], O: [{ no: "0" }, { yes: "1" }],
}, },
{ {
F: 'service/telnetp', F: "service/telnetp",
P: '125', P: "125",
T: 'I', T: "I",
V: '23', V: "23",
H: 'port', H: "port",
S: '65001', S: "65001",
M: '1', M: "1",
}, },
{ {
F: 'service/ftp', F: "service/ftp",
P: '1208', P: "1208",
T: 'B', T: "B",
V: '1', V: "1",
H: 'enable', H: "enable",
O: [{ no: '0' }, { yes: '1' }], O: [{ no: "0" }, { yes: "1" }],
}, },
{ {
F: 'service/ftp', F: "service/ftp",
P: '1196', P: "1196",
T: 'I', T: "I",
V: '21', V: "21",
H: 'control port', H: "control port",
S: '65001', S: "65001",
M: '1', M: "1",
}, },
{ {
F: 'service/ftp', F: "service/ftp",
P: '1200', P: "1200",
T: 'I', T: "I",
V: '20', V: "20",
H: 'active port', H: "active port",
S: '65001', S: "65001",
M: '1', M: "1",
}, },
{ {
F: 'service/ftp', F: "service/ftp",
P: '1204', P: "1204",
T: 'I', T: "I",
V: '55600', V: "55600",
H: 'passive port', H: "passive port",
S: '65001', S: "65001",
M: '1', M: "1",
}, },
{ {
F: 'service/notification', F: "service/notification",
P: '1191', P: "1191",
T: 'B', T: "B",
V: '1', V: "1",
H: 'auto notif', H: "auto notif",
O: [{ no: '0' }, { yes: '1' }], O: [{ no: "0" }, { yes: "1" }],
}, },
{ {
F: 'service/notification', F: "service/notification",
P: '116', P: "116",
T: 'B', T: "B",
V: '0', V: "0",
H: 'notification', H: "notification",
O: [ O: [
{ none: '0' }, { none: "0" },
{ pushover: '1' }, { pushover: "1" },
{ email: '2' }, { email: "2" },
{ line: '3' }, { line: "3" },
], ],
}, },
{ {
F: 'service/notification', F: "service/notification",
P: '332', P: "332",
T: 'S', T: "S",
V: '********', V: "********",
S: '63', S: "63",
H: 't1', H: "t1",
M: '0', M: "0",
}, },
{ {
F: 'service/notification', F: "service/notification",
P: '583', P: "583",
T: 'S', T: "S",
V: '********', V: "********",
S: '63', S: "63",
H: 't2', H: "t2",
M: '0', M: "0",
}, },
{ {
F: 'service/notification', F: "service/notification",
P: '1042', P: "1042",
T: 'S', T: "S",
V: ' ', V: " ",
S: '127', S: "127",
H: 'ts', H: "ts",
M: '0', M: "0",
}, },
{ {
F: 'system/system', F: "system/system",
P: '648', P: "648",
T: 'B', T: "B",
V: '40', V: "40",
H: 'targetfw', H: "targetfw",
O: [ O: [
{ repetier: '50' }, { repetier: "50" },
{ marlin: '20' }, { marlin: "20" },
{ marlinkimbra: '35' }, { marlinkimbra: "35" },
{ smoothieware: '40' }, { smoothieware: "40" },
{ grbl: '10' }, { grbl: "10" },
{ unknown: '0' }, { unknown: "0" },
], ],
}, },
{ {
F: 'system/system', F: "system/system",
P: '112', P: "112",
T: 'I', T: "I",
V: '115200', V: "115200",
H: 'baud', H: "baud",
O: [ O: [
{ 9600: '9600' }, { 9600: "9600" },
{ 19200: '19200' }, { 19200: "19200" },
{ 38400: '38400' }, { 38400: "38400" },
{ 57600: '57600' }, { 57600: "57600" },
{ 74880: '74880' }, { 74880: "74880" },
{ 115200: '115200' }, { 115200: "115200" },
{ 230400: '230400' }, { 230400: "230400" },
{ 250000: '250000' }, { 250000: "250000" },
{ 500000: '500000' }, { 500000: "500000" },
{ 921600: '921600' }, { 921600: "921600" },
], ],
}, },
{ {
F: 'system/system', F: "system/system",
P: '320', P: "320",
T: 'I', T: "I",
V: '10000', V: "10000",
H: 'bootdelay', H: "bootdelay",
S: '40000', S: "40000",
M: '0', M: "0",
}, },
{ {
F: 'system/system', F: "system/system",
P: '129', P: "129",
T: 'F', T: "F",
V: '255', V: "255",
H: 'outputmsg', H: "outputmsg",
O: [{ M117: '16' }, { serial: '1' }, { telnet: '2' }], O: [{ M117: "16" }, { serial: "1" }, { telnet: "2" }],
}, },
], ],
}); });
return; return;
} }
SendBinary('ok\n'); SendBinary("ok\n");
res.send(''); res.send("");
}); });
function fileSizeString(size) { function fileSizeString(size) {
let s; let s;
if (size < 1024) return size + ' B'; if (size < 1024) return size + " B";
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + ' KB'; if (size < 1024 * 1024) return (size / 1024).toFixed(2) + " KB";
if (size < 1024 * 1024 * 1024) if (size < 1024 * 1024 * 1024)
return (size / (1024 * 1024)).toFixed(2) + ' MB'; return (size / (1024 * 1024)).toFixed(2) + " MB";
if (size < 1024 * 1024 * 1024 * 1024) if (size < 1024 * 1024 * 1024 * 1024)
return (size / (1024 * 1024 * 1024)).toFixed(2) + ' GB'; return (size / (1024 * 1024 * 1024)).toFixed(2) + " GB";
return 'X B'; return "X B";
} }
function filesList(mypath, mainpath) { function filesList(mypath, mainpath) {
@ -489,16 +489,16 @@ function filesList(mypath, mainpath) {
let total = sdpath == mainpath ? 4096 * 1024 * 1024 : 1.2 * 1024 * 1024; let total = sdpath == mainpath ? 4096 * 1024 * 1024 : 1.2 * 1024 * 1024;
let totalused = getTotalSize(mainpath); let totalused = getTotalSize(mainpath);
let currentpath = path.normalize(mainpath + mypath); let currentpath = path.normalize(mainpath + mypath);
console.log('[path]' + currentpath); console.log("[path]" + currentpath);
fs.readdirSync(currentpath).forEach((fileelement) => { fs.readdirSync(currentpath).forEach((fileelement) => {
let fullpath = path.normalize(currentpath + '/' + fileelement); let fullpath = path.normalize(currentpath + "/" + fileelement);
let fst = fs.statSync(fullpath); let fst = fs.statSync(fullpath);
let fsize = -1; let fsize = -1;
if (fst.isFile()) { if (fst.isFile()) {
fsize = fileSizeString(fst.size); fsize = fileSizeString(fst.size);
} }
if (nb > 0) res += ','; if (nb > 0) res += ",";
res += '{"name":"' + fileelement + '","size":"' + fsize + '"}'; res += '{"name":"' + fileelement + '","size":"' + fsize + '"}';
nb++; nb++;
}); });
@ -521,10 +521,10 @@ const getAllFiles = function (dirPath, arrayOfFiles) {
arrayOfFiles = arrayOfFiles || []; arrayOfFiles = arrayOfFiles || [];
files.forEach(function (file) { files.forEach(function (file) {
if (fs.statSync(dirPath + '/' + file).isDirectory()) { if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + '/' + file, arrayOfFiles); arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
} else { } else {
arrayOfFiles.push(dirPath + '/' + file); arrayOfFiles.push(dirPath + "/" + file);
} }
}); });
@ -546,7 +546,7 @@ const getTotalSize = function (directoryPath) {
function deleteFolderRecursive(path) { function deleteFolderRecursive(path) {
if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) { if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) {
fs.readdirSync(path).forEach(function (file, index) { fs.readdirSync(path).forEach(function (file, index) {
let curPath = path + '/' + file; let curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) { if (fs.lstatSync(curPath).isDirectory()) {
// recurse // recurse
@ -562,49 +562,49 @@ function deleteFolderRecursive(path) {
} else console.log(`[server]No directory "${path}"...`); } else console.log(`[server]No directory "${path}"...`);
} }
app.all('/updatefw', function (req, res) { app.all("/updatefw", function (req, res) {
res.send('ok'); res.send("ok");
}); });
app.all('/sdfiles', function (req, res) { app.all("/sdfiles", function (req, res) {
let mypath = req.query.path; let mypath = req.query.path;
let url = req.originalUrl; let url = req.originalUrl;
let filepath = path.normalize(sdpath + mypath + '/' + req.query.filename); let filepath = path.normalize(sdpath + mypath + "/" + req.query.filename);
if (url.indexOf('action=deletedir') != -1) { if (url.indexOf("action=deletedir") != -1) {
console.log('[server]delete directory ' + filepath); console.log("[server]delete directory " + filepath);
deleteFolderRecursive(filepath); deleteFolderRecursive(filepath);
fs.readdirSync(mypath); fs.readdirSync(mypath);
} else if (url.indexOf('action=delete') != -1) { } else if (url.indexOf("action=delete") != -1) {
fs.unlinkSync(filepath); fs.unlinkSync(filepath);
console.log('[server]delete file ' + filepath); console.log("[server]delete file " + filepath);
} }
if (url.indexOf('action=createdir') != -1) { if (url.indexOf("action=createdir") != -1) {
fs.mkdirSync(filepath); fs.mkdirSync(filepath);
console.log('[server]new directory ' + filepath); console.log("[server]new directory " + filepath);
} }
if (typeof mypath == 'undefined') { if (typeof mypath == "undefined") {
if (typeof req.body.path == 'undefined') { if (typeof req.body.path == "undefined") {
console.log('[server]path is not defined'); console.log("[server]path is not defined");
mypath = '/'; mypath = "/";
} else { } else {
mypath = (req.body.path == '/' ? '' : req.body.path) + '/'; mypath = (req.body.path == "/" ? "" : req.body.path) + "/";
} }
} }
console.log('[server]path is ' + mypath); console.log("[server]path is " + mypath);
if (!req.files || Object.keys(req.files).length === 0) { if (!req.files || Object.keys(req.files).length === 0) {
return res.send(filesList(mypath, sdpath)); return res.send(filesList(mypath, sdpath));
} }
let myFile = req.files.myfiles; let myFile = req.files.myfiles;
if (typeof myFile.length == 'undefined') { if (typeof myFile.length == "undefined") {
let fullpath = path.normalize(sdpath + mypath + myFile.name); let fullpath = path.normalize(sdpath + mypath + myFile.name);
console.log('[server]one file:' + fullpath); console.log("[server]one file:" + fullpath);
myFile.mv(fullpath, function (err) { myFile.mv(fullpath, function (err) {
if (err) return res.status(500).send(err); if (err) return res.status(500).send(err);
res.send(filesList(mypath, sdpath)); res.send(filesList(mypath, sdpath));
}); });
return; return;
} else { } else {
console.log(myFile.length + ' files'); console.log(myFile.length + " files");
for (let i = 0; i < myFile.length; i++) { for (let i = 0; i < myFile.length; i++) {
let fullpath = path.normalize(sdpath + mypath + myFile[i].name); let fullpath = path.normalize(sdpath + mypath + myFile[i].name);
console.log(fullpath); console.log(fullpath);
@ -615,47 +615,47 @@ app.all('/sdfiles', function (req, res) {
} }
}); });
app.all('/files', function (req, res) { app.all("/files", function (req, res) {
let mypath = req.query.path; let mypath = req.query.path;
let url = req.originalUrl; let url = req.originalUrl;
let filepath = path.normalize( let filepath = path.normalize(
serverpath + mypath + '/' + req.query.filename serverpath + mypath + "/" + req.query.filename
); );
if (url.indexOf('action=deletedir') != -1) { if (url.indexOf("action=deletedir") != -1) {
console.log('[server]delete directory ' + filepath); console.log("[server]delete directory " + filepath);
deleteFolderRecursive(filepath); deleteFolderRecursive(filepath);
fs.readdirSync(mypath); fs.readdirSync(mypath);
} else if (url.indexOf('action=delete') != -1) { } else if (url.indexOf("action=delete") != -1) {
fs.unlinkSync(filepath); fs.unlinkSync(filepath);
console.log('[server]delete file ' + filepath); console.log("[server]delete file " + filepath);
} }
if (url.indexOf('action=createdir') != -1) { if (url.indexOf("action=createdir") != -1) {
fs.mkdirSync(filepath); fs.mkdirSync(filepath);
console.log('[server]new directory ' + filepath); console.log("[server]new directory " + filepath);
} }
if (typeof mypath == 'undefined') { if (typeof mypath == "undefined") {
if (typeof req.body.path == 'undefined') { if (typeof req.body.path == "undefined") {
console.log('[server]path is not defined'); console.log("[server]path is not defined");
mypath = '/'; mypath = "/";
} else { } else {
mypath = (req.body.path == '/' ? '' : req.body.path) + '/'; mypath = (req.body.path == "/" ? "" : req.body.path) + "/";
} }
} }
console.log('[server]path is ' + mypath); console.log("[server]path is " + mypath);
if (!req.files || Object.keys(req.files).length === 0) { if (!req.files || Object.keys(req.files).length === 0) {
return res.send(filesList(mypath, serverpath)); return res.send(filesList(mypath, serverpath));
} }
let myFile = req.files.myfiles; let myFile = req.files.myfiles;
if (typeof myFile.length == 'undefined') { if (typeof myFile.length == "undefined") {
let fullpath = path.normalize(serverpath + mypath + myFile.name); let fullpath = path.normalize(serverpath + mypath + myFile.name);
console.log('[server]one file:' + fullpath); console.log("[server]one file:" + fullpath);
myFile.mv(fullpath, function (err) { myFile.mv(fullpath, function (err) {
if (err) return res.status(500).send(err); if (err) return res.status(500).send(err);
res.send(filesList(mypath, serverpath)); res.send(filesList(mypath, serverpath));
}); });
return; return;
} else { } else {
console.log(myFile.length + ' files'); console.log(myFile.length + " files");
for (let i = 0; i < myFile.length; i++) { for (let i = 0; i < myFile.length; i++) {
let fullpath = path.normalize(serverpath + mypath + myFile[i].name); let fullpath = path.normalize(serverpath + mypath + myFile[i].name);
console.log(fullpath); console.log(fullpath);
@ -667,8 +667,8 @@ app.all('/files', function (req, res) {
} }
}); });
wss.on('connection', (socket, request) => { wss.on("connection", (socket, request) => {
console.log(wscolor('[ws] New connection')); console.log(wscolor("[ws] New connection"));
console.log(wscolor(`[ws] currentID:${currentID}`)); console.log(wscolor(`[ws] currentID:${currentID}`));
socket.send(`currentID:${currentID}`); socket.send(`currentID:${currentID}`);
wss.clients.forEach(function each(client) { wss.clients.forEach(function each(client) {
@ -677,10 +677,10 @@ wss.on('connection', (socket, request) => {
} }
}); });
currentID++; currentID++;
socket.on('message', (message) => { socket.on("message", (message) => {
console.log(wscolor('[ws] received: %s', message)); console.log(wscolor("[ws] received: %s", message));
}); });
}); });
wss.on('error', (error) => { wss.on("error", (error) => {
console.log(wscolor('[ws] Error: %s', error)); console.log(wscolor("[ws] Error: %s", error));
}); });

View File

@ -1,31 +1,31 @@
const path = require('path'); const path = require("path");
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = { module.exports = {
mode: 'development', // this will trigger some webpack default stuffs for dev mode: "development", // this will trigger some webpack default stuffs for dev
entry: path.resolve(__dirname, '../src/index.js'), // if not set, default path to './src/index.js'. Accepts an object with multiple key-value pairs, with key as your custom bundle filename(substituting the [name]), and value as the corresponding file path entry: path.resolve(__dirname, "../src/index.js"), // if not set, default path to './src/index.js'. Accepts an object with multiple key-value pairs, with key as your custom bundle filename(substituting the [name]), and value as the corresponding file path
output: { output: {
filename: '[name].bundle.js', // [name] will take whatever the input filename is. defaults to 'main' if only a single entry value filename: "[name].bundle.js", // [name] will take whatever the input filename is. defaults to 'main' if only a single entry value
path: path.resolve(__dirname, '../dist'), // the folder containing you final dist/build files. Default to './dist' path: path.resolve(__dirname, "../dist"), // the folder containing you final dist/build files. Default to './dist'
}, },
devServer: { devServer: {
historyApiFallback: true, // to make our SPA works after a full reload, so that it serves 'index.html' when 404 response historyApiFallback: true, // to make our SPA works after a full reload, so that it serves 'index.html' when 404 response
open: true, open: true,
static: { static: {
directory: path.resolve(__dirname, './dist'), directory: path.resolve(__dirname, "./dist"),
}, },
port: 8088, port: 8088,
proxy: { proxy: {
context: () => true, context: () => true,
target: 'http://localhost:8080', target: "http://localhost:8080",
}, },
}, },
stats: 'minimal', // default behaviour spit out way too much info. adjust to your need. stats: "minimal", // default behaviour spit out way too much info. adjust to your need.
devtool: 'source-map', // a sourcemap type. map to original source with line number devtool: "source-map", // a sourcemap type. map to original source with line number
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: path.join(__dirname, '../src/index.html'), template: path.join(__dirname, "../src/index.html"),
inlineSource: '.(js|css)$', inlineSource: ".(js|css)$",
inject: true, inject: true,
}), }),
], // automatically creates a 'index.html' for us with our <link>, <style>, <script> tags inserted! Visit https://github.com/jantimon/html-webpack-plugin for more options ], // automatically creates a 'index.html' for us with our <link>, <style>, <script> tags inserted! Visit https://github.com/jantimon/html-webpack-plugin for more options
@ -35,9 +35,9 @@ module.exports = {
test: /\.js$/, test: /\.js$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
use: { use: {
loader: 'babel-loader', loader: "babel-loader",
options: { options: {
presets: ['@babel/preset-env'], presets: ["@babel/preset-env"],
}, },
}, },
}, },
@ -46,7 +46,7 @@ module.exports = {
// this are the loaders. they interpret files, in this case css. they run from right to left sequence. // this are the loaders. they interpret files, in this case css. they run from right to left sequence.
// css-loader: "interprets @import and url() like import/require() and will resolve them." // css-loader: "interprets @import and url() like import/require() and will resolve them."
// style-loader: "Adds CSS to the DOM by injecting a <style> tag". this is fine for development. // style-loader: "Adds CSS to the DOM by injecting a <style> tag". this is fine for development.
use: ['style-loader', 'css-loader'], use: ["style-loader", "css-loader"],
}, },
], ],
}, },

View File

@ -1,41 +1,41 @@
const path = require('path'); const path = require("path");
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin'); const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin'); const HtmlInlineScriptPlugin = require("html-inline-script-webpack-plugin");
const HTMLInlineCSSWebpackPlugin = const HTMLInlineCSSWebpackPlugin =
require('html-inline-css-webpack-plugin').default; require("html-inline-css-webpack-plugin").default;
const Compression = require('compression-webpack-plugin'); const Compression = require("compression-webpack-plugin");
module.exports = { module.exports = {
mode: 'production', // this trigger webpack out-of-box prod optimizations mode: "production", // this trigger webpack out-of-box prod optimizations
entry: path.resolve(__dirname, '../src/index.js'), entry: path.resolve(__dirname, "../src/index.js"),
output: { output: {
filename: `[name].[hash].js`, // [hash] is useful for cache busting! filename: `[name].[hash].js`, // [hash] is useful for cache busting!
path: path.resolve(__dirname, '../dist'), path: path.resolve(__dirname, "../dist"),
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.css$/, test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'], use: [MiniCssExtractPlugin.loader, "css-loader"],
}, },
{ {
test: /\.js$/, test: /\.js$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [ use: [
{ {
loader: 'babel-loader', loader: "babel-loader",
options: { options: {
presets: [ presets: [
[ [
'@babel/preset-env', "@babel/preset-env",
{ {
useBuiltIns: 'usage', useBuiltIns: "usage",
debug: false, debug: false,
corejs: 3, corejs: 3,
targets: { chrome: '88' }, targets: { chrome: "88" },
}, },
], ],
], ],
@ -49,13 +49,13 @@ module.exports = {
// always deletes the dist folder first in each build run. // always deletes the dist folder first in each build run.
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: '[name].css', filename: "[name].css",
chunkFilename: '[id].css', chunkFilename: "[id].css",
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: path.join(__dirname, '../src/index.html'), template: path.join(__dirname, "../src/index.html"),
inlineSource: '.(js|css)$', inlineSource: ".(js|css)$",
inject: 'body', inject: "body",
}), }),
new HtmlInlineScriptPlugin({ new HtmlInlineScriptPlugin({
@ -65,10 +65,10 @@ module.exports = {
new HTMLInlineCSSWebpackPlugin(), new HTMLInlineCSSWebpackPlugin(),
new Compression({ new Compression({
test: /\.(html)$/, test: /\.(html)$/,
filename: '[path][base].gz', filename: "[path][base].gz",
algorithm: 'gzip', algorithm: "gzip",
exclude: /.map$/, exclude: /.map$/,
deleteOriginalAssets: 'keep-source-map', deleteOriginalAssets: "keep-source-map",
}), }),
], ],
optimization: { optimization: {
@ -81,7 +81,7 @@ module.exports = {
minifyJS: true, minifyJS: true,
}, },
minify: (data, minimizerOptions) => { minify: (data, minimizerOptions) => {
const htmlMinifier = require('html-minifier-terser'); const htmlMinifier = require("html-minifier-terser");
const [[filename, input]] = Object.entries(data); const [[filename, input]] = Object.entries(data);
return htmlMinifier.minify(input, minimizerOptions); return htmlMinifier.minify(input, minimizerOptions);
@ -89,5 +89,5 @@ module.exports = {
}), }),
], ],
}, },
devtool: 'source-map', // supposedly the ideal type without bloating bundle size devtool: "source-map", // supposedly the ideal type without bloating bundle size
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,17 @@
function initMenus() { function initMenus() {
document.getElementById('FWLink').addEventListener('click', function () { document.getElementById("FWLink").addEventListener("click", function () {
window.open('https://github.com/luc-github/ESP3D/tree/3.0', '_blank'); window.open("https://github.com/luc-github/ESP3D/tree/3.0", "_blank");
}); });
document.getElementById('UiLink').addEventListener('click', function () { document.getElementById("UiLink").addEventListener("click", function () {
window.open( window.open(
'https://github.com/luc-github/ESP3D-WEBUI/tree/3.0', "https://github.com/luc-github/ESP3D-WEBUI/tree/3.0",
'_blank' "_blank"
); );
}); });
document.getElementById('hlpLink').addEventListener('click', function () { document.getElementById("hlpLink").addEventListener("click", function () {
window.open('https://github.com/luc-github/ESP3D/wiki', '_blank'); window.open("https://github.com/luc-github/ESP3D/wiki", "_blank");
}); });
} }