Packaging node-webkit App - javascript

https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps
While packaging my node-webkit app for windows using the steps given in the above link I could not find how to avoid readability of the resulting executable from the merge by archiving software, such as WinZip. EXCERPT(from link above): "The resulting executable from the merge will still be readable by archiving software, such as WinZip."
Is it possible to avoid readability by the archiving apps?
Any help is appreciated!

Fundamentally, running node-webkit is similar to running in a browser, so just as you can't hide your webpage source, you can't truly hide your HTML and CSS in such a way that it can't be read, because it needs to be read by node-webkit at runtime.
The situation is almost the same for Javascript code, with one exception. V8 (the javascript engine in Chrome) provides a "snapshot" capability, which sort of compiles your Javascript into a sort of bytecode that V8 understands. Nwsnapshot is available for node-webkit, which will allow you to avoid shipping your JS code (or at least some of it). However, this option is still experimental, and in fact there is a problem in version 0.8.* of node-webkit (referred to as v8 in the wiki, but not to be confused with the V8 js engine), though it should be working again now in v9. Details can be found here if you're interested:
https://github.com/rogerwang/node-webkit/wiki/Protect-JavaScript-source-code-with-v8-snapshot
Also be aware that it can have performance impacts, if that matters for your application.

You could also make an exe file.
See "Step 2b: Alternative way - Making an executable file out of a .nw file" from the link you provided.

Related

Compiling Dart into minifier friendly javascript: From dartdevc into google-closure-compiler

What compiler options are best to ensure that dartdevc generates minifier friendly javascript code which can be compressed by google closure compiler in ADVANCED mode.
Please show a tested example that specifies options for 1. dartdevc, and 2. java -jar goolge-closure-compiler.jar as a simple bash script, without pub.
Module type should be 'common' if possible, dart_sdk.js should be included, the final result should be es3 or es5 for compatibility with all browsers, and all output goes into one compressed .js file.
The dartdevc compiler is not meant for production usage at this time, and does not support any sort of "advanced" optimizations (such as those done by the Google Closure Compiler). Our only supported optimization path is using dart2js, our optimizing compiler which in many cases is as good as or better the Google Closure Compiler.
See "When should I use dartdevc" on our FAQ page:
Use dartdevc whenever you’re actively working on your code.
Keep using dart2js to build your deployed, production application. With dart2js you get advanced optimizations such as tree shaking to minimize downloaded code size.
I'm excited you'd like to see dartdevc work for more use cases, but we are concentrating on a great developer experience and keeping optimization usage in dart2js at this time.

Run compiled files on Google Native Client

How to run compiled files directly using Google Native Client (PNaCl)? It tried checking their documentation. It said that -
Native Client is a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user’s operating system.
But in their documentation, they only deal with sources of the application. Is there any way to run compiled code directly? I want to run files with .exe and .deb extensions
I'm not limiting the answer to Native Client. Any mechanism which can do that sort of work will work for me.
You can't run pre-compiled code within NaCl or PNaCl. You have to use the compilers provided by the SDK. There are three main reasons for this:
NaCl is an execution sandbox which relies on crafting machine code (x86-32, x86-64, ARM, MIPS) in a very particular way. This is regular machine code from the CPU's point of view, but allows the sandbox to run a validator and make sure that the code can't do anything malicious. This is called Software Fault Isolation, and is explained in this paper. The other ISA sandboxes are also documented.
PNaCl targets NaCl, but is an architecture-agnostic intermediate representation. This means that you ship what can be thought of as bytecode, and the browser figures out which type of machine code (x86-32, x86-64, ARM, MIPS) to generate based on the user's machine. The developer doesn't generate 4 binaries.
In both above cases, the code can execute as-is on Windows, MacOSX, Linux, ChromeOS, and (while not usually shipping) Android. This means that the NaCl sandbox presents itself as an operating system, and offers the same APIs. These APIs are different from other OSes, though they're pretty close to POSIX especially if you use nacl_io.
The above points require that you use the compilers provided by the SDK.
It is technically possible to run binaries built for other architectures or operating systems since the system is Turing-complete. That's what QEMU does, what Rosetta did, what Transmeta did, and what the Android Runtime for Chome (ARC) enables. This usually requires binary translation and emulation of all operating system calls. This is technically difficult to implement, and often has severe performance cost. I do not recommend exploring this option.
As #JFBastien pointed out, emulation is the only option to execute pre-compiled native code in the browser environment. But it is an option nevertheless. Depending on your demands on performance, it might even be a viable option.
Click here for example to boot up an emulator running Windows (a very old version though) in your browser.
From the menu pick, for example, notepad.exe (using the cursor down key on your keyboard) and hit enter. There you have it: an unmodified, precompiled, native notepad.exe running inside your browser! (and probably even faster than back in the day when this OS was new).
There are a lot of emulators written in Javascript all around the web. Running a small Linux distribution with usable performance and even with networking(!), graphics and sound is actually possible. Check out the OpenRISC emulator. You can even run an ssh daemon and log into it from your local machine!

Scripting layer for Android - LibGDX

I've been writing a full game engine on top of LibGDX for sometime now and had written almost every single game object in Javascript (I created a composite based game object system). For the JS interpretation, I used the Rhino engine which on my ubuntu system, works phenomenally well, however when I tried to run it on Android, I was not able to get it to compile at all and from what I HAD read, it's because Google didn't use a standard Java implementation that supported Rhino, but now I'm seeing the support with the SL4A project, however I was looking for a simple Rhino jar file that was compatible with Android but after looking through the downloads, all I found were APK files that did not appear to have the library and from what I have read, the APK is suppose to be a template project, but how can I use it with my existing code without a jar package? Maybe I'm totally missing the point?
It seems SL4A Rhino repository has all the necessary add-ons (among them rhino1_7R2-dex.jar) to get Rhino running on Android.

programming in javascript with Visual Studio (2010)?

Whether you are forced to code javascript in Visual Studio 2010, or insist on using Visual Studio 2010 instead of another IDE, I'm wondering what anyone has done to improve the javascript development experience in VS2010.
I'm asking since javascript support is lacking in Visual Studio 2010. You don't get the the kind of support you get as if you were developing Silverlight apps in C# and XAML. For example, the intellisense doesn't support javascript 1.8.5 (or even 1.6 functions i.e. JSON.Parse), it's difficult to navigate to function or object definitions (no Go To Definition), no Object Browser, Call Hierarchy, and the list can go on.
What have you done to compensate for the VS2010 features that don't exist for javascript? Also, what would be a good feature request to support javascript development; anything that VS2010 should add as an extension or a future release? Also, are there any suggestions to manage the .js code for large projects?
A few things that have helped me so far are the JScript Editor Extensions, and the Web Standards Update. Also, when working in .js files I rely on bookmarks to get back to key places, since the functions of the file aren't visible (as the would be in C#). My feature request would be to add intellisense support by javascript version, similar to how you can target .NET 2.0, 3.5, or 4.0.
There are a number of VS extensions to assist with javascript:
Visual Studio Javascript extensions feature comparison
JSEnhancements is awesome, and does what you really want: adds regions and code block collapsing.
Also see this extension: http://code.google.com/p/js-addin/
which parses your script into an object tree that can be used for navigation.
I have also used the free version of this editor: http://www.yaldex.com/JSFactory_Pro.htm
I can't recommend it, unfortunately, because it suffers from a couple critical problems (awkward UI, freaky intellisense, and not entirely stable). Which is too bad because it's a very thoughtfully designed piece of software by and large, it just fails where the rubber meets the road.
1) Install Resharper, helps a lot when building javascript heavy web apps.
2) Get FireBug for debugging.
3) Also, the JQuery.vsdocs files are sometimes helpful!
While I use vim and Notepad++ to cut code, I feel your pain, or did until I started using Firebug to debug JavaScript. While it many not be exactly fitting for your situation it's invaluable to me in developing Web based apps:
http://getfirebug.com/

Javascript and Windows

I noticed that if I have a .js file in windows explorer (not Internet Explorer, I'm meaning the folder explorer...) I can actually click on it and it will execute, giving error messages, like say "window object is undefined". Is there more information about the environment where the .js script are run into and the objects available?
Take a look at the Windows Scripting Host Docs (JScript).
Windows Script Host provides a reasonably rich environment allowing one to do a variety of interesting things - just yesterday I used it to create a tool that analyses a directory full of XML files which reference various resources such as images and other XML files, and produce an XML manifest in a predefined schema.
It's worth taking the time to get used to creating .wsf files (which use an XML-based syntax), rather than just running .js (JScript) or .vbs (VBScript) files - .wsf files offer much finer control over modularity and allow for better in-file documentation and usage explanations, and also allow scripts written in several different languages to be combined, which is handy if you find a VBScript that does 40% of what you need and don't want the hassle of converting it to use with the 60% you're writing in JScript.
The Windows® Scripting Guide provides technical resources, information and source code to help you automate the Windows® operating system using Windows® Script Host (WSH) and the VBScript and JScript scripting languages.
There is much information out there to get you started. There are many things you can do with it. I'm using a VBScript that makes the window handling work as in Linux (alt+Drag moves a window) with jus a few lines of code.
You can access many hooks to the system, including the file system. You can use any language that has registered itself with Windows Script Host, by default, VBScript and JScript.
You can run JScript (.js) and VBScript(.vbs) scripts directly in windows.
As what you have is a Javascript file intended to run in a web page, the environment that it expects is different. The window and document objects are only available inside the browser, so they don't work when you run the script outside the browser.
The objects that you have available are instead the ActiveX objects that are registered on the computer, like for example the Scripting.FileSystemObject object that you can use to access the file system.
JavaScript can be executed from the command line of any operating system provided you have access to a JavaScript interpreter that can be executed from the command line. The two common command line JavaScript interpreters are Rhino from Mozilla, which requires Java, and Windows Script Helper which can run natively in a Windows environment.

Categories