svelteesp32 1.2.5 → 1.2.7

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.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export type cppCodeSource = {
3
2
  index: number;
4
3
  filename: string;
package/dist/cppCode.js CHANGED
@@ -15,35 +15,41 @@ const psychicTemplate = `
15
15
  #include <PsychicHttpsServer.h>
16
16
 
17
17
  {{#each sources}}
18
+ {{#if this.isDefault}}
19
+ const uint8_t dataDefaultDocument[{{this.length}}] = { {{this.bytes}} };
20
+ {{#if ../isEtag}}
21
+ const char * etagDefaultDocument = "{{this.md5}}";
22
+ {{/if}}
23
+ {{else}}
18
24
  const uint8_t data{{this.index}}[{{this.length}}] = { {{this.bytes}} };
19
25
  {{#if ../isEtag}}
20
26
  const char * etag{{this.index}} = "{{this.md5}}";
21
27
  {{/if}}
28
+ {{/if}}
22
29
  {{/each}}
23
30
 
24
31
  void {{methodName}}(PsychicHttpServer * server) {
25
32
  {{#each sources}}
26
-
27
- {{#if this.isDefault}}server->defaultEndpoint = {{/if}}server->on("/{{this.filename}}", HTTP_GET, [](PsychicRequest * request)
28
- {
29
- {{#if ../isEtag}}
30
- if (request->hasHeader("If-None-Match") && request->header("If-None-Match") == String(etag{{this.index}})) {
33
+ {{#if this.isDefault}}server->defaultEndpoint = {{/if}}server->on("/{{this.filename}}", HTTP_GET, [](PsychicRequest * request) {
34
+ {{#if ../isEtag}}
35
+ if (request->hasHeader("If-None-Match") && request->header("If-None-Match") == String({{#if this.isDefault}}etagDefaultDocument{{else}}etag{{this.index}}{{/if}})) {
31
36
  PsychicResponse response304(request);
32
37
  response304.setCode(304);
33
38
  return response304.send();
34
39
  }
35
- {{/if}}
40
+ {{/if}}
36
41
  PsychicResponse response(request);
37
42
  response.setContentType("{{this.mime}}");
38
- {{#if this.isGzip}}
43
+ {{#if this.isGzip}}
39
44
  response.addHeader("Content-Encoding", "gzip");
40
- {{/if}}
45
+ {{/if}}
41
46
  {{#if ../isEtag}}
42
- response.addHeader("ETag", etag{{this.index}});
43
- {{/if}}
44
- response.setContent(data{{this.index}}, sizeof(data{{this.index}}));
47
+ response.addHeader("ETag", {{#if this.isDefault}}etagDefaultDocument{{else}}etag{{this.index}}{{/if}});
48
+ {{/if}}
49
+ response.setContent({{#if this.isDefault}}dataDefaultDocument{{else}}data{{this.index}}{{/if}}, sizeof({{#if this.isDefault}}dataDefaultDocument{{else}}data{{this.index}}{{/if}}));
45
50
  return response.send();
46
51
  });
52
+
47
53
  {{/each}}
48
54
  }`;
49
55
  const asyncTemplate = `
@@ -57,36 +63,44 @@ const asyncTemplate = `
57
63
  #include <ESPAsyncWebServer.h>
58
64
 
59
65
  {{#each sources}}
66
+ {{#if this.isDefault}}
67
+ const uint8_t dataDefaultDocument[{{this.length}}] = { {{this.bytes}} };
68
+ {{#if ../isEtag}}
69
+ const char * etagDefaultDocument = "{{this.md5}}";
70
+ {{/if}}
71
+ {{else}}
60
72
  const uint8_t data{{this.index}}[{{this.length}}] PROGMEM = { {{this.bytes}} };
61
73
  {{#if ../isEtag}}
62
74
  const char * etag{{this.index}} = "{{this.md5}}";
63
75
  {{/if}}
76
+ {{/if}}
64
77
  {{/each}}
65
78
 
66
79
  void {{methodName}}(AsyncWebServer * server) {
67
80
  {{#each sources}}
68
-
69
- ArRequestHandlerFunction func{{this.index}} = [](AsyncWebServerRequest * request)
70
- {
71
- {{#if ../isEtag}}
72
- if (request->hasHeader("If-None-Match") && request->getHeader("If-None-Match")->value() == String(etag{{this.index}})) {
81
+ ArRequestHandlerFunction {{#if this.isDefault}}funcDefaultDocument{{else}}func{{this.index}}{{/if}} = [](AsyncWebServerRequest * request) {
82
+ {{#if ../isEtag}}
83
+ if (request->hasHeader("If-None-Match") && request->getHeader("If-None-Match")->value() == String({{#if this.isDefault}}etagDefaultDocument{{else}}etag{{this.index}}{{/if}})) {
73
84
  request->send(304);
74
85
  return;
75
86
  }
76
- {{/if}}
77
- AsyncWebServerResponse *response = request->beginResponse_P(200, "{{this.mime}}", data{{this.index}}, {{this.length}});
78
- {{#if this.isGzip}}
87
+ {{/if}}
88
+ AsyncWebServerResponse *response = request->beginResponse_P(200, "{{this.mime}}", {{#if this.isDefault}}dataDefaultDocument{{else}}data{{this.index}}{{/if}}, {{this.length}});
89
+ {{#if this.isGzip}}
79
90
  response->addHeader("Content-Encoding", "gzip");
80
- {{/if}}
81
- {{#if ../isEtag}}
82
- response->addHeader("ETag", etag{{this.index}});
83
- {{/if}}
91
+ {{/if}}
92
+ {{#if ../isEtag}}
93
+ response->addHeader("ETag", {{#if this.isDefault}}etagDefaultDocument{{else}}etag{{this.index}}{{/if}});
94
+ {{/if}}
84
95
  request->send(response);
85
96
  };
97
+ {{#if this.isDefault}}
98
+ server->on("/{{this.filename}}", HTTP_GET, funcDefaultDocument);
99
+ server->on("/", HTTP_GET, funcDefaultDocument);
100
+ {{else}}
86
101
  server->on("/{{this.filename}}", HTTP_GET, func{{this.index}});
87
- {{#if this.isDefault}}
88
- server->on("/", HTTP_GET, func{{this.index}});
89
- {{/if}}
102
+ {{/if}}
103
+
90
104
  {{/each}}
91
105
  }`;
92
106
  const getCppCode = (sources) => (0, handlebars_1.compile)(commandLine_1.cmdLine.engine === 'psychic' ? psychicTemplate : asyncTemplate)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteesp32",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
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",
@@ -53,20 +53,20 @@
53
53
  ],
54
54
  "devDependencies": {
55
55
  "@types/mime-types": "^2.1.4",
56
- "@types/node": "^20.14.5",
57
- "@typescript-eslint/eslint-plugin": "^7.13.1",
58
- "@typescript-eslint/parser": "^7.13.1",
56
+ "@types/node": "^20.14.12",
57
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
58
+ "@typescript-eslint/parser": "^7.17.0",
59
59
  "eslint": "^8.57.0",
60
60
  "eslint-config-prettier": "^9.1.0",
61
- "eslint-plugin-simple-import-sort": "^12.1.0",
62
- "eslint-plugin-unicorn": "^54.0.0",
63
- "nodemon": "^3.1.3",
64
- "prettier": "^3.3.2",
61
+ "eslint-plugin-simple-import-sort": "^12.1.1",
62
+ "eslint-plugin-unicorn": "^55.0.0",
63
+ "nodemon": "^3.1.4",
64
+ "prettier": "^3.3.3",
65
65
  "ts-node": "^10.9.2",
66
- "typescript": "^5.4.5"
66
+ "typescript": "^5.5.4"
67
67
  },
68
68
  "dependencies": {
69
- "glob": "^10.4.1",
69
+ "glob": "^11.0.0",
70
70
  "handlebars": "^4.7.8",
71
71
  "mime-types": "^2.1.35",
72
72
  "ts-command-line-args": "^2.5.1"