Skip to content

Commit

Permalink
Enhancement: replaced exsiting toml parser. (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: Rushikesh Patange <rushikesh.patange@espressif.com>
  • Loading branch information
RushikeshPatange and Rushikesh Patange authored Oct 17, 2023
1 parent c3e92b5 commit 0f1f2ce
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ <h4 class=" mb-4" style="color: #e63f36;"><b>Publish your own firmware apps</b><
<script src="node_modules/xterm-addon-fit/lib/xterm-addon-fit.js"></script>
<script src="node_modules/crypto-js/crypto-js.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.3/pako.js"></script>
<script type="text/javascript" src="node_modules/toml-js/src/toml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>

Expand Down
12 changes: 7 additions & 5 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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]]);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 = "";
}
Expand Down
1 change: 0 additions & 1 deletion minimal-launchpad/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ <h4 class="topic" data-target-tab-panel-id="about">
<script src="../node_modules/xterm-addon-fit/lib/xterm-addon-fit.js"></script>
<script src="../node_modules/crypto-js/crypto-js.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.3/pako.js"></script>
<script type="text/javascript" src="../node_modules/toml-js/src/toml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>

Expand Down
16 changes: 8 additions & 8 deletions minimal-launchpad/minimal_ui_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 13 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 0f1f2ce

Please sign in to comment.