1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-20 09:01:50 +03:00
tabby/app/lib/index.ts

70 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-07-27 10:59:35 +03:00
import 'v8-compile-cache'
import './portable'
2021-01-01 20:25:54 +03:00
import 'source-map-support/register'
2019-11-26 17:51:31 +03:00
import './sentry'
import './lru'
import { app, ipcMain, Menu } from 'electron'
import { parseArgs } from './cli'
import { Application } from './app'
2019-05-24 21:46:44 +03:00
import electronDebug = require('electron-debug')
2021-06-30 00:57:04 +03:00
if (!process.env.TABBY_PLUGINS) {
process.env.TABBY_PLUGINS = ''
}
const application = new Application()
ipcMain.on('app:new-window', () => {
application.newWindow()
})
app.on('activate', () => {
if (!application.hasWindows()) {
application.newWindow()
} else {
application.focus()
}
})
process.on('uncaughtException' as any, err => {
console.log(err)
application.broadcast('uncaughtException', err)
})
app.on('second-instance', (_event, argv, cwd) => {
application.handleSecondInstance(argv, cwd)
})
const argv = parseArgs(process.argv, process.cwd())
if (!app.requestSingleInstanceLock()) {
app.quit()
2019-08-07 16:10:00 +03:00
app.exit(0)
}
if (argv.d) {
2019-05-24 22:19:08 +03:00
electronDebug({
isEnabled: true,
showDevTools: true,
2019-11-26 17:51:31 +03:00
devToolsMode: 'undocked',
2019-05-24 22:19:08 +03:00
})
}
app.on('ready', async () => {
2018-09-05 11:24:16 +03:00
if (process.platform === 'darwin') {
app.dock.setMenu(Menu.buildFromTemplate([
{
label: 'New window',
click () {
this.app.newWindow()
2020-02-05 15:16:31 +03:00
},
},
2018-09-05 11:24:16 +03:00
]))
}
application.init()
const window = await application.newWindow({ hidden: argv.hidden })
await window.ready
window.passCliArguments(process.argv, process.cwd(), false)
})