blob: 10f840e39c96104b356d0069c24df35cf7d1ef4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
export type RequestHandler = {
(request: string, res: (response: string) => void): void
}
export type Config = Partial<{
instanceName: string
gtkTheme: string
iconTheme: string
cursorTheme: string
css: string
requestHandler: RequestHandler
hold: boolean
}>
export function runJS(body: string): Promise<any> {
return new Promise((res, rej) => {
try {
const fn = Function(`return (async function() {
${body.includes(";") ? body : `return ${body};`}
})`)
fn()()
.then(res)
.catch(rej)
} catch (error) {
rej(error)
}
})
}
|