svelteesp32 1.4.0 → 1.4.2
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/dist/consoleColor.js +3 -3
- package/dist/cppCode.js +4 -0
- package/dist/file.d.ts +1 -1
- package/dist/file.js +27 -5
- package/dist/index.js +10 -8
- package/package.json +6 -5
package/dist/consoleColor.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.redLog = exports.yellowLog = exports.greenLog = void 0;
|
|
4
|
-
const greenLog = (s) => `\u001B[32m
|
|
4
|
+
const greenLog = (s) => `\u001B[32m${s}\u001B[0m`;
|
|
5
5
|
exports.greenLog = greenLog;
|
|
6
|
-
const yellowLog = (s) => `\u001B[33m
|
|
6
|
+
const yellowLog = (s) => `\u001B[33m${s}\u001B[0m`;
|
|
7
7
|
exports.yellowLog = yellowLog;
|
|
8
|
-
const redLog = (s) => `\u001B[31m
|
|
8
|
+
const redLog = (s) => `\u001B[31m${s}\u001B[0m`;
|
|
9
9
|
exports.redLog = redLog;
|
package/dist/cppCode.js
CHANGED
|
@@ -150,10 +150,12 @@ void {{methodName}}(PsychicHttpServer * server) {
|
|
|
150
150
|
|
|
151
151
|
{{#switch ../etag}}
|
|
152
152
|
{{#case "true"}}
|
|
153
|
+
response.addHeader("cache-control", "no-cache");
|
|
153
154
|
response.addHeader("ETag", etag_{{this.dataname}});
|
|
154
155
|
{{/case}}
|
|
155
156
|
{{#case "compiler"}}
|
|
156
157
|
#ifdef {{../definePrefix}}_ENABLE_ETAG
|
|
158
|
+
response.addHeader("cache-control", "no-cache");
|
|
157
159
|
response.addHeader("ETag", etag_{{this.dataname}});
|
|
158
160
|
#endif
|
|
159
161
|
{{/case}}
|
|
@@ -328,10 +330,12 @@ void {{methodName}}(AsyncWebServer * server) {
|
|
|
328
330
|
|
|
329
331
|
{{#switch ../etag}}
|
|
330
332
|
{{#case "true"}}
|
|
333
|
+
response->addHeader("cache-control", "no-cache");
|
|
331
334
|
response->addHeader("ETag", etag_{{this.dataname}});
|
|
332
335
|
{{/case}}
|
|
333
336
|
{{#case "compiler"}}
|
|
334
337
|
#ifdef {{../definePrefix}}_ENABLE_ETAG
|
|
338
|
+
response->addHeader("cache-control", "no-cache");
|
|
335
339
|
response->addHeader("ETag", etag_{{this.dataname}});
|
|
336
340
|
#endif
|
|
337
341
|
{{/case}}
|
package/dist/file.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getFiles: () => string
|
|
1
|
+
export declare const getFiles: () => Map<string, Buffer>;
|
package/dist/file.js
CHANGED
|
@@ -4,23 +4,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getFiles = void 0;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
7
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
10
|
const glob_1 = require("glob");
|
|
9
11
|
const commandLine_1 = require("./commandLine");
|
|
10
12
|
const consoleColor_1 = require("./consoleColor");
|
|
13
|
+
const findSimilarFiles = (files) => {
|
|
14
|
+
const contentComparer = new Map();
|
|
15
|
+
for (const [filename, content] of files.entries()) {
|
|
16
|
+
const hash = (0, node_crypto_1.createHash)('sha256').update(content).digest('hex');
|
|
17
|
+
if (contentComparer.has(hash))
|
|
18
|
+
contentComparer.get(hash).push(filename);
|
|
19
|
+
else
|
|
20
|
+
contentComparer.set(hash, [filename]);
|
|
21
|
+
}
|
|
22
|
+
const result = [];
|
|
23
|
+
for (const filenames of contentComparer.values())
|
|
24
|
+
if (filenames.length > 1)
|
|
25
|
+
result.push(filenames);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
11
28
|
const getFiles = () => {
|
|
12
|
-
let
|
|
13
|
-
|
|
29
|
+
let filenames = (0, glob_1.globSync)('**/*', { cwd: commandLine_1.cmdLine.sourcepath, nodir: true });
|
|
30
|
+
filenames = filenames.filter((filename) => {
|
|
14
31
|
const extension = node_path_1.default.extname(filename);
|
|
15
32
|
if (['.gz', '.brottli', '.br'].includes(extension)) {
|
|
16
33
|
const original = filename.slice(0, -1 * extension.length);
|
|
17
|
-
if (
|
|
18
|
-
console.log((0, consoleColor_1.redLog)(
|
|
34
|
+
if (filenames.includes(original)) {
|
|
35
|
+
console.log((0, consoleColor_1.redLog)(` ${filename} skipped because is perhaps a compressed version of ${original}`));
|
|
19
36
|
return false;
|
|
20
37
|
}
|
|
21
38
|
}
|
|
22
39
|
return true;
|
|
23
40
|
});
|
|
24
|
-
|
|
41
|
+
const result = new Map();
|
|
42
|
+
for (const filename of filenames)
|
|
43
|
+
result.set(filename, (0, node_fs_1.readFileSync)(node_path_1.default.join(commandLine_1.cmdLine.sourcepath, filename), { flag: 'r' }));
|
|
44
|
+
for (const sameFile of findSimilarFiles(result))
|
|
45
|
+
console.log((0, consoleColor_1.yellowLog)(` ${sameFile.join(', ')} files look like identical`));
|
|
46
|
+
return result;
|
|
25
47
|
};
|
|
26
48
|
exports.getFiles = getFiles;
|
package/dist/index.js
CHANGED
|
@@ -19,16 +19,19 @@ const summary = {
|
|
|
19
19
|
};
|
|
20
20
|
const sources = [];
|
|
21
21
|
const filesByExtension = [];
|
|
22
|
+
console.log('Collecting source files');
|
|
22
23
|
const files = (0, file_1.getFiles)();
|
|
23
|
-
if (files.
|
|
24
|
+
if (files.size === 0) {
|
|
24
25
|
console.error(`Directory ${commandLine_1.cmdLine.sourcepath} is empty`);
|
|
25
26
|
process.exit(1);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
console.log();
|
|
29
|
+
console.log('Translation to header file');
|
|
30
|
+
const longestFilename = [...files.keys()].reduce((p, c) => (c.length > p ? c.length : p), 0);
|
|
31
|
+
for (const [originalFilename, content] of files) {
|
|
32
|
+
const mime = (0, mime_types_1.lookup)(originalFilename) || 'text/plain';
|
|
30
33
|
summary.filecount++;
|
|
31
|
-
const filename =
|
|
34
|
+
const filename = originalFilename.replace(/\\/g, '/');
|
|
32
35
|
const dataname = filename.replace(/[./-]/g, '_');
|
|
33
36
|
let extension = node_path_1.default.extname(filename).toUpperCase();
|
|
34
37
|
if (extension.startsWith('.'))
|
|
@@ -38,7 +41,6 @@ for (const file of files) {
|
|
|
38
41
|
group.count += 1;
|
|
39
42
|
else
|
|
40
43
|
filesByExtension.push({ extension, count: 1 });
|
|
41
|
-
const content = (0, node_fs_1.readFileSync)(node_path_1.default.join(commandLine_1.cmdLine.sourcepath, file), { flag: 'r' });
|
|
42
44
|
const md5 = (0, node_crypto_1.createHash)('md5').update(content).digest('hex');
|
|
43
45
|
summary.size += content.length;
|
|
44
46
|
const zipContent = (0, node_zlib_1.gzipSync)(content, { level: 9 });
|
|
@@ -55,7 +57,7 @@ for (const file of files) {
|
|
|
55
57
|
mime,
|
|
56
58
|
md5
|
|
57
59
|
});
|
|
58
|
-
console.log((0, consoleColor_1.greenLog)(`[${
|
|
60
|
+
console.log((0, consoleColor_1.greenLog)(` [${originalFilename}] ${' '.repeat(longestFilename - originalFilename.length)} ✓ gzip used (${content.length} -> ${zipContent.length} = ${zipRatio}%)`));
|
|
59
61
|
}
|
|
60
62
|
else {
|
|
61
63
|
sources.push({
|
|
@@ -68,7 +70,7 @@ for (const file of files) {
|
|
|
68
70
|
mime,
|
|
69
71
|
md5
|
|
70
72
|
});
|
|
71
|
-
console.log((0, consoleColor_1.yellowLog)(`[${
|
|
73
|
+
console.log((0, consoleColor_1.yellowLog)(` [${originalFilename}] ${' '.repeat(longestFilename - originalFilename.length)} x gzip unused ${content.length <= 1024 ? `(too small) ` : ''}(${content.length} -> ${zipContent.length} = ${zipRatio}%)`));
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
console.log('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteesp32",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)",
|
|
5
5
|
"author": "BCsabaEngine",
|
|
6
6
|
"license": "ISC",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"format:fix": "prettier --write .",
|
|
38
38
|
"lint:check": "eslint .",
|
|
39
39
|
"lint:fix": "eslint --fix .",
|
|
40
|
-
"fix": "npm run format:fix && npm run lint:fix"
|
|
40
|
+
"fix": "npm run format:fix && npm run lint:fix",
|
|
41
|
+
"npm:reinstall": "rm -rf ./node_modules && rm -f ./package-lock.json && npm i"
|
|
41
42
|
},
|
|
42
43
|
"keywords": [
|
|
43
44
|
"svelte",
|
|
@@ -52,9 +53,9 @@
|
|
|
52
53
|
],
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/mime-types": "^2.1.4",
|
|
55
|
-
"@types/node": "^22.4.
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
+
"@types/node": "^22.4.2",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.2.0",
|
|
58
59
|
"eslint": "^9.9.0",
|
|
59
60
|
"eslint-config-prettier": "^9.1.0",
|
|
60
61
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|