svelteesp32 1.12.0 → 1.12.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 +1 -1
- package/dist/commandLine.d.ts +1 -0
- package/dist/commandLine.js +22 -0
- package/dist/cppCode.js +4 -4
- package/dist/cppCodeEspIdf.d.ts +1 -1
- package/dist/cppCodeEspIdf.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,7 +202,7 @@ The content of **generated file** (do not edit, just use):
|
|
|
202
202
|
|
|
203
203
|
```c
|
|
204
204
|
//engine: PsychicHttpServer
|
|
205
|
-
//
|
|
205
|
+
//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true cachetime=0 espmethod=initSvelteStaticFiles define=SVELTEESP32
|
|
206
206
|
//
|
|
207
207
|
#define SVELTEESP32_COUNT 5
|
|
208
208
|
#define SVELTEESP32_SIZE 468822
|
package/dist/commandLine.d.ts
CHANGED
package/dist/commandLine.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.cmdLine = void 0;
|
|
7
|
+
exports.formatConfiguration = formatConfiguration;
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
8
9
|
const node_os_1 = require("node:os");
|
|
9
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -350,6 +351,27 @@ function parseArguments() {
|
|
|
350
351
|
}
|
|
351
352
|
return result;
|
|
352
353
|
}
|
|
354
|
+
function formatConfiguration(cmdLine) {
|
|
355
|
+
const parts = [
|
|
356
|
+
`engine=${cmdLine.engine}`,
|
|
357
|
+
`sourcepath=${cmdLine.sourcepath}`,
|
|
358
|
+
`outputfile=${cmdLine.outputfile}`,
|
|
359
|
+
`etag=${cmdLine.etag}`,
|
|
360
|
+
`gzip=${cmdLine.gzip}`,
|
|
361
|
+
`cachetime=${cmdLine.cachetime}`
|
|
362
|
+
];
|
|
363
|
+
if (cmdLine.created)
|
|
364
|
+
parts.push(`created=${cmdLine.created}`);
|
|
365
|
+
if (cmdLine.version)
|
|
366
|
+
parts.push(`version=${cmdLine.version}`);
|
|
367
|
+
if (cmdLine.espmethod)
|
|
368
|
+
parts.push(`espmethod=${cmdLine.espmethod}`);
|
|
369
|
+
if (cmdLine.define)
|
|
370
|
+
parts.push(`define=${cmdLine.define}`);
|
|
371
|
+
if (cmdLine.exclude.length > 0)
|
|
372
|
+
parts.push(`exclude=[${cmdLine.exclude.join(', ')}]`);
|
|
373
|
+
return parts.join(' ');
|
|
374
|
+
}
|
|
353
375
|
exports.cmdLine = parseArguments();
|
|
354
376
|
if (!(0, node_fs_1.existsSync)(exports.cmdLine.sourcepath) || !(0, node_fs_1.statSync)(exports.cmdLine.sourcepath).isDirectory()) {
|
|
355
377
|
console.error(`Directory ${exports.cmdLine.sourcepath} not exists or not a directory`);
|
package/dist/cppCode.js
CHANGED
|
@@ -97,7 +97,7 @@ const char * etag_{{this.dataname}} = "{{this.md5}}";
|
|
|
97
97
|
`;
|
|
98
98
|
const psychicTemplate = `
|
|
99
99
|
//engine: PsychicHttpServer
|
|
100
|
-
//
|
|
100
|
+
//config: {{{config}}}
|
|
101
101
|
//You should use server.config.max_uri_handlers = {{fileCount}}; or higher value to proper handles all files
|
|
102
102
|
{{#if created }}
|
|
103
103
|
//created: {{now}}
|
|
@@ -207,7 +207,7 @@ void {{methodName}}(PsychicHttpServer * server) {
|
|
|
207
207
|
}`;
|
|
208
208
|
const psychic2Template = `
|
|
209
209
|
//engine: PsychicHttpServerV2
|
|
210
|
-
//
|
|
210
|
+
//config: {{{config}}}
|
|
211
211
|
{{#if created }}
|
|
212
212
|
//created: {{now}}
|
|
213
213
|
{{/if}}
|
|
@@ -313,7 +313,7 @@ void {{methodName}}(PsychicHttpServer * server) {
|
|
|
313
313
|
}`;
|
|
314
314
|
const asyncTemplate = `
|
|
315
315
|
//engine: ESPAsyncWebServer
|
|
316
|
-
//
|
|
316
|
+
//config: {{{config}}}
|
|
317
317
|
{{#if created }}
|
|
318
318
|
//created: {{now}}
|
|
319
319
|
{{/if}}
|
|
@@ -526,7 +526,7 @@ const createHandlebarsHelpers = () => {
|
|
|
526
526
|
const getCppCode = (sources, filesByExtension) => {
|
|
527
527
|
const template = (0, handlebars_1.compile)(getTemplate(commandLine_1.cmdLine.engine));
|
|
528
528
|
const templateData = {
|
|
529
|
-
|
|
529
|
+
config: (0, commandLine_1.formatConfiguration)(commandLine_1.cmdLine),
|
|
530
530
|
now: `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
|
|
531
531
|
fileCount: sources.length.toString(),
|
|
532
532
|
fileSize: sources.reduce((previous, current) => previous + current.content.length, 0).toString(),
|
package/dist/cppCodeEspIdf.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const espidfTemplate = "\n//engine: espidf\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 \"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}}\nconst char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n{{/case}}\n{{#case \"false\"}}\n {{#each sources}}\nconst char data_{{this.dataname}}[{{this.length}}] = { {{this.bytes}} };\n {{/each}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_GZIP\n {{#each sources}}\nconst char datagzip_{{this.dataname}}[{{this.lengthGzip}}] = { {{this.bytesGzip}} };\n {{/each}}\n#else\n {{#each sources}}\nconst 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}}\nconst char * etag_{{this.dataname}} = \"{{this.md5}}\";\n {{/each}}\n{{/case}}\n{{#case \"false\"}}\n{{/case}}\n{{#case \"compiler\"}}\n#ifdef {{definePrefix}}_ENABLE_ETAG\n {{#each sources}}\nconst char * etag_{{this.dataname}} = \"{{this.md5}}\";\n {{/each}}\n#endif \n{{/case}}\n{{/switch}}\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 (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 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 (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 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{{#../cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/../cacheTime}}\n{{^../cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/../cacheTime}}\n httpd_resp_set_hdr(req, \"ETag\", etag_{{this.dataname}});\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_ETAG\n{{#../cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"max-age={{value}}\");\n{{/../cacheTime}}\n{{^../cacheTime}}\n httpd_resp_set_hdr(req, \"Cache-Control\", \"no-cache\");\n{{/../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 httpd_resp_send(req, datagzip_{{this.dataname}}, {{this.lengthGzip}});\n{{/case}}\n{{#case \"false\"}}\n httpd_resp_send(req, data_{{this.dataname}}, {{this.length}});\n{{/case}}\n{{#case \"compiler\"}}\n #ifdef {{../definePrefix}}_ENABLE_GZIP\n httpd_resp_send(req, datagzip_{{this.dataname}}, {{this.lengthGzip}});\n #else\n httpd_resp_send(req, 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 = \"/\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n{{/if}}\n\nstatic const httpd_uri_t route_{{this.datanameUpperCase}} = {\n .uri = \"/{{this.filename}}\",\n .method = HTTP_GET,\n .handler = file_handler_{{this.datanameUpperCase}},\n};\n\n{{/each}}\n\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\n}";
|
package/dist/cppCodeEspIdf.js
CHANGED