svelteesp32 2.2.0 → 2.2.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 CHANGED
@@ -79,6 +79,7 @@ void setup() {
79
79
 
80
80
  ## What's New
81
81
 
82
+ - **v2.2.1** — Enhanced `--dryrun` output: engine/ETag/gzip/SPA summary header + aligned route table with MIME types, sizes, and tags (`[default]`, `[no gzip]`, `[SPA catch-all]`)
82
83
  - **v2.2.0** — SPA routing catch-all (`--spa`) for client-side routers on all four engines
83
84
  - **v2.1.0** — New Arduino WebServer engine (`-e webserver`), dependency updates
84
85
  - **v2.0.0** — **BREAKING**: PsychicHttpServer V2 is now the default `psychic` engine. The `psychic2` engine has been removed. Dry run mode, C++ identifier validation, improved MIME type warnings
@@ -461,7 +462,7 @@ Called for every response (200 = content served, 304 = cache hit).
461
462
  | `--define` | C++ define prefix | `SVELTEESP32` |
462
463
  | `--espmethod` | Init function name | `initSvelteStaticFiles` |
463
464
  | `--config` | Custom RC file path | `.svelteesp32rc.json` |
464
- | `--dryrun` | Show summary without writing output | `false` |
465
+ | `--dryrun` | Show route table + summary without writing output | `false` |
465
466
  | `--spa` | Serve index.html for unmatched routes (SPA routing) | `false` |
466
467
  | `--noindexcheck` | Skip index.html validation | `false` |
467
468
  | `-h` | Show help | |
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { CppCodeSource, ExtensionGroups } from './cppCode';
1
+ import { CppCodeSource, CppCodeSources, ExtensionGroups } from './cppCode';
2
2
  declare const shouldUseGzip: (originalSize: number, compressedSize: number) => boolean;
3
3
  declare const calculateCompressionRatio: (originalSize: number, compressedSize: number) => number;
4
4
  declare const formatCompressionLog: (filename: string, padding: string, originalSize: number, compressedSize: number, useGzip: boolean) => string;
5
5
  declare const formatSize: (bytes: number) => string;
6
6
  declare const createSourceEntry: (filename: string, dataname: string, content: Buffer, contentGzip: Buffer, mimeType: string, sha256: string, isGzip: boolean) => CppCodeSource;
7
7
  declare const updateExtensionGroup: (filesByExtension: ExtensionGroups, extension: string) => void;
8
+ declare const formatDryRunRoutes: (sources: CppCodeSources, engine: "psychic" | "async" | "espidf" | "webserver", basePath: string, spa: boolean) => string;
8
9
  export declare function main(): void;
9
- export { calculateCompressionRatio, createSourceEntry, formatCompressionLog, formatSize, shouldUseGzip, updateExtensionGroup };
10
+ export { calculateCompressionRatio, createSourceEntry, formatCompressionLog, formatDryRunRoutes, formatSize, shouldUseGzip, updateExtensionGroup };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateExtensionGroup = exports.shouldUseGzip = exports.formatSize = exports.formatCompressionLog = exports.createSourceEntry = exports.calculateCompressionRatio = void 0;
6
+ exports.updateExtensionGroup = exports.shouldUseGzip = exports.formatSize = exports.formatDryRunRoutes = exports.formatCompressionLog = exports.createSourceEntry = exports.calculateCompressionRatio = void 0;
7
7
  exports.main = main;
8
8
  const node_fs_1 = require("node:fs");
9
9
  const node_path_1 = __importDefault(require("node:path"));
@@ -54,6 +54,46 @@ const updateExtensionGroup = (filesByExtension, extension) => {
54
54
  filesByExtension.push({ extension, count: 1 });
55
55
  };
56
56
  exports.updateExtensionGroup = updateExtensionGroup;
57
+ const sizeCellFor = (s) => {
58
+ const orig = formatSize(s.content.length);
59
+ if (s.isGzip)
60
+ return `${orig} → ${formatSize(s.contentGzip.length)}`;
61
+ return orig;
62
+ };
63
+ const formatDryRunRoutes = (sources, engine, basePath, spa) => {
64
+ if (sources.length === 0)
65
+ return ' (no files)';
66
+ const defaultSource = sources.find((s) => s.filename === 'index.html' || s.filename === 'index.htm');
67
+ const rows = [];
68
+ if (defaultSource)
69
+ rows.push({
70
+ url: basePath || '/',
71
+ mime: defaultSource.mime,
72
+ sizeCell: sizeCellFor(defaultSource),
73
+ tag: '[default]'
74
+ });
75
+ for (const source of sources)
76
+ rows.push({
77
+ url: `${basePath}/${source.filename}`,
78
+ mime: source.mime,
79
+ sizeCell: sizeCellFor(source),
80
+ tag: source.isGzip ? '' : '[no gzip]'
81
+ });
82
+ if (spa && defaultSource) {
83
+ const spaUrl = engine === 'psychic' && basePath ? `${basePath}/*` : '(SPA catch-all)';
84
+ rows.push({ url: spaUrl, mime: defaultSource.mime, sizeCell: '', tag: '[SPA catch-all → index.html]' });
85
+ }
86
+ const urlWidth = Math.max(...rows.map((r) => r.url.length));
87
+ const mimeWidth = Math.max(...rows.map((r) => r.mime.length));
88
+ const sizeWidth = Math.max(...rows.map((r) => r.sizeCell.length));
89
+ return rows
90
+ .map((r) => {
91
+ const tagPart = r.tag ? ` ${r.tag}` : '';
92
+ return ` GET ${r.url.padEnd(urlWidth)} ${r.mime.padEnd(mimeWidth)} ${r.sizeCell.padEnd(sizeWidth)}${tagPart}`.trimEnd();
93
+ })
94
+ .join('\n');
95
+ };
96
+ exports.formatDryRunRoutes = formatDryRunRoutes;
57
97
  function main() {
58
98
  const summary = {
59
99
  filecount: 0,
@@ -106,8 +146,13 @@ function main() {
106
146
  process.exit(1);
107
147
  }
108
148
  if (commandLine_1.cmdLine.dryRun) {
109
- console.log(`[DRY RUN] ${summary.filecount} files, ${formatSize(summary.size)} original size, ${formatSize(summary.gzipsize)} gzip size`);
110
- console.log(`[DRY RUN] Would write to ${commandLine_1.cmdLine.outputfile}`);
149
+ const baseLabel = commandLine_1.cmdLine.basePath || '(none)';
150
+ const spaLabel = commandLine_1.cmdLine.spa ? 'yes' : 'no';
151
+ console.log(`[DRY RUN] Engine: ${commandLine_1.cmdLine.engine} | ETag: ${commandLine_1.cmdLine.etag} | Gzip: ${commandLine_1.cmdLine.gzip} | Base: ${baseLabel} | SPA: ${spaLabel}`);
152
+ console.log(`[DRY RUN] ${summary.filecount} files, ${formatSize(summary.size)} → ${formatSize(summary.gzipsize)} gzip | would write to ${commandLine_1.cmdLine.outputfile}`);
153
+ console.log('');
154
+ console.log('[DRY RUN] Routes:');
155
+ console.log(formatDryRunRoutes(sources, commandLine_1.cmdLine.engine, commandLine_1.cmdLine.basePath, commandLine_1.cmdLine.spa ?? false));
111
156
  return;
112
157
  }
113
158
  const cppFile = (0, cppCode_1.getCppCode)(sources, filesByExtension);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteesp32",
3
- "version": "2.2.0",
3
+ "version": "2.2.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",
@@ -62,11 +62,11 @@
62
62
  "@eslint/eslintrc": "^3.3.5",
63
63
  "@eslint/js": "^10.0.1",
64
64
  "@types/mime-types": "^3.0.1",
65
- "@types/node": "^25.4.0",
65
+ "@types/node": "^25.5.0",
66
66
  "@types/picomatch": "^4.0.2",
67
67
  "@typescript-eslint/eslint-plugin": "^8.57.0",
68
68
  "@typescript-eslint/parser": "^8.57.0",
69
- "@vitest/coverage-v8": "^4.0.18",
69
+ "@vitest/coverage-v8": "^4.1.0",
70
70
  "eslint": "^10.0.3",
71
71
  "eslint-config-prettier": "^10.1.8",
72
72
  "eslint-plugin-simple-import-sort": "^12.1.1",
@@ -77,7 +77,7 @@
77
77
  "ts-node": "^10.9.2",
78
78
  "tsx": "^4.21.0",
79
79
  "typescript": "^5.9.3",
80
- "vitest": "^4.0.18"
80
+ "vitest": "^4.1.0"
81
81
  },
82
82
  "dependencies": {
83
83
  "handlebars": "^4.7.8",