You are previewing Developing an Electron Edge.
O'Reilly logo
Developing an Electron Edge

Book Description

Developing an Electron Edge is for anyone looking to keep up with the cutting edge of desktop application development. If you have ever wanted to create a cross-platform desktop app and put your Web app on users’ desktops, you will love this book. If you’re a Web developer or a Node.js user, you’ll be pleasantly surprised by how easy it is, given how your existing skills will be leveraged throughout. Newcomers are introduced to the power of Electron, Web technologies, and Node.js, although we do assume you have some JavaScript literacy. Don’t worry if you’ve been around the block, or if you already use Electron. We go into plenty of detail on some of the more advanced topics or obstacles you’ll face in order to deliver a rich desktop app. This book is full of potential pitfalls and lessons learned from real world experience, as well as covering intricate subjects like distributing your app to end users. There is something in this book for everyone.

Table of Contents

  1. Preface
    1. Why use Electron?
    2. Who this book is for
    3. What this book is about
    4. About the authors
    5. Acknowledgements
      1. Technical reviewers
      2. Code examples
  2. 1. Introduction
    1. So you want to create a desktop app
    2. Support and community
    3. Hello, World!
  3. 2. The Different Processes
    1. The Main Process
    2. The Renderer Process(es)
    3. How this differs from NW.js
    4. Summary
  4. 3. Using Node Modules
    1. Node internal modules
    2. Packages from npm
    3. Semantic Versioning
    4. Finding good packages
    5. Summary
  5. 4. Application Lifecycle
    1. Before your Code is loaded
    2. Startup
    3. Quitting
    4. Crashing
    5. Summary
  6. 5. Building a Real Desktop App
    1. Initializing the project
    2. The frontend
    3. Adding logic
    4. Opening files
    5. Tapping into the desktop a bit more
    6. Dropping a file on the dock icon (Mac OS X)
    7. Recent documents
    8. Represented file (Mac OS X)
    9. Summary
      1. The code
  7. 6. Platform Detection and Custom Frames
    1. Which operating system?
    2. Which Linux distribution?
    3. 32-bit or 64-bit architecture?
    4. Version detection
    5. The finished article
    6. Platform-dependent styles
      1. Dark mode
    7. Custom frames
      1. Draggability
      2. Uh oh
      3. A nice workaround
      4. Linux
    8. Summary
  8. 7. Desktop Integrations
    1. Special paths
    2. Opening files with your app
      1. Detecting production or development
    3. User tasks (Windows)
    4. Custom dock menu (Mac OS X)
    5. Unity launcher shortcuts (Linux)
    6. Thumbnail toolbars (Windows 7+)
    7. Represented file of window (Mac OS X)
    8. Progress bar in taskbar
    9. Badge counts (Mac OS X)
    10. Even more dock icon actions (Mac OS X)
    11. Showing definitions (Mac OS X)
    12. Global shortcuts
      1. Our options
      2. An example
      3. Unregistering
      4. Shortcut clashes
    13. System dialogs
      1. Uh oh!
      2. Where to?
    14. The Shell API
      1. Opening a resource
      2. Opening URLs
      3. Recycling and beeping
    15. Notifications
      1. OS X
      2. Linux
      3. Windows
      4. Metadata
      5. Custom HTML notifications
    16. The Tray API
      1. Balloons
    17. Automatically launching your app on startup
      1. Let’s talk platforms
      2. Hidden mode
      3. Be careful during development
    18. Summary
  9. 8. Debugging
    1. Renderer Processes
      1. The “Elements” tab
      2. The “Console” tab
      3. The “Sources” tab
      4. The “Network” tab
    2. Main process
      1. node-gyp prerequisites
      2. node-inspector
      3. Patched version of node-pre-gyp
      4. Recompiling the node-inspector v8 modules for Electron
      5. Enable debug mode in Electron
      6. Start the node-inspector server
      7. Load the debugger UI
    3. Summary
  10. 9. Using Native Node Modules
    1. Writing a Native Addon
    2. Using Native Addons
    3. Summary
  11. 10. Electron Versus the Web
    1. Exploiting browser lock-in
      1. Battery status
      2. WebSockets
      3. Device orientation
      4. Speech
      5. Audio
      6. MIDI
      7. Web components
      8. Service worker
      9. Visuals
      10. CSS3 layout modules
      11. Barebones DOM manipulation
      12. localStorage
    2. Detecting connectivity
      1. Is there anyone out there?
    3. Watch out for protocol-less URLs
    4. Spell checking
      1. webFrame
    5. Shortcuts
    6. Be careful what you wish for
    7. Won’t I have bigger problems than that?
    8. Back to the future
    9. Local before CDN
    10. Away from keyboard
    11. Automated testing
    12. Summary
  12. 11. Distributing Your App
    1. Rebranding
    2. Windows and path length problems
      1. npm
      2. Manually checking for exceedingly long paths
      3. Introducing gulp-path-length
      4. Distributed long paths
      5. Aha! Asar to the rescue
    3. Asar
      1. Creating an asar archive
      2. Reading files
      3. Unpacked files
    4. The better way
      1. Command-line interface
      2. Rebranding
      3. Programmatic API
    5. Creating installers
      1. Forget what you know
      2. Let’s do what we’re told
      3. Generating the installers
      4. Signing
      5. Automate everything
    6. Summary
  13. 12. Automatic Updates
    1. A standalone updater app
    2. Reinstalling per update
    3. The Indiana Jones maneuver
    4. The heart transplant
    5. Delta updates
    6. Electron’s autoUpdater
      1. Mac
      2. Windows
      3. Common ground
    7. Mac App Store
    8. Summary
  14. 13. Crash Reports
    1. The crash-reporter module
    2. Usage
    3. Building a crash-reports server
    4. Analyzing the crash report data
    5. The upload_file_minidump file
    6. Summary