Skip to content
forked from nwjs/nw.js

Call all Node.js modules directly from DOM and enable a new way of writing applications with all Web technologies.

License

Notifications You must be signed in to change notification settings

getJavaScript/nw.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a NodeJS module for WebKit. With this module, your Javascript code in HTML can call NodeJS functions directly. The following demo lists the current directory in the page:

<html><head>
<title>testfs</title>
<script>
var fs = require('fs');

function test_fs() {
  var output = document.getElementById ('output');
  output.innerHTML = '';
  fs.readdir(".", function (err, files) {
    var result = '';
    files.forEach(function (filename) { result += filename + '<br/>'; } );
    output.innerHTML = result;
  });
}
</script></head>
<body onload="test_fs()">
<p id="output"></p>
</body>
</html>

From NodeJS code, you can manipulate DOM or run Javascript in DOM context as well:

var nwebkit;
nwebkit = require('nwebkit');

nwebkit.init ({'url' : "tests/testfs.html"},
      function() {
	  nwebkit.context.runScript("document.body.style.background='#a3a3a3'");
});

Dependencies

A patched version of CEF(Chromium Embedded Framework) is need to make this possible. Prebuilt binaries are available for Linux (Debian and Ubuntu), Windows and OSX.

The source of Chromium is at https://github.com/rogerwang/chromium

Other hacks on the dependencies are:

https://github.com/rogerwang/node https://github.com/rogerwang/libuv

Build from source

How it works

  • Chromium's (render process) main loop is merged with libev's main loop in NodeJS, so they can run in the same process.

  • WebKit is patched so the V8 context is merged (actually bridged) with the context from NodeJS. This makes NodeJS functions accessiable in web page.

Community

Welcome to join the discussion in our mailing list:

node-webkit@googlegroups.com

http://groups.google.com/group/node-webkit

subscribe via node-webkit+subscribe@googlegroups.com

Our vision

We believe that the async I/O framework in NodeJS and the Javascript programming language is a perfect combination for client (mobile) side applications. By bringing WebKit to NodeJS, a new way is avaliable to write applications with web technology. We'll contintue our development and support for this runtime. More platform and applications will be enabled.

License

MIT License

About

Call all Node.js modules directly from DOM and enable a new way of writing applications with all Web technologies.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 60.7%
  • JavaScript 21.3%
  • HTML 7.8%
  • Objective-C++ 5.9%
  • Python 2.4%
  • Objective-C 1.4%
  • Other 0.5%