The aim of this project is to provide an easy and fast way for users to launch nw.js based applications. It consists of a small executable (nwjsmanager) for Windows and Linux which will manage a cache of one or more nw.js versions in a common directory on the user's machine. These nw.js runtime files are shared between multiple applications. The project defines a new way for developers to package their nw.js apps, without bundling the nw binaries with the application files; when a user installs an application packaged in this format, the installer (NSIS-based on Windows, or .deb/.rpm package on Linux) looks for nwjsmanager and extracts it if it's not already present on the computer, and launches it to ensure a suitable nw.js version is installed; if not, it downloads the latest compatible version. When the user launches the application, nwjsmanager checks if there is a nw.js version compatible with the application in the cache folder; if a suitable version is found, the application will be launched using it, otherwise the latest compatible version will be downloaded from http://dl.nwjs.io/ and put in the cache. This will avoid the 40MB+ nw.js download when the user installs another nw.js based application, speeding up the download&install process and saving hard drive space.
A tiny native executable (applauncher) is packed with the application: the developer can rename it accordingly to the application's name (and maybe add an icon on Windows), and it's purpose is to look for nwjsmanager and launch it with the correct arguments if it's found, or show a proper error message asking the user to reinstall the application if it's not (a copy of nwjsmanager, which is around 1MB, is shipped with applications and is installed if it isn't already).
This repository also contains a command line tool that automates the process of building packages and installers for your nw.js application. See it's README here. To start packaging applications with this system-wide nwjs installation method, get the cli tool from npm.
When nwjsmanager needs to download an nw.js version, the latest one compatible with the application is chosen. To specify which nw.js versions are compatible with your application, you need to add this section to your package.json
:
"nwjsmanager":{
"nwjs-version-filter": ">=0.15.1" //Example
}
The filter string is made of a semver operator and a version. See here for a list of supported operators.
Flowchart (bitmap version)
- There are currently a couple of issues with packages generated with the cli tool: https://github.com/gianluca-nitti/nw.js-global-install/issues.
- Repository with example application
- Thread on the nw.js discussion group
- Post on my blog
The tools in this repository are made possible thanks to the following projects. Both applauncher and nwjsmanager are compiled with gcc (natively on Linux and cross-compiled to Windows with MingW).
- applauncher links to:
- (Linux version only) GTK+, LGPL licensed, and related libraries (GDK, Pango, Glib (LGPL), Xlib (MIT))
- nwjsmanager links to:
- curl (MIT-like license)
- IUP (MIT), user interface library that uses the native Win32 API on Windows and GTK+ on Linux (which is dinamically linked with nwjsmanager too).
- jsmn (MIT)
- semver.c (MIT)
- zlib (zlib license) and uses parts of code from the following projects:
- (Windows version only) junzip (public domain/unlicense)
- (Windows version only) Part of the IsWow64Process function example, MS-PL licensed is included in the nwjsmanager/win-only/IsWow64.c file
- (Linux version only) untar.c (public domain, as stated in the source file)
- the cli tool uses the following node modules: