erratic-gate/src/index.ts

41 lines
910 B
TypeScript
Raw Normal View History

2019-07-23 21:53:59 +02:00
import { Splash } from './modules/splash/classes/Splash'
2019-08-03 23:55:22 +02:00
/**
* The function wich is run when the app is loaded
*/
2019-07-23 21:53:59 +02:00
async function main() {
2019-08-03 23:55:22 +02:00
// Create splash screen variable
2019-07-23 21:53:59 +02:00
let splash: Splash | undefined = undefined
try {
2019-08-03 23:55:22 +02:00
// instantiate splash screen
2019-07-23 21:53:59 +02:00
splash = new Splash()
} catch {}
try {
2019-08-03 23:55:22 +02:00
// import main app
2019-07-23 21:53:59 +02:00
const app = await import('./main')
2019-08-03 23:55:22 +02:00
// wait for app to start
2019-07-23 21:53:59 +02:00
await app.start()
} catch (error) {
2019-08-03 23:55:22 +02:00
// show the error to the client
2019-07-23 21:53:59 +02:00
if (splash) splash.setError(error)
2019-08-03 23:55:22 +02:00
// log the error to the console
2019-07-23 21:53:59 +02:00
console.error(error.stack || error)
return
}
2019-08-03 23:55:22 +02:00
// hide splash screen if it exists
2019-07-23 21:53:59 +02:00
if (splash) {
splash.fade()
}
}
2019-08-03 23:55:22 +02:00
// Call entry
2019-07-23 21:53:59 +02:00
main().catch(error => {
2019-08-03 23:55:22 +02:00
// if the error handling error has an error, log that error
2019-07-23 21:53:59 +02:00
console.error('Error loading app', error)
})