O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

NW.js Essentials

Book Description

Build native desktop applications for Windows, Mac OS, or Linux using the latest web technologies

In Detail

Using Node.js, we can create web applications easily. Now, thanks to NW.js, we can also create desktop apps with it using a unique combination of HTML5 and Node. NW.js is a runtime application based on Chromium and Node.js.

In this book, you'll discover how to leverage well-known programming languages, such as JavaScript, HTML, and CSS in order to create NW.js desktop applications.

You will implement your first simple application right from the first chapter and see how easy it is to use the platform, after which you will learn about Native UI APIs and the different approaches to Node.js programming.

You'll get a complete picture of the many possible ways to package and deploy NW.js applications on Microsoft Windows, Mac OS X, and Linux. So, get ready to explore NW.js and build a real, and complex, application.

What You Will Learn

  • Develop a fully working NW.js desktop application from scratch
  • Take advantage of third-party tools to simplify the packaging process of NW.js applications
  • Create an astonishing user experience using Native UI APIs
  • Debug NW.js applications with Chromium DevTools, Crash dump log files, and third-party debugging tools
  • Package and deploy NW.js applications on Microsoft Windows, Mac OS X, and Linux
  • Take advantage of Browser Web APIs, expanding on data persistence solutions and security
  • Avoid common programming mistakes by integrating prior knowledge of Node.js with NW.js development

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. NW.js Essentials
    1. Table of Contents
    2. NW.js Essentials
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    9. 1. Meet NW.js
      1. NW.js under the hood
      2. Features and drawbacks of NW.js
        1. NW.js – usage scenarios
        2. Popular NW.js applications
      3. Downloading and installing NW.js
        1. Installing NW.js on Mac OS X
        2. Installing NW.js on Microsoft Windows
        3. Installing NW.js on Linux
      4. Development tools
      5. Writing and running your first "Hello World" app
        1. Running NW.js applications on Sublime Text 2
        2. Running NW.js applications on Microsoft Windows
        3. Running NW.js applications on Mac OS
        4. Running NW.js applications on Linux
      6. Summary
    10. 2. NW.js Native UI APIs
      1. The App API – the core of your applications
        1. Opening a file in your application natively
        2. Accessing the application data folder path
        3. Accessing the manifest file data
        4. Best practices for closing applications
        5. Registering system-wide hotkeys
        6. Other app APIs
      2. The Window API – working with windows on NW.js
        1. Instantiating a new window object
        2. Window – setting size and position of windows
        3. Changing the window status
        4. Fullscreen windows and the Kiosk mode
        5. Frameless windows and drag regions
        6. The taskbar icon – get the user's attention!
        7. Closing windows
        8. Other Window APIs
      3. The Screen API – screen geometry functions
      4. The Menu API – handling window and context menus
        1. The contextual menu
        2. The window menu
      5. File dialogs – opening and saving files
        1. Opening multiple files
        2. Filtering by file type
        3. Opening a directory
        4. Saving files
        5. Suggesting a default path
      6. Opening files through file dragging
      7. The Tray API – hide your application in plain sight
      8. The Clipboard API – accessing the system clipboard
      9. The Shell API – platform-dependent desktop functions
      10. Summary
    11. 3. Leveraging the Power of Node.js
      1. Routing and templating in NW.js
      2. Node.js global and process objects
      3. The window object
      4. Using NW.js' main module
      5. Handling paths in NW.js
      6. NW.js context issues
      7. Working with Node.js modules
        1. Internal modules
        2. Third-party modules written in JavaScript
        3. Third-party modules with C/C++ add-ons
      8. Summary
    12. 4. Data Persistence Solutions and Other Browser Web APIs
      1. Data persistence solutions
        1. Web storage
        2. Web SQL Database
        3. IndexedDB
      2. XMLHttpRequest and BLOBs
      3. Handling media files
      4. Shedding some light on security issues
      5. The Web Notifications API
      6. Summary
    13. 5. Let's Put It All Together
      1. Let's get started!
      2. A matter of style
      3. The HTML5 skeleton
      4. Let's dive deep into the application logic
      5. The application layer
        1. Adding a new task
        2. Loading all the tasks
        3. Implementing export and sync features
      6. The NativeUI layer
        1. Implementing the Window menu
        2. Implementing the Context menu
        3. Restoring the window position
        4. Implementing the Options window
        5. Closing the application
        6. Making the application open smoothly
      7. Summary
    14. 6. Packaging Your Application for Distribution
      1. The manifest file
      2. The general logic behind the packaging procedure
      3. Packaging NW.js applications for Mac OS X
        1. Associating a file extension with your application
      4. Packaging NW.js applications for Microsoft Windows
        1. Registering a file type association on Microsoft Windows
      5. Packaging NW.js applications for Linux
        1. Adding icon and file type associations on Linux
      6. Securing your source code
      7. About NW.js application licensing
      8. Summary
    15. 7. Automated Packaging Tools
      1. Web2Executable
      2. node-webkit-builder and grunt-node-webkit-builder
        1. grunt-node-webkit-builder
      3. generator-node-webkit
      4. Summary
    16. 8. Let's Debug Your Application
      1. Remote debugging
      2. The DevTools API
      3. Live reloading NW.js
      4. Troubleshooting common issues
      5. Summary
    17. 9. Taking Your Application to the Next Level
      1. NW.js boilerplates
        1. node-webkit-hipster-seed
        2. angular-desktop-app
        3. node-webkit-tomster-seed
        4. node-webkit-boilerplate
        5. nw-boilerplate
      2. Development ideas
      3. Resources and tutorials
      4. Summary
    18. Index