forked from d3/d3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes a bug with the usage of `require` in env-js, such that env-js now uses proper relative paths rather than unshifting "." onto `require.paths`. The behavior of `require` is documented here: <http://nodejs.org/docs/v0.4.2/api/modules.html#all_Together...> With this change in place, it's now possible to use env-js simply by require'ing it from a script, rather than having env-js host and eval. Also, this commit changes the initialization of env-js, such that the initial document is immediately available when the env-js module is loaded. And, the event loop is disabled so that env-js shuts down cleanly. This probably breaks some parts of env-js, but it makes it much easier to use so I'm going to play with it a bit.
- Loading branch information
Showing
21 changed files
with
189 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
# Usage: envjs <platorm> file.js [file2.js ...] | ||
########################################################################### | ||
ENVJS_PLATFORM='node' | ||
|
||
# first arguments ($1) | ||
# may be a platform or is a file and the default platorm is used | ||
if [ -n "$1" ]; then | ||
if [ -n "$1" ]; then ENVJS_PLATFORM="$1"; shift; fi | ||
fi | ||
|
||
# Run envjs with the given platform | ||
########################################################################### | ||
case "$ENVJS_PLATFORM" in | ||
|
||
"node") | ||
node envjs/node.js $@ | ||
;; | ||
"rhino") | ||
java -Xmx512M -jar rhino/js.jar -opt -1 envjs/rhino.js $@ | ||
;; | ||
"rhino-debug") | ||
java -cp rhino/js.jar org.mozilla.javascript.tools.debugger.Main envjs/rhino.js $@ | ||
;; | ||
"spyd") | ||
python envjs/spydermonkey.py envjs/spydermonkey.js $@ | ||
;; | ||
"rubyracer") | ||
ruby -rrubygems envjs/rubyracer.rb envjs/rubyracer.js $@ | ||
;; | ||
"johnson") | ||
ruby -rrubygems envjs/johnson.rb envjs/johnson.js $@ | ||
;; | ||
*) | ||
# platform default means $1 was actually a file | ||
node envjs/node.js $ENVJS_PLATFORM $@ | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require.paths.unshift('.'); | ||
require('envjs/platform/node'); | ||
require('envjs/window'); | ||
require('./platform/node'); | ||
Envjs.eventLoop = function() {}; // disabled for clean shutdown | ||
|
||
require('./window'); | ||
new Window(__this__); // initialize a blank window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.