NodeJS Runtime for Chrome

483 views
Skip to first unread message

Arunoda Susiripala

unread,
Oct 31, 2012, 10:06:19 AM10/31/12
to nod...@googlegroups.com
Hi Guys,

Look at this amazing project: https://github.com/arunoda/chrome-node

with the reference of running node in chrome - http://www.youtube.com/watch?v=gkb_x9ZN0Vo&feature=g-all-lsb

Trygve Lie

unread,
Oct 31, 2012, 10:15:02 AM10/31/12
to nod...@googlegroups.com
Is this related to this from the Chrome team (video released yesterday):
http://www.youtube.com/watch?v=gkb_x9ZN0Vo

I've not have time to seen the video yet.

Trygve
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en


Tim Caswell

unread,
Oct 31, 2012, 10:16:25 AM10/31/12
to nod...@googlegroups.com
Neat idea, but it's certainly not new. The hard part is actually
making it work and finding a way to combine node's super open security
model with that required to run in a web browser.

If you just want to make desktop apps using nodejs + chrome's webkit
the appjs and node-webkit projects are pretty active. Since they are
desktop apps they don't have the sandbox security constraints of a web
app.

What's your plan for implementing the node runtime in chrome? It
sounds very interesting.

Roger WANG

unread,
Oct 31, 2012, 10:43:19 AM10/31/12
to nod...@googlegroups.com
Arunoda Susiripala <arunoda.s...@gmail.com> writes:

> Hi Guys,
>
> Look at this amazing project: https://github.com/arunoda/chrome-node

If you're interested in calling Node from DOM, here is another project
worth to check:

https://github.com/rogerwang/node-webkit

It's based on Chromium and Node.

> with the reference of running node in chrome -
> http://www.youtube.com/watch?v=gkb_x9ZN0Vo&feature=g-all-lsb

--
Roger WANG Intel Open Source Technology Center

P. Douglas Reeder

unread,
Oct 31, 2012, 10:50:26 AM10/31/12
to nod...@googlegroups.com
The video from the Chrome team is on using Browserify.

Arunoda Susiripala

unread,
Oct 31, 2012, 11:03:06 AM10/31/12
to nod...@googlegroups.com
Hi, 

I think with chrome we really don't need to much worry security model. Since chrome will take care of it.
What we actually need it set of wrappers for the core node APIs.

Yes. we will not have to use npm projects with c/c++ add-ons, but still we can you alot, as mentioned in the video using browserify.

Tim Caswell

unread,
Oct 31, 2012, 11:32:05 AM10/31/12
to nod...@googlegroups.com
On Wed, Oct 31, 2012 at 10:03 AM, Arunoda Susiripala
<arunoda.s...@gmail.com> wrote:
> Hi,
>
> I think with chrome we really don't need to much worry security model. Since
> chrome will take care of it.
> What we actually need it set of wrappers for the core node APIs.
>
> Yes. we will not have to use npm projects with c/c++ add-ons, but still we
> can you alot, as mentioned in the video using browserify.


Ok, so you're looking for a library that implements the node api in
pure javascript. That's basically what browserify does. Do be aware
that many node apis simply aren't possible to fully implement in the
browser because the dom doesn't provide the primitives required. But
as far as it's possible, it would be a neat project. You could even
fake a lot of the impossible APIs and let people hook in mock
providers. I've wanted to create something like this to let people
run a node repl purely in the browser.

Arunoda Susiripala

unread,
Oct 31, 2012, 11:44:07 AM10/31/12
to nod...@googlegroups.com
Yes. I browserify does it. The video show's that. But what I suggest is it will be cooler, we can bundle all the Node Core (if possible) into a single JS file which using Chrome new APIS.

What are the primitives which chrome is not possible to do? I have not much experience in Node Core. And I'm referring to chrome (but not other browser) which has native APIs for Socket API and so many others.


Tim Caswell

unread,
Oct 31, 2012, 12:15:57 PM10/31/12
to nod...@googlegroups.com
On Wed, Oct 31, 2012 at 10:44 AM, Arunoda Susiripala
<arunoda.s...@gmail.com> wrote:
> Yes. I browserify does it. The video show's that. But what I suggest is it
> will be cooler, we can bundle all the Node Core (if possible) into a single
> JS file which using Chrome new APIS.

It's not possible to take the JS in node as-is and put it in a
browser. Node consumes custom libuv C++ bindings that were designed
for node, not browser dom APIs. This would be a new implementation of
the node APIs on top of what the browser provides.

>
> What are the primitives which chrome is not possible to do? I have not much
> experience in Node Core. And I'm referring to chrome (but not other browser)
> which has native APIs for Socket API and so many others.

Go through the node API, it's not that big. http://nodejs.org/api/
And for each item, find a corresponding browser API that provides the
same abilities. Some problems I can see right away are:

fs.*. I'm not aware of any browser API that lets web pages read and
write a user's hard-drive
net.* While there are tcp clients coming to browsers, I have yet to
see any standard that allows binding to a port and listening on it.
child_process.* I'm pretty sure the browser doesn't allow a web page
to create arbitrary processes and execute them
...

If you're ok with requiring your users to use a specefic browser, why
not just use node-webkit or appjs and provide the webkit runtime for
them with all of node embedded already?

Jeff Barczewski

unread,
Nov 1, 2012, 1:04:39 PM11/1/12
to nod...@googlegroups.com
I agree with what you are saying Tim, just adding a couple comments.

On Wednesday, 31 October 2012 11:16:10 UTC-5, Tim Caswell wrote:
...


Go through the node API, it's not that big. http://nodejs.org/api/
And for each item, find a corresponding browser API that provides the
same abilities.  Some problems I can see right away are:

fs.*.  I'm not aware of any browser API that lets web pages read and
write a user's hard-drive


The File API (http://www.w3.org/TR/FileAPI/) is a working draft for being able to manipulate local files, but obviously this can be sandboxed (or not allowed). It is being implemented in modern browsers. (http://caniuse.com/#feat=fileapi)


 
net.* While there are tcp clients coming to browsers, I have yet to
see any standard that allows binding to a port and listening on it.
child_process.*  I'm pretty sure the browser doesn't allow a web page
to create arbitrary processes and execute them


These are obviously harder, but Firefox OS is building on ideas started by phonegap to provide API's for doing these other types of things. 

web workers would be a way of spawning new execution (but obviously not as rich as processes). 

In the context of creating new rich browser apps that have access to things previously reserved for desktop apps, I think these new API's (Firefox OS and phonegap/cordova) are exciting.

Arunoda Susiripala

unread,
Nov 1, 2012, 1:27:10 PM11/1/12
to nod...@googlegroups.com
Hi,

I'm talking about the chrome's canary build.
It has both tcp/udp socket access and file-system access. But not sure about the child-processes.
These api are for building add-ons and not for web apps.

Here is the node net module implementation for Chrome - https://github.com/PaulKinlan/net-browserify/blob/master/index.js

I think with this, it will be possible to use http, https and eventually express too.

Dean Mao

unread,
Nov 1, 2012, 1:35:16 PM11/1/12
to nod...@googlegroups.com
I have something similar as well called node-chimera, it's a meld of phantomjs inside of node basically.  An example runtime code looks like this:

var Chimera = require('chimera').Chimera;

var c = new Chimera();
c.perform({
  locals: {
    username: 'myuser',
    password: 'mypass'
  },
  run: function(callback) {
    jQuery('#username').val(username);
    jQuery('#password').val(password);
    jQuery('#login').click();
    callback(null, "success");
  },
  callback: function(err, result) {
    console.log('capture screen shot');
    c.capture("screenshot.png");

    var cookies = c.cookies();
    c.close();

    console.log("Browser cookies here:");
    console.log(cookies);
  }
});


Dave Kuhn

unread,
Nov 2, 2012, 2:58:30 PM11/2/12
to nod...@googlegroups.com
Chimera looks awesome Dean. Definitely something I'd be interested in evaluating over at tubes.io for our customers. What's the state of the documentation? Anything I can sink my teeth into?

Dave
Reply all
Reply to author
Forward
0 new messages