|
|
|
@ -27,7 +27,10 @@ export class CompilerLoaderPlugin extends ElectronBasePlugin { |
|
|
|
|
clients: CompilerLoaderPluginClient[] = [] |
|
|
|
|
constructor() { |
|
|
|
|
super(profile, clientProfile, CompilerLoaderPluginClient) |
|
|
|
|
this.methods = [...super.methods, 'getPort'] |
|
|
|
|
this.methods = [...super.methods, 'getPort']; |
|
|
|
|
(async()=>{ |
|
|
|
|
await getLists() |
|
|
|
|
})() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getPort(): Promise<number> { |
|
|
|
@ -39,7 +42,7 @@ const clientProfile: Profile = { |
|
|
|
|
name: 'compilerloader', |
|
|
|
|
displayName: 'compilerloader', |
|
|
|
|
description: 'Compiler Loader', |
|
|
|
|
methods: ['getPort', 'downloadCompiler', 'listCompilers'], |
|
|
|
|
methods: ['getPort', 'downloadCompiler', 'listCompilers', 'getBaseUrls', 'getLists'], |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class CompilerLoaderPluginClient extends ElectronBasePluginClient { |
|
|
|
@ -62,7 +65,8 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient { |
|
|
|
|
try { |
|
|
|
|
if (await fs.stat(filePath)) { |
|
|
|
|
return |
|
|
|
|
}} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (e) { |
|
|
|
|
// do nothing
|
|
|
|
|
} |
|
|
|
@ -102,4 +106,54 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient { |
|
|
|
|
const compilers = await fs.readdir(compilersDir) |
|
|
|
|
return compilers |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getBaseUrls(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getLists(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getLists = async()=>{ |
|
|
|
|
|
|
|
|
|
let binData |
|
|
|
|
let wasmData |
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
let binRes = await axios.get(baseURLBin + '/list.json') |
|
|
|
|
await fs.writeFile(cacheDir + '/binlist.json', JSON.stringify(binRes.data, null, 2)) |
|
|
|
|
binData = binRes.data |
|
|
|
|
}catch(e) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
let wasmRes = await axios.get(baseURLWasm + '/list.json') |
|
|
|
|
await fs.writeFile(cacheDir + '/wasmlist.json', JSON.stringify(wasmRes.data, null, 2)) |
|
|
|
|
wasmData = wasmRes.data |
|
|
|
|
}catch(e) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!wasmData){ |
|
|
|
|
try{ |
|
|
|
|
wasmData = JSON.parse(await fs.readFile(cacheDir + '/wasmlist.json', 'utf8')); |
|
|
|
|
}catch(e){ |
|
|
|
|
wasmData = {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!binData){ |
|
|
|
|
try{ |
|
|
|
|
binData = JSON.parse(await fs.readFile(cacheDir + '/binlist.json', 'utf8')); |
|
|
|
|
}catch(e){ |
|
|
|
|
binData = {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
binData, wasmData |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |