diff --git a/.gitignore b/.gitignore index 54bfd200..d4584b3f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # compiled output /dist +/dist-desktop /tmp /out-tsc diff --git a/build/icon.icns b/build/icon.icns new file mode 100644 index 00000000..8354970e Binary files /dev/null and b/build/icon.icns differ diff --git a/build/icon.ico b/build/icon.ico new file mode 100644 index 00000000..8c58a205 Binary files /dev/null and b/build/icon.ico differ diff --git a/main.js b/main.js new file mode 100644 index 00000000..21b61d93 --- /dev/null +++ b/main.js @@ -0,0 +1,64 @@ +const { app, BrowserWindow, shell, Menu } = require('electron'); + +let mainWindow; + +function createWindow () { + // Create the browser window. + mainWindow = new BrowserWindow({width: 1000, height: 600}); + const options = { extraHeaders: "pragma: no-cache\n" }; + mainWindow.loadURL('https://nanovault.io', options); + // mainWindow.loadURL('http://localhost:4200/'); + // TODO: Use environment to load config which holds the actual url to load for the app + + // 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 + }) + + mainWindow.webContents.on('new-window', function(e, url) { + e.preventDefault(); + shell.openExternal(url); + }); + + if (process.platform === 'darwin') { + // Create our menu entries so that we can use MAC shortcuts + Menu.setApplicationMenu(Menu.buildFromTemplate([ + { + label: 'Edit', + submenu: [ + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + { role: 'pasteandmatchstyle' }, + { role: 'delete' }, + { role: 'selectall' } + ] + } + ])); + } +} + +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() + } +}); diff --git a/package.json b/package.json index aedf8e9f..d6d46582 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,21 @@ { - "name": "raivault", - "version": "0.0.0", + "name": "NanoVault", + "version": "1.0.0", "license": "MIT", + "description": "Wallet for interacting with Nano", + "author": "Andrew Steele", + "main": "main.js", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "ng e2e", + "desktop": "electron main.js", + "pack": "electron-builder --dir", + "dist": "electron-builder", + "dist-full": "electron-builder -wml --x64" }, "private": true, "dependencies": { @@ -43,6 +50,8 @@ "@types/node": "~6.0.60", "@types/qrcode": "^0.8.1", "codelyzer": "^4.0.1", + "electron": "^1.8.2", + "electron-builder": "^19.52.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", @@ -55,5 +64,21 @@ "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2" + }, + "build": { + "appId": "com.electron.nanovault", + "buildVersion": "1.0.0", + "productName": "NanoVault", + "copyright": "Copyright © 2018 Andrew Steele", + "directories": { + "output": "dist-desktop", + "app": "./" + }, + "mac": { + "category": "public.app-category.finance" + }, + "linux": { + "target": "AppImage" + } } } diff --git a/renderer.js b/renderer.js new file mode 100644 index 00000000..901d75ec --- /dev/null +++ b/renderer.js @@ -0,0 +1,3 @@ +// This file is required by the index.html file and will +// be executed in the renderer process for that window. +// All of the Node.js APIs are available in this process.