|
| 1 | +'use babel' |
| 2 | +import { time } from './misc'; |
| 3 | +import externalTerminal from './connection/terminal'; |
| 4 | + |
| 5 | +export default { |
| 6 | + // TODO Fix all of these dynamic requires and circular dependencies |
| 7 | + IPC: require('./connection/ipc'), |
| 8 | + messages: require('./connection/messages'), |
| 9 | + client: require('./connection/client'), |
| 10 | + local: require('./connection/local'), |
| 11 | + terminal: require('./connection/terminal'), |
| 12 | + |
| 13 | + activate() { |
| 14 | + this.messages.activate(); |
| 15 | + this.client.activate(); |
| 16 | + this.client.boot = () => this.boot(); |
| 17 | + this.local.activate(); |
| 18 | + this.booting = false; |
| 19 | + }, |
| 20 | + |
| 21 | + deactivate() { |
| 22 | + this.client.deactivate(); |
| 23 | + }, |
| 24 | + |
| 25 | + consumeInk(ink) { |
| 26 | + this.IPC.consumeInk(ink); |
| 27 | + this.ink = ink; |
| 28 | + }, |
| 29 | + |
| 30 | + consumeGetServerConfig(getconf) { |
| 31 | + this.local.consumeGetServerConfig(getconf); |
| 32 | + }, |
| 33 | + |
| 34 | + consumeGetServerName(name) { |
| 35 | + this.local.consumeGetServerName(name); |
| 36 | + }, |
| 37 | + |
| 38 | + _boot(provider) { |
| 39 | + if (!this.client.isActive() && !this.booting) { |
| 40 | + this.booting = true; |
| 41 | + this.client.setBootMode(provider); |
| 42 | + |
| 43 | + let p; |
| 44 | + if (provider === 'External Terminal') { |
| 45 | + p = externalTerminal.connectedRepl(); |
| 46 | + } else { |
| 47 | + p = this.local.start(provider); |
| 48 | + } |
| 49 | + |
| 50 | + if (this.ink) { |
| 51 | + this.ink.Opener.allowRemoteFiles(provider === 'Remote'); |
| 52 | + } |
| 53 | + p.then(() => { |
| 54 | + this.booting = false; |
| 55 | + }); |
| 56 | + p.catch(() => { |
| 57 | + this.booting = false; |
| 58 | + }); |
| 59 | + return time("Julia Boot", this.client.import('ping')()); |
| 60 | + } |
| 61 | + }, |
| 62 | + |
| 63 | + bootRemote() { |
| 64 | + return this._boot('Remote'); |
| 65 | + }, |
| 66 | + |
| 67 | + boot() { |
| 68 | + return this._boot(atom.config.get('julia-client.juliaOptions.bootMode')); |
| 69 | + } |
| 70 | +}; |
0 commit comments