1.0.0 • Published 5 years ago

nw-splasher v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

NW-Splasher

Small library to show a splash screen until main application loads.

The splash screen will run in a separate process so any animations will play smoothly while the app is loading.


Demo

Here is a demo projec that uses the nw-splasher.js and nw-splasher.css files:


Usage

  1. npm install --save nw-splasher
  2. Create a splash.html file and an index.html file (for your app)
  • Add this line to the <head> of both files.
  • <script src="node_modules/nw-splasher/nw-splasher.js"></script>
  1. In package.json set "main": "splash.html"
  2. In the splash.html run nwSplasher.loadAppWindowInBackground()
  3. In the index.html run nwSplasher.closeSplashAndShowApp() after the app is done loading and ready to be displayed

API

nwSplasher.loadAppWindowInBackground(url, newWindowOptions, port)

Used by your Splash screen window. This creates a websocket and spawns your main app in a hidden window. Then waits for the app to send a signal to the websocket to close the splash screen.

ArgumentOptionalTypeDescriptionDefaults
urlyesStringURL to load in the App window.Defaults to index.html, default.html, main.html, or app.html if those files exist, or the first html file it finds in the current directory. Console logs if no html file found.
newWindowOptionsyesObjectObject with the NW.js Window Subfields.show is always set to false. new_instance is always set to true.
portyesNumberIf you pass in a number it must match the same port number passed in the app window.Defaults to 4443.

nwSplasher.closeSplashAndShowApp(port)

Call this from your App window when it is ready to be shown. This will also trigger closing the Splash screen window.

ArgumentOptionalTypeDescriptionDefaults
portyesNumberIf you pass in a number it must match the same port number passed in the splash window.Defaults to 4443.