Repository navigation
Expand file tree
/
Copy pathbackground-process.js
More file actions
84 lines (64 loc) · 2.52 KB
/
Copy pathbackground-process.js
File metadata and controls
84 lines (64 loc) · 2.52 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Error.stackTraceLimit = Infinity;
// This is main process of Electron, started as first thing when your
// app starts. This script is running through entire life of your application.
// It doesn't have any windows which you can see on screen, but we can open
// window from here.
import { app, Menu, protocol } from 'electron'
import * as beakerBrowser from './background-process/browser'
import * as webAPIs from './background-process/web-apis'
import * as windows from './background-process/ui/windows'
import buildWindowMenu from './background-process/ui/window-menu'
import registerContextMenu from './background-process/ui/context-menu'
import * as downloads from './background-process/ui/downloads'
import * as permissions from './background-process/ui/permissions'
import * as archives from './background-process/dbs/archives'
import * as settings from './background-process/dbs/settings'
import * as sitedata from './background-process/dbs/sitedata'
import * as profileDataDb from './background-process/dbs/profile-data-db'
import * as beakerProtocol from './background-process/protocols/beaker'
import * as beakerFaviconProtocol from './background-process/protocols/beaker-favicon'
import * as datProtocol from './background-process/protocols/dat'
import * as openURL from './background-process/open-url'
// read config from env vars
if (process.env.beaker_user_data_path) {
console.log('User data path set by environment variables')
console.log('userData:', process.env.beaker_user_data_path)
app.setPath('userData', process.env.beaker_user_data_path)
}
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason)
})
// configure the protocols
protocol.registerStandardSchemes(['dat', 'beaker'], { secure: true })
app.on('ready', function () {
// databases
archives.setup()
settings.setup()
sitedata.setup()
profileDataDb.setup()
// base
beakerBrowser.setup()
// ui
Menu.setApplicationMenu(Menu.buildFromTemplate(buildWindowMenu()))
registerContextMenu()
windows.setup()
downloads.setup()
permissions.setup()
// protocols
beakerProtocol.setup()
beakerFaviconProtocol.setup()
datProtocol.setup()
// configure chromium's permissions for the protocols
protocol.registerServiceWorkerSchemes(['dat', 'app'])
// web APIs
webAPIs.setup()
// listen OSX open-url event
openURL.setup()
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin')
app.quit()
})
app.on('open-url', function (e, url) {
openURL.open(url)
})