From 337bfac5e328621085001232a5495d49b79a2000 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sat, 15 May 2021 15:34:00 +0200 Subject: [PATCH 01/19] update repl example --- examples/repl.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/repl.js b/examples/repl.js index 47027d1..7dc29cf 100644 --- a/examples/repl.js +++ b/examples/repl.js @@ -1,21 +1,22 @@ /** - * + * * A network based REPL (Read–eval–print loop). - * + * * Usage: * netcat [IP-ADDRESS] 1234 - * + * * After successful connection a prompt appears: '>' * Then type [USER]:[PASS] (the defaults are esp32:esp32) * After successful authentication you will see "====> authorized." - * - * After that you can type every JS expression, which then gets - * evaluated in esp32-javascript and the result is printed. - * + * + * After that you can type every JS expression, which then gets + * evaluated in esp32-javascript and the result is printed. + * */ var configManager = require("esp32-javascript/config"); var PROMPT = "> "; +var textDecoder = new TextDecoder(); function writeOutput(socket, result) { socket.write(result); @@ -27,7 +28,8 @@ require("socket-events").sockListen( function (socket) { var authorized = false; var _ = undefined; - socket.onData = function (data) { + socket.onData = function (buffer) { + var data = textDecoder.decode(buffer); var result = null; if (!authorized) { var accessConfig = configManager.config.access; From 1a969feba8c156951d6bd1da17ac013d5be32c47 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sat, 22 May 2021 20:13:01 +0200 Subject: [PATCH 02/19] feat: first draft of native ota implementation --- CMakeLists.txt | 2 +- babel.config.json | 9 +- .../esp32-javascript/esp32-javascript.c | 260 +- .../modules/esp32-javascript/boot.js | 2 +- .../modules/esp32-javascript/boot.ts | 2 +- .../modules/esp32-javascript/chunked.js | 262 ++ .../modules/esp32-javascript/chunked.ts | 261 ++ .../modules/esp32-javascript/configserver.js | 48 +- .../modules/esp32-javascript/configserver.ts | 49 +- .../esp32-javascript/esp32-javascript.d.ts | 21 +- .../modules/esp32-javascript/http.js | 303 +- .../modules/esp32-javascript/http.ts | 237 +- .../modules/esp32-javascript/index.js | 23 + .../modules/esp32-javascript/index.ts | 28 + .../modules/esp32-javascript/native-ota.js | 117 + .../modules/esp32-javascript/native-ota.ts | 164 + .../modules/socket-events/index.js | 5 +- .../modules/socket-events/index.ts | 15 +- components/socket-events/socket-events.c | 71 +- components/socket-events/tcp.c | 24 +- components/spiffs-events/spiffs-events.c | 86 +- components/wifi-events/wifi-events.c | 14 +- examples/repl.js | 3 + package-lock.json | 2749 ++++++++--------- package.json | 16 +- partitions.csv => partitions2MB.csv | 0 partitions4MB.csv | 10 + sdkconfig.defaults | 8 +- 28 files changed, 3033 insertions(+), 1756 deletions(-) create mode 100644 components/esp32-javascript/modules/esp32-javascript/chunked.js create mode 100644 components/esp32-javascript/modules/esp32-javascript/chunked.ts create mode 100644 components/esp32-javascript/modules/esp32-javascript/native-ota.js create mode 100644 components/esp32-javascript/modules/esp32-javascript/native-ota.ts rename partitions.csv => partitions2MB.csv (100%) create mode 100644 partitions4MB.csv diff --git a/CMakeLists.txt b/CMakeLists.txt index afb6732..9a7ee6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(ENV{BOARD_VARIANT} "../esp32-javascript/include/variants/my") # set ESP32_JS_PROJECT_NAME to define your project component name. # Place your component below ./components directory. Set to "" # if you don't have a project component yet. -set(ENV{ESP32_JS_PROJECT_NAME} "") +set(ENV{ESP32_JS_PROJECT_NAME} "esp32-home") ################################################# include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/babel.config.json b/babel.config.json index f80b2ca..1efeeae 100644 --- a/babel.config.json +++ b/babel.config.json @@ -1,4 +1,11 @@ { - "presets": ["minify"], + "presets": [ + [ + "minify", + { + "builtIns": false + } + ] + ], "comments": false } diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index dceeab5..680e454 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -50,6 +50,8 @@ SOFTWARE. #include "esp32-js-log.h" #include "libb64/cdecode.h" #include "libb64/cencode.h" +#include "esp_ota_ops.h" +#include "esp_partition.h" static const char *tag = "esp32-javascript"; @@ -64,6 +66,23 @@ duk_context *ctx = NULL; // only for debug purposes bool DISABLE_EVENTS = false; +void fileLog(duk_context *ctx, log_level_t level, char *message) +{ + if (level >= INFO) + { + // append to logfile + duk_eval_string(ctx, "typeof el_appendLogBuffer"); + if (strcmp(duk_get_string(ctx, -1), "function") == 0) + { + duk_push_string(ctx, "el_appendLogBuffer"); + duk_eval(ctx); + duk_push_string(ctx, message); + duk_push_uint(ctx, level); + duk_call(ctx, 2); + } + } +} + void jslog(log_level_t level, const char *msg, ...) { char *my_string; @@ -121,22 +140,30 @@ void jslog(log_level_t level, const char *msg, ...) static duk_ret_t console_debug_binding(duk_context *ctx) { - ESP_LOGD(tag, "%s", duk_to_string(ctx, 0)); + char *message = duk_to_string(ctx, 0); + ESP_LOGD(tag, "%s", message); + fileLog(ctx, DEBUG, message); return 0; } static duk_ret_t console_info_binding(duk_context *ctx) { - ESP_LOGI(tag, "%s", duk_to_string(ctx, 0)); + char *message = duk_to_string(ctx, 0); + ESP_LOGI(tag, "%s", message); + fileLog(ctx, INFO, message); return 0; } static duk_ret_t console_warn_binding(duk_context *ctx) { - ESP_LOGW(tag, "%s", duk_to_string(ctx, 0)); + char *message = duk_to_string(ctx, 0); + ESP_LOGW(tag, "%s", message); + fileLog(ctx, WARN, message); return 0; } static duk_ret_t console_error_binding(duk_context *ctx) { - ESP_LOGE(tag, "%s", duk_to_string(ctx, 0)); + char *message = duk_to_string(ctx, 0); + ESP_LOGE(tag, "%s", message); + fileLog(ctx, ERROR, message); return 0; } @@ -144,7 +171,7 @@ void IRAM_ATTR el_add_event(js_eventlist_t *events, js_event_t *event) { if (events->events_len >= MAX_EVENTS) { - jslog(ERROR, "Event queue full. Max event number: %d => aborting.\n", MAX_EVENTS); + jslog(ERROR, "Event queue full. Max event number: %d => aborting.", MAX_EVENTS); abort(); } events->events[events->events_len] = *event; @@ -155,17 +182,17 @@ void IRAM_ATTR el_fire_events(js_eventlist_t *events) { if (DISABLE_EVENTS) { - jslog(WARN, "Events are disabled. They will never be fired.\n"); + jslog(WARN, "Events are disabled. They will never be fired."); } else { if (events->events_len > 0) { - jslog(DEBUG, "Send %d events to queue...\n", events->events_len); + jslog(DEBUG, "Send %d events to queue...", events->events_len); int ret = xQueueSendFromISR(el_event_queue, events, NULL); if (ret != pdTRUE) { - jslog(ERROR, "Event queue is full... is something blocking the event loop?...aborting.\n"); + jslog(ERROR, "Event queue is full... is something blocking the event loop?...aborting."); abort(); } } @@ -229,7 +256,7 @@ static duk_ret_t el_load(duk_context *ctx) } else if (err != ESP_OK) { - jslog(ERROR, "Error (%d) opening NVS!\n", err); + jslog(ERROR, "Error (%d) opening NVS!", err); return -1; } @@ -242,7 +269,7 @@ static duk_ret_t el_load(duk_context *ctx) } else if (err != ESP_OK) { - jslog(ERROR, "Cannot get key %s from storage, err=%d\n", key, err); + jslog(ERROR, "Cannot get key %s from storage, err=%d", key, err); ret = -1; } else @@ -251,7 +278,7 @@ static duk_ret_t el_load(duk_context *ctx) err = nvs_get_blob(my_handle, key, value, &string_size); if (err != ESP_OK) { - jslog(ERROR, "Cannot get key %s from storage, err=%d\n", key, err); + jslog(ERROR, "Cannot get key %s from storage, err=%d", key, err); ret = -1; } else @@ -273,7 +300,7 @@ static duk_ret_t el_store(duk_context *ctx) const char *key = duk_to_string(ctx, 0); if (strlen(key) > 15) { - jslog(ERROR, "Keys may not be longer than 15 chars. Key '%s' is longer.\n", key); + jslog(ERROR, "Keys may not be longer than 15 chars. Key '%s' is longer.", key); return -1; } @@ -281,7 +308,7 @@ static duk_ret_t el_store(duk_context *ctx) int len = strlen(value); if (len > (1984 - 1)) { - jslog(ERROR, "Values may not be longer than 1984 chars (including zero-termination). Current string length is %d\n", len); + jslog(ERROR, "Values may not be longer than 1984 chars (including zero-termination). Current string length is %d", len); return -1; } @@ -290,21 +317,21 @@ static duk_ret_t el_store(duk_context *ctx) err = nvs_open("esp32js2", NVS_READWRITE, &my_handle); if (err != ESP_OK) { - jslog(ERROR, "Error (%d) opening NVS!\n", err); + jslog(ERROR, "Error (%d) opening NVS!", err); return -1; } err = nvs_set_blob(my_handle, key, (void *)value, len + 1); if (err != ESP_OK) { - jslog(ERROR, "Cannot set key %s and value %s from storage, err=%d\n", key, value, err); + jslog(ERROR, "Cannot set key %s and value %s from storage, err=%d", key, value, err); ret = -1; } err = nvs_commit(my_handle); if (err != ESP_OK) { - jslog(ERROR, "Cannot commit changes, err=%d\n", err); + jslog(ERROR, "Cannot commit changes, err=%d", err); ret = -1; } nvs_close(my_handle); @@ -314,7 +341,7 @@ static duk_ret_t el_store(duk_context *ctx) static duk_ret_t native_delay(duk_context *ctx) { int delay = duk_to_int32(ctx, 0); - jslog(DEBUG, "Waiting %dms...\n", delay); + jslog(DEBUG, "Waiting %dms...", delay); if (delay < 0) { delay = 0; @@ -330,7 +357,7 @@ static duk_ret_t el_createTimer(duk_context *ctx) { delay = 0; } - jslog(DEBUG, "Install timer to notify in %dms.\n", delay); + jslog(DEBUG, "Install timer to notify in %dms.", delay); int handle = createTimer(delay); duk_push_int(ctx, handle); return 1; @@ -368,16 +395,16 @@ static duk_ret_t el_suspend(duk_context *ctx) duk_gc(ctx, 0); duk_gc(ctx, 0); // feed watchdog - //vTaskDelay(1); + vTaskDelay(1); // jslog(INFO, "Free memory: %d bytes", esp_get_free_heap_size()); js_eventlist_t events; - jslog(DEBUG, "Waiting for events...\n"); + jslog(DEBUG, "Waiting for events..."); xQueueReceive(el_event_queue, &events, portMAX_DELAY); - jslog(DEBUG, "Receiving %d events.\n", events.events_len); + jslog(DEBUG, "Receiving %d events.", events.events_len); int arr_idx = duk_push_array(ctx); for (int i = 0; i < events.events_len; i++) @@ -402,7 +429,7 @@ static duk_ret_t el_pinMode(duk_context *ctx) int pin = duk_to_int(ctx, 0); int dir = duk_to_int(ctx, 1); - jslog(DEBUG, "el_pinMode pin=%d dir=%d\n", pin, dir); + jslog(DEBUG, "el_pinMode pin=%d dir=%d", pin, dir); pinMode(pin, dir); return 0; @@ -413,7 +440,7 @@ static duk_ret_t el_digitalWrite(duk_context *ctx) int pin = duk_to_int(ctx, 0); int level = duk_to_int(ctx, 1); - jslog(DEBUG, "el_digitalWrite pin=%d level=%d\n", pin, level); + jslog(DEBUG, "el_digitalWrite pin=%d level=%d", pin, level); digitalWrite(pin, level); return 0; @@ -423,7 +450,7 @@ static duk_ret_t el_digitalRead(duk_context *ctx) { int pin = duk_to_int(ctx, 0); - jslog(DEBUG, "el_digitalRead pin=%d\n", pin); + jslog(DEBUG, "el_digitalRead pin=%d", pin); int val = digitalRead(pin); duk_push_int(ctx, val); @@ -436,7 +463,7 @@ static duk_ret_t el_ledcSetup(duk_context *ctx) int freq = duk_to_int(ctx, 1); int resolution = duk_to_int(ctx, 2); - jslog(DEBUG, "el_ledcSetup channel=%d freq=%d resolution=%d \n", channel, freq, resolution); + jslog(DEBUG, "el_ledcSetup channel=%d freq=%d resolution=%d ", channel, freq, resolution); ledcSetup(channel, freq, resolution); return 0; @@ -447,7 +474,7 @@ static duk_ret_t el_ledcAttachPin(duk_context *ctx) int pin = duk_to_int(ctx, 0); int channel = duk_to_int(ctx, 1); - jslog(DEBUG, "el_ledcAttachPin pin=%d channel=%d\n", pin, channel); + jslog(DEBUG, "el_ledcAttachPin pin=%d channel=%d", pin, channel); ledcAttachPin(pin, channel); return 0; @@ -458,7 +485,7 @@ static duk_ret_t el_ledcWrite(duk_context *ctx) int channel = duk_to_int(ctx, 0); int dutyCycle = duk_to_int(ctx, 1); - jslog(DEBUG, "el_ledcWrite channel=%d dutyCycle=%d \n", channel, dutyCycle); + jslog(DEBUG, "el_ledcWrite channel=%d dutyCycle=%d ", channel, dutyCycle); ledcWrite(channel, dutyCycle); return 0; @@ -486,7 +513,7 @@ static void my_fatal(void *udata, const char *msg) (void)udata; /* ignored in this case, silence warning */ /* Note that 'msg' may be NULL. */ - jslog(ERROR, "*** FATAL ERROR: %s\n", (msg ? msg : "no message")); + jslog(ERROR, "*** FATAL ERROR: %s", (msg ? msg : "no message")); abort(); } @@ -510,7 +537,7 @@ static duk_ret_t setDateTimeZoneOffsetInHours(duk_context *ctx) void loadJS(duk_context *ctx, const char *name, char *start, char *end) { const unsigned int length = end - start - 1; - jslog(INFO, "Loading %s ...\n", name); + jslog(INFO, "Loading %s ...", name); duk_eval_lstring_noresult(ctx, start, length); } @@ -538,7 +565,7 @@ duk_ret_t btoa(duk_context *ctx) free(buffer); return 1; } - jslog(ERROR, "malloc returned NULL\n"); + jslog(ERROR, "malloc returned NULL"); return -1; } @@ -557,7 +584,7 @@ duk_ret_t atob(duk_context *ctx) duk_push_lstring(ctx, buffer, size); return 1; } - jslog(ERROR, "malloc returned NULL\n"); + jslog(ERROR, "malloc returned NULL"); return -1; } @@ -620,6 +647,147 @@ bool spiramAvail() return false; } +duk_ret_t el_ota_begin(duk_context *ctx) +{ + esp_partition_t *partition = esp_ota_get_next_update_partition(NULL); + esp_ota_handle_t handle; + esp_err_t err = esp_ota_begin(partition, OTA_SIZE_UNKNOWN, &handle); + if (err == ESP_OK) + { + duk_push_uint(ctx, handle); + return 1; + } + else + { + jslog(ERROR, "esp_ota_begin returned error %i", err); + return -1; + } +} + +duk_ret_t el_ota_write(duk_context *ctx) +{ + duk_size_t size; + esp_ota_handle_t handle = duk_to_uint32(ctx, 0); + void *data = duk_get_buffer_data(ctx, 1, &size); + + esp_err_t err = esp_ota_write(handle, data, size); + if (err == ESP_OK) + { + return 0; + } + else + { + jslog(ERROR, "Error while ota write: %i", err); + return -1; + } +} + +duk_ret_t el_ota_end(duk_context *ctx) +{ + esp_ota_handle_t handle = duk_to_uint32(ctx, 0); + + esp_err_t err = esp_ota_end(handle); + if (err == ESP_OK) + { + return 0; + } + else + { + jslog(ERROR, "Error while ota end: %i", err); + return -1; + } +} + +duk_ret_t el_ota_switch_boot_partition(duk_context *ctx) +{ + esp_partition_t *partition = esp_ota_get_next_update_partition(NULL); + esp_err_t err = esp_ota_set_boot_partition(partition); + + if (err == ESP_OK) + { + return 0; + } + else + { + jslog(ERROR, "Error while ota switching boot: %i", err); + return -1; + } +} + +duk_ret_t el_ota_find_next_modules_partition(duk_context *ctx) +{ + esp_partition_t *partition = esp_ota_get_next_update_partition(NULL); + const char *modulesLabel = strcmp(partition->label, "ota_1") == 0 ? "modules_1" : "modules"; + esp_partition_t *modulesPartition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, modulesLabel); + if (modulesPartition != NULL) + { + duk_push_pointer(ctx, modulesPartition); + return 1; + } + else + { + jslog(ERROR, "Next modules partition not found."); + return -1; + } +} + +duk_ret_t el_find_partition(duk_context *ctx) +{ + char *label = duk_to_string(ctx, 0); + esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, label); + if (partition != NULL) + { + duk_idx_t obj_idx = duk_push_object(ctx); + + duk_push_pointer(ctx, partition); + duk_put_prop_string(ctx, obj_idx, "_ref"); + duk_push_uint(ctx, partition->size); + duk_put_prop_string(ctx, obj_idx, "size"); + + return 1; + } + else + { + jslog(ERROR, "Partition with label %s not found.", label); + return -1; + } +} + +duk_ret_t el_partition_erase(duk_context *ctx) +{ + esp_partition_t *partition = duk_to_pointer(ctx, 0); + esp_err_t err = esp_partition_erase_range(partition, 0, partition->size); + if (err == ESP_OK) + { + return 0; + } + else + { + jslog(ERROR, "Error while erasing next modules partition: %i", err); + return -1; + } +} + +duk_ret_t el_partition_write(duk_context *ctx) +{ + esp_partition_t *partition = duk_to_pointer(ctx, 0); + size_t offset = duk_to_uint(ctx, 1); + + size_t size; + void *data = duk_get_buffer_data(ctx, 2, &size); + + esp_err_t err = esp_partition_write(partition, offset, data, size); + if (err == ESP_OK) + { + return 0; + } + else + { + jslog(ERROR, "Error while erasing next modules partition: %i", err); + return -1; + } +} + void duktape_task(void *ignore) { spiramAvailable = spiramAvail(); @@ -709,19 +877,43 @@ void duktape_task(void *ignore) duk_push_c_function(ctx, atob, 1 /*nargs*/); duk_put_global_string(ctx, "atob"); + duk_push_c_function(ctx, el_ota_begin, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_begin"); + + duk_push_c_function(ctx, el_ota_write, 2 /*nargs*/); + duk_put_global_string(ctx, "el_ota_write"); + + duk_push_c_function(ctx, el_ota_end, 1 /*nargs*/); + duk_put_global_string(ctx, "el_ota_end"); + + duk_push_c_function(ctx, el_ota_switch_boot_partition, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_switch_boot_partition"); + + duk_push_c_function(ctx, el_ota_find_next_modules_partition, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_find_next_modules_partition"); + + duk_push_c_function(ctx, el_partition_erase, 1 /*nargs*/); + duk_put_global_string(ctx, "el_partition_erase"); + + duk_push_c_function(ctx, el_partition_write, 3 /*nargs*/); + duk_put_global_string(ctx, "el_partition_write"); + + duk_push_c_function(ctx, el_find_partition, 1 /*nargs*/); + duk_put_global_string(ctx, "el_find_partition"); + + loadUrlPolyfill(ctx); + #define ESP32_JAVASCRIPT_EXTERN ESP32_JAVASCRIPT_EXTERN_REGISTER #include "esp32-javascript-config.h" #undef ESP32_JAVASCRIPT_EXTERN - loadUrlPolyfill(ctx); - duk_eval_string_noresult(ctx, "require('esp32-javascript')"); #define ESP32_JAVASCRIPT_EXTERN ESP32_JAVASCRIPT_EXTERN_LOAD #include "esp32-javascript-config.h" #undef ESP32_JAVASCRIPT_EXTERN - jslog(INFO, "Reaching end of event loop.\n"); + jslog(INFO, "Reaching end of event loop."); //Return from task is not allowed vTaskDelete(NULL); diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.js b/components/esp32-javascript/modules/esp32-javascript/boot.js index b6fbaec..8233723 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.js +++ b/components/esp32-javascript/modules/esp32-javascript/boot.js @@ -164,7 +164,7 @@ function connectToWifi() { if (dateString) { var now = parseDate(dateString); setDateTimeInMillis(now.getTime()); - setDateTimeZoneOffsetInHours(1); + setDateTimeZoneOffsetInHours(2); setBootTime(new Date()); console.debug("Setting boot time to " + getBootTime()); } diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.ts b/components/esp32-javascript/modules/esp32-javascript/boot.ts index e725974..7e16559 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.ts +++ b/components/esp32-javascript/modules/esp32-javascript/boot.ts @@ -175,7 +175,7 @@ function connectToWifi() { if (dateString) { const now = parseDate(dateString); setDateTimeInMillis(now.getTime()); - setDateTimeZoneOffsetInHours(1); + setDateTimeZoneOffsetInHours(2); setBootTime(new Date()); console.debug(`Setting boot time to ${getBootTime()}`); } diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.js b/components/esp32-javascript/modules/esp32-javascript/chunked.js new file mode 100644 index 0000000..0ada59c --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.js @@ -0,0 +1,262 @@ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createChunkedEncodingConsumer = void 0; +var READ_CR = 0; +var READ_LF = 1; +var READ_LEN = 2; +var READ_PAYL = 3; +var FINISHED = 4; +function assertTransferChunked(test, message) { + if (!test) { + throw Error("Invalid chunked transfer encoding. Failed test " + message); + } +} +function createChunkedEncodingConsumer(onData) { + var state = READ_LEN; + var tempLen = 0; + var chunkLen = -1; + var finishing = false; + return function (data) { + var p = 0; + while (p < data.length && state !== FINISHED) { + /*console.log("s=" + state); + console.log("p=" + p); + console.log("cl=" + chunkLen); + console.log("dl=" + data.length); + */ + var d = data[p]; + switch (state) { + case READ_CR: + assertTransferChunked(d === 13, "d === 13"); + state = READ_LF; + p++; + break; + case READ_LF: + assertTransferChunked(d === 10, "d === 10"); + if (finishing) { + state = FINISHED; + } + else if (chunkLen == 0) { + finishing = true; + state = READ_CR; + } + else if (chunkLen > 0) { + state = READ_PAYL; + } + else { + state = READ_LEN; + } + p++; + break; + case READ_LEN: + if (d == 13) { + state = READ_CR; + chunkLen = tempLen; + tempLen = 0; + break; + } + else if (d >= 97 && d <= 102) { + // a-f + tempLen = tempLen * 16 + (d - 97) + 10; + } + else if (d >= 65 && d <= 70) { + // A-F + tempLen = tempLen * 16 + (d - 65) + 10; + } + else if (d >= 48 && d <= 57) { + // 0-9 + tempLen = tempLen * 16 + (d - 48); + } + else { + assertTransferChunked(false, "Invalid length char: " + d); + } + //console.log("templen=" + tempLen + "d=" + d); + p++; + break; + case READ_PAYL: + assertTransferChunked(chunkLen > 0, "chunkLen > 0"); + if (chunkLen >= data.length - p) { + if (onData) { + onData(data.subarray(p, data.length)); + } + chunkLen -= data.length - p; + p = data.length; + } + else { + if (onData) { + onData(data.subarray(p, p + chunkLen)); + } + p += chunkLen; + chunkLen = -1; + state = READ_CR; + } + break; + case FINISHED: + return true; + } + } + return state === FINISHED; + }; +} +exports.createChunkedEncodingConsumer = createChunkedEncodingConsumer; +/* + +function selftest() { + let consumer = createChunkedEncodingConsumer(); + console.log( + consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => { + throw Error("Should not be called."); + }) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "0".charCodeAt(0), + "1".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + "a".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log( + data.length === 26 && + data[0] === "x".charCodeAt(0) && + data[1] === "y".charCodeAt(0) + ) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + "a".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + ]), + (data: Uint8Array) => + console.log(data.length === 25 && data[0] === "x".charCodeAt(0)) + ) === READ_PAYL + ); + console.log("test"); + console.log( + consumer( + new Uint8Array([ + "y".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "y".charCodeAt(0)) + ) === FINISHED + ); +} +selftest(); +*/ diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.ts b/components/esp32-javascript/modules/esp32-javascript/chunked.ts new file mode 100644 index 0000000..ce44a41 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.ts @@ -0,0 +1,261 @@ +const READ_CR = 0; +const READ_LF = 1; +const READ_LEN = 2; +const READ_PAYL = 3; +const FINISHED = 4; + +function assertTransferChunked(test: boolean, message: string) { + if (!test) { + throw Error("Invalid chunked transfer encoding. Failed test " + message); + } +} + +export type ChunkedEncodingConsumer = (data: Uint8Array) => boolean; + +export function createChunkedEncodingConsumer( + onData?: (data: Uint8Array) => void +): ChunkedEncodingConsumer { + let state = READ_LEN; + let tempLen = 0; + let chunkLen = -1; + let finishing = false; + + return (data: Uint8Array) => { + let p = 0; + + while (p < data.length && state !== FINISHED) { + /*console.log("s=" + state); + console.log("p=" + p); + console.log("cl=" + chunkLen); + console.log("dl=" + data.length); +*/ + const d = data[p]; + + switch (state) { + case READ_CR: + assertTransferChunked(d === 13, "d === 13"); + state = READ_LF; + p++; + break; + case READ_LF: + assertTransferChunked(d === 10, "d === 10"); + if (finishing) { + state = FINISHED; + } else if (chunkLen == 0) { + finishing = true; + state = READ_CR; + } else if (chunkLen > 0) { + state = READ_PAYL; + } else { + state = READ_LEN; + } + p++; + break; + case READ_LEN: + if (d == 13) { + state = READ_CR; + chunkLen = tempLen; + tempLen = 0; + break; + } else if (d >= 97 && d <= 102) { + // a-f + tempLen = tempLen * 16 + (d - 97) + 10; + } else if (d >= 65 && d <= 70) { + // A-F + tempLen = tempLen * 16 + (d - 65) + 10; + } else if (d >= 48 && d <= 57) { + // 0-9 + tempLen = tempLen * 16 + (d - 48); + } else { + assertTransferChunked(false, "Invalid length char: " + d); + } + //console.log("templen=" + tempLen + "d=" + d); + p++; + break; + case READ_PAYL: + assertTransferChunked(chunkLen > 0, "chunkLen > 0"); + if (chunkLen >= data.length - p) { + if (onData) { + onData(data.subarray(p, data.length)); + } + chunkLen -= data.length - p; + p = data.length; + } else { + if (onData) { + onData(data.subarray(p, p + chunkLen)); + } + p += chunkLen; + chunkLen = -1; + state = READ_CR; + } + break; + case FINISHED: + return true; + } + } + return state === FINISHED; + }; +} + +/* + +function selftest() { + let consumer = createChunkedEncodingConsumer(); + console.log( + consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => { + throw Error("Should not be called."); + }) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "0".charCodeAt(0), + "1".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + "a".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log( + data.length === 26 && + data[0] === "x".charCodeAt(0) && + data[1] === "y".charCodeAt(0) + ) + ) === FINISHED + ); + + consumer = createChunkedEncodingConsumer(); + console.log( + consumer( + new Uint8Array([ + "1".charCodeAt(0), + "a".charCodeAt(0), + 10, + 13, + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + "y".charCodeAt(0), + "x".charCodeAt(0), + ]), + (data: Uint8Array) => + console.log(data.length === 25 && data[0] === "x".charCodeAt(0)) + ) === READ_PAYL + ); + console.log("test"); + console.log( + consumer( + new Uint8Array([ + "y".charCodeAt(0), + 10, + 13, + "0".charCodeAt(0), + 10, + 13, + 10, + 13, + ]), + (data: Uint8Array) => + console.log(data.length === 1 && data[0] === "y".charCodeAt(0)) + ) === FINISHED + ); +} +selftest(); +*/ diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index 8fad4b3..9112c0a 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -110,6 +110,8 @@ function page(res, headline, text, cb) { } res.end("\r\n\r\n"); } +var successMessage = ""; +var errorMessage = ""; function startConfigServer() { console.info("Starting config server."); var authString = "Basic " + @@ -131,8 +133,6 @@ function startConfigServer() { }); } else if (req.path === "/setup" || req.path === "/restart") { - var saved = false; - var error = undefined; if (req.path === "/setup" && req.method === "POST") { try { var storedConfig = configManager.config; @@ -149,19 +149,28 @@ function startConfigServer() { storedConfig.ota.offline = config_1.offline === "true"; storedConfig.ota.script = config_1.script; configManager.saveConfig(storedConfig); - saved = true; + successMessage = "Saved. Some settings require a restart."; } catch (err) { - error = err; + errorMessage = err; } } var config = configManager.config; - page(res, "Setup", "" + (saved - ? '
Saved. Some settings require a restart.
' - : "") + (error - ? "
Saving failed. Error message: " + error + "
" - : "") + "
\n
\n
\n
\n
\n
\n
\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / + var logFileSize = void 0; + try { + logFileSize = fileSize("/data/logs.txt"); + } + catch (_) { + // ignore + } + page(res, "Setup", "" + (successMessage + ? "
" + successMessage + "
" + : "") + (errorMessage + ? "
Saving failed. Error message: " + errorMessage + "
" + : "") + "
\n
\n
\n
\n
\n
\n
\n

Logs

\n
\n Log size: " + (logFileSize ? Math.floor(logFileSize / 1024) : "?") + " kB\n
\n
\n
\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / 100 + "
\n
\n
\n Boot time is only available if a valid 'JS file url' is configured, otherwise it starts at unix epoch (1970).\n
"); + successMessage = ""; + errorMessage = ""; } else { var handled = false; @@ -172,12 +181,12 @@ function startConfigServer() { handled = Boolean(handled || reqHandled); } catch (error) { - var errorMessage = "Internal server error: " + error; - console.error(errorMessage); + var errorMessage_1 = "Internal server error: " + error; + console.error(errorMessage_1); if (!res.isEnded) { res.setStatus(500); res.headers.set("Content-type", "text/plain"); - res.end(errorMessage); + res.end(errorMessage_1); } } } @@ -235,5 +244,20 @@ function startConfigServer() { } } }); + exports.requestHandler.push(function (req, res) { + if (/\/logs(|\?.*)/.exec(req.path)) { + res.setStatus(200); + res.headers.set("Content-type", "text/plain"); + global.el_flushLogBuffer(); + res.end(readFile("/data/logs.txt")); + } + }); + exports.requestHandler.push(function (req, res) { + if (/\/deletelogs(|\?.*)/.exec(req.path)) { + removeFile("/data/logs.txt"); + successMessage = "Logs were deleted successfully."; + redirect(res, "/setup"); + } + }); } exports.startConfigServer = startConfigServer; diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index 12fa8b1..0d06a9a 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -152,6 +152,8 @@ function page( res.end("
\r\n\r\n"); } +let successMessage = ""; +let errorMessage = ""; export function startConfigServer(): void { console.info("Starting config server."); const authString = @@ -180,9 +182,6 @@ export function startConfigServer(): void { } ); } else if (req.path === "/setup" || req.path === "/restart") { - let saved = false; - let error = undefined; - if (req.path === "/setup" && req.method === "POST") { try { const storedConfig = configManager.config; @@ -201,22 +200,29 @@ export function startConfigServer(): void { storedConfig.ota.script = config.script; configManager.saveConfig(storedConfig); - saved = true; + successMessage = "Saved. Some settings require a restart."; } catch (err) { - error = err; + errorMessage = err; } } const config = configManager.config; + + let logFileSize: number | undefined; + try { + logFileSize = fileSize("/data/logs.txt"); + } catch (_) { + // ignore + } page( res, "Setup", `${ - saved - ? '
Saved. Some settings require a restart.
' + successMessage + ? `
${successMessage}
` : "" }${ - error - ? `
Saving failed. Error message: ${error}
` + errorMessage + ? `
Saving failed. Error message: ${errorMessage}
` : "" }
+

Logs

+
+ Log size: ${logFileSize ? Math.floor(logFileSize / 1024) : "?"} kB +
+
+

Request restart

Uptime

@@ -251,6 +263,8 @@ export function startConfigServer(): void { Boot time is only available if a valid 'JS file url' is configured, otherwise it starts at unix epoch (1970). ` ); + successMessage = ""; + errorMessage = ""; } else { let handled = false; for (let i = 0; i < requestHandler.length; i++) { @@ -417,4 +431,21 @@ export function startConfigServer(): void { } } }); + + requestHandler.push((req, res) => { + if (/\/logs(|\?.*)/.exec(req.path)) { + res.setStatus(200); + res.headers.set("Content-type", "text/plain"); + global.el_flushLogBuffer(); + res.end(readFile("/data/logs.txt")); + } + }); + + requestHandler.push((req, res) => { + if (/\/deletelogs(|\?.*)/.exec(req.path)) { + removeFile("/data/logs.txt"); + successMessage = "Logs were deleted successfully."; + redirect(res, "/setup"); + } + }); } diff --git a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts index b437023..047a917 100644 --- a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts +++ b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts @@ -78,7 +78,24 @@ declare const EL_SOCKET_EVENT_TYPE: number; declare function readSocket( sockfd: number, ssl: any -): { data: string; length: number }; +): { data: Uint8Array; length: number }; declare function readFile(path: string): string; -declare function writeFile(path: string, data: string): void; +declare function writeFile(path: string, data: string): number; +declare function appendFile(path: string, data: string): number; +declare function removeFile(path: string): number; +declare function fileSize(path: string): number; + +// ota +declare function el_ota_begin(): number; +declare function el_ota_write(handle: number, data: Uint8Array): number; +declare function el_ota_end(handle: number): number; +declare function el_ota_switch_boot_partition(): number; + +declare function el_ota_find_next_modules_partition(): number; +declare function el_partition_erase(partition: number): void; +declare function el_partition_write( + partition: number, + offset: number, + data: Uint8Array +): void; diff --git a/components/esp32-javascript/modules/esp32-javascript/http.js b/components/esp32-javascript/modules/esp32-javascript/http.js index 2d3a354..c710e0f 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.js +++ b/components/esp32-javascript/modules/esp32-javascript/http.js @@ -1,6 +1,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.XMLHttpRequest = exports.httpClient = exports.parseQueryStr = exports.decodeQueryParam = exports.httpServer = void 0; +exports.XMLHttpRequest = exports.getDefaultPort = exports.httpClient = exports.parseQueryStr = exports.decodeQueryParam = exports.httpServer = void 0; var socketEvents = require("socket-events"); +var chunked_1 = require("./chunked"); var stringbuffer_1 = require("./stringbuffer"); var sockListen = socketEvents.sockListen; var sockConnect = socketEvents.sockConnect; @@ -50,7 +51,9 @@ function httpServer(port, isSSL, cb) { var gotten = 0; var active = []; socket.onData = function (data, _, length) { - complete = complete ? complete.append(data) : new stringbuffer_1.StringBuffer(data); + complete = complete + ? complete.append(textDecoder.decode(data)) + : new stringbuffer_1.StringBuffer(textDecoder.decode(data)); gotten += length; var endOfHeaders = complete.indexOf("\r\n\r\n"); if (gotten >= 4 && endOfHeaders >= 0) { @@ -115,7 +118,7 @@ function httpServer(port, isSSL, cb) { } return close; }; - var chunked_1 = function () { + var chunked_2 = function () { var chunked = true; if (chunked && headers && headers.get("connection") === "close") { chunked = false; @@ -162,7 +165,7 @@ function httpServer(port, isSSL, cb) { socket.write("HTTP/1.1 " + res_1.status.status + " " + res_1.status.statusText + "\r\n"); } if (!res_1.headersWritten) { - if (chunked_1()) { + if (chunked_2()) { responseHeaders_1.set("transfer-encoding", "chunked"); chunkedEncoding_1 = true; } @@ -252,7 +255,7 @@ function httpServer(port, isSSL, cb) { }); } if (gotten > 0 && socket.onData) { - socket.onData("", _, 0); + socket.onData(new Uint8Array(0), _, 0); } } } @@ -284,7 +287,126 @@ function parseQueryStr(query) { return parsed; } exports.parseQueryStr = parseQueryStr; -function httpClient(ssl, host, port, path, method, requestHeaders, body, successCB, errorCB, finishCB) { +/*export function httpClient( + ssl: boolean, + host: string, + port: string, + path: string, + method: string, + requestHeaders?: string, + body?: { toString: () => string }, + successCB?: (content: string, headers: string) => void, + errorCB?: (message: string) => void, + finishCB?: () => void, + dataCB?: (data: Uint8Array) => void +): void { + const complete: StringBuffer = new StringBuffer(); + let completeLength = 0; + let chunked = false; + let headerRead = false; + let headerEnd = -1; + let contentLength = -1; + requestHeaders = requestHeaders || ""; + if (!errorCB) { + errorCB = print; + } + + const textDecoder = new TextDecoder(); + + sockConnect( + ssl, + host, + port, + function (socket) { + const bodyStr = body ? body.toString() : null; + + const requestLines = `${method} ${path} HTTP/1.1\r\nHost: ${host}\r\n${ + bodyStr ? `Content-length: ${bodyStr.length}\r\n` : "" + }${requestHeaders}\r\n${bodyStr ? bodyStr + "\r\n" : ""}`; + + socket.write(requestLines); + socket.flush(); + }, + function (data, sockfd, length) { + dataCB && dataCB(data); + + complete.append(textDecoder.decode(data)); + completeLength = completeLength + length; + + if (!headerRead && (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { + headerRead = true; + chunked = + complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; + const clIndex = complete.toLowerCase().indexOf("content-length: "); + if (clIndex >= 0) { + const endOfContentLength = complete.indexOf("\r\n", clIndex); + contentLength = parseInt( + complete.substring(clIndex + 15, endOfContentLength).toString() + ); + } + headerEnd += 4; + } + + if (chunked) { + if (complete.substring(complete.length - 5).toString() == "0\r\n\r\n") { + closeSocket(sockfd); + } + } + if (contentLength >= 0) { + if (completeLength - headerEnd == contentLength) { + closeSocket(sockfd); + } + } + }, + function () { + if (errorCB) { + errorCB( + `Could not load ${ssl ? "https" : "http"}://${host}:${port}${path}` + ); + } + }, + function () { + let startFrom = headerEnd; + let content = null; + + if (chunked) { + content = new StringBuffer(); + + let chunkLength; + do { + const chunkLengthEnd = complete.indexOf("\r\n", startFrom); + const lengthStr = complete + .substring(startFrom, chunkLengthEnd) + .toString(); + chunkLength = parseInt(lengthStr, 16); + const chunkEnd = chunkLengthEnd + chunkLength + 2; + + content.append(complete.substring(chunkLengthEnd + 2, chunkEnd)); + startFrom = chunkEnd + 2; + } while (chunkLength > 0); + } else { + content = complete.substring(startFrom); + } + + const headers = complete.substring(0, headerEnd); + + if (successCB) { + successCB(content.toString(), headers.toString()); + } + //free complete for GC + content = null; + if (finishCB) { + finishCB(); + } + } + ); +} +*/ +function httpClient(ssl, host, port, path, method, requestHeaders, body, successCB, // this is removed in favor of the new data and head callback (dataCB, headCB) +errorCB, finishCB, dataCB, headCB) { + if (successCB) { + throw Error("The successCB is not supported anymore."); + } var complete = new stringbuffer_1.StringBuffer(); var completeLength = 0; var chunked = false; @@ -292,74 +414,108 @@ function httpClient(ssl, host, port, path, method, requestHeaders, body, success var headerEnd = -1; var contentLength = -1; requestHeaders = requestHeaders || ""; + var headers; + var chunkedConsumer; if (!errorCB) { errorCB = print; } - sockConnect(ssl, host, port, function (socket) { + var textDecoder = new TextDecoder(); + var socket = sockConnect(ssl, host, port, function (socket) { var bodyStr = body ? body.toString() : null; var requestLines = method + " " + path + " HTTP/1.1\r\nHost: " + host + "\r\n" + (bodyStr ? "Content-length: " + bodyStr.length + "\r\n" : "") + requestHeaders + "\r\n" + (bodyStr ? bodyStr + "\r\n" : ""); socket.write(requestLines); socket.flush(); }, function (data, sockfd, length) { - complete.append(data); - completeLength = completeLength + length; - if (!headerRead && (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { - headerRead = true; - chunked = - complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; - var clIndex = complete.toLowerCase().indexOf("content-length: "); - if (clIndex >= 0) { - var endOfContentLength = complete.indexOf("\r\n", clIndex); - contentLength = parseInt(complete.substring(clIndex + 15, endOfContentLength).toString()); + try { + complete === null || complete === void 0 ? void 0 : complete.append(textDecoder.decode(data)); + completeLength = completeLength + length; + if (!headerRead && + complete && + (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { + headerRead = true; + chunked = + complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; + var clIndex = complete.toLowerCase().indexOf("content-length: "); + if (clIndex >= 0) { + var endOfContentLength = complete.indexOf("\r\n", clIndex); + contentLength = parseInt(complete.substring(clIndex + 15, endOfContentLength).toString()); + } + headerEnd += 4; + headers = complete.substring(0, headerEnd); + complete = undefined; + if (headCB) { + headCB(headers); + } + if (chunked) { + chunkedConsumer = chunked_1.createChunkedEncodingConsumer(dataCB); + } + // the rest of the data is considered data and has to be consumed by the data consumers. + data = data.subarray(headerEnd, data.length); } - headerEnd += 4; - } - if (chunked) { - if (complete.substring(complete.length - 5).toString() == "0\r\n\r\n") { - closeSocket(sockfd); + if (chunkedConsumer) { + // handle chunked data + var eof = chunkedConsumer(data); + if (eof) { + closeSocket(sockfd); + } + } + else if (dataCB) { + // handle non chunked data + dataCB(data); + } + if (contentLength >= 0) { + if (completeLength - headerEnd == contentLength) { + closeSocket(sockfd); + } } } - if (contentLength >= 0) { - if (completeLength - headerEnd == contentLength) { - closeSocket(sockfd); + catch (error) { + if (errorCB) { + errorCB(error); } + closeSocket(sockfd); } }, function () { if (errorCB) { errorCB("Could not load " + (ssl ? "https" : "http") + "://" + host + ":" + port + path); } }, function () { - var startFrom = headerEnd; - var content = null; - if (chunked) { - content = new stringbuffer_1.StringBuffer(); - var chunkLength = void 0; - do { - var chunkLengthEnd = complete.indexOf("\r\n", startFrom); - var lengthStr = complete - .substring(startFrom, chunkLengthEnd) - .toString(); - chunkLength = parseInt(lengthStr, 16); - var chunkEnd = chunkLengthEnd + chunkLength + 2; - content.append(complete.substring(chunkLengthEnd + 2, chunkEnd)); - startFrom = chunkEnd + 2; - } while (chunkLength > 0); - } - else { - content = complete.substring(startFrom); - } - var headers = complete.substring(0, headerEnd); - if (successCB) { - successCB(content.toString(), headers.toString()); - } - //free complete for GC - content = null; if (finishCB) { finishCB(); } }); + var client = { + cancelled: false, + cancel: function () { + if (!client.cancelled) { + client.cancelled = true; + if (errorCB) { + errorCB("Request was cancelled."); + } + closeSocket(socket); + } + }, + }; + return client; } exports.httpClient = httpClient; +// get default port +function getDefaultPort(url) { + var port = parseInt(url.port, 10); + if (isNaN(port)) { + if (url.protocol === "https:") { + port = 443; + } + else if (url.protocol === "http:") { + port = 80; + } + else { + throw Error("Cannot determine default port for protocol " + url.protocol); + } + } + return port; +} +exports.getDefaultPort = getDefaultPort; var XMLHttpRequest = /** @class */ (function () { function XMLHttpRequest() { this.method = "GET"; @@ -368,14 +524,25 @@ var XMLHttpRequest = /** @class */ (function () { // eslint-disable-next-line @typescript-eslint/no-this-alias var self = this; if (this.url) { - httpClient(this.url.protocol === "https:", this.url.hostname, this.url.port, this.url.pathname + this.url.search, this.method, this.requestHeaders ? this.requestHeaders.toString() : undefined, body, function (data, responseHeaders) { - var r = responseHeaders.match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); + var data_1 = undefined; + var responseHeaders_2 = undefined; + var textDecoder_1 = new TextDecoder(); + httpClient(this.url.protocol === "https:", this.url.hostname, this.url.port, this.url.pathname + this.url.search, this.method, this.requestHeaders ? this.requestHeaders.toString() : undefined, body, undefined, function (error) { + console.error(error); + if (self.onerror) { + self.onerror(error); + } + }, function () { + var r = responseHeaders_2 && + responseHeaders_2.toString().match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); if (r) { self.status = parseInt(r[1], 10); self.statusText = r[2]; self.responseURL = ""; - self.responseText = data; - self.reponseHeaders = responseHeaders.substring(r[0].length + 2); + self.responseText = data_1 && data_1.toString(); + self.reponseHeaders = + responseHeaders_2 && + responseHeaders_2.substring(r[0].length + 2).toString(); if (self.onload) { self.onload(); } @@ -385,11 +552,17 @@ var XMLHttpRequest = /** @class */ (function () { self.onerror("Bad http status line."); } } - }, function (error) { - console.error(error); - if (self.onerror) { - self.onerror(error); + data_1 = undefined; + responseHeaders_2 = undefined; + }, function (dataIn) { + if (data_1) { + data_1.append(textDecoder_1.decode(dataIn)); + } + else { + data_1 = new stringbuffer_1.StringBuffer(textDecoder_1.decode(dataIn)); } + }, function (head) { + responseHeaders_2 = head; }); } else { @@ -408,19 +581,7 @@ var XMLHttpRequest = /** @class */ (function () { if (this.url.protocol !== "http:" && this.url.protocol !== "https:") { throw Error("Unsupported protocol for esp32 fetch implementation: " + this.url.protocol); } - // get default port - var port = parseInt(this.url.port, 10); - if (isNaN(port)) { - if (this.url.protocol === "https:") { - port = 443; - } - else if (this.url.protocol === "http:") { - port = 80; - } - else { - throw Error("Cannot determine default port for protocol " + this.url.protocol); - } - } + var port = getDefaultPort(this.url); this.url.port = "" + port; }; XMLHttpRequest.prototype.setRequestHeader = function (name, value) { diff --git a/components/esp32-javascript/modules/esp32-javascript/http.ts b/components/esp32-javascript/modules/esp32-javascript/http.ts index 7bd534b..5354279 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.ts +++ b/components/esp32-javascript/modules/esp32-javascript/http.ts @@ -1,4 +1,8 @@ import socketEvents = require("socket-events"); +import { + ChunkedEncodingConsumer, + createChunkedEncodingConsumer, +} from "./chunked"; import { StringBuffer } from "./stringbuffer"; export interface Esp32JsRequest { @@ -78,8 +82,10 @@ export function httpServer( let gotten = 0; const active: { req: Esp32JsRequest; res: Esp32JsResponse }[] = []; - socket.onData = function (data: string, _: number, length: number) { - complete = complete ? complete.append(data) : new StringBuffer(data); + socket.onData = function (data: Uint8Array, _: number, length: number) { + complete = complete + ? complete.append(textDecoder.decode(data)) + : new StringBuffer(textDecoder.decode(data)); gotten += length; const endOfHeaders = complete.indexOf("\r\n\r\n"); @@ -333,7 +339,7 @@ export function httpServer( } if (gotten > 0 && socket.onData) { - socket.onData("", _, 0); + socket.onData(new Uint8Array(0), _, 0); } } } @@ -369,7 +375,7 @@ export function parseQueryStr(query: string | null): { [key: string]: string } { return parsed; } -export function httpClient( +/*export function httpClient( ssl: boolean, host: string, port: string, @@ -379,7 +385,8 @@ export function httpClient( body?: { toString: () => string }, successCB?: (content: string, headers: string) => void, errorCB?: (message: string) => void, - finishCB?: () => void + finishCB?: () => void, + dataCB?: (data: Uint8Array) => void ): void { const complete: StringBuffer = new StringBuffer(); let completeLength = 0; @@ -392,6 +399,8 @@ export function httpClient( errorCB = print; } + const textDecoder = new TextDecoder(); + sockConnect( ssl, host, @@ -407,7 +416,9 @@ export function httpClient( socket.flush(); }, function (data, sockfd, length) { - complete.append(data); + dataCB && dataCB(data); + + complete.append(textDecoder.decode(data)); completeLength = completeLength + length; if (!headerRead && (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { @@ -478,16 +489,170 @@ export function httpClient( } ); } +*/ + +export function httpClient( + ssl: boolean, + host: string, + port: string, + path: string, + method: string, + requestHeaders?: string, + body?: { toString: () => string }, + successCB?: undefined, // this is removed in favor of the new data and head callback (dataCB, headCB) + errorCB?: (message: string) => void, + finishCB?: () => void, + dataCB?: (data: Uint8Array) => void, + headCB?: (head: StringBuffer) => void +): { cancel: () => void; cancelled: boolean } { + if (successCB) { + throw Error("The successCB is not supported anymore."); + } + + let complete: StringBuffer | undefined = new StringBuffer(); + + let completeLength = 0; + let chunked = false; + let headerRead = false; + let headerEnd = -1; + let contentLength = -1; + requestHeaders = requestHeaders || ""; + let headers: StringBuffer; + let chunkedConsumer: ChunkedEncodingConsumer | undefined; + + if (!errorCB) { + errorCB = print; + } + + const textDecoder = new TextDecoder(); + + const socket = sockConnect( + ssl, + host, + port, + function (socket) { + const bodyStr = body ? body.toString() : null; + + const requestLines = `${method} ${path} HTTP/1.1\r\nHost: ${host}\r\n${ + bodyStr ? `Content-length: ${bodyStr.length}\r\n` : "" + }${requestHeaders}\r\n${bodyStr ? bodyStr + "\r\n" : ""}`; + + socket.write(requestLines); + socket.flush(); + }, + function (data, sockfd, length) { + try { + complete?.append(textDecoder.decode(data)); + completeLength = completeLength + length; + + if ( + !headerRead && + complete && + (headerEnd = complete.indexOf("\r\n\r\n")) >= 0 + ) { + headerRead = true; + chunked = + complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; + const clIndex = complete.toLowerCase().indexOf("content-length: "); + if (clIndex >= 0) { + const endOfContentLength = complete.indexOf("\r\n", clIndex); + contentLength = parseInt( + complete.substring(clIndex + 15, endOfContentLength).toString() + ); + } + headerEnd += 4; + headers = complete.substring(0, headerEnd); + complete = undefined; + if (headCB) { + headCB(headers); + } + + if (chunked) { + chunkedConsumer = createChunkedEncodingConsumer(dataCB); + } + + // the rest of the data is considered data and has to be consumed by the data consumers. + data = data.subarray(headerEnd, data.length); + } + + if (chunkedConsumer) { + // handle chunked data + const eof = chunkedConsumer(data); + if (eof) { + closeSocket(sockfd); + } + } else if (dataCB) { + // handle non chunked data + dataCB(data); + } + + if (contentLength >= 0) { + if (completeLength - headerEnd == contentLength) { + closeSocket(sockfd); + } + } + } catch (error) { + if (errorCB) { + errorCB(error); + } + closeSocket(sockfd); + } + }, + function () { + if (errorCB) { + errorCB( + `Could not load ${ssl ? "https" : "http"}://${host}:${port}${path}` + ); + } + }, + function () { + if (finishCB) { + finishCB(); + } + } + ); + + const client = { + cancelled: false, + cancel: () => { + if (!client.cancelled) { + client.cancelled = true; + if (errorCB) { + errorCB("Request was cancelled."); + } + closeSocket(socket); + } + }, + }; + return client; +} +// get default port +export function getDefaultPort(url: { + port: string; + protocol: string; +}): number { + let port = parseInt(url.port, 10); + if (isNaN(port)) { + if (url.protocol === "https:") { + port = 443; + } else if (url.protocol === "http:") { + port = 80; + } else { + throw Error(`Cannot determine default port for protocol ${url.protocol}`); + } + } + return port; +} export class XMLHttpRequest { private url?: AnchorElement; private method = "GET"; private reponseHeaders?: string; private requestHeaders?: StringBuffer; - private status?: number; - private statusText?: string; - private responseURL?: string; - private responseText?: string; + public status?: number; + public statusText?: string; + public responseURL?: string; + public responseText?: string; public onerror?: (error: string) => void; public onload?: () => void; @@ -495,7 +660,12 @@ export class XMLHttpRequest { public send(body: string): void { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; + if (this.url) { + let data: StringBuffer | undefined = undefined; + let responseHeaders: StringBuffer | undefined = undefined; + const textDecoder: TextDecoder = new TextDecoder(); + httpClient( this.url.protocol === "https:", this.url.hostname, @@ -504,14 +674,25 @@ export class XMLHttpRequest { this.method, this.requestHeaders ? this.requestHeaders.toString() : undefined, body, - function (data: string, responseHeaders: string) { - const r = responseHeaders.match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); + undefined, + function (error: string) { + console.error(error); + if (self.onerror) { + self.onerror(error); + } + }, + function () { + const r = + responseHeaders && + responseHeaders.toString().match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); if (r) { self.status = parseInt(r[1], 10); self.statusText = r[2]; self.responseURL = ""; - self.responseText = data; - self.reponseHeaders = responseHeaders.substring(r[0].length + 2); + self.responseText = data && data.toString(); + self.reponseHeaders = + responseHeaders && + responseHeaders.substring(r[0].length + 2).toString(); if (self.onload) { self.onload(); } @@ -520,12 +701,18 @@ export class XMLHttpRequest { self.onerror("Bad http status line."); } } + data = undefined; + responseHeaders = undefined; }, - function (error: string) { - console.error(error); - if (self.onerror) { - self.onerror(error); + function (dataIn) { + if (data) { + data.append(textDecoder.decode(dataIn)); + } else { + data = new StringBuffer(textDecoder.decode(dataIn)); } + }, + function (head) { + responseHeaders = head; } ); } else { @@ -550,19 +737,7 @@ export class XMLHttpRequest { ); } - // get default port - let port = parseInt(this.url.port, 10); - if (isNaN(port)) { - if (this.url.protocol === "https:") { - port = 443; - } else if (this.url.protocol === "http:") { - port = 80; - } else { - throw Error( - `Cannot determine default port for protocol ${this.url.protocol}` - ); - } - } + const port = getDefaultPort(this.url); this.url.port = "" + port; } diff --git a/components/esp32-javascript/modules/esp32-javascript/index.js b/components/esp32-javascript/modules/esp32-javascript/index.js index e588e2c..d9d7fc0 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.js +++ b/components/esp32-javascript/modules/esp32-javascript/index.js @@ -1,9 +1,32 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var stringbuffer_1 = require("./stringbuffer"); console.info("Load global.js (NEW)..."); require("./global.js"); +/** + * This is defines the function to append to buffered file logging. + */ +console.info("Loading logging buffer (NEW)..."); +var TDIWEF = "TDIWEF"; +global.el_flushLogBuffer = function () { + var swap = global.logBuffer; + global.logBuffer = new stringbuffer_1.StringBuffer(); + appendFile("/data/logs.txt", swap.toString()); +}; +global.el_appendLogBuffer = function (message, level) { + global.logBuffer = global.logBuffer || new stringbuffer_1.StringBuffer(); + var l = TDIWEF.substr(level, 1); + global.logBuffer.append(l + "\t" + new Date() + "\t" + message + "\n"); + if (global.logBuffer.length > 1024) { + global.el_flushLogBuffer(); + } +}; +console.info("Importing http (NEW)..."); var http = require("./http"); +console.info("Importing boot (NEW)..."); var boot = require("./boot"); +console.info("Importing eventloop (NEW)..."); var eventloop = require("esp32-js-eventloop"); +console.info("Importing config (NEW)..."); var configManager = require("./config"); console.info("Loading promise.js and exposing globals (NEW)..."); // eslint-disable-next-line @typescript-eslint/no-var-requires diff --git a/components/esp32-javascript/modules/esp32-javascript/index.ts b/components/esp32-javascript/modules/esp32-javascript/index.ts index 90e08b6..1a8e8b9 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.ts +++ b/components/esp32-javascript/modules/esp32-javascript/index.ts @@ -1,9 +1,37 @@ +import { StringBuffer } from "./stringbuffer"; + console.info("Load global.js (NEW)..."); require("./global.js"); +/** + * This is defines the function to append to buffered file logging. + */ +console.info("Loading logging buffer (NEW)..."); +const TDIWEF = "TDIWEF"; +global.el_flushLogBuffer = function (): void { + const swap = global.logBuffer; + global.logBuffer = new StringBuffer(); + appendFile("/data/logs.txt", swap.toString()); +}; +global.el_appendLogBuffer = function (message: string, level: number): void { + global.logBuffer = global.logBuffer || new StringBuffer(); + const l = TDIWEF.substr(level, 1); + global.logBuffer.append(`${l}\t${new Date()}\t${message}\n`); + if (global.logBuffer.length > 1024) { + global.el_flushLogBuffer(); + } +}; + +console.info("Importing http (NEW)..."); import http = require("./http"); + +console.info("Importing boot (NEW)..."); import boot = require("./boot"); + +console.info("Importing eventloop (NEW)..."); import eventloop = require("esp32-js-eventloop"); + +console.info("Importing config (NEW)..."); import configManager = require("./config"); console.info("Loading promise.js and exposing globals (NEW)..."); diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.js b/components/esp32-javascript/modules/esp32-javascript/native-ota.js new file mode 100644 index 0000000..38425d1 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.js @@ -0,0 +1,117 @@ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.upgrade = void 0; +var http = require("./http"); +function assertStatusCode(status, url) { + return function (head) { + var r = head && head.toString().match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); + if (!r || r[1] !== "" + status) { + throw Error("Status " + (r && r[1]) + " for URL '" + url + "'"); + } + }; +} +function upgradeApp(handle, appImageUrl, submitSuccess, submitError) { + var parsedAppImageUrl = urlparse(appImageUrl); + parsedAppImageUrl.port = "" + http.getDefaultPort(parsedAppImageUrl); + var offset = 0; + var error = false; + var client = http.httpClient(parsedAppImageUrl.protocol === "https", parsedAppImageUrl.hostname, parsedAppImageUrl.port, parsedAppImageUrl.pathname, "GET", undefined, // requestHeaders + undefined, // body + undefined, // success + //error: + function (message) { + error = true; + try { + el_ota_end(handle); + } + catch (_) { + //ignore + } + if (!client.cancelled) { + console.error("Error loading ota firmware: " + message); + submitError(message); + } + }, + //finish: + function () { + if (!error) { + el_ota_end(handle); + submitSuccess("app"); + } + }, + //onData: + function (data) { + console.log("App download: " + Math.floor(offset / 1024) + " kb"); + el_ota_write(handle, data); + offset += data.length; + }, assertStatusCode(200, appImageUrl)); + return client; +} +function upgradeModules(partition, modulesImageUrl, submitSuccess, submitError) { + var parsedModulesImageUrl = urlparse(modulesImageUrl); + parsedModulesImageUrl.port = "" + http.getDefaultPort(parsedModulesImageUrl); + var offset = 0; + var error = false; + var client = http.httpClient(parsedModulesImageUrl.protocol === "https", parsedModulesImageUrl.hostname, parsedModulesImageUrl.port, parsedModulesImageUrl.pathname, "GET", undefined, // requestHeaders + undefined, // body + undefined, // success + //error: + function (message) { + error = true; + if (!client.cancelled) { + console.error("Error loading new modules firmware: " + message); + submitError(message); + } + }, + //finish: + function () { + if (!error) { + submitSuccess("modules"); + } + }, + //onData: + function (data) { + console.log("Modules download: " + Math.floor(offset / 1024) + " kb"); + el_partition_write(partition, offset, data); + offset += data.length; + }, assertStatusCode(200, modulesImageUrl)); + return client; +} +exports.upgrade = function (appImageUrl, modulesImageUrl, onError, onFinish) { + console.log("Start native firmware upgrade:"); + console.log("App image: " + appImageUrl); + console.log("Modules image: " + modulesImageUrl); + var appImageUpdateCompleted = false; + var modulesImageUpdateCompleted = false; + var submitSuccess = function (type) { + if (type === "app") { + appImageUpdateCompleted = true; + console.log("App image upgrade finished successfully."); + } + else if (type === "modules") { + modulesImageUpdateCompleted = true; + console.log("Modules image upgrade finished successfully."); + } + if (appImageUpdateCompleted && modulesImageUpdateCompleted) { + el_ota_switch_boot_partition(); + console.log("Upgrade finished successfully. Please restart to start upgraded firmware."); + onFinish && onFinish(); + } + }; + var cancellable = []; + var submitError = function (message) { + console.error("Upgrading firmware failed: " + message); + cancellable.forEach(function (c) { return c.cancel(); }); + onError && onError(message); + }; + console.log("Erase 'App' flash partition..."); + var handle = el_ota_begin(); + var partition = el_ota_find_next_modules_partition(); + console.log("Erase 'Modules' flash partition..."); + el_partition_erase(partition); + cancellable = [ + // this method starts the app upgrade async + upgradeApp(handle, appImageUrl, submitSuccess, submitError), + // this method starts the modules upgrade async + upgradeModules(partition, modulesImageUrl, submitSuccess, submitError), + ]; +}; diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.ts b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts new file mode 100644 index 0000000..ca52656 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts @@ -0,0 +1,164 @@ +import http = require("./http"); +import { StringBuffer } from "./stringbuffer"; + +type SubmitFunction = (type: "app" | "modules") => void; +type SubmitErrorFunction = (message: string) => void; + +function assertStatusCode(status: number, url: string) { + return (head: StringBuffer) => { + const r = head && head.toString().match(/^HTTP\/[0-9.]+ ([0-9]+) (.*)/); + if (!r || r[1] !== "" + status) { + throw Error(`Status ${r && r[1]} for URL '${url}'`); + } + }; +} + +function upgradeApp( + handle: number, + appImageUrl: string, + submitSuccess: SubmitFunction, + submitError: SubmitErrorFunction +) { + const parsedAppImageUrl = urlparse(appImageUrl); + parsedAppImageUrl.port = "" + http.getDefaultPort(parsedAppImageUrl); + + let offset = 0; + let error = false; + const client = http.httpClient( + parsedAppImageUrl.protocol === "https", + parsedAppImageUrl.hostname, + parsedAppImageUrl.port, + parsedAppImageUrl.pathname, + "GET", + undefined, // requestHeaders + undefined, // body + undefined, // success + //error: + (message) => { + error = true; + try { + el_ota_end(handle); + } catch (_) { + //ignore + } + if (!client.cancelled) { + console.error(`Error loading ota firmware: ${message}`); + submitError(message); + } + }, + //finish: + () => { + if (!error) { + el_ota_end(handle); + submitSuccess("app"); + } + }, + //onData: + (data) => { + console.log(`App download: ${Math.floor(offset / 1024)} kb`); + el_ota_write(handle, data); + offset += data.length; + }, + assertStatusCode(200, appImageUrl) + ); + return client; +} + +function upgradeModules( + partition: number, + modulesImageUrl: string, + submitSuccess: SubmitFunction, + submitError: SubmitErrorFunction +) { + const parsedModulesImageUrl = urlparse(modulesImageUrl); + parsedModulesImageUrl.port = "" + http.getDefaultPort(parsedModulesImageUrl); + + let offset = 0; + let error = false; + const client = http.httpClient( + parsedModulesImageUrl.protocol === "https", + parsedModulesImageUrl.hostname, + parsedModulesImageUrl.port, + parsedModulesImageUrl.pathname, + "GET", + undefined, // requestHeaders + undefined, // body + undefined, // success + //error: + (message) => { + error = true; + if (!client.cancelled) { + console.error(`Error loading new modules firmware: ${message}`); + submitError(message); + } + }, + //finish: + () => { + if (!error) { + submitSuccess("modules"); + } + }, + //onData: + (data) => { + console.log(`Modules download: ${Math.floor(offset / 1024)} kb`); + el_partition_write(partition, offset, data); + offset += data.length; + }, + assertStatusCode(200, modulesImageUrl) + ); + return client; +} + +export const upgrade = ( + appImageUrl: string, + modulesImageUrl: string, + onError: (message: string) => void, + onFinish: () => void +): void => { + console.log(`Start native firmware upgrade:`); + console.log(`App image: ${appImageUrl}`); + console.log(`Modules image: ${modulesImageUrl}`); + + let appImageUpdateCompleted = false; + let modulesImageUpdateCompleted = false; + + const submitSuccess: SubmitFunction = (type) => { + if (type === "app") { + appImageUpdateCompleted = true; + console.log("App image upgrade finished successfully."); + } else if (type === "modules") { + modulesImageUpdateCompleted = true; + console.log("Modules image upgrade finished successfully."); + } + + if (appImageUpdateCompleted && modulesImageUpdateCompleted) { + el_ota_switch_boot_partition(); + console.log( + "Upgrade finished successfully. Please restart to start upgraded firmware." + ); + onFinish && onFinish(); + } + }; + + let cancellable: { cancel: () => void }[] = []; + const submitError: SubmitErrorFunction = (message) => { + console.error(`Upgrading firmware failed: ${message}`); + + cancellable.forEach((c) => c.cancel()); + onError && onError(message); + }; + + console.log("Erase 'App' flash partition..."); + const handle = el_ota_begin(); + + const partition = el_ota_find_next_modules_partition(); + console.log("Erase 'Modules' flash partition..."); + el_partition_erase(partition); + + cancellable = [ + // this method starts the app upgrade async + upgradeApp(handle, appImageUrl, submitSuccess, submitError), + // this method starts the modules upgrade async + upgradeModules(partition, modulesImageUrl, submitSuccess, submitError), + ]; +}; diff --git a/components/socket-events/modules/socket-events/index.js b/components/socket-events/modules/socket-events/index.js index a36f571..ee8976a 100644 --- a/components/socket-events/modules/socket-events/index.js +++ b/components/socket-events/modules/socket-events/index.js @@ -398,7 +398,10 @@ function afterSuspend(evt, collected) { var result = readSocket(socket_1.sockfd, socket_1.ssl); console.debug("after eventloop read socket"); if (result === null || - (result && typeof result.data === "string" && result.length == 0)) { + (result && + Object.prototype.toString.call(result.data) === + "[object Uint8Array]" && + result.length == 0)) { closeSocket(socket_1.sockfd); } else if (!result) { diff --git a/components/socket-events/modules/socket-events/index.ts b/components/socket-events/modules/socket-events/index.ts index d5a4995..19bc872 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -3,7 +3,11 @@ import { afterSuspendHandlers, } from "esp32-js-eventloop"; -export type OnDataCB = (data: string, sockfd: number, length: number) => void; +export type OnDataCB = ( + data: Uint8Array, + sockfd: number, + length: number +) => void; export type OnConnectCB = (socket: Esp32JsSocket) => boolean | void; export type OnErrorCB = (sockfd: number) => void; export type OnCloseCB = (sockfd: number) => void; @@ -317,13 +321,13 @@ export function sockConnect( host: string, port: string, onConnect: OnConnectCB, - onData: (data: string, sockfd: number, length: number) => void, + onData: (data: Uint8Array, sockfd: number, length: number) => void, onError: (sockfd: number) => void, onClose: () => void ): Esp32JsSocket { const sockfd = el_createNonBlockingSocket(); el_connectNonBlocking(sockfd, host, parseInt(port, 10)); - + const socket = getOrCreateNewSocket(); socket.sockfd = sockfd; socket.onData = onData; @@ -514,7 +518,10 @@ function afterSuspend(evt: Esp32JsEventloopEvent, collected: Function[]) { console.debug("after eventloop read socket"); if ( result === null || - (result && typeof result.data === "string" && result.length == 0) + (result && + Object.prototype.toString.call(result.data) === + "[object Uint8Array]" && + result.length == 0) ) { closeSocket(socket.sockfd); } else if (!result) { diff --git a/components/socket-events/socket-events.c b/components/socket-events/socket-events.c index 0a6253a..9b0618b 100644 --- a/components/socket-events/socket-events.c +++ b/components/socket-events/socket-events.c @@ -75,7 +75,7 @@ int createSocketPair() { struct sockaddr_in server; - jslog(DEBUG, "Start creating socket paair\n"); + jslog(DEBUG, "Start creating socket paair"); /*int bits = xEventGroupGetBits(wifi_event_group); int connected = CONNECTED_BIT & bits; */ @@ -92,17 +92,17 @@ int createSocketPair() server.sin_port = htons(port); server.sin_len = sizeof(server); - jslog(DEBUG, "Trying to bind socket %d...\n", sd); + jslog(DEBUG, "Trying to bind socket %d...", sd); if (bind(sd, (struct sockaddr *)&server, sizeof(server)) >= 0) { - jslog(DEBUG, "Trying to create client socket...\n"); + jslog(DEBUG, "Trying to create client socket..."); int sc = createNonBlockingSocket(AF_INET, SOCK_DGRAM, 0, true); - jslog(DEBUG, "Created socket pair: %d<-->%d\n", sd, sc); + jslog(DEBUG, "Created socket pair: %d<-->%d", sd, sc); - jslog(DEBUG, "Send test data...\n"); + jslog(DEBUG, "Send test data..."); memset((char *)&target, 0, sizeof(target)); target.sin_family = AF_INET; @@ -112,11 +112,11 @@ int createSocketPair() if (sendto(sc, "", 1, 0, (struct sockaddr *)&target, sizeof(target)) < 0) { - jslog(ERROR, "Error sending test data to self-socket: %d\n", errno); + jslog(ERROR, "Error sending test data to self-socket: %d", errno); } else { - jslog(DEBUG, "Trying to receive test data...\n"); + jslog(DEBUG, "Trying to receive test data..."); char msg[2] = "A"; struct sockaddr_in remaddr; socklen_t addrlen = sizeof(remaddr); @@ -128,29 +128,29 @@ int createSocketPair() while (result < 0) { - jslog(ERROR, "Error receiving test data from self-socket: %d\n", errno); + jslog(ERROR, "Error receiving test data from self-socket: %d", errno); } - jslog(DEBUG, "Finished reading.\n"); + jslog(DEBUG, "Finished reading."); if (strcmp(msg, "") == 0) { - jslog(INFO, "Self-Socket Test successful!\n"); + jslog(INFO, "Self-Socket Test successful!"); selectClientSocket = sc; selectServerSocket = sd; - jslog(DEBUG, "Successfully created socket pair: %d<-->%d\n", selectServerSocket, selectClientSocket); + jslog(DEBUG, "Successfully created socket pair: %d<-->%d", selectServerSocket, selectClientSocket); return 0; } else { - jslog(ERROR, "Self-socket test NOT successful: %s\n", msg); + jslog(ERROR, "Self-socket test NOT successful: %s", msg); } } close(sc); } else { - jslog(ERROR, "Binding self-socket was unsuccessful: %d\n", errno); + jslog(ERROR, "Binding self-socket was unsuccessful: %d", errno); } close(sd); @@ -162,10 +162,10 @@ int createSocketPair() } else { - jslog(DEBUG, "Skip until wifi connected: %d\n", errno); + jslog(DEBUG, "Skip until wifi connected: %d", errno); } - jslog(DEBUG, "Could not create socket pair... no wifi?\n"); + jslog(DEBUG, "Could not create socket pair... no wifi?"); return -1; } @@ -231,7 +231,7 @@ void select_task_it() { jslog(ERROR, "Error getting data available from self-socket: %d.", errno); } - jslog(DEBUG, "DATA AVAILABLE %d.\n", dataAvailable); + jslog(DEBUG, "DATA AVAILABLE %d.", dataAvailable); //read self-socket if flag is set if (dataAvailable > 0) { @@ -240,11 +240,11 @@ void select_task_it() socklen_t addrlen = sizeof(remaddr); if (recvfrom(selectServerSocket, msg, dataAvailable, 0, (struct sockaddr *)&remaddr, &addrlen) < 0) { - jslog(ERROR, "READ self-socket FAILED: %d\n", errno); + jslog(ERROR, "READ self-socket FAILED: %d", errno); } else { - jslog(DEBUG, "READ of self-socket.\n"); + jslog(DEBUG, "READ of self-socket."); } } @@ -256,7 +256,7 @@ void select_task_it() // self socket end int ret = select(sockfd_max + 1, &readset, &writeset, &errset, NULL); needsUnblock = true; - jslog(DEBUG, "Select return %d.\n", ret); + jslog(DEBUG, "Select return %d.", ret); if (ret >= 0) { if (ret > 0) @@ -305,23 +305,23 @@ void select_task_it() if (events.events_len > 0) { - jslog(DEBUG, "Fire all %d socket events!\n", events.events_len); + jslog(DEBUG, "Fire all %d socket events!", events.events_len); el_fire_events(&events); } else { - jslog(DEBUG, "No socket events to fire!\n"); + jslog(DEBUG, "No socket events to fire!"); } } } else { - jslog(ERROR, "select returns ERROR: %d\n", errno); + jslog(ERROR, "select returns ERROR: %d", errno); } } //wait for next loop needsUnblock = true; - jslog(DEBUG, "Select loop finished and now waits for next iteration.\n"); + jslog(DEBUG, "Select loop finished and now waits for next iteration."); xSemaphoreTake(xSemaphore, portMAX_DELAY); needsUnblock = false; } @@ -451,7 +451,7 @@ static duk_ret_t el_registerSocketEvents(duk_context *ctx) if (changes) { - jslog(DEBUG, "Trying to trigger the next select iteration... "); + jslog(DEBUG, "Trying to trigger the next select iteration..."); if (selectClientSocket >= 0) { //interrupt select through self-socket @@ -459,11 +459,11 @@ static duk_ret_t el_registerSocketEvents(duk_context *ctx) needsUnblock = true; if (sendto(selectClientSocket, ".", 1, 0, (struct sockaddr *)&target, sizeof(target)) < 0) { - jslog(ERROR, "Self-socket sending was NOT successful: %d\n", errno); + jslog(ERROR, "Self-socket sending was NOT successful: %d", errno); } else { - jslog(DEBUG, "Self-socket sending was successful.\n"); + jslog(DEBUG, "Self-socket sending was successful."); } } } @@ -492,8 +492,7 @@ static duk_ret_t el_connectNonBlocking(duk_context *ctx) int port = duk_to_int(ctx, 2); int ret = connectNonBlocking(sockfd, hostname, port); - duk_push_int(ctx, ret); - return 1; + return ret >= 0 ? 0 : -1; } static duk_ret_t el_bindAndListen(duk_context *ctx) @@ -515,13 +514,13 @@ static duk_ret_t el_acceptIncoming(duk_context *ctx) { if (errno == EAGAIN) { - jslog(INFO, "accept returned EAGAIN\n"); + jslog(INFO, "accept returned EAGAIN"); //return undefined return 0; } else { - jslog(ERROR, "accept returned errno:%d on socket %d\n", errno, sockfd); + jslog(ERROR, "accept returned errno:%d on socket %d", errno, sockfd); } } @@ -713,19 +712,21 @@ static duk_ret_t el_readSocket(duk_context *ctx) duk_idx_t obj_idx = duk_push_object(ctx); duk_push_int(ctx, ret); duk_put_prop_string(ctx, obj_idx, "length"); - duk_push_string(ctx, msg); + //duk_push_string(ctx, msg); + void *p = duk_push_fixed_buffer(ctx, ret); + memcpy(p, msg, ret); duk_put_prop_string(ctx, obj_idx, "data"); } else if ((ssl == NULL && error == EAGAIN) || (ssl != NULL && error == SSL_ERROR_WANT_READ)) { - jslog(DEBUG, "*** EAGAIN OR SSL_ERROR_WANT_READ RETURNED!!!\n"); + jslog(DEBUG, "*** EAGAIN OR SSL_ERROR_WANT_READ RETURNED!!!"); //eagain duk_push_undefined(ctx); } else { - jslog(ERROR, "READ ERROR return value %d and error code %d\n", ret, error); + jslog(ERROR, "READ ERROR return value %d and error code %d", ret, error); //error duk_push_null(ctx); } @@ -734,11 +735,11 @@ static duk_ret_t el_readSocket(duk_context *ctx) void select_task(void *ignore) { - jslog(DEBUG, "Starting select task...\n"); + jslog(DEBUG, "Starting select task..."); while (true) { - jslog(DEBUG, "Starting next select loop.\n"); + jslog(DEBUG, "Starting next select loop."); select_task_it(); } } diff --git a/components/socket-events/tcp.c b/components/socket-events/tcp.c index cdb9b7b..143fc02 100644 --- a/components/socket-events/tcp.c +++ b/components/socket-events/tcp.c @@ -50,7 +50,7 @@ int createNonBlockingSocket(int domain, int type, int protocol, bool nonblocking sockfd = socket(domain, type, protocol); if (sockfd < 0) { - jslog(ERROR, "ERROR opening socket\n"); + jslog(ERROR, "ERROR opening socket"); return -1; } @@ -60,7 +60,7 @@ int createNonBlockingSocket(int domain, int type, int protocol, bool nonblocking ret = lwip_ioctl(sockfd, FIONBIO, &opt); if (ret < 0) { - jslog(ERROR, "Cannot set non-blocking opt.\n"); + jslog(ERROR, "Cannot set non-blocking opt."); return -1; } } @@ -78,7 +78,7 @@ int connectNonBlocking(int sockfd, const char *hostname, int portno) server = gethostbyname(hostname); if (server == NULL) { - jslog(ERROR, "ERROR, no such host as %s\n", hostname); + jslog(ERROR, "ERROR, no such host as %s", hostname); return -1; } @@ -93,7 +93,7 @@ int connectNonBlocking(int sockfd, const char *hostname, int portno) ret = connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)); if (ret == -1 && errno != EINPROGRESS) { - jslog(ERROR, "ERROR connecting\n"); + jslog(ERROR, "ERROR connecting"); return -1; } return 0; @@ -111,7 +111,7 @@ int acceptIncoming(int sockfd) int ret = lwip_ioctl(cfd, FIONBIO, &opt); if (ret < 0) { - jslog(ERROR, "ERROR while accepting and setting non blocking: %d\n", errno); + jslog(ERROR, "ERROR while accepting and setting non blocking: %d", errno); return -1; } } @@ -119,7 +119,7 @@ int acceptIncoming(int sockfd) { if (errno != EAGAIN) { - jslog(ERROR, "ERROR while accepting: %d\n", errno); + jslog(ERROR, "ERROR while accepting: %d", errno); } } return cfd; @@ -141,13 +141,13 @@ int bindAndListen(int sockfd, int portno) sizeof(serveraddr)); if (ret == -1) { - jslog(ERROR, "ERROR binding\n"); + jslog(ERROR, "ERROR binding"); return -1; } if (listen(sockfd, LISTEN_BACKLOG) == -1) { - jslog(ERROR, "ERROR listening\n"); + jslog(ERROR, "ERROR listening"); return -1; } return 0; @@ -169,12 +169,12 @@ int writeSocket(int sockfd, const char *msg, int len, SSL *ssl) { if (errno == EAGAIN) { - jslog(INFO, "EAGAIN in socket: %d\n", errno); + jslog(INFO, "EAGAIN in socket: %d", errno); return 0; } else { - jslog(ERROR, "ERROR writing to socket: %d\n", errno); + jslog(ERROR, "ERROR writing to socket: %d", errno); return n; } } @@ -192,7 +192,7 @@ int readSocket(int sockfd, char *msg, int len) int ret = lwip_ioctl(sockfd, FIONBIO, &opt); if (ret < 0) { - jslog(ERROR, "Cannot set non-blocking opt.\n"); + jslog(ERROR, "Cannot set non-blocking opt."); return -1; } @@ -206,7 +206,7 @@ int readSocket(int sockfd, char *msg, int len) &tv, sizeof(struct timeval)) < 0) { - jslog(ERROR, "Cannot set timeout opt.\n"); + jslog(ERROR, "Cannot set timeout opt."); return -1; } diff --git a/components/spiffs-events/spiffs-events.c b/components/spiffs-events/spiffs-events.c index c5db8a7..ccda3c4 100644 --- a/components/spiffs-events/spiffs-events.c +++ b/components/spiffs-events/spiffs-events.c @@ -32,10 +32,12 @@ SOFTWARE. #include #include "esp32-js-log.h" #include "esp32-javascript.h" +#include "esp_ota_ops.h" +#include "esp_partition.h" void initFilesystem(const char *label, const char *basePath) { - jslog(INFO, "Initializing SPIFFS"); + jslog(INFO, "Initializing SPIFFS partition %s", label); esp_vfs_spiffs_conf_t conf = { .base_path = basePath, @@ -76,9 +78,26 @@ void initFilesystem(const char *label, const char *basePath) } } +long fileSize(const char *path) +{ + jslog(DEBUG, "Getting filesize of %s", path); + FILE *f = fopen(path, "r"); + if (f == NULL) + { + jslog(ERROR, "Failed to open file to get filesize"); + return -1; + } + + fseek(f, 0, SEEK_END); + long fsize = ftell(f); + fclose(f); + + return fsize; +} + char *readFile(const char *path) { - jslog(INFO, "Reading file %s", path); + jslog(DEBUG, "Reading file %s", path); FILE *f = fopen(path, "r"); if (f == NULL) { @@ -99,9 +118,15 @@ char *readFile(const char *path) return string; } +int removeFile(const char *path) +{ + jslog(DEBUG, "Removing file %s", path); + return remove(path); +} + int writeFile(const char *path, const char *content) { - jslog(INFO, "Writing file %s", path); + jslog(DEBUG, "Writing file %s", path); FILE *f = fopen(path, "w"); if (f == NULL) { @@ -113,6 +138,20 @@ int writeFile(const char *path, const char *content) return result; } +int appendFile(const char *path, const char *content) +{ + jslog(DEBUG, "Appending to file %s", path); + FILE *f = fopen(path, "a"); + if (f == NULL) + { + jslog(ERROR, "Failed to open file for appending"); + return -1; + } + int result = fputs(content, f); + fclose(f); + return result; +} + bool fileExists(const char *path) { struct stat buffer; @@ -135,6 +174,21 @@ duk_ret_t el_readFile(duk_context *ctx) } } +duk_ret_t el_fileSize(duk_context *ctx) +{ + const char *path = duk_to_string(ctx, 0); + long size = fileSize(path); + if (size >= 0) + { + duk_push_number(ctx, size); + return 1; + } + else + { + return 0; // undefined + } +} + duk_ret_t el_writeFile(duk_context *ctx) { const char *path = duk_to_string(ctx, 0); @@ -143,6 +197,21 @@ duk_ret_t el_writeFile(duk_context *ctx) return 1; } +duk_ret_t el_appendFile(duk_context *ctx) +{ + const char *path = duk_to_string(ctx, 0); + const char *content = duk_to_string(ctx, 1); + duk_push_int(ctx, appendFile(path, content)); + return 1; +} + +duk_ret_t el_removeFile(duk_context *ctx) +{ + const char *path = duk_to_string(ctx, 0); + duk_push_int(ctx, removeFile(path)); + return 1; +} + duk_ret_t el_fileExists(duk_context *ctx) { const char *path = duk_to_string(ctx, 0); @@ -158,11 +227,20 @@ void registerBindings(duk_context *ctx) duk_put_global_string(ctx, "fileExists"); duk_push_c_function(ctx, el_writeFile, 2); duk_put_global_string(ctx, "writeFile"); + duk_push_c_function(ctx, el_appendFile, 2); + duk_put_global_string(ctx, "appendFile"); + duk_push_c_function(ctx, el_removeFile, 1); + duk_put_global_string(ctx, "removeFile"); + duk_push_c_function(ctx, el_fileSize, 1); + duk_put_global_string(ctx, "fileSize"); } void initSpiffs(duk_context *ctx) { - initFilesystem("modules", "/modules"); + esp_partition_t *partition = esp_ota_get_boot_partition(); + const char *modulesLabel = strcmp(partition->label, "ota_1") == 0 ? "modules_1" : "modules"; + initFilesystem(modulesLabel, "/modules"); + initFilesystem("data", "/data"); registerBindings(ctx); } diff --git a/components/wifi-events/wifi-events.c b/components/wifi-events/wifi-events.c index 7e03d0e..fb4ce95 100644 --- a/components/wifi-events/wifi-events.c +++ b/components/wifi-events/wifi-events.c @@ -44,7 +44,7 @@ void startScan() int ret = esp_wifi_scan_start(&scanConf, false); if (ret > 0) { - jslog(WARN, "SCAN RETURNED %d\n", ret); + jslog(WARN, "SCAN RETURNED %d", ret); } else { @@ -61,7 +61,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) js_event_t event2; wifi_mode_t mode; - jslog(DEBUG, "WIFI EVENT %d\n", sysevent->event_id); + jslog(DEBUG, "WIFI EVENT %d", sysevent->event_id); switch (sysevent->event_id) { case SYSTEM_EVENT_SCAN_DONE: @@ -71,7 +71,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) uint16_t apCount = 0; esp_wifi_scan_get_ap_num(&apCount); - jslog(DEBUG, "Number of access points found: %d\n", sysevent->event_info.scan_done.number); + jslog(DEBUG, "Number of access points found: %d", sysevent->event_info.scan_done.number); uint8_t *bssid = NULL; int8_t rssi = -127; wifi_ap_record_t *list = NULL; @@ -97,7 +97,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) xEventGroupClearBits(wifi_event_group, SCANNING_BIT); if (bssid != NULL) { - jslog(INFO, "SSID %s found, best rssi %d, bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", wifi_config.sta.ssid, rssi, + jslog(INFO, "SSID %s found, best rssi %d, bssid=%02x:%02x:%02x:%02x:%02x:%02x", wifi_config.sta.ssid, rssi, bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); memcpy(wifi_config.sta.bssid, bssid, 6 * sizeof(uint8_t)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); @@ -105,7 +105,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) } else { - jslog(ERROR, "SSID not found %s\n", wifi_config.sta.ssid); + jslog(ERROR, "SSID not found %s", wifi_config.sta.ssid); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); el_create_event(&event, EL_WIFI_EVENT_TYPE, EL_WIFI_STATUS_DISCONNECTED, 0); @@ -155,7 +155,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) el_add_event(&events, &event); break; default: - jslog(ERROR, "UNKNOWN WIFI EVENT %d\n", sysevent->event_id); + jslog(ERROR, "UNKNOWN WIFI EVENT %d", sysevent->event_id); break; } @@ -251,7 +251,7 @@ static duk_ret_t setupWifi(duk_context *ctx, bool softap) wifi_config.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; wifi_config.sta.bssid_set = true; - jslog(DEBUG, "Setting WiFi configuration SSID %s and PASS %s ...", wifi_config.sta.ssid, wifi_config.sta.password); + jslog(DEBUG, "Setting WiFi configuration SSID %s and PASS **** ...", wifi_config.sta.ssid); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); diff --git a/examples/repl.js b/examples/repl.js index 7dc29cf..77dcad2 100644 --- a/examples/repl.js +++ b/examples/repl.js @@ -12,6 +12,9 @@ * After that you can type every JS expression, which then gets * evaluated in esp32-javascript and the result is printed. * + * This is only considered as demo. If you want to use it in production + * please change the ssl flag to true, otherwise credentials + * are visible for "persons in the middle". */ var configManager = require("esp32-javascript/config"); diff --git a/package-lock.json b/package-lock.json index ffb7941..fa0812c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,424 +5,22 @@ "requires": true, "dependencies": { "@babel/cli": { - "version": "7.11.6", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.11.6.tgz", - "integrity": "sha512-+w7BZCvkewSmaRM6H4L2QM3RL90teqEIHDIFXAmrW33+0jhlymnDAEdqVeCZATvxhQuio1ifoGVlJJbIiH9Ffg==", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.14.3.tgz", + "integrity": "sha512-zU4JLvwk32ay1lhhyGfqiRUSPoltVDjhYkA3aQq8+Yby9z30s/EsFw1EPOHxWG9YZo2pAGfgdRNeHZQAYU5m9A==", "dev": true, "requires": { - "chokidar": "^2.1.8", + "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents", + "chokidar": "^3.4.0", "commander": "^4.0.1", "convert-source-map": "^1.1.0", "fs-readdir-recursive": "^1.1.0", "glob": "^7.0.0", - "lodash": "^4.17.19", "make-dir": "^2.1.0", "slash": "^2.0.0", "source-map": "^0.5.0" }, "dependencies": { - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "optional": true, - "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "optional": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "optional": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "optional": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "dev": true, - "optional": true, - "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" - } - }, - "commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "optional": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "optional": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "optional": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "optional": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "optional": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "optional": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "optional": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "optional": true, - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "optional": true, - "requires": { - "is-extglob": "^2.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "optional": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "optional": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true, - "optional": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "optional": true - }, - "slash": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", - "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", - "dev": true - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -432,77 +30,62 @@ } }, "@babel/code-frame": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", - "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", + "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", "dev": true, "requires": { - "@babel/highlight": "^7.10.1" + "@babel/highlight": "^7.12.13" } }, + "@babel/compat-data": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.14.0.tgz", + "integrity": "sha512-vu9V3uMM/1o5Hl5OekMUowo3FqXLJSw+s+66nt0fSWVWTtmosdzn45JHOB3cPtZoe6CTBDzvSw0RdOY85Q37+Q==", + "dev": true + }, "@babel/core": { - "version": "7.11.6", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.6.tgz", - "integrity": "sha512-Wpcv03AGnmkgm6uS6k8iwhIwTrcP0m17TL1n1sy7qD0qelDu4XNeW0dN0mHfa+Gei211yDaLoEe/VlbXQzM4Bg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.11.6", - "@babel/helper-module-transforms": "^7.11.0", - "@babel/helpers": "^7.10.4", - "@babel/parser": "^7.11.5", - "@babel/template": "^7.10.4", - "@babel/traverse": "^7.11.5", - "@babel/types": "^7.11.5", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.14.3.tgz", + "integrity": "sha512-jB5AmTKOCSJIZ72sd78ECEhuPiDMKlQdDI/4QRI6lzYATx5SSogS1oQA2AoPecRCknm30gHi2l+QVvNUu3wZAg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.12.13", + "@babel/generator": "^7.14.3", + "@babel/helper-compilation-targets": "^7.13.16", + "@babel/helper-module-transforms": "^7.14.2", + "@babel/helpers": "^7.14.0", + "@babel/parser": "^7.14.3", + "@babel/template": "^7.12.13", + "@babel/traverse": "^7.14.2", + "@babel/types": "^7.14.2", "convert-source-map": "^1.7.0", "debug": "^4.1.0", - "gensync": "^1.0.0-beta.1", + "gensync": "^1.0.0-beta.2", "json5": "^2.1.2", - "lodash": "^4.17.19", - "resolve": "^1.3.2", - "semver": "^5.4.1", + "semver": "^6.3.0", "source-map": "^0.5.0" }, "dependencies": { - "@babel/code-frame": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", - "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "@babel/highlight": "^7.10.4" + "ms": "2.1.2" } }, - "@babel/helper-validator-identifier": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", - "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "@babel/highlight": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", - "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.4", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "json5": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", - "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, "source-map": { @@ -514,22 +97,16 @@ } }, "@babel/generator": { - "version": "7.11.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.6.tgz", - "integrity": "sha512-DWtQ1PV3r+cLbySoHrwn9RWEgKMBLLma4OBQloPRyDYvc5msJM9kvTLo1YnlJd1P/ZuKbdli3ijr5q3FvAF3uA==", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.3.tgz", + "integrity": "sha512-bn0S6flG/j0xtQdz3hsjJ624h3W0r3llttBMfyHX3YrZ/KtLYr15bjA0FXkgW7FpvrDuTuElXeVjiKlYRpnOFA==", "dev": true, "requires": { - "@babel/types": "^7.11.5", + "@babel/types": "^7.14.2", "jsesc": "^2.5.1", "source-map": "^0.5.0" }, "dependencies": { - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -538,273 +115,275 @@ } } }, + "@babel/helper-compilation-targets": { + "version": "7.13.16", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.13.16.tgz", + "integrity": "sha512-3gmkYIrpqsLlieFwjkGgLaSHmhnvlAYzZLlYVjlW+QwI+1zE17kGxuJGmIqDQdYp56XdmGeD+Bswx0UTyG18xA==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.13.15", + "@babel/helper-validator-option": "^7.12.17", + "browserslist": "^4.14.5", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@babel/helper-function-name": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz", - "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==", + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.14.2.tgz", + "integrity": "sha512-NYZlkZRydxw+YT56IlhIcS8PAhb+FEUiOzuhFTfqDyPmzAhRge6ua0dQYT/Uh0t/EDHq05/i+e5M2d4XvjgarQ==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.10.4", - "@babel/template": "^7.10.4", - "@babel/types": "^7.10.4" + "@babel/helper-get-function-arity": "^7.12.13", + "@babel/template": "^7.12.13", + "@babel/types": "^7.14.2" } }, "@babel/helper-get-function-arity": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz", - "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.13.tgz", + "integrity": "sha512-DjEVzQNz5LICkzN0REdpD5prGoidvbdYk1BVgRUOINaWJP2t6avB27X1guXK1kXNrX0WMfsrm1A/ZBthYuIMQg==", "dev": true, "requires": { - "@babel/types": "^7.10.4" + "@babel/types": "^7.12.13" } }, "@babel/helper-member-expression-to-functions": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.11.0.tgz", - "integrity": "sha512-JbFlKHFntRV5qKw3YC0CvQnDZ4XMwgzzBbld7Ly4Mj4cbFy3KywcR8NtNctRToMWJOVvLINJv525Gd6wwVEx/Q==", + "version": "7.13.12", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.13.12.tgz", + "integrity": "sha512-48ql1CLL59aKbU94Y88Xgb2VFy7a95ykGRbJJaaVv+LX5U8wFpLfiGXJJGUozsmA1oEh/o5Bp60Voq7ACyA/Sw==", "dev": true, "requires": { - "@babel/types": "^7.11.0" + "@babel/types": "^7.13.12" } }, "@babel/helper-module-imports": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz", - "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==", + "version": "7.13.12", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.13.12.tgz", + "integrity": "sha512-4cVvR2/1B693IuOvSI20xqqa/+bl7lqAMR59R4iu39R9aOX8/JoYY1sFaNvUMyMBGnHdwvJgUrzNLoUZxXypxA==", "dev": true, "requires": { - "@babel/types": "^7.10.4" + "@babel/types": "^7.13.12" } }, "@babel/helper-module-transforms": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.11.0.tgz", - "integrity": "sha512-02EVu8COMuTRO1TAzdMtpBPbe6aQ1w/8fePD2YgQmxZU4gpNWaL9gK3Jp7dxlkUlUCJOTaSeA+Hrm1BRQwqIhg==", - "dev": true, - "requires": { - "@babel/helper-module-imports": "^7.10.4", - "@babel/helper-replace-supers": "^7.10.4", - "@babel/helper-simple-access": "^7.10.4", - "@babel/helper-split-export-declaration": "^7.11.0", - "@babel/template": "^7.10.4", - "@babel/types": "^7.11.0", - "lodash": "^4.17.19" - }, - "dependencies": { - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - } + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.14.2.tgz", + "integrity": "sha512-OznJUda/soKXv0XhpvzGWDnml4Qnwp16GN+D/kZIdLsWoHj05kyu8Rm5kXmMef+rVJZ0+4pSGLkeixdqNUATDA==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.13.12", + "@babel/helper-replace-supers": "^7.13.12", + "@babel/helper-simple-access": "^7.13.12", + "@babel/helper-split-export-declaration": "^7.12.13", + "@babel/helper-validator-identifier": "^7.14.0", + "@babel/template": "^7.12.13", + "@babel/traverse": "^7.14.2", + "@babel/types": "^7.14.2" } }, "@babel/helper-optimise-call-expression": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", - "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.12.13.tgz", + "integrity": "sha512-BdWQhoVJkp6nVjB7nkFWcn43dkprYauqtk++Py2eaf/GRDFm5BxRqEIZCiHlZUGAVmtwKcsVL1dC68WmzeFmiA==", "dev": true, "requires": { - "@babel/types": "^7.10.4" + "@babel/types": "^7.12.13" } }, "@babel/helper-replace-supers": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz", - "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.14.3.tgz", + "integrity": "sha512-Rlh8qEWZSTfdz+tgNV/N4gz1a0TMNwCUcENhMjHTHKp3LseYH5Jha0NSlyTQWMnjbYcwFt+bqAMqSLHVXkQ6UA==", "dev": true, "requires": { - "@babel/helper-member-expression-to-functions": "^7.10.4", - "@babel/helper-optimise-call-expression": "^7.10.4", - "@babel/traverse": "^7.10.4", - "@babel/types": "^7.10.4" + "@babel/helper-member-expression-to-functions": "^7.13.12", + "@babel/helper-optimise-call-expression": "^7.12.13", + "@babel/traverse": "^7.14.2", + "@babel/types": "^7.14.2" } }, "@babel/helper-simple-access": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz", - "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==", + "version": "7.13.12", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.13.12.tgz", + "integrity": "sha512-7FEjbrx5SL9cWvXioDbnlYTppcZGuCY6ow3/D5vMggb2Ywgu4dMrpTJX0JdQAIcRRUElOIxF3yEooa9gUb9ZbA==", "dev": true, "requires": { - "@babel/template": "^7.10.4", - "@babel/types": "^7.10.4" + "@babel/types": "^7.13.12" } }, "@babel/helper-split-export-declaration": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz", - "integrity": "sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.12.13.tgz", + "integrity": "sha512-tCJDltF83htUtXx5NLcaDqRmknv652ZWCHyoTETf1CXYJdPC7nohZohjUgieXhv0hTJdRf2FjDueFehdNucpzg==", "dev": true, "requires": { - "@babel/types": "^7.11.0" + "@babel/types": "^7.12.13" } }, "@babel/helper-validator-identifier": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", - "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz", + "integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==", + "dev": true + }, + "@babel/helper-validator-option": { + "version": "7.12.17", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.12.17.tgz", + "integrity": "sha512-TopkMDmLzq8ngChwRlyjR6raKD6gMSae4JdYDB8bByKreQgG0RBTuKe9LRxW3wFtUnjxOPRKBDwEH6Mg5KeDfw==", "dev": true }, "@babel/helpers": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz", - "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.14.0.tgz", + "integrity": "sha512-+ufuXprtQ1D1iZTO/K9+EBRn+qPWMJjZSw/S0KlFrxCw4tkrzv9grgpDHkY9MeQTjTY8i2sp7Jep8DfU6tN9Mg==", "dev": true, "requires": { - "@babel/template": "^7.10.4", - "@babel/traverse": "^7.10.4", - "@babel/types": "^7.10.4" + "@babel/template": "^7.12.13", + "@babel/traverse": "^7.14.0", + "@babel/types": "^7.14.0" } }, "@babel/highlight": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", - "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.0.tgz", + "integrity": "sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.10.1", + "@babel/helper-validator-identifier": "^7.14.0", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.11.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.5.tgz", - "integrity": "sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==", + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.3.tgz", + "integrity": "sha512-7MpZDIfI7sUC5zWo2+foJ50CSI5lcqDehZ0lVgIhSi4bFEk94fLAKlF3Q0nzSQQ+ca0lm+O6G9ztKVBeu8PMRQ==", "dev": true }, "@babel/template": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz", - "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.12.13.tgz", + "integrity": "sha512-/7xxiGA57xMo/P2GVvdEumr8ONhFOhfgq2ihK3h1e6THqzTAkHbkXgB0xI9yeTfIUoH3+oAeHhqm/I43OTbbjA==", "dev": true, "requires": { - "@babel/code-frame": "^7.10.4", - "@babel/parser": "^7.10.4", - "@babel/types": "^7.10.4" - }, - "dependencies": { - "@babel/code-frame": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", - "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.10.4" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", - "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", - "dev": true - }, - "@babel/highlight": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", - "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.4", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - } + "@babel/code-frame": "^7.12.13", + "@babel/parser": "^7.12.13", + "@babel/types": "^7.12.13" } }, "@babel/traverse": { - "version": "7.11.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.11.5.tgz", - "integrity": "sha512-EjiPXt+r7LiCZXEfRpSJd+jUMnBd4/9OUv7Nx3+0u9+eimMwJmG0Q98lw4/289JCoxSE8OolDMNZaaF/JZ69WQ==", + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.14.2.tgz", + "integrity": "sha512-TsdRgvBFHMyHOOzcP9S6QU0QQtjxlRpEYOy3mcCO5RgmC305ki42aSAmfZEMSSYBla2oZ9BMqYlncBaKmD/7iA==", "dev": true, "requires": { - "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.11.5", - "@babel/helper-function-name": "^7.10.4", - "@babel/helper-split-export-declaration": "^7.11.0", - "@babel/parser": "^7.11.5", - "@babel/types": "^7.11.5", + "@babel/code-frame": "^7.12.13", + "@babel/generator": "^7.14.2", + "@babel/helper-function-name": "^7.14.2", + "@babel/helper-split-export-declaration": "^7.12.13", + "@babel/parser": "^7.14.2", + "@babel/types": "^7.14.2", "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.19" + "globals": "^11.1.0" }, "dependencies": { - "@babel/code-frame": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", - "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "@babel/highlight": "^7.10.4" + "ms": "2.1.2" } }, - "@babel/helper-validator-identifier": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", - "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", - "dev": true - }, - "@babel/highlight": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", - "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.4", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } }, "@babel/types": { - "version": "7.11.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.11.5.tgz", - "integrity": "sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q==", + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.2.tgz", + "integrity": "sha512-SdjAG/3DikRHpUOjxZgnkbR11xUlyDMUFJdvnIgZEE16mqmY0BINMmc4//JMJglEmn6i7sq6p+mGrFWyZ98EEw==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.10.4", - "lodash": "^4.17.19", + "@babel/helper-validator-identifier": "^7.14.0", "to-fast-properties": "^2.0.0" + } + }, + "@eslint/eslintrc": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.1.tgz", + "integrity": "sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" }, "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", - "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", - "dev": true + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", - "dev": true + "@nicolo-ribaudo/chokidar-2": { + "version": "2.1.8-no-fsevents", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.tgz", + "integrity": "sha512-+nb9vWloHNNMFHjGofEam3wopE3m1yuambrrd/fnPc+lFOMB9ROTqQlche9ByFWNkdNqfSgR/kkQtQ8DzEWt2w==", + "dev": true, + "optional": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } }, "@types/eslint-visitor-keys": { "version": "1.0.0", @@ -813,18 +392,18 @@ "dev": true }, "@types/json-schema": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", - "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==", + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.6.0.tgz", - "integrity": "sha512-ubHlHVt1lsPQB/CZdEov9XuOFhNG9YRC//kuiS1cMQI6Bs1SsqKrEmZnpgRwthGR09/kEDtr9MywlqXyyYd8GA==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz", + "integrity": "sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "3.6.0", + "@typescript-eslint/experimental-utils": "3.10.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -832,63 +411,72 @@ "tsutils": "^3.17.1" }, "dependencies": { - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "tsutils": { - "version": "3.17.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", - "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { - "tslib": "^1.8.1" + "lru-cache": "^6.0.0" } } } }, "@typescript-eslint/experimental-utils": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.6.0.tgz", - "integrity": "sha512-4Vdf2hvYMUnTdkCNZu+yYlFtL2v+N2R7JOynIOkFbPjf9o9wQvRwRkzUdWlFd2YiiUwJLbuuLnl5civNg5ykOQ==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz", + "integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/typescript-estree": "3.6.0", + "@typescript-eslint/types": "3.10.1", + "@typescript-eslint/typescript-estree": "3.10.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.6.0.tgz", - "integrity": "sha512-taghDxuLhbDAD1U5Fk8vF+MnR0yiFE9Z3v2/bYScFb0N1I9SK8eKHkdJl1DAD48OGFDMFTeOTX0z7g0W6SYUXw==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz", + "integrity": "sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.6.0", - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/typescript-estree": "3.6.0", + "@typescript-eslint/experimental-utils": "3.10.1", + "@typescript-eslint/types": "3.10.1", + "@typescript-eslint/typescript-estree": "3.10.1", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/types": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.6.0.tgz", - "integrity": "sha512-JwVj74ohUSt0ZPG+LZ7hb95fW8DFOqBuR6gE7qzq55KDI3BepqsCtHfBIoa0+Xi1AI7fq5nCu2VQL8z4eYftqg==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz", + "integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.6.0.tgz", - "integrity": "sha512-G57NDSABHjvob7zVV09ehWyD1K6/YUKjz5+AufObFyjNO4DVmKejj47MHjVHHlZZKgmpJD2yyH9lfCXHrPITFg==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz", + "integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==", "dev": true, "requires": { - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/visitor-keys": "3.6.0", + "@typescript-eslint/types": "3.10.1", + "@typescript-eslint/visitor-keys": "3.10.1", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -897,48 +485,57 @@ "tsutils": "^3.17.1" }, "dependencies": { - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "tsutils": { - "version": "3.17.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", - "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { - "tslib": "^1.8.1" + "lru-cache": "^6.0.0" } } } }, "@typescript-eslint/visitor-keys": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.6.0.tgz", - "integrity": "sha512-p1izllL2Ubwunite0ITjubuMQRBGgjdVYwyG7lXPX8GbrA6qF0uwSRz9MnXZaHMxID4948gX0Ez8v9tUDi/KfQ==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz", + "integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" } }, "acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-jsx": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", - "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, "ajv": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", - "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -968,6 +565,29 @@ "color-convert": "^1.9.0" } }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -977,6 +597,13 @@ "sprintf-js": "~1.0.2" } }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true, + "optional": true + }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", @@ -991,6 +618,13 @@ "dev": true, "optional": true }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true, + "optional": true + }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -999,9 +633,9 @@ "optional": true }, "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, "async-each": { @@ -1011,6 +645,12 @@ "dev": true, "optional": true }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -1320,13 +960,6 @@ "is-data-descriptor": "^1.0.0", "kind-of": "^6.0.2" } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true } } }, @@ -1337,16 +970,6 @@ "dev": true, "optional": true }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dev": true, - "optional": true, - "requires": { - "file-uri-to-path": "1.0.0" - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1357,6 +980,50 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "optional": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browserslist": { + "version": "4.16.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz", + "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001219", + "colorette": "^1.2.2", + "electron-to-chromium": "^1.3.723", + "escalade": "^3.1.1", + "node-releases": "^1.1.71" + } + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1373,15 +1040,6 @@ "to-object-path": "^0.3.0", "union-value": "^1.0.0", "unset-value": "^1.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - } } }, "callsites": { @@ -1390,6 +1048,12 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "caniuse-lite": { + "version": "1.0.30001228", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", + "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", + "dev": true + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -1401,6 +1065,110 @@ "supports-color": "^5.3.0" } }, + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "optional": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + }, + "dependencies": { + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "optional": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "optional": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "optional": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "optional": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "optional": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "optional": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "optional": true + }, + "readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dev": true, + "optional": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "optional": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -1423,13 +1191,6 @@ "requires": { "is-descriptor": "^0.1.0" } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true } } }, @@ -1459,6 +1220,18 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "colorette": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz", + "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", + "dev": true + }, + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -2098,12 +1871,13 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, + "optional": true, "requires": { - "ms": "^2.1.1" + "ms": "2.0.0" } }, "decode-uri-component": { @@ -2161,13 +1935,6 @@ "is-data-descriptor": "^1.0.0", "kind-of": "^6.0.2" } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true } } }, @@ -2180,10 +1947,16 @@ "esutils": "^2.0.2" } }, + "electron-to-chromium": { + "version": "1.3.734", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.734.tgz", + "integrity": "sha512-iQF2mjPZ6zNNq45kbJ6MYZYCBNdv2JpGiJC/lVx4tGJWi9MNg73KkL9sWGN4X4I/CP2SBLWsT8nPADZZpAHIyw==", + "dev": true + }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "enquirer": { @@ -2195,6 +1968,12 @@ "ansi-colors": "^4.1.1" } }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -2202,28 +1981,29 @@ "dev": true }, "eslint": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.4.0.tgz", - "integrity": "sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.26.0.tgz", + "integrity": "sha512-4R1ieRf52/izcZE7AlLy56uIHHDLT74Yzz2Iv2l6kDaYvEu9x+wMB5dZArVL8SYGXSYV2YAg70FcW5Y5nGGNIg==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", + "@eslint/eslintrc": "^0.4.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", "enquirer": "^2.3.5", - "eslint-scope": "^5.1.0", - "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.2.0", - "espree": "^7.1.0", - "esquery": "^1.2.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.4.0", "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", + "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", - "globals": "^12.1.0", + "globals": "^13.6.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", @@ -2231,7 +2011,7 @@ "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", - "lodash": "^4.17.14", + "lodash": "^4.17.21", "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", @@ -2240,25 +2020,33 @@ "semver": "^7.2.1", "strip-ansi": "^6.0.0", "strip-json-comments": "^3.1.0", - "table": "^5.2.3", + "table": "^6.0.4", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { + "@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2280,42 +2068,90 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "13.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.8.0.tgz", + "integrity": "sha512-rHtdA6+PDBIjeEvA91rpqzEvk/k3/i7EeNQiryiWuJH0Hw9cpyJMAt2jtbAwUaRdhD+573X4vWw6IcjKPasi9Q==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true } } }, "eslint-plugin-inclusive-language": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-inclusive-language/-/eslint-plugin-inclusive-language-1.2.0.tgz", - "integrity": "sha512-RNCQNqeMaiUT0nYpVEzdlF2ZTig7cU3C4wdt/6tzkfiD439DYH/QTRvwc73t2aiW5z9U7WntKXo3saTjqTiDYg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-inclusive-language/-/eslint-plugin-inclusive-language-1.2.1.tgz", + "integrity": "sha512-WFXME2g/rEm/ex9HCfptZXJVm6/IrBks4+0rZft24zve4RH196PPuCFvd36aidc2IaHrvVAZHeyahODc7ueoNw==", "dev": true }, "eslint-scope": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", - "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, "requires": { - "esrecurse": "^4.1.0", + "esrecurse": "^4.3.0", "estraverse": "^4.1.1" } }, @@ -2335,14 +2171,14 @@ "dev": true }, "espree": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.1.0.tgz", - "integrity": "sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", "dev": true, "requires": { - "acorn": "^7.2.0", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.2.0" + "acorn": "^7.4.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^1.3.0" } }, "esprima": { @@ -2352,34 +2188,42 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" }, "dependencies": { "estraverse": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz", - "integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", "dev": true } } }, "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "requires": { - "estraverse": "^4.1.0" - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, @@ -2389,6 +2233,44 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "optional": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "optional": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", @@ -2412,6 +2294,77 @@ } } }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "optional": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "optional": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "optional": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "optional": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "optional": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2431,36 +2384,53 @@ "dev": true }, "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "requires": { - "flat-cache": "^2.0.1" + "flat-cache": "^3.0.4" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, - "optional": true + "optional": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } }, "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" + "flatted": "^3.1.0", + "rimraf": "^3.0.2" } }, "flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", + "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, "for-in": { @@ -2504,15 +2474,11 @@ "dev": true }, "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } + "optional": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -2521,9 +2487,9 @@ "dev": true }, "gensync": { - "version": "1.0.0-beta.1", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", - "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true }, "get-value": { @@ -2548,31 +2514,34 @@ } }, "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, + "optional": true, "requires": { - "type-fest": "^0.8.1" + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" }, "dependencies": { - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } } } }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, "graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", @@ -2608,15 +2577,6 @@ "get-value": "^2.0.6", "has-values": "^1.0.0", "isobject": "^3.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - } } }, "has-values": { @@ -2630,28 +2590,6 @@ "kind-of": "^4.0.0" }, "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "kind-of": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", @@ -2677,9 +2615,9 @@ "dev": true }, "import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -2810,9 +2748,9 @@ "dev": true }, "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, "is-glob": { @@ -2824,6 +2762,28 @@ "is-extglob": "^2.1.1" } }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "optional": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "optional": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -2832,15 +2792,6 @@ "optional": true, "requires": { "isobject": "^3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - } } }, "is-windows": { @@ -2863,6 +2814,13 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true, + "optional": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -2870,15 +2828,21 @@ "dev": true }, "js-yaml": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", - "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -2891,6 +2855,15 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, + "json5": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -2923,6 +2896,27 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, "lunr": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", @@ -2962,6 +2956,28 @@ "integrity": "sha512-Wo+L1pWTVibfrSr+TTtMuiMfNzmZWiOPeO7rZsQUY5bgsxpHesBEcIWJloWVTFnrMXnf/TL30eTFSGJddmQAng==", "dev": true }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "optional": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -3000,25 +3016,10 @@ } } }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "nan": { - "version": "2.14.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true, "optional": true }, @@ -3040,22 +3041,6 @@ "regex-not": "^1.0.0", "snapdragon": "^0.8.1", "to-regex": "^3.0.1" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "optional": true - } } }, "natural-compare": { @@ -3070,6 +3055,19 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node-releases": { + "version": "1.1.72", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.72.tgz", + "integrity": "sha512-LLUo+PpH3dU6XizX3iVoubUNheF/owjXCZZ5yACDxNnPtgFuludV1ZL3ayK1kVep42Rmm0+R9/Y60NQbZ2bifw==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "optional": true + }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", @@ -3112,15 +3110,6 @@ "optional": true, "requires": { "isobject": "^3.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - } } }, "object.pick": { @@ -3131,457 +3120,143 @@ "optional": true, "requires": { "isobject": "^3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - } } }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true, - "optional": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true, - "optional": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true, - "optional": true - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true, - "optional": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", - "dev": true, - "optional": true, - "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "optional": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "optional": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "optional": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "optional": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "optional": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "optional": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "optional": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "optional": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "optional": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "optional": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "optional": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "optional": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true, - "optional": true - } + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true, + "optional": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true, + "optional": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "picomatch": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", + "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==", + "dev": true, + "optional": true + }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true, + "optional": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "optional": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" } }, "rechoir": { @@ -3618,9 +3293,9 @@ "optional": true }, "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz", + "integrity": "sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==", "dev": true, "optional": true }, @@ -3631,6 +3306,12 @@ "dev": true, "optional": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", @@ -3661,9 +3342,9 @@ "optional": true }, "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { "glob": "^7.1.3" @@ -3742,15 +3423,47 @@ "rechoir": "^0.6.2" } }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } } }, "snapdragon": { @@ -3770,16 +3483,6 @@ "use": "^3.1.0" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", @@ -3800,13 +3503,6 @@ "is-extendable": "^0.1.0" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true, - "optional": true - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -3869,13 +3565,6 @@ "is-data-descriptor": "^1.0.0", "kind-of": "^6.0.2" } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true } } }, @@ -3922,9 +3611,9 @@ } }, "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", + "integrity": "sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==", "dev": true, "optional": true }, @@ -3968,31 +3657,14 @@ } }, "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", "dev": true, "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" } }, "string_decoder": { @@ -4015,9 +3687,9 @@ } }, "strip-json-comments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", - "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, "supports-color": { @@ -4030,15 +3702,37 @@ } }, "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", + "integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==", "dev": true, "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" + "ajv": "^8.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.truncate": "^4.4.2", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.4.0.tgz", + "integrity": "sha512-7QD2l6+KBSLwf+7MuYocbWvRPdOu63/trReTLu2KFwkgctnub1auoF+Y1WYcm09CTM7quuscrzqmASaLHC/K4Q==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + } } }, "text-table": { @@ -4047,6 +3741,12 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -4091,36 +3791,23 @@ "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - } } }, "tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -4130,6 +3817,12 @@ "prelude-ls": "^1.2.1" } }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "typedoc": { "version": "0.17.8", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.17.8.tgz", @@ -4158,19 +3851,49 @@ } }, "typedoc-plugin-markdown": { - "version": "2.2.17", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.2.17.tgz", - "integrity": "sha512-eE6cTeqsZIbjur6RG91Lhx1vTwjR49OHwVPRlmsxY3dthS4FNRL8sHxT5Y9pkosBwv1kSmNGQEPHjMYy1Ag6DQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.4.2.tgz", + "integrity": "sha512-BBH+9/Uq5XbsqfzCDl8Jq4iaLXRMXRuAHZRFarAZX7df8+F3vUjDx/WHWoWqbZ/XUFzduLC2Iuy2qwsJX8SQ7A==", "dev": true, "requires": { - "fs-extra": "^8.1.0", - "handlebars": "^4.7.3" + "fs-extra": "^9.0.1", + "handlebars": "^4.7.6" + }, + "dependencies": { + "fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + } } }, "typescript": { - "version": "3.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", - "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", + "version": "3.9.9", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz", + "integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==", "dev": true }, "uglify-js": { @@ -4240,13 +3963,6 @@ "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", "dev": true, "optional": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true } } }, @@ -4258,9 +3974,9 @@ "optional": true }, "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "requires": { "punycode": "^2.1.0" @@ -4288,9 +4004,9 @@ "optional": true }, "v8-compile-cache": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", - "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, "which": { @@ -4320,14 +4036,11 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } } diff --git a/package.json b/package.json index ac98b9e..11b7e3d 100644 --- a/package.json +++ b/package.json @@ -17,17 +17,17 @@ }, "homepage": "https://github.com/marcelkottmann/esp32-javascript#readme", "devDependencies": { - "@babel/cli": "^7.11.6", - "@babel/core": "^7.11.6", - "@typescript-eslint/eslint-plugin": "^3.6.0", - "@typescript-eslint/parser": "^3.6.0", + "@babel/cli": "^7.14.3", + "@babel/core": "^7.14.3", + "@typescript-eslint/eslint-plugin": "^3.10.1", + "@typescript-eslint/parser": "^3.10.1", "babel-plugin-transform-remove-console": "^6.9.4", "babel-preset-minify": "^0.5.1", "cp2": "file:scripts/cp2", - "eslint": "^7.4.0", - "eslint-plugin-inclusive-language": "^1.2.0", + "eslint": "^7.26.0", + "eslint-plugin-inclusive-language": "^1.2.1", "typedoc": "^0.17.8", - "typedoc-plugin-markdown": "^2.2.17", - "typescript": "^3.8.3" + "typedoc-plugin-markdown": "^2.4.2", + "typescript": "^3.9.9" } } diff --git a/partitions.csv b/partitions2MB.csv similarity index 100% rename from partitions.csv rename to partitions2MB.csv diff --git a/partitions4MB.csv b/partitions4MB.csv new file mode 100644 index 0000000..f9360e4 --- /dev/null +++ b/partitions4MB.csv @@ -0,0 +1,10 @@ +# Espressif ESP32 Partition Table +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x4000, +otadata, data, ota, 0xd000, 0x2000, +phy_init, data, phy, 0xf000, 0x1000, +ota_0, app, ota_0, 0x10000, 0x1B0000, +ota_1, app, ota_1, , 0x1B0000, +modules, data, spiffs, , 0x30000, +modules_1, data, spiffs, , 0x30000, +data, data, spiffs, , 0x30000, diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 0627033..4582ca9 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -113,8 +113,8 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # CONFIG_PARTITION_TABLE_SINGLE_APP is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions4MB.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions4MB.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table @@ -123,8 +123,8 @@ CONFIG_PARTITION_TABLE_MD5=y # Compiler options # # CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -CONFIG_COMPILER_OPTIMIZATION_PERF=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set # CONFIG_COMPILER_OPTIMIZATION_NONE is not set # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set From 7586cedb57b9d2d62bad75f7d68a8ffdd93f5ed6 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sat, 22 May 2021 21:52:10 +0200 Subject: [PATCH 03/19] chore: change logging levels --- components/esp32-javascript/modules/esp32-javascript/boot.ts | 4 ++-- components/socket-events/modules/socket-events/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.ts b/components/esp32-javascript/modules/esp32-javascript/boot.ts index 7e16559..1ea2db6 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.ts +++ b/components/esp32-javascript/modules/esp32-javascript/boot.ts @@ -127,7 +127,7 @@ function connectToWifi() { let retries = 0; wifi.connectWifi(config.wifi.ssid, config.wifi.password, function (evt, ip) { if (evt.status === 0) { - console.info("WIFI: DISCONNECTED"); + console.debug("WIFI: DISCONNECTED"); if (!configServerStarted) { retries++; } @@ -191,7 +191,7 @@ function connectToWifi() { } } } else if (evt.status === 2) { - console.info("WIFI: CONNECTING..."); + console.debug("WIFI: CONNECTING..."); } }); } diff --git a/components/socket-events/modules/socket-events/index.ts b/components/socket-events/modules/socket-events/index.ts index 19bc872..5b0e346 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -118,7 +118,7 @@ class Socket implements Esp32JsSocket { this.clearReadTimeoutTimer(); if (this.readTimeout > 0) { this.readTimeoutHandle = setTimeout(() => { - console.log("Close socket because of read timeout."); + console.debug("Close socket because of read timeout."); closeSocket(this); }, this.readTimeout); } From 69db17ed370e62ab93fc1ce55810a2563b71b11e Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sun, 23 May 2021 21:10:54 +0200 Subject: [PATCH 04/19] chore: update license texts --- LICENSE | 2 +- .../duk_module_load_bindings.c | 23 +++ .../esp32-javascript/esp32-javascript.c | 2 +- .../include/esp32-javascript.h | 2 +- .../modules/esp32-javascript/boot.js | 27 +++- .../modules/esp32-javascript/boot.ts | 23 +++ .../modules/esp32-javascript/chunked.js | 23 +++ .../modules/esp32-javascript/chunked.ts | 23 +++ .../modules/esp32-javascript/config.js | 23 +++ .../modules/esp32-javascript/config.ts | 23 +++ .../modules/esp32-javascript/configserver.js | 23 +++ .../modules/esp32-javascript/configserver.ts | 23 +++ .../esp32-javascript/firmware-config.ts | 23 +++ .../modules/esp32-javascript/global.js | 23 +++ .../modules/esp32-javascript/global.ts | 24 +++ .../modules/esp32-javascript/http.js | 138 +++-------------- .../modules/esp32-javascript/http.ts | 139 +++--------------- .../modules/esp32-javascript/index.js | 23 +++ .../modules/esp32-javascript/index.ts | 23 +++ .../modules/esp32-javascript/native-ota.js | 23 +++ .../modules/esp32-javascript/native-ota.ts | 23 +++ .../modules/esp32-javascript/require.d.ts | 23 +++ .../self-test-firmware-config.ts | 23 +++ .../modules/esp32-javascript/self-test.js | 23 +++ .../modules/esp32-javascript/self-test.ts | 23 +++ .../modules/esp32-javascript/stringbuffer.js | 23 +++ .../modules/esp32-javascript/stringbuffer.ts | 23 +++ .../modules/esp32-js-eventloop/index.ts | 23 +++ components/esp32-javascript/urlparse.ts | 23 +++ .../esp32-js-log/include/esp32-js-log.h | 2 +- .../socket-events/include/socket-events.h | 2 +- components/socket-events/include/tcp.h | 2 +- .../modules/socket-events/index.js | 25 +++- .../modules/socket-events/index.ts | 23 +++ components/socket-events/socket-events.c | 2 +- components/socket-events/tcp.c | 2 +- components/spiffs-events/spiffs-events.c | 2 +- components/wifi-events/include/wifi-events.h | 2 +- .../wifi-events/modules/wifi-events/index.js | 23 +++ .../wifi-events/modules/wifi-events/index.ts | 23 +++ components/wifi-events/wifi-events.c | 2 +- main/include/esp32-javascript-config.h | 2 +- main/main.c | 2 +- 43 files changed, 707 insertions(+), 247 deletions(-) diff --git a/LICENSE b/LICENSE index 0e436b0..df7d316 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/duk-module-node/duk_module_load_bindings.c b/components/duk-module-node/duk_module_load_bindings.c index 65b4bbe..d3fd36a 100644 --- a/components/duk-module-node/duk_module_load_bindings.c +++ b/components/duk-module-node/duk_module_load_bindings.c @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ #include "duktape.h" #include "duk_module_node.h" #include "esp32-javascript.h" diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 680e454..62c671a 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/esp32-javascript/include/esp32-javascript.h b/components/esp32-javascript/include/esp32-javascript.h index 0f00de5..199901a 100644 --- a/components/esp32-javascript/include/esp32-javascript.h +++ b/components/esp32-javascript/include/esp32-javascript.h @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.js b/components/esp32-javascript/modules/esp32-javascript/boot.js index 8233723..afe096d 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.js +++ b/components/esp32-javascript/modules/esp32-javascript/boot.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.main = exports.getBootTime = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var wifi = require("wifi-events"); var configServer = require("./configserver"); var config_1 = require("./config"); @@ -117,7 +140,7 @@ function connectToWifi() { wifi.connectWifi(config_1.config.wifi.ssid, config_1.config.wifi.password, function (evt, ip) { var _a, _b; if (evt.status === 0) { - console.info("WIFI: DISCONNECTED"); + console.debug("WIFI: DISCONNECTED"); if (!configServerStarted) { retries++; } @@ -182,7 +205,7 @@ function connectToWifi() { } } else if (evt.status === 2) { - console.info("WIFI: CONNECTING..."); + console.debug("WIFI: CONNECTING..."); } }); } diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.ts b/components/esp32-javascript/modules/esp32-javascript/boot.ts index 1ea2db6..56fe564 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.ts +++ b/components/esp32-javascript/modules/esp32-javascript/boot.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import wifi = require("wifi-events"); import configServer = require("./configserver"); import { config, saveConfig } from "./config"; diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.js b/components/esp32-javascript/modules/esp32-javascript/chunked.js index 0ada59c..c9e7222 100644 --- a/components/esp32-javascript/modules/esp32-javascript/chunked.js +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createChunkedEncodingConsumer = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var READ_CR = 0; var READ_LF = 1; var READ_LEN = 2; diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.ts b/components/esp32-javascript/modules/esp32-javascript/chunked.ts index ce44a41..91002d1 100644 --- a/components/esp32-javascript/modules/esp32-javascript/chunked.ts +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ const READ_CR = 0; const READ_LF = 1; const READ_LEN = 2; diff --git a/components/esp32-javascript/modules/esp32-javascript/config.js b/components/esp32-javascript/modules/esp32-javascript/config.js index 2def187..98aa322 100644 --- a/components/esp32-javascript/modules/esp32-javascript/config.js +++ b/components/esp32-javascript/modules/esp32-javascript/config.js @@ -3,6 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.saveConfig = exports.reloadConfig = exports.config = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var firmware_config_1 = __importDefault(require("./firmware-config")); var CONFIG_PATH = "/data/config.js"; function reloadConfig() { diff --git a/components/esp32-javascript/modules/esp32-javascript/config.ts b/components/esp32-javascript/modules/esp32-javascript/config.ts index 62dc9e1..b3106eb 100644 --- a/components/esp32-javascript/modules/esp32-javascript/config.ts +++ b/components/esp32-javascript/modules/esp32-javascript/config.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import firmwareConfig from "./firmware-config"; export interface Esp32JsConfig { access: { diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index 9112c0a..cb27fa9 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -11,6 +11,29 @@ var __assign = (this && this.__assign) || function () { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.startConfigServer = exports.redirect = exports.baExceptionPathes = exports.requestHandler = exports.addSchema = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var configManager = require("./config"); var boot_1 = require("./boot"); var http_1 = require("./http"); diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index 0d06a9a..63f4de2 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import configManager = require("./config"); import { getBootTime } from "./boot"; diff --git a/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts b/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts index d097ead..825d4dc 100644 --- a/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts +++ b/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { Esp32JsConfig } from "./config"; const firmwareConfig: Esp32JsConfig = { diff --git a/components/esp32-javascript/modules/esp32-javascript/global.js b/components/esp32-javascript/modules/esp32-javascript/global.js index 654ea50..d04b38a 100644 --- a/components/esp32-javascript/modules/esp32-javascript/global.js +++ b/components/esp32-javascript/modules/esp32-javascript/global.js @@ -1 +1,24 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ globalThis.global = globalThis; diff --git a/components/esp32-javascript/modules/esp32-javascript/global.ts b/components/esp32-javascript/modules/esp32-javascript/global.ts index 4b49161..169cd5f 100644 --- a/components/esp32-javascript/modules/esp32-javascript/global.ts +++ b/components/esp32-javascript/modules/esp32-javascript/global.ts @@ -1,3 +1,27 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + /* eslint-disable no-var */ declare var global: any; (globalThis as any).global = globalThis; diff --git a/components/esp32-javascript/modules/esp32-javascript/http.js b/components/esp32-javascript/modules/esp32-javascript/http.js index c710e0f..cc13775 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.js +++ b/components/esp32-javascript/modules/esp32-javascript/http.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.XMLHttpRequest = exports.getDefaultPort = exports.httpClient = exports.parseQueryStr = exports.decodeQueryParam = exports.httpServer = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var socketEvents = require("socket-events"); var chunked_1 = require("./chunked"); var stringbuffer_1 = require("./stringbuffer"); @@ -287,121 +310,6 @@ function parseQueryStr(query) { return parsed; } exports.parseQueryStr = parseQueryStr; -/*export function httpClient( - ssl: boolean, - host: string, - port: string, - path: string, - method: string, - requestHeaders?: string, - body?: { toString: () => string }, - successCB?: (content: string, headers: string) => void, - errorCB?: (message: string) => void, - finishCB?: () => void, - dataCB?: (data: Uint8Array) => void -): void { - const complete: StringBuffer = new StringBuffer(); - let completeLength = 0; - let chunked = false; - let headerRead = false; - let headerEnd = -1; - let contentLength = -1; - requestHeaders = requestHeaders || ""; - if (!errorCB) { - errorCB = print; - } - - const textDecoder = new TextDecoder(); - - sockConnect( - ssl, - host, - port, - function (socket) { - const bodyStr = body ? body.toString() : null; - - const requestLines = `${method} ${path} HTTP/1.1\r\nHost: ${host}\r\n${ - bodyStr ? `Content-length: ${bodyStr.length}\r\n` : "" - }${requestHeaders}\r\n${bodyStr ? bodyStr + "\r\n" : ""}`; - - socket.write(requestLines); - socket.flush(); - }, - function (data, sockfd, length) { - dataCB && dataCB(data); - - complete.append(textDecoder.decode(data)); - completeLength = completeLength + length; - - if (!headerRead && (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { - headerRead = true; - chunked = - complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; - const clIndex = complete.toLowerCase().indexOf("content-length: "); - if (clIndex >= 0) { - const endOfContentLength = complete.indexOf("\r\n", clIndex); - contentLength = parseInt( - complete.substring(clIndex + 15, endOfContentLength).toString() - ); - } - headerEnd += 4; - } - - if (chunked) { - if (complete.substring(complete.length - 5).toString() == "0\r\n\r\n") { - closeSocket(sockfd); - } - } - if (contentLength >= 0) { - if (completeLength - headerEnd == contentLength) { - closeSocket(sockfd); - } - } - }, - function () { - if (errorCB) { - errorCB( - `Could not load ${ssl ? "https" : "http"}://${host}:${port}${path}` - ); - } - }, - function () { - let startFrom = headerEnd; - let content = null; - - if (chunked) { - content = new StringBuffer(); - - let chunkLength; - do { - const chunkLengthEnd = complete.indexOf("\r\n", startFrom); - const lengthStr = complete - .substring(startFrom, chunkLengthEnd) - .toString(); - chunkLength = parseInt(lengthStr, 16); - const chunkEnd = chunkLengthEnd + chunkLength + 2; - - content.append(complete.substring(chunkLengthEnd + 2, chunkEnd)); - startFrom = chunkEnd + 2; - } while (chunkLength > 0); - } else { - content = complete.substring(startFrom); - } - - const headers = complete.substring(0, headerEnd); - - if (successCB) { - successCB(content.toString(), headers.toString()); - } - //free complete for GC - content = null; - if (finishCB) { - finishCB(); - } - } - ); -} -*/ function httpClient(ssl, host, port, path, method, requestHeaders, body, successCB, // this is removed in favor of the new data and head callback (dataCB, headCB) errorCB, finishCB, dataCB, headCB) { if (successCB) { diff --git a/components/esp32-javascript/modules/esp32-javascript/http.ts b/components/esp32-javascript/modules/esp32-javascript/http.ts index 5354279..4453346 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.ts +++ b/components/esp32-javascript/modules/esp32-javascript/http.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import socketEvents = require("socket-events"); import { ChunkedEncodingConsumer, @@ -375,122 +398,6 @@ export function parseQueryStr(query: string | null): { [key: string]: string } { return parsed; } -/*export function httpClient( - ssl: boolean, - host: string, - port: string, - path: string, - method: string, - requestHeaders?: string, - body?: { toString: () => string }, - successCB?: (content: string, headers: string) => void, - errorCB?: (message: string) => void, - finishCB?: () => void, - dataCB?: (data: Uint8Array) => void -): void { - const complete: StringBuffer = new StringBuffer(); - let completeLength = 0; - let chunked = false; - let headerRead = false; - let headerEnd = -1; - let contentLength = -1; - requestHeaders = requestHeaders || ""; - if (!errorCB) { - errorCB = print; - } - - const textDecoder = new TextDecoder(); - - sockConnect( - ssl, - host, - port, - function (socket) { - const bodyStr = body ? body.toString() : null; - - const requestLines = `${method} ${path} HTTP/1.1\r\nHost: ${host}\r\n${ - bodyStr ? `Content-length: ${bodyStr.length}\r\n` : "" - }${requestHeaders}\r\n${bodyStr ? bodyStr + "\r\n" : ""}`; - - socket.write(requestLines); - socket.flush(); - }, - function (data, sockfd, length) { - dataCB && dataCB(data); - - complete.append(textDecoder.decode(data)); - completeLength = completeLength + length; - - if (!headerRead && (headerEnd = complete.indexOf("\r\n\r\n")) >= 0) { - headerRead = true; - chunked = - complete.toLowerCase().indexOf("transfer-encoding: chunked") >= 0; - const clIndex = complete.toLowerCase().indexOf("content-length: "); - if (clIndex >= 0) { - const endOfContentLength = complete.indexOf("\r\n", clIndex); - contentLength = parseInt( - complete.substring(clIndex + 15, endOfContentLength).toString() - ); - } - headerEnd += 4; - } - - if (chunked) { - if (complete.substring(complete.length - 5).toString() == "0\r\n\r\n") { - closeSocket(sockfd); - } - } - if (contentLength >= 0) { - if (completeLength - headerEnd == contentLength) { - closeSocket(sockfd); - } - } - }, - function () { - if (errorCB) { - errorCB( - `Could not load ${ssl ? "https" : "http"}://${host}:${port}${path}` - ); - } - }, - function () { - let startFrom = headerEnd; - let content = null; - - if (chunked) { - content = new StringBuffer(); - - let chunkLength; - do { - const chunkLengthEnd = complete.indexOf("\r\n", startFrom); - const lengthStr = complete - .substring(startFrom, chunkLengthEnd) - .toString(); - chunkLength = parseInt(lengthStr, 16); - const chunkEnd = chunkLengthEnd + chunkLength + 2; - - content.append(complete.substring(chunkLengthEnd + 2, chunkEnd)); - startFrom = chunkEnd + 2; - } while (chunkLength > 0); - } else { - content = complete.substring(startFrom); - } - - const headers = complete.substring(0, headerEnd); - - if (successCB) { - successCB(content.toString(), headers.toString()); - } - //free complete for GC - content = null; - if (finishCB) { - finishCB(); - } - } - ); -} -*/ - export function httpClient( ssl: boolean, host: string, diff --git a/components/esp32-javascript/modules/esp32-javascript/index.js b/components/esp32-javascript/modules/esp32-javascript/index.js index d9d7fc0..36993bf 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.js +++ b/components/esp32-javascript/modules/esp32-javascript/index.js @@ -1,4 +1,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var stringbuffer_1 = require("./stringbuffer"); console.info("Load global.js (NEW)..."); require("./global.js"); diff --git a/components/esp32-javascript/modules/esp32-javascript/index.ts b/components/esp32-javascript/modules/esp32-javascript/index.ts index 1a8e8b9..08fcfc9 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.ts +++ b/components/esp32-javascript/modules/esp32-javascript/index.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { StringBuffer } from "./stringbuffer"; console.info("Load global.js (NEW)..."); diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.js b/components/esp32-javascript/modules/esp32-javascript/native-ota.js index 38425d1..80cfb61 100644 --- a/components/esp32-javascript/modules/esp32-javascript/native-ota.js +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.upgrade = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var http = require("./http"); function assertStatusCode(status, url) { return function (head) { diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.ts b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts index ca52656..e4bfffe 100644 --- a/components/esp32-javascript/modules/esp32-javascript/native-ota.ts +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import http = require("./http"); import { StringBuffer } from "./stringbuffer"; diff --git a/components/esp32-javascript/modules/esp32-javascript/require.d.ts b/components/esp32-javascript/modules/esp32-javascript/require.d.ts index 0165a88..b0e32b7 100644 --- a/components/esp32-javascript/modules/esp32-javascript/require.d.ts +++ b/components/esp32-javascript/modules/esp32-javascript/require.d.ts @@ -1,2 +1,25 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ declare const module: { exports: any }; declare function require(moduleId: string): any; diff --git a/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts b/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts index 51553c0..30ec2cd 100644 --- a/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts +++ b/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { Esp32JsConfig } from "./config"; const firmwareConfig: Esp32JsConfig = { diff --git a/components/esp32-javascript/modules/esp32-javascript/self-test.js b/components/esp32-javascript/modules/esp32-javascript/self-test.js index c7bc81a..87eaa67 100644 --- a/components/esp32-javascript/modules/esp32-javascript/self-test.js +++ b/components/esp32-javascript/modules/esp32-javascript/self-test.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var configserver_1 = require("./configserver"); function setPinValue(pin, val) { pinMode(pin, OUTPUT); diff --git a/components/esp32-javascript/modules/esp32-javascript/self-test.ts b/components/esp32-javascript/modules/esp32-javascript/self-test.ts index 713f459..18138b9 100644 --- a/components/esp32-javascript/modules/esp32-javascript/self-test.ts +++ b/components/esp32-javascript/modules/esp32-javascript/self-test.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { requestHandler } from "./configserver"; function setPinValue(pin: number, val: number): void { diff --git a/components/esp32-javascript/modules/esp32-javascript/stringbuffer.js b/components/esp32-javascript/modules/esp32-javascript/stringbuffer.js index 5d4a7ad..bf9ce3f 100644 --- a/components/esp32-javascript/modules/esp32-javascript/stringbuffer.js +++ b/components/esp32-javascript/modules/esp32-javascript/stringbuffer.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.StringBuffer = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var StringBuffer = /** @class */ (function () { function StringBuffer(s) { this.content = []; diff --git a/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts b/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts index 00cb453..eb2c131 100644 --- a/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts +++ b/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ export class StringBuffer { private content: (string | StringBuffer)[]; public length: number; diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts index ea525da..6f47b30 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ interface Esp32JsTimer { handle: number; timeout: number; diff --git a/components/esp32-javascript/urlparse.ts b/components/esp32-javascript/urlparse.ts index acc814e..ea01e05 100644 --- a/components/esp32-javascript/urlparse.ts +++ b/components/esp32-javascript/urlparse.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ interface AnchorElement { href: string; pathname: string; diff --git a/components/esp32-js-log/include/esp32-js-log.h b/components/esp32-js-log/include/esp32-js-log.h index 10b6344..bfc1abc 100644 --- a/components/esp32-js-log/include/esp32-js-log.h +++ b/components/esp32-js-log/include/esp32-js-log.h @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/socket-events/include/socket-events.h b/components/socket-events/include/socket-events.h index 52074a1..1f8c49f 100644 --- a/components/socket-events/include/socket-events.h +++ b/components/socket-events/include/socket-events.h @@ -2,7 +2,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/socket-events/include/tcp.h b/components/socket-events/include/tcp.h index c874d63..3c2f94f 100644 --- a/components/socket-events/include/tcp.h +++ b/components/socket-events/include/tcp.h @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/socket-events/modules/socket-events/index.js b/components/socket-events/modules/socket-events/index.js index ee8976a..c6cbea0 100644 --- a/components/socket-events/modules/socket-events/index.js +++ b/components/socket-events/modules/socket-events/index.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.sockListen = exports.sockConnect = exports.closeSocket = exports.sockets = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var esp32_js_eventloop_1 = require("esp32-js-eventloop"); var sslClientCtx; exports.sockets = []; @@ -61,7 +84,7 @@ var Socket = /** @class */ (function () { this.clearReadTimeoutTimer(); if (this.readTimeout > 0) { this.readTimeoutHandle = setTimeout(function () { - console.log("Close socket because of read timeout."); + console.debug("Close socket because of read timeout."); closeSocket(_this); }, this.readTimeout); } diff --git a/components/socket-events/modules/socket-events/index.ts b/components/socket-events/modules/socket-events/index.ts index 5b0e346..a33d21a 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { beforeSuspendHandlers, afterSuspendHandlers, diff --git a/components/socket-events/socket-events.c b/components/socket-events/socket-events.c index 9b0618b..3b9542e 100644 --- a/components/socket-events/socket-events.c +++ b/components/socket-events/socket-events.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/socket-events/tcp.c b/components/socket-events/tcp.c index 143fc02..3aeffc4 100644 --- a/components/socket-events/tcp.c +++ b/components/socket-events/tcp.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/spiffs-events/spiffs-events.c b/components/spiffs-events/spiffs-events.c index ccda3c4..9cc9ca6 100644 --- a/components/spiffs-events/spiffs-events.c +++ b/components/spiffs-events/spiffs-events.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/wifi-events/include/wifi-events.h b/components/wifi-events/include/wifi-events.h index 04d2513..aa9c307 100644 --- a/components/wifi-events/include/wifi-events.h +++ b/components/wifi-events/include/wifi-events.h @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/components/wifi-events/modules/wifi-events/index.js b/components/wifi-events/modules/wifi-events/index.js index 1748503..35e3526 100644 --- a/components/wifi-events/modules/wifi-events/index.js +++ b/components/wifi-events/modules/wifi-events/index.js @@ -1,5 +1,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getIPAddress = exports.getBssid = exports.createSoftAp = exports.connectWifi = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ var esp32_js_eventloop_1 = require("esp32-js-eventloop"); var wifi = undefined; function resetWifiStatus(callback) { diff --git a/components/wifi-events/modules/wifi-events/index.ts b/components/wifi-events/modules/wifi-events/index.ts index 49854b1..8448ec6 100644 --- a/components/wifi-events/modules/wifi-events/index.ts +++ b/components/wifi-events/modules/wifi-events/index.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import { afterSuspendHandlers } from "esp32-js-eventloop"; /** diff --git a/components/wifi-events/wifi-events.c b/components/wifi-events/wifi-events.c index fb4ce95..e1e36f3 100644 --- a/components/wifi-events/wifi-events.c +++ b/components/wifi-events/wifi-events.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/main/include/esp32-javascript-config.h b/main/include/esp32-javascript-config.h index 033c58d..c9972e5 100644 --- a/main/include/esp32-javascript-config.h +++ b/main/include/esp32-javascript-config.h @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/main/main.c b/main/main.c index b5304e8..d34992f 100644 --- a/main/main.c +++ b/main/main.c @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2020 Marcel Kottmann +Copyright (c) 2021 Marcel Kottmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 3e8a3ddb0cd4fb78b045dd407b520566e652dce7 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sun, 23 May 2021 22:15:49 +0200 Subject: [PATCH 05/19] feat: improve logging to capture also log messages without js context --- .../esp32-javascript/esp32-javascript.c | 103 ++++++--- .../include/esp32-javascript.h | 2 +- .../modules/esp32-javascript/configserver.js | 125 +++++++++-- .../modules/esp32-javascript/configserver.ts | 200 +++++++++++++++--- .../esp32-javascript/esp32-javascript.d.ts | 9 + .../modules/esp32-javascript/filelogging.js | 77 +++++++ .../modules/esp32-javascript/filelogging.ts | 82 +++++++ .../modules/esp32-javascript/index.js | 23 +- .../modules/esp32-javascript/index.ts | 21 +- .../modules/esp32-js-eventloop/index.js | 24 ++- .../modules/esp32-js-eventloop/index.ts | 37 +++- components/spiffs-events/spiffs-events.c | 53 ++++- components/wifi-events/wifi-events.c | 2 +- main/include/esp32-javascript-config.h | 5 +- sdkconfig.defaults | 4 +- 15 files changed, 628 insertions(+), 139 deletions(-) create mode 100644 components/esp32-javascript/modules/esp32-javascript/filelogging.js create mode 100644 components/esp32-javascript/modules/esp32-javascript/filelogging.ts diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 62c671a..81ba2e0 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -85,6 +85,11 @@ void fileLog(duk_context *ctx, log_level_t level, char *message) void jslog(log_level_t level, const char *msg, ...) { + if (level < (5 - LOG_LOCAL_LEVEL)) + { + return; + } + char *my_string; va_list argp; @@ -115,25 +120,21 @@ void jslog(log_level_t level, const char *msg, ...) duk_eval(ctx); /* -> [ ... func ] */ duk_push_string(ctx, my_string); duk_call(ctx, 1); + //clear stack + duk_pop(ctx); } else { - if (level == DEBUG) - { - ESP_LOGD(tag, "No ctx present: %s", my_string); - } - else if (level == INFO) - { - ESP_LOGI(tag, "No ctx present: %s", my_string); - } - else if (level == WARN) - { - ESP_LOGW(tag, "No ctx present: %s", my_string); - } - else - { - ESP_LOGE(tag, "No ctx present: %s", my_string); - } + char *message = malloc(strlen(my_string) + 1); + strcpy(message, my_string); + + js_event_t event; + js_eventlist_t events; + events.events_len = 0; + + el_create_event(&event, EL_LOG_EVENT_TYPE, level, message); + el_add_event(&events, &event); + el_fire_events(&events); } free(my_string); } @@ -171,7 +172,7 @@ void IRAM_ATTR el_add_event(js_eventlist_t *events, js_event_t *event) { if (events->events_len >= MAX_EVENTS) { - jslog(ERROR, "Event queue full. Max event number: %d => aborting.", MAX_EVENTS); + ESP_LOGE(tag, "Event list is full. Max event list size: %d => aborting.", MAX_EVENTS); abort(); } events->events[events->events_len] = *event; @@ -182,17 +183,28 @@ void IRAM_ATTR el_fire_events(js_eventlist_t *events) { if (DISABLE_EVENTS) { - jslog(WARN, "Events are disabled. They will never be fired."); + ESP_LOGW(tag, "Events are disabled. They will never be fired."); } else { if (events->events_len > 0) { - jslog(DEBUG, "Send %d events to queue...", events->events_len); + ESP_LOGD(tag, "Send %d events to queue...", events->events_len); int ret = xQueueSendFromISR(el_event_queue, events, NULL); if (ret != pdTRUE) { - jslog(ERROR, "Event queue is full... is something blocking the event loop?...aborting."); + ESP_LOGE(tag, "Event queue is full... is something blocking the event loop?...aborting."); + js_eventlist_t devents; + int num = 0; + while (xQueueReceive(el_event_queue, &devents, 0)) + { + for (int i = 0; i < devents.events_len; i++) + { + ESP_LOGE(tag, "Events num %i, event idx %i, type %i, status %i", num, i, devents.events[i].type, devents.events[i].status); + } + num++; + } + abort(); } } @@ -401,26 +413,30 @@ static duk_ret_t el_suspend(duk_context *ctx) js_eventlist_t events; jslog(DEBUG, "Waiting for events..."); - - xQueueReceive(el_event_queue, &events, portMAX_DELAY); - - jslog(DEBUG, "Receiving %d events.", events.events_len); - int arr_idx = duk_push_array(ctx); - for (int i = 0; i < events.events_len; i++) + int arrsize = 0; + TickType_t timeout = portMAX_DELAY; + while (xQueueReceive(el_event_queue, &events, timeout) == pdTRUE) { - duk_idx_t obj_idx = duk_push_object(ctx); + timeout = 0; // set timeout to 0 to not wait in while loop if there are no more events available + for (int i = 0; i < events.events_len; i++) + { + duk_idx_t obj_idx = duk_push_object(ctx); - duk_push_int(ctx, events.events[i].type); - duk_put_prop_string(ctx, obj_idx, "type"); - duk_push_int(ctx, events.events[i].status); - duk_put_prop_string(ctx, obj_idx, "status"); - duk_push_int(ctx, (int)events.events[i].fd); - duk_put_prop_string(ctx, obj_idx, "fd"); + duk_push_int(ctx, events.events[i].type); + duk_put_prop_string(ctx, obj_idx, "type"); + duk_push_int(ctx, events.events[i].status); + duk_put_prop_string(ctx, obj_idx, "status"); + duk_push_int(ctx, (int)events.events[i].fd); + duk_put_prop_string(ctx, obj_idx, "fd"); - duk_put_prop_index(ctx, arr_idx, i); + duk_put_prop_index(ctx, arr_idx, arrsize); + arrsize++; + } } + jslog(DEBUG, "Received %d events.", arrsize); + return 1; } @@ -788,6 +804,14 @@ duk_ret_t el_partition_write(duk_context *ctx) } } +duk_ret_t el_readAndFreeString(duk_context *ctx) +{ + char *str = duk_to_int(ctx, 0); + duk_push_string(ctx, str); + free(str); + return 1; +} + void duktape_task(void *ignore) { spiramAvailable = spiramAvail(); @@ -901,6 +925,15 @@ void duktape_task(void *ignore) duk_push_c_function(ctx, el_find_partition, 1 /*nargs*/); duk_put_global_string(ctx, "el_find_partition"); + duk_push_int(ctx, EL_TIMER_EVENT_TYPE); + duk_put_global_string(ctx, "EL_TIMER_EVENT_TYPE"); + + duk_push_int(ctx, EL_LOG_EVENT_TYPE); + duk_put_global_string(ctx, "EL_LOG_EVENT_TYPE"); + + duk_push_c_function(ctx, el_readAndFreeString, 1 /*nargs*/); + duk_put_global_string(ctx, "el_readAndFreeString"); + loadUrlPolyfill(ctx); #define ESP32_JAVASCRIPT_EXTERN ESP32_JAVASCRIPT_EXTERN_REGISTER @@ -924,7 +957,7 @@ int esp32_javascript_init() esp_log_level_set("*", ESP_LOG_ERROR); esp_log_level_set("wifi", ESP_LOG_WARN); esp_log_level_set("dhcpc", ESP_LOG_WARN); - esp_log_level_set(tag, ESP_LOG_DEBUG); + esp_log_level_set(tag, LOG_LOCAL_LEVEL); nvs_flash_init(); tcpip_adapter_init(); diff --git a/components/esp32-javascript/include/esp32-javascript.h b/components/esp32-javascript/include/esp32-javascript.h index 199901a..ca0abbb 100644 --- a/components/esp32-javascript/include/esp32-javascript.h +++ b/components/esp32-javascript/include/esp32-javascript.h @@ -44,7 +44,7 @@ extern "C" void *fd; } js_event_t; -#define MAX_EVENTS 4 +#define MAX_EVENTS 8 typedef struct { js_event_t events[MAX_EVENTS]; diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index cb27fa9..be60969 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -36,7 +36,9 @@ SOFTWARE. */ var configManager = require("./config"); var boot_1 = require("./boot"); +var native_ota_1 = require("./native-ota"); var http_1 = require("./http"); +var filelogging_1 = require("./filelogging"); var schema = { access: { type: "object", @@ -117,14 +119,14 @@ function redirect(res, location) { res.end(); } exports.redirect = redirect; -function page(res, headline, text, cb) { +function page(res, headline, text, cb, additionalHeadTags) { if (cb) { // register callback res.on("end", cb); } res.setStatus(200); res.headers.set("content-type", "text/html"); - res.write("esp32-javascript\n \n \n \n \n

" + headline + "

"); + res.write("esp32-javascript\n \n \n " + (additionalHeadTags ? additionalHeadTags : "") + "\n \n

" + headline + "

"); if (Array.isArray(text)) { res.write(text.join("")); } @@ -133,6 +135,32 @@ function page(res, headline, text, cb) { } res.end("
\r\n\r\n"); } +function getLogFileList() { + global.el_flushLogBuffer(); + var logFileList = []; + try { + var list = listDir(filelogging_1.FILE_LOGGING_DIRECTORY).sort(); + list.forEach(function (f) { + try { + logFileList.push({ + filename: f, + size: fileSize(filelogging_1.FILE_LOGGING_DIRECTORY + "/" + f), + }); + } + catch (error) { + console.error(error); + } + }); + } + catch (_) { + // ignore + } + return logFileList; +} +var upgradeStatus = { + status: "idle", + message: "", +}; var successMessage = ""; var errorMessage = ""; function startConfigServer() { @@ -168,6 +196,8 @@ function startConfigServer() { var config_1 = http_1.parseQueryStr(req.body); storedConfig.wifi.ssid = config_1.ssid; storedConfig.wifi.password = config_1.password; + storedConfig.access.username = config_1.username; + storedConfig.access.password = config_1.userpass; storedConfig.ota.url = config_1.url; storedConfig.ota.offline = config_1.offline === "true"; storedConfig.ota.script = config_1.script; @@ -179,18 +209,15 @@ function startConfigServer() { } } var config = configManager.config; - var logFileSize = void 0; - try { - logFileSize = fileSize("/data/logs.txt"); - } - catch (_) { - // ignore - } page(res, "Setup", "" + (successMessage ? "
" + successMessage + "
" - : "") + (errorMessage - ? "
Saving failed. Error message: " + errorMessage + "
" - : "") + "
\n
\n
\n
\n
\n
\n
\n

Logs

\n
\n Log size: " + (logFileSize ? Math.floor(logFileSize / 1024) : "?") + " kB\n
\n
\n
\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / + : "") + (errorMessage ? "
" + errorMessage + "
" : "") + "

Configuration

Wifi

\n
\n
\n

Basic authentication

\n
\n
\n

JavaScript OTA

\n
\n
\n
\n

Logs

\n
\n

\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.
\n

\n " + getLogFileList() + .map(function (e) { + return e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB)

"; + }) + .join("") + "\n \n
\n \n

Native OTA Upgrade

\n
\n
\n
\n
" + (upgradeStatus.status !== "idle" + ? 'Upgrade status' + : "") + "
\n
\n\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / 100 + "
\n
\n
\n Boot time is only available if a valid 'JS file url' is configured, otherwise it starts at unix epoch (1970).\n
"); successMessage = ""; errorMessage = ""; @@ -268,19 +295,77 @@ function startConfigServer() { } }); exports.requestHandler.push(function (req, res) { - if (/\/logs(|\?.*)/.exec(req.path)) { - res.setStatus(200); - res.headers.set("Content-type", "text/plain"); - global.el_flushLogBuffer(); - res.end(readFile("/data/logs.txt")); + if (/\/viewlog/.exec(req.path)) { + var parsed = http_1.parseQueryStr(req.body); + if (parsed.file.indexOf(filelogging_1.FILE_LOGGING_DIRECTORY) !== 0) { + res.setStatus(400, "Invalid supplied filename."); + res.end(); + return; + } + try { + var content = readFile(parsed.file); + res.setStatus(200); + res.headers.set("Content-type", "text/plain"); + global.el_flushLogBuffer(); + res.write(content); + } + catch (_a) { + res.setStatus(404, "Not found"); + } + finally { + res.end(); + } } }); exports.requestHandler.push(function (req, res) { - if (/\/deletelogs(|\?.*)/.exec(req.path)) { - removeFile("/data/logs.txt"); - successMessage = "Logs were deleted successfully."; + if (/\/deletelog/.exec(req.path)) { + var parsed = http_1.parseQueryStr(req.body); + if (parsed.file.indexOf(filelogging_1.FILE_LOGGING_DIRECTORY) !== 0) { + res.setStatus(400, "Invalid supplied filename."); + res.end(); + return; + } + if (removeFile(parsed.file) >= 0) { + successMessage = "Log file deleted successfully."; + } + else { + errorMessage = "Log file not found."; + } redirect(res, "/setup"); } }); + exports.requestHandler.push(function (req, res) { + if (/\/native-ota/.exec(req.path)) { + if (req.method === "POST") { + var parsed_1 = http_1.parseQueryStr(req.body); + if (parsed_1.appbin && parsed_1.modulesbin) { + if (upgradeStatus.status !== "inprogress") { + upgradeStatus.status = "inprogress"; + upgradeStatus.message = ""; + setTimeout(function () { + native_ota_1.upgrade(parsed_1.appbin, parsed_1.modulesbin, function (error) { + upgradeStatus.status = "error"; + upgradeStatus.message = error; + }, function () { + upgradeStatus.status = "success"; + upgradeStatus.message = ""; + }); + }, 2000); + } + redirect(res, "/native-ota"); + } + } + else { + page(res, "Upgrade", "" + ((upgradeStatus.status === "error" && + "
An error occured while upgrading: " + upgradeStatus.message + "
") || + (upgradeStatus.status === "success" && + "
Upgrade was successful. Please restart to start upgraded firmware.
\n
") || + (upgradeStatus.status === "inprogress" && + "
Upgrade in progress...
Page refreshes automatically.
") || + (upgradeStatus.status === "idle" && + "
No upgrade started.
")), undefined, ''); + } + } + }); } exports.startConfigServer = startConfigServer; diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index 63f4de2..c94f6b3 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -23,6 +23,7 @@ SOFTWARE. */ import configManager = require("./config"); import { getBootTime } from "./boot"; +import { upgrade } from "./native-ota"; import { httpServer, @@ -30,6 +31,11 @@ import { parseQueryStr, Esp32JsRequest, } from "./http"; +import { + FILE_LOGGING_DIRECTORY, + LOG_FILE_NUM_LIMIT, + LOG_FILE_SIZE_LIMIT, +} from "./filelogging"; let schema = { access: { @@ -120,7 +126,8 @@ function page( res: Esp32JsResponse, headline: string, text: string | string[], - cb?: () => void + cb?: () => void, + additionalHeadTags?: string ) { if (cb) { // register callback @@ -163,8 +170,19 @@ function page( .red { color: red; } + .inline-form { + display: inline; + } + .blink { + animation: blinkanimation 1s linear infinite; + } + @keyframes blinkanimation { + 50% { + opacity: 0; + } + } - + ${additionalHeadTags ? additionalHeadTags : ""}

${headline}

`); if (Array.isArray(text)) { @@ -175,6 +193,35 @@ function page( res.end("
\r\n\r\n"); } +function getLogFileList() { + global.el_flushLogBuffer(); + const logFileList: { filename: string; size: number | undefined }[] = []; + try { + const list = listDir(FILE_LOGGING_DIRECTORY).sort(); + list.forEach((f) => { + try { + logFileList.push({ + filename: f, + size: fileSize(`${FILE_LOGGING_DIRECTORY}/${f}`), + }); + } catch (error) { + console.error(error); + } + }); + } catch (_) { + // ignore + } + return logFileList; +} + +const upgradeStatus: { + status: "idle" | "error" | "success" | "inprogress"; + message: string; +} = { + status: "idle", + message: "", +}; + let successMessage = ""; let errorMessage = ""; export function startConfigServer(): void { @@ -218,6 +265,8 @@ export function startConfigServer(): void { const config = parseQueryStr(req.body); storedConfig.wifi.ssid = config.ssid; storedConfig.wifi.password = config.password; + storedConfig.access.username = config.username; + storedConfig.access.password = config.userpass; storedConfig.ota.url = config.url; storedConfig.ota.offline = config.offline === "true"; storedConfig.ota.script = config.script; @@ -230,12 +279,6 @@ export function startConfigServer(): void { } const config = configManager.config; - let logFileSize: number | undefined; - try { - logFileSize = fileSize("/data/logs.txt"); - } catch (_) { - // ignore - } page( res, "Setup", @@ -244,17 +287,22 @@ export function startConfigServer(): void { ? `
${successMessage}
` : "" }${ - errorMessage - ? `
Saving failed. Error message: ${errorMessage}
` - : "" - }
+ errorMessage ? `
${errorMessage}
` : "" + }

Configuration

Wifi

-
+
+

JavaScript OTA

-

Logs

+

Logs

- Log size: ${logFileSize ? Math.floor(logFileSize / 1024) : "?"} kB +

+ Showing last ${LOG_FILE_NUM_LIMIT} log files, with each having maximum of ${ + LOG_FILE_SIZE_LIMIT / 1024 + } kB data.
+

+ ${getLogFileList() + .map((e) => { + return `${e.filename} (${ + e.size === undefined ? "?" : Math.floor(e.size / 1024) + } kB)

`; + }) + .join("")} +
-
-
-

Request restart

+ +

Native OTA Upgrade

+
+
+
+
${ + upgradeStatus.status !== "idle" + ? 'Upgrade status' + : "" + }
+
+ +

Request restart

-

Uptime

+

Uptime

Boot time: ${getBootTime()}
@@ -456,19 +532,89 @@ export function startConfigServer(): void { }); requestHandler.push((req, res) => { - if (/\/logs(|\?.*)/.exec(req.path)) { - res.setStatus(200); - res.headers.set("Content-type", "text/plain"); - global.el_flushLogBuffer(); - res.end(readFile("/data/logs.txt")); + if (/\/viewlog/.exec(req.path)) { + const parsed = parseQueryStr(req.body); + if (parsed.file.indexOf(FILE_LOGGING_DIRECTORY) !== 0) { + res.setStatus(400, "Invalid supplied filename."); + res.end(); + return; + } + try { + const content = readFile(parsed.file); + res.setStatus(200); + res.headers.set("Content-type", "text/plain"); + global.el_flushLogBuffer(); + res.write(content); + } catch { + res.setStatus(404, "Not found"); + } finally { + res.end(); + } } }); requestHandler.push((req, res) => { - if (/\/deletelogs(|\?.*)/.exec(req.path)) { - removeFile("/data/logs.txt"); - successMessage = "Logs were deleted successfully."; + if (/\/deletelog/.exec(req.path)) { + const parsed = parseQueryStr(req.body); + if (parsed.file.indexOf(FILE_LOGGING_DIRECTORY) !== 0) { + res.setStatus(400, "Invalid supplied filename."); + res.end(); + return; + } + if (removeFile(parsed.file) >= 0) { + successMessage = "Log file deleted successfully."; + } else { + errorMessage = "Log file not found."; + } redirect(res, "/setup"); } }); + + requestHandler.push((req, res) => { + if (/\/native-ota/.exec(req.path)) { + if (req.method === "POST") { + const parsed = parseQueryStr(req.body); + + if (parsed.appbin && parsed.modulesbin) { + if (upgradeStatus.status !== "inprogress") { + upgradeStatus.status = "inprogress"; + upgradeStatus.message = ""; + setTimeout(() => { + upgrade( + parsed.appbin, + parsed.modulesbin, + (error) => { + upgradeStatus.status = "error"; + upgradeStatus.message = error; + }, + () => { + upgradeStatus.status = "success"; + upgradeStatus.message = ""; + } + ); + }, 2000); + } + redirect(res, "/native-ota"); + } + } else { + page( + res, + "Upgrade", + `${ + (upgradeStatus.status === "error" && + `
An error occured while upgrading: ${upgradeStatus.message}
`) || + (upgradeStatus.status === "success" && + `
Upgrade was successful. Please restart to start upgraded firmware.
+
`) || + (upgradeStatus.status === "inprogress" && + `
Upgrade in progress...
Page refreshes automatically.
`) || + (upgradeStatus.status === "idle" && + `
No upgrade started.
`) + }`, + undefined, + '' + ); + } + } + }); } diff --git a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts index 047a917..176b38d 100644 --- a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts +++ b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts @@ -41,6 +41,8 @@ interface Esp32JsWifiConfig { } declare function getWifiConfig(): Esp32JsWifiConfig; declare const EL_WIFI_EVENT_TYPE: number; +declare const EL_TIMER_EVENT_TYPE: number; +declare const EL_LOG_EVENT_TYPE: number; declare function el_connectWifi(ssid: string, password: string): void; declare function el_createSoftAp(ssid: string, password: string): void; @@ -85,6 +87,8 @@ declare function writeFile(path: string, data: string): number; declare function appendFile(path: string, data: string): number; declare function removeFile(path: string): number; declare function fileSize(path: string): number; +declare function listDir(path: string): string[]; +declare function mkdir(path: string): void; // ota declare function el_ota_begin(): number; @@ -99,3 +103,8 @@ declare function el_partition_write( offset: number, data: Uint8Array ): void; +declare function el_find_partition(name: string): { + _ref: number; + size: number; +}; +declare function el_readAndFreeString(ptr: number): string; diff --git a/components/esp32-javascript/modules/esp32-javascript/filelogging.js b/components/esp32-javascript/modules/esp32-javascript/filelogging.js new file mode 100644 index 0000000..e9ad088 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/filelogging.js @@ -0,0 +1,77 @@ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LOG_FILE_NUM_LIMIT = exports.LOG_FILE_SIZE_LIMIT = exports.FILE_LOGGING_DIRECTORY = void 0; +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +var stringbuffer_1 = require("./stringbuffer"); +exports.FILE_LOGGING_DIRECTORY = "/data/logs"; +exports.LOG_FILE_SIZE_LIMIT = 10240; +exports.LOG_FILE_NUM_LIMIT = 10; +var TDIWEF = "TDIWEF"; +var NUMBER_PREFIX = "00000000"; +var logFileNumber = -1; +function getLogFileNumber() { + var max = -1; + if (logFileNumber < 0) { + var files = listDir(exports.FILE_LOGGING_DIRECTORY); + files.forEach(function (f) { + var m = f.match(/\d+/); + if (m) { + max = Math.max(max, parseInt(m[0], 10)); + } + }); + logFileNumber = max + 1; + } + var numStr = logFileNumber.toString(); + return NUMBER_PREFIX.substr(0, 8 - numStr.length) + numStr; +} +function cleanupOldLogs() { + var files = listDir(exports.FILE_LOGGING_DIRECTORY).sort(); + if (files.length > exports.LOG_FILE_NUM_LIMIT) { + for (var i = 0; i < files.length - exports.LOG_FILE_NUM_LIMIT; i++) { + removeFile(exports.FILE_LOGGING_DIRECTORY + "/" + files[i]); + } + } +} +global.el_flushLogBuffer = function () { + var swap = global.logBuffer; + global.logBuffer = new stringbuffer_1.StringBuffer(); + var logFile = exports.FILE_LOGGING_DIRECTORY + "/logs-" + getLogFileNumber() + ".txt"; + appendFile(logFile, swap.toString()); + if (fileSize(logFile) > exports.LOG_FILE_SIZE_LIMIT) { + logFileNumber++; + } + cleanupOldLogs(); +}; +/** + * This is defines the function to append to buffered file logging. + */ +global.el_appendLogBuffer = function (message, level) { + global.logBuffer = global.logBuffer || new stringbuffer_1.StringBuffer(); + var l = TDIWEF.substr(level, 1); + global.logBuffer.append(l + "\t" + new Date() + "\t" + message + "\n"); + if (global.logBuffer.length > 1024) { + global.el_flushLogBuffer(); + } +}; +console.log("File logging initialized successfully."); diff --git a/components/esp32-javascript/modules/esp32-javascript/filelogging.ts b/components/esp32-javascript/modules/esp32-javascript/filelogging.ts new file mode 100644 index 0000000..17d9cd9 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/filelogging.ts @@ -0,0 +1,82 @@ +/* +MIT License + +Copyright (c) 2021 Marcel Kottmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +import { StringBuffer } from "./stringbuffer"; + +export const FILE_LOGGING_DIRECTORY = "/data/logs"; +export const LOG_FILE_SIZE_LIMIT = 10240; +export const LOG_FILE_NUM_LIMIT = 10; + +const TDIWEF = "TDIWEF"; +const NUMBER_PREFIX = "00000000"; +let logFileNumber = -1; + +function getLogFileNumber(): string { + let max = -1; + if (logFileNumber < 0) { + const files = listDir(FILE_LOGGING_DIRECTORY); + files.forEach((f) => { + const m = f.match(/\d+/); + if (m) { + max = Math.max(max, parseInt(m[0], 10)); + } + }); + logFileNumber = max + 1; + } + const numStr = logFileNumber.toString(); + return NUMBER_PREFIX.substr(0, 8 - numStr.length) + numStr; +} + +function cleanupOldLogs() { + const files = listDir(FILE_LOGGING_DIRECTORY).sort(); + if (files.length > LOG_FILE_NUM_LIMIT) { + for (let i = 0; i < files.length - LOG_FILE_NUM_LIMIT; i++) { + removeFile(`${FILE_LOGGING_DIRECTORY}/${files[i]}`); + } + } +} + +global.el_flushLogBuffer = function (): void { + const swap = global.logBuffer; + global.logBuffer = new StringBuffer(); + const logFile = `${FILE_LOGGING_DIRECTORY}/logs-${getLogFileNumber()}.txt`; + appendFile(logFile, swap.toString()); + if (fileSize(logFile) > LOG_FILE_SIZE_LIMIT) { + logFileNumber++; + } + cleanupOldLogs(); +}; + +/** + * This is defines the function to append to buffered file logging. + */ +global.el_appendLogBuffer = function (message: string, level: number): void { + global.logBuffer = global.logBuffer || new StringBuffer(); + const l = TDIWEF.substr(level, 1); + global.logBuffer.append(`${l}\t${new Date()}\t${message}\n`); + if (global.logBuffer.length > 1024) { + global.el_flushLogBuffer(); + } +}; + +console.log("File logging initialized successfully."); diff --git a/components/esp32-javascript/modules/esp32-javascript/index.js b/components/esp32-javascript/modules/esp32-javascript/index.js index 36993bf..d852470 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.js +++ b/components/esp32-javascript/modules/esp32-javascript/index.js @@ -1,4 +1,3 @@ -Object.defineProperty(exports, "__esModule", { value: true }); /* MIT License @@ -22,27 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -var stringbuffer_1 = require("./stringbuffer"); +Object.defineProperty(exports, "__esModule", { value: true }); console.info("Load global.js (NEW)..."); require("./global.js"); -/** - * This is defines the function to append to buffered file logging. - */ -console.info("Loading logging buffer (NEW)..."); -var TDIWEF = "TDIWEF"; -global.el_flushLogBuffer = function () { - var swap = global.logBuffer; - global.logBuffer = new stringbuffer_1.StringBuffer(); - appendFile("/data/logs.txt", swap.toString()); -}; -global.el_appendLogBuffer = function (message, level) { - global.logBuffer = global.logBuffer || new stringbuffer_1.StringBuffer(); - var l = TDIWEF.substr(level, 1); - global.logBuffer.append(l + "\t" + new Date() + "\t" + message + "\n"); - if (global.logBuffer.length > 1024) { - global.el_flushLogBuffer(); - } -}; +console.info("Loading file logging buffer (NEW)..."); +require("./filelogging"); console.info("Importing http (NEW)..."); var http = require("./http"); console.info("Importing boot (NEW)..."); diff --git a/components/esp32-javascript/modules/esp32-javascript/index.ts b/components/esp32-javascript/modules/esp32-javascript/index.ts index 08fcfc9..bcc4c65 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.ts +++ b/components/esp32-javascript/modules/esp32-javascript/index.ts @@ -21,29 +21,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { StringBuffer } from "./stringbuffer"; console.info("Load global.js (NEW)..."); require("./global.js"); -/** - * This is defines the function to append to buffered file logging. - */ -console.info("Loading logging buffer (NEW)..."); -const TDIWEF = "TDIWEF"; -global.el_flushLogBuffer = function (): void { - const swap = global.logBuffer; - global.logBuffer = new StringBuffer(); - appendFile("/data/logs.txt", swap.toString()); -}; -global.el_appendLogBuffer = function (message: string, level: number): void { - global.logBuffer = global.logBuffer || new StringBuffer(); - const l = TDIWEF.substr(level, 1); - global.logBuffer.append(`${l}\t${new Date()}\t${message}\n`); - if (global.logBuffer.length > 1024) { - global.el_flushLogBuffer(); - } -}; +console.info("Loading file logging buffer (NEW)..."); +require("./filelogging"); console.info("Importing http (NEW)..."); import http = require("./http"); diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.js b/components/esp32-javascript/modules/esp32-js-eventloop/index.js index f48938a..3d52784 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.js +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.js @@ -67,7 +67,7 @@ function el_select_next() { var _loop_1 = function (evid) { var evt = events[evid]; console.debug("HANDLE EVENT: " + JSON.stringify(evt)); - if (evt.type === 0) { + if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT var nextTimer = null; for (var timerIdx = 0; timerIdx < timers.length; timerIdx++) { @@ -84,6 +84,28 @@ function el_select_next() { JSON.stringify(timers)); } } + else if (evt.type === EL_LOG_EVENT_TYPE) { + //LOG EVENT + var logevent_1 = evt; + collected.push(function () { + var logfunction = console.log; + switch (logevent_1.status) { + case 1: + logfunction = console.debug; + break; + case 2: + logfunction = console.info; + break; + case 3: + logfunction = console.warn; + break; + case 4: + logfunction = console.error; + break; + } + logfunction(el_readAndFreeString(logevent_1.fd)); + }); + } else { var eventHandled_1 = false; if (exports.afterSuspendHandlers) { diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts index 6f47b30..78fe21e 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts @@ -38,9 +38,9 @@ type Esp32JsEventHandler = ( errorhandler = typeof errorhandler === "undefined" ? function (error) { - console.error("Uncaught error:"); - console.error(error.stack || error); - } + console.error("Uncaught error:"); + console.error(error.stack || error); + } : errorhandler; const timers: Esp32JsTimer[] = []; @@ -111,7 +111,7 @@ function el_select_next() { for (let evid = 0; evid < events.length; evid++) { const evt = events[evid]; console.debug("HANDLE EVENT: " + JSON.stringify(evt)); - if (evt.type === 0) { + if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT let nextTimer = null; for (let timerIdx = 0; timerIdx < timers.length; timerIdx++) { @@ -124,11 +124,32 @@ function el_select_next() { //throw Error('UNKNOWN TIMER HANDLE!!!'); console.warn( "UNKNOWN TIMER HANDLE:" + - JSON.stringify(evt) + - ";" + - JSON.stringify(timers) + JSON.stringify(evt) + + ";" + + JSON.stringify(timers) ); } + } else if (evt.type === EL_LOG_EVENT_TYPE) { + //LOG EVENT + const logevent = evt; + collected.push(() => { + let logfunction = console.log; + switch (logevent.status) { + case 1: + logfunction = console.debug; + break; + case 2: + logfunction = console.info; + break; + case 3: + logfunction = console.warn; + break; + case 4: + logfunction = console.error; + break; + } + logfunction(el_readAndFreeString(logevent.fd)); + }); } else { let eventHandled = false; if (afterSuspendHandlers) { @@ -152,7 +173,7 @@ function el_select_next() { export function start(): void { // eslint-disable-next-line @typescript-eslint/ban-types let nextfuncs: Function[] = [main]; - for (; ;) { + for (;;) { if (Array.isArray(nextfuncs)) { nextfuncs.forEach(function (nf) { if (typeof nf === "function") { diff --git a/components/spiffs-events/spiffs-events.c b/components/spiffs-events/spiffs-events.c index 9cc9ca6..c2ad710 100644 --- a/components/spiffs-events/spiffs-events.c +++ b/components/spiffs-events/spiffs-events.c @@ -23,6 +23,7 @@ SOFTWARE. */ #include +#include #include #include #include @@ -34,6 +35,7 @@ SOFTWARE. #include "esp32-javascript.h" #include "esp_ota_ops.h" #include "esp_partition.h" +#include void initFilesystem(const char *label, const char *basePath) { @@ -84,7 +86,7 @@ long fileSize(const char *path) FILE *f = fopen(path, "r"); if (f == NULL) { - jslog(ERROR, "Failed to open file to get filesize"); + jslog(ERROR, "Failed to open file '%s' to get filesize, errno %i", path, errno); return -1; } @@ -130,7 +132,7 @@ int writeFile(const char *path, const char *content) FILE *f = fopen(path, "w"); if (f == NULL) { - jslog(ERROR, "Failed to open file for writing"); + jslog(ERROR, "Failed to open file '%s'for writing, errno %i", path, errno); return -1; } int result = fputs(content, f); @@ -144,7 +146,7 @@ int appendFile(const char *path, const char *content) FILE *f = fopen(path, "a"); if (f == NULL) { - jslog(ERROR, "Failed to open file for appending"); + jslog(ERROR, "Failed to open file '%s' for appending, errno %i", path, errno); return -1; } int result = fputs(content, f); @@ -158,6 +160,47 @@ bool fileExists(const char *path) return (stat(path, &buffer) == 0); } +duk_ret_t el_listDir(duk_context *ctx) +{ + const char *path = duk_to_string(ctx, 0); + + DIR *dp; + struct dirent *ep; + dp = opendir(path); + + if (dp != NULL) + { + duk_idx_t arrayIdx = duk_push_array(ctx); + int i = 0; + while (ep = readdir(dp)) + { + duk_push_string(ctx, ep->d_name); + duk_put_prop_index(ctx, arrayIdx, i++); + } + closedir(dp); + return 1; + } + + jslog(ERROR, "Failed to list dir '%s', errno %i", path, errno); + + return -1; +} + +// duk_ret_t el_mkdir(duk_context *ctx) +// { +// const char *path = duk_to_string(ctx, 0); + +// int ret = mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO); + +// if (ret == -1 && errno != EEXIST) +// { +// jslog(ERROR, "Failed to make directory %s, with errno %i", path, errno); +// return -1; +// } + +// return 0; +// } + duk_ret_t el_readFile(duk_context *ctx) { const char *path = duk_to_string(ctx, 0); @@ -233,6 +276,10 @@ void registerBindings(duk_context *ctx) duk_put_global_string(ctx, "removeFile"); duk_push_c_function(ctx, el_fileSize, 1); duk_put_global_string(ctx, "fileSize"); + duk_push_c_function(ctx, el_listDir, 1); + duk_put_global_string(ctx, "listDir"); + // duk_push_c_function(ctx, el_mkdir, 1); + // duk_put_global_string(ctx, "mkdir"); } void initSpiffs(duk_context *ctx) diff --git a/components/wifi-events/wifi-events.c b/components/wifi-events/wifi-events.c index e1e36f3..05041e8 100644 --- a/components/wifi-events/wifi-events.c +++ b/components/wifi-events/wifi-events.c @@ -105,7 +105,7 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) } else { - jslog(ERROR, "SSID not found %s", wifi_config.sta.ssid); + jslog(DEBUG, "SSID not found %s", wifi_config.sta.ssid); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); el_create_event(&event, EL_WIFI_EVENT_TYPE, EL_WIFI_STATUS_DISCONNECTED, 0); diff --git a/main/include/esp32-javascript-config.h b/main/include/esp32-javascript-config.h index c9972e5..4f1756d 100644 --- a/main/include/esp32-javascript-config.h +++ b/main/include/esp32-javascript-config.h @@ -29,9 +29,10 @@ SOFTWARE. #define EL_TIMER_EVENT_TYPE 0 #define EL_WIFI_EVENT_TYPE 1 #define EL_SOCKET_EVENT_TYPE 2 -#define RADIO_RECEIVE_EVENT_TYPE 3 +#define EL_LOG_EVENT_TYPE 3 +#define RADIO_RECEIVE_EVENT_TYPE 4 // define your custom event types here -// #define CUSTOM_XXX_EVENT_TYPE 3 +// #define CUSTOM_XXX_EVENT_TYPE 4 #if ESP32_JAVASCRIPT_EXTERN == ESP32_JAVASCRIPT_EXTERN_INCLUDE extern void initSpiffs(duk_context *ctx); diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 4582ca9..0549176 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -123,8 +123,8 @@ CONFIG_PARTITION_TABLE_MD5=y # Compiler options # # CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +CONFIG_COMPILER_OPTIMIZATION_PERF=y # CONFIG_COMPILER_OPTIMIZATION_NONE is not set # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set From 05b9480aa3bf76dd3d01253dbf6cb903403702b8 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sat, 29 May 2021 18:25:38 +0200 Subject: [PATCH 06/19] feat: perform garbage collection only, if no event is in queue --- components/esp32-javascript/esp32-javascript.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 81ba2e0..8eb0daa 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -402,10 +402,6 @@ static void createConsole(duk_context *ctx) static duk_ret_t el_suspend(duk_context *ctx) { - // force garbage collection 2 times see duktape doc - // greatly increases perfomance with external memory - duk_gc(ctx, 0); - duk_gc(ctx, 0); // feed watchdog vTaskDelay(1); @@ -416,6 +412,16 @@ static duk_ret_t el_suspend(duk_context *ctx) int arr_idx = duk_push_array(ctx); int arrsize = 0; TickType_t timeout = portMAX_DELAY; + + // If event queue is empty its time for a manually started garbage collection + if (uxQueueMessagesWaiting(el_event_queue) == 0) + { + // force garbage collection 2 times see duktape doc + // greatly increases perfomance with external memory + duk_gc(ctx, 0); + duk_gc(ctx, 0); + } + while (xQueueReceive(el_event_queue, &events, timeout) == pdTRUE) { timeout = 0; // set timeout to 0 to not wait in while loop if there are no more events available From 5095e8a1fb30462544542e942f192ba6ddbe8ca3 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sat, 29 May 2021 21:55:53 +0200 Subject: [PATCH 07/19] feat: improve socket-events performance --- .../esp32-javascript/esp32-javascript.c | 22 +- .../modules/esp32-javascript/configserver.js | 2 +- .../modules/esp32-javascript/configserver.ts | 2 +- .../esp32-javascript/esp32-javascript.d.ts | 23 +- .../modules/esp32-javascript/http.js | 46 ++-- .../modules/esp32-javascript/http.ts | 58 +++-- .../modules/esp32-js-eventloop/index.js | 45 ++-- .../modules/esp32-js-eventloop/index.ts | 65 +++-- .../modules/socket-events/index.js | 197 +++++++++++---- .../modules/socket-events/index.ts | 232 ++++++++++++++---- components/socket-events/socket-events.c | 7 +- components/socket-events/tcp.c | 4 +- .../wifi-events/modules/wifi-events/index.js | 1 - .../wifi-events/modules/wifi-events/index.ts | 3 +- tsconfig.json | 6 +- 15 files changed, 489 insertions(+), 224 deletions(-) diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 8eb0daa..70dfb9a 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -390,18 +390,31 @@ static void createConsole(duk_context *ctx) duk_put_prop_string(ctx, obj_idx, "log"); duk_push_c_function(ctx, console_debug_binding, 1); duk_put_prop_string(ctx, obj_idx, "debug"); + duk_push_boolean(ctx, DEBUG >= (5 - LOG_LOCAL_LEVEL)); + duk_put_prop_string(ctx, obj_idx, "isDebug"); duk_push_c_function(ctx, console_info_binding, 1); duk_put_prop_string(ctx, obj_idx, "info"); + duk_push_boolean(ctx, INFO >= (5 - LOG_LOCAL_LEVEL)); + duk_put_prop_string(ctx, obj_idx, "isInfo"); duk_push_c_function(ctx, console_warn_binding, 1); duk_put_prop_string(ctx, obj_idx, "warn"); + duk_push_boolean(ctx, WARN >= (5 - LOG_LOCAL_LEVEL)); + duk_put_prop_string(ctx, obj_idx, "isWarn"); duk_push_c_function(ctx, console_error_binding, 1); duk_put_prop_string(ctx, obj_idx, "error"); + duk_push_boolean(ctx, ERROR >= (5 - LOG_LOCAL_LEVEL)); + duk_put_prop_string(ctx, obj_idx, "isError"); duk_put_global_string(ctx, "console"); } static duk_ret_t el_suspend(duk_context *ctx) { + // force garbage collection 2 times see duktape doc + // greatly increases perfomance with external memory + duk_gc(ctx, 0); + duk_gc(ctx, 0); + // feed watchdog vTaskDelay(1); @@ -413,15 +426,6 @@ static duk_ret_t el_suspend(duk_context *ctx) int arrsize = 0; TickType_t timeout = portMAX_DELAY; - // If event queue is empty its time for a manually started garbage collection - if (uxQueueMessagesWaiting(el_event_queue) == 0) - { - // force garbage collection 2 times see duktape doc - // greatly increases perfomance with external memory - duk_gc(ctx, 0); - duk_gc(ctx, 0); - } - while (xQueueReceive(el_event_queue, &events, timeout) == pdTRUE) { timeout = 0; // set timeout to 0 to not wait in while loop if there are no more events available diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index be60969..2764f24 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -352,8 +352,8 @@ function startConfigServer() { }); }, 2000); } - redirect(res, "/native-ota"); } + redirect(res, "/native-ota"); } else { page(res, "Upgrade", "" + ((upgradeStatus.status === "error" && diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index c94f6b3..88061b1 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -594,8 +594,8 @@ export function startConfigServer(): void { ); }, 2000); } - redirect(res, "/native-ota"); } + redirect(res, "/native-ota"); } else { page( res, diff --git a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts index 176b38d..ec7b74c 100644 --- a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts +++ b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts @@ -16,7 +16,6 @@ declare function el_store(key: string, value: string): void; declare function setDateTimeInMillis(time: number): void; declare function setDateTimeZoneOffsetInHours(hours: number): void; - interface Esp32JsFirmwareDefaults { basicAuthUsername: string; basicAuthPassword: string; @@ -108,3 +107,25 @@ declare function el_find_partition(name: string): { size: number; }; declare function el_readAndFreeString(ptr: number): string; + +interface Console { + /* + * Check if logger level is appropiate to print debug messsages. + */ + isDebug: boolean; + + /* + * Check if logger level is appropiate to print info messsages. + */ + isInfo: boolean; + + /* + * Check if logger level is appropiate to print warn messsages. + */ + isWarn: boolean; + + /* + * Check if logger level is appropiate to print error messsages. + */ + isError: boolean; +} diff --git a/components/esp32-javascript/modules/esp32-javascript/http.js b/components/esp32-javascript/modules/esp32-javascript/http.js index cc13775..15d4173 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.js +++ b/components/esp32-javascript/modules/esp32-javascript/http.js @@ -93,20 +93,22 @@ function httpServer(port, isSSL, cb) { contentLength = parseInt(contentLengthHeader); } if (contentLength > 0) { - console.debug("A request body is expected."); + if (console.isDebug) { + console.debug("A request body is expected."); + } if (gotten >= endOfHeaders + 4 + contentLength) { var potentialRequestBody = textEncoder.encode(complete.substring(endOfHeaders + 4).toString()); postedData = textDecoder.decode(potentialRequestBody.subarray(0, contentLength)); - console.debug("Request body is complete:"); - console.debug(postedData); + if (console.isDebug) { + console.debug("Request body is complete:"); + console.debug(postedData); + } } else { //wait for more data to come (body of a POST request) - console.debug("Waiting for more data to come:"); - console.debug(contentLength); - console.debug(complete.length); - console.debug(gotten); - console.debug(endOfHeaders); + if (console.isDebug) { + console.debug("Waiting for more data to come:"); + } return; } } @@ -197,7 +199,7 @@ function httpServer(port, isSSL, cb) { } if (!responseHeaders_1.has("connection")) { responseHeaders_1.set("connection", "keep-alive"); - socket.setReadTimeout(20000); + socket.setReadTimeout(22222); // set to a non-standard timeout } var contentType = responseHeaders_1.get("content-type"); if (typeof contentType !== "string") { @@ -251,29 +253,39 @@ function httpServer(port, isSSL, cb) { contentLength = 0; headers = undefined; statusLine = undefined; - console.debug("gotten: " + gotten); - console.debug("complete.length: " + complete.length); var item_1 = { req: req_1, res: res_1 }; var num = active.push(item_1); - console.debug("Currently active requests: " + num); + if (console.isDebug) { + console.debug("Currently active requests: " + num); + } res_1.on("end", function () { - console.debug("splicing req/res form active list"); + if (console.isDebug) { + console.debug("splicing req/res form active list"); + } active.splice(active.indexOf(item_1), 1); }); var previous = num - 2; if (previous < 0 || active[previous].res.isEnded) { // active request/response is empty, perform immediately - console.debug("// active request/response is empty or entries are ended, perform immediately"); + if (console.isDebug) { + console.debug("// active request/response is empty or entries are ended, perform immediately"); + } setTimeout(function () { - console.debug("perform immediate"); + if (console.isDebug) { + console.debug("perform immediate"); + } cb(req_1, res_1); }, 0); } else { // queue request/response callback after previous request/response - console.debug("// queue request/response callback after previous request/response"); + if (console.isDebug) { + console.debug("// queue request/response callback after previous request/response"); + } active[previous].res.on("end", function () { - console.debug("end of previous req/res: triggering new req/res callback"); + if (console.isDebug) { + console.debug("end of previous req/res: triggering new req/res callback"); + } cb(req_1, res_1); }); } diff --git a/components/esp32-javascript/modules/esp32-javascript/http.ts b/components/esp32-javascript/modules/esp32-javascript/http.ts index 4453346..536e8c5 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.ts +++ b/components/esp32-javascript/modules/esp32-javascript/http.ts @@ -131,8 +131,9 @@ export function httpServer( } if (contentLength > 0) { - console.debug("A request body is expected."); - + if (console.isDebug) { + console.debug("A request body is expected."); + } if (gotten >= endOfHeaders + 4 + contentLength) { const potentialRequestBody = textEncoder.encode( complete.substring(endOfHeaders + 4).toString() @@ -140,15 +141,15 @@ export function httpServer( postedData = textDecoder.decode( potentialRequestBody.subarray(0, contentLength) ); - console.debug("Request body is complete:"); - console.debug(postedData); + if (console.isDebug) { + console.debug("Request body is complete:"); + console.debug(postedData); + } } else { //wait for more data to come (body of a POST request) - console.debug("Waiting for more data to come:"); - console.debug(contentLength); - console.debug(complete.length); - console.debug(gotten); - console.debug(endOfHeaders); + if (console.isDebug) { + console.debug("Waiting for more data to come:"); + } return; } } @@ -264,7 +265,7 @@ export function httpServer( } if (!responseHeaders.has("connection")) { responseHeaders.set("connection", "keep-alive"); - socket.setReadTimeout(20000); + socket.setReadTimeout(22222); // set to a non-standard timeout } const contentType = responseHeaders.get("content-type"); if (typeof contentType !== "string") { @@ -327,36 +328,45 @@ export function httpServer( headers = undefined; statusLine = undefined; - console.debug(`gotten: ${gotten}`); - console.debug(`complete.length: ${complete.length}`); - const item = { req, res }; const num = active.push(item); - console.debug(`Currently active requests: ${num}`); + if (console.isDebug) { + console.debug(`Currently active requests: ${num}`); + } res.on("end", () => { - console.debug("splicing req/res form active list"); + if (console.isDebug) { + console.debug("splicing req/res form active list"); + } active.splice(active.indexOf(item), 1); }); const previous = num - 2; if (previous < 0 || active[previous].res.isEnded) { // active request/response is empty, perform immediately - console.debug( - "// active request/response is empty or entries are ended, perform immediately" - ); + if (console.isDebug) { + console.debug( + "// active request/response is empty or entries are ended, perform immediately" + ); + } setTimeout(() => { - console.debug("perform immediate"); + if (console.isDebug) { + console.debug("perform immediate"); + } cb(req, res); }, 0); } else { // queue request/response callback after previous request/response - console.debug( - "// queue request/response callback after previous request/response" - ); - active[previous].res.on("end", () => { + if (console.isDebug) { console.debug( - "end of previous req/res: triggering new req/res callback" + "// queue request/response callback after previous request/response" ); + } + active[previous].res.on("end", () => { + if (console.isDebug) { + console.debug( + "end of previous req/res: triggering new req/res callback" + ); + } cb(req, res); }); } diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.js b/components/esp32-javascript/modules/esp32-js-eventloop/index.js index 3d52784..26ad8af 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.js +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.js @@ -12,7 +12,6 @@ var intervals = []; var handles = 0; exports.beforeSuspendHandlers = []; exports.afterSuspendHandlers = []; -// eslint-disable-next-line @typescript-eslint/ban-types function setTimeout(fn, timeout) { var handle = el_createTimer(timeout); timers.push({ @@ -39,7 +38,6 @@ function clearInterval(handle) { intervals.splice(idx, 1); } } -// eslint-disable-next-line @typescript-eslint/ban-types function installIntervalTimeout(handle, fn, timeout) { setTimeout(function () { if (intervals.indexOf(handle) >= 0) { @@ -48,7 +46,6 @@ function installIntervalTimeout(handle, fn, timeout) { } }, timeout); } -// eslint-disable-next-line @typescript-eslint/ban-types function setInterval(fn, timeout) { var handle = handles++; intervals.push(handle); @@ -62,11 +59,12 @@ function el_select_next() { }); } var events = el_suspend(); - // eslint-disable-next-line @typescript-eslint/ban-types var collected = []; var _loop_1 = function (evid) { var evt = events[evid]; - console.debug("HANDLE EVENT: " + JSON.stringify(evt)); + if (console.isDebug) { + console.debug("== HANDLE EVENT: " + JSON.stringify(evt) + " =="); + } if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT var nextTimer = null; @@ -77,7 +75,6 @@ function el_select_next() { } } if (!nextTimer) { - //throw Error('UNKNOWN TIMER HANDLE!!!'); console.warn("UNKNOWN TIMER HANDLE:" + JSON.stringify(evt) + ";" + @@ -86,25 +83,22 @@ function el_select_next() { } else if (evt.type === EL_LOG_EVENT_TYPE) { //LOG EVENT - var logevent_1 = evt; - collected.push(function () { - var logfunction = console.log; - switch (logevent_1.status) { - case 1: - logfunction = console.debug; - break; - case 2: - logfunction = console.info; - break; - case 3: - logfunction = console.warn; - break; - case 4: - logfunction = console.error; - break; - } - logfunction(el_readAndFreeString(logevent_1.fd)); - }); + var logfunction = console.log; + switch (evt.status) { + case 1: + logfunction = console.debug; + break; + case 2: + logfunction = console.info; + break; + case 3: + logfunction = console.warn; + break; + case 4: + logfunction = console.error; + break; + } + logfunction("LE " + evt.fd + ": " + el_readAndFreeString(evt.fd)); } else { var eventHandled_1 = false; @@ -126,7 +120,6 @@ function el_select_next() { return collected; } function start() { - // eslint-disable-next-line @typescript-eslint/ban-types var nextfuncs = [main]; for (;;) { if (Array.isArray(nextfuncs)) { diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts index 78fe21e..54390b7 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts @@ -24,15 +24,13 @@ SOFTWARE. interface Esp32JsTimer { handle: number; timeout: number; - // eslint-disable-next-line @typescript-eslint/ban-types - fn: Function; + fn: () => void; installed: boolean; } type Esp32JsEventHandler = ( event: Esp32JsEventloopEvent, - // eslint-disable-next-line @typescript-eslint/ban-types - collected: Function[] + collected: (() => void)[] ) => boolean; errorhandler = @@ -49,8 +47,7 @@ let handles = 0; export const beforeSuspendHandlers: (() => void)[] = []; export const afterSuspendHandlers: Esp32JsEventHandler[] = []; -// eslint-disable-next-line @typescript-eslint/ban-types -function setTimeout(fn: Function, timeout: number) { +function setTimeout(fn: () => void, timeout: number) { const handle = el_createTimer(timeout); timers.push({ timeout: Date.now() + timeout, @@ -79,8 +76,11 @@ function clearInterval(handle: number) { } } -// eslint-disable-next-line @typescript-eslint/ban-types -function installIntervalTimeout(handle: number, fn: Function, timeout: number) { +function installIntervalTimeout( + handle: number, + fn: () => void, + timeout: number +) { setTimeout(function () { if (intervals.indexOf(handle) >= 0) { fn(); @@ -89,8 +89,7 @@ function installIntervalTimeout(handle: number, fn: Function, timeout: number) { }, timeout); } -// eslint-disable-next-line @typescript-eslint/ban-types -function setInterval(fn: Function, timeout: number) { +function setInterval(fn: () => void, timeout: number) { const handle = handles++; intervals.push(handle); installIntervalTimeout(handle, fn, timeout); @@ -106,11 +105,12 @@ function el_select_next() { const events = el_suspend(); - // eslint-disable-next-line @typescript-eslint/ban-types - const collected: Function[] = []; + const collected: (() => void)[] = []; for (let evid = 0; evid < events.length; evid++) { const evt = events[evid]; - console.debug("HANDLE EVENT: " + JSON.stringify(evt)); + if (console.isDebug) { + console.debug(`== HANDLE EVENT: ${JSON.stringify(evt)} ==`); + } if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT let nextTimer = null; @@ -121,7 +121,6 @@ function el_select_next() { } } if (!nextTimer) { - //throw Error('UNKNOWN TIMER HANDLE!!!'); console.warn( "UNKNOWN TIMER HANDLE:" + JSON.stringify(evt) + @@ -131,25 +130,22 @@ function el_select_next() { } } else if (evt.type === EL_LOG_EVENT_TYPE) { //LOG EVENT - const logevent = evt; - collected.push(() => { - let logfunction = console.log; - switch (logevent.status) { - case 1: - logfunction = console.debug; - break; - case 2: - logfunction = console.info; - break; - case 3: - logfunction = console.warn; - break; - case 4: - logfunction = console.error; - break; - } - logfunction(el_readAndFreeString(logevent.fd)); - }); + let logfunction = console.log; + switch (evt.status) { + case 1: + logfunction = console.debug; + break; + case 2: + logfunction = console.info; + break; + case 3: + logfunction = console.warn; + break; + case 4: + logfunction = console.error; + break; + } + logfunction(`LE ${evt.fd}: ${el_readAndFreeString(evt.fd)}`); } else { let eventHandled = false; if (afterSuspendHandlers) { @@ -171,8 +167,7 @@ function el_select_next() { } export function start(): void { - // eslint-disable-next-line @typescript-eslint/ban-types - let nextfuncs: Function[] = [main]; + let nextfuncs: (() => void)[] = [main]; for (;;) { if (Array.isArray(nextfuncs)) { nextfuncs.forEach(function (nf) { diff --git a/components/socket-events/modules/socket-events/index.js b/components/socket-events/modules/socket-events/index.js index c6cbea0..422c30d 100644 --- a/components/socket-events/modules/socket-events/index.js +++ b/components/socket-events/modules/socket-events/index.js @@ -1,5 +1,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.sockListen = exports.sockConnect = exports.closeSocket = exports.sockets = void 0; +exports.sockListen = exports.sockConnect = exports.closeSocket = exports.el_debug_sockets = exports.sockets = void 0; /* MIT License @@ -29,14 +29,73 @@ exports.sockets = []; exports.sockets.pushNative = exports.sockets.push; exports.sockets.push = function (item) { exports.sockets.pushNative(item); + maintainSocketStatus(item.sockfd, item.isListening, item.isConnected, item.isError, item.onWritable); }; exports.sockets.find = function (predicate) { - for (var i = 0; i < exports.sockets.length; i++) { - if (predicate(exports.sockets[i])) { - return exports.sockets[i]; + for (var _i = 0, sockets_1 = exports.sockets; _i < sockets_1.length; _i++) { + var s = sockets_1[_i]; + if (predicate(s)) { + return s; } } }; +var NumberSet = /** @class */ (function () { + function NumberSet() { + this.set = []; + } + NumberSet.prototype.add = function (n) { + if (this.set.indexOf(n) < 0) { + this.set.push(n); + } + }; + NumberSet.prototype.remove = function (n) { + var i = this.set.indexOf(n); + if (i >= 0) { + this.set.splice(i, 1); + } + }; + return NumberSet; +}()); +// maintained socket status lists +var sst_notConnectedSockets = new NumberSet(); +var sst_connectedSockets = new NumberSet(); +var sst_connectedWritableSockets = new NumberSet(); +exports.el_debug_sockets = { + sockets: exports.sockets, + sst_notConnectedSockets: sst_notConnectedSockets, + sst_connectedSockets: sst_connectedSockets, + sst_connectedWritableSockets: sst_connectedWritableSockets, +}; +function maintainSocketStatus(sockfd, isListening, isConnected, isError, onWritable) { + // check if socket is still a valid actual socket + if (!exports.sockets.find(function (s) { return sockfd === s.sockfd; })) { + if (console.isDebug) { + console.debug("Invalid sockfd " + sockfd + " given to maintain."); + } + return; + } + if (console.isDebug) { + console.debug("Maintain socket status, sockfd: " + sockfd + ", isListening: " + isListening + ", isConnected: " + isConnected + ", isError: " + isError); + } + if (onWritable && isConnected && !isError) { + sst_connectedWritableSockets.add(sockfd); + } + else { + sst_connectedWritableSockets.remove(sockfd); + } + if (isConnected && !isError) { + sst_connectedSockets.add(sockfd); + } + else { + sst_connectedSockets.remove(sockfd); + } + if (!isConnected && !isListening && !isError) { + sst_notConnectedSockets.add(sockfd); + } + else { + sst_notConnectedSockets.remove(sockfd); + } +} /** * @class */ @@ -63,10 +122,10 @@ var Socket = /** @class */ (function () { this.onConnect = null; this.onError = null; this.onClose = null; - this.onWritable = null; - this.isConnected = false; - this.isError = false; - this.isListening = false; + this._onWritable = null; + this._isConnected = false; + this._isError = false; + this._isListening = false; this.ssl = null; this.flushAlways = true; } @@ -89,6 +148,53 @@ var Socket = /** @class */ (function () { }, this.readTimeout); } }; + Socket.prototype.maintainSocketStatus = function () { + maintainSocketStatus(this.sockfd, this.isListening, this.isConnected, this.isError, this.onWritable); + }; + Object.defineProperty(Socket.prototype, "isConnected", { + get: function () { + return this._isConnected; + }, + set: function (isConnected) { + this._isConnected = isConnected; + this.maintainSocketStatus(); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Socket.prototype, "isListening", { + get: function () { + return this._isListening; + }, + set: function (isListening) { + this._isListening = isListening; + this.maintainSocketStatus(); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Socket.prototype, "onWritable", { + get: function () { + return this._onWritable; + }, + set: function (onWritable) { + this._onWritable = onWritable; + this.maintainSocketStatus(); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Socket.prototype, "isError", { + get: function () { + return this._isError; + }, + set: function (isError) { + this._isError = isError; + this.maintainSocketStatus(); + }, + enumerable: false, + configurable: true + }); Socket.prototype.write = function (data) { if (this.dataBuffer) { if (typeof data === "undefined" || data === null) { @@ -132,12 +238,18 @@ var Socket = /** @class */ (function () { break; } else { - console.debug("before write to socket"); + if (console.isDebug) { + console.debug("before write to socket"); + } var ret = writeSocket(socket.sockfd, data, len - written, written, socket.ssl); - console.debug("after write to socket"); + if (console.isDebug) { + console.debug("after write to socket"); + } if (ret == 0) { // eagain, return immediately and wait for futher onWritable calls - console.debug("eagain in onWritable, socket " + socket.sockfd); + if (console.isDebug) { + console.debug("eagain in onWritable, socket " + socket.sockfd); + } // wait for next select when socket is writable break; } @@ -146,14 +258,16 @@ var Socket = /** @class */ (function () { entry.written = written; } else { - console.error("error writing to socket:" + ret); + console.error("error writing to socket " + socket.sockfd + ", return value was " + ret); break; } } } if (written >= len) { // remove entry because it has been written completely. - console.debug("// remove entry because it has been written completely."); + if (console.isDebug) { + console.debug("// remove entry because it has been written completely."); + } socket.writebuffer.shift(); if (entry.cb) { entry.cb(); @@ -331,7 +445,9 @@ function sockListen(port, onAccept, onError, onClose, isSSL) { } } else { - console.debug("EAGAIN received after accept..."); + if (console.isDebug) { + console.debug("EAGAIN received after accept..."); + } } }; socket.onError = function (sockfd) { @@ -351,42 +467,26 @@ function sockListen(port, onAccept, onError, onClose, isSSL) { } exports.sockListen = sockListen; function resetSocket(socket) { + if (console.isDebug) { + console.debug("Reset Socket called on " + socket.sockfd); + } if (socket) { + // free maintained socket status + sst_connectedSockets.remove(socket.sockfd); + sst_notConnectedSockets.remove(socket.sockfd); + sst_connectedWritableSockets.remove(socket.sockfd); + console.debug("CS " + sst_connectedSockets.set + " NC " + sst_notConnectedSockets.set + " CW " + sst_connectedWritableSockets.set); exports.sockets.splice(exports.sockets.indexOf(socket), 1); return; } throw Error("invalid sockfd"); } function beforeSuspend() { - //collect sockets - function notConnectedFilter(s) { - return !s.isConnected && !s.isListening; + if (console.isDebug) { + console.debug("Socket FDs for select.\n not connected =>" + sst_notConnectedSockets.set + "\n connected =>" + sst_connectedSockets.set + "\n connected wri =>" + sst_connectedWritableSockets.set + "\n"); } - function connectedFilter(s) { - return s.isConnected; - } - function connectedWritableFilter(s) { - return s.isConnected && s.onWritable; - } - function mapToSockfd(s) { - return s.sockfd; - } - function validSocketsFilter(s) { - return s.sockfd && !s.isError; - } - var validSockets = exports.sockets.filter(validSocketsFilter); - var notConnectedSockets = validSockets - .filter(notConnectedFilter) - .map(mapToSockfd); - var connectedSockets = validSockets - .filter(connectedFilter) - .map(mapToSockfd); - var connectedWritableSockets = validSockets - .filter(connectedWritableFilter) - .map(mapToSockfd); - el_registerSocketEvents(notConnectedSockets, connectedSockets, connectedWritableSockets); + el_registerSocketEvents(sst_notConnectedSockets.set, sst_connectedSockets.set, sst_connectedWritableSockets.set); } -// eslint-disable-next-line @typescript-eslint/ban-types function afterSuspend(evt, collected) { if (evt.type === EL_SOCKET_EVENT_TYPE) { var findSocket = exports.sockets.filter(function (s) { @@ -417,18 +517,27 @@ function afterSuspend(evt, collected) { collected.push(socket_1.onAccept); } else { - console.debug("before eventloop read socket"); + if (console.isDebug) { + console.debug("before eventloop read socket"); + } var result = readSocket(socket_1.sockfd, socket_1.ssl); - console.debug("after eventloop read socket"); + if (console.isDebug) { + console.debug("after eventloop read socket"); + } if (result === null || (result && Object.prototype.toString.call(result.data) === "[object Uint8Array]" && result.length == 0)) { + if (console.isDebug) { + console.debug("Read EOF from " + socket_1.sockfd + ". Closing..."); + } closeSocket(socket_1.sockfd); } else if (!result) { - console.debug("******** EAGAIN!!"); + if (console.isDebug) { + console.debug("******** EAGAIN!!"); + } } else { if (socket_1.onData) { diff --git a/components/socket-events/modules/socket-events/index.ts b/components/socket-events/modules/socket-events/index.ts index a33d21a..9c51968 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -97,17 +97,89 @@ interface SocketArrayFind { export const sockets: Socket[] & SocketArrayFind = [] as any; (sockets as any).pushNative = sockets.push; -(sockets as any).push = function (item: Esp32JsSocket) { +(sockets as any).push = function (item: Socket) { (sockets as any).pushNative(item); + maintainSocketStatus( + item.sockfd, + item.isListening, + item.isConnected, + item.isError, + item.onWritable + ); }; (sockets as any).find = function (predicate: (socket: Socket) => boolean) { - for (let i = 0; i < sockets.length; i++) { - if (predicate(sockets[i])) { - return sockets[i]; + for (const s of sockets) { + if (predicate(s)) { + return s; } } }; +class NumberSet { + public set: number[] = []; + public add(n: number) { + if (this.set.indexOf(n) < 0) { + this.set.push(n); + } + } + public remove(n: number) { + const i = this.set.indexOf(n); + if (i >= 0) { + this.set.splice(i, 1); + } + } +} +// maintained socket status lists +const sst_notConnectedSockets = new NumberSet(); +const sst_connectedSockets = new NumberSet(); +const sst_connectedWritableSockets = new NumberSet(); + +export const el_debug_sockets = { + sockets, + sst_notConnectedSockets, + sst_connectedSockets, + sst_connectedWritableSockets, +}; + +function maintainSocketStatus( + sockfd: number, + isListening: boolean, + isConnected: boolean, + isError: boolean, + onWritable: OnWritableCB | null +) { + // check if socket is still a valid actual socket + if (!sockets.find((s) => sockfd === s.sockfd)) { + if (console.isDebug) { + console.debug(`Invalid sockfd ${sockfd} given to maintain.`); + } + return; + } + + if (console.isDebug) { + console.debug( + `Maintain socket status, sockfd: ${sockfd}, isListening: ${isListening}, isConnected: ${isConnected}, isError: ${isError}` + ); + } + + if (onWritable && isConnected && !isError) { + sst_connectedWritableSockets.add(sockfd); + } else { + sst_connectedWritableSockets.remove(sockfd); + } + + if (isConnected && !isError) { + sst_connectedSockets.add(sockfd); + } else { + sst_connectedSockets.remove(sockfd); + } + + if (!isConnected && !isListening && !isError) { + sst_notConnectedSockets.add(sockfd); + } else { + sst_notConnectedSockets.remove(sockfd); + } +} interface BufferEntry { written: number; data: Uint8Array; @@ -162,13 +234,59 @@ class Socket implements Esp32JsSocket { public onConnect: OnConnectCB | null = null; public onError: OnErrorCB | null = null; public onClose: OnCloseCB | null = null; - public onWritable: OnWritableCB | null = null; - public isConnected = false; - public isError = false; - public isListening = false; + private _onWritable: OnWritableCB | null = null; + private _isConnected = false; + public _isError = false; + private _isListening = false; public ssl: any = null; public flushAlways = true; + private maintainSocketStatus() { + maintainSocketStatus( + this.sockfd, + this.isListening, + this.isConnected, + this.isError, + this.onWritable + ); + } + + public set isConnected(isConnected: boolean) { + this._isConnected = isConnected; + this.maintainSocketStatus(); + } + + public get isConnected() { + return this._isConnected; + } + + public set isListening(isListening: boolean) { + this._isListening = isListening; + this.maintainSocketStatus(); + } + + public get isListening() { + return this._isListening; + } + + public set onWritable(onWritable: OnWritableCB | null) { + this._onWritable = onWritable; + this.maintainSocketStatus(); + } + + public get onWritable() { + return this._onWritable; + } + + public set isError(isError: boolean) { + this._isError = isError; + this.maintainSocketStatus(); + } + + public get isError() { + return this._isError; + } + public write(data: string | Uint8Array) { if (this.dataBuffer) { if (typeof data === "undefined" || data === null) { @@ -213,7 +331,9 @@ class Socket implements Esp32JsSocket { console.error("error writing to socket. not initialized."); break; } else { - console.debug("before write to socket"); + if (console.isDebug) { + console.debug("before write to socket"); + } const ret = writeSocket( socket.sockfd, data, @@ -221,10 +341,14 @@ class Socket implements Esp32JsSocket { written, socket.ssl ); - console.debug("after write to socket"); + if (console.isDebug) { + console.debug("after write to socket"); + } if (ret == 0) { // eagain, return immediately and wait for futher onWritable calls - console.debug("eagain in onWritable, socket " + socket.sockfd); + if (console.isDebug) { + console.debug("eagain in onWritable, socket " + socket.sockfd); + } // wait for next select when socket is writable break; } @@ -232,16 +356,20 @@ class Socket implements Esp32JsSocket { written += ret; entry.written = written; } else { - console.error("error writing to socket:" + ret); + console.error( + `error writing to socket ${socket.sockfd}, return value was ${ret}` + ); break; } } } if (written >= len) { // remove entry because it has been written completely. - console.debug( - "// remove entry because it has been written completely." - ); + if (console.isDebug) { + console.debug( + "// remove entry because it has been written completely." + ); + } socket.writebuffer.shift(); if (entry.cb) { entry.cb(); @@ -350,7 +478,7 @@ export function sockConnect( ): Esp32JsSocket { const sockfd = el_createNonBlockingSocket(); el_connectNonBlocking(sockfd, host, parseInt(port, 10)); - + const socket = getOrCreateNewSocket(); socket.sockfd = sockfd; socket.onData = onData; @@ -444,7 +572,9 @@ export function sockListen( } } } else { - console.debug("EAGAIN received after accept..."); + if (console.isDebug) { + console.debug("EAGAIN received after accept..."); + } } }; socket.onError = function (sockfd) { @@ -465,7 +595,19 @@ export function sockListen( } function resetSocket(socket: Socket) { + if (console.isDebug) { + console.debug(`Reset Socket called on ${socket.sockfd}`); + } if (socket) { + // free maintained socket status + sst_connectedSockets.remove(socket.sockfd); + sst_notConnectedSockets.remove(socket.sockfd); + sst_connectedWritableSockets.remove(socket.sockfd); + + console.debug( + `CS ${sst_connectedSockets.set} NC ${sst_notConnectedSockets.set} CW ${sst_connectedWritableSockets.set}` + ); + sockets.splice(sockets.indexOf(socket), 1); return; } @@ -473,43 +615,22 @@ function resetSocket(socket: Socket) { } function beforeSuspend() { - //collect sockets - function notConnectedFilter(s: Socket) { - return !s.isConnected && !s.isListening; - } - function connectedFilter(s: Socket) { - return s.isConnected; + if (console.isDebug) { + console.debug(`Socket FDs for select. + not connected =>${sst_notConnectedSockets.set} + connected =>${sst_connectedSockets.set} + connected wri =>${sst_connectedWritableSockets.set} +`); } - function connectedWritableFilter(s: Socket) { - return s.isConnected && s.onWritable; - } - function mapToSockfd(s: Socket) { - return s.sockfd; - } - function validSocketsFilter(s: Socket) { - return s.sockfd && !s.isError; - } - - const validSockets = sockets.filter(validSocketsFilter); - const notConnectedSockets = validSockets - .filter(notConnectedFilter) - .map(mapToSockfd); - const connectedSockets = validSockets - .filter(connectedFilter) - .map(mapToSockfd); - const connectedWritableSockets = validSockets - .filter(connectedWritableFilter) - .map(mapToSockfd); el_registerSocketEvents( - notConnectedSockets, - connectedSockets, - connectedWritableSockets + sst_notConnectedSockets.set, + sst_connectedSockets.set, + sst_connectedWritableSockets.set ); } -// eslint-disable-next-line @typescript-eslint/ban-types -function afterSuspend(evt: Esp32JsEventloopEvent, collected: Function[]) { +function afterSuspend(evt: Esp32JsEventloopEvent, collected: (() => void)[]) { if (evt.type === EL_SOCKET_EVENT_TYPE) { const findSocket = sockets.filter((s) => { return s.sockfd === evt.fd; @@ -536,9 +657,13 @@ function afterSuspend(evt: Esp32JsEventloopEvent, collected: Function[]) { if (socket.isListening && socket.onAccept) { collected.push(socket.onAccept); } else { - console.debug("before eventloop read socket"); + if (console.isDebug) { + console.debug("before eventloop read socket"); + } const result = readSocket(socket.sockfd, socket.ssl); - console.debug("after eventloop read socket"); + if (console.isDebug) { + console.debug("after eventloop read socket"); + } if ( result === null || (result && @@ -546,9 +671,14 @@ function afterSuspend(evt: Esp32JsEventloopEvent, collected: Function[]) { "[object Uint8Array]" && result.length == 0) ) { + if (console.isDebug) { + console.debug(`Read EOF from ${socket.sockfd}. Closing...`); + } closeSocket(socket.sockfd); } else if (!result) { - console.debug("******** EAGAIN!!"); + if (console.isDebug) { + console.debug("******** EAGAIN!!"); + } } else { if (socket.onData) { socket.extendReadTimeout(); diff --git a/components/socket-events/socket-events.c b/components/socket-events/socket-events.c index 3b9542e..dfb8c1e 100644 --- a/components/socket-events/socket-events.c +++ b/components/socket-events/socket-events.c @@ -242,10 +242,6 @@ void select_task_it() { jslog(ERROR, "READ self-socket FAILED: %d", errno); } - else - { - jslog(DEBUG, "READ of self-socket."); - } } FD_SET(selectServerSocket, &readset); @@ -256,7 +252,6 @@ void select_task_it() // self socket end int ret = select(sockfd_max + 1, &readset, &writeset, &errset, NULL); needsUnblock = true; - jslog(DEBUG, "Select return %d.", ret); if (ret >= 0) { if (ret > 0) @@ -514,7 +509,7 @@ static duk_ret_t el_acceptIncoming(duk_context *ctx) { if (errno == EAGAIN) { - jslog(INFO, "accept returned EAGAIN"); + jslog(DEBUG, "accept returned EAGAIN"); //return undefined return 0; } diff --git a/components/socket-events/tcp.c b/components/socket-events/tcp.c index 3aeffc4..542eae2 100644 --- a/components/socket-events/tcp.c +++ b/components/socket-events/tcp.c @@ -169,12 +169,12 @@ int writeSocket(int sockfd, const char *msg, int len, SSL *ssl) { if (errno == EAGAIN) { - jslog(INFO, "EAGAIN in socket: %d", errno); + jslog(DEBUG, "EAGAIN in socket %d, errno %d", sockfd, errno); return 0; } else { - jslog(ERROR, "ERROR writing to socket: %d", errno); + jslog(ERROR, "ERROR writing to socket %d, errno %d", sockfd, errno); return n; } } diff --git a/components/wifi-events/modules/wifi-events/index.js b/components/wifi-events/modules/wifi-events/index.js index 35e3526..94ce0e3 100644 --- a/components/wifi-events/modules/wifi-events/index.js +++ b/components/wifi-events/modules/wifi-events/index.js @@ -91,7 +91,6 @@ function getIPAddress() { return wifi === null || wifi === void 0 ? void 0 : wifi.ip; } exports.getIPAddress = getIPAddress; -// eslint-disable-next-line @typescript-eslint/ban-types function afterSuspend(evt, collected) { if (evt.type === EL_WIFI_EVENT_TYPE) { collected.push(function () { diff --git a/components/wifi-events/modules/wifi-events/index.ts b/components/wifi-events/modules/wifi-events/index.ts index 8448ec6..aca2628 100644 --- a/components/wifi-events/modules/wifi-events/index.ts +++ b/components/wifi-events/modules/wifi-events/index.ts @@ -117,8 +117,7 @@ export function getIPAddress(): string | undefined { return wifi?.ip; } -// eslint-disable-next-line @typescript-eslint/ban-types -function afterSuspend(evt: Esp32JsEventloopEvent, collected: Function[]) { +function afterSuspend(evt: Esp32JsEventloopEvent, collected: (() => void)[]) { if (evt.type === EL_WIFI_EVENT_TYPE) { collected.push(() => { if (wifi) { diff --git a/tsconfig.json b/tsconfig.json index 1faf847..8fccdd9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,5 @@ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ }, - "exclude": [ - "build" - ] -} \ No newline at end of file + "exclude": ["build"] +} From b9f252dcad7899e8a7ee8adf16549090a6cf30c4 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sun, 30 May 2021 19:16:28 +0200 Subject: [PATCH 08/19] fix: some further improvements of logging and socket-events --- .../esp32-javascript/esp32-javascript.c | 18 +- .../modules/esp32-javascript/boot.js | 2 +- .../modules/esp32-javascript/boot.ts | 135 ++++++----- .../modules/esp32-javascript/config.ts | 1 + .../modules/esp32-javascript/configserver.js | 9 +- .../modules/esp32-javascript/configserver.ts | 8 + .../esp32-javascript/esp32-javascript.d.ts | 8 +- .../modules/esp32-javascript/filelogging.js | 10 +- .../modules/esp32-javascript/filelogging.ts | 11 +- .../modules/esp32-javascript/index.js | 64 ++--- .../modules/esp32-javascript/index.ts | 62 ++--- .../modules/esp32-js-eventloop/index.js | 2 +- .../modules/esp32-js-eventloop/index.ts | 2 +- .../modules/socket-events/index.js | 161 ++++++------- .../modules/socket-events/index.ts | 227 +++++++----------- .../wifi-events/modules/wifi-events/index.js | 39 ++- .../wifi-events/modules/wifi-events/index.ts | 48 +++- components/wifi-events/wifi-events.c | 77 +++++- 18 files changed, 497 insertions(+), 387 deletions(-) diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 70dfb9a..087f1dc 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -410,11 +410,6 @@ static void createConsole(duk_context *ctx) static duk_ret_t el_suspend(duk_context *ctx) { - // force garbage collection 2 times see duktape doc - // greatly increases perfomance with external memory - duk_gc(ctx, 0); - duk_gc(ctx, 0); - // feed watchdog vTaskDelay(1); @@ -426,6 +421,19 @@ static duk_ret_t el_suspend(duk_context *ctx) int arrsize = 0; TickType_t timeout = portMAX_DELAY; + // force garbage collection 2 times see duktape doc + // greatly increases perfomance with external memory + duk_gc(ctx, 0); + if (uxQueueMessagesWaiting(el_event_queue) == 0) + { + // if no event is waiting also compact heap + duk_gc(ctx, DUK_GC_COMPACT); + } + else + { + duk_gc(ctx, 0); + } + while (xQueueReceive(el_event_queue, &events, timeout) == pdTRUE) { timeout = 0; // set timeout to 0 to not wait in while loop if there are no more events available diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.js b/components/esp32-javascript/modules/esp32-javascript/boot.js index afe096d..ded505c 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.js +++ b/components/esp32-javascript/modules/esp32-javascript/boot.js @@ -207,7 +207,7 @@ function connectToWifi() { else if (evt.status === 2) { console.debug("WIFI: CONNECTING..."); } - }); + }, config_1.config.wifi.bssid); } function main() { var _a, _b; diff --git a/components/esp32-javascript/modules/esp32-javascript/boot.ts b/components/esp32-javascript/modules/esp32-javascript/boot.ts index 56fe564..b3b066c 100644 --- a/components/esp32-javascript/modules/esp32-javascript/boot.ts +++ b/components/esp32-javascript/modules/esp32-javascript/boot.ts @@ -148,75 +148,82 @@ function connectToWifi() { } let retries = 0; - wifi.connectWifi(config.wifi.ssid, config.wifi.password, function (evt, ip) { - if (evt.status === 0) { - console.debug("WIFI: DISCONNECTED"); - if (!configServerStarted) { - retries++; - } - if (!configServerStarted && retries === 5) { - console.warn("Maximum retries exceeded to connect to wifi."); - if (config?.ota?.offline) { - stopWifi(); - loadOfflineScript(); - } else { - console.warn("No offline script was found."); - startSoftApMode(); - } - } - } else if (evt.status === 1) { - if (!programLoaded) { - console.info("WIFI: CONNECTED [" + ip + "]"); - + wifi.connectWifi( + config.wifi.ssid, + config.wifi.password, + function (evt, ip) { + if (evt.status === 0) { + console.debug("WIFI: DISCONNECTED"); if (!configServerStarted) { - configServer.startConfigServer(); - configServerStarted = true; + retries++; + } + if (!configServerStarted && retries === 5) { + console.warn("Maximum retries exceeded to connect to wifi."); + if (config?.ota?.offline) { + stopWifi(); + loadOfflineScript(); + } else { + console.warn("No offline script was found."); + startSoftApMode(); + } } + } else if (evt.status === 1) { + if (!programLoaded) { + console.info("WIFI: CONNECTED [" + ip + "]"); - retries = 0; - - if (config?.ota?.url) { - programLoaded = true; - console.info("Loading program from: " + config.ota.url); - - let headers: Headers; - fetch(config.ota.url) - .then(function (r) { - headers = r.headers; - return r.text(); - }) - .then(function (data) { - if (config?.ota?.offline) { - config.ota.script = data; - saveConfig(config); - console.info("==> Saved offline script length=" + data.length); - } else { - console.info("==> NOT saving offline script"); - } - - const dateString = headers.get("Date"); - if (dateString) { - const now = parseDate(dateString); - setDateTimeInMillis(now.getTime()); - setDateTimeZoneOffsetInHours(2); - setBootTime(new Date()); - console.debug(`Setting boot time to ${getBootTime()}`); - } - evalScript(data, headers); - }) - .catch(function (error) { - console.error(error); - startSoftApMode(); - }); - } else { - console.error("No OTA (Over-the-air) url specified."); - loadOfflineScript(); + if (!configServerStarted) { + configServer.startConfigServer(); + configServerStarted = true; + } + + retries = 0; + + if (config?.ota?.url) { + programLoaded = true; + console.info("Loading program from: " + config.ota.url); + + let headers: Headers; + fetch(config.ota.url) + .then(function (r) { + headers = r.headers; + return r.text(); + }) + .then(function (data) { + if (config?.ota?.offline) { + config.ota.script = data; + saveConfig(config); + console.info( + "==> Saved offline script length=" + data.length + ); + } else { + console.info("==> NOT saving offline script"); + } + + const dateString = headers.get("Date"); + if (dateString) { + const now = parseDate(dateString); + setDateTimeInMillis(now.getTime()); + setDateTimeZoneOffsetInHours(2); + setBootTime(new Date()); + console.debug(`Setting boot time to ${getBootTime()}`); + } + evalScript(data, headers); + }) + .catch(function (error) { + console.error(error); + startSoftApMode(); + }); + } else { + console.error("No OTA (Over-the-air) url specified."); + loadOfflineScript(); + } } + } else if (evt.status === 2) { + console.debug("WIFI: CONNECTING..."); } - } else if (evt.status === 2) { - console.debug("WIFI: CONNECTING..."); - } - }); + }, + config.wifi.bssid + ); } export function main(): void { diff --git a/components/esp32-javascript/modules/esp32-javascript/config.ts b/components/esp32-javascript/modules/esp32-javascript/config.ts index b3106eb..2b0ba0c 100644 --- a/components/esp32-javascript/modules/esp32-javascript/config.ts +++ b/components/esp32-javascript/modules/esp32-javascript/config.ts @@ -30,6 +30,7 @@ export interface Esp32JsConfig { wifi?: { ssid?: string; password?: string; + bssid?: string; }; ota?: { url?: string; diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index 2764f24..3e830a5 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -78,6 +78,10 @@ var schema = { type: "string", title: "Password", }, + bssid: { + type: "string", + title: "BSSID", + }, }, }, ota: { @@ -170,7 +174,7 @@ function startConfigServer() { ":" + configManager.config.access.password); http_1.httpServer(80, false, function (req, res) { - var _a, _b, _c, _d, _e; + var _a, _b, _c, _d, _e, _f; if (req.headers.get("authorization") !== authString && exports.baExceptionPathes.indexOf(req.path) < 0) { console.debug("401 response"); @@ -196,6 +200,7 @@ function startConfigServer() { var config_1 = http_1.parseQueryStr(req.body); storedConfig.wifi.ssid = config_1.ssid; storedConfig.wifi.password = config_1.password; + storedConfig.wifi.bssid = config_1.bssid; storedConfig.access.username = config_1.username; storedConfig.access.password = config_1.userpass; storedConfig.ota.url = config_1.url; @@ -211,7 +216,7 @@ function startConfigServer() { var config = configManager.config; page(res, "Setup", "" + (successMessage ? "
" + successMessage + "
" - : "") + (errorMessage ? "
" + errorMessage + "
" : "") + "

Configuration

Wifi

\n
\n
\n

Basic authentication

\n
\n
\n

JavaScript OTA

\n
\n
\n
\n

Logs

\n
\n

\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.
\n

\n " + getLogFileList() + : "") + (errorMessage ? "
" + errorMessage + "
" : "") + "

Configuration

Wifi

\n
\n
\n
\n

Basic authentication

\n
\n
\n

JavaScript OTA

\n
\n
\n
\n

Logs

\n
\n

\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.
\n

\n " + getLogFileList() .map(function (e) { return e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB)

"; }) diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index 88061b1..ebfc3a7 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -76,6 +76,10 @@ let schema = { type: "string", title: "Password", }, + bssid: { + type: "string", + title: "BSSID", + }, }, }, ota: { @@ -265,6 +269,7 @@ export function startConfigServer(): void { const config = parseQueryStr(req.body); storedConfig.wifi.ssid = config.ssid; storedConfig.wifi.password = config.password; + storedConfig.wifi.bssid = config.bssid; storedConfig.access.username = config.username; storedConfig.access.password = config.userpass; storedConfig.ota.url = config.url; @@ -295,6 +300,9 @@ export function startConfigServer(): void {
+

Basic authentication

exports.LOG_FILE_SIZE_LIMIT) { logFileNumber++; } diff --git a/components/esp32-javascript/modules/esp32-javascript/filelogging.ts b/components/esp32-javascript/modules/esp32-javascript/filelogging.ts index 17d9cd9..36554c4 100644 --- a/components/esp32-javascript/modules/esp32-javascript/filelogging.ts +++ b/components/esp32-javascript/modules/esp32-javascript/filelogging.ts @@ -25,7 +25,7 @@ import { StringBuffer } from "./stringbuffer"; export const FILE_LOGGING_DIRECTORY = "/data/logs"; export const LOG_FILE_SIZE_LIMIT = 10240; -export const LOG_FILE_NUM_LIMIT = 10; +export const LOG_FILE_NUM_LIMIT = 8; const TDIWEF = "TDIWEF"; const NUMBER_PREFIX = "00000000"; @@ -57,10 +57,13 @@ function cleanupOldLogs() { } global.el_flushLogBuffer = function (): void { - const swap = global.logBuffer; - global.logBuffer = new StringBuffer(); const logFile = `${FILE_LOGGING_DIRECTORY}/logs-${getLogFileNumber()}.txt`; - appendFile(logFile, swap.toString()); + const ret = appendFile(logFile, global.logBuffer.toString()); + if (ret < 0) { + console.error("Could not flush log file. Space exceeded?"); + } + + global.logBuffer = new StringBuffer(); if (fileSize(logFile) > LOG_FILE_SIZE_LIMIT) { logFileNumber++; } diff --git a/components/esp32-javascript/modules/esp32-javascript/index.js b/components/esp32-javascript/modules/esp32-javascript/index.js index d852470..55842a2 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.js +++ b/components/esp32-javascript/modules/esp32-javascript/index.js @@ -21,33 +21,37 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -Object.defineProperty(exports, "__esModule", { value: true }); -console.info("Load global.js (NEW)..."); -require("./global.js"); -console.info("Loading file logging buffer (NEW)..."); -require("./filelogging"); -console.info("Importing http (NEW)..."); -var http = require("./http"); -console.info("Importing boot (NEW)..."); -var boot = require("./boot"); -console.info("Importing eventloop (NEW)..."); -var eventloop = require("esp32-js-eventloop"); -console.info("Importing config (NEW)..."); -var configManager = require("./config"); -console.info("Loading promise.js and exposing globals (NEW)..."); -// eslint-disable-next-line @typescript-eslint/no-var-requires -global.Promise = require("./promise.js").Promise; -console.info("Loading config (NEW)..."); -configManager.reloadConfig(); -console.info("Loading http.js and exposing globals (NEW)..."); -global.XMLHttpRequest = http.XMLHttpRequest; -console.info("Loading fetch.js and exposing globals (NEW)..."); -require("./fetch.js"); -console.info("Loading boot.js and exposing main (NEW)..."); -global.main = boot.main; -console.info("Loading socket-events (NEW)..."); -require("socket-events"); -console.info("Loading wifi-events (NEW)..."); -require("wifi-events"); -console.info("Loading eventloop.js and starting eventloop (NEW)..."); -eventloop.start(); +/* eslint-disable @typescript-eslint/no-var-requires */ +try { + console.info("Load global.js (NEW)..."); + require("./global.js"); + console.info("Loading file logging buffer (NEW)..."); + require("./filelogging"); + console.info("Importing http (NEW)..."); + var http = require("./http"); + console.info("Importing boot (NEW)..."); + var boot = require("./boot"); + console.info("Importing eventloop (NEW)..."); + var eventloop = require("esp32-js-eventloop"); + console.info("Importing config (NEW)..."); + var configManager = require("./config"); + console.info("Loading promise.js and exposing globals (NEW)..."); + global.Promise = require("./promise.js").Promise; + console.info("Loading config (NEW)..."); + configManager.reloadConfig(); + console.info("Loading http.js and exposing globals (NEW)..."); + global.XMLHttpRequest = http.XMLHttpRequest; + console.info("Loading fetch.js and exposing globals (NEW)..."); + require("./fetch.js"); + console.info("Loading boot.js and exposing main (NEW)..."); + global.main = boot.main; + console.info("Loading socket-events (NEW)..."); + require("socket-events"); + console.info("Loading wifi-events (NEW)..."); + require("wifi-events"); + console.info("Loading eventloop.js and starting eventloop (NEW)..."); + eventloop.start(); +} +catch (error) { + console.error(error.stack || error); +} diff --git a/components/esp32-javascript/modules/esp32-javascript/index.ts b/components/esp32-javascript/modules/esp32-javascript/index.ts index bcc4c65..d7cda92 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.ts +++ b/components/esp32-javascript/modules/esp32-javascript/index.ts @@ -21,46 +21,50 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* eslint-disable @typescript-eslint/no-var-requires */ -console.info("Load global.js (NEW)..."); -require("./global.js"); +try { + console.info("Load global.js (NEW)..."); + require("./global.js"); -console.info("Loading file logging buffer (NEW)..."); -require("./filelogging"); + console.info("Loading file logging buffer (NEW)..."); + require("./filelogging"); -console.info("Importing http (NEW)..."); -import http = require("./http"); + console.info("Importing http (NEW)..."); + const http = require("./http"); -console.info("Importing boot (NEW)..."); -import boot = require("./boot"); + console.info("Importing boot (NEW)..."); + const boot = require("./boot"); -console.info("Importing eventloop (NEW)..."); -import eventloop = require("esp32-js-eventloop"); + console.info("Importing eventloop (NEW)..."); + const eventloop = require("esp32-js-eventloop"); -console.info("Importing config (NEW)..."); -import configManager = require("./config"); + console.info("Importing config (NEW)..."); + const configManager = require("./config"); -console.info("Loading promise.js and exposing globals (NEW)..."); -// eslint-disable-next-line @typescript-eslint/no-var-requires -global.Promise = require("./promise.js").Promise; + console.info("Loading promise.js and exposing globals (NEW)..."); + global.Promise = require("./promise.js").Promise; -console.info("Loading config (NEW)..."); -configManager.reloadConfig(); + console.info("Loading config (NEW)..."); + configManager.reloadConfig(); -console.info("Loading http.js and exposing globals (NEW)..."); -global.XMLHttpRequest = http.XMLHttpRequest; + console.info("Loading http.js and exposing globals (NEW)..."); + global.XMLHttpRequest = http.XMLHttpRequest; -console.info("Loading fetch.js and exposing globals (NEW)..."); -require("./fetch.js"); + console.info("Loading fetch.js and exposing globals (NEW)..."); + require("./fetch.js"); -console.info("Loading boot.js and exposing main (NEW)..."); -global.main = boot.main; + console.info("Loading boot.js and exposing main (NEW)..."); + global.main = boot.main; -console.info("Loading socket-events (NEW)..."); -require("socket-events"); + console.info("Loading socket-events (NEW)..."); + require("socket-events"); -console.info("Loading wifi-events (NEW)..."); -require("wifi-events"); + console.info("Loading wifi-events (NEW)..."); + require("wifi-events"); -console.info("Loading eventloop.js and starting eventloop (NEW)..."); -eventloop.start(); + console.info("Loading eventloop.js and starting eventloop (NEW)..."); + eventloop.start(); +} catch (error) { + console.error(error.stack || error); +} diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.js b/components/esp32-javascript/modules/esp32-js-eventloop/index.js index 26ad8af..5a565e7 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.js +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.js @@ -98,7 +98,7 @@ function el_select_next() { logfunction = console.error; break; } - logfunction("LE " + evt.fd + ": " + el_readAndFreeString(evt.fd)); + logfunction(el_readAndFreeString(evt.fd)); } else { var eventHandled_1 = false; diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts index 54390b7..92b232d 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts @@ -145,7 +145,7 @@ function el_select_next() { logfunction = console.error; break; } - logfunction(`LE ${evt.fd}: ${el_readAndFreeString(evt.fd)}`); + logfunction(el_readAndFreeString(evt.fd)); } else { let eventHandled = false; if (afterSuspendHandlers) { diff --git a/components/socket-events/modules/socket-events/index.js b/components/socket-events/modules/socket-events/index.js index 422c30d..d930a36 100644 --- a/components/socket-events/modules/socket-events/index.js +++ b/components/socket-events/modules/socket-events/index.js @@ -1,5 +1,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.sockListen = exports.sockConnect = exports.closeSocket = exports.el_debug_sockets = exports.sockets = void 0; +exports.sockListen = exports.sockConnect = exports.closeSocket = exports.sockets = void 0; /* MIT License @@ -25,20 +25,6 @@ SOFTWARE. */ var esp32_js_eventloop_1 = require("esp32-js-eventloop"); var sslClientCtx; -exports.sockets = []; -exports.sockets.pushNative = exports.sockets.push; -exports.sockets.push = function (item) { - exports.sockets.pushNative(item); - maintainSocketStatus(item.sockfd, item.isListening, item.isConnected, item.isError, item.onWritable); -}; -exports.sockets.find = function (predicate) { - for (var _i = 0, sockets_1 = exports.sockets; _i < sockets_1.length; _i++) { - var s = sockets_1[_i]; - if (predicate(s)) { - return s; - } - } -}; var NumberSet = /** @class */ (function () { function NumberSet() { this.set = []; @@ -56,46 +42,75 @@ var NumberSet = /** @class */ (function () { }; return NumberSet; }()); -// maintained socket status lists -var sst_notConnectedSockets = new NumberSet(); -var sst_connectedSockets = new NumberSet(); -var sst_connectedWritableSockets = new NumberSet(); -exports.el_debug_sockets = { - sockets: exports.sockets, - sst_notConnectedSockets: sst_notConnectedSockets, - sst_connectedSockets: sst_connectedSockets, - sst_connectedWritableSockets: sst_connectedWritableSockets, -}; -function maintainSocketStatus(sockfd, isListening, isConnected, isError, onWritable) { - // check if socket is still a valid actual socket - if (!exports.sockets.find(function (s) { return sockfd === s.sockfd; })) { - if (console.isDebug) { - console.debug("Invalid sockfd " + sockfd + " given to maintain."); - } - return; - } - if (console.isDebug) { - console.debug("Maintain socket status, sockfd: " + sockfd + ", isListening: " + isListening + ", isConnected: " + isConnected + ", isError: " + isError); - } - if (onWritable && isConnected && !isError) { - sst_connectedWritableSockets.add(sockfd); - } - else { - sst_connectedWritableSockets.remove(sockfd); +var SocketLookupMap = /** @class */ (function () { + function SocketLookupMap() { + this.map = {}; } - if (isConnected && !isError) { - sst_connectedSockets.add(sockfd); - } - else { - sst_connectedSockets.remove(sockfd); - } - if (!isConnected && !isListening && !isError) { - sst_notConnectedSockets.add(sockfd); - } - else { - sst_notConnectedSockets.remove(sockfd); + SocketLookupMap.prototype.add = function (item) { + this.map[item.sockfd] = item; + }; + SocketLookupMap.prototype.get = function (sockfd) { + return this.map[sockfd]; + }; + SocketLookupMap.prototype.remove = function (sockfd) { + delete this.map[sockfd]; + }; + return SocketLookupMap; +}()); +var ActiveSockets = /** @class */ (function () { + function ActiveSockets() { + this.activeSockets = new SocketLookupMap(); + // maintained socket status lists + this.sst_notConnectedSockets = new NumberSet(); + this.sst_connectedSockets = new NumberSet(); + this.sst_connectedWritableSockets = new NumberSet(); } -} + ActiveSockets.prototype.maintainSocketStatus = function (sockfd, isListening, isConnected, isError, onWritable) { + // check if socket is still a valid actual socket + if (!this.get(sockfd)) { + if (console.isDebug) { + console.debug("Invalid sockfd " + sockfd + " given to maintain."); + } + return; + } + if (console.isDebug) { + console.debug("Maintain socket status, sockfd: " + sockfd + ", isListening: " + isListening + ", isConnected: " + isConnected + ", isError: " + isError); + } + if (onWritable && isConnected && !isError) { + this.sst_connectedWritableSockets.add(sockfd); + } + else { + this.sst_connectedWritableSockets.remove(sockfd); + } + if (isConnected && !isError) { + this.sst_connectedSockets.add(sockfd); + } + else { + this.sst_connectedSockets.remove(sockfd); + } + if (!isConnected && !isListening && !isError) { + this.sst_notConnectedSockets.add(sockfd); + } + else { + this.sst_notConnectedSockets.remove(sockfd); + } + }; + ActiveSockets.prototype.add = function (item) { + this.activeSockets.add(item); + this.maintainSocketStatus(item.sockfd, item.isListening, item.isConnected, item.isError, item.onWritable); + }; + ActiveSockets.prototype.remove = function (sockfd) { + this.sst_connectedSockets.remove(sockfd); + this.sst_notConnectedSockets.remove(sockfd); + this.sst_connectedWritableSockets.remove(sockfd); + this.activeSockets.remove(sockfd); + }; + ActiveSockets.prototype.get = function (sockfd) { + return this.activeSockets.get(sockfd); + }; + return ActiveSockets; +}()); +exports.sockets = new ActiveSockets(); /** * @class */ @@ -149,7 +164,7 @@ var Socket = /** @class */ (function () { } }; Socket.prototype.maintainSocketStatus = function () { - maintainSocketStatus(this.sockfd, this.isListening, this.isConnected, this.isError, this.onWritable); + exports.sockets.maintainSocketStatus(this.sockfd, this.isListening, this.isConnected, this.isError, this.onWritable); }; Object.defineProperty(Socket.prototype, "isConnected", { get: function () { @@ -314,16 +329,12 @@ function performOnClose(socket) { * @param {(module:socket-events~Socket|number)} */ function closeSocket(socketOrSockfd) { - var socket = null; + var socket; if (typeof socketOrSockfd === "number") { - socket = exports.sockets.find(function (s) { - return s.sockfd === socketOrSockfd; - }); + socket = exports.sockets.get(socketOrSockfd); } else if (typeof socketOrSockfd === "object") { - socket = exports.sockets.find(function (s) { - return s.sockfd === socketOrSockfd.sockfd; - }); + socket = exports.sockets.get(socketOrSockfd.sockfd); } if (!socket) { console.debug("Socket not found for closing! Maybe already closed, doing nothing."); @@ -391,9 +402,7 @@ function sockConnect(ssl, host, port, onConnect, onData, onError, onClose) { } }; } - if (exports.sockets.indexOf(socket) < 0) { - exports.sockets.push(socket); - } + exports.sockets.add(socket); return socket; } exports.sockConnect = sockConnect; @@ -431,9 +440,7 @@ function sockListen(port, onAccept, onError, onClose, isSSL) { newSocket.isError = false; newSocket.isListening = false; newSocket.ssl = ssl; - if (exports.sockets.indexOf(newSocket) < 0) { - exports.sockets.push(newSocket); - } + exports.sockets.add(newSocket); if (onAccept) { onAccept(newSocket); } @@ -459,9 +466,7 @@ function sockListen(port, onAccept, onError, onClose, isSSL) { socket.isConnected = true; socket.isError = false; socket.isListening = true; - if (exports.sockets.indexOf(socket) < 0) { - exports.sockets.push(socket); - } + exports.sockets.add(socket); return socket; } } @@ -471,28 +476,20 @@ function resetSocket(socket) { console.debug("Reset Socket called on " + socket.sockfd); } if (socket) { - // free maintained socket status - sst_connectedSockets.remove(socket.sockfd); - sst_notConnectedSockets.remove(socket.sockfd); - sst_connectedWritableSockets.remove(socket.sockfd); - console.debug("CS " + sst_connectedSockets.set + " NC " + sst_notConnectedSockets.set + " CW " + sst_connectedWritableSockets.set); - exports.sockets.splice(exports.sockets.indexOf(socket), 1); + exports.sockets.remove(socket.sockfd); return; } throw Error("invalid sockfd"); } function beforeSuspend() { if (console.isDebug) { - console.debug("Socket FDs for select.\n not connected =>" + sst_notConnectedSockets.set + "\n connected =>" + sst_connectedSockets.set + "\n connected wri =>" + sst_connectedWritableSockets.set + "\n"); + console.debug("Socket FDs for select.\n not connected =>" + exports.sockets.sst_notConnectedSockets.set + "\n connected =>" + exports.sockets.sst_connectedSockets.set + "\n connected wri =>" + exports.sockets.sst_connectedWritableSockets.set + "\n"); } - el_registerSocketEvents(sst_notConnectedSockets.set, sst_connectedSockets.set, sst_connectedWritableSockets.set); + el_registerSocketEvents(exports.sockets.sst_notConnectedSockets.set, exports.sockets.sst_connectedSockets.set, exports.sockets.sst_connectedWritableSockets.set); } function afterSuspend(evt, collected) { if (evt.type === EL_SOCKET_EVENT_TYPE) { - var findSocket = exports.sockets.filter(function (s) { - return s.sockfd === evt.fd; - }); - var socket_1 = findSocket[0]; + var socket_1 = exports.sockets.get(evt.fd); if (socket_1) { if (evt.status === 0) { //writable diff --git a/components/socket-events/modules/socket-events/index.ts b/components/socket-events/modules/socket-events/index.ts index 9c51968..0499e4a 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -54,67 +54,6 @@ export interface Esp32JsSocket { let sslClientCtx: any; -/** - * @module socket-events - */ - -/** - * Callback for connect event. - * - * @callback onConnectCB - * @param {module:socket-events~Socket} socket The socket. - * @returns {boolean} If the connection attempt should be retried. - */ -/** - * Callback for data event. - * - * @callback onDataCB - * @param {string} data Data that was received on the socket. - * @param {number} sockfd The socket file descriptor. - * @param {number} length The length of the data. - */ -/** - * Callback for error event. - * - * @callback onErrorCB - * @param {number} sockfd The socket file descriptor. - */ -/** - * Callback for close event. - * - * @callback onCloseCB - * @param {number} sockfd The socket file descriptor. - */ - -/** - * An array which holds all active sockets. - * - * @type module:socket-events~Socket[] - */ -interface SocketArrayFind { - find(predicate: (socket: Socket) => boolean): Socket; -} -export const sockets: Socket[] & SocketArrayFind = [] as any; - -(sockets as any).pushNative = sockets.push; -(sockets as any).push = function (item: Socket) { - (sockets as any).pushNative(item); - maintainSocketStatus( - item.sockfd, - item.isListening, - item.isConnected, - item.isError, - item.onWritable - ); -}; -(sockets as any).find = function (predicate: (socket: Socket) => boolean) { - for (const s of sockets) { - if (predicate(s)) { - return s; - } - } -}; - class NumberSet { public set: number[] = []; public add(n: number) { @@ -129,57 +68,93 @@ class NumberSet { } } } -// maintained socket status lists -const sst_notConnectedSockets = new NumberSet(); -const sst_connectedSockets = new NumberSet(); -const sst_connectedWritableSockets = new NumberSet(); - -export const el_debug_sockets = { - sockets, - sst_notConnectedSockets, - sst_connectedSockets, - sst_connectedWritableSockets, -}; - -function maintainSocketStatus( - sockfd: number, - isListening: boolean, - isConnected: boolean, - isError: boolean, - onWritable: OnWritableCB | null -) { - // check if socket is still a valid actual socket - if (!sockets.find((s) => sockfd === s.sockfd)) { + +class SocketLookupMap { + public map: { [key: string]: Socket } = {}; + public add(item: Socket): void { + this.map[item.sockfd] = item; + } + public get(sockfd: number): Socket | undefined { + return this.map[sockfd]; + } + public remove(sockfd: number) { + delete this.map[sockfd]; + } +} + +class ActiveSockets { + private activeSockets = new SocketLookupMap(); + + // maintained socket status lists + public sst_notConnectedSockets = new NumberSet(); + public sst_connectedSockets = new NumberSet(); + public sst_connectedWritableSockets = new NumberSet(); + + maintainSocketStatus( + sockfd: number, + isListening: boolean, + isConnected: boolean, + isError: boolean, + onWritable: OnWritableCB | null + ) { + // check if socket is still a valid actual socket + if (!this.get(sockfd)) { + if (console.isDebug) { + console.debug(`Invalid sockfd ${sockfd} given to maintain.`); + } + return; + } + if (console.isDebug) { - console.debug(`Invalid sockfd ${sockfd} given to maintain.`); + console.debug( + `Maintain socket status, sockfd: ${sockfd}, isListening: ${isListening}, isConnected: ${isConnected}, isError: ${isError}` + ); + } + + if (onWritable && isConnected && !isError) { + this.sst_connectedWritableSockets.add(sockfd); + } else { + this.sst_connectedWritableSockets.remove(sockfd); + } + + if (isConnected && !isError) { + this.sst_connectedSockets.add(sockfd); + } else { + this.sst_connectedSockets.remove(sockfd); + } + + if (!isConnected && !isListening && !isError) { + this.sst_notConnectedSockets.add(sockfd); + } else { + this.sst_notConnectedSockets.remove(sockfd); } - return; } - if (console.isDebug) { - console.debug( - `Maintain socket status, sockfd: ${sockfd}, isListening: ${isListening}, isConnected: ${isConnected}, isError: ${isError}` + public add(item: Socket) { + this.activeSockets.add(item); + this.maintainSocketStatus( + item.sockfd, + item.isListening, + item.isConnected, + item.isError, + item.onWritable ); } - if (onWritable && isConnected && !isError) { - sst_connectedWritableSockets.add(sockfd); - } else { - sst_connectedWritableSockets.remove(sockfd); - } + public remove(sockfd: number) { + this.sst_connectedSockets.remove(sockfd); + this.sst_notConnectedSockets.remove(sockfd); + this.sst_connectedWritableSockets.remove(sockfd); - if (isConnected && !isError) { - sst_connectedSockets.add(sockfd); - } else { - sst_connectedSockets.remove(sockfd); + this.activeSockets.remove(sockfd); } - if (!isConnected && !isListening && !isError) { - sst_notConnectedSockets.add(sockfd); - } else { - sst_notConnectedSockets.remove(sockfd); + public get(sockfd: number): Socket | undefined { + return this.activeSockets.get(sockfd); } } +export const sockets = new ActiveSockets(); + interface BufferEntry { written: number; data: Uint8Array; @@ -242,7 +217,7 @@ class Socket implements Esp32JsSocket { public flushAlways = true; private maintainSocketStatus() { - maintainSocketStatus( + sockets.maintainSocketStatus( this.sockfd, this.isListening, this.isConnected, @@ -421,15 +396,11 @@ function performOnClose(socket: Esp32JsSocket) { */ export function closeSocket(socketOrSockfd: Esp32JsSocket | number): void { - let socket: Socket | null = null; + let socket: Socket | undefined; if (typeof socketOrSockfd === "number") { - socket = sockets.find(function (s) { - return s.sockfd === socketOrSockfd; - }); + socket = sockets.get(socketOrSockfd); } else if (typeof socketOrSockfd === "object") { - socket = sockets.find(function (s) { - return s.sockfd === socketOrSockfd.sockfd; - }); + socket = sockets.get(socketOrSockfd.sockfd); } if (!socket) { @@ -511,9 +482,7 @@ export function sockConnect( }; } - if (sockets.indexOf(socket) < 0) { - sockets.push(socket); - } + sockets.add(socket); return socket; } @@ -559,9 +528,7 @@ export function sockListen( newSocket.isListening = false; newSocket.ssl = ssl; - if (sockets.indexOf(newSocket) < 0) { - sockets.push(newSocket); - } + sockets.add(newSocket); if (onAccept) { onAccept(newSocket); } @@ -587,9 +554,7 @@ export function sockListen( socket.isError = false; socket.isListening = true; - if (sockets.indexOf(socket) < 0) { - sockets.push(socket); - } + sockets.add(socket); return socket; } } @@ -599,16 +564,7 @@ function resetSocket(socket: Socket) { console.debug(`Reset Socket called on ${socket.sockfd}`); } if (socket) { - // free maintained socket status - sst_connectedSockets.remove(socket.sockfd); - sst_notConnectedSockets.remove(socket.sockfd); - sst_connectedWritableSockets.remove(socket.sockfd); - - console.debug( - `CS ${sst_connectedSockets.set} NC ${sst_notConnectedSockets.set} CW ${sst_connectedWritableSockets.set}` - ); - - sockets.splice(sockets.indexOf(socket), 1); + sockets.remove(socket.sockfd); return; } throw Error("invalid sockfd"); @@ -617,25 +573,22 @@ function resetSocket(socket: Socket) { function beforeSuspend() { if (console.isDebug) { console.debug(`Socket FDs for select. - not connected =>${sst_notConnectedSockets.set} - connected =>${sst_connectedSockets.set} - connected wri =>${sst_connectedWritableSockets.set} + not connected =>${sockets.sst_notConnectedSockets.set} + connected =>${sockets.sst_connectedSockets.set} + connected wri =>${sockets.sst_connectedWritableSockets.set} `); } el_registerSocketEvents( - sst_notConnectedSockets.set, - sst_connectedSockets.set, - sst_connectedWritableSockets.set + sockets.sst_notConnectedSockets.set, + sockets.sst_connectedSockets.set, + sockets.sst_connectedWritableSockets.set ); } function afterSuspend(evt: Esp32JsEventloopEvent, collected: (() => void)[]) { if (evt.type === EL_SOCKET_EVENT_TYPE) { - const findSocket = sockets.filter((s) => { - return s.sockfd === evt.fd; - }); - const socket = findSocket[0]; + const socket = sockets.get(evt.fd); if (socket) { if (evt.status === 0) { //writable diff --git a/components/wifi-events/modules/wifi-events/index.js b/components/wifi-events/modules/wifi-events/index.js index 94ce0e3..0663f57 100644 --- a/components/wifi-events/modules/wifi-events/index.js +++ b/components/wifi-events/modules/wifi-events/index.js @@ -1,5 +1,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.getIPAddress = exports.getBssid = exports.createSoftAp = exports.connectWifi = void 0; +exports.getIPAddress = exports.convertBssidToArray = exports.convertBssidToString = exports.getBssid = exports.createSoftAp = exports.connectWifi = void 0; /* MIT License @@ -38,10 +38,11 @@ function resetWifiStatus(callback) { * @param ssid The ssid of the wifi network. * @param password The password of the wifi network. * @param {wifiStatusCallback} callback A cb which gets the connect status updates. + * @param bssid Optional bssid to pin to a specific AP. */ -function connectWifi(ssid, password, callback) { +function connectWifi(ssid, password, callback, bssid) { resetWifiStatus(callback); - el_connectWifi(ssid, password); + el_connectWifi(ssid, password, bssid ? convertBssidToArray(bssid) : undefined); } exports.connectWifi = connectWifi; /** @@ -61,13 +62,35 @@ exports.createSoftAp = createSoftAp; * @returns The bssid. */ function getBssid() { - return getWifiConfig() - .bssid.map(function (n) { - return n.toString(16); - }) - .join(":"); + return convertBssidToString(getWifiConfig().bssid); } exports.getBssid = getBssid; +/** + * Converts a 6 number array into a string representation of a BSSID. + * @returns The bssid as string representation. + */ +function convertBssidToString(bssid) { + if (bssid.length == 6) { + return bssid + .map(function (n) { + var str = n.toString(16).toUpperCase(); + return str.length == 2 ? str : "0" + str; + }) + .join(":"); + } +} +exports.convertBssidToString = convertBssidToString; +/** + * Converts a bssid string representation in a 6 number array. + * @returns The bssid as 6 number array. + */ +function convertBssidToArray(bssid) { + var bssidArray = bssid.split(":").map(function (s) { return parseInt(s, 16); }); + if (bssidArray.length == 6) { + return bssidArray; + } +} +exports.convertBssidToArray = convertBssidToArray; /** * Convert 32 bit number to ip address string. * @returns The ip address as string representation. diff --git a/components/wifi-events/modules/wifi-events/index.ts b/components/wifi-events/modules/wifi-events/index.ts index aca2628..fd1d968 100644 --- a/components/wifi-events/modules/wifi-events/index.ts +++ b/components/wifi-events/modules/wifi-events/index.ts @@ -53,14 +53,20 @@ function resetWifiStatus( * @param ssid The ssid of the wifi network. * @param password The password of the wifi network. * @param {wifiStatusCallback} callback A cb which gets the connect status updates. + * @param bssid Optional bssid to pin to a specific AP. */ export function connectWifi( ssid: string, password: string, - callback: (event: Esp32JsWifiEvent, ip: string | undefined) => void + callback: (event: Esp32JsWifiEvent, ip: string | undefined) => void, + bssid?: string ): void { resetWifiStatus(callback); - el_connectWifi(ssid, password); + el_connectWifi( + ssid, + password, + bssid ? convertBssidToArray(bssid) : undefined + ); } /** @@ -83,12 +89,38 @@ export function createSoftAp( * Get the bssid of the current connected wifi AP as formatted as hex string. * @returns The bssid. */ -export function getBssid(): string { - return getWifiConfig() - .bssid.map((n) => { - return n.toString(16); - }) - .join(":"); +export function getBssid(): string | undefined { + return convertBssidToString(getWifiConfig().bssid); +} + +/** + * Converts a 6 number array into a string representation of a BSSID. + * @returns The bssid as string representation. + */ +export function convertBssidToString( + bssid: [number, number, number, number, number, number] +): string | undefined { + if (bssid.length == 6) { + return bssid + .map((n) => { + const str = n.toString(16).toUpperCase(); + return str.length == 2 ? str : "0" + str; + }) + .join(":"); + } +} + +/** + * Converts a bssid string representation in a 6 number array. + * @returns The bssid as 6 number array. + */ +export function convertBssidToArray( + bssid: string +): [number, number, number, number, number, number] | undefined { + const bssidArray = bssid.split(":").map((s) => parseInt(s, 16)); + if (bssidArray.length == 6) { + return bssidArray as [number, number, number, number, number, number]; + } } /** diff --git a/components/wifi-events/wifi-events.c b/components/wifi-events/wifi-events.c index 05041e8..fa10ec9 100644 --- a/components/wifi-events/wifi-events.c +++ b/components/wifi-events/wifi-events.c @@ -33,6 +33,7 @@ SOFTWARE. static EventGroupHandle_t wifi_event_group; static const int CONNECTED_BIT = BIT0; static const int SCANNING_BIT = BIT1; +static uint8_t *staticBssid = NULL; void startScan() { @@ -52,6 +53,18 @@ void startScan() } } +bool bssidEquals(uint8_t *bssid1, uint8_t *bssid2) +{ + for (int i = 0; i < 6; i++) + { + if (bssid1[i] != bssid2[i]) + { + return false; + } + } + return true; +} + static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) { js_eventlist_t events; @@ -69,10 +82,16 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) wifi_config_t wifi_config; ESP_ERROR_CHECK(esp_wifi_get_config(WIFI_IF_STA, &wifi_config)); + jslog(DEBUG, "Search for SSID %s ", wifi_config.sta.ssid); + if (staticBssid != NULL) + { + jslog(DEBUG, "AND bssid=%02x:%02x:%02x:%02x:%02x:%02x", staticBssid[0], staticBssid[1], staticBssid[2], staticBssid[3], staticBssid[4], staticBssid[5]); + } + uint16_t apCount = 0; esp_wifi_scan_get_ap_num(&apCount); jslog(DEBUG, "Number of access points found: %d", sysevent->event_info.scan_done.number); - uint8_t *bssid = NULL; + uint8_t *selectedBssid = NULL; int8_t rssi = -127; wifi_ap_record_t *list = NULL; if (apCount > 0) @@ -83,23 +102,30 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) int i = 0; for (i = 0; i < apCount; i++) { - if (strcmp((const char *)list[i].ssid, (const char *)wifi_config.sta.ssid) == 0) + bool ssidMatch = strcmp((const char *)list[i].ssid, (const char *)wifi_config.sta.ssid) == 0; + bool bssidMatch = (staticBssid == NULL) || bssidEquals(staticBssid, list[i].bssid); + + jslog(DEBUG, "ssidmatch=%s, bssidmatch=%s", ssidMatch ? "true" : "false", bssidMatch ? "true" : "false"); + jslog(DEBUG, "SSID %s , bssid=%02x:%02x:%02x:%02x:%02x:%02x, rssi=%d,", list[i].ssid, + list[i].bssid[0], list[i].bssid[1], list[i].bssid[2], list[i].bssid[3], list[i].bssid[4], list[i].bssid[5], list[i].rssi); + if (ssidMatch && bssidMatch) { if (list[i].rssi > rssi) { - bssid = list[i].bssid; + selectedBssid = list[i].bssid; rssi = list[i].rssi; + jslog(DEBUG, "==> SELECTED!"); } } } } esp_wifi_scan_stop(); xEventGroupClearBits(wifi_event_group, SCANNING_BIT); - if (bssid != NULL) + if (selectedBssid != NULL) { - jslog(INFO, "SSID %s found, best rssi %d, bssid=%02x:%02x:%02x:%02x:%02x:%02x", wifi_config.sta.ssid, rssi, - bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); - memcpy(wifi_config.sta.bssid, bssid, 6 * sizeof(uint8_t)); + jslog(INFO, "==> SSID %s found, bssid=%02x:%02x:%02x:%02x:%02x:%02x, rssi=%d,", wifi_config.sta.ssid, + selectedBssid[0], selectedBssid[1], selectedBssid[2], selectedBssid[3], selectedBssid[4], selectedBssid[5], rssi); + memcpy(wifi_config.sta.bssid, selectedBssid, 6 * sizeof(uint8_t)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); esp_wifi_connect(); } @@ -218,6 +244,27 @@ static duk_ret_t setupWifi(duk_context *ctx, bool softap) const char *ssid = duk_to_string(ctx, 0); const char *pass = duk_to_string(ctx, 1); + uint8_t *bssid = NULL; + if (!softap && !duk_is_undefined(ctx, 2)) + { + if (duk_is_array(ctx, 2) && duk_get_length(ctx, 2) == 6) + { + bssid = calloc(6, sizeof(uint8_t)); + + for (int i = 0; i < 6; i++) + { + duk_get_prop_index(ctx, 2, i); + bssid[i] = duk_to_int(ctx, -1); + duk_pop(ctx); + } + } + else + { + jslog(ERROR, "Provided bssid is invalid."); + return -1; + } + } + //try stopping //esp_wifi_stop(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); @@ -251,10 +298,22 @@ static duk_ret_t setupWifi(duk_context *ctx, bool softap) wifi_config.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; wifi_config.sta.bssid_set = true; - jslog(DEBUG, "Setting WiFi configuration SSID %s and PASS **** ...", wifi_config.sta.ssid); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); + jslog(INFO, "Setting WiFi configuration SSID %s and PASS ****. BSSID was provided: %s", wifi_config.sta.ssid, staticBssid != NULL ? "true" : "false"); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); + + if (staticBssid != NULL) + { + free(staticBssid); + staticBssid = NULL; + } + if (bssid != NULL) + { + staticBssid = bssid; + } + startScan(); } @@ -276,7 +335,7 @@ void registerWifiEventsBindings(duk_context *ctx) wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); - duk_push_c_function(ctx, el_connectWifi, 2 /*nargs*/); + duk_push_c_function(ctx, el_connectWifi, 3 /*nargs*/); duk_put_global_string(ctx, "el_connectWifi"); duk_push_c_function(ctx, el_createSoftAp, 2 /*nargs*/); From e7b295808fff60b35296a960a0a31b6a033aab00 Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Sun, 30 May 2021 21:09:18 +0200 Subject: [PATCH 09/19] feat: detect setups without ota partition setup --- README.md | 7 +++ .../esp32-javascript/esp32-javascript.c | 44 ++++++++++++++----- .../include/esp32-javascript.h | 1 + .../modules/esp32-javascript/config.js | 2 +- .../modules/esp32-javascript/config.ts | 2 +- .../modules/esp32-javascript/configserver.js | 8 ++-- .../modules/esp32-javascript/configserver.ts | 14 +++--- .../esp32-javascript/esp32-javascript.d.ts | 1 + .../modules/esp32-javascript/native-ota.js | 4 ++ .../modules/esp32-javascript/native-ota.ts | 5 +++ components/spiffs-events/spiffs-events.c | 14 +++--- 11 files changed, 76 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 10fdb4b..eaf0129 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,13 @@ If you need more than this, you can create your own esp-idf component below `./c Additionally you have to set your component name in the top level `./CMakeLists.txt`. Refer to the documentation next to the setting `ESP32_JS_PROJECT_NAME`. See [ESP Build System](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html) for information on how to create a component with the esp-idf build system. +### Native OTA + +You can perform a native firmware OTA upgrade by calling the URL /setup . There is a section called "Native OTA" where you can provide two urls to the new images: One for the actual firmware image (normally named esp32-javascript.bin in your build directory) and the other for the JS modules image (normally named modules.bin in your build directory). + +The upgrade is performed in the background. You can check the upgrade status either by staying on the upgrade page, which is reloaded automatically every ~20 seconds or click on "Upgrade status" in the setup page. + +After upgrade has finished you have to restart the device to load the new firmware. ### Clean You can clean the project by executing diff --git a/components/esp32-javascript/esp32-javascript.c b/components/esp32-javascript/esp32-javascript.c index 087f1dc..bfb3766 100644 --- a/components/esp32-javascript/esp32-javascript.c +++ b/components/esp32-javascript/esp32-javascript.c @@ -822,6 +822,24 @@ duk_ret_t el_partition_write(duk_context *ctx) } } +bool isNativeOtaSupported() +{ + if (esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, "otadata") == NULL) + { + return false; + } + else + { + return true; + } +} + +duk_ret_t el_is_native_ota_supported(duk_context *ctx) +{ + duk_push_boolean(ctx, isNativeOtaSupported()); + return 1; +} + duk_ret_t el_readAndFreeString(duk_context *ctx) { char *str = duk_to_int(ctx, 0); @@ -919,20 +937,26 @@ void duktape_task(void *ignore) duk_push_c_function(ctx, atob, 1 /*nargs*/); duk_put_global_string(ctx, "atob"); - duk_push_c_function(ctx, el_ota_begin, 0 /*nargs*/); - duk_put_global_string(ctx, "el_ota_begin"); + if (isNativeOtaSupported()) + { + duk_push_c_function(ctx, el_ota_begin, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_begin"); + + duk_push_c_function(ctx, el_ota_write, 2 /*nargs*/); + duk_put_global_string(ctx, "el_ota_write"); - duk_push_c_function(ctx, el_ota_write, 2 /*nargs*/); - duk_put_global_string(ctx, "el_ota_write"); + duk_push_c_function(ctx, el_ota_end, 1 /*nargs*/); + duk_put_global_string(ctx, "el_ota_end"); - duk_push_c_function(ctx, el_ota_end, 1 /*nargs*/); - duk_put_global_string(ctx, "el_ota_end"); + duk_push_c_function(ctx, el_ota_switch_boot_partition, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_switch_boot_partition"); - duk_push_c_function(ctx, el_ota_switch_boot_partition, 0 /*nargs*/); - duk_put_global_string(ctx, "el_ota_switch_boot_partition"); + duk_push_c_function(ctx, el_ota_find_next_modules_partition, 0 /*nargs*/); + duk_put_global_string(ctx, "el_ota_find_next_modules_partition"); + } - duk_push_c_function(ctx, el_ota_find_next_modules_partition, 0 /*nargs*/); - duk_put_global_string(ctx, "el_ota_find_next_modules_partition"); + duk_push_c_function(ctx, el_is_native_ota_supported, 0 /*nargs*/); + duk_put_global_string(ctx, "el_is_native_ota_supported"); duk_push_c_function(ctx, el_partition_erase, 1 /*nargs*/); duk_put_global_string(ctx, "el_partition_erase"); diff --git a/components/esp32-javascript/include/esp32-javascript.h b/components/esp32-javascript/include/esp32-javascript.h index ca0abbb..5a7ba8d 100644 --- a/components/esp32-javascript/include/esp32-javascript.h +++ b/components/esp32-javascript/include/esp32-javascript.h @@ -67,6 +67,7 @@ extern "C" void loadJS(duk_context *ctx, const char *name, char *start, char *end); int esp32_javascript_init(); + bool isNativeOtaSupported(); #ifdef __cplusplus } diff --git a/components/esp32-javascript/modules/esp32-javascript/config.js b/components/esp32-javascript/modules/esp32-javascript/config.js index 98aa322..9602f35 100644 --- a/components/esp32-javascript/modules/esp32-javascript/config.js +++ b/components/esp32-javascript/modules/esp32-javascript/config.js @@ -34,7 +34,7 @@ function reloadConfig() { } catch (error) { exports.config = firmware_config_1.default; - console.error("An error ocurred while accessing config. Maybe it does not exist."); + console.error("Using default config. Seems like you never changed the config."); } } exports.reloadConfig = reloadConfig; diff --git a/components/esp32-javascript/modules/esp32-javascript/config.ts b/components/esp32-javascript/modules/esp32-javascript/config.ts index 2b0ba0c..df0be33 100644 --- a/components/esp32-javascript/modules/esp32-javascript/config.ts +++ b/components/esp32-javascript/modules/esp32-javascript/config.ts @@ -49,7 +49,7 @@ export function reloadConfig(): void { } catch (error) { config = firmwareConfig; console.error( - "An error ocurred while accessing config. Maybe it does not exist." + "Using default config. Seems like you never changed the config." ); } } diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index 3e830a5..b319e47 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -220,9 +220,11 @@ function startConfigServer() { .map(function (e) { return e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB)

"; }) - .join("") + "\n \n
\n \n

Native OTA Upgrade

\n
\n
\n
\n
" + (upgradeStatus.status !== "idle" - ? 'Upgrade status' - : "") + "
\n
\n\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / + .join("") + "\n \n
\n \n " + (el_is_native_ota_supported() + ? "

Native OTA Upgrade

\n
\n
\n
\n
" + (upgradeStatus.status !== "idle" + ? 'Upgrade status' + : "") + "
\n
" + : "") + "\n\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / 100 + "
\n
\n
\n Boot time is only available if a valid 'JS file url' is configured, otherwise it starts at unix epoch (1970).\n
"); successMessage = ""; errorMessage = ""; diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index ebfc3a7..4f281e1 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -341,18 +341,22 @@ export function startConfigServer(): void {
-

Native OTA Upgrade

+ ${ + el_is_native_ota_supported() + ? `

Native OTA Upgrade

${ - upgradeStatus.status !== "idle" - ? 'Upgrade status' + upgradeStatus.status !== "idle" + ? 'Upgrade status' + : "" + }
+
` : "" - }
- + }

Request restart

diff --git a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts index 72a452e..4413312 100644 --- a/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts +++ b/components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts @@ -94,6 +94,7 @@ declare function listDir(path: string): string[]; declare function mkdir(path: string): void; // ota +declare function el_is_native_ota_supported(): boolean; declare function el_ota_begin(): number; declare function el_ota_write(handle: number, data: Uint8Array): number; declare function el_ota_end(handle: number): number; diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.js b/components/esp32-javascript/modules/esp32-javascript/native-ota.js index 80cfb61..8ece739 100644 --- a/components/esp32-javascript/modules/esp32-javascript/native-ota.js +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.js @@ -100,6 +100,10 @@ function upgradeModules(partition, modulesImageUrl, submitSuccess, submitError) return client; } exports.upgrade = function (appImageUrl, modulesImageUrl, onError, onFinish) { + if (!el_is_native_ota_supported()) { + onError && onError("Native OTA is not supported."); + return; + } console.log("Start native firmware upgrade:"); console.log("App image: " + appImageUrl); console.log("Modules image: " + modulesImageUrl); diff --git a/components/esp32-javascript/modules/esp32-javascript/native-ota.ts b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts index e4bfffe..ab000b4 100644 --- a/components/esp32-javascript/modules/esp32-javascript/native-ota.ts +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts @@ -138,6 +138,11 @@ export const upgrade = ( onError: (message: string) => void, onFinish: () => void ): void => { + if (!el_is_native_ota_supported()) { + onError && onError("Native OTA is not supported."); + return; + } + console.log(`Start native firmware upgrade:`); console.log(`App image: ${appImageUrl}`); console.log(`Modules image: ${modulesImageUrl}`); diff --git a/components/spiffs-events/spiffs-events.c b/components/spiffs-events/spiffs-events.c index c2ad710..2111c6a 100644 --- a/components/spiffs-events/spiffs-events.c +++ b/components/spiffs-events/spiffs-events.c @@ -103,7 +103,7 @@ char *readFile(const char *path) FILE *f = fopen(path, "r"); if (f == NULL) { - jslog(ERROR, "Failed to open file for reading"); + jslog(ERROR, "Failed to open file '%s' for reading.", path); return NULL; } @@ -132,7 +132,7 @@ int writeFile(const char *path, const char *content) FILE *f = fopen(path, "w"); if (f == NULL) { - jslog(ERROR, "Failed to open file '%s'for writing, errno %i", path, errno); + jslog(ERROR, "Failed to open file '%s' for writing, errno %i", path, errno); return -1; } int result = fputs(content, f); @@ -278,14 +278,16 @@ void registerBindings(duk_context *ctx) duk_put_global_string(ctx, "fileSize"); duk_push_c_function(ctx, el_listDir, 1); duk_put_global_string(ctx, "listDir"); - // duk_push_c_function(ctx, el_mkdir, 1); - // duk_put_global_string(ctx, "mkdir"); } void initSpiffs(duk_context *ctx) { - esp_partition_t *partition = esp_ota_get_boot_partition(); - const char *modulesLabel = strcmp(partition->label, "ota_1") == 0 ? "modules_1" : "modules"; + const char *modulesLabel = "modules"; + if (isNativeOtaSupported()) + { + esp_partition_t *partition = esp_ota_get_boot_partition(); + modulesLabel = partition != NULL && strcmp(partition->label, "ota_1") == 0 ? "modules_1" : "modules"; + } initFilesystem(modulesLabel, "/modules"); initFilesystem("data", "/data"); From bb7489bad8df2aa515c25695b50988e5f150227a Mon Sep 17 00:00:00 2001 From: Marcel Kottmann Date: Wed, 2 Jun 2021 20:39:47 +0200 Subject: [PATCH 10/19] fix: improve styling --- CMakeLists.txt | 2 +- .../modules/esp32-javascript/chunked.js | 162 ----------------- .../modules/esp32-javascript/chunked.ts | 163 ------------------ .../modules/esp32-javascript/configserver.js | 8 +- .../modules/esp32-javascript/configserver.ts | 37 ++-- 5 files changed, 28 insertions(+), 344 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a7ee6b..afb6732 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(ENV{BOARD_VARIANT} "../esp32-javascript/include/variants/my") # set ESP32_JS_PROJECT_NAME to define your project component name. # Place your component below ./components directory. Set to "" # if you don't have a project component yet. -set(ENV{ESP32_JS_PROJECT_NAME} "esp32-home") +set(ENV{ESP32_JS_PROJECT_NAME} "") ################################################# include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.js b/components/esp32-javascript/modules/esp32-javascript/chunked.js index c9e7222..0fb53c2 100644 --- a/components/esp32-javascript/modules/esp32-javascript/chunked.js +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.js @@ -121,165 +121,3 @@ function createChunkedEncodingConsumer(onData) { }; } exports.createChunkedEncodingConsumer = createChunkedEncodingConsumer; -/* - -function selftest() { - let consumer = createChunkedEncodingConsumer(); - console.log( - consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => { - throw Error("Should not be called."); - }) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "0".charCodeAt(0), - "1".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - "a".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log( - data.length === 26 && - data[0] === "x".charCodeAt(0) && - data[1] === "y".charCodeAt(0) - ) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - "a".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - ]), - (data: Uint8Array) => - console.log(data.length === 25 && data[0] === "x".charCodeAt(0)) - ) === READ_PAYL - ); - console.log("test"); - console.log( - consumer( - new Uint8Array([ - "y".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "y".charCodeAt(0)) - ) === FINISHED - ); -} -selftest(); -*/ diff --git a/components/esp32-javascript/modules/esp32-javascript/chunked.ts b/components/esp32-javascript/modules/esp32-javascript/chunked.ts index 91002d1..efe2aae 100644 --- a/components/esp32-javascript/modules/esp32-javascript/chunked.ts +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.ts @@ -119,166 +119,3 @@ export function createChunkedEncodingConsumer( return state === FINISHED; }; } - -/* - -function selftest() { - let consumer = createChunkedEncodingConsumer(); - console.log( - consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => { - throw Error("Should not be called."); - }) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "0".charCodeAt(0), - "1".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "x".charCodeAt(0)) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - "a".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log( - data.length === 26 && - data[0] === "x".charCodeAt(0) && - data[1] === "y".charCodeAt(0) - ) - ) === FINISHED - ); - - consumer = createChunkedEncodingConsumer(); - console.log( - consumer( - new Uint8Array([ - "1".charCodeAt(0), - "a".charCodeAt(0), - 10, - 13, - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - "y".charCodeAt(0), - "x".charCodeAt(0), - ]), - (data: Uint8Array) => - console.log(data.length === 25 && data[0] === "x".charCodeAt(0)) - ) === READ_PAYL - ); - console.log("test"); - console.log( - consumer( - new Uint8Array([ - "y".charCodeAt(0), - 10, - 13, - "0".charCodeAt(0), - 10, - 13, - 10, - 13, - ]), - (data: Uint8Array) => - console.log(data.length === 1 && data[0] === "y".charCodeAt(0)) - ) === FINISHED - ); -} -selftest(); -*/ diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.js b/components/esp32-javascript/modules/esp32-javascript/configserver.js index b319e47..bbd8b29 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -130,7 +130,7 @@ function page(res, headline, text, cb, additionalHeadTags) { } res.setStatus(200); res.headers.set("content-type", "text/html"); - res.write("esp32-javascript\n \n \n " + (additionalHeadTags ? additionalHeadTags : "") + "\n \n

" + headline + "

"); + res.write("esp32-javascript\n \n \n " + (additionalHeadTags ? additionalHeadTags : "") + "\n \n \n

" + headline + "

"); if (Array.isArray(text)) { res.write(text.join("")); } @@ -216,12 +216,12 @@ function startConfigServer() { var config = configManager.config; page(res, "Setup", "" + (successMessage ? "
" + successMessage + "
" - : "") + (errorMessage ? "
" + errorMessage + "
" : "") + "

Configuration

Wifi

\n
\n
\n
\n

Basic authentication

\n
\n
\n

JavaScript OTA

\n
\n
\n
\n

Logs

\n
\n

\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.
\n

\n " + getLogFileList() + : "") + (errorMessage ? "
" + errorMessage + "
" : "") + "

Configuration

Wifi

\n

\n

\n

\n

Basic authentication

\n

\n

\n

JavaScript OTA


\n
\n
\n
\n

Logs

\n
\n

\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.
\n

\n " + getLogFileList() .map(function (e) { - return e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB)

"; + return "
" + e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB)
 
"; }) .join("") + "\n \n
\n \n " + (el_is_native_ota_supported() - ? "

Native OTA Upgrade

\n
\n
\n
\n
" + (upgradeStatus.status !== "idle" + ? "

Native OTA Upgrade

\n \n

\n

\n
" + (upgradeStatus.status !== "idle" ? 'Upgrade status' : "") + "
\n " : "") + "\n\n

Request restart

\n
\n

Uptime

\n
\n Boot time: " + boot_1.getBootTime() + "\n
\n
\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) / diff --git a/components/esp32-javascript/modules/esp32-javascript/configserver.ts b/components/esp32-javascript/modules/esp32-javascript/configserver.ts index 4f281e1..a86fb7e 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -163,7 +163,6 @@ function page( } .formlabel { display: inline-block; - width: 130px; } .formpad { padding: 8px; @@ -180,6 +179,9 @@ function page( .blink { animation: blinkanimation 1s linear infinite; } + .nowrap { + white-space: nowrap; + } @keyframes blinkanimation { 50% { opacity: 0; @@ -187,6 +189,13 @@ function page( } ${additionalHeadTags ? additionalHeadTags : ""} +

${headline}

`); if (Array.isArray(text)) { @@ -294,23 +303,23 @@ export function startConfigServer(): void { }${ errorMessage ? `
${errorMessage}
` : "" }

Configuration

Wifi

-

-

-

Basic authentication

-

-

-

JavaScript OTA