Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Download network dapps and load them from filesystem #144

Merged
merged 15 commits into from
Jul 9, 2018
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ npm-debug.log
build
dist
docs
test/tmp
.build
.coverage
.dist
Expand Down
19 changes: 0 additions & 19 deletions Cargo.precompiled.toml

This file was deleted.

18 changes: 0 additions & 18 deletions Cargo.toml

This file was deleted.

22 changes: 0 additions & 22 deletions build.rs

This file was deleted.

28 changes: 12 additions & 16 deletions electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

const electron = require('electron');
const fs = require('fs');
const path = require('path');
const url = require('url');
const util = require('util');
const { ensureDir: fsEnsureDir } = require('fs-extra');

const addMenu = require('./menu');
const { cli } = require('./cli');
Expand All @@ -32,11 +31,16 @@ const { name: appName } = require('../package.json');

const { app, BrowserWindow, ipcMain, session } = electron;

const fsExists = util.promisify(fs.stat); // eslint-disable-line
const fsMkdir = util.promisify(fs.mkdir);

let mainWindow;

function runApp () {
doesParityExist()
.catch(() => fetchParity(mainWindow)) // Install parity if not present
.catch(handleError); // Errors should be handled before, this is really just in case

return fsEnsureDir(getLocalDappsPath()).then(createWindow);
}

function createWindow () {
// Will send these variables to renderers via IPC
global.dirName = __dirname;
Expand All @@ -45,18 +49,10 @@ function createWindow () {

mainWindow = new BrowserWindow({
height: 800,
width: 1200
width: 1200,
webPreferences: { nodeIntegrationInWorker: true }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodeintegration is enabled for the BrowserWindow but disabled by default for its WebWorkers; I had to add this option to remove the following error (wasn't blocking though):

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine, we are not requiring any external files as web workers.

Is the error stack longer? Who is requiring @parity/shared/lib/webWorker.js? I'd be more enthusiast to remove web workers altoghether.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the whole error stack

we import some files of @parity/shared (for example import { initStore } from '@parity/shared/lib/redux' in index.parity.js) that require the worker of @parity/shared (in that case, initStore calls setupWorker). I imagine that's where it's coming from

});

const localDappsPath = getLocalDappsPath();

fsExists(localDappsPath)
.catch(() => fsMkdir(localDappsPath));

doesParityExist()
.catch(() => fetchParity(mainWindow)) // Install parity if not present
.catch(handleError); // Errors should be handled before, this is really just in case

if (cli.uiDev === true) {
// Opens http://127.0.0.1:3000 in --ui-dev mode
mainWindow.loadURL('http://127.0.0.1:3000');
Expand Down Expand Up @@ -122,7 +118,7 @@ function createWindow () {
});
}

app.on('ready', createWindow);
app.on('ready', runApp);

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
Expand Down
2 changes: 1 addition & 1 deletion electron/operations/runParity.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {
.then(() => fsChmod(parityPath(), '755')) // Should already be 755 after download, just to be sure
.then(() => {
const logStream = fs.createWriteStream(logFile, { flags: 'a' });
let logLastLine; // Always contains last line of the logFile
let logLastLine = ''; // Always contains last line of the logFile

// Run an instance of parity with the correct args
parity = spawn(parityPath(), parityArgv);
Expand Down
Loading