diff --git a/.babelrc b/.babelrc index c2a80b34..487714b6 100644 --- a/.babelrc +++ b/.babelrc @@ -3,9 +3,11 @@ [ "env", { + "loose": true, "modules": false, "targets": { - "node": "8" + "electron": "1.8", + "node": "current" } } ], diff --git a/electron-builder.yml b/electron-builder.yml index 4c77ac8e..144918be 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,4 +1,4 @@ -appId: com.electron.ledger +appId: com.ledger.desktop protocols: name: Ledger Wallet Desktop @@ -6,9 +6,39 @@ protocols: - ledgerhq mac: - category: public.app-category.utilities + artifactName: ${name}-${version}-${os}.${ext} + category: public.app-category.wallet + target: + - dmg + - zip + linux: - target: appImage + artifactName: ${name}-${version}-${os}-${arch}.${ext} + target: + - target: AppImage + arch: + - x64 + - target: tar.gz + arch: + - x64 + +win: + artifactName: ${name}-${version}-${os}-${arch}.${ext} + target: + - target: nsis + arch: + - x64 + - ia32 + - target: zip + arch: + - x64 + - ia32 + +nsis: + oneClick: false + perMachine: true + allowToChangeInstallationDirectory: true + files: - dist/internals diff --git a/src/components/base/Defer.js b/src/components/base/Defer.js index f7ddab7e..acc869d2 100644 --- a/src/components/base/Defer.js +++ b/src/components/base/Defer.js @@ -7,31 +7,25 @@ type Props = { } type State = { - show: boolean, + shouldRender: boolean, } class Defer extends PureComponent { state = { - show: false, + shouldRender: false, } componentDidMount() { window.requestAnimationFrame(() => - this.setState({ - show: true, - }), + window.requestAnimationFrame(() => this.setState({ shouldRender: true })), ) } render() { const { children } = this.props - const { show } = this.state + const { shouldRender } = this.state - if (show) { - return children - } - - return null + return shouldRender ? children : null } } diff --git a/src/main/app.js b/src/main/app.js index 98806972..5887a1e6 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -1,6 +1,6 @@ // @flow -import { app, BrowserWindow, Menu, ipcMain } from 'electron' +import { app, BrowserWindow, Menu, ipcMain, screen } from 'electron' import menu from 'main/menu' @@ -12,31 +12,43 @@ let forceClose = false const devTools = __DEV__ -const defaultWindowOptions = { +const getWindowPosition = (height, width) => { + const { bounds } = screen.getPrimaryDisplay() + + return { + x: Math.ceil(bounds.x + (bounds.width - width) / 2), + y: Math.ceil(bounds.y + (bounds.height - height) / 2), + } +} + +const defaultWindowOptions = ({ height, width }) => ({ + ...getWindowPosition(height, width), backgroundColor: '#fff', - center: true, webPreferences: { devTools, }, -} +}) function createMainWindow() { const MIN_HEIGHT = 768 const MIN_WIDTH = 1024 + const height = MIN_HEIGHT + const width = MIN_WIDTH + const windowOptions = { - ...defaultWindowOptions, + ...defaultWindowOptions({ height, width }), ...(process.platform === 'darwin' ? { frame: false, titleBarStyle: 'hiddenInset', } : {}), - height: MIN_HEIGHT, + height, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH, show: false, - width: MIN_WIDTH, + width, webPreferences: { ...defaultWindowOptions.webPreferences, // Enable, among other things, the ResizeObserver @@ -80,19 +92,19 @@ function createPreloadWindow() { // Preload renderer of main windows mainWindow = createMainWindow() - const HEIGHT = 144 - const WIDTH = 256 + const height = 144 + const width = 256 const windowOptions = { - ...defaultWindowOptions, + ...defaultWindowOptions({ height, width }), closable: false, frame: false, fullscreenable: false, - height: HEIGHT, + height, resizable: false, show: false, skipTaskbar: true, - width: WIDTH, + width, } const window = new BrowserWindow(windowOptions)