commit
19ec6ca581
@ -1,8 +1,9 @@ |
||||
import React from 'react' |
||||
import ReactDOM from 'react-dom' |
||||
import { createRoot } from 'react-dom/client'; |
||||
import App from './app/app' |
||||
|
||||
ReactDOM.render( |
||||
<App />, |
||||
document.getElementById('root') |
||||
) |
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render(<App />); |
||||
} |
@ -1,6 +1,10 @@ |
||||
import React from 'react' |
||||
import ReactDOM from 'react-dom' |
||||
import { createRoot } from 'react-dom/client'; |
||||
|
||||
import App from './app/app' |
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root')) |
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render(<App />); |
||||
} |
||||
|
@ -1,11 +1,11 @@ |
||||
import React from 'react' |
||||
import ReactDOM from 'react-dom' |
||||
import { createRoot } from 'react-dom/client'; |
||||
import App from './app/App' |
||||
// import { Routes } from "./routes";
|
||||
|
||||
ReactDOM.render( |
||||
<React.StrictMode> |
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render(<React.StrictMode> |
||||
<App /> |
||||
</React.StrictMode>, |
||||
document.getElementById('root'), |
||||
) |
||||
</React.StrictMode>); |
||||
} |
||||
|
@ -1,10 +1,11 @@ |
||||
import React from 'react' |
||||
import ReactDOM from 'react-dom' |
||||
import { createRoot } from 'react-dom/client'; |
||||
import App from './app/App' |
||||
|
||||
ReactDOM.render( |
||||
<React.StrictMode> |
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render(<React.StrictMode> |
||||
<App /> |
||||
</React.StrictMode>, |
||||
document.getElementById('root') |
||||
) |
||||
</React.StrictMode>); |
||||
} |
||||
|
@ -1,11 +1,14 @@ |
||||
import {StrictMode} from 'react' |
||||
import React from 'react' |
||||
import * as ReactDOM from 'react-dom' |
||||
|
||||
import { createRoot } from 'react-dom/client'; |
||||
import App from './app/app' |
||||
|
||||
ReactDOM.render( |
||||
<StrictMode> |
||||
|
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render( |
||||
<App /> |
||||
</StrictMode>, |
||||
document.getElementById('root') |
||||
) |
||||
); |
||||
} |
||||
|
||||
|
@ -0,0 +1,35 @@ |
||||
import { NightwatchBrowser } from 'nightwatch' |
||||
import EventEmitter from 'events' |
||||
|
||||
class EnableClipBoard extends EventEmitter { |
||||
command (this: NightwatchBrowser, remember:boolean, accept: boolean): NightwatchBrowser { |
||||
const browser = this.api |
||||
|
||||
if(browser.browserName.indexOf('chrome') > -1){ |
||||
const chromeBrowser = (browser as any).chrome |
||||
chromeBrowser.setPermission('clipboard-read', 'granted') |
||||
chromeBrowser.setPermission('clipboard-write', 'granted') |
||||
// test it
|
||||
browser.executeAsyncScript(function (done) { |
||||
navigator.clipboard.writeText('test').then(function () { |
||||
navigator.clipboard.readText().then(function (text) { |
||||
console.log('Pasted content: ', text) |
||||
done(text) |
||||
}).catch(function (err) { |
||||
console.error('Failed to read clipboard contents: ', err) |
||||
done() |
||||
}) |
||||
}).catch(function (err) { |
||||
console.error('Failed to write to clipboard: ', err) |
||||
done() |
||||
}) |
||||
}, [], function (result) { |
||||
browser.assert.ok((result as any).value === 'test', 'copy paste should work') |
||||
}) |
||||
} |
||||
this.emit('complete') |
||||
return this |
||||
} |
||||
} |
||||
|
||||
module.exports = EnableClipBoard |
@ -0,0 +1,29 @@ |
||||
import {NightwatchBrowser} from 'nightwatch' |
||||
import EventEmitter from 'events' |
||||
|
||||
class HideToolTips extends EventEmitter { |
||||
command(this: NightwatchBrowser) { |
||||
browser |
||||
.perform((done) => { |
||||
browser.execute(function () { |
||||
// hide tooltips
|
||||
function addStyle(styleString) { |
||||
const style = document.createElement('style') |
||||
style.textContent = styleString |
||||
document.head.append(style) |
||||
} |
||||
addStyle(` |
||||
.popover { |
||||
display:none !important; |
||||
} |
||||
`)
|
||||
}, [], done()) |
||||
}) |
||||
.perform((done) => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
} |
||||
} |
||||
|
||||
module.exports = HideToolTips |
@ -1,16 +1,33 @@ |
||||
import { NightwatchBrowser } from 'nightwatch' |
||||
import {NightwatchBrowser} from 'nightwatch' |
||||
import EventEmitter from 'events' |
||||
|
||||
class RefreshPage extends EventEmitter { |
||||
command(this: NightwatchBrowser) { |
||||
browser.refresh() |
||||
.verifyLoad() |
||||
.perform((done) => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
} |
||||
} |
||||
command(this: NightwatchBrowser) { |
||||
browser |
||||
.refresh() |
||||
.verifyLoad() |
||||
.perform((done) => { |
||||
//if (hideToolTips) {
|
||||
browser.execute(function () { |
||||
// hide tooltips
|
||||
function addStyle(styleString) { |
||||
const style = document.createElement('style') |
||||
style.textContent = styleString |
||||
document.head.append(style) |
||||
} |
||||
|
||||
addStyle(` |
||||
.popover { |
||||
display:none !important; |
||||
} |
||||
`)
|
||||
}, [], done()) |
||||
}) |
||||
.perform((done) => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
} |
||||
} |
||||
|
||||
module.exports = RefreshPage |
@ -1,11 +1,12 @@ |
||||
import React from 'react' |
||||
import ReactDOM from 'react-dom' |
||||
import { createRoot } from 'react-dom/client'; |
||||
|
||||
import App from './app/app' |
||||
|
||||
ReactDOM.render( |
||||
<React.StrictMode> |
||||
const container = document.getElementById('root'); |
||||
|
||||
if (container) { |
||||
createRoot(container).render(<React.StrictMode> |
||||
<App /> |
||||
</React.StrictMode>, |
||||
document.getElementById('root') |
||||
) |
||||
</React.StrictMode>); |
||||
} |
||||
|
@ -0,0 +1,129 @@ |
||||
'use strict' |
||||
import { NightwatchBrowser } from 'nightwatch' |
||||
import init from '../helpers/init' |
||||
|
||||
module.exports = { |
||||
'@disabled': true, |
||||
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||
init(browser, done) |
||||
}, |
||||
// file copy file name tests
|
||||
'Should copy file name and paste in root with new file button and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('*[data-id="fileExplorerNewFilecreateNewFile"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.CONTROL + 'v') |
||||
.pause(1000) |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME1.txt"]', 7000) |
||||
}, |
||||
'Should copy file name and paste in another folder with new file button and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.click('*[data-id="fileExplorerNewFilecreateNewFile"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.CONTROL + 'v') |
||||
.pause(1000) |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/README.txt"]', 7000) |
||||
}, |
||||
'Should copy file name and paste in another folder that has the same filename with new file button and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.click('*[data-id="fileExplorerNewFilecreateNewFile"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.CONTROL + 'v') |
||||
.pause(1000) |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/README1.txt"]', 7000) |
||||
}, |
||||
'Should copy file name and paste in root with right click and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="contextMenuItemcopyFileName"]') |
||||
.rightClick('*[data-id="treeViewUltreeViewMenu"]') |
||||
.click('*[data-id="contextMenuItemnewFile"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.CONTROL + 'v') |
||||
.pause(1000) |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME2.txt"]', 7000) |
||||
}, |
||||
'Should copy file name and paste in contracts with right click and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopyFileName"]') |
||||
.click('[data-id="contextMenuItemcopyFileName"]') |
||||
.rightClick('*[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.click('*[data-id="contextMenuItemnewFile"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.CONTROL + 'v') |
||||
.pause(1000) |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME2.txt"]', 7000) |
||||
}, |
||||
// file copy paste tests
|
||||
'Should copy file and paste in root with right click and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopy') |
||||
.click('[data-id="contextMenuItemcopy"]') |
||||
.rightClick('*[data-id="treeViewLiMenu"]') |
||||
.saveScreenshot('./reports/screenshot/file_explorer_context_menu.png') |
||||
.click('*[data-id="contextMenuItempaste"]') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemCopy_README.txt"]', 7000) |
||||
}, |
||||
'Should copy file and paste in contracts with right click and it will contain a new file #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopy') |
||||
.click('[data-id="contextMenuItemcopy"]') |
||||
.rightClick('*[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.click('*[data-id="contextMenuItempaste"]') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/Copy_README.txt"]', 7000) |
||||
}, |
||||
// folder copy paste tests
|
||||
'Should copy folder and paste in root with right click and it will contain a copied folder #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.rightClick('li[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopy') |
||||
.click('[data-id="contextMenuItemcopy"]') |
||||
.rightClick('*[data-id="treeViewLiMenu"]') |
||||
.click('*[data-id="contextMenuItempaste"]') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemCopy_contracts"]', 7000) |
||||
}, |
||||
'Should copy folder and paste in contracts with right click and it will contain a copied folder #group1 ': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.pause(1000) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemcopy') |
||||
.click('[data-id="contextMenuItemcopy"]') |
||||
.rightClick('*[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.click('*[data-id="contextMenuItempaste"]') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/Copy_scripts"]', 7000) |
||||
} |
||||
} |
@ -0,0 +1,103 @@ |
||||
'use strict' |
||||
import { NightwatchBrowser } from 'nightwatch' |
||||
import init from '../helpers/init' |
||||
|
||||
const checkBrowserIsChrome = function (browser: NightwatchBrowser) { |
||||
return browser.browserName.indexOf('chrome') > -1 |
||||
} |
||||
|
||||
|
||||
module.exports = { |
||||
'@disabled': true, |
||||
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||
init(browser, done) |
||||
}, |
||||
'drag and drop file from root to contracts #group1 ': function (browser: NightwatchBrowser) { |
||||
if (checkBrowserIsChrome(browser)) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { |
||||
console.log((el as any).value.getId()) |
||||
const id = (el as any).value.getId() |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') |
||||
.dragAndDrop('li[data-id="treeViewLitreeViewItemREADME.txt"]', id) |
||||
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') |
||||
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') |
||||
}) |
||||
} |
||||
}, |
||||
|
||||
'drag and drop file from contracts to root #group1': function (browser: NightwatchBrowser) { |
||||
if (checkBrowserIsChrome(browser)) { |
||||
browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { |
||||
console.log((el as any).value.getId()) |
||||
const id = (el as any).value.getId() |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]') |
||||
.dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]', id) |
||||
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') |
||||
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) |
||||
}) |
||||
browser.pause(1000) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItem1_Storage.sol"]') |
||||
} |
||||
}, |
||||
'drag and drop scripts from root to contracts #group1': function (browser: NightwatchBrowser) { |
||||
if (checkBrowserIsChrome(browser)) { |
||||
browser |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') |
||||
.findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { |
||||
console.log((el as any).value.getId()) |
||||
const id = (el as any).value.getId() |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
.dragAndDrop('li[data-id="treeViewLitreeViewItemscripts"]', id) |
||||
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') |
||||
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') |
||||
}) |
||||
} |
||||
}, |
||||
'drag scripts from contracts to root #group1': function (browser: NightwatchBrowser) { |
||||
if (checkBrowserIsChrome(browser)) { |
||||
browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { |
||||
console.log((el as any).value.getId()) |
||||
const id = (el as any).value.getId() |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') |
||||
.dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/scripts"]', id) |
||||
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') |
||||
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) |
||||
}) |
||||
browser.pause(1000) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
} |
||||
}, |
||||
'drag into nested folder': function (browser: NightwatchBrowser) { |
||||
if (checkBrowserIsChrome(browser)) { |
||||
browser.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
.rightClick('li[data-id="treeViewLitreeViewItemscripts"]') |
||||
.waitForElementPresent('[data-id="contextMenuItemnewFolder') |
||||
.click('[data-id="contextMenuItemnewFolder') |
||||
.waitForElementVisible('*[data-id$="fileExplorerTreeItemInput"]') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', 'nested') |
||||
.sendKeys('*[data-id$="fileExplorerTreeItemInput"]', browser.Keys.ENTER) |
||||
.findElement('*[data-id="treeViewLitreeViewItemscripts/nested"]', (el) => { |
||||
console.log((el as any).value.getId()) |
||||
const id = (el as any).value.getId() |
||||
browser |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') |
||||
.dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]', id) |
||||
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') |
||||
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) |
||||
.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts/nested/README.txt"]') |
||||
}) |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,92 @@ |
||||
import FileProvider from "./fileProvider" |
||||
|
||||
|
||||
declare global { |
||||
interface Window { |
||||
remixFileSystem: any |
||||
} |
||||
} |
||||
|
||||
export class ElectronProvider extends FileProvider { |
||||
_appManager: any |
||||
constructor(appManager) { |
||||
super('') |
||||
this._appManager = appManager |
||||
|
||||
} |
||||
|
||||
async init() { |
||||
this._appManager.on('fs', 'change', async (event, path) => { |
||||
this.handleEvent(event, path) |
||||
}) |
||||
this._appManager.on('fs', 'eventGroup', async (data) => { |
||||
for (const event of data) { |
||||
this.handleEvent(event.payload[0], event.payload[1]) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
handleEvent = (event, path) => { |
||||
switch (event) { |
||||
case 'add': |
||||
this.event.emit('fileAdded', path) |
||||
break |
||||
case 'unlink': |
||||
this.event.emit('fileRemoved', path) |
||||
break |
||||
case 'change': |
||||
this.get(path, (_error, content) => { |
||||
this.event.emit('fileExternallyChanged', path, content, false) |
||||
}) |
||||
break |
||||
case 'rename': |
||||
this.event.emit('fileRenamed', path) |
||||
break |
||||
case 'addDir': |
||||
this.event.emit('folderAdded', path) |
||||
break |
||||
case 'unlinkDir': |
||||
this.event.emit('fileRemoved', path) |
||||
} |
||||
} |
||||
|
||||
|
||||
// isDirectory is already included
|
||||
// this is a more efficient version of the default implementation
|
||||
async resolveDirectory(path, cb) { |
||||
path = this.removePrefix(path) |
||||
if (path.indexOf('/') !== 0) path = '/' + path |
||||
try { |
||||
const files = await window.remixFileSystem.readdir(path) |
||||
const ret = {} |
||||
if (files) { |
||||
for (const element of files) { |
||||
path = path.replace(/^\/|\/$/g, '') // remove first and last slash
|
||||
const file = element.file.replace(/^\/|\/$/g, '') // remove first and last slash
|
||||
const absPath = (path === '/' ? '' : path) + '/' + file |
||||
ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: element.isDirectory } |
||||
// ^ ret does not accept path starting with '/'
|
||||
} |
||||
} |
||||
if (cb) cb(null, ret) |
||||
return ret |
||||
} catch (error) { |
||||
if (cb) cb(error, null) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Removes the folder recursively |
||||
* @param {*} path is the folder to be removed |
||||
*/ |
||||
async remove(path: string) { |
||||
try { |
||||
await window.remixFileSystem.rmdir(path) |
||||
return true |
||||
} catch (error) { |
||||
console.log(error) |
||||
return false |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,64 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
import { Plugin } from '@remixproject/engine'; |
||||
import { baseURLBin, baseURLWasm } from '@remix-project/remix-solidity' |
||||
import axios, {AxiosResponse} from 'axios' |
||||
import { iSolJsonBinData } from '@remix-project/remix-lib' |
||||
|
||||
const profile = { |
||||
displayName: 'compilerLoader', |
||||
name: 'compilerloader', |
||||
description: 'Loads the compiler for offline use', |
||||
} |
||||
|
||||
const methods = ['getJsonBinData'] |
||||
|
||||
export class compilerLoaderPlugin extends Plugin { |
||||
constructor() { |
||||
super(profile) |
||||
this.methods = methods |
||||
} |
||||
|
||||
async getJsonBinData() { |
||||
const response: iSolJsonBinData = { |
||||
baseURLBin: '', |
||||
baseURLWasm: '', |
||||
binList: [], |
||||
wasmList: [], |
||||
selectorList: [] |
||||
} |
||||
let binRes: AxiosResponse |
||||
let wasmRes: AxiosResponse |
||||
try { |
||||
// fetch normal builds
|
||||
binRes = await axios(`${baseURLBin}/list.json`) |
||||
// fetch wasm builds
|
||||
wasmRes = await axios(`${baseURLWasm}/list.json`) |
||||
} catch (e) { |
||||
} |
||||
if (wasmRes.status === 200) { |
||||
response.wasmList = wasmRes.data.builds |
||||
} |
||||
if (binRes.status === 200) { |
||||
response.binList = binRes.data.builds |
||||
} |
||||
response.baseURLBin = baseURLBin |
||||
response.baseURLWasm = baseURLWasm |
||||
|
||||
this.emit('jsonBinDataLoaded', response) |
||||
} |
||||
} |
||||
|
||||
export class compilerLoaderPluginDesktop extends ElectronPlugin { |
||||
constructor() { |
||||
super(profile) |
||||
this.methods = [] |
||||
} |
||||
|
||||
async onActivation(): Promise<void> { |
||||
|
||||
this.on('solidity', 'loadingCompiler', async (url) => { |
||||
await this.call('compilerloader', 'downloadCompiler', url) |
||||
}) |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class electronConfig extends ElectronPlugin { |
||||
constructor() { |
||||
super({ |
||||
displayName: 'electronconfig', |
||||
name: 'electronconfig', |
||||
description: 'electronconfig', |
||||
}) |
||||
this.methods = [] |
||||
} |
||||
} |
@ -0,0 +1,127 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
let workingDir = null |
||||
|
||||
const fixPath = (path: string) => { |
||||
return path |
||||
} |
||||
|
||||
export class fsPlugin extends ElectronPlugin { |
||||
public fs: any |
||||
public fsSync: any |
||||
|
||||
constructor() { |
||||
super({ |
||||
displayName: 'fs', |
||||
name: 'fs', |
||||
description: 'fs', |
||||
}) |
||||
this.methods = ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'setWorkingDir', 'getRecentFolders', 'openWindow'] |
||||
|
||||
// List of commands all filesystems are expected to provide. `rm` is not
|
||||
// included since it may not exist and must be handled as a special case
|
||||
const commands = [ |
||||
'readFile', |
||||
'writeFile', |
||||
'mkdir', |
||||
'rmdir', |
||||
'unlink', |
||||
'stat', |
||||
'lstat', |
||||
'readdir', |
||||
'readlink', |
||||
'symlink', |
||||
] |
||||
|
||||
this.fs = { |
||||
exists: async (path: string) => { |
||||
path = fixPath(path) |
||||
const exists = await this.call('fs', 'exists', path) |
||||
return exists |
||||
}, |
||||
rmdir: async (path: string) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'rmdir', path) |
||||
}, |
||||
readdir: async (path: string) => { |
||||
path = fixPath(path) |
||||
const files = await this.call('fs', 'readdir', path) |
||||
return files |
||||
}, |
||||
unlink: async (path: string) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'unlink', path) |
||||
}, |
||||
mkdir: async (path: string) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'mkdir', path) |
||||
}, |
||||
readFile: async (path: string, options) => { |
||||
try { |
||||
path = fixPath(path) |
||||
const file = await this.call('fs', 'readFile', path, options) |
||||
return file |
||||
} catch (e) { |
||||
return undefined |
||||
} |
||||
} |
||||
, |
||||
rename: async (from: string, to: string) => { |
||||
return await this.call('fs', 'rename', from, to) |
||||
}, |
||||
writeFile: async (path: string, content: string, options: any) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'writeFile', path, content, options) |
||||
} |
||||
, |
||||
stat: async (path: string) => { |
||||
try { |
||||
path = fixPath(path) |
||||
const stat = await this.call('fs', 'stat', path) |
||||
if(!stat) return undefined |
||||
stat.isDirectory = () => stat.isDirectoryValue |
||||
stat.isFile = () => !stat.isDirectoryValue |
||||
return stat |
||||
} catch (e) { |
||||
return undefined |
||||
} |
||||
}, |
||||
lstat: async (path: string) => { |
||||
try { |
||||
path = fixPath(path) |
||||
const stat = await this.call('fs', 'lstat', path) |
||||
if(!stat) return undefined |
||||
stat.isDirectory = () => stat.isDirectoryValue |
||||
stat.isFile = () => !stat.isDirectoryValue |
||||
return stat |
||||
} catch (e) { |
||||
return undefined |
||||
} |
||||
}, |
||||
readlink: async (path: string) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'readlink', path) |
||||
}, |
||||
symlink: async (target: string, path: string) => { |
||||
path = fixPath(path) |
||||
return await this.call('fs', 'symlink', target, path) |
||||
} |
||||
} |
||||
} |
||||
|
||||
async onActivation() { |
||||
(window as any).remixFileSystem = this.fs |
||||
this.on('fs', 'workingDirChanged', async (path: string) => { |
||||
workingDir = path |
||||
await this.call('fileManager', 'refresh') |
||||
}) |
||||
this.on('fs', 'error', async (error: string) => { |
||||
if(error === 'ENOSPC'){ |
||||
this.call('notification', 'alert', { |
||||
id: 'fsError', |
||||
message: 'Cannot watch file changes. There are too many files in your project.' |
||||
}) |
||||
} |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class isoGitPlugin extends ElectronPlugin { |
||||
constructor() { |
||||
super({ |
||||
displayName: 'isogit', |
||||
name: 'isogit', |
||||
description: 'isogit', |
||||
}) |
||||
this.methods = [] |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class ripgrepPlugin extends ElectronPlugin { |
||||
constructor(){ |
||||
super({ |
||||
displayName: 'ripgrep', |
||||
name: 'ripgrep', |
||||
description: 'ripgrep' |
||||
}) |
||||
this.methods = ['glob'] |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class electronTemplates extends ElectronPlugin { |
||||
constructor() { |
||||
super({ |
||||
displayName: 'electronTemplates', |
||||
name: 'electronTemplates', |
||||
description: 'templates', |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class xtermPlugin extends ElectronPlugin { |
||||
constructor(){ |
||||
super({ |
||||
displayName: 'xterm', |
||||
name: 'xterm', |
||||
description: 'xterm', |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,30 @@ |
||||
import { Plugin } from '@remixproject/engine' |
||||
import * as templateWithContent from '@remix-project/remix-ws-templates' |
||||
|
||||
const profile = { |
||||
name: 'remix-templates', |
||||
displayName: 'remix-templates', |
||||
description: 'Remix Templates plugin', |
||||
methods: ['getTemplate', 'loadTemplateInNewWindow'], |
||||
} |
||||
|
||||
export class TemplatesPlugin extends Plugin { |
||||
|
||||
constructor() { |
||||
super(profile) |
||||
} |
||||
|
||||
async getTemplate (template: string, opts?: any) { |
||||
const templateList = Object.keys(templateWithContent) |
||||
if (!templateList.includes(template)) return |
||||
// @ts-ignore
|
||||
const files = await templateWithContent[template](opts) |
||||
return files |
||||
} |
||||
// electron only method
|
||||
async loadTemplateInNewWindow (template: string, opts?: any) { |
||||
const files = await this.getTemplate(template, opts) |
||||
this.call('electronTemplates', 'loadTemplateInNewWindow', files) |
||||
} |
||||
} |
||||
|
@ -0,0 +1,170 @@ |
||||
import React from 'react' |
||||
import { ViewPlugin } from '@remixproject/engine-web' |
||||
import {PluginViewWrapper} from '@remix-ui/helper' |
||||
import { RemixAppManager } from '../../remixAppManager' |
||||
import { RemixUiVyperCompileDetails } from '@remix-ui/vyper-compile-details' |
||||
import { ThemeKeys, ThemeObject } from '@microlink/react-json-view' |
||||
//@ts-ignore
|
||||
const _paq = (window._paq = window._paq || []) |
||||
|
||||
const profile = { |
||||
name: 'vyperCompilationDetails', |
||||
displayName: 'Vyper Compile Details', |
||||
description: 'Displays details from vyper compiler', |
||||
location: 'mainPanel', |
||||
methods: ['showDetails'], |
||||
events: [] |
||||
} |
||||
|
||||
export class VyperCompilationDetailsPlugin extends ViewPlugin { |
||||
dispatch: React.Dispatch<any> = () => {} |
||||
appManager: RemixAppManager |
||||
element: HTMLDivElement |
||||
payload: any |
||||
themeStyle: any |
||||
theme: ThemeKeys | ThemeObject |
||||
constructor(appManager: RemixAppManager) { |
||||
super(profile) |
||||
this.appManager = appManager |
||||
this.element = document.createElement('div') |
||||
this.element.setAttribute('id', 'vypercompileDetails') |
||||
this.payload = { |
||||
contractProperties: {} as any, |
||||
selectedContract: '', |
||||
help: {} as any, |
||||
insertValue: {} as any, |
||||
saveAs: {} as any, |
||||
} |
||||
} |
||||
|
||||
async onActivation() { |
||||
this.handleThemeChange() |
||||
await this.call('tabs', 'focus', 'vyperCompilationDetails') |
||||
this.renderComponent() |
||||
_paq.push(['trackEvent', 'plugin', 'activated', 'vyperCompilationDetails']) |
||||
} |
||||
|
||||
onDeactivation(): void { |
||||
|
||||
} |
||||
|
||||
async showDetails(sentPayload: any) { |
||||
const contractName = Object.entries(sentPayload).find(([key, value]) => key ) |
||||
await this.call('tabs', 'focus', 'vyperCompilationDetails') |
||||
this.profile.displayName = `${contractName[0]}` |
||||
this.payload = sentPayload |
||||
const active = await this.call('theme', 'currentTheme') |
||||
if (active.quality === 'dark') { |
||||
switch(active.name) { |
||||
case 'HackerOwl': |
||||
this.theme = 'harmonic' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Black': |
||||
this.theme = 'eighties' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Cyborg': |
||||
this.theme = 'shapeshifter' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Dark': |
||||
this.theme = 'flat' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
default: |
||||
this.theme = 'shapeshifter' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
} |
||||
} else { |
||||
switch(active.name) { |
||||
case 'Candy': |
||||
this.theme = 'apathy:inverted' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Midcentury': |
||||
this.theme = 'apathy:inverted' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Unicorn': |
||||
this.theme = 'apathy:inverted' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
case 'Violet': |
||||
this.theme = 'summerfruit:inverted' |
||||
this.themeStyle = { backgroundColor: active.backgroundColor } |
||||
break |
||||
default: |
||||
this.theme = 'bright:inverted' |
||||
break |
||||
} |
||||
} |
||||
this.renderComponent() |
||||
} |
||||
|
||||
private handleThemeChange() { |
||||
this.on('theme', 'themeChanged', (theme: any) => { |
||||
if (theme.quality === 'dark') { |
||||
switch(theme.name) { |
||||
case 'HackerOwl': |
||||
this.theme = 'solarized' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
break |
||||
case 'Black': |
||||
this.theme = 'shapeshifter' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
break |
||||
case 'Cyborg': |
||||
this.theme = 'shapeshifter' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
break |
||||
case 'Dark': |
||||
this.theme = 'harmonic' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
break |
||||
default: |
||||
this.theme = 'shapeshifter' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
break |
||||
} |
||||
} else { |
||||
this.theme = 'bright:inverted' |
||||
this.themeStyle = { backgroundColor: theme.backgroundColor } |
||||
} |
||||
this.renderComponent() |
||||
}) |
||||
} |
||||
|
||||
setDispatch(dispatch: React.Dispatch<any>): void { |
||||
this.dispatch = dispatch |
||||
this.renderComponent() |
||||
} |
||||
render() { |
||||
return ( |
||||
<div id="compileDetails"> |
||||
<PluginViewWrapper plugin={this} /> |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
renderComponent() { |
||||
this.dispatch({ |
||||
...this, |
||||
...this.payload, |
||||
themeStyle: this.themeStyle, |
||||
theme: this.theme |
||||
}) |
||||
} |
||||
|
||||
updateComponent(state: any) { |
||||
return ( |
||||
<RemixUiVyperCompileDetails |
||||
payload={state.payload} |
||||
theme={state.theme} |
||||
themeStyle={state.themeStyle} |
||||
/> |
||||
) |
||||
} |
||||
|
||||
} |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"electron.openFolder": "Open Folder", |
||||
"electron.recentFolders": "Recent Folders" |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue