diff --git a/lib/connection.coffee b/lib/connection.coffee deleted file mode 100644 index 40463175..00000000 --- a/lib/connection.coffee +++ /dev/null @@ -1,52 +0,0 @@ -{time} = require './misc' -externalTerminal = require './connection/terminal' - -module.exports = - IPC: require './connection/ipc' - messages: require './connection/messages' - client: require './connection/client' - local: require './connection/local' - terminal: require './connection/terminal' - - activate: -> - @messages.activate() - @client.activate() - @client.boot = => @boot() - @local.activate() - @booting = false - - deactivate: -> - @client.deactivate() - - consumeInk: (ink) -> - @IPC.consumeInk ink - @ink = ink - - consumeGetServerConfig: (getconf) -> - @local.consumeGetServerConfig(getconf) - - consumeGetServerName: (name) -> - @local.consumeGetServerName(name) - - _boot: (provider) -> - if not @client.isActive() and not @booting - @booting = true - @client.setBootMode(provider) - if provider is 'External Terminal' - p = externalTerminal.connectedRepl() - else - p = @local.start(provider) - - if @ink? - @ink.Opener.allowRemoteFiles(provider == 'Remote') - p.then => - @booting = false - p.catch => - @booting = false - time "Julia Boot", @client.import('ping')() - - bootRemote: -> - @_boot('Remote') - - boot: -> - @_boot(atom.config.get('julia-client.juliaOptions.bootMode')) diff --git a/lib/connection.js b/lib/connection.js new file mode 100644 index 00000000..b4651886 --- /dev/null +++ b/lib/connection.js @@ -0,0 +1,76 @@ +'use babel' +import { time } from './misc'; +import externalTerminal from './connection/terminal'; + +import IPC from './connection/ipc' +import messages from './connection/messages' +import client from './connection/client' +import local from './connection/local' +import terminal from './connection/terminal' + +let booting = false; +let ink; + +export function activate() { + messages.activate(); + client.activate(); + client.boot = () => boot(); + local.activate(); + booting = false; +} + +export function deactivate() { + client.deactivate(); +} + +export function consumeInk(ink_in) { + ink = ink_in; + IPC.consumeInk(ink); +} + +export function consumeGetServerConfig(getconf) { + local.consumeGetServerConfig(getconf); +} + +export function consumeGetServerName(name) { + local.consumeGetServerName(name); +} + +export function _boot(provider) { + if (!client.isActive() && !booting) { + booting = true; + client.setBootMode(provider); + + let p; + if (provider === 'External Terminal') { + p = externalTerminal.connectedRepl(); + } else { + p = local.start(provider); + } + + if (ink) { + ink.Opener.allowRemoteFiles(provider === 'Remote'); + } + p.then(() => { + booting = false; + }); + p.catch(() => { + booting = false; + }); + return time("Julia Boot", client.import('ping')()); + } +} + +export function bootRemote() { + return _boot('Remote'); +} + +export function boot() { + return _boot(atom.config.get('julia-client.juliaOptions.bootMode')); +} + +exports.IPC = IPC +exports.messages = messages +exports.client = client +exports.local = local +exports.terminal = terminal diff --git a/lib/package/config.coffee b/lib/package/config.coffee index 24cc61c8..0e934fb1 100644 --- a/lib/package/config.coffee +++ b/lib/package/config.coffee @@ -1,4 +1,4 @@ -{terminal} = require '../connection' +terminal = require '../connection/terminal' config = juliaPath: diff --git a/lib/runtime/debugger.js b/lib/runtime/debugger.js index 03bed5e7..253fb973 100644 --- a/lib/runtime/debugger.js +++ b/lib/runtime/debugger.js @@ -3,8 +3,7 @@ import { CompositeDisposable } from 'atom' import { views } from '../ui' -import { client } from '../connection' -import connection from '../connection' +import { client, boot as connection_boot } from '../connection' import { blocks, cells, paths } from '../misc' import modules from './modules' @@ -273,53 +272,53 @@ export function debugBlock(shouldStep, cell) { } export function clearbps() { - connection.boot() + connection_boot() breakpoints.clear() if (client.isActive()) client.import('clearbps')() } function toggleJuliaBP (item) { - connection.boot() + connection_boot() return client.import('toggleBP')(item) } function clearJulia () { - connection.boot() + connection_boot() return client.import('clearbps')() } function toggleUncaughtJulia () { - connection.boot() + connection_boot() return client.import('toggleUncaught')() } function toggleExceptionJulia () { - connection.boot() + connection_boot() return client.import('toggleException')() } function toggleCompiled () { - connection.boot() + connection_boot() return client.import('toggleCompiled')() } function getBreakpoints () { - connection.boot() + connection_boot() return client.import('getBreakpoints')() } function addArgsJulia (args) { - connection.boot() + connection_boot() return client.import('addArgs')(args) } function toggleAllActiveJulia (args) { - connection.boot() + connection_boot() return client.import('toggleAllActiveBP')(args) } function toggleActiveJulia (item) { - connection.boot() + connection_boot() return client.import('toggleActiveBP')(item) } function addCondition (item, cond) { - connection.boot() + connection_boot() return client.import('addConditionById')(item, cond) } function setLevel (level) { - connection.boot() + connection_boot() return client.import('setStackLevel')(level) } diff --git a/lib/runtime/evaluation.coffee b/lib/runtime/evaluation.coffee index b9c68781..db9f4428 100644 --- a/lib/runtime/evaluation.coffee +++ b/lib/runtime/evaluation.coffee @@ -2,7 +2,7 @@ path = require 'path' {dialog, BrowserWindow} = require('electron').remote -{client} = require '../connection' +client = require '../connection/client' {notifications, views, selector, docpane} = require '../ui' {paths, blocks, cells, words, weave} = require '../misc' {processLinks} = require '../ui/docs' diff --git a/lib/runtime/modules.coffee b/lib/runtime/modules.coffee index 09f98ecd..9a44b90a 100644 --- a/lib/runtime/modules.coffee +++ b/lib/runtime/modules.coffee @@ -3,7 +3,7 @@ {CompositeDisposable, Disposable, Emitter} = require 'atom' {debounce} = require 'underscore-plus' -{client} = require '../connection' +client = require '../connection/client' {show} = require '../ui/selector' {module: getmodule, allmodules, ismodule} = client.import ['module', 'allmodules', 'ismodule'] diff --git a/lib/runtime/workspace.coffee b/lib/runtime/workspace.coffee index e4e9d172..66903421 100644 --- a/lib/runtime/workspace.coffee +++ b/lib/runtime/workspace.coffee @@ -1,6 +1,6 @@ {CompositeDisposable} = require 'atom' -{client} = require '../connection' +client = require '../connection/client' {views} = require '../ui' goto = require './goto' modules = require './modules' diff --git a/lib/ui/progress.coffee b/lib/ui/progress.coffee index d5466317..d2089c3d 100644 --- a/lib/ui/progress.coffee +++ b/lib/ui/progress.coffee @@ -1,5 +1,5 @@ {CompositeDisposable} = require 'atom' -{client} = require '../connection' +client = require '../connection/client' {formatTimePeriod} = require '../misc' module.exports = diff --git a/lib/ui/views.coffee b/lib/ui/views.coffee index dc278d92..ab12ec4b 100644 --- a/lib/ui/views.coffee +++ b/lib/ui/views.coffee @@ -1,6 +1,6 @@ Highlighter = require './highlighter' -{client} = require '../connection' +client = require '../connection/client' {once} = require '../misc' getlazy = client.import 'getlazy'