Skip to content

Commit

Permalink
Merge pull request #1658 from proddy/dev
Browse files Browse the repository at this point in the history
fix broken web - #1656
  • Loading branch information
proddy authored Mar 12, 2024
2 parents 27aa57d + be6bb1d commit e00c30c
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 117 deletions.
10 changes: 5 additions & 5 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@table-library/react-table-library": "4.1.7",
"@types/imagemin": "^8.0.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.11.25",
"@types/react": "^18.2.64",
"@types/node": "^20.11.26",
"@types/react": "^18.2.65",
"@types/react-dom": "^18.2.21",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.17.1",
Expand All @@ -54,8 +54,8 @@
"devDependencies": {
"@preact/compat": "^17.1.2",
"@preact/preset-vite": "^2.8.1",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -70,7 +70,7 @@
"prettier": "^3.2.5",
"rollup-plugin-visualizer": "^5.12.0",
"terser": "^5.29.1",
"vite": "^5.1.5",
"vite": "^5.1.6",
"vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^4.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion interface/progmem-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bytesPerLine = 20;
var totalSize = 0;

const generateWWWClass = () =>
`typedef std::function<void(const String& uri, const String& contentType, const uint8_t * content, size_t len, const String& hash)> RouteRegistrationHandler;
`typedef std::function<void(const char * uri, const String & contentType, const uint8_t * content, size_t len, const String & hash)> RouteRegistrationHandler;
// Total size is ${totalSize} bytes
class WWWData {
Expand Down
134 changes: 67 additions & 67 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1590,12 +1590,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^20.11.25":
version: 20.11.25
resolution: "@types/node@npm:20.11.25"
"@types/node@npm:^20.11.26":
version: 20.11.26
resolution: "@types/node@npm:20.11.26"
dependencies:
undici-types: "npm:~5.26.4"
checksum: 10/861265f1bbb151404bd8842b595f027a4ff067c61ecff9a37b9f7f53922c18dd532c8e795e8e7675dd8dba056645623fd2b9848d5ef72863ec3609096cd2923e
checksum: 10/37a69017fc0e70bd52e106a7a0de21f78b29a869b2ab7b0539438ee6ce91cb9b49b80d6b68108e88fcc20e24cdc4dc00f6e8e1c28215d93412cb19a303572130
languageName: node
linkType: hard

Expand Down Expand Up @@ -1670,14 +1670,14 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:^18.2.64":
version: 18.2.64
resolution: "@types/react@npm:18.2.64"
"@types/react@npm:^18.2.65":
version: 18.2.65
resolution: "@types/react@npm:18.2.65"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10/e82bd16660030c9aabdb5027bb9bf69570a90813e4a894c17bfb288978c2b80251def5754e455d72aa3485d99136e1b11b694f78c586e5918e10b3bb09b91b3c
checksum: 10/8022689f6c68e76b5e7b3c95af794fb3d128d5b2ccac408adaa80b117724c48b04dd4a2750e5c2ca29cd70ac7719b4ed5c5b1c12cb739d6f1d52188c09fb3060
languageName: node
linkType: hard

Expand Down Expand Up @@ -1713,15 +1713,15 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/eslint-plugin@npm:7.1.1"
"@typescript-eslint/eslint-plugin@npm:^7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.2.0"
dependencies:
"@eslint-community/regexpp": "npm:^4.5.1"
"@typescript-eslint/scope-manager": "npm:7.1.1"
"@typescript-eslint/type-utils": "npm:7.1.1"
"@typescript-eslint/utils": "npm:7.1.1"
"@typescript-eslint/visitor-keys": "npm:7.1.1"
"@typescript-eslint/scope-manager": "npm:7.2.0"
"@typescript-eslint/type-utils": "npm:7.2.0"
"@typescript-eslint/utils": "npm:7.2.0"
"@typescript-eslint/visitor-keys": "npm:7.2.0"
debug: "npm:^4.3.4"
graphemer: "npm:^1.4.0"
ignore: "npm:^5.2.4"
Expand All @@ -1734,68 +1734,68 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/5b357566a6dd7996ef2fdd13e5f747d55213f6217642c4a53618f432cf211be07ec62e23668132d997e1dcd1b1f56b36406989856ef7da373ea0f94b7c422f23
checksum: 10/c50366021d63dc0f31fbd4673679d41eeaf53e1d411330742ea6e36bc854d5d9d52531df9efe708078e5c798fb9a6fca45473a451c197f46ac04050d47c9a9d2
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:^7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/parser@npm:7.1.1"
"@typescript-eslint/parser@npm:^7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/parser@npm:7.2.0"
dependencies:
"@typescript-eslint/scope-manager": "npm:7.1.1"
"@typescript-eslint/types": "npm:7.1.1"
"@typescript-eslint/typescript-estree": "npm:7.1.1"
"@typescript-eslint/visitor-keys": "npm:7.1.1"
"@typescript-eslint/scope-manager": "npm:7.2.0"
"@typescript-eslint/types": "npm:7.2.0"
"@typescript-eslint/typescript-estree": "npm:7.2.0"
"@typescript-eslint/visitor-keys": "npm:7.2.0"
debug: "npm:^4.3.4"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/6df5fb8f34f887ddb086d2a02b74b422f6468daed3eded9a840b0c77b2d96ef818c8739f151bc1ba904be2973cbd82f48a07ef08101dcfec4cdfc71ef00c0a04
checksum: 10/2236acd9f794ccb34062309f3d6fa2a0e34ac6560262213807a11fb42592011cd13ff3290a2fdbdf441fb3d248cbe23383e6c7e6c744d1cacc916159d885204f
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/scope-manager@npm:7.1.1"
"@typescript-eslint/scope-manager@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/scope-manager@npm:7.2.0"
dependencies:
"@typescript-eslint/types": "npm:7.1.1"
"@typescript-eslint/visitor-keys": "npm:7.1.1"
checksum: 10/74a1de52eebf8f6c050bd071ba580f00dbd104bd0a9a2bfc7a794fcf5019be4b208ab63c318695bb4347669b55abd03016fa46a775d97c9e25f43cb46e5889e0
"@typescript-eslint/types": "npm:7.2.0"
"@typescript-eslint/visitor-keys": "npm:7.2.0"
checksum: 10/9b1d43c87b0fc269df1820ebcbdb08e1c5c8cc719a6af8298d87077ca78cf5ebbfa8caa6eb5141f4dfb4cbb3a641291c50c73a213faab90bc43d34abfc68a1fe
languageName: node
linkType: hard

"@typescript-eslint/type-utils@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/type-utils@npm:7.1.1"
"@typescript-eslint/type-utils@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/type-utils@npm:7.2.0"
dependencies:
"@typescript-eslint/typescript-estree": "npm:7.1.1"
"@typescript-eslint/utils": "npm:7.1.1"
"@typescript-eslint/typescript-estree": "npm:7.2.0"
"@typescript-eslint/utils": "npm:7.2.0"
debug: "npm:^4.3.4"
ts-api-utils: "npm:^1.0.1"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/779a4700d1277180759d4df03af56395cfc4ba039d8bfd9245cf1084448d17c9ab899ebfff719f77713c44736f7adce7a97bd9fffb79bb21a3742ae9bdfcb5ef
checksum: 10/1c4efcd068987ed5bbf6f3dda1fed313eec84fc0840af6e00593338cc2605c96ab760bf83f868271a6b5fcde8a44d00e21b70a8607474a4df9d43d29775bb235
languageName: node
linkType: hard

"@typescript-eslint/types@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/types@npm:7.1.1"
checksum: 10/e0fab31cb850a4923e0fca0663497b442a63fecfd1a293f70ecb4145b9f7cfbebb4d0ba29be76d70b95c153e51fc66e0400cd565d7552766783338878955680a
"@typescript-eslint/types@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/types@npm:7.2.0"
checksum: 10/d70cbd77f21caddbb1c3519bb523b5217a300d52682e9acfa9ff645d7250f7f07653f48930f531675216e848b5f83cb9b14cf63db76239cec1159550a989e16d
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/typescript-estree@npm:7.1.1"
"@typescript-eslint/typescript-estree@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/typescript-estree@npm:7.2.0"
dependencies:
"@typescript-eslint/types": "npm:7.1.1"
"@typescript-eslint/visitor-keys": "npm:7.1.1"
"@typescript-eslint/types": "npm:7.2.0"
"@typescript-eslint/visitor-keys": "npm:7.2.0"
debug: "npm:^4.3.4"
globby: "npm:^11.1.0"
is-glob: "npm:^4.0.3"
Expand All @@ -1805,34 +1805,34 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/6840f31ffe44072f0e20eb4acc091161eeac265fed44937d33064880269650ea63d68e8d79759f2dfaeff9a5803dcdf30e15a8b27e7db6cffbed42a02f9851e5
checksum: 10/77a81dc903da1ccb302c96bf7f845f297d87ab7871849bfabdddee51583646a1147923fc23c550c6c783229bc7bda37a3ea147478fa08b3847d0440a34587198
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/utils@npm:7.1.1"
"@typescript-eslint/utils@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/utils@npm:7.2.0"
dependencies:
"@eslint-community/eslint-utils": "npm:^4.4.0"
"@types/json-schema": "npm:^7.0.12"
"@types/semver": "npm:^7.5.0"
"@typescript-eslint/scope-manager": "npm:7.1.1"
"@typescript-eslint/types": "npm:7.1.1"
"@typescript-eslint/typescript-estree": "npm:7.1.1"
"@typescript-eslint/scope-manager": "npm:7.2.0"
"@typescript-eslint/types": "npm:7.2.0"
"@typescript-eslint/typescript-estree": "npm:7.2.0"
semver: "npm:^7.5.4"
peerDependencies:
eslint: ^8.56.0
checksum: 10/da8daae269ce15360ed91508f7c430b37d2e877321a91f437f611f9b643cc563c4aefe3d6b3983fadbb1bed389c82a4ceac95bbfeb015b62830fdb9ceea40e5a
checksum: 10/4852d43f1e0ca7e4914fef6cb5984a472d77af6fafcfad18905c0ba2ac5539a7ba8e72a4b3f7cbff712733f9cf8e8af790b4875f944aae1006ca297f8e041d32
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:7.1.1":
version: 7.1.1
resolution: "@typescript-eslint/visitor-keys@npm:7.1.1"
"@typescript-eslint/visitor-keys@npm:7.2.0":
version: 7.2.0
resolution: "@typescript-eslint/visitor-keys@npm:7.2.0"
dependencies:
"@typescript-eslint/types": "npm:7.1.1"
"@typescript-eslint/types": "npm:7.2.0"
eslint-visitor-keys: "npm:^3.4.1"
checksum: 10/d0c6c0811f38186053679b8447469e9a5c040db639d59e710ce5c5f5fddf9554287eb01a7cfa7a31e06f274bbe261c3b89a51a8c42869b1157b2d90c08f79507
checksum: 10/e0c9c7a9bb1ae93149e7a4816aed12651fd7374d0eb17e1f45348dbfddd8ee7014d3de35b40bc46b9df73cc1c9053aaf5d82b43270d93a0b551ed14e8afde37a
languageName: node
linkType: hard

Expand All @@ -1858,12 +1858,12 @@ __metadata:
"@table-library/react-table-library": "npm:4.1.7"
"@types/imagemin": "npm:^8.0.5"
"@types/lodash-es": "npm:^4.17.12"
"@types/node": "npm:^20.11.25"
"@types/react": "npm:^18.2.64"
"@types/node": "npm:^20.11.26"
"@types/react": "npm:^18.2.65"
"@types/react-dom": "npm:^18.2.21"
"@types/react-router-dom": "npm:^5.3.3"
"@typescript-eslint/eslint-plugin": "npm:^7.1.1"
"@typescript-eslint/parser": "npm:^7.1.1"
"@typescript-eslint/eslint-plugin": "npm:^7.2.0"
"@typescript-eslint/parser": "npm:^7.2.0"
alova: "npm:^2.17.1"
async-validator: "npm:^4.2.5"
concurrently: "npm:^8.2.2"
Expand Down Expand Up @@ -1893,7 +1893,7 @@ __metadata:
terser: "npm:^5.29.1"
typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.4.2"
vite: "npm:^5.1.5"
vite: "npm:^5.1.6"
vite-plugin-imagemin: "npm:^0.6.1"
vite-tsconfig-paths: "npm:^4.3.1"
languageName: unknown
Expand Down Expand Up @@ -9193,9 +9193,9 @@ __metadata:
languageName: node
linkType: hard

"vite@npm:^5.1.5":
version: 5.1.5
resolution: "vite@npm:5.1.5"
"vite@npm:^5.1.6":
version: 5.1.6
resolution: "vite@npm:5.1.6"
dependencies:
esbuild: "npm:^0.19.3"
fsevents: "npm:~2.3.3"
Expand Down Expand Up @@ -9229,7 +9229,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
checksum: 10/ada0a9138ca541723008ee261d80a97f6b70173508ded0f87834e2142660f45dff9801d143551aa3a8979ed446f0aec71ae114ab3ae978b3fbd5cf1f8c4bc331
checksum: 10/f48073e93ead62fa58034398442de4517c824b3e50184f8b4059fb24077a26f2c04e910e29d7fb7ec51ea53eb61b9c7d94d56b14a38851de80c67480094cc79d
languageName: node
linkType: hard

Expand Down
6 changes: 0 additions & 6 deletions lib/ESPAsyncWebServer/src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,6 @@ AsyncWebServerResponse * AsyncWebServerRequest::beginResponse_P(int code, const
return beginResponse_P(code, contentType, (const uint8_t *)content, strlen_P(content), callback);
}

// added by proddy
AsyncWebServerResponse *
AsyncWebServerRequest::beginResponse(const String & contentType, const uint8_t * content, size_t len) {
return new AsyncResponse(contentType, content, len);
}

void AsyncWebServerRequest::send(int code, const String & contentType, const String & content) {
send(beginResponse(code, contentType, content));
}
Expand Down
14 changes: 0 additions & 14 deletions lib/ESPAsyncWebServer/src/WebResponseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,6 @@ class AsyncProgmemResponse : public AsyncAbstractResponse {
virtual size_t _fillBuffer(uint8_t * buf, size_t maxLen) override;
};

// added by proddy
class AsyncResponse : public AsyncAbstractResponse {
private:
const uint8_t * _content;
size_t _readLength;

public:
AsyncResponse(const String & contentType, const uint8_t * content, size_t len);
bool _sourceValid() const {
return true;
}
virtual size_t _fillBuffer(uint8_t * buf, size_t maxLen) override;
};

class cbuf;

class AsyncResponseStream : public AsyncAbstractResponse, public Print {
Expand Down
14 changes: 0 additions & 14 deletions lib/ESPAsyncWebServer/src/WebResponses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,20 +746,6 @@ size_t AsyncProgmemResponse::_fillBuffer(uint8_t * data, size_t len) {
return left;
}

// added by proddy
AsyncResponse::AsyncResponse(const String & contentType, const uint8_t * content, size_t len)
: AsyncAbstractResponse(nullptr) {
_code = 200;
_content = content;
_contentType = contentType;
_contentLength = len;
_readLength = len;
}
size_t AsyncResponse::_fillBuffer(uint8_t * data, size_t len) {
memcpy(data, _content, len);
return len;
}

/*
* Response Stream (You can print/write/printf to it, up to the contentLen bytes)
* */
Expand Down
10 changes: 5 additions & 5 deletions lib/framework/ESP8266React.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs)
static char last_modified[50];
sprintf(last_modified, "%s %s CET", __DATE__, __TIME__);

WWWData::registerRoutes([server](const String & uri, const String & contentType, const uint8_t * content, size_t len, const String & hash) {
WWWData::registerRoutes([server](const char * uri, const String & contentType, const uint8_t * content, size_t len, const String & hash) {
ArRequestHandlerFunction requestHandler = [contentType, content, len, hash](AsyncWebServerRequest * request) {
// Check if the client already has the same version and respond with a 304 (Not modified)
if (request->header("If-Modified-Since").indexOf(last_modified) > 0) {
Expand All @@ -36,7 +36,7 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs)
return request->send(304);
}

AsyncWebServerResponse * response = request->beginResponse(contentType, content, len);
AsyncWebServerResponse * response = request->beginResponse_P(200, contentType, content, len);

response->addHeader("Content-Encoding", "gzip");
// response->addHeader("Content-Encoding", "br"); // only works over HTTPS
Expand All @@ -47,10 +47,10 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs)
request->send(response);
};

server->on(uri.c_str(), HTTP_GET, requestHandler);
server->on(uri, HTTP_GET, requestHandler);
// Serving non matching get requests with "/index.html"
// OPTIONS get a straight up 200 response
if (uri.equals("/index.html")) {
if (strncmp(uri, "/index.html", 11) == 0) {
server->onNotFound([requestHandler](AsyncWebServerRequest * request) {
if (request->method() == HTTP_GET) {
requestHandler(request);
Expand Down Expand Up @@ -87,4 +87,4 @@ void ESP8266React::loop() {
_apSettingsService.loop();
_otaSettingsService.loop();
_mqttSettingsService.loop();
}
}
5 changes: 0 additions & 5 deletions lib/framework/NetworkSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,6 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
case ARDUINO_EVENT_ETH_GOT_IP6:
if (emsesp::EMSESP::system_.ethernet_connected()) {
emsesp::EMSESP::logger().info("Ethernet connected (IPv6=%s, speed %d Mbps)", ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
} else {
emsesp::EMSESP::logger().info("WiFi connected (IPv6=%s, hostname=%s, TxPower=%s dBm)",
WiFi.localIPv6().toString().c_str(),
WiFi.getHostname(),
emsesp::Helpers::render_value(result, ((double)(WiFi.getTxPower()) / 4), 1));
}
mDNS_start();
emsesp::EMSESP::system_.has_ipv6(true);
Expand Down

0 comments on commit e00c30c

Please sign in to comment.