2020-07-09 15:48:39 +00:00
|
|
|
const { app } = require('electron');
|
2023-06-15 14:42:27 +00:00
|
|
|
const http = require('node:http');
|
|
|
|
const v8 = require('node:v8');
|
2023-06-26 09:51:54 +00:00
|
|
|
// eslint-disable-next-line camelcase,@typescript-eslint/no-unused-vars
|
2023-06-15 14:42:27 +00:00
|
|
|
const promises_1 = require('node:timers/promises');
|
2020-04-22 22:53:12 +00:00
|
|
|
|
2021-06-17 21:17:25 +00:00
|
|
|
if (app.commandLine.hasSwitch('boot-eval')) {
|
|
|
|
// eslint-disable-next-line no-eval
|
|
|
|
eval(app.commandLine.getSwitchValue('boot-eval'));
|
|
|
|
}
|
|
|
|
|
2020-07-09 15:48:39 +00:00
|
|
|
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`);
|
2020-04-22 22:53:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
process.exit(0);
|
|
|
|
}, 30000);
|