Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

bump version #35

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions applicationMenu.js
Original file line number Diff line number Diff line change
@@ -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) => {

Expand Down Expand Up @@ -31,7 +30,7 @@ const template = [
label: 'Open Folder',
click: async () => {
selectFolder().then((folder) => {
setFolder(sharedFolderClient, folder)
sharedFolderClient(folder)
}).catch(console.log)
}
},
Expand Down
63 changes: 51 additions & 12 deletions main.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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({
Expand All @@ -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/*']
Expand All @@ -55,7 +55,7 @@ function createWindow () {
})

win.webContents.session.webRequest.onErrorOccurred((details) => {
console.error(details)
// console.error(details)
})
}

Expand All @@ -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)
}
Expand Down
Loading