svelteesp32 1.9.4 → 1.10.0
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 +2 -0
- package/dist/commandLine.js +178 -85
- package/dist/file.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@ In order to be able to easily update OTA, it is important - from the users' poin
|
|
|
12
12
|
|
|
13
13
|
This npm package provides a solution for **inserting any JS client application into the ESP web server** (PsychicHttp and also ESPAsyncWebServer (https://github.com/ESP32Async/ESPAsyncWebServer) and ESP-IDF available, PsychicHttp is the default). For this, JS, html, css, font, assets, etc. files must be converted to binary byte array. Npm mode is easy to use and easy to **integrate into your CI/CD pipeline**.
|
|
14
14
|
|
|
15
|
+
> Starting with version v1.10.0, we reduced npm dependencies
|
|
16
|
+
|
|
15
17
|
> Starting with version v1.9.0, code generator for esp-idf is available
|
|
16
18
|
|
|
17
19
|
> Starting with version v1.8.0, use the new and maintained ESPAsyncWebserver available at https://github.com/ESP32Async/ESPAsyncWebServer
|
package/dist/commandLine.js
CHANGED
|
@@ -2,91 +2,184 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cmdLine = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
5
|
+
function showHelp() {
|
|
6
|
+
console.log(`
|
|
7
|
+
svelteesp32 - Svelte JS to ESP32 converter
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
-e, --engine <value> The engine for which the include file is created
|
|
11
|
+
(psychic|psychic2|async|espidf) (default: "psychic")
|
|
12
|
+
-s, --sourcepath <path> Source dist folder contains compiled web files (required)
|
|
13
|
+
-o, --outputfile <path> Generated output file with path (default: "svelteesp32.h")
|
|
14
|
+
--etag <value> Use ETAG header for cache (true|false|compiler) (default: "false")
|
|
15
|
+
--gzip <value> Compress content with gzip (true|false|compiler) (default: "true")
|
|
16
|
+
--created Include creation time in the output file (default: false)
|
|
17
|
+
--version <value> Include version info in the output file (default: "")
|
|
18
|
+
--espmethod <name> Name of generated method (default: "initSvelteStaticFiles")
|
|
19
|
+
--define <prefix> Prefix of c++ defines (default: "SVELTEESP32")
|
|
20
|
+
--cachetime <seconds> max-age cache time in seconds (default: 0)
|
|
21
|
+
-h, --help Shows this help
|
|
22
|
+
`);
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
function validateEngine(value) {
|
|
26
|
+
if (value === 'psychic' || value === 'psychic2' || value === 'async' || value === 'espidf')
|
|
27
|
+
return value;
|
|
28
|
+
throw new Error(`Invalid engine: ${value}`);
|
|
29
|
+
}
|
|
30
|
+
function validateTriState(value, name) {
|
|
31
|
+
if (value === 'true' || value === 'false' || value === 'compiler')
|
|
32
|
+
return value;
|
|
33
|
+
throw new Error(`Invalid ${name}: ${value}`);
|
|
34
|
+
}
|
|
35
|
+
function parseArguments() {
|
|
36
|
+
const arguments_ = process.argv.slice(2);
|
|
37
|
+
const result = {
|
|
38
|
+
engine: 'psychic',
|
|
39
|
+
outputfile: 'svelteesp32.h',
|
|
40
|
+
etag: 'false',
|
|
41
|
+
gzip: 'true',
|
|
42
|
+
created: false,
|
|
43
|
+
version: '',
|
|
44
|
+
espmethod: 'initSvelteStaticFiles',
|
|
45
|
+
define: 'SVELTEESP32',
|
|
46
|
+
cachetime: 0
|
|
47
|
+
};
|
|
48
|
+
for (let index = 0; index < arguments_.length; index++) {
|
|
49
|
+
const argument = arguments_[index];
|
|
50
|
+
if (!argument)
|
|
51
|
+
continue;
|
|
52
|
+
if (argument === '--help' || argument === '-h')
|
|
53
|
+
showHelp();
|
|
54
|
+
if (argument.startsWith('--') && argument.includes('=')) {
|
|
55
|
+
const parts = argument.split('=');
|
|
56
|
+
const flag = parts[0];
|
|
57
|
+
const value = parts.slice(1).join('=');
|
|
58
|
+
if (!flag || !value)
|
|
59
|
+
throw new Error(`Invalid argument format: ${argument}`);
|
|
60
|
+
const flagName = flag.slice(2);
|
|
61
|
+
switch (flagName) {
|
|
62
|
+
case 'engine':
|
|
63
|
+
result.engine = validateEngine(value);
|
|
64
|
+
break;
|
|
65
|
+
case 'sourcepath':
|
|
66
|
+
result.sourcepath = value;
|
|
67
|
+
break;
|
|
68
|
+
case 'outputfile':
|
|
69
|
+
result.outputfile = value;
|
|
70
|
+
break;
|
|
71
|
+
case 'etag':
|
|
72
|
+
result.etag = validateTriState(value, 'etag');
|
|
73
|
+
break;
|
|
74
|
+
case 'gzip':
|
|
75
|
+
result.gzip = validateTriState(value, 'gzip');
|
|
76
|
+
break;
|
|
77
|
+
case 'version':
|
|
78
|
+
result.version = value;
|
|
79
|
+
break;
|
|
80
|
+
case 'espmethod':
|
|
81
|
+
result.espmethod = value;
|
|
82
|
+
break;
|
|
83
|
+
case 'define':
|
|
84
|
+
result.define = value;
|
|
85
|
+
break;
|
|
86
|
+
case 'cachetime':
|
|
87
|
+
result.cachetime = Number.parseInt(value, 10);
|
|
88
|
+
if (Number.isNaN(result.cachetime)) {
|
|
89
|
+
throw new TypeError(`Invalid cachetime: ${value}`);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`Unknown flag: ${flag}`);
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (argument === '--created') {
|
|
98
|
+
result.created = true;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (argument.startsWith('-') && !argument.startsWith('--')) {
|
|
102
|
+
const flag = argument.slice(1);
|
|
103
|
+
const nextArgument = arguments_[index + 1];
|
|
104
|
+
if (!nextArgument || nextArgument.startsWith('-'))
|
|
105
|
+
throw new Error(`Missing value for flag: ${argument}`);
|
|
106
|
+
switch (flag) {
|
|
107
|
+
case 'e':
|
|
108
|
+
result.engine = validateEngine(nextArgument);
|
|
109
|
+
index++;
|
|
110
|
+
break;
|
|
111
|
+
case 's':
|
|
112
|
+
result.sourcepath = nextArgument;
|
|
113
|
+
index++;
|
|
114
|
+
break;
|
|
115
|
+
case 'o':
|
|
116
|
+
result.outputfile = nextArgument;
|
|
117
|
+
index++;
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
throw new Error(`Unknown flag: ${argument}`);
|
|
121
|
+
}
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (argument.startsWith('--')) {
|
|
125
|
+
const flag = argument.slice(2);
|
|
126
|
+
const nextArgument = arguments_[index + 1];
|
|
127
|
+
if (!nextArgument || nextArgument.startsWith('-'))
|
|
128
|
+
throw new Error(`Missing value for flag: ${argument}`);
|
|
129
|
+
switch (flag) {
|
|
130
|
+
case 'engine':
|
|
131
|
+
result.engine = validateEngine(nextArgument);
|
|
132
|
+
index++;
|
|
133
|
+
break;
|
|
134
|
+
case 'sourcepath':
|
|
135
|
+
result.sourcepath = nextArgument;
|
|
136
|
+
index++;
|
|
137
|
+
break;
|
|
138
|
+
case 'outputfile':
|
|
139
|
+
result.outputfile = nextArgument;
|
|
140
|
+
index++;
|
|
141
|
+
break;
|
|
142
|
+
case 'etag':
|
|
143
|
+
result.etag = validateTriState(nextArgument, 'etag');
|
|
144
|
+
index++;
|
|
145
|
+
break;
|
|
146
|
+
case 'gzip':
|
|
147
|
+
result.gzip = validateTriState(nextArgument, 'gzip');
|
|
148
|
+
index++;
|
|
149
|
+
break;
|
|
150
|
+
case 'version':
|
|
151
|
+
result.version = nextArgument;
|
|
152
|
+
index++;
|
|
153
|
+
break;
|
|
154
|
+
case 'espmethod':
|
|
155
|
+
result.espmethod = nextArgument;
|
|
156
|
+
index++;
|
|
157
|
+
break;
|
|
158
|
+
case 'define':
|
|
159
|
+
result.define = nextArgument;
|
|
160
|
+
index++;
|
|
161
|
+
break;
|
|
162
|
+
case 'cachetime':
|
|
163
|
+
result.cachetime = Number.parseInt(nextArgument, 10);
|
|
164
|
+
if (Number.isNaN(result.cachetime)) {
|
|
165
|
+
throw new TypeError(`Invalid cachetime: ${nextArgument}`);
|
|
166
|
+
}
|
|
167
|
+
index++;
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
throw new Error(`Unknown flag: --${flag}`);
|
|
171
|
+
}
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
throw new Error(`Unknown argument: ${argument}`);
|
|
175
|
+
}
|
|
176
|
+
if (!result.sourcepath) {
|
|
177
|
+
console.error('Error: --sourcepath is required');
|
|
178
|
+
showHelp();
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
exports.cmdLine = parseArguments();
|
|
90
183
|
if (!(0, node_fs_1.existsSync)(exports.cmdLine.sourcepath) || !(0, node_fs_1.statSync)(exports.cmdLine.sourcepath).isDirectory()) {
|
|
91
184
|
console.error(`Directory ${exports.cmdLine.sourcepath} not exists or not a directory`);
|
|
92
185
|
process.exit(1);
|
package/dist/file.js
CHANGED
|
@@ -7,7 +7,7 @@ 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
|
|
10
|
+
const tinyglobby_1 = require("tinyglobby");
|
|
11
11
|
const commandLine_1 = require("./commandLine");
|
|
12
12
|
const consoleColor_1 = require("./consoleColor");
|
|
13
13
|
const findSimilarFiles = (files) => {
|
|
@@ -43,7 +43,7 @@ const shouldSkipFile = (filename, allFilenames) => {
|
|
|
43
43
|
return false;
|
|
44
44
|
};
|
|
45
45
|
const getFiles = () => {
|
|
46
|
-
const allFilenames = (0,
|
|
46
|
+
const allFilenames = (0, tinyglobby_1.globSync)('**/*', { cwd: commandLine_1.cmdLine.sourcepath, onlyFiles: true, dot: false });
|
|
47
47
|
const filenames = allFilenames.filter((filename) => !shouldSkipFile(filename, allFilenames));
|
|
48
48
|
const result = new Map();
|
|
49
49
|
for (const filename of filenames) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteesp32",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
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",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/mime-types": "^3.0.1",
|
|
61
61
|
"@types/node": "^24.10.1",
|
|
62
|
+
"@types/picomatch": "^4.0.2",
|
|
62
63
|
"@typescript-eslint/eslint-plugin": "^8.47.0",
|
|
63
64
|
"@typescript-eslint/parser": "^8.47.0",
|
|
64
65
|
"eslint": "^9.39.1",
|
|
@@ -72,9 +73,8 @@
|
|
|
72
73
|
"typescript": "^5.9.3"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"glob": "^12.0.0",
|
|
76
76
|
"handlebars": "^4.7.8",
|
|
77
|
-
"mime-types": "^3.0.
|
|
78
|
-
"
|
|
77
|
+
"mime-types": "^3.0.2",
|
|
78
|
+
"tinyglobby": "^0.2.15"
|
|
79
79
|
}
|
|
80
80
|
}
|