diff --git a/ci/browser_tests.sh b/ci/browser_tests.sh index 9bf3c38917..5b4c27ce40 100755 --- a/ci/browser_tests.sh +++ b/ci/browser_tests.sh @@ -3,7 +3,6 @@ set -e setupRemixd () { - npm install remixd mkdir remixdSharedfolder cd remixdSharedfolder echo "contract test1 { function get () returns (uint) { return 8; }}" > contract1.sol @@ -15,7 +14,7 @@ setupRemixd () { cd .. echo 'sharing folder: ' echo $PWD - ./../node_modules/.bin/remixd -S $PWD & + node ../node_modules/remixd/src/main.js -s $PWD & cd .. } diff --git a/package.json b/package.json index 2909118ff4..acbbdc71ec 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "babel-plugin-transform-object-assign": "^6.22.0", "babel-plugin-yo-yoify": "^0.3.3", "babel-polyfill": "^6.22.0", + "babel-preset-env": "^1.6.1", "babel-preset-es2015": "^6.24.0", "babel-preset-stage-0": "^6.24.1", "babelify": "^7.3.0", @@ -44,7 +45,7 @@ "remix-debugger": "latest", "remix-lib": "latest", "remix-solidity": "latest", - "remixd": "^0.1.2", + "remixd": "git+https://github.com/ethereum/remixd.git", "rimraf": "^2.6.1", "selenium-standalone": "^6.0.1", "solc": "https://github.com/ethereum/solc-js", @@ -155,12 +156,12 @@ "nightwatch_remote_safari": "nightwatch --config nightwatch.js --env safari", "onchange": "onchange build/app.js -- npm-run-all lint", "prepublish": "mkdirp build; npm-run-all -ls downloadsolc build", - "remixd": "remixd -S ./contracts", + "remixd": "node ./node_modules/remixd/src/main.js -s ./contracts", "selenium": "execr --silent selenium-standalone start", "selenium-install": "selenium-standalone install", "serve": "execr --silent http-server .", "sourcemap": "exorcist --root ../ build/app.js.map > build/app.js", - "start": "npm-run-all -lpr serve watch onchange", + "start": "npm-run-all -lpr serve watch onchange remixd", "test": "npm run csslint; standard && node test/index.js", "test-browser": "npm-run-all -lpr selenium downloadsolc make-mock-compiler serve browsertest", "watch": "watchify src/index.js -dv -p browserify-reload -o build/app.js" diff --git a/src/app.js b/src/app.js index 22ff2aec10..f6dd0f8c3b 100644 --- a/src/app.js +++ b/src/app.js @@ -453,10 +453,15 @@ function run () { }) // insert ballot contract if there are no files available - if (!loadingFromGist && Object.keys(filesProviders['browser'].list()).length === 0) { - if (!filesProviders['browser'].set(examples.ballot.name, examples.ballot.content)) { - modalDialogCustom.alert('Failed to store example contract in browser. Remix will not work properly. Please ensure Remix has access to LocalStorage. Safari in Private mode is known not to work.') - } + if (!loadingFromGist) { + filesProviders['browser'].resolveDirectory('', (error, filesList) => { + if (error) console.error(error) + if (Object.keys(filesList).length === 0) { + if (!filesProviders['browser'].set(examples.ballot.name, examples.ballot.content)) { + modalDialogCustom.alert('Failed to store example contract in browser. Remix will not work properly. Please ensure Remix has access to LocalStorage. Safari in Private mode is known not to work.') + } + } + }) } window.syncStorage = chromeCloudStorageSync diff --git a/src/app/compiler/compiler.js b/src/app/compiler/compiler.js index f733e294b3..4082c5ee51 100644 --- a/src/app/compiler/compiler.js +++ b/src/app/compiler/compiler.js @@ -233,7 +233,7 @@ function Compiler (handleImportCall) { // Set a safe fallback until the new one is loaded setCompileJSON(function (source, optimize) { - compilationFinished({error: 'Compiler not yet loaded.'}) + compilationFinished({ error: { formattedMessage: 'Compiler not yet loaded.' } }) }) var newScript = document.createElement('script') diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index 882b14cb5a..cbf54a2255 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -80,7 +80,8 @@ class BasicReadOnlyExplorer { // } // } // - listAsTree () { + resolveDirectory (path, callback /* (error, filesList) => { } */) { + // path = '' + (path || '') function hashmapize (obj, path, val) { var nodes = path.split('/') var i = 0 @@ -107,7 +108,7 @@ class BasicReadOnlyExplorer { '/content': self.get(path) }) }) - return tree + callback(null, tree) } removePrefix (path) { diff --git a/src/app/files/browser-files.js b/src/app/files/browser-files.js index 4142d8df10..ecc42a083b 100644 --- a/src/app/files/browser-files.js +++ b/src/app/files/browser-files.js @@ -11,9 +11,7 @@ function Files (storage) { this.exists = function (path) { var unprefixedpath = this.removePrefix(path) // NOTE: ignore the config file - if (path === '.remix.config') { - return false - } + if (path === '.remix.config') return false return this.isReadOnly(unprefixedpath) || storage.exists(unprefixedpath) } @@ -105,29 +103,6 @@ function Files (storage) { return false } - this.list = function () { - var files = {} - - // add r/w files to the list - storage.keys().forEach((path) => { - // NOTE: as a temporary measure do not show the config file - if (path !== '.remix.config') { - files[this.type + '/' + path] = false - } - }) - - // add r/o files to the list - Object.keys(readonly).forEach((path) => { - files[this.type + '/' + path] = true - }) - - return files - } - - this.removePrefix = function (path) { - return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path - } - // // Tree model for files // { @@ -140,11 +115,12 @@ function Files (storage) { // } // } // - this.listAsTree = function () { + this.resolveDirectory = function (path, callback) { + var self = this + // path = '' + (path || '') function hashmapize (obj, path, val) { var nodes = path.split('/') var i = 0 - for (; i < nodes.length - 1; i++) { var node = nodes[i] if (obj[node] === undefined) { @@ -152,22 +128,34 @@ function Files (storage) { } obj = obj[node] } - obj[nodes[i]] = val } - + var filesList = {} + // add r/w filesList to the list + storage.keys().forEach((path) => { + // NOTE: as a temporary measure do not show the config file + if (path !== '.remix.config') { + filesList[self.type + '/' + path] = false + } + }) + // add r/o files to the list + Object.keys(readonly).forEach((path) => { + filesList[self.type + '/' + path] = true + }) var tree = {} - - var self = this // This does not include '.remix.config', because it is filtered // inside list(). - Object.keys(this.list()).forEach(function (path) { + Object.keys(filesList).forEach(function (path) { hashmapize(tree, path, { '/readonly': self.isReadOnly(path), '/content': self.get(path) }) }) - return tree + callback(null, tree) + } + + this.removePrefix = function (path) { + return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path } // rename .browser-solidity.json to .remix.config diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 2a6f938083..27ad8034be 100755 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -99,13 +99,13 @@ function fileExplorer (appAPI, files) { })) : undefined } }, - formatSelf: function (key, data) { + formatSelf: function (key, data, li) { var isRoot = data.path.indexOf('/') === -1 return yo`