mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Add type annotations in browser-main
This commit is contained in:
parent
a68f5aa83e
commit
f0d1c07417
|
@ -12,14 +12,28 @@ const { ipcRenderer } = require('electron');
|
||||||
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
|
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
|
||||||
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
|
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} filePath
|
||||||
|
*/
|
||||||
function readJson(filePath) {
|
function readJson(filePath) {
|
||||||
return JSON.parse(fs.readFileSync(filePath, { encoding: 'utf8' }));
|
return JSON.parse(fs.readFileSync(filePath, { encoding: 'utf8' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} filePath
|
||||||
|
* @param {any} obj
|
||||||
|
*/
|
||||||
function writeJson(filePath, obj) {
|
function writeJson(filePath, obj) {
|
||||||
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2));
|
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) {
|
function renderOption(form, id, title, value, checked) {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.type = 'radio';
|
input.type = 'radio';
|
||||||
|
@ -37,7 +51,14 @@ function renderOption(form, id, title, value, checked) {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {HTMLElement} el
|
||||||
|
* @param {any} state
|
||||||
|
*/
|
||||||
function render(el, state) {
|
function render(el, state) {
|
||||||
|
/**
|
||||||
|
* @param {any} state
|
||||||
|
*/
|
||||||
function setState(state) {
|
function setState(state) {
|
||||||
try {
|
try {
|
||||||
writeJson(controlFilePath, state.control);
|
writeJson(controlFilePath, state.control);
|
||||||
|
@ -115,7 +136,9 @@ function main() {
|
||||||
control = {};
|
control = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (el) {
|
||||||
render(el, { builtin, control });
|
render(el, { builtin, control });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = main;
|
window.onload = main;
|
||||||
|
|
Loading…
Reference in a new issue