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/README.md b/README.md index 10fdb4b..88d4451 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Because of the limited memory on ESP32-WROOM modules, the full functionality is ### Prerequisites -Install [esp-idf 4.2](https://docs.espressif.com/projects/esp-idf/en/release-v4.2/esp32/get-started/index.html) on your system. +Install [esp-idf 4.2.2](https://docs.espressif.com/projects/esp-idf/en/release-v4.2/esp32/get-started/index.html) on your system. ### First install @@ -63,13 +63,21 @@ If this is your first install, your onboard LED should blink now. Blinking signa On the Setup page you can configure your WLAN settings and an URL to download your JS main script from. -Please note that the script, does not need to have a main function, because its evaluated entirely. +![Setup page screenshot](setup.png) +### Examples + +Please note that the Javascript OTA script, does not need to have a main function, because its evaluated entirely. That means, to print out "Hello World", you only have to include one line in your script on the webserver: ```js console.log("Hello world!"); ``` +You can test this example by configuring this URL as "Javascript OTA": +https://raw.githubusercontent.com/marcelkottmann/esp32-javascript/master/examples/example.js + +Please see also the other example in [./examples](./examples) + ### C/C++bindings If you need to create your own C/C++ bindings for your JS code, this are the steps to perform: @@ -92,6 +100,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 @@ -120,12 +135,32 @@ You can erase the persistent flash memory, which will be equivalent to a factory | Version | Compatible | | ----------------------------------------------------------------- | :--------------------: | -| [4.2](https://github.com/espressif/esp-idf/releases/tag/v4.2) | :heavy_check_mark:[^1] | -| [4.2.1](https://github.com/espressif/esp-idf/releases/tag/v4.2.1) | :heavy_check_mark:[^1] | +| [4.2](https://github.com/espressif/esp-idf/releases/tag/v4.2) | ☑️1 | +| [4.2.1](https://github.com/espressif/esp-idf/releases/tag/v4.2.1) | ☑️1 | +| [4.2.2](https://github.com/espressif/esp-idf/releases/tag/v4.2.2) | ✅ Recommended | -[^1]: SSL client connections currently not working properly for ESP32-S2 devices due to esp-idf bug in 4.2.x: +1 SSL client connections currently not working properly for ESP32-S2 devices due to esp-idf bug in 4.2.x: https://github.com/espressif/esp-idf/pull/6998 , but can be fixed manually (see changes in PR). +## REPL + +The [examples](examples/) directory contains a [repl](examples/repl.js) that can be used as JS OTA Url: +https://raw.githubusercontent.com/marcelkottmann/esp32-javascript/http-streaming/examples/repl.js + +The repl can be used with netcat directly or with a combination of rlwrap and netcat to have a history-support: +`rlwrap netcat [IP-ADDRESS] 1234` + +Enter username and password separated with colon(`:`) to authenticate, e.g. `esp32:esp32` + Enter + +```bash +~/esp/esp32-javascript> rlwrap netcat 192.168.188.24 1234 +> esp32:esp32 +====> authorized. +> console.log('Hello world.') +LOG|Hello world. +====> undefined +> +``` ## API [API documentation](docs/README.md) 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/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 dceeab5..1d110bd 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 @@ -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,8 +66,30 @@ 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, ...) { + if (level < (5 - LOG_LOCAL_LEVEL)) + { + return; + } + char *my_string; va_list argp; @@ -96,47 +120,57 @@ 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) + char *message = spiram_malloc(strlen(my_string) + 1); // gets freed in el_readAndFreeString + if (message == NULL) { - 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); + ESP_LOGE(tag, "No memory to log message. Aborting..."); + abort(); } + + 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); } 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 +178,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); + ESP_LOGE(tag, "Event list is full. Max event list size: %d => aborting.", MAX_EVENTS); abort(); } events->events[events->events_len] = *event; @@ -155,17 +189,31 @@ void IRAM_ATTR el_fire_events(js_eventlist_t *events) { if (DISABLE_EVENTS) { - jslog(WARN, "Events are disabled. They will never be fired.\n"); + ESP_LOGW(tag, "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); + // el_fire_events is called from ISR and logging leads to overflowing stack (sometimes) + // e.g. in timer routines, because timer task has limited stack size. Discovered in + // backtrace of ELF 00d57bf2ccbe7755 + // 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.\n"); + 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(); } } @@ -184,8 +232,6 @@ void IRAM_ATTR vTimerCallback(TimerHandle_t xTimer) js_event_t event; js_eventlist_t events; - xTimerDelete(xTimer, portMAX_DELAY); - el_create_event(&event, EL_TIMER_EVENT_TYPE, (int)xTimer, 0); events.events_len = 0; el_add_event(&events, &event); @@ -198,6 +244,12 @@ int createTimer(int timer_period_us) TimerHandle_t tmr = xTimerCreate("", interval <= 0 ? 1 : interval, pdFALSE, NULL, vTimerCallback); + if (tmr == NULL) + { + jslog(ERROR, "Could not create timer."); + abort(); + } + if (interval <= 0) { // fire event immediatley without starting the timer @@ -229,7 +281,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 +294,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 +303,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 +325,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 +333,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 +342,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 +366,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 +382,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; @@ -351,49 +403,63 @@ 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); + vTaskDelay(1); // jslog(INFO, "Free memory: %d bytes", esp_get_free_heap_size()); js_eventlist_t events; - jslog(DEBUG, "Waiting for events...\n"); - - xQueueReceive(el_event_queue, &events, portMAX_DELAY); + jslog(DEBUG, "Waiting for events..."); + int arr_idx = duk_push_array(ctx); + int arrsize = 0; + TickType_t timeout = portMAX_DELAY; - jslog(DEBUG, "Receiving %d events.\n", events.events_len); + // force garbage collection 2 times see duktape doc + // greatly increases perfomance with external memory + duk_gc(ctx, 0); + duk_gc(ctx, 0); - int arr_idx = duk_push_array(ctx); - for (int i = 0; i < events.events_len; i++) + 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; } @@ -402,7 +468,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 +479,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 +489,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 +502,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 +513,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 +524,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; @@ -466,8 +532,8 @@ static duk_ret_t el_ledcWrite(duk_context *ctx) static duk_ret_t info(duk_context *ctx) { - size_t internal = heap_caps_get_free_size(MALLOC_CAP_INTERNAL); - size_t external = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); + size_t internal = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + size_t external = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); jslog(INFO, "INTERNAL MEMORY HEAP INFO FREE: %d", internal); jslog(INFO, "EXTERNAL MEMORY HEAP INFO FREE: %d", external); @@ -486,7 +552,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 +576,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 +604,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 +623,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; } @@ -565,7 +631,7 @@ IRAM_ATTR void *duk_spiram_malloc(void *udata, size_t size) { if (spiramAvailable) { - return heap_caps_malloc(size, MALLOC_CAP_SPIRAM); + return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); } else { @@ -581,7 +647,7 @@ IRAM_ATTR void *duk_spiram_realloc(void *udata, void *ptr, size_t size) { if (spiramAvailable) { - return heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM); + return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); } else { @@ -611,7 +677,7 @@ IRAM_ATTR void spiram_free(void *ptr) bool spiramAvail() { - void *ptr = heap_caps_malloc(1, MALLOC_CAP_SPIRAM); + void *ptr = heap_caps_malloc(1, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); if (ptr != NULL) { heap_caps_free(ptr); @@ -620,6 +686,173 @@ 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; + } +} + +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); + duk_push_string(ctx, str); + spiram_free(str); + return 1; +} + void duktape_task(void *ignore) { spiramAvailable = spiramAvail(); @@ -709,19 +942,58 @@ void duktape_task(void *ignore) duk_push_c_function(ctx, atob, 1 /*nargs*/); duk_put_global_string(ctx, "atob"); + 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_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_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"); + + 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"); + + 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 #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); @@ -732,7 +1004,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 0f00de5..5a7ba8d 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 @@ -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]; @@ -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/boot.js b/components/esp32-javascript/modules/esp32-javascript/boot.js index b6fbaec..ded505c 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++; } @@ -164,7 +187,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()); } @@ -182,9 +205,9 @@ function connectToWifi() { } } else if (evt.status === 2) { - console.info("WIFI: CONNECTING..."); + 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 e725974..b3b066c 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"; @@ -125,75 +148,82 @@ function connectToWifi() { } let retries = 0; - wifi.connectWifi(config.wifi.ssid, config.wifi.password, function (evt, ip) { - if (evt.status === 0) { - console.info("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 + "]"); + + if (!configServerStarted) { + configServer.startConfigServer(); + configServerStarted = true; + } + + retries = 0; - 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(1); - 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 (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.info("WIFI: CONNECTING..."); - } - }); + }, + config.wifi.bssid + ); } export function main(): void { 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..0fb53c2 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.js @@ -0,0 +1,123 @@ +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; +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; 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..efe2aae --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/chunked.ts @@ -0,0 +1,121 @@ +/* +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; +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; + }; +} diff --git a/components/esp32-javascript/modules/esp32-javascript/config.js b/components/esp32-javascript/modules/esp32-javascript/config.js index 2def187..9602f35 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() { @@ -11,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 62dc9e1..df0be33 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: { @@ -7,6 +30,7 @@ export interface Esp32JsConfig { wifi?: { ssid?: string; password?: string; + bssid?: string; }; ota?: { url?: string; @@ -25,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 8fad4b3..f8c644c 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.js +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.js @@ -11,9 +11,34 @@ 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 native_ota_1 = require("./native-ota"); var http_1 = require("./http"); +var filelogging_1 = require("./filelogging"); var schema = { access: { type: "object", @@ -53,6 +78,10 @@ var schema = { type: "string", title: "Password", }, + bssid: { + type: "string", + title: "BSSID", + }, }, }, ota: { @@ -94,14 +123,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 \n

" + headline + "

"); if (Array.isArray(text)) { res.write(text.join("")); } @@ -110,6 +139,34 @@ 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() { console.info("Starting config server."); var authString = "Basic " + @@ -117,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"); @@ -125,14 +182,15 @@ function startConfigServer() { res.headers.set("WWW-Authenticate", 'Basic realm="Enter credentials"'); res.end("401 Unauthorized"); } + else if (req.path === "/health") { + res.end(JSON.stringify({ status: "ok" })); + } else if (req.path === "/restart" && req.method === "POST") { page(res, "Restart", '
Restarting... please wait. Home
', function () { setTimeout(restart, 1000); }); } 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; @@ -145,23 +203,34 @@ 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; 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) / + 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() + .map(function (e) { + 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" + ? '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 = ""; } else { var handled = false; @@ -172,12 +241,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 +304,78 @@ function startConfigServer() { } } }); + exports.requestHandler.push(function (req, res) { + 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 (/\/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 12fa8b1..adb5a61 100644 --- a/components/esp32-javascript/modules/esp32-javascript/configserver.ts +++ b/components/esp32-javascript/modules/esp32-javascript/configserver.ts @@ -1,5 +1,29 @@ +/* +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"; +import { upgrade } from "./native-ota"; import { httpServer, @@ -7,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: { @@ -47,6 +76,10 @@ let schema = { type: "string", title: "Password", }, + bssid: { + type: "string", + title: "BSSID", + }, }, }, ota: { @@ -97,7 +130,8 @@ function page( res: Esp32JsResponse, headline: string, text: string | string[], - cb?: () => void + cb?: () => void, + additionalHeadTags?: string ) { if (cb) { // register callback @@ -129,7 +163,6 @@ function page( } .formlabel { display: inline-block; - width: 130px; } .formpad { padding: 8px; @@ -140,8 +173,29 @@ function page( .red { color: red; } + .inline-form { + display: inline; + } + .blink { + animation: blinkanimation 1s linear infinite; + } + .nowrap { + white-space: nowrap; + } + @keyframes blinkanimation { + 50% { + opacity: 0; + } + } - + ${additionalHeadTags ? additionalHeadTags : ""} +

${headline}

`); if (Array.isArray(text)) { @@ -152,6 +206,37 @@ 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 { console.info("Starting config server."); const authString = @@ -170,6 +255,8 @@ export function startConfigServer(): void { res.setStatus(401); res.headers.set("WWW-Authenticate", 'Basic realm="Enter credentials"'); res.end("401 Unauthorized"); + } else if (req.path === "/health") { + res.end(JSON.stringify({ status: "ok" })); } else if (req.path === "/restart" && req.method === "POST") { page( res, @@ -180,9 +267,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; @@ -196,36 +280,48 @@ 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; storedConfig.ota.offline = config.offline === "true"; 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; + page( res, "Setup", `${ - saved - ? '
Saved. Some settings require a restart.
' + successMessage + ? `
${successMessage}
` : "" }${ - error - ? `
Saving failed. Error message: ${error}
` - : "" - }
-
${errorMessage}
` : "" + }

Configuration

Wifi

+

-

-

+

Basic authentication

+

+

+

JavaScript OTA


-

Request restart

+

Logs

+
+

+ 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("")} + +
+ + ${ + el_is_native_ota_supported() + ? `

Native OTA Upgrade

+
+

+

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

Request restart

-

Uptime

+

Uptime

Boot time: ${getBootTime()}
@@ -251,6 +385,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 +553,91 @@ export function startConfigServer(): void { } } }); + + requestHandler.push((req, res) => { + 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 (/\/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 b437023..4413312 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; @@ -37,11 +36,17 @@ declare function el_suspend(): Esp32JsEventloopEvent[]; declare function main(): void; interface Esp32JsWifiConfig { - bssid: number[]; + bssid: [number, number, number, number, number, number]; } declare function getWifiConfig(): Esp32JsWifiConfig; declare const EL_WIFI_EVENT_TYPE: number; -declare function el_connectWifi(ssid: string, password: string): void; +declare const EL_TIMER_EVENT_TYPE: number; +declare const EL_LOG_EVENT_TYPE: number; +declare function el_connectWifi( + ssid: string, + password: string, + bssid?: [number, number, number, number, number, number] +): void; declare function el_createSoftAp(ssid: string, password: string): void; declare function writeSocket( @@ -78,7 +83,54 @@ 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; +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; +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; +declare function el_find_partition(name: string): { + _ref: number; + 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/fetch.js b/components/esp32-javascript/modules/esp32-javascript/fetch.js index 6a9291e..3c61af1 100644 --- a/components/esp32-javascript/modules/esp32-javascript/fetch.js +++ b/components/esp32-javascript/modules/esp32-javascript/fetch.js @@ -1,518 +1,537 @@ -(function (self){ -var support = { - searchParams: 'URLSearchParams' in self, - iterable: 'Symbol' in self && 'iterator' in Symbol, - blob: - 'FileReader' in self && - 'Blob' in self && - (function() { - try { - new Blob() - return true - } catch (e) { - return false - } - })(), - formData: 'FormData' in self, - arrayBuffer: 'ArrayBuffer' in self - } - +(function (self) { + var support = { + searchParams: "URLSearchParams" in self, + iterable: "Symbol" in self && "iterator" in Symbol, + blob: + "FileReader" in self && + "Blob" in self && + (function () { + try { + new Blob(); + return true; + } catch (e) { + return false; + } + })(), + formData: "FormData" in self, + arrayBuffer: "ArrayBuffer" in self, + }; + function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj) + return obj && DataView.prototype.isPrototypeOf(obj); } - + if (support.arrayBuffer) { - var viewClasses = [ - '[object Int8Array]', - '[object Uint8Array]', - '[object Uint8ClampedArray]', - '[object Int16Array]', - '[object Uint16Array]', - '[object Int32Array]', - '[object Uint32Array]', - '[object Float32Array]', - '[object Float64Array]' - ] - - var isArrayBufferView = - ArrayBuffer.isView || - function(obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 - } - } - + var viewClasses = [ + "[object Int8Array]", + "[object Uint8Array]", + "[object Uint8ClampedArray]", + "[object Int16Array]", + "[object Uint16Array]", + "[object Int32Array]", + "[object Uint32Array]", + "[object Float32Array]", + "[object Float64Array]", + ]; + + var isArrayBufferView = + ArrayBuffer.isView || + function (obj) { + return ( + obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + ); + }; + } + function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name) - } - if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name) || name === '') { - throw new TypeError('Invalid character in header field name:'+name) - } - return name.toLowerCase() - } - + if (typeof name !== "string") { + name = String(name); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name) || name === "") { + throw new TypeError("Invalid character in header field name:" + name); + } + return name.toLowerCase(); + } + function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value) - } - return value + if (typeof value !== "string") { + value = String(value); + } + return value; } - + // Build a destructive iterator for the value list function iteratorFor(items) { - var iterator = { - next: function() { - var value = items.shift() - return {done: value === undefined, value: value} - } - } - - if (support.iterable) { - iterator[Symbol.iterator] = function() { - return iterator - } - } - - return iterator - } - - var Headers=function(headers) { - this.map = {} - - if (headers instanceof Headers) { - headers.forEach(function(value, name) { - this.append(name, value) - }, this) - } else if (Array.isArray(headers)) { - headers.forEach(function(header) { - this.append(header[0], header[1]) - }, this) - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]) - }, this) - } - } - - Headers.prototype.append = function(name, value) { - name = normalizeName(name) - value = normalizeValue(value) - var oldValue = this.map[name] - this.map[name] = oldValue ? oldValue + ', ' + value : value - } - - Headers.prototype['delete'] = function(name) { - delete this.map[normalizeName(name)] - } - - Headers.prototype.get = function(name) { - name = normalizeName(name) - return this.has(name) ? this.map[name] : null - } - - Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - } - - Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = normalizeValue(value) - } - - Headers.prototype.forEach = function(callback, thisArg) { - for (var name in this.map) { - if (this.map.hasOwnProperty(name)) { - callback.call(thisArg, this.map[name], name, this) - } - } - } - - Headers.prototype.keys = function() { - var items = [] - this.forEach(function(value, name) { - items.push(name) - }) - return iteratorFor(items) - } - - Headers.prototype.values = function() { - var items = [] - this.forEach(function(value) { - items.push(value) - }) - return iteratorFor(items) - } - - Headers.prototype.entries = function() { - var items = [] - this.forEach(function(value, name) { - items.push([name, value]) - }) - return iteratorFor(items) - } - + var iterator = { + next: function () { + var value = items.shift(); + return { done: value === undefined, value: value }; + }, + }; + + if (support.iterable) { + iterator[Symbol.iterator] = function () { + return iterator; + }; + } + + return iterator; + } + + var Headers = function (headers) { + this.map = {}; + + if (headers instanceof Headers) { + headers.forEach(function (value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function (header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function (name) { + this.append(name, headers[name]); + }, this); + } + }; + + Headers.prototype.append = function (name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ", " + value : value; + }; + + Headers.prototype["delete"] = function (name) { + delete this.map[normalizeName(name)]; + }; + + Headers.prototype.get = function (name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null; + }; + + Headers.prototype.has = function (name) { + return this.map.hasOwnProperty(normalizeName(name)); + }; + + Headers.prototype.set = function (name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; + + Headers.prototype.forEach = function (callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; + + Headers.prototype.keys = function () { + var items = []; + this.forEach(function (value, name) { + items.push(name); + }); + return iteratorFor(items); + }; + + Headers.prototype.values = function () { + var items = []; + this.forEach(function (value) { + items.push(value); + }); + return iteratorFor(items); + }; + + Headers.prototype.entries = function () { + var items = []; + this.forEach(function (value, name) { + items.push([name, value]); + }); + return iteratorFor(items); + }; + if (support.iterable) { - Headers.prototype[Symbol.iterator] = Headers.prototype.entries + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; } - + function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')) - } - body.bodyUsed = true + if (body.bodyUsed) { + return Promise.reject(new TypeError("Already read")); + } + body.bodyUsed = true; } - + function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result) - } - reader.onerror = function() { - reject(reader.error) - } - }) - } - + return new Promise(function (resolve, reject) { + reader.onload = function () { + resolve(reader.result); + }; + reader.onerror = function () { + reject(reader.error); + }; + }); + } + function readBlobAsArrayBuffer(blob) { - var reader = new FileReader() - var promise = fileReaderReady(reader) - reader.readAsArrayBuffer(blob) - return promise + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise; } - + function readBlobAsText(blob) { - var reader = new FileReader() - var promise = fileReaderReady(reader) - reader.readAsText(blob) - return promise + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise; } - + function readArrayBufferAsText(buf) { - var view = new Uint8Array(buf) - var chars = new Array(view.length) - - for (var i = 0; i < view.length; i++) { - chars[i] = String.fromCharCode(view[i]) - } - return chars.join('') - } - + var view = new Uint8Array(buf); + var chars = new Array(view.length); + + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } + return chars.join(""); + } + function bufferClone(buf) { - if (buf.slice) { - return buf.slice(0) - } else { - var view = new Uint8Array(buf.byteLength) - view.set(new Uint8Array(buf)) - return view.buffer - } - } - + if (buf.slice) { + return buf.slice(0); + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer; + } + } + function Body() { - this.bodyUsed = false - - this._initBody = function(body) { - this._bodyInit = body - if (!body) { - this._bodyText = '' - } else if (typeof body === 'string') { - this._bodyText = body - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this._bodyText = body.toString() - } else if (support.arrayBuffer && support.blob && isDataView(body)) { - this._bodyArrayBuffer = bufferClone(body.buffer) - // IE 10-11 can't handle a DataView body. - this._bodyInit = new Blob([this._bodyArrayBuffer]) - } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { - this._bodyArrayBuffer = bufferClone(body) - } else { - this._bodyText = body = Object.prototype.toString.call(body) - } - - if (!this.headers.get('content-type')) { - if (typeof body === 'string') { - this.headers.set('content-type', 'text/plain;charset=UTF-8') - } else if (this._bodyBlob && this._bodyBlob.type) { - this.headers.set('content-type', this._bodyBlob.type) - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') - } - } - } - - if (support.blob) { - this.blob = function() { - var rejected = consumed(this) - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(new Blob([this._bodyArrayBuffer])) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob') - } else { - return Promise.resolve(new Blob([this._bodyText])) - } - } - - this.arrayBuffer = function() { - if (this._bodyArrayBuffer) { - return consumed(this) || Promise.resolve(this._bodyArrayBuffer) - } else { - return this.blob().then(readBlobAsArrayBuffer) - } - } - } - - this.text = function() { - var rejected = consumed(this) - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text') - } else { - return Promise.resolve(this._bodyText) - } - } - - if (support.formData) { - this.formData = function() { - return this.text().then(decode) - } - } - - this.json = function() { - return this.text().then(JSON.parse) - } - - return this - } - + this.bodyUsed = false; + + this._initBody = function (body) { + this._bodyInit = body; + if (!body) { + this._bodyText = ""; + } else if (typeof body === "string") { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if ( + support.searchParams && + URLSearchParams.prototype.isPrototypeOf(body) + ) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + // IE 10-11 can't handle a DataView body. + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if ( + support.arrayBuffer && + (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body)) + ) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + + if (!this.headers.get("content-type")) { + if (typeof body === "string") { + this.headers.set("content-type", "text/plain;charset=UTF-8"); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set("content-type", this._bodyBlob.type); + } else if ( + support.searchParams && + URLSearchParams.prototype.isPrototypeOf(body) + ) { + this.headers.set( + "content-type", + "application/x-www-form-urlencoded;charset=UTF-8" + ); + } + } + }; + + if (support.blob) { + this.blob = function () { + var rejected = consumed(this); + if (rejected) { + return rejected; + } + + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])); + } else if (this._bodyFormData) { + throw new Error("could not read FormData body as blob"); + } else { + return Promise.resolve(new Blob([this._bodyText])); + } + }; + + this.arrayBuffer = function () { + if (this._bodyArrayBuffer) { + return consumed(this) || Promise.resolve(this._bodyArrayBuffer); + } else { + return this.blob().then(readBlobAsArrayBuffer); + } + }; + } + + this.text = function () { + var rejected = consumed(this); + if (rejected) { + return rejected; + } + + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); + } else if (this._bodyFormData) { + throw new Error("could not read FormData body as text"); + } else { + return Promise.resolve(this._bodyText); + } + }; + + if (support.formData) { + this.formData = function () { + return this.text().then(decode); + }; + } + + this.json = function () { + return this.text().then(JSON.parse); + }; + + return this; + } + // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] - + var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; + function normalizeMethod(method) { - var upcased = method.toUpperCase() - return methods.indexOf(upcased) > -1 ? upcased : method - } - - var Request=function(input, options) { - options = options || {} - var body = options.body - - if (input instanceof Request) { - if (input.bodyUsed) { - throw new TypeError('Already read') - } - this.url = input.url - this.credentials = input.credentials - if (!options.headers) { - this.headers = new Headers(input.headers) - } - this.method = input.method - this.mode = input.mode - this.signal = input.signal - if (!body && input._bodyInit != null) { - body = input._bodyInit - input.bodyUsed = true - } - } else { - this.url = String(input) - } - - this.credentials = options.credentials || this.credentials || 'same-origin' - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers) - } - this.method = normalizeMethod(options.method || this.method || 'GET') - this.mode = options.mode || this.mode || null - this.signal = options.signal || this.signal - this.referrer = null - - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests') - } - this._initBody(body) - } - - Request.prototype.clone = function() { - return new Request(this, {body: this._bodyInit}) - } - + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method; + } + + var Request = function (input, options) { + options = options || {}; + var body = options.body; + + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError("Already read"); + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } + + this.credentials = options.credentials || this.credentials || "same-origin"; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || "GET"); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; + + if ((this.method === "GET" || this.method === "HEAD") && body) { + throw new TypeError("Body not allowed for GET or HEAD requests"); + } + this._initBody(body); + }; + + Request.prototype.clone = function () { + return new Request(this, { body: this._bodyInit }); + }; + function decode(body) { - var form = new FormData() - body - .trim() - .split('&') - .forEach(function(bytes) { - if (bytes) { - var split = bytes.split('=') - var name = split.shift().replace(/\+/g, ' ') - var value = split.join('=').replace(/\+/g, ' ') - form.append(decodeURIComponent(name), decodeURIComponent(value)) - } - }) - return form - } - + var form = new FormData(); + body + .trim() + .split("&") + .forEach(function (bytes) { + if (bytes) { + var split = bytes.split("="); + var name = split.shift().replace(/\+/g, " "); + var value = split.join("=").replace(/\+/g, " "); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form; + } + function parseHeaders(rawHeaders) { - var headers = new Headers() - // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space - // https://tools.ietf.org/html/rfc7230#section-3.2 - var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ') - preProcessedHeaders.split(/\r?\n/).forEach(function(line) { - var parts = line.split(':') - var key = parts.shift().trim() - if (key) { - var value = parts.join(':').trim() - headers.append(key, value) - } - }) - return headers - } - - Body.call(Request.prototype) - - var Response=function(bodyInit, options) { - if (!options) { - options = {} - } - - this.type = 'default' - this.status = options.status === undefined ? 200 : options.status - this.ok = this.status >= 200 && this.status < 300 - this.statusText = 'statusText' in options ? options.statusText : 'OK' - this.headers = new Headers(options.headers) - this.url = options.url || '' - this._initBody(bodyInit) - } - - Body.call(Response.prototype) - - Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - } - - Response.error = function() { - var response = new Response(null, {status: 0, statusText: ''}) - response.type = 'error' - return response - } - - var redirectStatuses = [301, 302, 303, 307, 308] - - Response.redirect = function(url, status) { - if (redirectStatuses.indexOf(status) === -1) { - throw new RangeError('Invalid status code') - } - - return new Response(null, {status: status, headers: {location: url}}) - } - - var DOMException = self.DOMException + var headers = new Headers(); + // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " "); + preProcessedHeaders.split(/\r?\n/).forEach(function (line) { + var parts = line.split(":"); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(":").trim(); + headers.append(key, value); + } + }); + return headers; + } + + Body.call(Request.prototype); + + var Response = function (bodyInit, options) { + if (!options) { + options = {}; + } + + this.type = "default"; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = "statusText" in options ? options.statusText : "OK"; + this.headers = new Headers(options.headers); + this.url = options.url || ""; + this._initBody(bodyInit); + }; + + Body.call(Response.prototype); + + Response.prototype.clone = function () { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url, + }); + }; + + Response.error = function () { + var response = new Response(null, { status: 0, statusText: "" }); + response.type = "error"; + return response; + }; + + var redirectStatuses = [301, 302, 303, 307, 308]; + + Response.redirect = function (url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError("Invalid status code"); + } + + return new Response(null, { status: status, headers: { location: url } }); + }; + + var DOMException = self.DOMException; try { - new DOMException() + new DOMException(); } catch (err) { - DOMException = function(message, name) { - this.message = message - this.name = name - var error = Error(message) - this.stack = error.stack - } - DOMException.prototype = Object.create(Error.prototype) - DOMException.prototype.constructor = DOMException - } - - var fetch=function(input, init) { - return new Promise(function(resolve, reject) { - var request = new Request(input, init) - - if (request.signal && request.signal.aborted) { - return reject(new DOMException('Aborted', 'AbortError')) - } - - var xhr = new XMLHttpRequest() - - function abortXhr() { - xhr.abort() - } - - xhr.onload = function() { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') - } - options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL') - var body = 'response' in xhr ? xhr.response : xhr.responseText - resolve(new Response(body, options)) - } - - xhr.onerror = function() { - reject(new TypeError('Network request failed')) - } - - xhr.ontimeout = function() { - reject(new TypeError('Network request failed')) - } - - xhr.onabort = function() { - reject(new DOMException('Aborted', 'AbortError')) - } - - xhr.open(request.method, request.url, true) - - if (request.credentials === 'include') { - xhr.withCredentials = true - } else if (request.credentials === 'omit') { - xhr.withCredentials = false - } - - if ('responseType' in xhr && support.blob) { - xhr.responseType = 'blob' - } - - request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value) - }) - - if (request.signal) { - request.signal.addEventListener('abort', abortXhr) - - xhr.onreadystatechange = function() { - // DONE (success or failure) - if (xhr.readyState === 4) { - request.signal.removeEventListener('abort', abortXhr) - } - } - } - - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) - }) - } - - fetch.polyfill = true - + DOMException = function (message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; + DOMException.prototype = Object.create(Error.prototype); + DOMException.prototype.constructor = DOMException; + } + + var fetch = function (input, init) { + return new Promise(function (resolve, reject) { + var request = new Request(input, init); + + if (request.signal && request.signal.aborted) { + return reject(new DOMException("Aborted", "AbortError")); + } + + var xhr = new XMLHttpRequest(); + + function abortXhr() { + xhr.abort(); + } + + xhr.onload = function () { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || ""), + }; + options.url = + "responseURL" in xhr + ? xhr.responseURL + : options.headers.get("X-Request-URL"); + var body = "response" in xhr ? xhr.response : xhr.responseText; + resolve(new Response(body, options)); + }; + + xhr.onerror = function () { + reject(new TypeError("Network request failed")); + }; + + xhr.ontimeout = function () { + reject(new TypeError("Network request failed")); + }; + + xhr.onabort = function () { + reject(new DOMException("Aborted", "AbortError")); + }; + + xhr.open(request.method, request.url, true); + + if (request.credentials === "include") { + xhr.withCredentials = true; + } else if (request.credentials === "omit") { + xhr.withCredentials = false; + } + + if ("responseType" in xhr && support.blob) { + xhr.responseType = "blob"; + } + + request.headers.forEach(function (value, name) { + xhr.setRequestHeader(name, value); + }); + + if (request.signal) { + request.signal.addEventListener("abort", abortXhr); + + xhr.onreadystatechange = function () { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener("abort", abortXhr); + } + }; + } + + xhr.send( + typeof request._bodyInit === "undefined" ? null : request._bodyInit + ); + }); + }; + + fetch.polyfill = true; + if (!self.fetch) { - self.fetch = fetch - self.Headers = Headers - self.Request = Request - self.Response = Response + self.fetch = fetch; + self.Headers = Headers; + self.Request = Request; + self.Response = Response; } -})(global); \ No newline at end of file +})(global); 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..d1a5665 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/filelogging.js @@ -0,0 +1,85 @@ +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 = 8; +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; // swap to prevent endless loop when error occurs in this method + global.logBuffer = new stringbuffer_1.StringBuffer(); + var logFile = exports.FILE_LOGGING_DIRECTORY + "/logs-" + getLogFileNumber() + ".txt"; + try { + var ret = appendFile(logFile, swap.toString()); + if (ret < 0) { + console.error("Could not flush log file. Space exceeded?"); + } + } + catch (error) { + console.error("Could not open log file. Space exceeded?"); + } + 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..e9e6acd --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/filelogging.ts @@ -0,0 +1,91 @@ +/* +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 = 8; + +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; // swap to prevent endless loop when error occurs in this method + global.logBuffer = new StringBuffer(); + + const logFile = `${FILE_LOGGING_DIRECTORY}/logs-${getLogFileNumber()}.txt`; + try { + const ret = appendFile(logFile, swap.toString()); + if (ret < 0) { + console.error("Could not flush log file. Space exceeded?"); + } + } catch (error) { + console.error("Could not open log file. Space exceeded?"); + } + + 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/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..dc8d18d 100644 --- a/components/esp32-javascript/modules/esp32-javascript/global.js +++ b/components/esp32-javascript/modules/esp32-javascript/global.js @@ -1 +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. +*/ +// make `global` available for compatibility reasons. For new features use globalThis instead. 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..3803dff 100644 --- a/components/esp32-javascript/modules/esp32-javascript/global.ts +++ b/components/esp32-javascript/modules/esp32-javascript/global.ts @@ -1,3 +1,28 @@ +/* +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; +// make `global` available for compatibility reasons. For new features use globalThis instead. +(globalThis as any).global = globalThis; \ No newline at end of file diff --git a/components/esp32-javascript/modules/esp32-javascript/http.js b/components/esp32-javascript/modules/esp32-javascript/http.js index 2d3a354..446d482 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.js +++ b/components/esp32-javascript/modules/esp32-javascript/http.js @@ -1,6 +1,30 @@ 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; +/* +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"); var sockListen = socketEvents.sockListen; var sockConnect = socketEvents.sockConnect; @@ -50,7 +74,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) { @@ -67,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; } } @@ -115,7 +143,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 +190,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; } @@ -171,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") { @@ -225,34 +253,44 @@ 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); }); } if (gotten > 0 && socket.onData) { - socket.onData("", _, 0); + socket.onData(new Uint8Array(0), _, 0); } } } @@ -284,7 +322,11 @@ function parseQueryStr(query) { return parsed; } exports.parseQueryStr = parseQueryStr; -function httpClient(ssl, host, port, path, method, requestHeaders, body, successCB, errorCB, 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 +334,109 @@ 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 () { + }, function (sockfd) { if (errorCB) { errorCB("Could not load " + (ssl ? "https" : "http") + "://" + host + ":" + port + path); } + closeSocket(sockfd); }, 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 +445,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 +473,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 +502,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..7239871 100644 --- a/components/esp32-javascript/modules/esp32-javascript/http.ts +++ b/components/esp32-javascript/modules/esp32-javascript/http.ts @@ -1,4 +1,31 @@ +/* +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, + createChunkedEncodingConsumer, +} from "./chunked"; import { StringBuffer } from "./stringbuffer"; export interface Esp32JsRequest { @@ -78,8 +105,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"); @@ -102,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() @@ -111,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; } } @@ -235,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") { @@ -298,42 +328,51 @@ 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); }); } if (gotten > 0 && socket.onData) { - socket.onData("", _, 0); + socket.onData(new Uint8Array(0), _, 0); } } } @@ -377,22 +416,34 @@ export function httpClient( method: string, requestHeaders?: string, body?: { toString: () => string }, - successCB?: (content: string, headers: string) => void, + successCB?: undefined, // this is removed in favor of the new data and head callback (dataCB, headCB) errorCB?: (message: string) => void, - finishCB?: () => void -): void { - const complete: StringBuffer = new StringBuffer(); + 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; } - sockConnect( + const textDecoder = new TextDecoder(); + + const socket = sockConnect( ssl, host, port, @@ -407,87 +458,119 @@ export function httpClient( 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; - 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() - ); + 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); } - headerEnd += 4; - } - if (chunked) { - if (complete.substring(complete.length - 5).toString() == "0\r\n\r\n") { - closeSocket(sockfd); + 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); + + if (contentLength >= 0) { + if (completeLength - headerEnd == contentLength) { + closeSocket(sockfd); + } + } + } catch (error) { + if (errorCB) { + errorCB(error); } + closeSocket(sockfd); } }, - function () { + function (sockfd) { if (errorCB) { errorCB( `Could not load ${ssl ? "https" : "http"}://${host}:${port}${path}` ); } + closeSocket(sockfd) }, 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(); } } ); + + 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 +578,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 +592,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 +619,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 +655,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..55842a2 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.js +++ b/components/esp32-javascript/modules/esp32-javascript/index.js @@ -1,24 +1,57 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -console.info("Load global.js (NEW)..."); -require("./global.js"); -var http = require("./http"); -var boot = require("./boot"); -var eventloop = require("esp32-js-eventloop"); -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(); +/* +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 @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 90e08b6..d7cda92 100644 --- a/components/esp32-javascript/modules/esp32-javascript/index.ts +++ b/components/esp32-javascript/modules/esp32-javascript/index.ts @@ -1,32 +1,70 @@ -console.info("Load global.js (NEW)..."); -require("./global.js"); +/* +MIT License -import http = require("./http"); -import boot = require("./boot"); -import eventloop = require("esp32-js-eventloop"); -import configManager = require("./config"); +Copyright (c) 2021 Marcel Kottmann -console.info("Loading promise.js and exposing globals (NEW)..."); -// eslint-disable-next-line @typescript-eslint/no-var-requires -global.Promise = require("./promise.js").Promise; +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: -console.info("Loading config (NEW)..."); -configManager.reloadConfig(); +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -console.info("Loading http.js and exposing globals (NEW)..."); -global.XMLHttpRequest = http.XMLHttpRequest; +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 @typescript-eslint/no-var-requires */ -console.info("Loading fetch.js and exposing globals (NEW)..."); -require("./fetch.js"); +try { + console.info("Load global.js (NEW)..."); + require("./global.js"); -console.info("Loading boot.js and exposing main (NEW)..."); -global.main = boot.main; + console.info("Loading file logging buffer (NEW)..."); + require("./filelogging"); -console.info("Loading socket-events (NEW)..."); -require("socket-events"); + console.info("Importing http (NEW)..."); + const http = require("./http"); -console.info("Loading wifi-events (NEW)..."); -require("wifi-events"); + console.info("Importing boot (NEW)..."); + const boot = require("./boot"); -console.info("Loading eventloop.js and starting eventloop (NEW)..."); -eventloop.start(); + console.info("Importing eventloop (NEW)..."); + const eventloop = require("esp32-js-eventloop"); + + console.info("Importing config (NEW)..."); + const 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/native-ota.js b/components/esp32-javascript/modules/esp32-javascript/native-ota.js new file mode 100644 index 0000000..38fc633 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.js @@ -0,0 +1,145 @@ +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) { + 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; +} +var 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); + 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), + ]; +}; +exports.upgrade = upgrade; 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..ab000b4 --- /dev/null +++ b/components/esp32-javascript/modules/esp32-javascript/native-ota.ts @@ -0,0 +1,192 @@ +/* +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"; + +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 => { + 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}`); + + 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/esp32-javascript/modules/esp32-javascript/promise.js b/components/esp32-javascript/modules/esp32-javascript/promise.js index 3f3845a..715440e 100644 --- a/components/esp32-javascript/modules/esp32-javascript/promise.js +++ b/components/esp32-javascript/modules/esp32-javascript/promise.js @@ -295,31 +295,19 @@ module.exports=(function() { } - var registry = (function() { - - var records = []; - + var registry = (function () { function add(promise, enhancedPromise) { - records.push({ - promise: promise, - enhancedPromise: enhancedPromise - }); + promise.__enhancedPromise = enhancedPromise; } function getEnhanced(promise) { - for(var i = 0; i < records.length; i++) { - var record = records[i]; - if(record.promise === promise) { - return record.enhancedPromise; - } - } + return promise.__enhancedPromise; } return { add: add, - getEnhanced: getEnhanced - } - + getEnhanced: getEnhanced, + }; })(); function Promise(executor) { 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.js b/components/esp32-javascript/modules/esp32-js-eventloop/index.js index f48938a..db4a4c8 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.js +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.js @@ -1,18 +1,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.start = exports.afterSuspendHandlers = exports.beforeSuspendHandlers = void 0; -errorhandler = - typeof errorhandler === "undefined" - ? function (error) { - console.error("Uncaught error:"); - console.error(error.stack || error); - } - : errorhandler; +errorhandler = function () { + // empty default implementation +}; +function internalErrorHandler(error) { + console.error("Uncaught error:"); + console.error(error.stack || error); + global.el_flushLogBuffer(); + errorhandler(error); +} var timers = []; 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 +40,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 +48,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,28 +61,48 @@ 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 (evt.type === 0) { + if (console.isDebug) { + console.debug("== HANDLE EVENT: " + JSON.stringify(evt) + " =="); + } + if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT var nextTimer = null; for (var timerIdx = 0; timerIdx < timers.length; timerIdx++) { if (timers[timerIdx].handle === evt.status) { nextTimer = timers.splice(timerIdx, 1)[0]; + el_removeTimer(nextTimer.handle); collected.push(nextTimer.fn); } } if (!nextTimer) { - //throw Error('UNKNOWN TIMER HANDLE!!!'); console.warn("UNKNOWN TIMER HANDLE:" + JSON.stringify(evt) + ";" + JSON.stringify(timers)); } } + else if (evt.type === EL_LOG_EVENT_TYPE) { + //LOG EVENT + 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(el_readAndFreeString(evt.fd)); + } else { var eventHandled_1 = false; if (exports.afterSuspendHandlers) { @@ -104,21 +123,18 @@ function el_select_next() { return collected; } function start() { - // eslint-disable-next-line @typescript-eslint/ban-types var nextfuncs = [main]; for (;;) { - if (Array.isArray(nextfuncs)) { - nextfuncs.forEach(function (nf) { - if (typeof nf === "function") { - try { - nf(); - } - catch (error) { - errorhandler(error); - } + nextfuncs.forEach(function (nf) { + if (typeof nf === "function") { + try { + nf(); } - }); - } + catch (error) { + internalErrorHandler(error); + } + } + }); nextfuncs = el_select_next(); } } diff --git a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts index ea525da..9a06cad 100644 --- a/components/esp32-javascript/modules/esp32-js-eventloop/index.ts +++ b/components/esp32-javascript/modules/esp32-js-eventloop/index.ts @@ -1,24 +1,50 @@ +/* +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; - // 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 = - typeof errorhandler === "undefined" - ? function (error) { - console.error("Uncaught error:"); - console.error(error.stack || error); - } - : errorhandler; +errorhandler = function () { + // empty default implementation +}; + +function internalErrorHandler(error: Error) { + console.error("Uncaught error:"); + console.error(error.stack || error); + + global.el_flushLogBuffer(); + + errorhandler(error); +} const timers: Esp32JsTimer[] = []; const intervals: number[] = []; @@ -26,8 +52,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, @@ -56,8 +81,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(); @@ -66,8 +94,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); @@ -83,29 +110,48 @@ 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 (evt.type === 0) { + if (console.isDebug) { + console.debug(`== HANDLE EVENT: ${JSON.stringify(evt)} ==`); + } + if (evt.type === EL_TIMER_EVENT_TYPE) { //TIMER EVENT let nextTimer = null; for (let timerIdx = 0; timerIdx < timers.length; timerIdx++) { if (timers[timerIdx].handle === evt.status) { nextTimer = timers.splice(timerIdx, 1)[0]; + el_removeTimer(nextTimer.handle); collected.push(nextTimer.fn); } } if (!nextTimer) { - //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 + 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(el_readAndFreeString(evt.fd)); } else { let eventHandled = false; if (afterSuspendHandlers) { @@ -127,20 +173,17 @@ function el_select_next() { } export function start(): void { - // eslint-disable-next-line @typescript-eslint/ban-types - let nextfuncs: Function[] = [main]; - for (; ;) { - if (Array.isArray(nextfuncs)) { - nextfuncs.forEach(function (nf) { - if (typeof nf === "function") { - try { - nf(); - } catch (error) { - errorhandler(error); - } + let nextfuncs: (() => void)[] = [main]; + for (;;) { + nextfuncs.forEach(function (nf) { + if (typeof nf === "function") { + try { + nf(); + } catch (error) { + internalErrorHandler(error); } - }); - } + } + }); nextfuncs = el_select_next(); } } 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 a36f571..e6af512 100644 --- a/components/socket-events/modules/socket-events/index.js +++ b/components/socket-events/modules/socket-events/index.js @@ -1,19 +1,116 @@ 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 = []; -exports.sockets.pushNative = exports.sockets.push; -exports.sockets.push = function (item) { - exports.sockets.pushNative(item); -}; -exports.sockets.find = function (predicate) { - for (var i = 0; i < exports.sockets.length; i++) { - if (predicate(exports.sockets[i])) { - return exports.sockets[i]; +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; +}()); +var SocketLookupMap = /** @class */ (function () { + function SocketLookupMap() { + this.map = {}; } -}; + 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 */ @@ -40,10 +137,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; } @@ -61,11 +158,60 @@ var Socket = /** @class */ (function () { this.clearReadTimeoutTimer(); if (this.readTimeout > 0) { this.readTimeoutHandle = setTimeout(function () { - console.log("Close socket because of read timeout."); + if (console.isDebug) { + console.debug("Close socket because of read timeout."); + } closeSocket(_this); }, this.readTimeout); } }; + Socket.prototype.maintainSocketStatus = function () { + exports.sockets.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) { @@ -109,12 +255,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; } @@ -123,14 +275,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(); @@ -177,16 +331,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."); @@ -204,6 +354,7 @@ function closeSocket(socketOrSockfd) { } performOnClose(socket); resetSocket(socket); + socket.sockfd = -1; } exports.closeSocket = closeSocket; /** @@ -221,7 +372,13 @@ exports.closeSocket = closeSocket; */ function sockConnect(ssl, host, port, onConnect, onData, onError, onClose) { var sockfd = el_createNonBlockingSocket(); - el_connectNonBlocking(sockfd, host, parseInt(port, 10)); + var connectError; + try { + el_connectNonBlocking(sockfd, host, parseInt(port, 10)); + } + catch (error) { + connectError = error; + } var socket = getOrCreateNewSocket(); socket.sockfd = sockfd; socket.onData = onData; @@ -254,8 +411,11 @@ function sockConnect(ssl, host, port, onConnect, onData, onError, onClose) { } }; } - if (exports.sockets.indexOf(socket) < 0) { - exports.sockets.push(socket); + exports.sockets.add(socket); + //if connect error occured call the callback + if (connectError && socket.onError) { + console.debug("Error connecting " + host + ":" + port + " : " + connectError); + socket.onError(sockfd); } return socket; } @@ -294,9 +454,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); } @@ -308,7 +466,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) { @@ -320,56 +480,30 @@ 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; } } exports.sockListen = sockListen; function resetSocket(socket) { + if (console.isDebug) { + console.debug("Reset Socket called on " + socket.sockfd); + } if (socket) { - exports.sockets.splice(exports.sockets.indexOf(socket), 1); + exports.sockets.remove(socket.sockfd); return; } throw Error("invalid sockfd"); } function beforeSuspend() { - //collect sockets - function notConnectedFilter(s) { - return !s.isConnected && !s.isListening; - } - function connectedFilter(s) { - return s.isConnected; - } - function connectedWritableFilter(s) { - return s.isConnected && s.onWritable; - } - function mapToSockfd(s) { - return s.sockfd; + if (console.isDebug) { + 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"); } - 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(exports.sockets.sst_notConnectedSockets.set, exports.sockets.sst_connectedSockets.set, exports.sockets.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) { - 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 @@ -394,15 +528,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 && typeof result.data === "string" && result.length == 0)) { + (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 d5a4995..71e800a 100644 --- a/components/socket-events/modules/socket-events/index.ts +++ b/components/socket-events/modules/socket-events/index.ts @@ -1,9 +1,36 @@ +/* +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, } 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; @@ -27,59 +54,106 @@ 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. - */ +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); + } + } +} -/** - * An array which holds all active sockets. - * - * @type module:socket-events~Socket[] - */ -interface SocketArrayFind { - find(predicate: (socket: Socket) => boolean): Socket; +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]; + } } -export const sockets: Socket[] & SocketArrayFind = [] as any; - -(sockets as any).pushNative = sockets.push; -(sockets as any).push = function (item: Esp32JsSocket) { - (sockets as any).pushNative(item); -}; -(sockets as any).find = function (predicate: (socket: Socket) => boolean) { - for (let i = 0; i < sockets.length; i++) { - if (predicate(sockets[i])) { - return sockets[i]; + +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( + `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); } } -}; + + public add(item: Socket) { + this.activeSockets.add(item); + this.maintainSocketStatus( + item.sockfd, + item.isListening, + item.isConnected, + item.isError, + item.onWritable + ); + } + + public remove(sockfd: number) { + this.sst_connectedSockets.remove(sockfd); + this.sst_notConnectedSockets.remove(sockfd); + this.sst_connectedWritableSockets.remove(sockfd); + + this.activeSockets.remove(sockfd); + } + + public get(sockfd: number): Socket | undefined { + return this.activeSockets.get(sockfd); + } +} +export const sockets = new ActiveSockets(); interface BufferEntry { written: number; @@ -114,7 +188,9 @@ class Socket implements Esp32JsSocket { this.clearReadTimeoutTimer(); if (this.readTimeout > 0) { this.readTimeoutHandle = setTimeout(() => { - console.log("Close socket because of read timeout."); + if (console.isDebug) { + console.debug("Close socket because of read timeout."); + } closeSocket(this); }, this.readTimeout); } @@ -135,13 +211,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() { + sockets.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) { @@ -186,7 +308,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, @@ -194,10 +318,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; } @@ -205,16 +333,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(); @@ -266,15 +398,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) { @@ -297,6 +425,7 @@ export function closeSocket(socketOrSockfd: Esp32JsSocket | number): void { } performOnClose(socket); resetSocket(socket); + socket.sockfd = -1; } /** @@ -317,12 +446,18 @@ 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)); + + let connectError; + try { + el_connectNonBlocking(sockfd, host, parseInt(port, 10)); + } catch (error) { + connectError = error; + } const socket = getOrCreateNewSocket(); socket.sockfd = sockfd; @@ -356,9 +491,14 @@ export function sockConnect( }; } - if (sockets.indexOf(socket) < 0) { - sockets.push(socket); + sockets.add(socket); + + //if connect error occured call the callback + if (connectError && socket.onError) { + console.debug(`Error connecting ${host}:${port} : ${connectError}`); + socket.onError(sockfd); } + return socket; } @@ -404,9 +544,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); } @@ -417,7 +555,9 @@ export function sockListen( } } } else { - console.debug("EAGAIN received after accept..."); + if (console.isDebug) { + console.debug("EAGAIN received after accept..."); + } } }; socket.onError = function (sockfd) { @@ -430,64 +570,41 @@ export function sockListen( socket.isError = false; socket.isListening = true; - if (sockets.indexOf(socket) < 0) { - sockets.push(socket); - } + sockets.add(socket); return socket; } } function resetSocket(socket: Socket) { + if (console.isDebug) { + console.debug(`Reset Socket called on ${socket.sockfd}`); + } if (socket) { - sockets.splice(sockets.indexOf(socket), 1); + sockets.remove(socket.sockfd); return; } throw Error("invalid sockfd"); } function beforeSuspend() { - //collect sockets - function notConnectedFilter(s: Socket) { - return !s.isConnected && !s.isListening; - } - function connectedFilter(s: Socket) { - return s.isConnected; - } - 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; + if (console.isDebug) { + console.debug(`Socket FDs for select. + not connected =>${sockets.sst_notConnectedSockets.set} + connected =>${sockets.sst_connectedSockets.set} + connected wri =>${sockets.sst_connectedWritableSockets.set} +`); } - 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 + sockets.sst_notConnectedSockets.set, + sockets.sst_connectedSockets.set, + sockets.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; - }); - const socket = findSocket[0]; + const socket = sockets.get(evt.fd); if (socket) { if (evt.status === 0) { //writable @@ -509,16 +626,28 @@ 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 && typeof result.data === "string" && result.length == 0) + (result && + Object.prototype.toString.call(result.data) === + "[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 0a6253a..0caae94 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 @@ -61,8 +61,8 @@ int connectedWritableSockets_len = 0; int *connectedWritableSockets = NULL; int selectClientSocket = -1; int selectServerSocket = -1; -SemaphoreHandle_t xSemaphore; -bool needsUnblock = false; +volatile SemaphoreHandle_t xSemaphore; +volatile bool needsUnblock = false; struct sockaddr_in target; extern const uint8_t cacert_pem_start[] asm("_binary_cacert_pem_start"); @@ -71,11 +71,13 @@ extern const uint8_t cacert_pem_end[] asm("_binary_cacert_pem_end"); extern const uint8_t prvtkey_pem_start[] asm("_binary_prvtkey_pem_start"); extern const uint8_t prvtkey_pem_end[] asm("_binary_prvtkey_pem_end"); +static const char *tag = "esp32-javascript"; + 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 +94,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 +114,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 +130,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 +164,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,20 +233,14 @@ 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) { char msg[dataAvailable]; - struct sockaddr_in remaddr; - 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); - } - else + if (recv(selectServerSocket, msg, dataAvailable, 0) < 0) { - jslog(DEBUG, "READ of self-socket.\n"); + jslog(ERROR, "READ self-socket FAILED: %d", errno); } } @@ -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.\n", ret); if (ret >= 0) { if (ret > 0) @@ -305,27 +300,52 @@ 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); + if (errno == 9) + { + jslog(DEBUG, "select returns EBADF: Most likely due to socket read timeout during select."); + } + else + { + 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; } +static void triggerNextSelectIteration() +{ + jslog(DEBUG, "Trying to trigger the next select iteration..."); + if (selectClientSocket >= 0) + { + //interrupt select through self-socket + jslog(DEBUG, "Sending . to self-socket."); + if (sendto(selectClientSocket, ".", 1, 0, (struct sockaddr *)&target, sizeof(target)) < 0) + { + jslog(ERROR, "Self-socket sending was NOT successful: %d", errno); + } + else + { + jslog(DEBUG, "Self-socket sending was successful."); + } + } +} + static duk_ret_t el_registerSocketEvents(duk_context *ctx) { int c_len, nc_len, cw_len; @@ -451,21 +471,7 @@ static duk_ret_t el_registerSocketEvents(duk_context *ctx) if (changes) { - jslog(DEBUG, "Trying to trigger the next select iteration... "); - if (selectClientSocket >= 0) - { - //interrupt select through self-socket - jslog(DEBUG, "Sending . to self-socket."); - needsUnblock = true; - if (sendto(selectClientSocket, ".", 1, 0, (struct sockaddr *)&target, sizeof(target)) < 0) - { - jslog(ERROR, "Self-socket sending was NOT successful: %d\n", errno); - } - else - { - jslog(DEBUG, "Self-socket sending was successful.\n"); - } - } + triggerNextSelectIteration(); } //trigger next select loop @@ -492,8 +498,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 +520,13 @@ static duk_ret_t el_acceptIncoming(duk_context *ctx) { if (errno == EAGAIN) { - jslog(INFO, "accept returned EAGAIN\n"); + jslog(DEBUG, "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); } } @@ -606,6 +611,7 @@ static duk_ret_t connectSSL(duk_context *ctx) static duk_ret_t el_closeSocket(duk_context *ctx) { int socketfd = duk_to_int(ctx, 0); + closeSocket(socketfd); return 0; } @@ -713,19 +719,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 +742,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..8de2b26 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 @@ -37,30 +37,53 @@ SOFTWARE. #include "esp32-js-log.h" #include "esp32-javascript.h" -#define BUFSIZE 1024 #define LISTEN_BACKLOG 50 +int setNonBlocking(int sockfd) +{ + int opt = 1; + int ret = lwip_ioctl(sockfd, FIONBIO, &opt); + + if (ret >= 0) + { + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 1; + + if (lwip_setsockopt(sockfd, + SOL_SOCKET, + SO_RCVTIMEO, + &tv, + sizeof(struct timeval)) < 0) + { + jslog(ERROR, "Cannot set timeout opt."); + return -1; + } + } + + return ret; +} + int createNonBlockingSocket(int domain, int type, int protocol, bool nonblocking) { int sockfd; - int opt; + int ret; /* socket: create the socket */ sockfd = socket(domain, type, protocol); if (sockfd < 0) { - jslog(ERROR, "ERROR opening socket\n"); + jslog(ERROR, "ERROR opening socket"); return -1; } if (nonblocking) { - opt = 1; - ret = lwip_ioctl(sockfd, FIONBIO, &opt); + int ret = setNonBlocking(sockfd); if (ret < 0) { - jslog(ERROR, "Cannot set non-blocking opt.\n"); + jslog(ERROR, "Cannot set non-blocking opt."); return -1; } } @@ -78,7 +101,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 %s", hostname); return -1; } @@ -93,7 +116,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; @@ -107,11 +130,10 @@ int acceptIncoming(int sockfd) int one = 1; setsockopt(cfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); - int opt = 1; - int ret = lwip_ioctl(cfd, FIONBIO, &opt); + int ret = setNonBlocking(sockfd); 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 +141,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 +163,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 +191,12 @@ int writeSocket(int sockfd, const char *msg, int len, SSL *ssl) { if (errno == EAGAIN) { - jslog(INFO, "EAGAIN in socket: %d\n", errno); + jslog(DEBUG, "EAGAIN in socket %d, errno %d", sockfd, errno); return 0; } else { - jslog(ERROR, "ERROR writing to socket: %d\n", errno); + jslog(ERROR, "ERROR writing to socket %d, errno %d", sockfd, errno); return n; } } @@ -183,34 +205,16 @@ int writeSocket(int sockfd, const char *msg, int len, SSL *ssl) int readSocket(int sockfd, char *msg, int len) { - struct sockaddr_in remaddr; - socklen_t addrlen = sizeof(remaddr); - int result = 0; - int opt = 1; - int ret = lwip_ioctl(sockfd, FIONBIO, &opt); + int ret = setNonBlocking(sockfd); if (ret < 0) { - jslog(ERROR, "Cannot set non-blocking opt.\n"); - return -1; - } - - struct timeval tv; - tv.tv_sec = 1; - tv.tv_usec = 0; - - if (lwip_setsockopt(sockfd, - SOL_SOCKET, - SO_RCVTIMEO, - &tv, - sizeof(struct timeval)) < 0) - { - jslog(ERROR, "Cannot set timeout opt.\n"); + jslog(ERROR, "Cannot set non-blocking opt."); return -1; } - result = recvfrom(sockfd, msg, len, MSG_DONTWAIT, (struct sockaddr *)&remaddr, &addrlen); + result = recv(sockfd, msg, len, MSG_DONTWAIT); return result; } diff --git a/components/spiffs-events/spiffs-events.c b/components/spiffs-events/spiffs-events.c index c5db8a7..2111c6a 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 @@ -23,6 +23,7 @@ SOFTWARE. */ #include +#include #include #include #include @@ -32,10 +33,13 @@ SOFTWARE. #include #include "esp32-js-log.h" #include "esp32-javascript.h" +#include "esp_ota_ops.h" +#include "esp_partition.h" +#include 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,13 +80,30 @@ 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 '%s' to get filesize, errno %i", path, errno); + 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) { - jslog(ERROR, "Failed to open file for reading"); + jslog(ERROR, "Failed to open file '%s' for reading.", path); return NULL; } @@ -99,13 +120,33 @@ 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) { - 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); + fclose(f); + 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 '%s' for appending, errno %i", path, errno); return -1; } int result = fputs(content, f); @@ -119,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); @@ -135,6 +217,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 +240,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 +270,26 @@ 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"); + duk_push_c_function(ctx, el_listDir, 1); + duk_put_global_string(ctx, "listDir"); } void initSpiffs(duk_context *ctx) { - initFilesystem("modules", "/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"); registerBindings(ctx); } 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..0663f57 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; +exports.getIPAddress = exports.convertBssidToArray = exports.convertBssidToString = 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) { @@ -15,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; /** @@ -38,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. @@ -68,7 +114,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 49854b1..fd1d968 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"; /** @@ -30,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 + ); } /** @@ -60,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]; + } } /** @@ -94,8 +149,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/components/wifi-events/wifi-events.c b/components/wifi-events/wifi-events.c index 7e03d0e..285da01 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 @@ -33,6 +33,9 @@ SOFTWARE. static EventGroupHandle_t wifi_event_group; static const int CONNECTED_BIT = BIT0; static const int SCANNING_BIT = BIT1; +static volatile uint8_t *staticBssid = NULL; + +static const char *tag = "esp32-javascript"; void startScan() { @@ -44,7 +47,7 @@ void startScan() int ret = esp_wifi_scan_start(&scanConf, false); if (ret > 0) { - jslog(WARN, "SCAN RETURNED %d\n", ret); + ESP_LOGW(tag, "SCAN RETURNED %d", ret); } else { @@ -52,6 +55,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; @@ -61,7 +76,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); + ESP_LOGD(tag, "WIFI EVENT %d", sysevent->event_id); switch (sysevent->event_id) { case SYSTEM_EVENT_SCAN_DONE: @@ -69,10 +84,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)); + ESP_LOGD(tag, "Search for SSID %s ", wifi_config.sta.ssid); + if (staticBssid != NULL) + { + ESP_LOGD(tag, "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\n", sysevent->event_info.scan_done.number); - uint8_t *bssid = NULL; + ESP_LOGD(tag, "Number of access points found: %d", sysevent->event_info.scan_done.number); + uint8_t *selectedBssid = NULL; int8_t rssi = -127; wifi_ap_record_t *list = NULL; if (apCount > 0) @@ -83,29 +104,36 @@ 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); + + ESP_LOGD(tag, "ssidmatch=%s, bssidmatch=%s", ssidMatch ? "true" : "false", bssidMatch ? "true" : "false"); + ESP_LOGD(tag, "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; + ESP_LOGD(tag, "==> 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\n", 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_LOGI(tag, "==> 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(); } else { - jslog(ERROR, "SSID not found %s\n", wifi_config.sta.ssid); + ESP_LOGD(tag, "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); @@ -116,7 +144,8 @@ static IRAM_ATTR esp_err_t event_handler(void *ctx, system_event_t *sysevent) if (list != NULL) { - free(list); + spiram_free(list); + list = NULL; } break; } @@ -155,7 +184,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); + ESP_LOGE(tag, "UNKNOWN WIFI EVENT %d", sysevent->event_id); break; } @@ -218,6 +247,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 +301,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 %s ...", wifi_config.sta.ssid, wifi_config.sta.password); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); + + if (staticBssid != NULL) + { + free(staticBssid); + staticBssid = NULL; + } + if (bssid != NULL) + { + staticBssid = bssid; + } + 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()); + startScan(); } @@ -276,7 +338,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*/); diff --git a/docs/README.md b/docs/README.md index 0427cff..783c297 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,12 +7,15 @@ ### Modules * ["esp32-javascript/modules/esp32-javascript/boot"](modules/_esp32_javascript_modules_esp32_javascript_boot_.md) +* ["esp32-javascript/modules/esp32-javascript/chunked"](modules/_esp32_javascript_modules_esp32_javascript_chunked_.md) * ["esp32-javascript/modules/esp32-javascript/config"](modules/_esp32_javascript_modules_esp32_javascript_config_.md) * ["esp32-javascript/modules/esp32-javascript/configserver"](modules/_esp32_javascript_modules_esp32_javascript_configserver_.md) +* ["esp32-javascript/modules/esp32-javascript/filelogging"](modules/_esp32_javascript_modules_esp32_javascript_filelogging_.md) * ["esp32-javascript/modules/esp32-javascript/firmware-config"](modules/_esp32_javascript_modules_esp32_javascript_firmware_config_.md) * ["esp32-javascript/modules/esp32-javascript/global"](modules/_esp32_javascript_modules_esp32_javascript_global_.md) * ["esp32-javascript/modules/esp32-javascript/http"](modules/_esp32_javascript_modules_esp32_javascript_http_.md) * ["esp32-javascript/modules/esp32-javascript/index"](modules/_esp32_javascript_modules_esp32_javascript_index_.md) +* ["esp32-javascript/modules/esp32-javascript/native-ota"](modules/_esp32_javascript_modules_esp32_javascript_native_ota_.md) * ["esp32-javascript/modules/esp32-javascript/self-test"](modules/_esp32_javascript_modules_esp32_javascript_self_test_.md) * ["esp32-javascript/modules/esp32-javascript/self-test-firmware-config"](modules/_esp32_javascript_modules_esp32_javascript_self_test_firmware_config_.md) * ["esp32-javascript/modules/esp32-javascript/stringbuffer"](modules/_esp32_javascript_modules_esp32_javascript_stringbuffer_.md) diff --git a/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.eventemitter.md b/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.eventemitter.md index ea858e4..065ea2f 100644 --- a/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.eventemitter.md +++ b/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.eventemitter.md @@ -23,7 +23,7 @@ • **listener**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:49](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L49)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:76](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L76)* #### Type declaration: @@ -35,7 +35,7 @@ ▸ **emit**(`event`: string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:53](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L53)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:80](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L80)* **Parameters:** @@ -51,7 +51,7 @@ ___ ▸ **on**(`event`: string, `cb`: function): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:50](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L50)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:77](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L77)* **Parameters:** diff --git a/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md b/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md index 61eb90e..ef282a1 100644 --- a/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md +++ b/docs/classes/_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md @@ -15,10 +15,10 @@ * [onload](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#optional-onload) * [reponseHeaders](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-reponseheaders) * [requestHeaders](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-requestheaders) -* [responseText](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-responsetext) -* [responseURL](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-responseurl) -* [status](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-status) -* [statusText](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-statustext) +* [responseText](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#optional-responsetext) +* [responseURL](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#optional-responseurl) +* [status](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#optional-status) +* [statusText](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#optional-statustext) * [url](_esp32_javascript_modules_esp32_javascript_http_.xmlhttprequest.md#private-optional-url) ### Methods @@ -34,7 +34,7 @@ • **method**: *string* = "GET" -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:484](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L484)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:567](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L567)* ___ @@ -42,7 +42,7 @@ ___ • **onerror**? : *undefined | function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:492](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L492)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:575](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L575)* ___ @@ -50,7 +50,7 @@ ___ • **onload**? : *undefined | function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:493](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L493)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:576](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L576)* ___ @@ -58,7 +58,7 @@ ___ • **reponseHeaders**? : *undefined | string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:485](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L485)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:568](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L568)* ___ @@ -66,39 +66,39 @@ ___ • **requestHeaders**? : *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:486](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L486)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:569](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L569)* ___ -### `Private` `Optional` responseText +### `Optional` responseText • **responseText**? : *undefined | string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:490](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L490)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:573](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L573)* ___ -### `Private` `Optional` responseURL +### `Optional` responseURL • **responseURL**? : *undefined | string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:489](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L489)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:572](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L572)* ___ -### `Private` `Optional` status +### `Optional` status • **status**? : *undefined | number* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:487](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L487)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:570](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L570)* ___ -### `Private` `Optional` statusText +### `Optional` statusText • **statusText**? : *undefined | string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:488](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L488)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:571](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L571)* ___ @@ -106,7 +106,7 @@ ___ • **url**? : *[AnchorElement](../interfaces/_esp32_javascript_urlparse_.anchorelement.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:483](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L483)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:566](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L566)* ## Methods @@ -114,7 +114,7 @@ ___ ▸ **getAllResponseHeaders**(): *string | undefined* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:538](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L538)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:643](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L643)* **Returns:** *string | undefined* @@ -124,7 +124,7 @@ ___ ▸ **open**(`method`: string, `url`: string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:542](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L542)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:647](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L647)* **Parameters:** @@ -141,7 +141,7 @@ ___ ▸ **send**(`body`: string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:495](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L495)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:578](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L578)* **Parameters:** @@ -157,7 +157,7 @@ ___ ▸ **setRequestHeader**(`name`: string, `value`: string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:569](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L569)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:662](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L662)* **Parameters:** diff --git a/docs/classes/_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md b/docs/classes/_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md index d6b554b..aa474ad 100644 --- a/docs/classes/_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md +++ b/docs/classes/_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md @@ -33,7 +33,7 @@ \+ **new StringBuffer**(`s?`: undefined | string): *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L26)* **Parameters:** @@ -47,9 +47,9 @@ Name | Type | ### `Private` content -• **content**: *string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›[]* +• **content**: *(string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›)[]* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:2](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L2)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L25)* ___ @@ -57,21 +57,21 @@ ___ • **length**: *number* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L26)* ## Methods ### append -▸ **append**(...`s`: string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›[]): *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* +▸ **append**(...`s`: (string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›)[]): *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L35)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:58](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L58)* **Parameters:** Name | Type | ------ | ------ | -`...s` | string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›[] | +`...s` | (string | [StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)‹›)[] | **Returns:** *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* @@ -81,7 +81,7 @@ ___ ▸ **indexOf**(`searchString`: string, `position?`: undefined | number): *number* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:14](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L14)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:37](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L37)* **Parameters:** @@ -98,7 +98,7 @@ ___ ▸ **substr**(`s`: number, `l`: number): *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:98](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L98)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:121](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L121)* **Parameters:** @@ -115,7 +115,7 @@ ___ ▸ **substring**(`s`: number, `e?`: undefined | number): *[StringBuffer](_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:43](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L43)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:66](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L66)* **Parameters:** @@ -132,7 +132,7 @@ ___ ▸ **toLowerCase**(): *string* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L18)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L41)* **Returns:** *string* @@ -142,7 +142,7 @@ ___ ▸ **toString**(): *string* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L26)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:49](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L49)* **Returns:** *string* @@ -152,6 +152,6 @@ ___ ▸ **toUpperCase**(): *string* -*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:22](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L22)* +*Defined in [esp32-javascript/modules/esp32-javascript/stringbuffer.ts:45](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/stringbuffer.ts#L45)* **Returns:** *string* diff --git a/docs/classes/_socket_events_modules_socket_events_index_.activesockets.md b/docs/classes/_socket_events_modules_socket_events_index_.activesockets.md new file mode 100644 index 0000000..2de97d8 --- /dev/null +++ b/docs/classes/_socket_events_modules_socket_events_index_.activesockets.md @@ -0,0 +1,123 @@ +[esp32-javascript](../README.md) › ["socket-events/modules/socket-events/index"](../modules/_socket_events_modules_socket_events_index_.md) › [ActiveSockets](_socket_events_modules_socket_events_index_.activesockets.md) + +# Class: ActiveSockets + +## Hierarchy + +* **ActiveSockets** + +## Index + +### Properties + +* [activeSockets](_socket_events_modules_socket_events_index_.activesockets.md#private-activesockets) +* [sst_connectedSockets](_socket_events_modules_socket_events_index_.activesockets.md#sst_connectedsockets) +* [sst_connectedWritableSockets](_socket_events_modules_socket_events_index_.activesockets.md#sst_connectedwritablesockets) +* [sst_notConnectedSockets](_socket_events_modules_socket_events_index_.activesockets.md#sst_notconnectedsockets) + +### Methods + +* [add](_socket_events_modules_socket_events_index_.activesockets.md#add) +* [get](_socket_events_modules_socket_events_index_.activesockets.md#get) +* [maintainSocketStatus](_socket_events_modules_socket_events_index_.activesockets.md#maintainsocketstatus) +* [remove](_socket_events_modules_socket_events_index_.activesockets.md#remove) + +## Properties + +### `Private` activeSockets + +• **activeSockets**: *[SocketLookupMap](_socket_events_modules_socket_events_index_.socketlookupmap.md)‹›* = new SocketLookupMap() + +*Defined in [socket-events/modules/socket-events/index.ts:86](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L86)* + +___ + +### sst_connectedSockets + +• **sst_connectedSockets**: *[NumberSet](_socket_events_modules_socket_events_index_.numberset.md)‹›* = new NumberSet() + +*Defined in [socket-events/modules/socket-events/index.ts:90](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L90)* + +___ + +### sst_connectedWritableSockets + +• **sst_connectedWritableSockets**: *[NumberSet](_socket_events_modules_socket_events_index_.numberset.md)‹›* = new NumberSet() + +*Defined in [socket-events/modules/socket-events/index.ts:91](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L91)* + +___ + +### sst_notConnectedSockets + +• **sst_notConnectedSockets**: *[NumberSet](_socket_events_modules_socket_events_index_.numberset.md)‹›* = new NumberSet() + +*Defined in [socket-events/modules/socket-events/index.ts:89](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L89)* + +## Methods + +### add + +▸ **add**(`item`: [Socket](_socket_events_modules_socket_events_index_.socket.md)): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:133](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L133)* + +**Parameters:** + +Name | Type | +------ | ------ | +`item` | [Socket](_socket_events_modules_socket_events_index_.socket.md) | + +**Returns:** *void* + +___ + +### get + +▸ **get**(`sockfd`: number): *[Socket](_socket_events_modules_socket_events_index_.socket.md) | undefined* + +*Defined in [socket-events/modules/socket-events/index.ts:152](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L152)* + +**Parameters:** + +Name | Type | +------ | ------ | +`sockfd` | number | + +**Returns:** *[Socket](_socket_events_modules_socket_events_index_.socket.md) | undefined* + +___ + +### maintainSocketStatus + +▸ **maintainSocketStatus**(`sockfd`: number, `isListening`: boolean, `isConnected`: boolean, `isError`: boolean, `onWritable`: [OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:93](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L93)* + +**Parameters:** + +Name | Type | +------ | ------ | +`sockfd` | number | +`isListening` | boolean | +`isConnected` | boolean | +`isError` | boolean | +`onWritable` | [OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null | + +**Returns:** *void* + +___ + +### remove + +▸ **remove**(`sockfd`: number): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:144](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L144)* + +**Parameters:** + +Name | Type | +------ | ------ | +`sockfd` | number | + +**Returns:** *void* diff --git a/docs/classes/_socket_events_modules_socket_events_index_.numberset.md b/docs/classes/_socket_events_modules_socket_events_index_.numberset.md new file mode 100644 index 0000000..8f5accf --- /dev/null +++ b/docs/classes/_socket_events_modules_socket_events_index_.numberset.md @@ -0,0 +1,58 @@ +[esp32-javascript](../README.md) › ["socket-events/modules/socket-events/index"](../modules/_socket_events_modules_socket_events_index_.md) › [NumberSet](_socket_events_modules_socket_events_index_.numberset.md) + +# Class: NumberSet + +## Hierarchy + +* **NumberSet** + +## Index + +### Properties + +* [set](_socket_events_modules_socket_events_index_.numberset.md#set) + +### Methods + +* [add](_socket_events_modules_socket_events_index_.numberset.md#add) +* [remove](_socket_events_modules_socket_events_index_.numberset.md#remove) + +## Properties + +### set + +• **set**: *number[]* = [] + +*Defined in [socket-events/modules/socket-events/index.ts:58](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L58)* + +## Methods + +### add + +▸ **add**(`n`: number): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:59](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L59)* + +**Parameters:** + +Name | Type | +------ | ------ | +`n` | number | + +**Returns:** *void* + +___ + +### remove + +▸ **remove**(`n`: number): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:64](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L64)* + +**Parameters:** + +Name | Type | +------ | ------ | +`n` | number | + +**Returns:** *void* diff --git a/docs/classes/_socket_events_modules_socket_events_index_.socket.md b/docs/classes/_socket_events_modules_socket_events_index_.socket.md index b0d213e..6932a0d 100644 --- a/docs/classes/_socket_events_modules_socket_events_index_.socket.md +++ b/docs/classes/_socket_events_modules_socket_events_index_.socket.md @@ -14,19 +14,19 @@ ### Properties +* [_isConnected](_socket_events_modules_socket_events_index_.socket.md#private-_isconnected) +* [_isError](_socket_events_modules_socket_events_index_.socket.md#_iserror) +* [_isListening](_socket_events_modules_socket_events_index_.socket.md#private-_islistening) +* [_onWritable](_socket_events_modules_socket_events_index_.socket.md#private-_onwritable) * [dataBuffer](_socket_events_modules_socket_events_index_.socket.md#private-databuffer) * [dataBufferSize](_socket_events_modules_socket_events_index_.socket.md#private-databuffersize) * [defaultBufferSize](_socket_events_modules_socket_events_index_.socket.md#private-defaultbuffersize) * [flushAlways](_socket_events_modules_socket_events_index_.socket.md#flushalways) -* [isConnected](_socket_events_modules_socket_events_index_.socket.md#isconnected) -* [isError](_socket_events_modules_socket_events_index_.socket.md#iserror) -* [isListening](_socket_events_modules_socket_events_index_.socket.md#islistening) * [onAccept](_socket_events_modules_socket_events_index_.socket.md#onaccept) * [onClose](_socket_events_modules_socket_events_index_.socket.md#onclose) * [onConnect](_socket_events_modules_socket_events_index_.socket.md#onconnect) * [onData](_socket_events_modules_socket_events_index_.socket.md#ondata) * [onError](_socket_events_modules_socket_events_index_.socket.md#onerror) -* [onWritable](_socket_events_modules_socket_events_index_.socket.md#onwritable) * [readTimeout](_socket_events_modules_socket_events_index_.socket.md#private-readtimeout) * [readTimeoutHandle](_socket_events_modules_socket_events_index_.socket.md#private-readtimeouthandle) * [sockfd](_socket_events_modules_socket_events_index_.socket.md#sockfd) @@ -34,69 +34,85 @@ * [textEncoder](_socket_events_modules_socket_events_index_.socket.md#private-textencoder) * [writebuffer](_socket_events_modules_socket_events_index_.socket.md#writebuffer) +### Accessors + +* [isConnected](_socket_events_modules_socket_events_index_.socket.md#isconnected) +* [isError](_socket_events_modules_socket_events_index_.socket.md#iserror) +* [isListening](_socket_events_modules_socket_events_index_.socket.md#islistening) +* [onWritable](_socket_events_modules_socket_events_index_.socket.md#onwritable) + ### Methods * [clearReadTimeoutTimer](_socket_events_modules_socket_events_index_.socket.md#clearreadtimeouttimer) * [extendReadTimeout](_socket_events_modules_socket_events_index_.socket.md#extendreadtimeout) * [flush](_socket_events_modules_socket_events_index_.socket.md#flush) +* [maintainSocketStatus](_socket_events_modules_socket_events_index_.socket.md#private-maintainsocketstatus) * [setReadTimeout](_socket_events_modules_socket_events_index_.socket.md#setreadtimeout) * [write](_socket_events_modules_socket_events_index_.socket.md#write) ## Properties -### `Private` dataBuffer +### `Private` _isConnected -• **dataBuffer**: *Uint8Array‹›* = new Uint8Array(this.defaultBufferSize) +• **_isConnected**: *boolean* = false -*Defined in [socket-events/modules/socket-events/index.ts:95](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L95)* +*Defined in [socket-events/modules/socket-events/index.ts:213](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L213)* ___ -### `Private` dataBufferSize +### _isError -• **dataBufferSize**: *number* = 0 +• **_isError**: *boolean* = false -*Defined in [socket-events/modules/socket-events/index.ts:96](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L96)* +*Defined in [socket-events/modules/socket-events/index.ts:214](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L214)* ___ -### `Private` defaultBufferSize +### `Private` _isListening -• **defaultBufferSize**: *number* = 3 * 1024 +• **_isListening**: *boolean* = false -*Defined in [socket-events/modules/socket-events/index.ts:94](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L94)* +*Defined in [socket-events/modules/socket-events/index.ts:215](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L215)* ___ -### flushAlways +### `Private` _onWritable -• **flushAlways**: *boolean* = true +• **_onWritable**: *[OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null* = null -*Defined in [socket-events/modules/socket-events/index.ts:143](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L143)* +*Defined in [socket-events/modules/socket-events/index.ts:212](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L212)* ___ -### isConnected +### `Private` dataBuffer -• **isConnected**: *boolean* = false +• **dataBuffer**: *Uint8Array‹›* = new Uint8Array(this.defaultBufferSize) -*Defined in [socket-events/modules/socket-events/index.ts:139](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L139)* +*Defined in [socket-events/modules/socket-events/index.ts:169](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L169)* ___ -### isError +### `Private` dataBufferSize -• **isError**: *boolean* = false +• **dataBufferSize**: *number* = 0 -*Defined in [socket-events/modules/socket-events/index.ts:140](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L140)* +*Defined in [socket-events/modules/socket-events/index.ts:170](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L170)* ___ -### isListening +### `Private` defaultBufferSize + +• **defaultBufferSize**: *number* = 3 * 1024 -• **isListening**: *boolean* = false +*Defined in [socket-events/modules/socket-events/index.ts:168](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L168)* -*Defined in [socket-events/modules/socket-events/index.ts:141](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L141)* +___ + +### flushAlways + +• **flushAlways**: *boolean* = true + +*Defined in [socket-events/modules/socket-events/index.ts:217](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L217)* ___ @@ -106,7 +122,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onAccept](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#onaccept)* -*Defined in [socket-events/modules/socket-events/index.ts:133](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L133)* +*Defined in [socket-events/modules/socket-events/index.ts:207](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L207)* The onData callback. @@ -118,7 +134,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onClose](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#onclose)* -*Defined in [socket-events/modules/socket-events/index.ts:137](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L137)* +*Defined in [socket-events/modules/socket-events/index.ts:211](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L211)* ___ @@ -128,7 +144,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onConnect](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#onconnect)* -*Defined in [socket-events/modules/socket-events/index.ts:135](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L135)* +*Defined in [socket-events/modules/socket-events/index.ts:209](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L209)* ___ @@ -138,7 +154,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onData](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#ondata)* -*Defined in [socket-events/modules/socket-events/index.ts:134](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L134)* +*Defined in [socket-events/modules/socket-events/index.ts:208](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L208)* ___ @@ -148,17 +164,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onError](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#onerror)* -*Defined in [socket-events/modules/socket-events/index.ts:136](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L136)* - -___ - -### onWritable - -• **onWritable**: *[OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null* = null - -*Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[onWritable](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#onwritable)* - -*Defined in [socket-events/modules/socket-events/index.ts:138](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L138)* +*Defined in [socket-events/modules/socket-events/index.ts:210](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L210)* ___ @@ -166,7 +172,7 @@ ___ • **readTimeout**: *number* = -1 -*Defined in [socket-events/modules/socket-events/index.ts:99](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L99)* +*Defined in [socket-events/modules/socket-events/index.ts:173](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L173)* ___ @@ -174,7 +180,7 @@ ___ • **readTimeoutHandle**: *number* = -1 -*Defined in [socket-events/modules/socket-events/index.ts:100](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L100)* +*Defined in [socket-events/modules/socket-events/index.ts:174](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L174)* ___ @@ -184,7 +190,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[sockfd](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#sockfd)* -*Defined in [socket-events/modules/socket-events/index.ts:127](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L127)* +*Defined in [socket-events/modules/socket-events/index.ts:201](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L201)* The socket file descriptor. @@ -196,7 +202,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[ssl](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#ssl)* -*Defined in [socket-events/modules/socket-events/index.ts:142](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L142)* +*Defined in [socket-events/modules/socket-events/index.ts:216](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L216)* ___ @@ -204,7 +210,7 @@ ___ • **textEncoder**: *TextEncoder* = new TextEncoder() -*Defined in [socket-events/modules/socket-events/index.ts:97](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L97)* +*Defined in [socket-events/modules/socket-events/index.ts:171](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L171)* ___ @@ -214,7 +220,95 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md).[writebuffer](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md#writebuffer)* -*Defined in [socket-events/modules/socket-events/index.ts:98](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L98)* +*Defined in [socket-events/modules/socket-events/index.ts:172](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L172)* + +## Accessors + +### isConnected + +• **get isConnected**(): *boolean* + +*Defined in [socket-events/modules/socket-events/index.ts:234](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L234)* + +**Returns:** *boolean* + +• **set isConnected**(`isConnected`: boolean): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:229](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L229)* + +**Parameters:** + +Name | Type | +------ | ------ | +`isConnected` | boolean | + +**Returns:** *void* + +___ + +### isError + +• **get isError**(): *boolean* + +*Defined in [socket-events/modules/socket-events/index.ts:261](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L261)* + +**Returns:** *boolean* + +• **set isError**(`isError`: boolean): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:256](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L256)* + +**Parameters:** + +Name | Type | +------ | ------ | +`isError` | boolean | + +**Returns:** *void* + +___ + +### isListening + +• **get isListening**(): *boolean* + +*Defined in [socket-events/modules/socket-events/index.ts:243](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L243)* + +**Returns:** *boolean* + +• **set isListening**(`isListening`: boolean): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:238](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L238)* + +**Parameters:** + +Name | Type | +------ | ------ | +`isListening` | boolean | + +**Returns:** *void* + +___ + +### onWritable + +• **get onWritable**(): *null | function* + +*Defined in [socket-events/modules/socket-events/index.ts:252](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L252)* + +**Returns:** *null | function* + +• **set onWritable**(`onWritable`: [OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:247](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L247)* + +**Parameters:** + +Name | Type | +------ | ------ | +`onWritable` | [OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null | + +**Returns:** *void* ## Methods @@ -222,7 +316,7 @@ ___ ▸ **clearReadTimeoutTimer**(): *void* -*Defined in [socket-events/modules/socket-events/index.ts:107](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L107)* +*Defined in [socket-events/modules/socket-events/index.ts:181](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L181)* **Returns:** *void* @@ -232,7 +326,7 @@ ___ ▸ **extendReadTimeout**(): *void* -*Defined in [socket-events/modules/socket-events/index.ts:113](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L113)* +*Defined in [socket-events/modules/socket-events/index.ts:187](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L187)* **Returns:** *void* @@ -242,7 +336,7 @@ ___ ▸ **flush**(`cb?`: undefined | function): *void* -*Defined in [socket-events/modules/socket-events/index.ts:174](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L174)* +*Defined in [socket-events/modules/socket-events/index.ts:294](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L294)* **Parameters:** @@ -254,13 +348,23 @@ Name | Type | ___ +### `Private` maintainSocketStatus + +▸ **maintainSocketStatus**(): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:219](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L219)* + +**Returns:** *void* + +___ + ### setReadTimeout ▸ **setReadTimeout**(`readTimeout`: number): *void* *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md)* -*Defined in [socket-events/modules/socket-events/index.ts:102](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L102)* +*Defined in [socket-events/modules/socket-events/index.ts:176](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L176)* **Parameters:** @@ -278,7 +382,7 @@ ___ *Implementation of [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md)* -*Defined in [socket-events/modules/socket-events/index.ts:145](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L145)* +*Defined in [socket-events/modules/socket-events/index.ts:265](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L265)* **Parameters:** diff --git a/docs/classes/_socket_events_modules_socket_events_index_.socketlookupmap.md b/docs/classes/_socket_events_modules_socket_events_index_.socketlookupmap.md new file mode 100644 index 0000000..6695278 --- /dev/null +++ b/docs/classes/_socket_events_modules_socket_events_index_.socketlookupmap.md @@ -0,0 +1,79 @@ +[esp32-javascript](../README.md) › ["socket-events/modules/socket-events/index"](../modules/_socket_events_modules_socket_events_index_.md) › [SocketLookupMap](_socket_events_modules_socket_events_index_.socketlookupmap.md) + +# Class: SocketLookupMap + +## Hierarchy + +* **SocketLookupMap** + +## Index + +### Properties + +* [map](_socket_events_modules_socket_events_index_.socketlookupmap.md#map) + +### Methods + +* [add](_socket_events_modules_socket_events_index_.socketlookupmap.md#add) +* [get](_socket_events_modules_socket_events_index_.socketlookupmap.md#get) +* [remove](_socket_events_modules_socket_events_index_.socketlookupmap.md#remove) + +## Properties + +### map + +• **map**: *object* + +*Defined in [socket-events/modules/socket-events/index.ts:73](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L73)* + +#### Type declaration: + +* \[ **key**: *string*\]: [Socket](_socket_events_modules_socket_events_index_.socket.md) + +## Methods + +### add + +▸ **add**(`item`: [Socket](_socket_events_modules_socket_events_index_.socket.md)): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:74](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L74)* + +**Parameters:** + +Name | Type | +------ | ------ | +`item` | [Socket](_socket_events_modules_socket_events_index_.socket.md) | + +**Returns:** *void* + +___ + +### get + +▸ **get**(`sockfd`: number): *[Socket](_socket_events_modules_socket_events_index_.socket.md) | undefined* + +*Defined in [socket-events/modules/socket-events/index.ts:77](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L77)* + +**Parameters:** + +Name | Type | +------ | ------ | +`sockfd` | number | + +**Returns:** *[Socket](_socket_events_modules_socket_events_index_.socket.md) | undefined* + +___ + +### remove + +▸ **remove**(`sockfd`: number): *void* + +*Defined in [socket-events/modules/socket-events/index.ts:80](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L80)* + +**Parameters:** + +Name | Type | +------ | ------ | +`sockfd` | number | + +**Returns:** *void* diff --git a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md index f3f88ef..22b74fa 100644 --- a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md +++ b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md @@ -20,7 +20,7 @@ • **access**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L26)* #### Type declaration: @@ -34,7 +34,7 @@ ___ • **ota**? : *undefined | object* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:11](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L11)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L35)* ___ @@ -42,4 +42,4 @@ ___ • **wifi**? : *undefined | object* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L7)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L30)* diff --git a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsrequest.md b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsrequest.md index 94e74c1..a132800 100644 --- a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsrequest.md +++ b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsrequest.md @@ -21,7 +21,7 @@ • **body**: *string | null* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:8](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L8)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L35)* ___ @@ -29,7 +29,7 @@ ___ • **headers**: *Headers* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:6](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L6)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:33](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L33)* ___ @@ -37,7 +37,7 @@ ___ • **method**: *string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L7)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L34)* ___ @@ -45,4 +45,4 @@ ___ • **path**: *string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:5](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L5)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L32)* diff --git a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md index 38a35fa..a213082 100644 --- a/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md +++ b/docs/interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md @@ -27,7 +27,7 @@ • **end**: *function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:16](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L16)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:43](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L43)* #### Type declaration: @@ -45,7 +45,7 @@ ___ • **flush**: *function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:13](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L13)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L40)* #### Type declaration: @@ -57,7 +57,7 @@ ___ • **headers**: *Headers* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:21](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L21)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:48](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L48)* ___ @@ -65,7 +65,7 @@ ___ • **headersWritten**: *boolean* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:20](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L20)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:47](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L47)* ___ @@ -73,7 +73,7 @@ ___ • **isEnded**: *boolean* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L18)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:45](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L45)* ___ @@ -81,7 +81,7 @@ ___ • **on**: *function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:12](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L12)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:39](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L39)* #### Type declaration: @@ -101,7 +101,7 @@ ___ • **setStatus**: *function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:14](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L14)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L41)* #### Type declaration: @@ -120,7 +120,7 @@ ___ • **status**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:17](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L17)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:44](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L44)* #### Type declaration: @@ -134,7 +134,7 @@ ___ • **statusWritten**: *boolean* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:19](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L19)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:46](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L46)* ___ @@ -142,7 +142,7 @@ ___ • **write**: *function* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:15](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L15)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:42](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L42)* #### Type declaration: diff --git a/docs/interfaces/_esp32_javascript_modules_esp32_js_eventloop_index_.esp32jstimer.md b/docs/interfaces/_esp32_javascript_modules_esp32_js_eventloop_index_.esp32jstimer.md index 7b94c4d..ed01bb3 100644 --- a/docs/interfaces/_esp32_javascript_modules_esp32_js_eventloop_index_.esp32jstimer.md +++ b/docs/interfaces/_esp32_javascript_modules_esp32_js_eventloop_index_.esp32jstimer.md @@ -19,9 +19,13 @@ ### fn -• **fn**: *Function* +• **fn**: *function* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:5](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L5)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L27)* + +#### Type declaration: + +▸ (): *void* ___ @@ -29,7 +33,7 @@ ___ • **handle**: *number* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:2](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L2)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L25)* ___ @@ -37,7 +41,7 @@ ___ • **installed**: *boolean* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:6](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L6)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L28)* ___ @@ -45,4 +49,4 @@ ___ • **timeout**: *number* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L26)* diff --git a/docs/interfaces/_esp32_javascript_urlparse_.anchorelement.md b/docs/interfaces/_esp32_javascript_urlparse_.anchorelement.md index ef7badb..3c02680 100644 --- a/docs/interfaces/_esp32_javascript_urlparse_.anchorelement.md +++ b/docs/interfaces/_esp32_javascript_urlparse_.anchorelement.md @@ -37,7 +37,7 @@ • **_hash**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:19](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L19)* +*Defined in [esp32-javascript/urlparse.ts:42](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L42)* ___ @@ -45,7 +45,7 @@ ___ • **_host**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:15](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L15)* +*Defined in [esp32-javascript/urlparse.ts:38](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L38)* ___ @@ -53,7 +53,7 @@ ___ • **_hostname**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:14](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L14)* +*Defined in [esp32-javascript/urlparse.ts:37](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L37)* ___ @@ -61,7 +61,7 @@ ___ • **_pathname**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:17](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L17)* +*Defined in [esp32-javascript/urlparse.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L40)* ___ @@ -69,7 +69,7 @@ ___ • **_port**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:16](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L16)* +*Defined in [esp32-javascript/urlparse.ts:39](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L39)* ___ @@ -77,7 +77,7 @@ ___ • **_protocol**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:13](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L13)* +*Defined in [esp32-javascript/urlparse.ts:36](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L36)* ___ @@ -85,7 +85,7 @@ ___ • **_search**: *string | undefined* -*Defined in [esp32-javascript/urlparse.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L18)* +*Defined in [esp32-javascript/urlparse.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L41)* ___ @@ -93,7 +93,7 @@ ___ • **hash**: *string* -*Defined in [esp32-javascript/urlparse.ts:5](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L5)* +*Defined in [esp32-javascript/urlparse.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L28)* ___ @@ -101,7 +101,7 @@ ___ • **host**: *string* -*Defined in [esp32-javascript/urlparse.ts:9](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L9)* +*Defined in [esp32-javascript/urlparse.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L32)* ___ @@ -109,7 +109,7 @@ ___ • **hostname**: *string* -*Defined in [esp32-javascript/urlparse.ts:8](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L8)* +*Defined in [esp32-javascript/urlparse.ts:31](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L31)* ___ @@ -117,7 +117,7 @@ ___ • **href**: *string* -*Defined in [esp32-javascript/urlparse.ts:2](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L2)* +*Defined in [esp32-javascript/urlparse.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L25)* ___ @@ -125,7 +125,7 @@ ___ • **origin**: *string* -*Defined in [esp32-javascript/urlparse.ts:6](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L6)* +*Defined in [esp32-javascript/urlparse.ts:29](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L29)* ___ @@ -133,7 +133,7 @@ ___ • **pathname**: *string* -*Defined in [esp32-javascript/urlparse.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L3)* +*Defined in [esp32-javascript/urlparse.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L26)* ___ @@ -141,7 +141,7 @@ ___ • **port**: *string* -*Defined in [esp32-javascript/urlparse.ts:10](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L10)* +*Defined in [esp32-javascript/urlparse.ts:33](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L33)* ___ @@ -149,7 +149,7 @@ ___ • **protocol**: *string* -*Defined in [esp32-javascript/urlparse.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L7)* +*Defined in [esp32-javascript/urlparse.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L30)* ___ @@ -157,7 +157,7 @@ ___ • **search**: *string* -*Defined in [esp32-javascript/urlparse.ts:4](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L4)* +*Defined in [esp32-javascript/urlparse.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L27)* ## Methods @@ -165,7 +165,7 @@ ___ ▸ **resolve**(`rel`: string): *[AnchorElement](_esp32_javascript_urlparse_.anchorelement.md)* -*Defined in [esp32-javascript/urlparse.ts:11](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L11)* +*Defined in [esp32-javascript/urlparse.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L34)* **Parameters:** diff --git a/docs/interfaces/_socket_events_modules_socket_events_index_.bufferentry.md b/docs/interfaces/_socket_events_modules_socket_events_index_.bufferentry.md index 793b5c4..0e9be3e 100644 --- a/docs/interfaces/_socket_events_modules_socket_events_index_.bufferentry.md +++ b/docs/interfaces/_socket_events_modules_socket_events_index_.bufferentry.md @@ -21,7 +21,7 @@ • **cb**? : *undefined | function* -*Defined in [socket-events/modules/socket-events/index.ts:88](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L88)* +*Defined in [socket-events/modules/socket-events/index.ts:162](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L162)* ___ @@ -29,7 +29,7 @@ ___ • **data**: *Uint8Array* -*Defined in [socket-events/modules/socket-events/index.ts:86](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L86)* +*Defined in [socket-events/modules/socket-events/index.ts:160](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L160)* ___ @@ -37,7 +37,7 @@ ___ • **len**: *number* -*Defined in [socket-events/modules/socket-events/index.ts:87](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L87)* +*Defined in [socket-events/modules/socket-events/index.ts:161](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L161)* ___ @@ -45,4 +45,4 @@ ___ • **written**: *number* -*Defined in [socket-events/modules/socket-events/index.ts:85](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L85)* +*Defined in [socket-events/modules/socket-events/index.ts:159](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L159)* diff --git a/docs/interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md b/docs/interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md index add210d..9970f60 100644 --- a/docs/interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md +++ b/docs/interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md @@ -36,7 +36,7 @@ • **onAccept**: *[OnAcceptCB](../modules/_socket_events_modules_socket_events_index_.md#onacceptcb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:15](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L15)* +*Defined in [socket-events/modules/socket-events/index.ts:42](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L42)* ___ @@ -44,7 +44,7 @@ ___ • **onClose**: *[OnCloseCB](../modules/_socket_events_modules_socket_events_index_.md#onclosecb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:22](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L22)* +*Defined in [socket-events/modules/socket-events/index.ts:49](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L49)* ___ @@ -52,7 +52,7 @@ ___ • **onConnect**: *[OnConnectCB](../modules/_socket_events_modules_socket_events_index_.md#onconnectcb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:17](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L17)* +*Defined in [socket-events/modules/socket-events/index.ts:44](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L44)* ___ @@ -60,7 +60,7 @@ ___ • **onData**: *[OnDataCB](../modules/_socket_events_modules_socket_events_index_.md#ondatacb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:16](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L16)* +*Defined in [socket-events/modules/socket-events/index.ts:43](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L43)* ___ @@ -68,7 +68,7 @@ ___ • **onError**: *[OnErrorCB](../modules/_socket_events_modules_socket_events_index_.md#onerrorcb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L18)* +*Defined in [socket-events/modules/socket-events/index.ts:45](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L45)* ___ @@ -76,7 +76,7 @@ ___ • **onWritable**: *[OnWritableCB](../modules/_socket_events_modules_socket_events_index_.md#onwritablecb) | null* -*Defined in [socket-events/modules/socket-events/index.ts:19](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L19)* +*Defined in [socket-events/modules/socket-events/index.ts:46](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L46)* ___ @@ -84,7 +84,7 @@ ___ • **sockfd**: *number* -*Defined in [socket-events/modules/socket-events/index.ts:14](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L14)* +*Defined in [socket-events/modules/socket-events/index.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L41)* ___ @@ -92,7 +92,7 @@ ___ • **ssl**: *any* -*Defined in [socket-events/modules/socket-events/index.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L24)* +*Defined in [socket-events/modules/socket-events/index.ts:51](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L51)* ___ @@ -100,7 +100,7 @@ ___ • **writebuffer**: *[BufferEntry](_socket_events_modules_socket_events_index_.bufferentry.md)[]* -*Defined in [socket-events/modules/socket-events/index.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L25)* +*Defined in [socket-events/modules/socket-events/index.ts:52](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L52)* ## Methods @@ -108,7 +108,7 @@ ___ ▸ **flush**(`cb?`: undefined | function): *void* -*Defined in [socket-events/modules/socket-events/index.ts:20](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L20)* +*Defined in [socket-events/modules/socket-events/index.ts:47](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L47)* **Parameters:** @@ -124,7 +124,7 @@ ___ ▸ **setReadTimeout**(`readTimeout`: number): *void* -*Defined in [socket-events/modules/socket-events/index.ts:23](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L23)* +*Defined in [socket-events/modules/socket-events/index.ts:50](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L50)* **Parameters:** @@ -140,7 +140,7 @@ ___ ▸ **write**(`data`: string | Uint8Array): *void* -*Defined in [socket-events/modules/socket-events/index.ts:21](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L21)* +*Defined in [socket-events/modules/socket-events/index.ts:48](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L48)* **Parameters:** diff --git a/docs/interfaces/_socket_events_modules_socket_events_index_.socketarrayfind.md b/docs/interfaces/_socket_events_modules_socket_events_index_.socketarrayfind.md deleted file mode 100644 index e83d610..0000000 --- a/docs/interfaces/_socket_events_modules_socket_events_index_.socketarrayfind.md +++ /dev/null @@ -1,37 +0,0 @@ -[esp32-javascript](../README.md) › ["socket-events/modules/socket-events/index"](../modules/_socket_events_modules_socket_events_index_.md) › [SocketArrayFind](_socket_events_modules_socket_events_index_.socketarrayfind.md) - -# Interface: SocketArrayFind - -An array which holds all active sockets. - -## Hierarchy - -* **SocketArrayFind** - -## Index - -### Methods - -* [find](_socket_events_modules_socket_events_index_.socketarrayfind.md#find) - -## Methods - -### find - -▸ **find**(`predicate`: function): *[Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)* - -*Defined in [socket-events/modules/socket-events/index.ts:68](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L68)* - -**Parameters:** - -▪ **predicate**: *function* - -▸ (`socket`: [Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)): *boolean* - -**Parameters:** - -Name | Type | ------- | ------ | -`socket` | [Socket](../classes/_socket_events_modules_socket_events_index_.socket.md) | - -**Returns:** *[Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)* diff --git a/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md b/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md index eb3770c..fdd858f 100644 --- a/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md +++ b/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md @@ -19,7 +19,7 @@ • **ip**: *string | undefined* -*Defined in [wifi-events/modules/wifi-events/index.ts:12](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L12)* +*Defined in [wifi-events/modules/wifi-events/index.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L35)* ___ @@ -27,7 +27,7 @@ ___ • **status**: *function* -*Defined in [wifi-events/modules/wifi-events/index.ts:11](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L11)* +*Defined in [wifi-events/modules/wifi-events/index.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L34)* #### Type declaration: diff --git a/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifievent.md b/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifievent.md index f7ca78f..1cf3432 100644 --- a/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifievent.md +++ b/docs/interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifievent.md @@ -20,4 +20,4 @@ • **status**: *number* -*Defined in [wifi-events/modules/wifi-events/index.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L7)* +*Defined in [wifi-events/modules/wifi-events/index.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L30)* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_boot_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_boot_.md index 04c689f..6268982 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_boot_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_boot_.md @@ -30,7 +30,7 @@ • **bootTime**: *Date* = new Date() -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L30)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:53](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L53)* ___ @@ -38,7 +38,7 @@ ___ • **configServer**: *["esp32-javascript/modules/esp32-javascript/configserver"](_esp32_javascript_modules_esp32_javascript_configserver_.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:2](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L2)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L25)* ___ @@ -46,7 +46,7 @@ ___ • **configServerStarted**: *boolean* = false -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:17](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L17)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L40)* ___ @@ -54,7 +54,7 @@ ___ • **programLoaded**: *boolean* = false -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L18)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L41)* ___ @@ -62,7 +62,7 @@ ___ • **wifi**: *["wifi-events/modules/wifi-events/index"](_wifi_events_modules_wifi_events_index_.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:1](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L1)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L24)* ## Functions @@ -70,7 +70,7 @@ ___ ▸ **blink**(): *undefined | number* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:20](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L20)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:43](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L43)* **Returns:** *undefined | number* @@ -80,7 +80,7 @@ ___ ▸ **connectToWifi**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:115](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L115)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:138](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L138)* **Returns:** *void* @@ -90,7 +90,7 @@ ___ ▸ **evalScript**(`content`: string, `headers?`: Headers): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:98](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L98)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:121](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L121)* **Parameters:** @@ -107,7 +107,7 @@ ___ ▸ **getBootTime**(): *Date* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:36](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L36)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:59](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L59)* **Returns:** *Date* @@ -117,7 +117,7 @@ ___ ▸ **loadOfflineScript**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:106](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L106)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:129](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L129)* **Returns:** *void* @@ -127,7 +127,7 @@ ___ ▸ **main**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:199](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L199)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:229](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L229)* **Returns:** *void* @@ -137,7 +137,7 @@ ___ ▸ **parseDate**(`d`: string): *Date* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:69](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L69)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:92](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L92)* **Parameters:** @@ -153,7 +153,7 @@ ___ ▸ **setBootTime**(`date`: Date): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L32)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:55](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L55)* **Parameters:** @@ -169,6 +169,6 @@ ___ ▸ **startSoftApMode**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/boot.ts#L40)* +*Defined in [esp32-javascript/modules/esp32-javascript/boot.ts:63](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/boot.ts#L63)* **Returns:** *void* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_chunked_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_chunked_.md new file mode 100644 index 0000000..b3fa625 --- /dev/null +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_chunked_.md @@ -0,0 +1,113 @@ +[esp32-javascript](../README.md) › ["esp32-javascript/modules/esp32-javascript/chunked"](_esp32_javascript_modules_esp32_javascript_chunked_.md) + +# Module: "esp32-javascript/modules/esp32-javascript/chunked" + +## Index + +### Type aliases + +* [ChunkedEncodingConsumer](_esp32_javascript_modules_esp32_javascript_chunked_.md#chunkedencodingconsumer) + +### Variables + +* [FINISHED](_esp32_javascript_modules_esp32_javascript_chunked_.md#const-finished) +* [READ_CR](_esp32_javascript_modules_esp32_javascript_chunked_.md#const-read_cr) +* [READ_LEN](_esp32_javascript_modules_esp32_javascript_chunked_.md#const-read_len) +* [READ_LF](_esp32_javascript_modules_esp32_javascript_chunked_.md#const-read_lf) +* [READ_PAYL](_esp32_javascript_modules_esp32_javascript_chunked_.md#const-read_payl) + +### Functions + +* [assertTransferChunked](_esp32_javascript_modules_esp32_javascript_chunked_.md#asserttransferchunked) +* [createChunkedEncodingConsumer](_esp32_javascript_modules_esp32_javascript_chunked_.md#createchunkedencodingconsumer) + +## Type aliases + +### ChunkedEncodingConsumer + +Ƭ **ChunkedEncodingConsumer**: *function* + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:36](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L36)* + +#### Type declaration: + +▸ (`data`: Uint8Array): *boolean* + +**Parameters:** + +Name | Type | +------ | ------ | +`data` | Uint8Array | + +## Variables + +### `Const` FINISHED + +• **FINISHED**: *4* = 4 + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L28)* + +___ + +### `Const` READ_CR + +• **READ_CR**: *0* = 0 + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L24)* + +___ + +### `Const` READ_LEN + +• **READ_LEN**: *2* = 2 + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L26)* + +___ + +### `Const` READ_LF + +• **READ_LF**: *1* = 1 + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L25)* + +___ + +### `Const` READ_PAYL + +• **READ_PAYL**: *3* = 3 + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L27)* + +## Functions + +### assertTransferChunked + +▸ **assertTransferChunked**(`test`: boolean, `message`: string): *void* + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L30)* + +**Parameters:** + +Name | Type | +------ | ------ | +`test` | boolean | +`message` | string | + +**Returns:** *void* + +___ + +### createChunkedEncodingConsumer + +▸ **createChunkedEncodingConsumer**(`onData?`: undefined | function): *[ChunkedEncodingConsumer](_esp32_javascript_modules_esp32_javascript_chunked_.md#chunkedencodingconsumer)* + +*Defined in [esp32-javascript/modules/esp32-javascript/chunked.ts:38](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/chunked.ts#L38)* + +**Parameters:** + +Name | Type | +------ | ------ | +`onData?` | undefined | function | + +**Returns:** *[ChunkedEncodingConsumer](_esp32_javascript_modules_esp32_javascript_chunked_.md#chunkedencodingconsumer)* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_config_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_config_.md index 1aa0032..68e9556 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_config_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_config_.md @@ -24,7 +24,7 @@ • **CONFIG_PATH**: *"/data/config.js"* = "/data/config.js" -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:18](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L18)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:42](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L42)* ___ @@ -32,7 +32,7 @@ ___ • **config**: *[Esp32JsConfig](../interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:20](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L20)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:44](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L44)* ## Functions @@ -40,7 +40,7 @@ ___ ▸ **reloadConfig**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:22](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L22)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:46](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L46)* **Returns:** *void* @@ -50,7 +50,7 @@ ___ ▸ **saveConfig**(`config`: [Esp32JsConfig](../interfaces/_esp32_javascript_modules_esp32_javascript_config_.esp32jsconfig.md)): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:33](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/config.ts#L33)* +*Defined in [esp32-javascript/modules/esp32-javascript/config.ts:57](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/config.ts#L57)* **Parameters:** diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_configserver_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_configserver_.md index 3c15da5..9caa8de 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_configserver_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_configserver_.md @@ -8,11 +8,14 @@ * [baExceptionPathes](_esp32_javascript_modules_esp32_javascript_configserver_.md#const-baexceptionpathes) * [configManager](_esp32_javascript_modules_esp32_javascript_configserver_.md#configmanager) +* [errorMessage](_esp32_javascript_modules_esp32_javascript_configserver_.md#let-errormessage) * [requestHandler](_esp32_javascript_modules_esp32_javascript_configserver_.md#const-requesthandler) +* [successMessage](_esp32_javascript_modules_esp32_javascript_configserver_.md#let-successmessage) ### Functions * [addSchema](_esp32_javascript_modules_esp32_javascript_configserver_.md#addschema) +* [getLogFileList](_esp32_javascript_modules_esp32_javascript_configserver_.md#getlogfilelist) * [page](_esp32_javascript_modules_esp32_javascript_configserver_.md#page) * [redirect](_esp32_javascript_modules_esp32_javascript_configserver_.md#redirect) * [startConfigServer](_esp32_javascript_modules_esp32_javascript_configserver_.md#startconfigserver) @@ -20,6 +23,7 @@ ### Object literals * [schema](_esp32_javascript_modules_esp32_javascript_configserver_.md#let-schema) +* [upgradeStatus](_esp32_javascript_modules_esp32_javascript_configserver_.md#const-upgradestatus) ## Variables @@ -27,7 +31,7 @@ • **baExceptionPathes**: *string[]* = [] -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:87](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L87)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:120](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L120)* ___ @@ -35,7 +39,15 @@ ___ • **configManager**: *["esp32-javascript/modules/esp32-javascript/config"](_esp32_javascript_modules_esp32_javascript_config_.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:1](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L1)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L24)* + +___ + +### `Let` errorMessage + +• **errorMessage**: *string* = "" + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:239](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L239)* ___ @@ -43,7 +55,15 @@ ___ • **requestHandler**: *function[]* = [] -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:83](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L83)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:116](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L116)* + +___ + +### `Let` successMessage + +• **successMessage**: *string* = "" + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:238](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L238)* ## Functions @@ -51,7 +71,7 @@ ___ ▸ **addSchema**(`additional`: any): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:79](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L79)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:112](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L112)* **Parameters:** @@ -63,11 +83,21 @@ Name | Type | ___ +### getLogFileList + +▸ **getLogFileList**(): *object[]* + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:209](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L209)* + +**Returns:** *object[]* + +___ + ### page -▸ **page**(`res`: [Esp32JsResponse](../interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md), `headline`: string, `text`: string | string[], `cb?`: undefined | function): *void* +▸ **page**(`res`: [Esp32JsResponse](../interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md), `headline`: string, `text`: string | string[], `cb?`: undefined | function, `additionalHeadTags?`: undefined | string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:96](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L96)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:129](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L129)* **Parameters:** @@ -77,6 +107,7 @@ Name | Type | `headline` | string | `text` | string | string[] | `cb?` | undefined | function | +`additionalHeadTags?` | undefined | string | **Returns:** *void* @@ -86,7 +117,7 @@ ___ ▸ **redirect**(`res`: [Esp32JsResponse](../interfaces/_esp32_javascript_modules_esp32_javascript_http_.esp32jsresponse.md), `location`: string): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:89](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L89)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:122](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L122)* **Parameters:** @@ -103,7 +134,7 @@ ___ ▸ **startConfigServer**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:155](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L155)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:240](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L240)* **Returns:** *void* @@ -113,11 +144,11 @@ ___ ### ▪ **schema**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:11](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L11)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L40)* ▪ **access**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:12](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L12)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L41)* * **additionalProperties**: *boolean* = false @@ -149,7 +180,7 @@ ___ ▪ **ota**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:52](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L52)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:85](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L85)* * **additionalProperties**: *boolean* = false @@ -189,7 +220,7 @@ ___ ▪ **wifi**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L32)* +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:61](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L61)* * **additionalProperties**: *boolean* = false @@ -207,6 +238,12 @@ ___ * **properties**: *object* + * **bssid**: *object* + + * **title**: *string* = "BSSID" + + * **type**: *string* = "string" + * **password**: *object* * **title**: *string* = "Password" @@ -218,3 +255,23 @@ ___ * **title**: *string* = "SSID" * **type**: *string* = "string" + +___ + +### `Const` upgradeStatus + +### ▪ **upgradeStatus**: *object* + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:230](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L230)* + +### message + +• **message**: *string* = "" + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:235](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L235)* + +### status + +• **status**: *"idle"* = "idle" + +*Defined in [esp32-javascript/modules/esp32-javascript/configserver.ts:234](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/configserver.ts#L234)* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_filelogging_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_filelogging_.md new file mode 100644 index 0000000..ac556dc --- /dev/null +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_filelogging_.md @@ -0,0 +1,87 @@ +[esp32-javascript](../README.md) › ["esp32-javascript/modules/esp32-javascript/filelogging"](_esp32_javascript_modules_esp32_javascript_filelogging_.md) + +# Module: "esp32-javascript/modules/esp32-javascript/filelogging" + +## Index + +### Variables + +* [FILE_LOGGING_DIRECTORY](_esp32_javascript_modules_esp32_javascript_filelogging_.md#const-file_logging_directory) +* [LOG_FILE_NUM_LIMIT](_esp32_javascript_modules_esp32_javascript_filelogging_.md#const-log_file_num_limit) +* [LOG_FILE_SIZE_LIMIT](_esp32_javascript_modules_esp32_javascript_filelogging_.md#const-log_file_size_limit) +* [NUMBER_PREFIX](_esp32_javascript_modules_esp32_javascript_filelogging_.md#const-number_prefix) +* [TDIWEF](_esp32_javascript_modules_esp32_javascript_filelogging_.md#const-tdiwef) +* [logFileNumber](_esp32_javascript_modules_esp32_javascript_filelogging_.md#let-logfilenumber) + +### Functions + +* [cleanupOldLogs](_esp32_javascript_modules_esp32_javascript_filelogging_.md#cleanupoldlogs) +* [getLogFileNumber](_esp32_javascript_modules_esp32_javascript_filelogging_.md#getlogfilenumber) + +## Variables + +### `Const` FILE_LOGGING_DIRECTORY + +• **FILE_LOGGING_DIRECTORY**: *"/data/logs"* = "/data/logs" + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L26)* + +___ + +### `Const` LOG_FILE_NUM_LIMIT + +• **LOG_FILE_NUM_LIMIT**: *8* = 8 + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L28)* + +___ + +### `Const` LOG_FILE_SIZE_LIMIT + +• **LOG_FILE_SIZE_LIMIT**: *10240* = 10240 + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L27)* + +___ + +### `Const` NUMBER_PREFIX + +• **NUMBER_PREFIX**: *"00000000"* = "00000000" + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:31](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L31)* + +___ + +### `Const` TDIWEF + +• **TDIWEF**: *"TDIWEF"* = "TDIWEF" + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L30)* + +___ + +### `Let` logFileNumber + +• **logFileNumber**: *number* = -1 + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L32)* + +## Functions + +### cleanupOldLogs + +▸ **cleanupOldLogs**(): *void* + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:50](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L50)* + +**Returns:** *void* + +___ + +### getLogFileNumber + +▸ **getLogFileNumber**(): *string* + +*Defined in [esp32-javascript/modules/esp32-javascript/filelogging.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/filelogging.ts#L34)* + +**Returns:** *string* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_firmware_config_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_firmware_config_.md index ca5601a..3010666 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_firmware_config_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_firmware_config_.md @@ -14,11 +14,11 @@ ### ▪ **firmwareConfig**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/firmware-config.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/firmware-config.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts#L26)* ▪ **access**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/firmware-config.ts:4](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts#L4)* +*Defined in [esp32-javascript/modules/esp32-javascript/firmware-config.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/firmware-config.ts#L27)* * **password**: *string* = "esp32" diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_global_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_global_.md index 13f1c81..63a50d9 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_global_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_global_.md @@ -14,4 +14,4 @@ • **global**: *any* -*Defined in [esp32-javascript/modules/esp32-javascript/global.ts:2](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/global.ts#L2)* +*Defined in [esp32-javascript/modules/esp32-javascript/global.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/global.ts#L26)* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_http_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_http_.md index b397d9b..5d5b910 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_http_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_http_.md @@ -24,6 +24,7 @@ ### Functions * [decodeQueryParam](_esp32_javascript_modules_esp32_javascript_http_.md#decodequeryparam) +* [getDefaultPort](_esp32_javascript_modules_esp32_javascript_http_.md#getdefaultport) * [httpClient](_esp32_javascript_modules_esp32_javascript_http_.md#httpclient) * [httpServer](_esp32_javascript_modules_esp32_javascript_http_.md#httpserver) * [parseHeaders](_esp32_javascript_modules_esp32_javascript_http_.md#parseheaders) @@ -35,7 +36,7 @@ • **closeSocket**: *[closeSocket](_socket_events_modules_socket_events_index_.md#closesocket)* = socketEvents.closeSocket -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L26)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:53](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L53)* ___ @@ -43,7 +44,7 @@ ___ • **sockConnect**: *[sockConnect](_socket_events_modules_socket_events_index_.md#sockconnect)* = socketEvents.sockConnect -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L25)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:52](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L52)* ___ @@ -51,7 +52,7 @@ ___ • **sockListen**: *[sockListen](_socket_events_modules_socket_events_index_.md#socklisten)* = socketEvents.sockListen -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L24)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:51](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L51)* ___ @@ -59,7 +60,7 @@ ___ • **socketEvents**: *["socket-events/modules/socket-events/index"](_socket_events_modules_socket_events_index_.md)* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:1](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L1)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L24)* ## Functions @@ -67,7 +68,7 @@ ___ ▸ **decodeQueryParam**(`value`: string): *string* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:355](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L355)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:394](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L394)* **Parameters:** @@ -79,11 +80,30 @@ Name | Type | ___ +### getDefaultPort + +▸ **getDefaultPort**(`url`: object): *number* + +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:549](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L549)* + +**Parameters:** + +▪ **url**: *object* + +Name | Type | +------ | ------ | +`port` | string | +`protocol` | string | + +**Returns:** *number* + +___ + ### httpClient -▸ **httpClient**(`ssl`: boolean, `host`: string, `port`: string, `path`: string, `method`: string, `requestHeaders?`: undefined | string, `body?`: undefined | object, `successCB?`: undefined | function, `errorCB?`: undefined | function, `finishCB?`: undefined | function): *void* +▸ **httpClient**(`ssl`: boolean, `host`: string, `port`: string, `path`: string, `method`: string, `requestHeaders?`: undefined | string, `body?`: undefined | object, `successCB?`: undefined, `errorCB?`: undefined | function, `finishCB?`: undefined | function, `dataCB?`: undefined | function, `headCB?`: undefined | function): *object* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:372](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L372)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:411](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L411)* **Parameters:** @@ -96,11 +116,19 @@ Name | Type | `method` | string | `requestHeaders?` | undefined | string | `body?` | undefined | object | -`successCB?` | undefined | function | +`successCB?` | undefined | `errorCB?` | undefined | function | `finishCB?` | undefined | function | +`dataCB?` | undefined | function | +`headCB?` | undefined | function | -**Returns:** *void* +**Returns:** *object* + +* **cancel**(): *function* + + * (): *void* + +* **cancelled**: *boolean* ___ @@ -108,7 +136,7 @@ ___ ▸ **httpServer**(`port`: string | number, `isSSL`: boolean, `cb`: function): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:63](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L63)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:90](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L90)* **Parameters:** @@ -135,7 +163,7 @@ ___ ▸ **parseHeaders**(`complete`: [StringBuffer](../classes/_esp32_javascript_modules_esp32_javascript_stringbuffer_.stringbuffer.md), `endOfHeaders`: number): *object* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L28)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:55](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L55)* **Parameters:** @@ -156,7 +184,7 @@ ___ ▸ **parseQueryStr**(`query`: string | null): *object* -*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:359](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/http.ts#L359)* +*Defined in [esp32-javascript/modules/esp32-javascript/http.ts:398](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/http.ts#L398)* **Parameters:** diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_index_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_index_.md index 3623e95..a9af03e 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_index_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_index_.md @@ -2,43 +2,4 @@ # Module: "esp32-javascript/modules/esp32-javascript/index" -## Index -### Variables - -* [boot](_esp32_javascript_modules_esp32_javascript_index_.md#boot) -* [configManager](_esp32_javascript_modules_esp32_javascript_index_.md#configmanager) -* [eventloop](_esp32_javascript_modules_esp32_javascript_index_.md#eventloop) -* [http](_esp32_javascript_modules_esp32_javascript_index_.md#http) - -## Variables - -### boot - -• **boot**: *["esp32-javascript/modules/esp32-javascript/boot"](_esp32_javascript_modules_esp32_javascript_boot_.md)* - -*Defined in [esp32-javascript/modules/esp32-javascript/index.ts:5](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/index.ts#L5)* - -___ - -### configManager - -• **configManager**: *["esp32-javascript/modules/esp32-javascript/config"](_esp32_javascript_modules_esp32_javascript_config_.md)* - -*Defined in [esp32-javascript/modules/esp32-javascript/index.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/index.ts#L7)* - -___ - -### eventloop - -• **eventloop**: *["esp32-javascript/modules/esp32-js-eventloop/index"](_esp32_javascript_modules_esp32_js_eventloop_index_.md)* - -*Defined in [esp32-javascript/modules/esp32-javascript/index.ts:6](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/index.ts#L6)* - -___ - -### http - -• **http**: *["esp32-javascript/modules/esp32-javascript/http"](_esp32_javascript_modules_esp32_javascript_http_.md)* - -*Defined in [esp32-javascript/modules/esp32-javascript/index.ts:4](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/index.ts#L4)* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_native_ota_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_native_ota_.md new file mode 100644 index 0000000..839c157 --- /dev/null +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_native_ota_.md @@ -0,0 +1,162 @@ +[esp32-javascript](../README.md) › ["esp32-javascript/modules/esp32-javascript/native-ota"](_esp32_javascript_modules_esp32_javascript_native_ota_.md) + +# Module: "esp32-javascript/modules/esp32-javascript/native-ota" + +## Index + +### Type aliases + +* [SubmitErrorFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submiterrorfunction) +* [SubmitFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submitfunction) + +### Variables + +* [http](_esp32_javascript_modules_esp32_javascript_native_ota_.md#http) + +### Functions + +* [assertStatusCode](_esp32_javascript_modules_esp32_javascript_native_ota_.md#assertstatuscode) +* [upgrade](_esp32_javascript_modules_esp32_javascript_native_ota_.md#const-upgrade) +* [upgradeApp](_esp32_javascript_modules_esp32_javascript_native_ota_.md#upgradeapp) +* [upgradeModules](_esp32_javascript_modules_esp32_javascript_native_ota_.md#upgrademodules) + +## Type aliases + +### SubmitErrorFunction + +Ƭ **SubmitErrorFunction**: *function* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L28)* + +#### Type declaration: + +▸ (`message`: string): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`message` | string | + +___ + +### SubmitFunction + +Ƭ **SubmitFunction**: *function* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L27)* + +#### Type declaration: + +▸ (`type`: "app" | "modules"): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`type` | "app" | "modules" | + +## Variables + +### http + +• **http**: *["esp32-javascript/modules/esp32-javascript/http"](_esp32_javascript_modules_esp32_javascript_http_.md)* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L24)* + +## Functions + +### assertStatusCode + +▸ **assertStatusCode**(`status`: number, `url`: string): *(Anonymous function)* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L30)* + +**Parameters:** + +Name | Type | +------ | ------ | +`status` | number | +`url` | string | + +**Returns:** *(Anonymous function)* + +___ + +### `Const` upgrade + +▸ **upgrade**(`appImageUrl`: string, `modulesImageUrl`: string, `onError`: function, `onFinish`: function): *void* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:135](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L135)* + +**Parameters:** + +▪ **appImageUrl**: *string* + +▪ **modulesImageUrl**: *string* + +▪ **onError**: *function* + +▸ (`message`: string): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`message` | string | + +▪ **onFinish**: *function* + +▸ (): *void* + +**Returns:** *void* + +___ + +### upgradeApp + +▸ **upgradeApp**(`handle`: number, `appImageUrl`: string, `submitSuccess`: [SubmitFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submitfunction), `submitError`: [SubmitErrorFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submiterrorfunction)): *object* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:39](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L39)* + +**Parameters:** + +Name | Type | +------ | ------ | +`handle` | number | +`appImageUrl` | string | +`submitSuccess` | [SubmitFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submitfunction) | +`submitError` | [SubmitErrorFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submiterrorfunction) | + +**Returns:** *object* + +* **cancel**(): *function* + + * (): *void* + +* **cancelled**: *boolean* + +___ + +### upgradeModules + +▸ **upgradeModules**(`partition`: number, `modulesImageUrl`: string, `submitSuccess`: [SubmitFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submitfunction), `submitError`: [SubmitErrorFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submiterrorfunction)): *object* + +*Defined in [esp32-javascript/modules/esp32-javascript/native-ota.ts:90](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/native-ota.ts#L90)* + +**Parameters:** + +Name | Type | +------ | ------ | +`partition` | number | +`modulesImageUrl` | string | +`submitSuccess` | [SubmitFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submitfunction) | +`submitError` | [SubmitErrorFunction](_esp32_javascript_modules_esp32_javascript_native_ota_.md#submiterrorfunction) | + +**Returns:** *object* + +* **cancel**(): *function* + + * (): *void* + +* **cancelled**: *boolean* diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_.md index 2391f02..d8f0c15 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_.md @@ -15,7 +15,7 @@ ▸ **run**(): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test.ts:9](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test.ts#L9)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test.ts:32](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test.ts#L32)* **Returns:** *void* @@ -25,7 +25,7 @@ ___ ▸ **setPinValue**(`pin`: number, `val`: number): *void* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test.ts#L26)* **Parameters:** diff --git a/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_firmware_config_.md b/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_firmware_config_.md index f81773f..2b02ca2 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_firmware_config_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_javascript_self_test_firmware_config_.md @@ -14,11 +14,11 @@ ### ▪ **firmwareConfig**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:3](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L3)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L26)* ▪ **access**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:4](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L4)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L27)* * **password**: *string* = "esp32" @@ -26,7 +26,7 @@ ▪ **ota**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:12](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L12)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L35)* * **offline**: *true* = true @@ -34,7 +34,7 @@ ▪ **wifi**: *object* -*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:8](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L8)* +*Defined in [esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts:31](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-javascript/self-test-firmware-config.ts#L31)* * **password**: *string* = "e2epassword" diff --git a/docs/modules/_esp32_javascript_modules_esp32_js_eventloop_index_.md b/docs/modules/_esp32_javascript_modules_esp32_js_eventloop_index_.md index fab2c46..5ec19f1 100644 --- a/docs/modules/_esp32_javascript_modules_esp32_js_eventloop_index_.md +++ b/docs/modules/_esp32_javascript_modules_esp32_js_eventloop_index_.md @@ -26,6 +26,7 @@ * [clearTimeout](_esp32_javascript_modules_esp32_js_eventloop_index_.md#cleartimeout) * [el_select_next](_esp32_javascript_modules_esp32_js_eventloop_index_.md#el_select_next) * [installIntervalTimeout](_esp32_javascript_modules_esp32_js_eventloop_index_.md#installintervaltimeout) +* [internalErrorHandler](_esp32_javascript_modules_esp32_js_eventloop_index_.md#internalerrorhandler) * [setInterval](_esp32_javascript_modules_esp32_js_eventloop_index_.md#setinterval) * [setTimeout](_esp32_javascript_modules_esp32_js_eventloop_index_.md#settimeout) * [start](_esp32_javascript_modules_esp32_js_eventloop_index_.md#start) @@ -36,18 +37,18 @@ Ƭ **Esp32JsEventHandler**: *function* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:9](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L9)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:31](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L31)* #### Type declaration: -▸ (`event`: Esp32JsEventloopEvent, `collected`: Function[]): *boolean* +▸ (`event`: Esp32JsEventloopEvent, `collected`: function[]): *boolean* **Parameters:** Name | Type | ------ | ------ | `event` | Esp32JsEventloopEvent | -`collected` | Function[] | +`collected` | function[] | ## Variables @@ -55,7 +56,7 @@ Name | Type | • **afterSuspendHandlers**: *[Esp32JsEventHandler](_esp32_javascript_modules_esp32_js_eventloop_index_.md#esp32jseventhandler)[]* = [] -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:27](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L27)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:53](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L53)* ___ @@ -63,7 +64,7 @@ ___ • **beforeSuspendHandlers**: *function[]* = [] -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:26](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L26)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:52](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L52)* ___ @@ -71,7 +72,7 @@ ___ • **handles**: *number* = 0 -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:25](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L25)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:51](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L51)* ___ @@ -79,7 +80,7 @@ ___ • **intervals**: *number[]* = [] -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:24](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L24)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:50](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L50)* ___ @@ -87,7 +88,7 @@ ___ • **timers**: *[Esp32JsTimer](../interfaces/_esp32_javascript_modules_esp32_js_eventloop_index_.esp32jstimer.md)[]* = [] -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:23](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L23)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:49](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L49)* ## Functions @@ -95,7 +96,7 @@ ___ ▸ **clearInterval**(`handle`: number): *void* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:52](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L52)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:77](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L77)* **Parameters:** @@ -111,7 +112,7 @@ ___ ▸ **clearTimeout**(`handle`: number): *void* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:41](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L41)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:66](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L66)* **Parameters:** @@ -125,27 +126,45 @@ ___ ### el_select_next -▸ **el_select_next**(): *Function[]* +▸ **el_select_next**(): *function[]* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:77](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L77)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:104](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L104)* -**Returns:** *Function[]* +**Returns:** *function[]* ___ ### installIntervalTimeout -▸ **installIntervalTimeout**(`handle`: number, `fn`: Function, `timeout`: number): *void* +▸ **installIntervalTimeout**(`handle`: number, `fn`: function, `timeout`: number): *void* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:60](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L60)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:84](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L84)* + +**Parameters:** + +▪ **handle**: *number* + +▪ **fn**: *function* + +▸ (): *void* + +▪ **timeout**: *number* + +**Returns:** *void* + +___ + +### internalErrorHandler + +▸ **internalErrorHandler**(`error`: Error): *void* + +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L40)* **Parameters:** Name | Type | ------ | ------ | -`handle` | number | -`fn` | Function | -`timeout` | number | +`error` | Error | **Returns:** *void* @@ -153,16 +172,17 @@ ___ ### setInterval -▸ **setInterval**(`fn`: Function, `timeout`: number): *number* +▸ **setInterval**(`fn`: function, `timeout`: number): *number* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:70](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L70)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:97](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L97)* **Parameters:** -Name | Type | ------- | ------ | -`fn` | Function | -`timeout` | number | +▪ **fn**: *function* + +▸ (): *void* + +▪ **timeout**: *number* **Returns:** *number* @@ -170,16 +190,17 @@ ___ ### setTimeout -▸ **setTimeout**(`fn`: Function, `timeout`: number): *number* +▸ **setTimeout**(`fn`: function, `timeout`: number): *number* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:30](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L30)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:55](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L55)* **Parameters:** -Name | Type | ------- | ------ | -`fn` | Function | -`timeout` | number | +▪ **fn**: *function* + +▸ (): *void* + +▪ **timeout**: *number* **Returns:** *number* @@ -189,6 +210,6 @@ ___ ▸ **start**(): *void* -*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:129](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L129)* +*Defined in [esp32-javascript/modules/esp32-js-eventloop/index.ts:175](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/modules/esp32-js-eventloop/index.ts#L175)* **Returns:** *void* diff --git a/docs/modules/_esp32_javascript_urlparse_.md b/docs/modules/_esp32_javascript_urlparse_.md index 86f7ed3..0c5d06f 100644 --- a/docs/modules/_esp32_javascript_urlparse_.md +++ b/docs/modules/_esp32_javascript_urlparse_.md @@ -18,7 +18,7 @@ ▸ **urlparse**(`absoluteUrl`: string): *[AnchorElement](../interfaces/_esp32_javascript_urlparse_.anchorelement.md)* -*Defined in [esp32-javascript/urlparse.ts:22](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/esp32-javascript/urlparse.ts#L22)* +*Defined in [esp32-javascript/urlparse.ts:45](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/esp32-javascript/urlparse.ts#L45)* **Parameters:** diff --git a/docs/modules/_socket_events_modules_socket_events_index_.md b/docs/modules/_socket_events_modules_socket_events_index_.md index 8be43b9..b161828 100644 --- a/docs/modules/_socket_events_modules_socket_events_index_.md +++ b/docs/modules/_socket_events_modules_socket_events_index_.md @@ -6,13 +6,15 @@ ### Classes +* [ActiveSockets](../classes/_socket_events_modules_socket_events_index_.activesockets.md) +* [NumberSet](../classes/_socket_events_modules_socket_events_index_.numberset.md) * [Socket](../classes/_socket_events_modules_socket_events_index_.socket.md) +* [SocketLookupMap](../classes/_socket_events_modules_socket_events_index_.socketlookupmap.md) ### Interfaces * [BufferEntry](../interfaces/_socket_events_modules_socket_events_index_.bufferentry.md) * [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md) -* [SocketArrayFind](../interfaces/_socket_events_modules_socket_events_index_.socketarrayfind.md) ### Type aliases @@ -45,7 +47,7 @@ Ƭ **OnAcceptCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:10](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L10)* +*Defined in [socket-events/modules/socket-events/index.ts:37](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L37)* #### Type declaration: @@ -57,7 +59,7 @@ ___ Ƭ **OnCloseCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:9](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L9)* +*Defined in [socket-events/modules/socket-events/index.ts:36](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L36)* #### Type declaration: @@ -75,7 +77,7 @@ ___ Ƭ **OnConnectCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:7](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L7)* +*Defined in [socket-events/modules/socket-events/index.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L34)* #### Type declaration: @@ -93,17 +95,17 @@ ___ Ƭ **OnDataCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:6](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L6)* +*Defined in [socket-events/modules/socket-events/index.ts:29](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L29)* #### Type declaration: -▸ (`data`: string, `sockfd`: number, `length`: number): *void* +▸ (`data`: Uint8Array, `sockfd`: number, `length`: number): *void* **Parameters:** Name | Type | ------ | ------ | -`data` | string | +`data` | Uint8Array | `sockfd` | number | `length` | number | @@ -113,7 +115,7 @@ ___ Ƭ **OnErrorCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:8](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L8)* +*Defined in [socket-events/modules/socket-events/index.ts:35](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L35)* #### Type declaration: @@ -131,7 +133,7 @@ ___ Ƭ **OnWritableCB**: *function* -*Defined in [socket-events/modules/socket-events/index.ts:11](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L11)* +*Defined in [socket-events/modules/socket-events/index.ts:38](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L38)* #### Type declaration: @@ -147,9 +149,9 @@ Name | Type | ### `Const` sockets -• **sockets**: *[Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)[] & [SocketArrayFind](../interfaces/_socket_events_modules_socket_events_index_.socketarrayfind.md)* = [] as any +• **sockets**: *[ActiveSockets](../classes/_socket_events_modules_socket_events_index_.activesockets.md)‹›* = new ActiveSockets() -*Defined in [socket-events/modules/socket-events/index.ts:70](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L70)* +*Defined in [socket-events/modules/socket-events/index.ts:156](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L156)* ___ @@ -157,22 +159,22 @@ ___ • **sslClientCtx**: *any* -*Defined in [socket-events/modules/socket-events/index.ts:28](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L28)* +*Defined in [socket-events/modules/socket-events/index.ts:55](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L55)* ## Functions ### afterSuspend -▸ **afterSuspend**(`evt`: Esp32JsEventloopEvent, `collected`: Function[]): *boolean* +▸ **afterSuspend**(`evt`: Esp32JsEventloopEvent, `collected`: function[]): *boolean* -*Defined in [socket-events/modules/socket-events/index.ts:485](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L485)* +*Defined in [socket-events/modules/socket-events/index.ts:603](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L603)* **Parameters:** Name | Type | ------ | ------ | `evt` | Esp32JsEventloopEvent | -`collected` | Function[] | +`collected` | function[] | **Returns:** *boolean* @@ -182,7 +184,7 @@ ___ ▸ **beforeSuspend**(): *void* -*Defined in [socket-events/modules/socket-events/index.ts:448](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L448)* +*Defined in [socket-events/modules/socket-events/index.ts:587](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L587)* **Returns:** *void* @@ -192,7 +194,7 @@ ___ ▸ **closeSocket**(`socketOrSockfd`: [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md) | number): *void* -*Defined in [socket-events/modules/socket-events/index.ts:268](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L268)* +*Defined in [socket-events/modules/socket-events/index.ts:398](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L398)* Flushes buffered writes, shutdowns SSL (if it is a secure socket), close the socket, performs the close callback function, removes @@ -212,7 +214,7 @@ ___ ▸ **getOrCreateNewSocket**(): *[Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)‹›* -*Defined in [socket-events/modules/socket-events/index.ts:250](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L250)* +*Defined in [socket-events/modules/socket-events/index.ts:380](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L380)* **Returns:** *[Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)‹›* @@ -222,7 +224,7 @@ ___ ▸ **performOnClose**(`socket`: [Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md)): *void* -*Defined in [socket-events/modules/socket-events/index.ts:254](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L254)* +*Defined in [socket-events/modules/socket-events/index.ts:384](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L384)* **Parameters:** @@ -238,7 +240,7 @@ ___ ▸ **resetSocket**(`socket`: [Socket](../classes/_socket_events_modules_socket_events_index_.socket.md)): *void* -*Defined in [socket-events/modules/socket-events/index.ts:440](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L440)* +*Defined in [socket-events/modules/socket-events/index.ts:576](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L576)* **Parameters:** @@ -254,7 +256,7 @@ ___ ▸ **sockConnect**(`ssl`: boolean, `host`: string, `port`: string, `onConnect`: [OnConnectCB](_socket_events_modules_socket_events_index_.md#onconnectcb), `onData`: function, `onError`: function, `onClose`: function): *[Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md)* -*Defined in [socket-events/modules/socket-events/index.ts:315](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L315)* +*Defined in [socket-events/modules/socket-events/index.ts:442](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L442)* Connects to specified host and port. @@ -280,13 +282,13 @@ A callback which gets called on connect event. A callback which gets called on a data event. -▸ (`data`: string, `sockfd`: number, `length`: number): *void* +▸ (`data`: Uint8Array, `sockfd`: number, `length`: number): *void* **Parameters:** Name | Type | ------ | ------ | -`data` | string | +`data` | Uint8Array | `sockfd` | number | `length` | number | @@ -318,7 +320,7 @@ ___ ▸ **sockListen**(`port`: string | number, `onAccept`: function, `onError`: function, `onClose`: function, `isSSL`: boolean): *[Esp32JsSocket](../interfaces/_socket_events_modules_socket_events_index_.esp32jssocket.md) | null* -*Defined in [socket-events/modules/socket-events/index.ts:365](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/socket-events/modules/socket-events/index.ts#L365)* +*Defined in [socket-events/modules/socket-events/index.ts:503](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/socket-events/modules/socket-events/index.ts#L503)* **Parameters:** diff --git a/docs/modules/_wifi_events_modules_wifi_events_index_.md b/docs/modules/_wifi_events_modules_wifi_events_index_.md index bfe2c81..2587866 100644 --- a/docs/modules/_wifi_events_modules_wifi_events_index_.md +++ b/docs/modules/_wifi_events_modules_wifi_events_index_.md @@ -17,6 +17,8 @@ * [afterSuspend](_wifi_events_modules_wifi_events_index_.md#aftersuspend) * [connectWifi](_wifi_events_modules_wifi_events_index_.md#connectwifi) +* [convertBssidToArray](_wifi_events_modules_wifi_events_index_.md#convertbssidtoarray) +* [convertBssidToString](_wifi_events_modules_wifi_events_index_.md#convertbssidtostring) * [convertIPAddress](_wifi_events_modules_wifi_events_index_.md#convertipaddress) * [createSoftAp](_wifi_events_modules_wifi_events_index_.md#createsoftap) * [getBssid](_wifi_events_modules_wifi_events_index_.md#getbssid) @@ -29,22 +31,22 @@ • **wifi**: *[Esp32JsWifi](../interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md) | undefined* = undefined -*Defined in [wifi-events/modules/wifi-events/index.ts:15](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L15)* +*Defined in [wifi-events/modules/wifi-events/index.ts:38](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L38)* ## Functions ### afterSuspend -▸ **afterSuspend**(`evt`: Esp32JsEventloopEvent, `collected`: Function[]): *boolean* +▸ **afterSuspend**(`evt`: Esp32JsEventloopEvent, `collected`: function[]): *boolean* -*Defined in [wifi-events/modules/wifi-events/index.ts:98](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L98)* +*Defined in [wifi-events/modules/wifi-events/index.ts:152](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L152)* **Parameters:** Name | Type | ------ | ------ | `evt` | Esp32JsEventloopEvent | -`collected` | Function[] | +`collected` | function[] | **Returns:** *boolean* @@ -52,9 +54,9 @@ ___ ### connectWifi -▸ **connectWifi**(`ssid`: string, `password`: string, `callback`: function): *void* +▸ **connectWifi**(`ssid`: string, `password`: string, `callback`: function, `bssid?`: undefined | string): *void* -*Defined in [wifi-events/modules/wifi-events/index.ts:34](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L34)* +*Defined in [wifi-events/modules/wifi-events/index.ts:58](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L58)* Connect to AP with given ssid and password. @@ -81,15 +83,59 @@ Name | Type | `event` | [Esp32JsWifiEvent](../interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifievent.md) | `ip` | string | undefined | +▪`Optional` **bssid**: *undefined | string* + +Optional bssid to pin to a specific AP. + **Returns:** *void* ___ +### convertBssidToArray + +▸ **convertBssidToArray**(`bssid`: string): *[number, number, number, number, number, number] | undefined* + +*Defined in [wifi-events/modules/wifi-events/index.ts:117](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L117)* + +Converts a bssid string representation in a 6 number array. + +**Parameters:** + +Name | Type | +------ | ------ | +`bssid` | string | + +**Returns:** *[number, number, number, number, number, number] | undefined* + +The bssid as 6 number array. + +___ + +### convertBssidToString + +▸ **convertBssidToString**(`bssid`: [number, number, number, number, number, number]): *string | undefined* + +*Defined in [wifi-events/modules/wifi-events/index.ts:100](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L100)* + +Converts a 6 number array into a string representation of a BSSID. + +**Parameters:** + +Name | Type | +------ | ------ | +`bssid` | [number, number, number, number, number, number] | + +**Returns:** *string | undefined* + +The bssid as string representation. + +___ + ### convertIPAddress ▸ **convertIPAddress**(`ip`: number): *string | undefined* -*Defined in [wifi-events/modules/wifi-events/index.ts:75](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L75)* +*Defined in [wifi-events/modules/wifi-events/index.ts:130](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L130)* Convert 32 bit number to ip address string. @@ -109,7 +155,7 @@ ___ ▸ **createSoftAp**(`ssid`: string, `password`: string, `callback`: function): *void* -*Defined in [wifi-events/modules/wifi-events/index.ts:50](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L50)* +*Defined in [wifi-events/modules/wifi-events/index.ts:79](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L79)* Create soft AP with given ssid and password. @@ -141,13 +187,13 @@ ___ ### getBssid -▸ **getBssid**(): *string* +▸ **getBssid**(): *string | undefined* -*Defined in [wifi-events/modules/wifi-events/index.ts:63](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L63)* +*Defined in [wifi-events/modules/wifi-events/index.ts:92](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L92)* Get the bssid of the current connected wifi AP as formatted as hex string. -**Returns:** *string* +**Returns:** *string | undefined* The bssid. @@ -157,7 +203,7 @@ ___ ▸ **getIPAddress**(): *string | undefined* -*Defined in [wifi-events/modules/wifi-events/index.ts:93](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L93)* +*Defined in [wifi-events/modules/wifi-events/index.ts:148](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L148)* Get the ip address. @@ -171,7 +217,7 @@ ___ ▸ **resetWifiStatus**(`callback`: function): *[Esp32JsWifi](../interfaces/_wifi_events_modules_wifi_events_index_.esp32jswifi.md)* -*Defined in [wifi-events/modules/wifi-events/index.ts:17](https://github.com/marcelkottmann/esp32-javascript/blob/801e1cb/components/wifi-events/modules/wifi-events/index.ts#L17)* +*Defined in [wifi-events/modules/wifi-events/index.ts:40](https://github.com/marcelkottmann/esp32-javascript/blob/22ffb3d/components/wifi-events/modules/wifi-events/index.ts#L40)* **Parameters:** diff --git a/examples/repl.js b/examples/repl.js index 47027d1..4cea1a6 100644 --- a/examples/repl.js +++ b/examples/repl.js @@ -1,21 +1,25 @@ /** - * + * * 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. + * + * 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"); var PROMPT = "> "; +var textDecoder = new TextDecoder(); function writeOutput(socket, result) { socket.write(result); @@ -27,7 +31,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; @@ -73,7 +78,7 @@ require("socket-events").sockListen( logOutput.push("ERROR|" + msg + "\n"); }, }; - _ = eval(data); + _ = eval.call(globalThis, data); } finally { console = _console; } diff --git a/examples/stress.js b/examples/stress.js new file mode 100644 index 0000000..fbca662 --- /dev/null +++ b/examples/stress.js @@ -0,0 +1,28 @@ +(function () { + var config = require("./config").config; + + var success = 0; + var err = 0; + + function stress() { + info(); + fetch("http://localhost/setup", { + headers: { + authorization: + "Basic " + + btoa(config.access.username + ":" + config.access.password), + }, + }) + .then(function () { + console.log(++success); + setTimeout(stress, 0); + }) + .catch(function (error) { + console.error(++err); + console.error(error); + setTimeout(stress, 0); + }); + } + + stress(); +})(); diff --git a/main/include/esp32-javascript-config.h b/main/include/esp32-javascript-config.h index 033c58d..4f1756d 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 @@ -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/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 diff --git a/package-lock.json b/package-lock.json index ffb7941..dca5706 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": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", "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..d294058 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": "4.3.5" } } 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/scripts/cp2/cp2.js b/scripts/cp2/cp2.js index 1550ba7..a7098c7 100755 --- a/scripts/cp2/cp2.js +++ b/scripts/cp2/cp2.js @@ -1,13 +1,13 @@ #!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); +const fs = require("fs"); +const path = require("path"); -const glob = require('glob'); -const meow = require('meow'); +const glob = require("glob"); +const meow = require("meow"); async function main() { - - const cli = meow(` + const cli = meow( + ` Usage of cp2 $ cp2 [--dry-run] [--verbose] SRC EXPR @@ -25,52 +25,56 @@ async function main() { Please use single-quotes enclosed arguments to protect glob and expression from interpretion by your shell. -`, { - flags: { - 'dry-run': { - type: 'boolean', - }, - 'verbose': { - type: 'boolean', - }, - 'move': { - type: 'boolean', - } - } - }); - - if (cli.input.length < 2) { - console.error(cli.help); - process.exit(1); +`, + { + flags: { + "dry-run": { + type: "boolean", + }, + verbose: { + type: "boolean", + }, + move: { + type: "boolean", + }, + }, } + ); - const files = glob.sync(cli.input[0]); + if (cli.input.length < 2) { + console.error(cli.help); + process.exit(1); + } - let findReplace; - try { - findReplace = eval(cli.input.slice(1).join(' ')); - } catch (error) { - console.error('javascript find-replace-function contains error:'); - console.error(error); - process.exit(2); - } + const files = glob.sync(cli.input[0], { + ignore: ["**/node_modules/**"], + }); - files.forEach(f => { - let target = findReplace.call(findReplace, f); + let findReplace; + try { + findReplace = eval(cli.input.slice(1).join(" ")); + } catch (error) { + console.error("javascript find-replace-function contains error:"); + console.error(error); + process.exit(2); + } - if (f === target) { - console.log(`ommiting ${f}: src and target are equal`) - } else { - if (cli.flags.verbose) { - console.log(`${cli.flags.move ? 'mv' : 'cp'} ${f} ==> ${target}`); - } + files.forEach((f) => { + let target = findReplace.call(findReplace, f); - if (!cli.flags.dryRun) { - fs.mkdirSync(path.dirname(target), { recursive: true }); - cli.flags.move ? fs.renameSync(f, target) : fs.copyFileSync(f, target); - } - } - }); + if (f === target) { + console.log(`ommiting ${f}: src and target are equal`); + } else { + if (cli.flags.verbose) { + console.log(`${cli.flags.move ? "mv" : "cp"} ${f} ==> ${target}`); + } + + if (!cli.flags.dryRun) { + fs.mkdirSync(path.dirname(target), { recursive: true }); + cli.flags.move ? fs.renameSync(f, target) : fs.copyFileSync(f, target); + } + } + }); } main(); diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 0627033..de20c4b 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 @@ -122,13 +122,13 @@ CONFIG_PARTITION_TABLE_MD5=y # # Compiler options # -# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y # CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -CONFIG_COMPILER_OPTIMIZATION_PERF=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_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set # CONFIG_COMPILER_CXX_EXCEPTIONS is not set # CONFIG_COMPILER_CXX_RTTI is not set CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y @@ -263,10 +263,9 @@ CONFIG_SPIRAM_IGNORE_NOTFOUND=y CONFIG_SPIRAM_USE_CAPS_ALLOC=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y -# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set +CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set CONFIG_SPIRAM_CACHE_WORKAROUND=y -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y # # SPIRAM cache workaround debugging @@ -346,7 +345,7 @@ CONFIG_ESP32_XTAL_FREQ=0 # CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 # CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY is not set -CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP=y +CONFIG_ESP_ALLOW_RTC_FAST_MEM_AS_HEAP=y # end of ESP32-specific # @@ -518,7 +517,7 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20 # # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set -CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_ESP_ENABLE_COREDUMP_TO_NONE=y # end of Core dump # @@ -650,7 +649,7 @@ CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set # CONFIG_LOG_DEFAULT_LEVEL_WARN is not set CONFIG_LOG_DEFAULT_LEVEL_INFO=y -# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_LOG_COLORS=y @@ -666,8 +665,8 @@ CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set CONFIG_LWIP_IRAM_OPTIMIZATION=y CONFIG_LWIP_TIMERS_ONDEMAND=y -CONFIG_LWIP_MAX_SOCKETS=10 -# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +CONFIG_LWIP_MAX_SOCKETS=12 +CONFIG_LWIP_USE_ONLY_LWIP_SELECT=y # CONFIG_LWIP_SO_LINGER is not set CONFIG_LWIP_SO_REUSE=y CONFIG_LWIP_SO_REUSE_RXTOALL=y @@ -1022,9 +1021,9 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_VFS_SUPPORT_IO=y CONFIG_VFS_SUPPORT_DIR=y -CONFIG_VFS_SUPPORT_SELECT=y -CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_VFS_SUPPORT_TERMIOS=y +CONFIG_VFS_SUPPORT_SELECT=n +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=n +CONFIG_VFS_SUPPORT_TERMIOS=n # # Host File System I/O (Semihosting) diff --git a/setup.png b/setup.png new file mode 100644 index 0000000..278e909 Binary files /dev/null and b/setup.png differ diff --git a/tsconfig.json b/tsconfig.json index 1faf847..f38eb6a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,13 +15,12 @@ "*": [ "esp32-javascript/modules/*", "wifi-events/modules/*", - "socket-events/modules/*" + "socket-events/modules/*", ] }, + "noEmitOnError": true, "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"] +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy