From 21bf2ecce82bf05eafa6ee4ab3503a2de8ec4508 Mon Sep 17 00:00:00 2001 From: Rushikesh Patange Date: Thu, 28 Sep 2023 15:47:09 +0530 Subject: [PATCH] Enhancement: replaced exsiting toml parser. --- index.html | 1 - js/index.js | 12 +++++++----- minimal-launchpad/index.html | 1 - minimal-launchpad/minimal_ui_index.js | 16 ++++++++-------- package-lock.json | 22 +++++++++++++--------- package.json | 2 +- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index 91578d4..07e89f2 100644 --- a/index.html +++ b/index.html @@ -436,7 +436,6 @@

Publish your own firmware apps< - diff --git a/js/index.js b/js/index.js index 7d5cb84..f8b89f5 100644 --- a/js/index.js +++ b/js/index.js @@ -34,6 +34,8 @@ let resizeTimeout = false; import * as utilities from "./utils.js"; import * as esptooljs from "../node_modules/esptool-js/bundle.js"; +import * as toml from '../node_modules/smol-toml/dist/index.js'; + const ESPLoader = esptooljs.ESPLoader; const Transport = esptooljs.Transport; @@ -132,8 +134,8 @@ function buildQuickTryUI_v1_0() { if(supported_apps) { addDeviceTypeOption(supported_apps); populateSupportedChipsets(config[supported_apps[0]]); - if (config[supported_apps[0]]["readme.text"]) { - markdown_payload_url = config[supported_apps[0]]["readme.text"]; + if (config[supported_apps[0]].readme?.text) { + markdown_payload_url = config[supported_apps[0]].readme.text; } } setAppURLs(config[supported_apps[0]]); @@ -186,7 +188,7 @@ function populateSupportedChipsets(deviceConfig) { inputElement.setAttribute("class", "form-check-input"); inputElement.name = "chipType"; inputElement.id = "radio-" + chipset; - inputElement.value = deviceConfig["image." + chipset.toLowerCase()]; + inputElement.value = deviceConfig["image"][chipset.toLowerCase()]; if (chipset.toLowerCase() === chip.toLowerCase()) inputElement.checked = true; @@ -220,8 +222,8 @@ $('#frameworkSel').on('change', function() { $('#device').on('change', function() { populateSupportedChipsets(config[deviceTypeSelect.value]); setAppURLs(config[deviceTypeSelect.value]); - if (config[deviceTypeSelect.value]["readme.text"]) { - markdown_payload_url = config[deviceTypeSelect.value]["readme.text"]; + if (config[deviceTypeSelect.value].readme?.text) { + markdown_payload_url = config[deviceTypeSelect.value].readme.text; } else { markdown_payload_url = ""; } diff --git a/minimal-launchpad/index.html b/minimal-launchpad/index.html index 2742f8b..69bde08 100644 --- a/minimal-launchpad/index.html +++ b/minimal-launchpad/index.html @@ -96,7 +96,6 @@

- diff --git a/minimal-launchpad/minimal_ui_index.js b/minimal-launchpad/minimal_ui_index.js index 7728255..1c970b4 100644 --- a/minimal-launchpad/minimal_ui_index.js +++ b/minimal-launchpad/minimal_ui_index.js @@ -10,6 +10,8 @@ const message = document.getElementById("message"); import * as utilities from "../js/utils.js" import * as esptooljs from "../node_modules/esptool-js/bundle.js"; +import * as toml from '../node_modules/smol-toml/dist/index.js'; + const ESPLoader = esptooljs.ESPLoader; const Transport = esptooljs.Transport; @@ -39,19 +41,17 @@ var config = []; // Code for minimalLaunchpad function setImagePartsAndOffsetArray() { - let application = "supported_apps"; + let app = config[config["supported_apps"][0]]; let chipInConfToml = undefined; - let imageString = undefined; - let addressString = undefined; + let appImageObj = undefined; if (chip !== "default" && config["multipart"]) { chipInConfToml = config["chip"]; + appImageObj = app["image"][chipInConfToml.toLowerCase()]; } if (chip !== "default" && chipInConfToml !== undefined) { - imageString = "image." + chipInConfToml.toLowerCase() + ".parts"; - addressString = "image." + chipInConfToml.toLowerCase() + ".addresses"; + imagePartsArray = appImageObj["parts"]; + imagePartsOffsetArray = appImageObj["addresses"]; } - imagePartsArray = config[config[application][0]][imageString]; - imagePartsOffsetArray = config[config[application][0]][addressString]; } async function downloadAndFlash() { @@ -79,7 +79,7 @@ function MDtoHtml() { var converter = new showdown.Converter({ tables: true }); converter.setFlavor('github'); try { - fetch(config[config[application][0]]["readme.text"]).then(response => { + fetch(config[config[application][0]].readme.text).then(response => { return response.text(); }).then(result => { let htmlText = converter.makeHtml(result); diff --git a/package-lock.json b/package-lock.json index 1e66981..59ccaa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "crypto-js": "^4.1.1", "esptool-js": "^0.3.0", - "toml-js": "^0.0.8", + "smol-toml": "^1.1.2", "xterm": "^4.17.0", "xterm-addon-fit": "^0.5.0" } @@ -32,10 +32,14 @@ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" }, - "node_modules/toml-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/toml-js/-/toml-js-0.0.8.tgz", - "integrity": "sha512-MQUXr5oq9fgOQIcucZuda1BtGUmQRt3Y2z1TY9JT3oUR6gs1qLkbsGfVdlr/gJ6JqrjJdPLO5wNXCgkmvzXNTQ==" + "node_modules/smol-toml": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.1.2.tgz", + "integrity": "sha512-opeweddRVyIFjnNPmEodUn4LlVeiZNE3OZ3QiLvyC/pWxNgW3z02oCTVOFVgYI1w1sSO4nifFCcvw1ADOMs5ag==", + "engines": { + "node": ">= 18", + "pnpm": ">= 8" + } }, "node_modules/tslib": { "version": "2.4.1", @@ -76,10 +80,10 @@ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" }, - "toml-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/toml-js/-/toml-js-0.0.8.tgz", - "integrity": "sha512-MQUXr5oq9fgOQIcucZuda1BtGUmQRt3Y2z1TY9JT3oUR6gs1qLkbsGfVdlr/gJ6JqrjJdPLO5wNXCgkmvzXNTQ==" + "smol-toml": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.1.2.tgz", + "integrity": "sha512-opeweddRVyIFjnNPmEodUn4LlVeiZNE3OZ3QiLvyC/pWxNgW3z02oCTVOFVgYI1w1sSO4nifFCcvw1ADOMs5ag==" }, "tslib": { "version": "2.4.1", diff --git a/package.json b/package.json index 8b0fb28..0036e58 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "dependencies": { "crypto-js": "^4.1.1", "esptool-js": "^0.3.0", - "toml-js": "^0.0.8", + "smol-toml": "^1.1.2", "xterm": "^4.17.0", "xterm-addon-fit": "^0.5.0" }