-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.es
73 lines (64 loc) · 1.87 KB
/
index.es
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
import _ from 'lodash'
import { join } from 'path-extra'
import { readJsonSync } from 'fs-extra'
import {} from './devtools'
import { NavyAlbumRoot as reactClass } from './ui'
import { loadPState } from './p-state'
import { globalSubscribe, globalUnsubscribe } from './observers'
import { loadMasterDataFile } from './store/ext-root/master'
import {
reducer,
boundActionCreators as bac,
initState,
} from './store'
import { registerIpc, unregisterIpc } from './ipc'
const windowMode = true
const pluginDidLoad = () => {
globalSubscribe()
registerIpc()
setTimeout(() => {
// start loading p-state
let newUiState = {}
let newGameUpdate = initState.gameUpdate
let newDebuffInfo = {}
try {
const pState = loadPState()
if (pState !== null && ('ui' in pState))
newUiState = pState.ui
if (pState !== null && ('gameUpdate' in pState))
newGameUpdate = pState.gameUpdate
if (pState !== null && ('debuffInfo' in pState))
newDebuffInfo = pState.debuffInfo
} catch (e) {
console.error('error while initializing', e)
} finally {
bac.uiReady(newUiState)
// now make sure that we always have gameUpdate.digest available
// before setting the ready flag
if (!newGameUpdate.digest) {
newGameUpdate.digest =
readJsonSync(join(__dirname,'assets','default-digest.json'))
}
bac.gameUpdateReady(newGameUpdate)
if (_.isEmpty(newDebuffInfo)) {
newDebuffInfo = readJsonSync(join(__dirname,'assets','default-debuff-info.json'))
}
bac.debuffInfoModify(() => newDebuffInfo)
setTimeout(() => {
const mstData = loadMasterDataFile()
bac.masterLoadFile(mstData)
})
}
})
}
const pluginWillUnload = () => {
unregisterIpc()
globalUnsubscribe()
}
export {
reducer,
pluginDidLoad,
pluginWillUnload,
reactClass,
windowMode,
}