-
7 Jun 2011 5:46 AM #1
Can you run SDK commands via rhino?
Can you run SDK commands via rhino?
I'm looking to auto-generate combined/compressed javascript within my java application when the all-classes.js URL is first requested (sort of like how jsp files are parsed and compiled when first executed).
So basically, I am needing to automate a call to "sencha create jsb -a http://localhost/path/to/application/index.php -p app.jsb3" and "sencha build -p app.jsb3 -d ." server-side.
It sort of works by executing the jsdb directly, but I am having problems with the process not actually exiting consistently.
Since it is a java application, I think it would be nice to simply be able to use the rhino javascript engine to execute the command/sencha.js directly since it would be running in-process and so I would have better control over how it is executing and will not have to worry about platform differences.
Does anyone know if rhino would be able to run the create and build commands? Or is there jsdb-specific javascript in there?
Nathan
-
7 Jun 2011 6:36 AM #2
Sencha SDK Tools uses Phantom JS (http://www.phantomjs.org/) to get dependencies list, this is "headless WebKit with JavaScript API" and this isn't java-application.
I don't think ExtJS 4.0 works correctly with Rhino js-engine... even more - Phino isn't HTML parser, so it's impossible to pass index.html to it.
To compress javascript you can use YUI compressor directly from Java. To get dependency list of js-files - you need to run phantomjs or any similar tool (it's not so hard to do this through System.exec or ProcessBuilder).
-
7 Jun 2011 6:44 AM #3Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
7 Jun 2011 6:57 AM #4
-
7 Jun 2011 7:20 AM #5
I don't need the whole ExtJS application to run under rhino, all I would need is the ability to get the "create jsb" and "build" commands to run. It does appear that the "create jsb" does run the all the initialization javascript, so we may need to be careful about what is in the init methods, but it seems like it should be possible.
ext-app-builder.bat uses phantomjs, but command and jsbuilder both use jsdb. Any idea why the difference? Are they using jsdb just as a javascript engine? Or are there calls in there to jsdb-specific functions like Stream and Process?
Nathan
Nathan
-
7 Jun 2011 7:40 AM #6Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
Rhino is just a JavaScript interpreter, it does not have the DOM implementation of a browser. So of course ExtJS won't run in it without adding something like JSDOM or env.js.
But I didn't see that as an issue... See this:
Not sure why you'd want to use Rhino, since it's 30x to 100x slower than the major browsers' JS engines. What it does have is threading, so you could do things in parallel...SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
7 Jun 2011 7:44 AM #7
"create jsb" in order to get dependency list runs whole ExtJS application inside PhantomJS (using WebKit engine).
So only with Rhino you cannot do "create jsb", if you will use PhantomJS - you don't need Rhino (PhantomJS can do everything that Rhino can).
I don't why Sencha use jsdb for for parsing argument and printing help instead of phantomjs, like as I don't know why they include Hammer JS and don't use it at all.
As for me, for building I created a simple js-script that returns deps list (a few lines from ext-app-builder.js), and in other shell script run it under phantomjs, create single file and compress with Yahoo js-compressor - result the same as after "sencha create jsb" && "sencha build", but everything is simple and works without problems everywhere (including Linux x64).
-
7 Jun 2011 1:23 PM #8
The reason I was looking at rhino is because I am already running inside a java environment, and I am trying to avoid forking a new process even at the expense of having a slow JS interpreter.
I hadn't realized ext did as much execution of your app in order to do "create jsb", and I see that ext-app-builder.js has references to phantom.fs, so it looks like rhino is not going to be an option.
I'll probably just have to see if I can do a better job of external-process management from java.
Nathan
-
7 Jun 2011 2:12 PM #9
This isn't big problem - you can write own ext-app-builder.js and use stdout instead of file i/o. The main problem in that fact, that you need to fully load your page like browsers do this, and only after this you can retrieve object Ext.Loader.history. Only in this case and if you correctly setup "require"d classes you will get full dependency list. Rhino can't do this. You should use js-engine only from one of supported by ExtJS browsers.
Execute external process in Java is very simple - good luck.
-
11 Aug 2011 1:43 AM #10
So is it possible to not use jsdb and use phantom instead???<br>Does someone knows how it's done?
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote
