1+ 'use strict' ;
2+
3+ const { rulesHandler } = require ( './src/rules/rules-handler' )
4+ const waitFor = require ( './src/wait-for' )
5+
6+ const init = { }
7+ const terminal = { }
8+
9+ exports . onApp = ( { config } ) =>
10+ Object . assign ( init , config . getConfig ( ) . init )
11+
12+ exports . getTabProps = ( uid , parentProps , props ) =>
13+ Object . assign ( terminal , uid , { tabs : parentProps . tabs } ) &&
14+ Object . assign ( { } , props )
15+
16+ exports . reduceTermGroups = reducer =>
17+ Object . assign ( terminal , reducer . termGroups ) && reducer
18+
19+ exports . middleware = store => next => action => {
20+ if ( action . type === 'SESSION_ADD' )
21+ Object . assign ( terminal , { splitDirection : action . splitDirection } )
22+
23+ next ( action )
24+ }
25+
26+ exports . onWindow = app =>
27+ app . rpc . on ( 'execute commands' , ( { uid, terminal } ) =>
28+ Object . keys ( init ) . map ( key =>
29+ init [ key ] . commands . map ( cmd =>
30+ rulesHandler ( { init, key, cmd, app, uid, terminal } ) )
31+ )
32+ )
33+
34+ exports . onRendererWindow = app =>
35+ waitFor ( app , 'rpc' , rpc =>
36+ rpc . on ( 'session add' , ( { uid } ) =>
37+ rpc . emit ( 'execute commands' , { uid, terminal } )
38+ )
39+ )
0 commit comments