svelteesp32 2.4.0 → 3.0.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/dist/cppCode.js CHANGED
@@ -6,12 +6,12 @@ const commandLine_1 = require("./commandLine");
6
6
  const cppCodeEspIdf_1 = require("./cppCodeEspIdf");
7
7
  const commonHeaderSection = `
8
8
  {{#switch etag}}
9
- {{#case "true"}}
9
+ {{#case "always"}}
10
10
  #ifdef {{definePrefix}}_ENABLE_ETAG
11
11
  #warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched ON
12
12
  #endif
13
13
  {{/case}}
14
- {{#case "false"}}
14
+ {{#case "never"}}
15
15
  #ifdef {{definePrefix}}_ENABLE_ETAG
16
16
  #warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched OFF
17
17
  #endif
@@ -19,12 +19,12 @@ const commonHeaderSection = `
19
19
  {{/switch}}
20
20
 
21
21
  {{#switch gzip}}
22
- {{#case "true"}}
22
+ {{#case "always"}}
23
23
  #ifdef {{definePrefix}}_ENABLE_GZIP
24
24
  #warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched ON
25
25
  #endif
26
26
  {{/case}}
27
- {{#case "false"}}
27
+ {{#case "never"}}
28
28
  #ifdef {{definePrefix}}_ENABLE_GZIP
29
29
  #warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched OFF
30
30
  #endif
@@ -56,12 +56,12 @@ const dataArraysSection = (progmem = false) => {
56
56
  const memDirective = progmem ? ' PROGMEM' : '';
57
57
  return `
58
58
  {{#switch gzip}}
59
- {{#case "true"}}
59
+ {{#case "always"}}
60
60
  {{#each sources}}
61
61
  static const uint8_t datagzip_{{this.dataname}}[{{this.lengthGzip}}]${memDirective} = { {{this.bytesGzip}} };
62
62
  {{/each}}
63
63
  {{/case}}
64
- {{#case "false"}}
64
+ {{#case "never"}}
65
65
  {{#each sources}}
66
66
  static const uint8_t data_{{this.dataname}}[{{this.length}}]${memDirective} = { {{this.bytes}} };
67
67
  {{/each}}
@@ -82,12 +82,12 @@ static const uint8_t data_{{this.dataname}}[{{this.length}}]${memDirective} = {
82
82
  };
83
83
  const etagArraysSection = `
84
84
  {{#switch etag}}
85
- {{#case "true"}}
85
+ {{#case "always"}}
86
86
  {{#each sources}}
87
87
  static const char etag_{{this.dataname}}[] = "{{this.sha256}}";
88
88
  {{/each}}
89
89
  {{/case}}
90
- {{#case "false"}}
90
+ {{#case "never"}}
91
91
  {{/case}}
92
92
  {{#case "compiler"}}
93
93
  #ifdef {{definePrefix}}_ENABLE_ETAG
@@ -155,7 +155,7 @@ void {{methodName}}(PsychicHttpServer * server) {
155
155
  {{#if this.isDefault}}{{#unless ../basePath}}server->defaultEndpoint = {{/unless}}{{/if}}server->on("{{../basePath}}/{{this.filename}}", HTTP_GET, [](PsychicRequest * request, PsychicResponse * response) {
156
156
 
157
157
  {{#switch ../etag}}
158
- {{#case "true"}}
158
+ {{#case "always"}}
159
159
  if (request->hasHeader("If-None-Match") && request->header("If-None-Match").equals(etag_{{this.dataname}})) {
160
160
  response->setCode(304);
161
161
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -176,7 +176,7 @@ void {{methodName}}(PsychicHttpServer * server) {
176
176
  response->setContentType("{{this.mime}}");
177
177
 
178
178
  {{#switch ../gzip}}
179
- {{#case "true"}}
179
+ {{#case "always"}}
180
180
  {{#if this.isGzip}}
181
181
  response->addHeader("Content-Encoding", "gzip");
182
182
  {{/if}}
@@ -191,7 +191,7 @@ void {{methodName}}(PsychicHttpServer * server) {
191
191
  {{/switch}}
192
192
 
193
193
  {{#switch ../etag}}
194
- {{#case "true"}}
194
+ {{#case "always"}}
195
195
  {{#this.cacheTime}}
196
196
  response->addHeader("Cache-Control", "max-age={{value}}");
197
197
  {{/this.cacheTime}}
@@ -214,10 +214,10 @@ void {{methodName}}(PsychicHttpServer * server) {
214
214
  {{/switch}}
215
215
 
216
216
  {{#switch ../gzip}}
217
- {{#case "true"}}
217
+ {{#case "always"}}
218
218
  response->setContent(datagzip_{{this.dataname}}, {{this.lengthGzip}});
219
219
  {{/case}}
220
- {{#case "false"}}
220
+ {{#case "never"}}
221
221
  response->setContent(data_{{this.dataname}}, {{this.length}});
222
222
  {{/case}}
223
223
  {{#case "compiler"}}
@@ -238,7 +238,7 @@ void {{methodName}}(PsychicHttpServer * server) {
238
238
  server->on("{{../basePath}}", HTTP_GET, [](PsychicRequest * request, PsychicResponse * response) {
239
239
 
240
240
  {{#switch ../etag}}
241
- {{#case "true"}}
241
+ {{#case "always"}}
242
242
  if (request->hasHeader("If-None-Match") && request->header("If-None-Match").equals(etag_{{this.dataname}})) {
243
243
  response->setCode(304);
244
244
  {{../definePrefix}}_onFileServed("{{../basePath}}", 304);
@@ -259,7 +259,7 @@ void {{methodName}}(PsychicHttpServer * server) {
259
259
  response->setContentType("{{this.mime}}");
260
260
 
261
261
  {{#switch ../gzip}}
262
- {{#case "true"}}
262
+ {{#case "always"}}
263
263
  {{#if this.isGzip}}
264
264
  response->addHeader("Content-Encoding", "gzip");
265
265
  {{/if}}
@@ -274,7 +274,7 @@ void {{methodName}}(PsychicHttpServer * server) {
274
274
  {{/switch}}
275
275
 
276
276
  {{#switch ../etag}}
277
- {{#case "true"}}
277
+ {{#case "always"}}
278
278
  {{#this.cacheTime}}
279
279
  response->addHeader("Cache-Control", "max-age={{value}}");
280
280
  {{/this.cacheTime}}
@@ -297,10 +297,10 @@ void {{methodName}}(PsychicHttpServer * server) {
297
297
  {{/switch}}
298
298
 
299
299
  {{#switch ../gzip}}
300
- {{#case "true"}}
300
+ {{#case "always"}}
301
301
  response->setContent(datagzip_{{this.dataname}}, {{this.lengthGzip}});
302
302
  {{/case}}
303
- {{#case "false"}}
303
+ {{#case "never"}}
304
304
  response->setContent(data_{{this.dataname}}, {{this.length}});
305
305
  {{/case}}
306
306
  {{#case "compiler"}}
@@ -326,7 +326,7 @@ void {{methodName}}(PsychicHttpServer * server) {
326
326
  server->on("{{../basePath}}/*", HTTP_GET, [](PsychicRequest * request, PsychicResponse * response) {
327
327
 
328
328
  {{#switch ../etag}}
329
- {{#case "true"}}
329
+ {{#case "always"}}
330
330
  if (request->hasHeader("If-None-Match") && request->header("If-None-Match").equals(etag_{{this.dataname}})) {
331
331
  response->setCode(304);
332
332
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -347,7 +347,7 @@ void {{methodName}}(PsychicHttpServer * server) {
347
347
  response->setContentType("{{this.mime}}");
348
348
 
349
349
  {{#switch ../gzip}}
350
- {{#case "true"}}
350
+ {{#case "always"}}
351
351
  {{#if this.isGzip}}
352
352
  response->addHeader("Content-Encoding", "gzip");
353
353
  {{/if}}
@@ -362,7 +362,7 @@ void {{methodName}}(PsychicHttpServer * server) {
362
362
  {{/switch}}
363
363
 
364
364
  {{#switch ../etag}}
365
- {{#case "true"}}
365
+ {{#case "always"}}
366
366
  {{#this.cacheTime}}
367
367
  response->addHeader("Cache-Control", "max-age={{value}}");
368
368
  {{/this.cacheTime}}
@@ -385,10 +385,10 @@ void {{methodName}}(PsychicHttpServer * server) {
385
385
  {{/switch}}
386
386
 
387
387
  {{#switch ../gzip}}
388
- {{#case "true"}}
388
+ {{#case "always"}}
389
389
  response->setContent(datagzip_{{this.dataname}}, {{this.lengthGzip}});
390
390
  {{/case}}
391
- {{#case "false"}}
391
+ {{#case "never"}}
392
392
  response->setContent(data_{{this.dataname}}, {{this.length}});
393
393
  {{/case}}
394
394
  {{#case "compiler"}}
@@ -441,7 +441,7 @@ void {{methodName}}(AsyncWebServer * server) {
441
441
  server->on("{{../basePath}}/{{this.filename}}", HTTP_GET, [](AsyncWebServerRequest * request) {
442
442
 
443
443
  {{#switch ../etag}}
444
- {{#case "true"}}
444
+ {{#case "always"}}
445
445
  const AsyncWebHeader* h = request->getHeader("If-None-Match");
446
446
  if (h && h->value().equals(etag_{{this.dataname}})) {
447
447
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -462,13 +462,13 @@ void {{methodName}}(AsyncWebServer * server) {
462
462
  {{/switch}}
463
463
 
464
464
  {{#switch ../gzip}}
465
- {{#case "true"}}
465
+ {{#case "always"}}
466
466
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", datagzip_{{this.dataname}}, {{this.lengthGzip}});
467
467
  {{#if this.isGzip}}
468
468
  response->addHeader("Content-Encoding", "gzip");
469
469
  {{/if}}
470
470
  {{/case}}
471
- {{#case "false"}}
471
+ {{#case "never"}}
472
472
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", data_{{this.dataname}}, {{this.length}});
473
473
  {{/case}}
474
474
  {{#case "compiler"}}
@@ -484,7 +484,7 @@ void {{methodName}}(AsyncWebServer * server) {
484
484
  {{/switch}}
485
485
 
486
486
  {{#switch ../etag}}
487
- {{#case "true"}}
487
+ {{#case "always"}}
488
488
  {{#this.cacheTime}}
489
489
  response->addHeader("Cache-Control", "max-age={{value}}");
490
490
  {{/this.cacheTime}}
@@ -513,7 +513,7 @@ void {{methodName}}(AsyncWebServer * server) {
513
513
  server->on("{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}", HTTP_GET, [](AsyncWebServerRequest * request) {
514
514
 
515
515
  {{#switch ../etag}}
516
- {{#case "true"}}
516
+ {{#case "always"}}
517
517
  const AsyncWebHeader* h = request->getHeader("If-None-Match");
518
518
  if (h && h->value().equals(etag_{{this.dataname}})) {
519
519
  {{../definePrefix}}_onFileServed("{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}", 304);
@@ -534,13 +534,13 @@ void {{methodName}}(AsyncWebServer * server) {
534
534
  {{/switch}}
535
535
 
536
536
  {{#switch ../gzip}}
537
- {{#case "true"}}
537
+ {{#case "always"}}
538
538
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", datagzip_{{this.dataname}}, {{this.lengthGzip}});
539
539
  {{#if this.isGzip}}
540
540
  response->addHeader("Content-Encoding", "gzip");
541
541
  {{/if}}
542
542
  {{/case}}
543
- {{#case "false"}}
543
+ {{#case "never"}}
544
544
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", data_{{this.dataname}}, {{this.length}});
545
545
  {{/case}}
546
546
  {{#case "compiler"}}
@@ -556,7 +556,7 @@ void {{methodName}}(AsyncWebServer * server) {
556
556
  {{/switch}}
557
557
 
558
558
  {{#switch ../etag}}
559
- {{#case "true"}}
559
+ {{#case "always"}}
560
560
  {{#this.cacheTime}}
561
561
  response->addHeader("Cache-Control", "max-age={{value}}");
562
562
  {{/this.cacheTime}}
@@ -595,7 +595,7 @@ void {{methodName}}(AsyncWebServer * server) {
595
595
  {{/if}}
596
596
 
597
597
  {{#switch ../etag}}
598
- {{#case "true"}}
598
+ {{#case "always"}}
599
599
  const AsyncWebHeader* h = request->getHeader("If-None-Match");
600
600
  if (h && h->value().equals(etag_{{this.dataname}})) {
601
601
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -616,13 +616,13 @@ void {{methodName}}(AsyncWebServer * server) {
616
616
  {{/switch}}
617
617
 
618
618
  {{#switch ../gzip}}
619
- {{#case "true"}}
619
+ {{#case "always"}}
620
620
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", datagzip_{{this.dataname}}, {{this.lengthGzip}});
621
621
  {{#if this.isGzip}}
622
622
  response->addHeader("Content-Encoding", "gzip");
623
623
  {{/if}}
624
624
  {{/case}}
625
- {{#case "false"}}
625
+ {{#case "never"}}
626
626
  AsyncWebServerResponse *response = request->beginResponse(200, "{{this.mime}}", data_{{this.dataname}}, {{this.length}});
627
627
  {{/case}}
628
628
  {{#case "compiler"}}
@@ -638,7 +638,7 @@ void {{methodName}}(AsyncWebServer * server) {
638
638
  {{/switch}}
639
639
 
640
640
  {{#switch ../etag}}
641
- {{#case "true"}}
641
+ {{#case "always"}}
642
642
  {{#this.cacheTime}}
643
643
  response->addHeader("Cache-Control", "max-age={{value}}");
644
644
  {{/this.cacheTime}}
@@ -711,7 +711,7 @@ void {{methodName}}(WebServer * server) {
711
711
  server->on("{{../basePath}}/{{this.filename}}", HTTP_GET, [server]() {
712
712
 
713
713
  {{#switch ../etag}}
714
- {{#case "true"}}
714
+ {{#case "always"}}
715
715
  if (server->hasHeader("If-None-Match") && server->header("If-None-Match").equals(etag_{{this.dataname}})) {
716
716
  server->send(304);
717
717
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -730,7 +730,7 @@ void {{methodName}}(WebServer * server) {
730
730
  {{/switch}}
731
731
 
732
732
  {{#switch ../etag}}
733
- {{#case "true"}}
733
+ {{#case "always"}}
734
734
  {{#this.cacheTime}}
735
735
  server->sendHeader("Cache-Control", "max-age={{value}}");
736
736
  {{/this.cacheTime}}
@@ -753,7 +753,7 @@ void {{methodName}}(WebServer * server) {
753
753
  {{/switch}}
754
754
 
755
755
  {{#switch ../gzip}}
756
- {{#case "true"}}
756
+ {{#case "always"}}
757
757
  {{#if this.isGzip}}
758
758
  server->sendHeader("Content-Encoding", "gzip");
759
759
  {{/if}}
@@ -761,7 +761,7 @@ void {{methodName}}(WebServer * server) {
761
761
  server->send(200, "{{this.mime}}", "");
762
762
  {{../definePrefix}}_sendChunked(server, datagzip_{{this.dataname}}, {{this.lengthGzip}});
763
763
  {{/case}}
764
- {{#case "false"}}
764
+ {{#case "never"}}
765
765
  server->setContentLength({{this.length}});
766
766
  server->send(200, "{{this.mime}}", "");
767
767
  {{../definePrefix}}_sendChunked(server, data_{{this.dataname}}, {{this.length}});
@@ -788,7 +788,7 @@ void {{methodName}}(WebServer * server) {
788
788
  server->on("{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}", HTTP_GET, [server]() {
789
789
 
790
790
  {{#switch ../etag}}
791
- {{#case "true"}}
791
+ {{#case "always"}}
792
792
  if (server->hasHeader("If-None-Match") && server->header("If-None-Match").equals(etag_{{this.dataname}})) {
793
793
  server->send(304);
794
794
  {{../definePrefix}}_onFileServed("{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}", 304);
@@ -807,7 +807,7 @@ void {{methodName}}(WebServer * server) {
807
807
  {{/switch}}
808
808
 
809
809
  {{#switch ../etag}}
810
- {{#case "true"}}
810
+ {{#case "always"}}
811
811
  {{#this.cacheTime}}
812
812
  server->sendHeader("Cache-Control", "max-age={{value}}");
813
813
  {{/this.cacheTime}}
@@ -830,7 +830,7 @@ void {{methodName}}(WebServer * server) {
830
830
  {{/switch}}
831
831
 
832
832
  {{#switch ../gzip}}
833
- {{#case "true"}}
833
+ {{#case "always"}}
834
834
  {{#if this.isGzip}}
835
835
  server->sendHeader("Content-Encoding", "gzip");
836
836
  {{/if}}
@@ -838,7 +838,7 @@ void {{methodName}}(WebServer * server) {
838
838
  server->send(200, "{{this.mime}}", "");
839
839
  {{../definePrefix}}_sendChunked(server, datagzip_{{this.dataname}}, {{this.lengthGzip}});
840
840
  {{/case}}
841
- {{#case "false"}}
841
+ {{#case "never"}}
842
842
  server->setContentLength({{this.length}});
843
843
  server->send(200, "{{this.mime}}", "");
844
844
  {{../definePrefix}}_sendChunked(server, data_{{this.dataname}}, {{this.length}});
@@ -875,7 +875,7 @@ void {{methodName}}(WebServer * server) {
875
875
  {{/if}}
876
876
 
877
877
  {{#switch ../etag}}
878
- {{#case "true"}}
878
+ {{#case "always"}}
879
879
  if (server->hasHeader("If-None-Match") && server->header("If-None-Match").equals(etag_{{this.dataname}})) {
880
880
  server->send(304);
881
881
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 304);
@@ -894,7 +894,7 @@ void {{methodName}}(WebServer * server) {
894
894
  {{/switch}}
895
895
 
896
896
  {{#switch ../etag}}
897
- {{#case "true"}}
897
+ {{#case "always"}}
898
898
  {{#this.cacheTime}}
899
899
  server->sendHeader("Cache-Control", "max-age={{value}}");
900
900
  {{/this.cacheTime}}
@@ -917,7 +917,7 @@ void {{methodName}}(WebServer * server) {
917
917
  {{/switch}}
918
918
 
919
919
  {{#switch ../gzip}}
920
- {{#case "true"}}
920
+ {{#case "always"}}
921
921
  {{#if this.isGzip}}
922
922
  server->sendHeader("Content-Encoding", "gzip");
923
923
  {{/if}}
@@ -925,7 +925,7 @@ void {{methodName}}(WebServer * server) {
925
925
  server->send(200, "{{this.mime}}", "");
926
926
  {{../definePrefix}}_sendChunked(server, datagzip_{{this.dataname}}, {{this.lengthGzip}});
927
927
  {{/case}}
928
- {{#case "false"}}
928
+ {{#case "never"}}
929
929
  server->setContentLength({{this.length}});
930
930
  server->send(200, "{{this.mime}}", "");
931
931
  {{../definePrefix}}_sendChunked(server, data_{{this.dataname}}, {{this.length}});
@@ -981,7 +981,7 @@ const transformSourceToTemplateData = (s, etag, effectiveCacheTime) => ({
981
981
  bytesGzip: bufferToByteString(s.contentGzip),
982
982
  isDefault: s.filename === 'index.html' || s.filename === 'index.htm',
983
983
  gzipSizeForManifest: s.isGzip ? s.contentGzip.length : 0,
984
- etagForManifest: etag === 'false' ? 'NULL' : `etag_${s.dataname}`,
984
+ etagForManifest: etag === 'never' ? 'NULL' : `etag_${s.dataname}`,
985
985
  cacheTime: effectiveCacheTime ? { value: effectiveCacheTime } : undefined
986
986
  });
987
987
  const postProcessCppCode = (code) => code
@@ -1 +1,2 @@
1
- export declare const espidfTemplate = "\n//engine: espidf\n//config: {{{config}}}\n{{#if created }}\n//created: {{now}}\n{{/if}}\n//\n\n{{#switch etag}}\n{{#case \"true\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n#warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched ON\n#endif\n{{/case}}\n{{#case \"false\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n#warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched OFF\n#endif\n{{/case}}\n{{/switch}}\n\n{{#switch gzip}}\n{{#case \"true\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n#warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched ON\n#endif\n{{/case}}\n{{#case \"false\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n#warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched OFF\n#endif\n{{/case}}\n{{/switch}}\n\n//\n{{#if version }}\n#define {{definePrefix}}_VERSION \"{{version}}\"\n{{/if}}\n#define {{definePrefix}}_COUNT {{fileCount}}\n#define {{definePrefix}}_SIZE {{fileSize}}\n#define {{definePrefix}}_SIZE_GZIP {{fileGzipSize}}\n\n//\n{{#each sources}}\n#define {{../definePrefix}}_FILE_{{this.datanameUpperCase}}\n{{/each}}\n\n//\n{{#each filesByExtension}}\n#define {{../definePrefix}}_{{this.extension}}_FILES {{this.count}}\n{{/each}}\n\n#include <stdint.h>\n#include <string.h>\n#include <stdlib.h>\n#include <esp_err.h>\n#include <esp_http_server.h>\n\n//\n{{#switch gzip}}\n{{#case \"true\"}}\n {{#each sources}}\nstatic const unsigned char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n{{/case}}\n{{#case \"false\"}}\n {{#each sources}}\nstatic const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };\n {{/each}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n {{#each sources}}\nstatic const unsigned char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n#else\n {{#each sources}}\nstatic const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };\n {{/each}}\n#endif \n{{/case}}\n{{/switch}}\n\n//\n{{#switch etag}}\n{{#case \"true\"}}\n {{#each sources}}\nstatic const char etag_{{this.dataname}}[] = \"{{this.sha256}}\";\n {{/each}}\n{{/case}}\n{{#case \"false\"}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n {{#each sources}}\nstatic const char etag_{{this.dataname}}[] = \"{{this.sha256}}\";\n {{/each}}\n#endif\n{{/case}}\n{{/switch}}\n\n// File manifest struct (C-compatible typedef)\ntypedef struct {\n const char* path;\n uint32_t size;\n uint32_t gzipSize;\n const char* etag;\n const char* contentType;\n} {{definePrefix}}_FileInfo;\n\n// File manifest array\nstatic const {{definePrefix}}_FileInfo {{definePrefix}}_FILES[] = {\n{{#each sources}}\n { \"{{../basePath}}/{{this.filename}}\", {{this.length}}, {{this.gzipSizeForManifest}}, {{this.etagForManifest}}, \"{{this.mime}}\" },\n{{/each}}\n};\nstatic const size_t {{definePrefix}}_FILE_COUNT = sizeof({{definePrefix}}_FILES) / sizeof({{definePrefix}}_FILES[0]);\n\n// File served hook - override with your own implementation\n__attribute__((weak)) void {{definePrefix}}_onFileServed(const char* path, int statusCode) {}\n\n{{#each sources}}\n\nstatic esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)\n{\n{{#switch ../etag}}\n{{#case \"true\"}}\n size_t hdr_len = httpd_req_get_hdr_value_len(req, \"If-None-Match\");\n if (hdr_len > 0) {\n char* hdr_value = malloc(hdr_len + 1);\n if (hdr_value == NULL) { httpd_resp_send_500(req); return ESP_FAIL; }\n if (httpd_req_get_hdr_value_str(req, \"If-None-Match\", hdr_value, hdr_len + 1) == ESP_OK) {\n if (strcmp(hdr_value, etag_{{this.dataname}}) == 0) {\n free(hdr_value);\n httpd_resp_set_status(req, \"304 Not Modified\");\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 304);\n httpd_resp_send(req, NULL, 0);\n return ESP_OK;\n }\n }\n free(hdr_value);\n }\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_ETAG\n size_t hdr_len = httpd_req_get_hdr_value_len(req, \"If-None-Match\");\n if (hdr_len > 0) {\n char* hdr_value = malloc(hdr_len + 1);\n if (hdr_value == NULL) { httpd_resp_send_500(req); return ESP_FAIL; }\n if (httpd_req_get_hdr_value_str(req, \"If-None-Match\", hdr_value, hdr_len + 1) == ESP_OK) {\n if (strcmp(hdr_value, etag_{{this.dataname}}) == 0) {\n free(hdr_value);\n httpd_resp_set_status(req, \"304 Not Modified\");\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 304);\n httpd_resp_send(req, NULL, 0);\n return ESP_OK;\n }\n }\n free(hdr_value);\n }\n #endif\n{{/case}}\n{{/switch}}\n httpd_resp_set_type(req, \"{{this.mime}}\");\n{{#switch ../gzip}}\n{{#case \"true\"}}\n{{#if this.isGzip}}\n httpd_resp_set_hdr(req, \"Content-Encoding\", \"gzip\");\n{{/if}}\n{{/case}}\n{{#case \"compiler\"}}\n {{#if this.isGzip}}\n #ifdef {{../definePrefix}}_ENABLE_GZIP\n httpd_resp_set_hdr(req, \"Content-Encoding\", \"gzip\");\n #endif \n {{/if}}\n{{/case}}\n{{/switch}}\n\n{{#switch ../etag}}\n{{#case \"true\"}}\n{{#this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/this.cacheTime}}\n{{^this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/this.cacheTime}}\n httpd_resp_set_hdr(req, \"ETag\", etag_{{this.dataname}});\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_ETAG\n{{#this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/this.cacheTime}}\n{{^this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/this.cacheTime}}\n httpd_resp_set_hdr(req, \"ETag\", etag_{{this.dataname}});\n #endif \n{{/case}}\n{{/switch}}\n\n{{#switch ../gzip}}\n{{#case \"true\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n httpd_resp_send(req, (const char *)datagzip_{{this.dataname}}, {{this.lengthGzip}});\n{{/case}}\n{{#case \"false\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n httpd_resp_send(req, (const char *)data_{{this.dataname}}, {{this.length}});\n{{/case}}\n{{#case \"compiler\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n #ifdef {{../definePrefix}}_ENABLE_GZIP\n httpd_resp_send(req, (const char *)datagzip_{{this.dataname}}, {{this.lengthGzip}});\n #else\n httpd_resp_send(req, (const char *)data_{{this.dataname}}, {{this.length}});\n #endif\n{{/case}}\n{{/switch}}\n return ESP_OK;\n}\n\n{{#if this.isDefault}}\nstatic const httpd_uri_t route_def_{{this.datanameUpperCase}} = {\n .uri = \"{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n{{/if}}\n\nstatic const httpd_uri_t route_{{this.datanameUpperCase}} = {\n .uri = \"{{../basePath}}/{{this.filename}}\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n\n{{/each}}\n\n{{#if spa}}\n{{#with spaSource}}\nstatic esp_err_t spa_handler_{{this.datanameUpperCase}}(httpd_req_t *req, httpd_err_code_t err) {\n{{#if ../basePath}}\n const char* prefix = \"{{../basePath}}/\";\n if (strncmp(req->uri, prefix, strlen(prefix)) != 0 && strcmp(req->uri, \"{{../basePath}}\") != 0) {\n httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, \"Not found\");\n return ESP_FAIL;\n }\n{{/if}}\n return file_handler_{{this.datanameUpperCase}}(req);\n}\n{{/with}}\n{{/if}}\n\n\nstatic inline void {{methodName}}(httpd_handle_t server) {\n{{#each sources}}\n{{#if this.isDefault}}\n httpd_register_uri_handler(server, &route_def_{{this.datanameUpperCase}});\n{{/if}}\n httpd_register_uri_handler(server, &route_{{this.datanameUpperCase}});\n{{/each}}\n{{#if spa}}\n{{#with spaSource}}\n httpd_register_err_handler(server, HTTPD_404_NOT_FOUND, spa_handler_{{this.datanameUpperCase}});\n{{/with}}\n{{/if}}\n\n}";
1
+ export declare const espidfTemplate = "\n//engine: espidf\n//config: {{{config}}}\n{{#if created }}\n//created: {{now}}\n{{/if}}\n//\n\n{{#switch etag}}\n{{#case \"always\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n#warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched ON\n#endif\n{{/case}}\n{{#case \"never\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n#warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched OFF\n#endif\n{{/case}}\n{{/switch}}\n\n{{#switch gzip}}\n{{#case \"always\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n#warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched ON\n#endif\n{{/case}}\n{{#case \"never\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n#warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched OFF\n#endif\n{{/case}}\n{{/switch}}\n\n//\n{{#if version }}\n#define {{definePrefix}}_VERSION \"{{version}}\"\n{{/if}}\n#define {{definePrefix}}_COUNT {{fileCount}}\n#define {{definePrefix}}_SIZE {{fileSize}}\n#define {{definePrefix}}_SIZE_GZIP {{fileGzipSize}}\n\n//\n{{#each sources}}\n#define {{../definePrefix}}_FILE_{{this.datanameUpperCase}}\n{{/each}}\n\n//\n{{#each filesByExtension}}\n#define {{../definePrefix}}_{{this.extension}}_FILES {{this.count}}\n{{/each}}\n\n#include <stdint.h>\n#include <string.h>\n#include <stdlib.h>\n#include <esp_err.h>\n#include <esp_http_server.h>\n\n//\n{{#switch gzip}}\n{{#case \"always\"}}\n {{#each sources}}\nstatic const unsigned char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n{{/case}}\n{{#case \"never\"}}\n {{#each sources}}\nstatic const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };\n {{/each}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n {{#each sources}}\nstatic const unsigned char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n#else\n {{#each sources}}\nstatic const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };\n {{/each}}\n#endif \n{{/case}}\n{{/switch}}\n\n//\n{{#switch etag}}\n{{#case \"always\"}}\n {{#each sources}}\nstatic const char etag_{{this.dataname}}[] = \"{{this.sha256}}\";\n {{/each}}\n{{/case}}\n{{#case \"never\"}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n {{#each sources}}\nstatic const char etag_{{this.dataname}}[] = \"{{this.sha256}}\";\n {{/each}}\n#endif\n{{/case}}\n{{/switch}}\n\n// File manifest struct (C-compatible typedef)\ntypedef struct {\n const char* path;\n uint32_t size;\n uint32_t gzipSize;\n const char* etag;\n const char* contentType;\n} {{definePrefix}}_FileInfo;\n\n// File manifest array\nstatic const {{definePrefix}}_FileInfo {{definePrefix}}_FILES[] = {\n{{#each sources}}\n { \"{{../basePath}}/{{this.filename}}\", {{this.length}}, {{this.gzipSizeForManifest}}, {{this.etagForManifest}}, \"{{this.mime}}\" },\n{{/each}}\n};\nstatic const size_t {{definePrefix}}_FILE_COUNT = sizeof({{definePrefix}}_FILES) / sizeof({{definePrefix}}_FILES[0]);\n\n// File served hook - override with your own implementation\n__attribute__((weak)) void {{definePrefix}}_onFileServed(const char* path, int statusCode) {}\n\n{{#each sources}}\n\nstatic esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)\n{\n{{#switch ../etag}}\n{{#case \"always\"}}\n size_t hdr_len = httpd_req_get_hdr_value_len(req, \"If-None-Match\");\n if (hdr_len > 0) {\n char* hdr_value = malloc(hdr_len + 1);\n if (hdr_value == NULL) { httpd_resp_send_500(req); return ESP_FAIL; }\n if (httpd_req_get_hdr_value_str(req, \"If-None-Match\", hdr_value, hdr_len + 1) == ESP_OK) {\n if (strcmp(hdr_value, etag_{{this.dataname}}) == 0) {\n free(hdr_value);\n httpd_resp_set_status(req, \"304 Not Modified\");\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 304);\n httpd_resp_send(req, NULL, 0);\n return ESP_OK;\n }\n }\n free(hdr_value);\n }\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_ETAG\n size_t hdr_len = httpd_req_get_hdr_value_len(req, \"If-None-Match\");\n if (hdr_len > 0) {\n char* hdr_value = malloc(hdr_len + 1);\n if (hdr_value == NULL) { httpd_resp_send_500(req); return ESP_FAIL; }\n if (httpd_req_get_hdr_value_str(req, \"If-None-Match\", hdr_value, hdr_len + 1) == ESP_OK) {\n if (strcmp(hdr_value, etag_{{this.dataname}}) == 0) {\n free(hdr_value);\n httpd_resp_set_status(req, \"304 Not Modified\");\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 304);\n httpd_resp_send(req, NULL, 0);\n return ESP_OK;\n }\n }\n free(hdr_value);\n }\n #endif\n{{/case}}\n{{/switch}}\n httpd_resp_set_type(req, \"{{this.mime}}\");\n{{#switch ../gzip}}\n{{#case \"always\"}}\n{{#if this.isGzip}}\n httpd_resp_set_hdr(req, \"Content-Encoding\", \"gzip\");\n{{/if}}\n{{/case}}\n{{#case \"compiler\"}}\n {{#if this.isGzip}}\n #ifdef {{../definePrefix}}_ENABLE_GZIP\n httpd_resp_set_hdr(req, \"Content-Encoding\", \"gzip\");\n #endif \n {{/if}}\n{{/case}}\n{{/switch}}\n\n{{#switch ../etag}}\n{{#case \"always\"}}\n{{#this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/this.cacheTime}}\n{{^this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/this.cacheTime}}\n httpd_resp_set_hdr(req, \"ETag\", etag_{{this.dataname}});\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_ETAG\n{{#this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/this.cacheTime}}\n{{^this.cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/this.cacheTime}}\n httpd_resp_set_hdr(req, \"ETag\", etag_{{this.dataname}});\n #endif \n{{/case}}\n{{/switch}}\n\n{{#switch ../gzip}}\n{{#case \"always\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n httpd_resp_send(req, (const char *)datagzip_{{this.dataname}}, {{this.lengthGzip}});\n{{/case}}\n{{#case \"never\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n httpd_resp_send(req, (const char *)data_{{this.dataname}}, {{this.length}});\n{{/case}}\n{{#case \"compiler\"}}\n {{../definePrefix}}_onFileServed(\"{{../basePath}}/{{this.filename}}\", 200);\n #ifdef {{../definePrefix}}_ENABLE_GZIP\n httpd_resp_send(req, (const char *)datagzip_{{this.dataname}}, {{this.lengthGzip}});\n #else\n httpd_resp_send(req, (const char *)data_{{this.dataname}}, {{this.length}});\n #endif\n{{/case}}\n{{/switch}}\n return ESP_OK;\n}\n\n{{#if this.isDefault}}\nstatic const httpd_uri_t route_def_{{this.datanameUpperCase}} = {\n .uri = \"{{#if ../basePath}}{{../basePath}}{{else}}/{{/if}}\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n{{/if}}\n\nstatic const httpd_uri_t route_{{this.datanameUpperCase}} = {\n .uri = \"{{../basePath}}/{{this.filename}}\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n\n{{/each}}\n\n{{#if spa}}\n{{#with spaSource}}\nstatic esp_err_t spa_handler_{{this.datanameUpperCase}}(httpd_req_t *req, httpd_err_code_t err) {\n{{#if ../basePath}}\n const char* prefix = \"{{../basePath}}/\";\n if (strncmp(req->uri, prefix, strlen(prefix)) != 0 && strcmp(req->uri, \"{{../basePath}}\") != 0) {\n httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, \"Not found\");\n return ESP_FAIL;\n }\n{{/if}}\n return file_handler_{{this.datanameUpperCase}}(req);\n}\n{{/with}}\n{{/if}}\n\n\nstatic inline void {{methodName}}(httpd_handle_t server) {\n{{#each sources}}\n{{#if this.isDefault}}\n httpd_register_uri_handler(server, &route_def_{{this.datanameUpperCase}});\n{{/if}}\n httpd_register_uri_handler(server, &route_{{this.datanameUpperCase}});\n{{/each}}\n{{#if spa}}\n{{#with spaSource}}\n httpd_register_err_handler(server, HTTPD_404_NOT_FOUND, spa_handler_{{this.datanameUpperCase}});\n{{/with}}\n{{/if}}\n\n}";
2
+ //# sourceMappingURL=cppCodeEspIdf.d.ts.map
@@ -10,12 +10,12 @@ exports.espidfTemplate = `
10
10
  //
11
11
 
12
12
  {{#switch etag}}
13
- {{#case "true"}}
13
+ {{#case "always"}}
14
14
  #ifdef {{definePrefix}}_ENABLE_ETAG
15
15
  #warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched ON
16
16
  #endif
17
17
  {{/case}}
18
- {{#case "false"}}
18
+ {{#case "never"}}
19
19
  #ifdef {{definePrefix}}_ENABLE_ETAG
20
20
  #warning {{definePrefix}}_ENABLE_ETAG has no effect because it is permanently switched OFF
21
21
  #endif
@@ -23,12 +23,12 @@ exports.espidfTemplate = `
23
23
  {{/switch}}
24
24
 
25
25
  {{#switch gzip}}
26
- {{#case "true"}}
26
+ {{#case "always"}}
27
27
  #ifdef {{definePrefix}}_ENABLE_GZIP
28
28
  #warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched ON
29
29
  #endif
30
30
  {{/case}}
31
- {{#case "false"}}
31
+ {{#case "never"}}
32
32
  #ifdef {{definePrefix}}_ENABLE_GZIP
33
33
  #warning {{definePrefix}}_ENABLE_GZIP has no effect because it is permanently switched OFF
34
34
  #endif
@@ -61,12 +61,12 @@ exports.espidfTemplate = `
61
61
 
62
62
  //
63
63
  {{#switch gzip}}
64
- {{#case "true"}}
64
+ {{#case "always"}}
65
65
  {{#each sources}}
66
66
  static const unsigned char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };
67
67
  {{/each}}
68
68
  {{/case}}
69
- {{#case "false"}}
69
+ {{#case "never"}}
70
70
  {{#each sources}}
71
71
  static const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };
72
72
  {{/each}}
@@ -86,12 +86,12 @@ static const unsigned char data_{{this.dataname}}[{{this.length}}] = { {{this.by
86
86
 
87
87
  //
88
88
  {{#switch etag}}
89
- {{#case "true"}}
89
+ {{#case "always"}}
90
90
  {{#each sources}}
91
91
  static const char etag_{{this.dataname}}[] = "{{this.sha256}}";
92
92
  {{/each}}
93
93
  {{/case}}
94
- {{#case "false"}}
94
+ {{#case "never"}}
95
95
  {{/case}}
96
96
  {{#case "compiler"}}
97
97
  #ifdef {{definePrefix}}_ENABLE_ETAG
@@ -127,7 +127,7 @@ __attribute__((weak)) void {{definePrefix}}_onFileServed(const char* path, int s
127
127
  static esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)
128
128
  {
129
129
  {{#switch ../etag}}
130
- {{#case "true"}}
130
+ {{#case "always"}}
131
131
  size_t hdr_len = httpd_req_get_hdr_value_len(req, "If-None-Match");
132
132
  if (hdr_len > 0) {
133
133
  char* hdr_value = malloc(hdr_len + 1);
@@ -166,7 +166,7 @@ static esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)
166
166
  {{/switch}}
167
167
  httpd_resp_set_type(req, "{{this.mime}}");
168
168
  {{#switch ../gzip}}
169
- {{#case "true"}}
169
+ {{#case "always"}}
170
170
  {{#if this.isGzip}}
171
171
  httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
172
172
  {{/if}}
@@ -181,7 +181,7 @@ static esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)
181
181
  {{/switch}}
182
182
 
183
183
  {{#switch ../etag}}
184
- {{#case "true"}}
184
+ {{#case "always"}}
185
185
  {{#this.cacheTime}}
186
186
  httpd_resp_set_hdr(req, "Cache-Control", "max-age={{value}}");
187
187
  {{/this.cacheTime}}
@@ -204,11 +204,11 @@ static esp_err_t file_handler_{{this.datanameUpperCase}} (httpd_req_t *req)
204
204
  {{/switch}}
205
205
 
206
206
  {{#switch ../gzip}}
207
- {{#case "true"}}
207
+ {{#case "always"}}
208
208
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 200);
209
209
  httpd_resp_send(req, (const char *)datagzip_{{this.dataname}}, {{this.lengthGzip}});
210
210
  {{/case}}
211
- {{#case "false"}}
211
+ {{#case "never"}}
212
212
  {{../definePrefix}}_onFileServed("{{../basePath}}/{{this.filename}}", 200);
213
213
  httpd_resp_send(req, (const char *)data_{{this.dataname}}, {{this.length}});
214
214
  {{/case}}
@@ -3,3 +3,4 @@ export declare function getInvalidEngineError(attempted: string): string;
3
3
  export declare function getSourcepathNotFoundError(sourcepath: string, reason: 'not_found' | 'not_directory'): string;
4
4
  export declare function getSizeBudgetExceededError(type: 'size' | 'gzipSize', limit: number, actual: number): string;
5
5
  export declare function getMaxUriHandlersHint(engine: string, routeCount: number, espmethod?: string): string;
6
+ //# sourceMappingURL=errorMessages.d.ts.map
@@ -68,7 +68,7 @@ Example RC file (.svelteesp32rc.json):
68
68
  "sourcepath": "./dist"
69
69
  }
70
70
 
71
- Documentation: https://github.com/hpieroni/svelteesp32#readme`);
71
+ Documentation: https://github.com/BCsabaEngine/svelteesp32#readme`);
72
72
  }
73
73
  function getSourcepathNotFoundError(sourcepath, reason) {
74
74
  if (reason === 'not_directory')
package/dist/file.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import type { ICopyFilesArguments } from './commandLine';
1
2
  export type FileData = {
2
3
  content: Buffer;
3
4
  hash: string;
4
5
  };
5
- export declare const getFiles: () => Map<string, FileData>;
6
+ export declare const getFiles: (options: Pick<ICopyFilesArguments, "sourcepath" | "exclude" | "noIndexCheck" | "engine">) => Map<string, FileData>;
7
+ //# sourceMappingURL=file.d.ts.map
package/dist/file.js CHANGED
@@ -9,7 +9,6 @@ const node_fs_1 = require("node:fs");
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
10
  const picomatch_1 = __importDefault(require("picomatch"));
11
11
  const tinyglobby_1 = require("tinyglobby");
12
- const commandLine_1 = require("./commandLine");
13
12
  const consoleColor_1 = require("./consoleColor");
14
13
  const errorMessages_1 = require("./errorMessages");
15
14
  const findSimilarFiles = (files) => {
@@ -33,7 +32,7 @@ const shouldSkipFile = (filename, allFilenames) => {
33
32
  if (compressedExtensions.includes(extension)) {
34
33
  const original = filename.slice(0, -1 * extension.length);
35
34
  if (allFilenames.includes(original)) {
36
- console.log((0, consoleColor_1.redLog)(` ${filename} skipped because is perhaps a compressed version of ${original}`));
35
+ console.log((0, consoleColor_1.redLog)(` ${filename} skipped likely a compressed version of ${original}`));
37
36
  return true;
38
37
  }
39
38
  }
@@ -50,15 +49,15 @@ const isExcluded = (filename, excludePatterns) => {
50
49
  });
51
50
  return isMatch(normalizedFilename);
52
51
  };
53
- const getFiles = () => {
52
+ const getFiles = (options) => {
54
53
  const allFilenames = (0, tinyglobby_1.globSync)('**/*', {
55
- cwd: commandLine_1.cmdLine.sourcepath,
54
+ cwd: options.sourcepath,
56
55
  onlyFiles: true,
57
56
  dot: false,
58
57
  followSymbolicLinks: false
59
58
  });
60
59
  const withoutCompressed = allFilenames.filter((filename) => !shouldSkipFile(filename, allFilenames));
61
- const excludePatterns = commandLine_1.cmdLine.exclude || [];
60
+ const excludePatterns = options.exclude;
62
61
  const excludedFiles = [];
63
62
  const filenames = withoutCompressed.filter((filename) => {
64
63
  if (isExcluded(filename, excludePatterns)) {
@@ -81,7 +80,7 @@ const getFiles = () => {
81
80
  const MAX_FILE_SIZE = 50 * 1024 * 1024;
82
81
  const result = new Map();
83
82
  for (const filename of filenames) {
84
- const filePath = node_path_1.default.join(commandLine_1.cmdLine.sourcepath, filename);
83
+ const filePath = node_path_1.default.join(options.sourcepath, filename);
85
84
  const fileSize = (0, node_fs_1.statSync)(filePath).size;
86
85
  if (fileSize > MAX_FILE_SIZE)
87
86
  throw new Error(`File too large (${Math.round(fileSize / 1024)}kB): ${filename}. Maximum single-file size is 50MB.`);
@@ -91,12 +90,10 @@ const getFiles = () => {
91
90
  }
92
91
  const duplicates = findSimilarFiles(result);
93
92
  for (const sameFiles of duplicates)
94
- console.log((0, consoleColor_1.yellowLog)(` ${sameFiles.join(', ')} files look like identical`));
93
+ console.log((0, consoleColor_1.yellowLog)(` ${sameFiles.join(', ')} files appear identical`));
95
94
  const hasIndex = [...result.keys()].some((f) => f === 'index.html' || f === 'index.htm' || f.endsWith('/index.html') || f.endsWith('/index.htm'));
96
- if (!hasIndex && !commandLine_1.cmdLine.noIndexCheck) {
97
- console.error('\n' + (0, errorMessages_1.getMissingIndexError)(commandLine_1.cmdLine.engine));
98
- process.exit(1);
99
- }
95
+ if (!hasIndex && !options.noIndexCheck)
96
+ throw new Error((0, errorMessages_1.getMissingIndexError)(options.engine));
100
97
  return result;
101
98
  };
102
99
  exports.getFiles = getFiles;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,3 @@
1
- import { CppCodeSource, CppCodeSources, ExtensionGroups } from './cppCode';
2
- type ProcessingSummary = {
3
- filecount: number;
4
- size: number;
5
- gzipsize: number;
6
- };
7
- declare const shouldUseGzip: (originalSize: number, compressedSize: number) => boolean;
8
- declare const calculateCompressionRatio: (originalSize: number, compressedSize: number) => number;
9
- declare const formatCompressionLog: (filename: string, padding: string, originalSize: number, compressedSize: number, useGzip: boolean) => string;
10
- declare const formatSize: (bytes: number) => string;
11
- declare const formatSizePrecise: (bytes: number) => string;
12
- declare const createSourceEntry: (filename: string, dataname: string, content: Buffer, contentGzip: Buffer, mimeType: string, sha256: string, isGzip: boolean) => CppCodeSource;
13
- declare const updateExtensionGroup: (filesByExtension: ExtensionGroups, extension: string) => void;
14
- declare const formatDryRunRoutes: (sources: CppCodeSources, engine: "psychic" | "async" | "espidf" | "webserver", basePath: string, spa: boolean) => string;
15
- declare const formatAnalyzeTable: (sources: CppCodeSources, summary: ProcessingSummary, maxSize: number | undefined, maxGzipSize: number | undefined) => string;
16
1
  export declare function main(): void;
17
- export { calculateCompressionRatio, createSourceEntry, formatAnalyzeTable, formatCompressionLog, formatDryRunRoutes, formatSize, formatSizePrecise, shouldUseGzip, updateExtensionGroup };
2
+ export { calculateCompressionRatio, createSourceEntry, formatAnalyzeTable, formatChangeSummary, formatCompressionLog, formatDryRunRoutes, formatSize, formatSizePrecise, type PreviousManifestFile, shouldUseGzip, updateExtensionGroup } from './pipeline';
3
+ //# sourceMappingURL=index.d.ts.map