building native desktop applications with node-webkit
DESCRIPTION
We build web apps that runs on browser and server-side apps on Node.JS, but what’s about native Desktop applications? In this talk I will introduce node-webkit: an app runtime based on Chromium + Node.JS, you can use to build Desktop apps with JS and HTML, with no browser’s limitations like file-system calls or running native code.TRANSCRIPT
OUT OF THE SANDBOXBuilding native Desktop apps
by Marco Pracucci - CTO @spreakerat JsDayon May 14, 2014
mercoledì 14 maggio 14
@pracucci
WHY DESKTOP ?
mercoledì 14 maggio 14
@pracucci
Hackable text editorby GitHub
Atom.io
mercoledì 14 maggio 14
@pracucci
Spreaker Studio
Mix audio sourcesand broadcast liveby Spreaker
mercoledì 14 maggio 14
@pracucci
WHY DESKTOP ?HOW
mercoledì 14 maggio 14
@pracucci
NODE-WEBKIT
app runtime based upon
https://github.com/rogerwang/node-webkit
+
mercoledì 14 maggio 14
@pracucci
NODE-WEBKIT
runs on
developed byRoger Wang at Intel
mercoledì 14 maggio 14
@pracucci
package.json
{ “name”: “Demo”, “main”: “index.html”, “window”: { “width”: 600, “height”: 400 }}
index.html
<html><body> <h1>My App</h1></body></html>
GETTING STARTED
mercoledì 14 maggio 14
@pracucci
<script>
var fs = require(“fs”);
var _ = require(“underscore”);
var _ = require(“lame”);
</script>
Node modules (built-in)
3rd party modules in JavaScript
3rd party modules in C/C++
GETTING STARTED
npm install ...
mercoledì 14 maggio 14
@pracucci
FRONT OR BACK ?Should I use Angular or Express?
mercoledì 14 maggio 14
@pracucci
Think of it as a
frontend appthat can “just” use node modules
“”
mercoledì 14 maggio 14
@pracucci
Single Page Apps
app://whatever/path
DESIGN
Multiple Page Apps
Ease repackage of your websiteto a node-webkit app
{ “main”: “index.html”,}
{ “main”: “app://foo/index.html”,}
mercoledì 14 maggio 14
@pracucci
Generally speaking,
you can easily port your web appto node-webkit
“”
mercoledì 14 maggio 14
@pracucci
few builtin codecs,but you can rebuild libffmpegto add any format / codec
MULTIMEDIA
<audio><video><canvas>getUserMedia()WebRTCWebGL...
mercoledì 14 maggio 14
@pracucci
• returns the real path on filesystem • can open file dialog programmatically
<input type='file' />
FILE DIALOGS
mercoledì 14 maggio 14
@pracucci
Select a directory instead of a file
FILE DIALOGS
<input type='file' nwdirectory />
mercoledì 14 maggio 14
@pracucci
Select a (non) existing file
FILE DIALOGS
<input type='file' nwsaveas />
mercoledì 14 maggio 14
@pracucci
NATIVE UI MODULE
var gui = require('nw.gui');
Built-in module to control the Native UI:
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My App
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My Appgui.Window
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My App
gui.Menu
gui.Window
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My App
gui.Menu gui.Tray
gui.Window
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My App
gui.Menu gui.Tray
gui.Window
gui.Clipboard
mercoledì 14 maggio 14
@pracucci
My App File Edit 5:45 pm
My App
gui.Menu gui.Tray
gui.Window
gui.Clipboard gui.Shell
mercoledì 14 maggio 14
@pracucci
Source code will be exposed.Use nwsnapshot to compileto native code.(experimental)
zip -r app.nw *
1. Make a package
nw app.nw
2. Ship node-webit + app package
PACKAGING
mercoledì 14 maggio 14
@pracucci
Hard to contribute
CONTRIBUTING
You both need to knowChromium and Node.JS internals(and have a strong experience with C++)
mercoledì 14 maggio 14
@pracucci
with node-webkit you can easilybuild native desktop apps
(and have a lot of fun !)
SUMMARY
mercoledì 14 maggio 14
Thank you!
https://joind.in/11272Any feedback is welcome!
mercoledì 14 maggio 14