https://github.com/rogerwang/node-webkit
<!DOCTYPE html>
<html>
<body>
<script>
var os = require('os');
document.write('Our computer is: ', os.platform());
</script>
</body>
</html>
need I say more
{
"name": "hello",
"main": "index.html",
"window": {
"width": 800,
"height": 600
}
}
directly add your code to the .app bundle on OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-/Apple/DTD PLIST 1.0/EN" "http:/www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mycompany.myapp.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node/</string>
<string>/path/to/node/app.js</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
server
node_modules/
public/
src/
node
server.js
NSBundle *bundle = [NSBundle mainBundle]; NSString *nodeBinary = [bundle pathForResource:@"node" ofType:nil]; NSString *serverJs = [bundle pathForResource:@"server" ofType:@"js"]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:nodeBinary]; [task setArguments:@[serverJs, @"some", @"args"]];
NSPipe *nodeout = [NSPipe pipe]; [task setStandardOutput:nodeout]; [[nodeout fileHandleForReading] waitForDataInBackgroundAndNotify]; void (^callback)(NSNotification *) = ^(NSNotification *notification) { NSData *output = [[nodeout fileHandleForReading] availableData]; NSString *outStr = [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding]; // do something with outStr [[nodeout fileHandleForReading] waitForDataInBackgroundAndNotify]; }; [[NSNotificationCenter defaultCenter] addObserverForName:NSFileHandleDataAvailableNotification object:[nodeout fileHandleForReading] queue:nil usingBlock:callback]; [task launch];