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 CHANGED
@@ -88,8 +88,7 @@ void setup() {
88
88
 
89
89
  ## What's New
90
90
 
91
- - **v3.0.1** — Vite plugin now reads RC file automatically; `output` is optional when `outputfile` is in the RC file; option names aligned to lowercase to match RC file keys (`cachetimehtml`, `cachetimeassets`, `noindexcheck`, `maxsize`, `maxgzipsize`); new `config` option to point at a custom RC file
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
- **`vite.config.ts`**
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
- `output` can be omitted when `outputfile` is set in an RC file. `sourcepath` defaults to Vite's `build.outDir`. All other options mirror CLI flags and fall back to the RC file before applying built-in defaults.
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
 
@@ -21,6 +21,7 @@ export interface ICopyFilesArguments {
21
21
  spa?: boolean;
22
22
  manifest?: boolean;
23
23
  help?: boolean;
24
+ configSource: 'cli' | 'rcfile' | 'vite';
24
25
  }
25
26
  export interface IRcFileConfig {
26
27
  engine?: 'psychic' | 'async' | 'espidf' | 'webserver';
@@ -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=${cmdLine.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)
@@ -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(options: SvelteESP32PluginOptions): VitePlugin;
32
+ export declare function svelteESP32(optionsOrRcPath?: SvelteESP32PluginOptions | string): VitePlugin;
34
33
  export {};
@@ -12,7 +12,7 @@ function coerceBool(value) {
12
12
  return undefined;
13
13
  return value === true || value === 'true';
14
14
  }
15
- function svelteESP32(options) {
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
- const rcConfig = (0, commandLine_1.loadRcFileConfig)(options.config);
24
- const rawOutput = options.output ?? rcConfig.outputfile;
25
- if (!rawOutput)
26
- throw new Error('output is required — specify it as a plugin option or in the RC file (outputfile)');
27
- const outputfile = node_path_1.default.resolve(rawOutput);
28
- const sourcepath = options.sourcepath ?? rcConfig.sourcepath ?? outDirectory;
29
- const rawBasepath = options.basepath ?? rcConfig.basepath ?? '';
30
- const basePath = (0, commandLine_1.validateBasePath)(rawBasepath);
31
- const options_ = {
32
- engine: options.engine ?? rcConfig.engine ?? 'psychic',
33
- sourcepath,
34
- outputfile,
35
- etag: options.etag ?? rcConfig.etag ?? 'never',
36
- gzip: options.gzip ?? rcConfig.gzip ?? 'always',
37
- cachetime: options.cachetime ?? rcConfig.cachetime ?? 0,
38
- cachetimeHtml: options.cachetimehtml ?? rcConfig.cachetimehtml,
39
- cachetimeAssets: options.cachetimeassets ?? rcConfig.cachetimeassets,
40
- created: options.created ?? coerceBool(rcConfig.created) ?? false,
41
- version: options.version ?? rcConfig.version ?? '',
42
- espmethod: options.espmethod ?? rcConfig.espmethod ?? 'initSvelteStaticFiles',
43
- define: options.define ?? rcConfig.define ?? 'SVELTEESP32',
44
- exclude: options.exclude ?? rcConfig.exclude ?? [],
45
- basePath,
46
- noIndexCheck: options.noindexcheck ?? coerceBool(rcConfig.noindexcheck),
47
- spa: options.spa ?? coerceBool(rcConfig.spa),
48
- manifest: options.manifest ?? coerceBool(rcConfig.manifest),
49
- maxSize: options.maxsize ?? rcConfig.maxsize,
50
- maxGzipSize: options.maxgzipsize ?? rcConfig.maxgzipsize
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.1",
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.1",
78
- "@typescript-eslint/parser": "^8.59.1",
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",