Skip to content

Commit

Permalink
Add type annotations in browser-main
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Feb 28, 2022
1 parent a68f5aa commit f0d1c07
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion build/builtin/browser-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@ const { ipcRenderer } = require('electron');
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');

/**
* @param {string} filePath
*/
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, { encoding: 'utf8' }));
}

/**
* @param {string} filePath
* @param {any} obj
*/
function writeJson(filePath, obj) {
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2));
}

/**
* @param {HTMLFormElement} form
* @param {string} id
* @param {string} title
* @param {string} value
* @param {boolean} checked
*/
function renderOption(form, id, title, value, checked) {
const input = document.createElement('input');
input.type = 'radio';
Expand All @@ -37,7 +51,14 @@ function renderOption(form, id, title, value, checked) {
return input;
}

/**
* @param {HTMLElement} el
* @param {any} state
*/
function render(el, state) {
/**
* @param {any} state
*/
function setState(state) {
try {
writeJson(controlFilePath, state.control);
Expand Down Expand Up @@ -115,7 +136,9 @@ function main() {
control = {};
}

render(el, { builtin, control });
if (el) {
render(el, { builtin, control });
}
}

window.onload = main;

0 comments on commit f0d1c07

Please sign in to comment.