-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathindex.js
45 lines (37 loc) · 1.44 KB
/
index.js
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
import * as Sentry from '@sentry/electron'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'
import App from './App'
import link from '../../resources/link'
import appStore from '../store'
Sentry.init({ dsn: 'https://7b09a85b26924609bef5882387e2c4dc@o1204372.ingest.sentry.io/6331069' })
document.addEventListener('dragover', (e) => e.preventDefault())
document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
} // eslint-disable-line
}
function AppComponent() {
return <App />
}
link.rpc('getFrameId', (err, frameId) => {
if (err) return console.error('Could not get frameId from main', err)
window.frameId = frameId
link.rpc('getState', (err, state) => {
if (err) return console.error('Could not get initial state from main')
const store = appStore(state)
window.store = store
store.observer(() => {
document.body.classList.remove('dark', 'light')
document.body.classList.add('clip', store('main.colorway'))
setTimeout(() => {
document.body.classList.remove('clip')
}, 100)
})
const root = createRoot(document.getElementById('dapp'))
const Dapp = Restore.connect(AppComponent, store)
root.render(<Dapp />)
})
})
document.addEventListener('contextmenu', (e) => link.send('*:contextmenu', e.clientX, e.clientY))