diff --git a/applicationMenu.js b/applicationMenu.js index d916d31..01b86a5 100644 --- a/applicationMenu.js +++ b/applicationMenu.js @@ -1,7 +1,6 @@ const {Menu, shell, app} = require('electron') const os = require('os') const selectFolder = require('./selectFolder') -const setFolder = require('./setFolder') module.exports = (sharedFolderClient) => { @@ -31,7 +30,7 @@ const template = [ label: 'Open Folder', click: async () => { selectFolder().then((folder) => { - setFolder(sharedFolderClient, folder) + sharedFolderClient(folder) }).catch(console.log) } }, diff --git a/main.js b/main.js index a132266..ee65b14 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -const remixd = require('remixd') +const remixd = require('@remix-project/remixd') const path = require('path') const os = require('os') const IPFS = require('ipfs') @@ -7,18 +7,19 @@ const IPFSGateway = require('ipfs-http-gateway') const { version } = require('./package.json') const applicationMenu = require('./applicationMenu') const { app, BrowserWindow, shell } = require('electron') -const { AppManager, registerPackageProtocol } = require('@philipplgh/electron-app-manager') +const { AppManager, registerPackageProtocol } = require('electron-app-manager') const cacheDir = path.join(os.homedir(), '.cache_remix_ide') registerPackageProtocol(cacheDir) +const remixIdeUrl = 'package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod' + console.log('running', version) const updater = new AppManager({ repository: 'https://github.com/ethereum/remix-desktop', auto: true, electron: true }) -const sharedFolderClient = new remixd.services.sharedFolder() function createWindow () { let win = new BrowserWindow({ @@ -29,13 +30,12 @@ function createWindow () { }, icon: path.join(__dirname, 'build/icon.png') }) - applicationMenu(sharedFolderClient) win.webContents.on('new-window', function(e, url) { e.preventDefault(); shell.openExternal(url); }) win.loadURL('package://github.com/ethereum/remix-project') - + // Modify the user agent for all requests to the following urls. const filter = { urls: ['https://*.dyn.plugin.remixproject.org/ipfs/*'] @@ -55,7 +55,7 @@ function createWindow () { }) win.webContents.session.webRequest.onErrorOccurred((details) => { - console.error(details) + // console.error(details) }) } @@ -65,16 +65,55 @@ app.on('ready', () => { ipfsStart() }) +let sharedFolderClient = new remixd.services.sharedFolder() +let gitClient = new remixd.services.GitClient() +const services = { + git: () => { + gitClient.options.customApi = {} + return gitClient + }, + folder: () => { + sharedFolderClient.options.customApi = {} + return sharedFolderClient + } +} + +applicationMenu((folder) => { + console.log('set folder', folder) + sharedFolderClient.sharedFolder(folder, false) + sharedFolderClient.setupNotifications(folder) + gitClient.sharedFolder(folder, false) +}) + +const ports = { + git: 65521, + folder: 65520 +} + +function startService (service, callback) { + try { + const socket = new remixd.Websocket(ports[service], { remixIdeUrl }, () => services[service]()) + socket.start(callback) + } catch (e) { + console.error(e) + } +} + let remixdStart = () => { - const remixIdeUrl = 'package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod' console.log('start shared folder service') + const currentFolder = process.cwd() try { - const websocketHandler = new remixd.Websocket(65520, { remixIdeUrl }, sharedFolderClient) - - websocketHandler.start((ws) => { - console.log('set websocket') - sharedFolderClient.setWebSocket(ws) + startService('folder', (ws, client) => { + client.setWebSocket(ws) + client.sharedFolder(currentFolder, false) + client.setupNotifications(currentFolder) + }) + + startService('git', (ws, client) => { + client.setWebSocket(ws) + client.sharedFolder(currentFolder, false) }) + } catch (error) { throw new Error(error) } diff --git a/package-lock.json b/package-lock.json index a181acb..36e153a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -482,20 +482,6 @@ "@types/node": ">= 8" } }, - "@philipplgh/electron-app-manager": { - "version": "0.55.0", - "resolved": "https://registry.npmjs.org/@philipplgh/electron-app-manager/-/electron-app-manager-0.55.0.tgz", - "integrity": "sha512-+im/3sU4Ogj591U2m+/qoitCQkJKi2UA90Knv3q/uhlgSSlXFuUV6mtLa9+9QGjWT69sc4Zq0mJfhEiNSgxSdA==", - "requires": { - "@octokit/rest": "^16.27.0", - "electron-updater": "4.1.2", - "ethpkg": "^0.3.0", - "openpgp": "^4.4.5", - "semver": "^5.6.0", - "tar-stream": "^1.6.2", - "xml2js": "^0.4.19" - } - }, "@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -550,25 +536,83 @@ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" }, - "@remixproject/plugin": { - "version": "0.3.0-beta.5", - "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.0-beta.5.tgz", - "integrity": "sha512-mQgXUhGNc+tQGIIFw7OaBaH7sZTBvDk8Gf4fS1NXhO5ilvykw9TXv5LXWoWkJCWQlKGuUTWd+U1XNpm5dPD3ag==" - }, - "@remixproject/plugin-api": { - "version": "0.3.0-beta.5", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.0-beta.5.tgz", - "integrity": "sha512-C1fuISsne3sfA61k1rx6qU9ZgubyP8SdNKinzeYvXg4XAm1DwoHQlzjq/WYmjOFx1NZhyMGK8ySBp0VcjAMc/Q==" - }, - "@remixproject/plugin-utils": { - "version": "0.3.0-beta.5", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.0-beta.5.tgz", - "integrity": "sha512-+gnfuSUimCxUTRxfTGu+mwI5U6EPUx2A2ANObaZzX8f17nhSW5NWw2vWKauZPSv2PWQoIukYzrmG/kogEe3Cyw==" - }, - "@remixproject/plugin-ws": { - "version": "0.3.0-beta.5", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.0-beta.5.tgz", - "integrity": "sha512-ECXn9xsLCW4lMeiFbAWj8q311vOR5cx8pMl5w8FwevRP2Sk8EtRV90H5CcEDJpDQqPRLjHa9je0n5/pk4wcjTw==" + "@remix-project/remixd": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@remix-project/remixd/-/remixd-0.3.0.tgz", + "integrity": "sha512-2dyxWfzgYIDYOimlh8knrfkg+nj6OYcIuQWYqop7r1w0FWg9FRuUMj3oEleqiOJo/bYnzSAYFjtDZULpZybGxA==", + "requires": { + "@remixproject/plugin": "^0.3.3", + "@remixproject/plugin-api": "^0.3.3", + "@remixproject/plugin-utils": "^0.3.3", + "@remixproject/plugin-ws": "^0.3.3", + "axios": "^0.20.0", + "chokidar": "^2.1.8", + "commander": "^2.20.3", + "fs-extra": "^3.0.1", + "isbinaryfile": "^3.0.2", + "ws": "^7.3.0" + }, + "dependencies": { + "@remixproject/plugin": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.8.tgz", + "integrity": "sha512-plWc4/GD6E0Bt8nX5gb8wcmOcSDFKtYZERj+3bs0W4b4mdnFDA0RdL4yWtFz3XW6yFXk5HJoPAA3QSJWv1v6XA==", + "requires": { + "@remixproject/plugin-api": "0.3.8", + "@remixproject/plugin-utils": "0.3.8", + "events": "3.2.0" + } + }, + "@remixproject/plugin-api": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.8.tgz", + "integrity": "sha512-M5ymiIzrz3erwsMMhf6odOr8DehuptHUuxJK5vtJM1mHAtsTImsYV9Ylqo3BHvmvrAL4jq0Vvqd2MhJaDG9Sqg==", + "requires": { + "@remixproject/plugin-utils": "0.3.8" + } + }, + "@remixproject/plugin-utils": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.8.tgz", + "integrity": "sha512-tI7PNHCwkoF2LzmZlQy1Lw0T/f05dURR+pjH+usqUAnyoVRgtgOvbHq18HLSyZN9xz6E1YNotuE4DFT2VJTZ2A==", + "requires": { + "tslib": "2.0.1" + } + }, + "@remixproject/plugin-ws": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.8.tgz", + "integrity": "sha512-ngE45rkzPgHnlE3Y5EjpHxynWwlqFDPv7ybJiRGIgJgw8X4ExsgJj7B26/YmeWBRP6MQ6q/nIBTjI5y0dHemvg==", + "requires": { + "@remixproject/plugin": "0.3.8", + "@remixproject/plugin-api": "0.3.8", + "@remixproject/plugin-utils": "0.3.8" + } + }, + "fs-extra": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", + "integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^3.0.0", + "universalify": "^0.1.0" + } + }, + "jsonfile": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", + "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } + } }, "@sideway/address": { "version": "4.1.0", @@ -1043,6 +1087,14 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, + "axios": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", + "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "backo2": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", @@ -2528,6 +2580,20 @@ } } }, + "electron-app-manager": { + "version": "0.57.0", + "resolved": "https://registry.npmjs.org/electron-app-manager/-/electron-app-manager-0.57.0.tgz", + "integrity": "sha512-nZ2jQM9JS98lao7uI9FdcZ4gL1UT77xm66aVZa+eJq5LJtEjhkQmT2olYRGV02CyMg8Zt1Fy+8cua07snq4Diw==", + "requires": { + "@octokit/rest": "^16.27.0", + "electron-updater": "4.1.2", + "ethpkg": "^0.3.0", + "openpgp": "^4.4.5", + "semver": "^5.6.0", + "tar-stream": "^1.6.2", + "xml2js": "^0.4.19" + } + }, "electron-builder": { "version": "21.2.0", "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-21.2.0.tgz", @@ -3616,6 +3682,11 @@ "resolved": "https://registry.npmjs.org/fnv1a/-/fnv1a-1.0.1.tgz", "integrity": "sha1-kV4tbQI8Q9UiStn20qPEFW9XEvU=" }, + "follow-redirects": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.2.tgz", + "integrity": "sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==" + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -8824,43 +8895,6 @@ "resolved": "https://registry.npmjs.org/relative-url/-/relative-url-1.0.2.tgz", "integrity": "sha1-0hxSpy1gYQGLzun5yfwQa/fWUoc=" }, - "remixd": { - "version": "0.2.3-alpha.7", - "resolved": "https://registry.npmjs.org/remixd/-/remixd-0.2.3-alpha.7.tgz", - "integrity": "sha512-fs5YmyZjP3t+JRk79bK3GR8kgJKfI7Zow2arA5xB0D499HXRxFbGaLtGrQiyiB/wUHyh9R0HIiD3EQT8AL5PQw==", - "requires": { - "@remixproject/plugin": "0.3.0-beta.5", - "@remixproject/plugin-api": "0.3.0-beta.5", - "@remixproject/plugin-utils": "0.3.0-beta.5", - "@remixproject/plugin-ws": "0.3.0-beta.5", - "chokidar": "^2.1.8", - "commander": "^2.20.3", - "fs-extra": "^3.0.1", - "isbinaryfile": "^3.0.2", - "tslib": "^2.0.1", - "ws": "^7.3.0" - }, - "dependencies": { - "fs-extra": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", - "integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=", - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^3.0.0", - "universalify": "^0.1.0" - } - }, - "jsonfile": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", - "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", - "requires": { - "graceful-fs": "^4.1.6" - } - } - } - }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -10137,11 +10171,6 @@ "utf8-byte-length": "^1.0.1" } }, - "tslib": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", - "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==" - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index e0a6039..d4540e8 100644 --- a/package.json +++ b/package.json @@ -71,9 +71,9 @@ } }, "dependencies": { - "@philipplgh/electron-app-manager": "^0.55.0", + "electron-app-manager": "0.57.0", "ipfs": "^0.52.2", "ipfs-http-gateway": "^0.1.3", - "remixd": "^0.2.3-alpha.4" + "@remix-project/remixd": "^0.3.0" } } diff --git a/setFolder.js b/setFolder.js deleted file mode 100644 index e48f366..0000000 --- a/setFolder.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = (sharedFolderClient, folder) => { - console.log('set folder', folder, sharedFolderClient.sharedFolder) - sharedFolderClient.sharedFolder(folder, false) - sharedFolderClient.setupNotifications(folder) -}