refactor: ginify BrowserView (#23578)
This commit is contained in:
parent
66d65a6d35
commit
9bd0fc5348
12 changed files with 128 additions and 165 deletions
|
@ -1,22 +1,25 @@
|
|||
const { app } = require('electron');
|
||||
const http = require('http');
|
||||
const v8 = require('v8');
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const chunks = [];
|
||||
req.on('data', chunk => { chunks.push(chunk); });
|
||||
req.on('end', () => {
|
||||
const js = Buffer.concat(chunks).toString('utf8');
|
||||
(async () => {
|
||||
try {
|
||||
const result = await Promise.resolve(eval(js)); // eslint-disable-line no-eval
|
||||
res.end(v8.serialize({ result }));
|
||||
} catch (e) {
|
||||
res.end(v8.serialize({ error: e.stack }));
|
||||
}
|
||||
})();
|
||||
app.whenReady().then(() => {
|
||||
const server = http.createServer((req, res) => {
|
||||
const chunks = [];
|
||||
req.on('data', chunk => { chunks.push(chunk); });
|
||||
req.on('end', () => {
|
||||
const js = Buffer.concat(chunks).toString('utf8');
|
||||
(async () => {
|
||||
try {
|
||||
const result = await Promise.resolve(eval(js)); // eslint-disable-line no-eval
|
||||
res.end(v8.serialize({ result }));
|
||||
} catch (e) {
|
||||
res.end(v8.serialize({ error: e.stack }));
|
||||
}
|
||||
})();
|
||||
});
|
||||
}).listen(0, '127.0.0.1', () => {
|
||||
process.stdout.write(`Listening: ${server.address().port}\n`);
|
||||
});
|
||||
}).listen(0, '127.0.0.1', () => {
|
||||
process.stdout.write(`Listening: ${server.address().port}\n`);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue