1
0
mirror of https://github.com/Eugeny/tabby.git synced 2025-08-16 14:21:53 +00:00
Files
.github
.vscode
.well-known
app
assets
lib
app.ts
cli.ts
config.ts
index.ts
lru.ts
pluginManager.ts
portable.ts
pty.ts
sentry.ts
utfSplitter.ts
window.ts
patches
src
dev-app-update.yml
index.pug
package.json
tsconfig.json
tsconfig.main.json
webpack.config.main.mjs
webpack.config.mjs
yarn.lock
build
docs
extras
locale
patches
scripts
snap
tabby-community-color-schemes
tabby-core
tabby-electron
tabby-linkifier
tabby-local
tabby-plugin-manager
tabby-serial
tabby-settings
tabby-ssh
tabby-telnet
tabby-terminal
tabby-uac
tabby-web
tabby-web-demo
web
.all-contributorsrc
.editorconfig
.env
.eslintrc.yml
.gitignore
.mergify.yml
.pug-lintrc.js
CODE_OF_CONDUCT.md
HACKING.md
LICENSE
README.de-DE.md
README.es-ES.md
README.id-ID.md
README.it-IT.md
README.ja-JP.md
README.ko-KR.md
README.md
README.pl-PL.md
README.pt-BR.md
README.ru-RU.md
README.zh-CN.md
electron-builder.yml
firebase.json
package.json
tsconfig.json
typedoc.mjs
webpack.config.mjs
webpack.plugin.config.mjs
yarn.lock
tabby/app/lib/index.ts
2024-08-03 10:31:19 +02:00

91 lines
2.0 KiB
TypeScript

import { app, ipcMain, Menu, dialog } from 'electron'
// set userData Path on portable version
import './portable'
// set defaults of environment variables
import 'dotenv/config'
process.env.TABBY_PLUGINS ??= ''
process.env.TABBY_CONFIG_DIRECTORY ??= app.getPath('userData')
import 'v8-compile-cache'
import 'source-map-support/register'
import './sentry'
import './lru'
import { parseArgs } from './cli'
import { Application } from './app'
import electronDebug = require('electron-debug')
import { loadConfig } from './config'
const argv = parseArgs(process.argv, process.cwd())
// eslint-disable-next-line @typescript-eslint/init-declarations
let configStore: any
try {
configStore = loadConfig()
} catch (err) {
dialog.showErrorBox('Could not read config', err.message)
app.exit(1)
}
process.mainModule = module
const application = new Application(configStore)
ipcMain.on('app:new-window', () => {
application.newWindow()
})
process.on('uncaughtException' as any, err => {
console.log(err)
application.broadcast('uncaughtException', err)
})
if (argv.d) {
electronDebug({
isEnabled: true,
showDevTools: true,
devToolsMode: 'undocked',
})
}
app.on('activate', async () => {
if (!application.hasWindows()) {
application.newWindow()
} else {
application.focus()
}
})
app.on('second-instance', async (_event, newArgv, cwd) => {
application.handleSecondInstance(newArgv, cwd)
})
if (!app.requestSingleInstanceLock()) {
app.quit()
app.exit(0)
}
app.on('ready', async () => {
if (process.platform === 'darwin') {
app.dock.setMenu(Menu.buildFromTemplate([
{
label: 'New window',
click () {
this.app.newWindow()
},
},
]))
}
application.init()
const window = await application.newWindow({ hidden: argv.hidden })
await window.ready
window.passCliArguments(process.argv, process.cwd(), false)
window.focus()
})