diff --git a/README.md b/README.md index 153df8e2..94151919 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,14 @@ To build: ...then open any of the HTML files in the `example-browsers` directory to test. +Electron app +------------ + +To run as an electron app, do: + +``` +npm start +``` Documentation ------------- diff --git a/example-browsers/zn_for_amy.html b/example-browsers/zn_for_amy.html new file mode 100644 index 00000000..6560aeff --- /dev/null +++ b/example-browsers/zn_for_amy.html @@ -0,0 +1,39 @@ + + + + + + + + +Zaire Ebolavirus :: Dalliance + + + + + + +
Failed to load the Biodalliance genome browser. Have you run "gulp"?
+ + diff --git a/main.js b/main.js new file mode 100644 index 00000000..1217c069 --- /dev/null +++ b/main.js @@ -0,0 +1,60 @@ +const electron = require('electron') +// Module to control application life. +const app = electron.app +// Module to create native browser window. +const BrowserWindow = electron.BrowserWindow + +const path = require('path') +const url = require('url') + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow + +function createWindow () { + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}) + + // and load the index.html of the app. + mainWindow.loadURL(url.format({ + pathname: path.join(__dirname, 'example-browsers/mouse38.html'), + protocol: 'file:', + slashes: true + })) + + // Open the DevTools. + // mainWindow.webContents.openDevTools() + + // Emitted when the window is closed. + mainWindow.on('closed', function () { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null + }) +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.on('ready', createWindow) + +// Quit when all windows are closed. +app.on('window-all-closed', function () { + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', function () { + // On OS X it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (mainWindow === null) { + createWindow() + } +}) + +// In this file you can include the rest of your app's specific main process +// code. You can also put them in separate files and require them here. diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 00000000..c82efcd2 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,45 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] +2 info using npm@3.10.10 +3 info using node@v6.11.3 +4 verbose run-script [ 'prestart', 'start', 'poststart' ] +5 info lifecycle dalliance@0.13.90-alpha.3~prestart: dalliance@0.13.90-alpha.3 +6 silly lifecycle dalliance@0.13.90-alpha.3~prestart: no script for prestart, continuing +7 info lifecycle dalliance@0.13.90-alpha.3~start: dalliance@0.13.90-alpha.3 +8 verbose lifecycle dalliance@0.13.90-alpha.3~start: unsafe-perm in lifecycle true +9 verbose lifecycle dalliance@0.13.90-alpha.3~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/olgabot/code/dalliance/node_modules/.bin:/Users/olgabot/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin +10 verbose lifecycle dalliance@0.13.90-alpha.3~start: CWD: /Users/olgabot/code/dalliance +11 silly lifecycle dalliance@0.13.90-alpha.3~start: Args: [ '-c', 'electron .' ] +12 silly lifecycle dalliance@0.13.90-alpha.3~start: Returned: code: 1 signal: null +13 info lifecycle dalliance@0.13.90-alpha.3~start: Failed to exec start script +14 verbose stack Error: dalliance@0.13.90-alpha.3 start: `electron .` +14 verbose stack Exit status 1 +14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at EventEmitter.emit (events.js:191:7) +14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at ChildProcess.emit (events.js:191:7) +14 verbose stack at maybeClose (internal/child_process.js:920:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5) +15 verbose pkgid dalliance@0.13.90-alpha.3 +16 verbose cwd /Users/olgabot/code/dalliance +17 error Darwin 16.7.0 +18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" +19 error node v6.11.3 +20 error npm v3.10.10 +21 error code ELIFECYCLE +22 error dalliance@0.13.90-alpha.3 start: `electron .` +22 error Exit status 1 +23 error Failed at the dalliance@0.13.90-alpha.3 start script 'electron .'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the dalliance package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error electron . +23 error You can get information on how to open an issue for this project with: +23 error npm bugs dalliance +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls dalliance +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/package.json b/package.json index 5c223946..f330acff 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "babel-preset-es2015": "^6.13.2", "babelify": "^7.3.0", "browserify": "12.0.1", + "electron": "1.7.6", "eslint": "^2.13.1", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", @@ -36,9 +37,18 @@ "vinyl-source-stream": "1.1.0", "watchify": "~3.6.1" }, - "files": ["lib", "css", "fonts", "help", "img", "build/worker-all.js"], + "files": [ + "lib", + "css", + "fonts", + "help", + "img", + "build/worker-all.js" + ], "main": "lib/module-exports.js", "scripts": { - "compile": "babel js -d lib && gulp compile-worker" + "compile": "babel js -d lib && gulp compile-worker", + "start": "electron main.js" } + }