|
|
@ -4,6 +4,7 @@ var async = require('async') |
|
|
|
var remixLib = require('remix-lib') |
|
|
|
var remixLib = require('remix-lib') |
|
|
|
var EventManager = require('../lib/events') |
|
|
|
var EventManager = require('../lib/events') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CompilerImport = require('../app/compiler/compiler-imports') |
|
|
|
var executionContext = require('../execution-context') |
|
|
|
var executionContext = require('../execution-context') |
|
|
|
var toolTip = require('../app/ui/tooltip') |
|
|
|
var toolTip = require('../app/ui/tooltip') |
|
|
|
var globalRegistry = require('../global/registry') |
|
|
|
var globalRegistry = require('../global/registry') |
|
|
@ -20,6 +21,7 @@ class CmdInterpreterAPI { |
|
|
|
self._components.registry = localRegistry || globalRegistry |
|
|
|
self._components.registry = localRegistry || globalRegistry |
|
|
|
self._components.terminal = terminal |
|
|
|
self._components.terminal = terminal |
|
|
|
self._components.sourceHighlighter = new SourceHighlighter() |
|
|
|
self._components.sourceHighlighter = new SourceHighlighter() |
|
|
|
|
|
|
|
self._components.fileImport = new CompilerImport() |
|
|
|
self._deps = { |
|
|
|
self._deps = { |
|
|
|
app: self._components.registry.get('app').api, |
|
|
|
app: self._components.registry.get('app').api, |
|
|
|
fileManager: self._components.registry.get('filemanager').api, |
|
|
|
fileManager: self._components.registry.get('filemanager').api, |
|
|
@ -141,20 +143,32 @@ class CmdInterpreterAPI { |
|
|
|
} |
|
|
|
} |
|
|
|
loadurl (url, cb) { |
|
|
|
loadurl (url, cb) { |
|
|
|
const self = this |
|
|
|
const self = this |
|
|
|
self._deps.app.importExternal(url, (err, content) => { |
|
|
|
self._components.fileImport.import(url, |
|
|
|
|
|
|
|
(loadingMsg) => { toolTip(loadingMsg) }, |
|
|
|
|
|
|
|
(err, content, cleanUrl, type, url) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
toolTip(`Unable to load ${url}: ${err}`) |
|
|
|
toolTip(`Unable to load ${url}: ${err}`) |
|
|
|
if (cb) cb(err) |
|
|
|
if (cb) cb(err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
self._deps.fileManager.setFile(type + '/' + cleanUrl, content) |
|
|
|
try { |
|
|
|
try { |
|
|
|
content = JSON.parse(content) |
|
|
|
content = JSON.parse(content) |
|
|
|
async.eachOfSeries(content.sources, (value, file, callbackSource) => { |
|
|
|
async.eachOfSeries(content.sources, (value, file, callbackSource) => { |
|
|
|
var url = value.urls[0] // @TODO retrieve all other contents ?
|
|
|
|
var url = value.urls[0] // @TODO retrieve all other contents ?
|
|
|
|
self._deps.app.importExternal(url, (error, content) => { |
|
|
|
self._components.fileImport.import(url, |
|
|
|
|
|
|
|
(loadingMsg) => { toolTip(loadingMsg) }, |
|
|
|
|
|
|
|
async (error, content, cleanUrl, type, url) => { |
|
|
|
if (error) { |
|
|
|
if (error) { |
|
|
|
toolTip(`Cannot retrieve the content of ${url}: ${error}`) |
|
|
|
toolTip(`Cannot retrieve the content of ${url}: ${error}`) |
|
|
|
} |
|
|
|
return callbackSource(`Cannot retrieve the content of ${url}: ${error}`) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await self._deps.fileManager.setFile(type + '/' + cleanUrl, content) |
|
|
|
callbackSource() |
|
|
|
callbackSource() |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
callbackSource(e.message) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, (error) => { |
|
|
|
}, (error) => { |
|
|
|
if (cb) cb(error) |
|
|
|
if (cb) cb(error) |
|
|
|