2016-07-13 12:44:24 -08:00
|
|
|
import rpc from './rpc';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { render } from 'react-dom';
|
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
import { init } from './actions/index';
|
|
|
|
|
import effects from './utils/effects';
|
|
|
|
|
import * as config from './utils/config';
|
|
|
|
|
import rootReducer from './reducers/index';
|
|
|
|
|
import * as plugins from './utils/plugins';
|
|
|
|
|
import * as uiActions from './actions/ui';
|
|
|
|
|
import forceUpdate from 'react-deep-force-update';
|
|
|
|
|
import * as updaterActions from './actions/updater';
|
|
|
|
|
import * as sessionActions from './actions/sessions';
|
|
|
|
|
import { createStore, applyMiddleware } from 'redux';
|
|
|
|
|
import HyperTermContainer from './containers/hyperterm';
|
|
|
|
|
import { loadConfig, reloadConfig } from './actions/config';
|
|
|
|
|
|
2016-07-13 21:19:32 -08:00
|
|
|
const store_ = createStore(
|
2016-07-13 12:44:24 -08:00
|
|
|
rootReducer,
|
|
|
|
|
applyMiddleware(
|
|
|
|
|
thunk,
|
|
|
|
|
plugins.middleware,
|
|
|
|
|
thunk,
|
|
|
|
|
effects
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2016-07-13 21:19:32 -08:00
|
|
|
window.__defineGetter__('store', () => store_);
|
|
|
|
|
window.__defineGetter__('rpc', () => rpc);
|
2016-07-16 10:54:21 -08:00
|
|
|
window.__defineGetter__('config', () => config);
|
|
|
|
|
window.__defineGetter__('plugins', () => plugins);
|
2016-07-13 12:44:24 -08:00
|
|
|
|
|
|
|
|
// initialize config
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(loadConfig(config.getConfig()));
|
2016-07-13 12:44:24 -08:00
|
|
|
config.subscribe(() => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(reloadConfig(config.getConfig()));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// initialize communication with main electron process
|
|
|
|
|
// and subscribe to all user intents for example from menues
|
|
|
|
|
rpc.on('ready', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(init());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
2016-07-14 15:40:15 -08:00
|
|
|
rpc.on('session add', ({ uid, shell }) => {
|
|
|
|
|
store_.dispatch(sessionActions.addSession(uid, shell));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session data', ({ uid, data }) => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.addSessionData(uid, data));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session title', ({ uid, title }) => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.setSessionProcessTitle(uid, title));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session exit', ({ uid }) => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.sessionExit(uid));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session add req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.requestSession());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session close req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.userExitActiveSession());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('session clear req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(sessionActions.clearActiveSession());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('reset fontSize req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(uiActions.resetFontSize());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('increase fontSize req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(uiActions.increaseFontSize());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('decrease fontSize req', () => {
|
2016-07-13 21:37:46 -08:00
|
|
|
store_.dispatch(uiActions.decreaseFontSize());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('move left req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(uiActions.moveLeft());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('move right req', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(uiActions.moveRight());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('preferences', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(uiActions.showPreferences());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('update available', ({ releaseName, releaseNotes }) => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(updaterActions.updateAvailable(releaseName, releaseNotes));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const app = render(
|
2016-07-13 21:19:32 -08:00
|
|
|
<Provider store={ store_ }>
|
2016-07-13 12:44:24 -08:00
|
|
|
<HyperTermContainer />
|
|
|
|
|
</Provider>,
|
|
|
|
|
document.getElementById('mount')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
rpc.on('reload', () => {
|
|
|
|
|
plugins.reload();
|
|
|
|
|
forceUpdate(app);
|
|
|
|
|
});
|