svelteesp32 1.16.0 → 1.16.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/README.md +8 -1
- package/dist/commandLine.d.ts +4 -3
- package/dist/commandLine.js +34 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ void setup() {
|
|
|
75
75
|
|
|
76
76
|
## What's New
|
|
77
77
|
|
|
78
|
+
- **v1.16.0** — Size budget constraints (`--maxsize`, `--maxgzipsize`)
|
|
78
79
|
- **v1.15.0** — `--basepath` for multiple frontends (e.g., `/admin`, `/app`)
|
|
79
80
|
- **v1.13.0** — npm package variable interpolation in RC files
|
|
80
81
|
- **v1.12.0** — RC file configuration support
|
|
@@ -411,6 +412,8 @@ Called for every response (200 = content served, 304 = cache hit).
|
|
|
411
412
|
| `--gzip` | Gzip compression (true/false/compiler) | `true` |
|
|
412
413
|
| `--exclude` | Exclude files by glob pattern | System files |
|
|
413
414
|
| `--basepath` | URL prefix for all routes | (none) |
|
|
415
|
+
| `--maxsize` | Max total uncompressed size (e.g., `400k`, `1m`) | (none) |
|
|
416
|
+
| `--maxgzipsize` | Max total gzip size (e.g., `150k`, `500k`) | (none) |
|
|
414
417
|
| `--cachetime` | Cache-Control max-age in seconds | `0` |
|
|
415
418
|
| `--version` | Version string in header | (none) |
|
|
416
419
|
| `--define` | C++ define prefix | `SVELTEESP32` |
|
|
@@ -432,7 +435,11 @@ Store your settings in `.svelteesp32rc.json` for zero-argument builds:
|
|
|
432
435
|
"outputfile": "./esp32/svelteesp32.h",
|
|
433
436
|
"etag": "true",
|
|
434
437
|
"gzip": "true",
|
|
435
|
-
"exclude": ["*.map", "*.md"]
|
|
438
|
+
"exclude": ["*.map", "*.md"],
|
|
439
|
+
"basepath": "/ui",
|
|
440
|
+
"maxsize": "400k",
|
|
441
|
+
"maxgzipsize": "150k",
|
|
442
|
+
"noindexcheck": false
|
|
436
443
|
}
|
|
437
444
|
```
|
|
438
445
|
|
package/dist/commandLine.d.ts
CHANGED
|
@@ -28,9 +28,10 @@ interface IRcFileConfig {
|
|
|
28
28
|
created?: boolean;
|
|
29
29
|
version?: string;
|
|
30
30
|
exclude?: string[];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
basepath?: string;
|
|
32
|
+
maxsize?: number | string;
|
|
33
|
+
maxgzipsize?: number | string;
|
|
34
|
+
noindexcheck?: boolean;
|
|
34
35
|
}
|
|
35
36
|
declare function parseSize(value: string, name: string): number;
|
|
36
37
|
declare function getNpmPackageVariable(packageJson: Record<string, unknown>, variableName: string): string | undefined;
|
package/dist/commandLine.js
CHANGED
|
@@ -52,7 +52,11 @@ RC File:
|
|
|
52
52
|
"outputfile": "./output.h",
|
|
53
53
|
"etag": "true",
|
|
54
54
|
"gzip": "true",
|
|
55
|
-
"exclude": ["*.map", "*.md"]
|
|
55
|
+
"exclude": ["*.map", "*.md"],
|
|
56
|
+
"basepath": "/ui",
|
|
57
|
+
"maxsize": "400k",
|
|
58
|
+
"maxgzipsize": "150k",
|
|
59
|
+
"noindexcheck": false
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
CLI arguments override RC file values.
|
|
@@ -170,7 +174,7 @@ function hasNpmVariables(config) {
|
|
|
170
174
|
checkStringForNpmVariable(config.espmethod) ||
|
|
171
175
|
checkStringForNpmVariable(config.define) ||
|
|
172
176
|
checkStringForNpmVariable(config.version) ||
|
|
173
|
-
checkStringForNpmVariable(config.
|
|
177
|
+
checkStringForNpmVariable(config.basepath) ||
|
|
174
178
|
(Array.isArray(config.exclude) && config.exclude.some((pattern) => checkStringForNpmVariable(pattern))) ||
|
|
175
179
|
false);
|
|
176
180
|
}
|
|
@@ -190,8 +194,8 @@ function interpolateNpmVariables(config, rcFilePath) {
|
|
|
190
194
|
affectedFields.push('espmethod');
|
|
191
195
|
if (config.define?.includes('$npm_package_'))
|
|
192
196
|
affectedFields.push('define');
|
|
193
|
-
if (config.
|
|
194
|
-
affectedFields.push('
|
|
197
|
+
if (config.basepath?.includes('$npm_package_'))
|
|
198
|
+
affectedFields.push('basepath');
|
|
195
199
|
if (config.exclude)
|
|
196
200
|
for (const [index, pattern] of config.exclude.entries())
|
|
197
201
|
if (pattern.includes('$npm_package_'))
|
|
@@ -216,8 +220,8 @@ function interpolateNpmVariables(config, rcFilePath) {
|
|
|
216
220
|
result.define = interpolateString(result.define);
|
|
217
221
|
if (result.version)
|
|
218
222
|
result.version = interpolateString(result.version);
|
|
219
|
-
if (result.
|
|
220
|
-
result.
|
|
223
|
+
if (result.basepath)
|
|
224
|
+
result.basepath = interpolateString(result.basepath);
|
|
221
225
|
if (result.exclude)
|
|
222
226
|
result.exclude = result.exclude.map((pattern) => interpolateString(pattern));
|
|
223
227
|
return result;
|
|
@@ -251,9 +255,10 @@ function validateRcConfig(config, rcPath) {
|
|
|
251
255
|
'created',
|
|
252
256
|
'version',
|
|
253
257
|
'exclude',
|
|
254
|
-
'
|
|
255
|
-
'
|
|
256
|
-
'
|
|
258
|
+
'basepath',
|
|
259
|
+
'maxsize',
|
|
260
|
+
'maxgzipsize',
|
|
261
|
+
'noindexcheck'
|
|
257
262
|
]);
|
|
258
263
|
for (const key of Object.keys(configObject))
|
|
259
264
|
if (!validKeys.has(key))
|
|
@@ -274,30 +279,32 @@ function validateRcConfig(config, rcPath) {
|
|
|
274
279
|
if (typeof pattern !== 'string')
|
|
275
280
|
throw new TypeError('All exclude patterns must be strings');
|
|
276
281
|
}
|
|
277
|
-
if (configObject['
|
|
278
|
-
const value = configObject['
|
|
282
|
+
if (configObject['maxsize'] !== undefined) {
|
|
283
|
+
const value = configObject['maxsize'];
|
|
279
284
|
if (typeof value === 'string')
|
|
280
285
|
try {
|
|
281
|
-
configObject['
|
|
286
|
+
configObject['maxsize'] = parseSize(value, 'maxsize');
|
|
282
287
|
}
|
|
283
288
|
catch {
|
|
284
|
-
throw new TypeError(`Invalid
|
|
289
|
+
throw new TypeError(`Invalid maxsize in RC file: ${value} (must be a positive number with optional k/m suffix)`);
|
|
285
290
|
}
|
|
286
291
|
else if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
|
|
287
|
-
throw new TypeError(`Invalid
|
|
292
|
+
throw new TypeError(`Invalid maxsize in RC file: ${value} (must be a positive number)`);
|
|
288
293
|
}
|
|
289
|
-
if (configObject['
|
|
290
|
-
const value = configObject['
|
|
294
|
+
if (configObject['maxgzipsize'] !== undefined) {
|
|
295
|
+
const value = configObject['maxgzipsize'];
|
|
291
296
|
if (typeof value === 'string')
|
|
292
297
|
try {
|
|
293
|
-
configObject['
|
|
298
|
+
configObject['maxgzipsize'] = parseSize(value, 'maxgzipsize');
|
|
294
299
|
}
|
|
295
300
|
catch {
|
|
296
|
-
throw new TypeError(`Invalid
|
|
301
|
+
throw new TypeError(`Invalid maxgzipsize in RC file: ${value} (must be a positive number with optional k/m suffix)`);
|
|
297
302
|
}
|
|
298
303
|
else if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
|
|
299
|
-
throw new TypeError(`Invalid
|
|
304
|
+
throw new TypeError(`Invalid maxgzipsize in RC file: ${value} (must be a positive number)`);
|
|
300
305
|
}
|
|
306
|
+
if (configObject['noindexcheck'] !== undefined && typeof configObject['noindexcheck'] !== 'boolean')
|
|
307
|
+
throw new TypeError(`Invalid noindexcheck in RC file: ${configObject['noindexcheck']} (must be boolean)`);
|
|
301
308
|
return configObject;
|
|
302
309
|
}
|
|
303
310
|
function parseArguments() {
|
|
@@ -353,12 +360,14 @@ function parseArguments() {
|
|
|
353
360
|
result.espmethod = rcConfig.espmethod;
|
|
354
361
|
if (rcConfig.define)
|
|
355
362
|
result.define = rcConfig.define;
|
|
356
|
-
if (rcConfig.
|
|
357
|
-
result.basePath = validateBasePath(rcConfig.
|
|
358
|
-
if (rcConfig.
|
|
359
|
-
result.maxSize = rcConfig.
|
|
360
|
-
if (rcConfig.
|
|
361
|
-
result.maxGzipSize = rcConfig.
|
|
363
|
+
if (rcConfig.basepath !== undefined)
|
|
364
|
+
result.basePath = validateBasePath(rcConfig.basepath);
|
|
365
|
+
if (rcConfig.maxsize !== undefined)
|
|
366
|
+
result.maxSize = rcConfig.maxsize;
|
|
367
|
+
if (rcConfig.maxgzipsize !== undefined)
|
|
368
|
+
result.maxGzipSize = rcConfig.maxgzipsize;
|
|
369
|
+
if (rcConfig.noindexcheck !== undefined)
|
|
370
|
+
result.noIndexCheck = rcConfig.noindexcheck;
|
|
362
371
|
if (rcConfig.exclude && rcConfig.exclude.length > 0)
|
|
363
372
|
result.exclude = [...rcConfig.exclude];
|
|
364
373
|
const cliExclude = [];
|