svelteesp32 3.0.1 → 3.0.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/README.md +17 -5
- package/dist/commandLine.d.ts +1 -0
- package/dist/commandLine.js +5 -2
- package/dist/pipeline.js +2 -0
- package/dist/vitePlugin.d.ts +1 -2
- package/dist/vitePlugin.js +67 -30
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -88,8 +88,7 @@ void setup() {
|
|
|
88
88
|
|
|
89
89
|
## What's New
|
|
90
90
|
|
|
91
|
-
- **v3.0.
|
|
92
|
-
- **v3.0.0** — **Vite plugin** (`import { svelteESP32 } from 'svelteesp32/vite'`) generates the header automatically after every build; `npx svelteesp32 init` interactive RC file wizard; Node.js >= 22 required
|
|
91
|
+
- **v3.0.0** — **Vite plugin** (`import { svelteESP32 } from 'svelteesp32/vite'`) generates the header automatically after every build — call with no argument for RC file mode or pass an options object for plugin-options mode; `npx svelteesp32 init` interactive RC file wizard; Node.js >= 22 required
|
|
93
92
|
- **v2.4.0** — `--analyze` for CI size budget checks (per-file table, exits 1 on over-budget); `--manifest` to write a companion JSON manifest alongside the header
|
|
94
93
|
- **v2.3.0** — `--cachetime-html` and `--cachetime-assets` for per-type cache control (e.g. `no-cache` for HTML, 1-year for content-hashed JS/CSS)
|
|
95
94
|
- **v2.2.0** — SPA routing catch-all (`--spa`) for client-side routers on all four engines
|
|
@@ -133,13 +132,27 @@ It asks for engine, source path, output path, and ETag preference, writes the RC
|
|
|
133
132
|
|
|
134
133
|
For Vite-based projects (SvelteKit, React, Vue, Vanilla) you can skip the manual CLI step entirely — the plugin hooks into the build pipeline and regenerates the C++ header automatically after every `vite build`.
|
|
135
134
|
|
|
136
|
-
|
|
135
|
+
The plugin has two exclusive modes — pick one:
|
|
136
|
+
|
|
137
|
+
**RC file mode** — call with no argument (or a string path to a custom RC file). All settings come from `.svelteesp32rc.json`; `outputfile` in the RC file is required.
|
|
137
138
|
|
|
138
139
|
```ts
|
|
139
140
|
import { svelteKit } from '@sveltejs/kit/vite';
|
|
140
141
|
import { svelteESP32 } from 'svelteesp32/vite';
|
|
141
142
|
import { defineConfig } from 'vite';
|
|
142
143
|
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
plugins: [
|
|
146
|
+
svelteKit(),
|
|
147
|
+
svelteESP32() // auto-discover .svelteesp32rc.json
|
|
148
|
+
// svelteESP32('/path/to/custom.rc.json') // or specify path explicitly
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Plugin options mode** — call with an options object. The RC file is completely ignored; `output` is required.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
143
156
|
export default defineConfig({
|
|
144
157
|
plugins: [
|
|
145
158
|
svelteKit(),
|
|
@@ -155,7 +168,7 @@ export default defineConfig({
|
|
|
155
168
|
});
|
|
156
169
|
```
|
|
157
170
|
|
|
158
|
-
`
|
|
171
|
+
`sourcepath` defaults to Vite's `build.outDir` in both modes.
|
|
159
172
|
|
|
160
173
|
**Plugin options**
|
|
161
174
|
|
|
@@ -180,7 +193,6 @@ export default defineConfig({
|
|
|
180
193
|
| `noindexcheck` | `boolean` | `false` | Skip `index.html` validation |
|
|
181
194
|
| `maxsize` | `number` | (none) | Max total uncompressed size in bytes |
|
|
182
195
|
| `maxgzipsize` | `number` | (none) | Max total gzip size in bytes |
|
|
183
|
-
| `config` | `string` | auto-discover | Path to a custom RC file |
|
|
184
196
|
|
|
185
197
|
### Generate Header File (CLI)
|
|
186
198
|
|
package/dist/commandLine.d.ts
CHANGED
package/dist/commandLine.js
CHANGED
|
@@ -412,7 +412,8 @@ function parseArguments() {
|
|
|
412
412
|
define: 'SVELTEESP32',
|
|
413
413
|
cachetime: 0,
|
|
414
414
|
exclude: [],
|
|
415
|
-
basePath: ''
|
|
415
|
+
basePath: '',
|
|
416
|
+
configSource: 'cli'
|
|
416
417
|
};
|
|
417
418
|
if (rcConfig.engine)
|
|
418
419
|
result.engine = rcConfig.engine;
|
|
@@ -615,10 +616,12 @@ function parseArguments() {
|
|
|
615
616
|
return result;
|
|
616
617
|
}
|
|
617
618
|
function formatConfiguration(cmdLine) {
|
|
619
|
+
const relativeOutput = node_path_1.default.relative(process.cwd(), cmdLine.outputfile);
|
|
618
620
|
const parts = [
|
|
621
|
+
`source=${cmdLine.configSource}`,
|
|
619
622
|
`engine=${cmdLine.engine}`,
|
|
620
623
|
`sourcepath=${cmdLine.sourcepath}`,
|
|
621
|
-
`outputfile=${
|
|
624
|
+
`outputfile=${relativeOutput}`,
|
|
622
625
|
`etag=${cmdLine.etag}`,
|
|
623
626
|
`gzip=${cmdLine.gzip}`,
|
|
624
627
|
`cachetime=${cmdLine.cachetime}`
|
package/dist/pipeline.js
CHANGED
|
@@ -181,6 +181,8 @@ function runPipeline(options) {
|
|
|
181
181
|
};
|
|
182
182
|
const sources = [];
|
|
183
183
|
const filesByExtension = [];
|
|
184
|
+
const sourceLabels = { cli: 'command line', rcfile: 'RC file', vite: 'vite plugin' };
|
|
185
|
+
console.log(`Config source: ${sourceLabels[options.configSource]}`);
|
|
184
186
|
console.log('Collecting source files');
|
|
185
187
|
const files = (0, file_1.getFiles)(options);
|
|
186
188
|
if (files.size === 0)
|
package/dist/vitePlugin.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export interface SvelteESP32PluginOptions {
|
|
|
28
28
|
noindexcheck?: boolean;
|
|
29
29
|
maxsize?: number;
|
|
30
30
|
maxgzipsize?: number;
|
|
31
|
-
config?: string;
|
|
32
31
|
}
|
|
33
|
-
export declare function svelteESP32(
|
|
32
|
+
export declare function svelteESP32(optionsOrRcPath?: SvelteESP32PluginOptions | string): VitePlugin;
|
|
34
33
|
export {};
|
package/dist/vitePlugin.js
CHANGED
|
@@ -12,7 +12,7 @@ function coerceBool(value) {
|
|
|
12
12
|
return undefined;
|
|
13
13
|
return value === true || value === 'true';
|
|
14
14
|
}
|
|
15
|
-
function svelteESP32(
|
|
15
|
+
function svelteESP32(optionsOrRcPath) {
|
|
16
16
|
let outDirectory = 'dist';
|
|
17
17
|
return {
|
|
18
18
|
name: 'svelteesp32',
|
|
@@ -20,35 +20,72 @@ function svelteESP32(options) {
|
|
|
20
20
|
outDirectory = config.build.outDir;
|
|
21
21
|
},
|
|
22
22
|
closeBundle() {
|
|
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
|
-
|
|
23
|
+
let options_;
|
|
24
|
+
if (optionsOrRcPath === undefined || typeof optionsOrRcPath === 'string') {
|
|
25
|
+
const rcPath = optionsOrRcPath;
|
|
26
|
+
const rcConfig = (0, commandLine_1.loadRcFileConfig)(rcPath);
|
|
27
|
+
const rawOutput = rcConfig.outputfile;
|
|
28
|
+
if (!rawOutput)
|
|
29
|
+
throw new Error('output is required — specify outputfile in the RC file (.svelteesp32rc.json)');
|
|
30
|
+
const outputfile = node_path_1.default.resolve(rawOutput);
|
|
31
|
+
const sourcepath = rcConfig.sourcepath ?? outDirectory;
|
|
32
|
+
const rawBasepath = rcConfig.basepath ?? '';
|
|
33
|
+
const basePath = (0, commandLine_1.validateBasePath)(rawBasepath);
|
|
34
|
+
options_ = {
|
|
35
|
+
configSource: 'rcfile',
|
|
36
|
+
engine: rcConfig.engine ?? 'psychic',
|
|
37
|
+
sourcepath,
|
|
38
|
+
outputfile,
|
|
39
|
+
etag: rcConfig.etag ?? 'never',
|
|
40
|
+
gzip: rcConfig.gzip ?? 'always',
|
|
41
|
+
cachetime: rcConfig.cachetime ?? 0,
|
|
42
|
+
cachetimeHtml: rcConfig.cachetimehtml,
|
|
43
|
+
cachetimeAssets: rcConfig.cachetimeassets,
|
|
44
|
+
created: coerceBool(rcConfig.created) ?? false,
|
|
45
|
+
version: rcConfig.version ?? '',
|
|
46
|
+
espmethod: rcConfig.espmethod ?? 'initSvelteStaticFiles',
|
|
47
|
+
define: rcConfig.define ?? 'SVELTEESP32',
|
|
48
|
+
exclude: rcConfig.exclude ?? [],
|
|
49
|
+
basePath,
|
|
50
|
+
noIndexCheck: coerceBool(rcConfig.noindexcheck),
|
|
51
|
+
spa: coerceBool(rcConfig.spa),
|
|
52
|
+
manifest: coerceBool(rcConfig.manifest),
|
|
53
|
+
maxSize: rcConfig.maxsize,
|
|
54
|
+
maxGzipSize: rcConfig.maxgzipsize
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const options = optionsOrRcPath;
|
|
59
|
+
const rawOutput = options.output;
|
|
60
|
+
if (!rawOutput)
|
|
61
|
+
throw new Error('output is required — specify it as a plugin option or use svelteESP32() for RC file mode');
|
|
62
|
+
const outputfile = node_path_1.default.resolve(rawOutput);
|
|
63
|
+
const sourcepath = options.sourcepath ?? outDirectory;
|
|
64
|
+
const rawBasepath = options.basepath ?? '';
|
|
65
|
+
const basePath = (0, commandLine_1.validateBasePath)(rawBasepath);
|
|
66
|
+
options_ = {
|
|
67
|
+
configSource: 'vite',
|
|
68
|
+
engine: options.engine ?? 'psychic',
|
|
69
|
+
sourcepath,
|
|
70
|
+
outputfile,
|
|
71
|
+
etag: options.etag ?? 'never',
|
|
72
|
+
gzip: options.gzip ?? 'always',
|
|
73
|
+
cachetime: options.cachetime ?? 0,
|
|
74
|
+
cachetimeHtml: options.cachetimehtml,
|
|
75
|
+
cachetimeAssets: options.cachetimeassets,
|
|
76
|
+
created: options.created ?? false,
|
|
77
|
+
version: options.version ?? '',
|
|
78
|
+
espmethod: options.espmethod ?? 'initSvelteStaticFiles',
|
|
79
|
+
define: options.define ?? 'SVELTEESP32',
|
|
80
|
+
exclude: options.exclude ?? [],
|
|
81
|
+
basePath,
|
|
82
|
+
noIndexCheck: options.noindexcheck,
|
|
83
|
+
spa: options.spa,
|
|
84
|
+
manifest: options.manifest,
|
|
85
|
+
maxSize: options.maxsize,
|
|
86
|
+
maxGzipSize: options.maxgzipsize
|
|
87
|
+
};
|
|
88
|
+
}
|
|
52
89
|
(0, pipeline_1.runPipeline)(options_);
|
|
53
90
|
}
|
|
54
91
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteesp32",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@types/mime-types": "^3.0.1",
|
|
75
75
|
"@types/node": "^25.6.0",
|
|
76
76
|
"@types/picomatch": "^4.0.3",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^8.59.
|
|
78
|
-
"@typescript-eslint/parser": "^8.59.
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.59.2",
|
|
78
|
+
"@typescript-eslint/parser": "^8.59.2",
|
|
79
79
|
"@vitest/coverage-v8": "^4.1.5",
|
|
80
80
|
"eslint": "^10.3.0",
|
|
81
81
|
"eslint-config-prettier": "^10.1.8",
|