2016-10-12 17:35:44 -08:00
|
|
|
import {webFrame} from 'electron';
|
2016-09-21 06:27:11 -08:00
|
|
|
import forceUpdate from 'react-deep-force-update';
|
|
|
|
|
import {Provider} from 'react-redux';
|
2016-07-13 12:44:24 -08:00
|
|
|
import React from 'react';
|
2016-09-21 06:27:11 -08:00
|
|
|
import {render} from 'react-dom';
|
|
|
|
|
|
|
|
|
|
import rpc from './rpc';
|
2016-10-25 04:53:15 -08:00
|
|
|
import init from './actions/index';
|
2016-07-13 12:44:24 -08:00
|
|
|
import * as config from './utils/config';
|
|
|
|
|
import * as plugins from './utils/plugins';
|
|
|
|
|
import * as uiActions from './actions/ui';
|
|
|
|
|
import * as updaterActions from './actions/updater';
|
|
|
|
|
import * as sessionActions from './actions/sessions';
|
2016-10-03 18:00:50 -08:00
|
|
|
import * as termGroupActions from './actions/term-groups';
|
2016-10-07 19:28:40 -08:00
|
|
|
import {addNotificationMessage} from './actions/notifications';
|
2016-09-21 06:27:11 -08:00
|
|
|
import {loadConfig, reloadConfig} from './actions/config';
|
2016-10-08 08:26:07 -08:00
|
|
|
import HyperContainer from './containers/hyper';
|
2016-09-21 18:29:23 -08:00
|
|
|
import configureStore from './store/configure-store';
|
2016-07-20 14:20:40 -08:00
|
|
|
|
|
|
|
|
// Disable pinch zoom
|
|
|
|
|
webFrame.setZoomLevelLimits(1, 1);
|
2016-07-13 12:44:24 -08:00
|
|
|
|
2016-09-21 14:11:42 -08:00
|
|
|
const store_ = configureStore();
|
2016-07-13 12:44:24 -08:00
|
|
|
|
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
|
2016-07-17 13:05:37 -08:00
|
|
|
// and subscribe to all user intents for example from menus
|
2016-07-13 12:44:24 -08:00
|
|
|
rpc.on('ready', () => {
|
2016-07-13 21:19:32 -08:00
|
|
|
store_.dispatch(init());
|
2016-07-19 10:30:57 -08:00
|
|
|
store_.dispatch(uiActions.setFontSmoothing());
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
2016-10-03 18:00:50 -08:00
|
|
|
rpc.on('session add', data => {
|
|
|
|
|
store_.dispatch(sessionActions.addSession(data));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -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
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
rpc.on('session data send', ({uid, data}) => {
|
2016-08-04 05:43:57 -08:00
|
|
|
store_.dispatch(sessionActions.sendSessionData(uid, data));
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
rpc.on('session exit', ({uid}) => {
|
2016-10-03 18:00:50 -08:00
|
|
|
store_.dispatch(termGroupActions.ptyExitTermGroup(uid));
|
2016-07-13 12:44:24 -08:00
|
|
|
});
|
|
|
|
|
|
2016-10-03 18:00:50 -08:00
|
|
|
rpc.on('termgroup close req', () => {
|
|
|
|
|
store_.dispatch(termGroupActions.exitActiveTermGroup());
|
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
|
|
|
});
|
|
|
|
|
|
2016-10-03 18:00:50 -08:00
|
|
|
rpc.on('termgroup add req', () => {
|
|
|
|
|
store_.dispatch(termGroupActions.requestTermGroup());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('split request horizontal', () => {
|
|
|
|
|
store_.dispatch(termGroupActions.requestHorizontalSplit());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('split request vertical', () => {
|
|
|
|
|
store_.dispatch(termGroupActions.requestVerticalSplit());
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
2016-10-03 18:00:50 -08:00
|
|
|
rpc.on('next pane req', () => {
|
|
|
|
|
store_.dispatch(uiActions.moveToNextPane());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rpc.on('prev pane req', () => {
|
|
|
|
|
store_.dispatch(uiActions.moveToPreviousPane());
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
rpc.on('open file', ({path}) => {
|
2016-08-01 14:52:21 -08:00
|
|
|
store_.dispatch(uiActions.openFile(path));
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -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
|
|
|
});
|
|
|
|
|
|
2016-07-19 10:30:57 -08:00
|
|
|
rpc.on('move', () => {
|
|
|
|
|
store_.dispatch(uiActions.windowMove());
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-07 19:28:40 -08:00
|
|
|
rpc.on('add notification', ({text, url, dismissable}) => {
|
|
|
|
|
store_.dispatch(addNotificationMessage(text, url, dismissable));
|
|
|
|
|
});
|
|
|
|
|
|
2016-07-13 12:44:24 -08:00
|
|
|
const app = render(
|
2016-09-21 06:27:11 -08:00
|
|
|
<Provider store={store_}>
|
2016-10-08 08:26:07 -08:00
|
|
|
<HyperContainer/>
|
2016-07-13 12:44:24 -08:00
|
|
|
</Provider>,
|
|
|
|
|
document.getElementById('mount')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
rpc.on('reload', () => {
|
|
|
|
|
plugins.reload();
|
|
|
|
|
forceUpdate(app);
|
|
|
|
|
});
|