svelteesp32 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/file.js +16 -19
- package/dist/pipeline.js +34 -2
- package/package.json +2 -5
package/dist/file.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.getFiles = void 0;
|
|
|
7
7
|
const node_crypto_1 = require("node:crypto");
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const picomatch_1 = __importDefault(require("picomatch"));
|
|
11
10
|
const tinyglobby_1 = require("tinyglobby");
|
|
12
11
|
const consoleColor_1 = require("./consoleColor");
|
|
13
12
|
const errorMessages_1 = require("./errorMessages");
|
|
@@ -38,17 +37,6 @@ const shouldSkipFile = (filename, allFilenames) => {
|
|
|
38
37
|
}
|
|
39
38
|
return false;
|
|
40
39
|
};
|
|
41
|
-
const isExcluded = (filename, excludePatterns) => {
|
|
42
|
-
if (excludePatterns.length === 0)
|
|
43
|
-
return false;
|
|
44
|
-
const normalizedFilename = filename.replace(/\\/g, '/');
|
|
45
|
-
const isMatch = (0, picomatch_1.default)(excludePatterns, {
|
|
46
|
-
dot: true,
|
|
47
|
-
noglobstar: false,
|
|
48
|
-
matchBase: false
|
|
49
|
-
});
|
|
50
|
-
return isMatch(normalizedFilename);
|
|
51
|
-
};
|
|
52
40
|
const getFiles = (options) => {
|
|
53
41
|
const allFilenames = (0, tinyglobby_1.globSync)('**/*', {
|
|
54
42
|
cwd: options.sourcepath,
|
|
@@ -59,13 +47,22 @@ const getFiles = (options) => {
|
|
|
59
47
|
const withoutCompressed = allFilenames.filter((filename) => !shouldSkipFile(filename, allFilenames));
|
|
60
48
|
const excludePatterns = options.exclude;
|
|
61
49
|
const excludedFiles = [];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
let filenames = withoutCompressed;
|
|
51
|
+
if (excludePatterns.length > 0) {
|
|
52
|
+
const allowedSet = new Set((0, tinyglobby_1.globSync)('**/*', {
|
|
53
|
+
cwd: options.sourcepath,
|
|
54
|
+
onlyFiles: true,
|
|
55
|
+
dot: false,
|
|
56
|
+
followSymbolicLinks: false,
|
|
57
|
+
ignore: excludePatterns
|
|
58
|
+
}));
|
|
59
|
+
filenames = [];
|
|
60
|
+
for (const filename of withoutCompressed)
|
|
61
|
+
if (allowedSet.has(filename))
|
|
62
|
+
filenames.push(filename);
|
|
63
|
+
else
|
|
64
|
+
excludedFiles.push(filename);
|
|
65
|
+
}
|
|
69
66
|
if (excludedFiles.length > 0) {
|
|
70
67
|
console.log(`\nExcluded ${excludedFiles.length} file(s):`);
|
|
71
68
|
const displayLimit = 10;
|
package/dist/pipeline.js
CHANGED
|
@@ -8,11 +8,43 @@ exports.runPipeline = runPipeline;
|
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const node_zlib_1 = require("node:zlib");
|
|
11
|
-
const mime_types_1 = require("mime-types");
|
|
12
11
|
const consoleColor_1 = require("./consoleColor");
|
|
13
12
|
const cppCode_1 = require("./cppCode");
|
|
14
13
|
const errorMessages_1 = require("./errorMessages");
|
|
15
14
|
const file_1 = require("./file");
|
|
15
|
+
const MIME_TYPES = {
|
|
16
|
+
html: 'text/html',
|
|
17
|
+
htm: 'text/html',
|
|
18
|
+
css: 'text/css',
|
|
19
|
+
js: 'text/javascript',
|
|
20
|
+
mjs: 'text/javascript',
|
|
21
|
+
json: 'application/json',
|
|
22
|
+
png: 'image/png',
|
|
23
|
+
jpg: 'image/jpeg',
|
|
24
|
+
jpeg: 'image/jpeg',
|
|
25
|
+
gif: 'image/gif',
|
|
26
|
+
svg: 'image/svg+xml',
|
|
27
|
+
ico: 'image/x-icon',
|
|
28
|
+
webp: 'image/webp',
|
|
29
|
+
woff: 'font/woff',
|
|
30
|
+
woff2: 'font/woff2',
|
|
31
|
+
ttf: 'font/ttf',
|
|
32
|
+
otf: 'font/otf',
|
|
33
|
+
eot: 'application/vnd.ms-fontobject',
|
|
34
|
+
mp3: 'audio/mpeg',
|
|
35
|
+
wav: 'audio/wav',
|
|
36
|
+
mp4: 'video/mp4',
|
|
37
|
+
webm: 'video/webm',
|
|
38
|
+
ogg: 'audio/ogg',
|
|
39
|
+
txt: 'text/plain',
|
|
40
|
+
xml: 'application/xml',
|
|
41
|
+
pdf: 'application/pdf',
|
|
42
|
+
map: 'application/json'
|
|
43
|
+
};
|
|
44
|
+
const mimeLookup = (filename) => {
|
|
45
|
+
const extension = node_path_1.default.extname(filename).slice(1).toLowerCase();
|
|
46
|
+
return MIME_TYPES[extension] ?? false;
|
|
47
|
+
};
|
|
16
48
|
const GZIP_MIN_SIZE = 1024;
|
|
17
49
|
const GZIP_MIN_REDUCTION_RATIO = 0.85;
|
|
18
50
|
const shouldUseGzip = (originalSize, compressedSize) => originalSize > GZIP_MIN_SIZE && compressedSize < originalSize * GZIP_MIN_REDUCTION_RATIO;
|
|
@@ -194,7 +226,7 @@ function runPipeline(options) {
|
|
|
194
226
|
const longestFilename = [...files.keys()].reduce((p, c) => Math.max(c.length, p), 0);
|
|
195
227
|
for (const [originalFilename, fileData] of files) {
|
|
196
228
|
const { content, hash: sha256 } = fileData;
|
|
197
|
-
const rawMime = (
|
|
229
|
+
const rawMime = mimeLookup(originalFilename);
|
|
198
230
|
if (!rawMime)
|
|
199
231
|
console.log((0, consoleColor_1.yellowLog)(` [${originalFilename}] unknown MIME type for extension '${node_path_1.default.extname(originalFilename)}', using text/plain`));
|
|
200
232
|
const mimeType = rawMime || 'text/plain';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteesp32",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
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",
|
|
@@ -71,8 +71,7 @@
|
|
|
71
71
|
],
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@eslint/js": "^10.0.1",
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/node": "^25.6.2",
|
|
74
|
+
"@types/node": "^25.7.0",
|
|
76
75
|
"@types/picomatch": "^4.0.3",
|
|
77
76
|
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
78
77
|
"@typescript-eslint/parser": "^8.59.3",
|
|
@@ -99,8 +98,6 @@
|
|
|
99
98
|
}
|
|
100
99
|
},
|
|
101
100
|
"dependencies": {
|
|
102
|
-
"mime-types": "^3.0.2",
|
|
103
|
-
"picomatch": "^4.0.4",
|
|
104
101
|
"tinyglobby": "^0.2.16"
|
|
105
102
|
}
|
|
106
103
|
}
|