Skip to content
This repository
Browse code

fixing merge

  • Loading branch information...
commit e3c8f204803f112fda21de5ce0cfb8d243ef6bed 1 parent ea0f1d9
authored

Showing 191 changed files with 1,377 additions and 1,899 deletions. Show diff stats Hide diff stats

  1. 0  README.md
  2. 0  array.js b/engines/default/lib/array.js
  3. 0  base16.js b/lib/base16.js
  4. 0  base64.js b/lib/base64.js
  5. 0  bin/activate.bash
  6. 1  bin/all-tests.cmd
  7. 1  bin/cgi-test.sh
  8. 2  bin/fcgi-test.sh
  9. 2  bin/jackup
  10. 1  bin/jackup.cmd
  11. 0  binary-engine.js b/engines/default/lib/binary-engine.js
  12. 0  binary.js b/engines/browser/lib/binary.js
  13. 0  binary.wiki b/docs/lib/binary.wiki
  14. 0  c/d.js b/tests/iojs/nested/a/b/c/d.js
  15. 0  codec/base64.js b/lib/codec/base64.js
  16. 0  date.js b/engines/default/lib/date.js
  17. 0  docs/.gitignore
  18. 0  docs/{browser-deployment.md → browser-api-plan.md}
  19. 153  docs/browser-api.md
  20. 0  docs/engines.md
  21. 0  docs/modules.md
  22. 0  docs/narwhal.md
  23. 0  docs/packages.md
  24. 0  docs/posts/2009-07-29-hello-0.1.md
  25. 0  docs/sea.md
  26. 60  engines/browser/inline.js
  27. 1,450  engines/browser/lib/modules.js
  28. 2  engines/rhino/bin/narwhal-rhino
  29. 2  engines/rhino/bin/narwhal-rhino.cmd
  30. 0  engines/rhino/jars/jline.jar
  31. BIN  engines/rhino/jars/jna.jar
  32. 0  engines/rhino/jars/js.jar
  33. 3  engines/rhino/lib/io-engine.js
  34. 16  engines/rhino/lib/os-engine.js
  35. 11  engines/rhino/lib/zip.js
  36. 0  engines/rhino/package.json
  37. 0  engines/template/bootstrap.js
  38. 35  examples/browser-deployment-jackconfig.js
  39. 0  examples/not-quite-a-quine.js
  40. 0  file-engine.js b/engines/default/lib/file-engine.js
  41. 0  file-engine.js b/engines/template/lib/file-engine.js
  42. 0  file.js b/engines/secure/lib/file.js
  43. 0  file.wiki b/docs/lib/file.wiki
  44. 0  function.js b/engines/default/lib/function.js
  45. 0  global.js b/engines/default/lib/global.js
  46. 0  hash.js b/lib/hash.js
  47. 0  hashp.js b/lib/hashp.js
  48. 0  http-engine.js b/engines/rhino/lib/http-engine.js
  49. 0  http.js b/lib/http.js
  50. 0  io-engine.js b/engines/default/lib/io-engine.js
  51. 0  io.js b/lib/io.js
  52. 0  jsmin.js b/lib/jsmin.js
  53. 0  json.js b/engines/default/lib/json.js
  54. 0  jsonpath.js b/lib/jsonpath.js
  55. 94  lib/file.js
  56. 254  lib/narwhal/client.js
  57. 104  lib/narwhal/inline.js
  58. 1  lib/narwhal/server-test.js
  59. 351  lib/narwhal/server.js
  60. 14  lib/narwhal/tusk.js
  61. 220  lib/narwhal/tusk/install.js
  62. 18  lib/os.js
  63. 2  lib/packages.js
  64. 3  lib/term.js
  65. 0  local.json.template
  66. 0  md4.js b/lib/md4.js
  67. 0  md5-engine.js b/engines/rhino/lib/md5-engine.js
  68. 0  md5.js b/lib/md5.js
  69. 0  mime.js b/lib/mime.js
  70. 0  narwhal.conf.template
  71. 0  narwhal.gemspec
  72. 0  narwhal.js b/lib/narwhal.js
  73. 0  narwhal/json.md b/lib/narwhal/json.md
  74. 0  narwhal/repl.js b/lib/narwhal/repl.js
  75. 0  narwhal/tusk/bin.js b/lib/narwhal/tusk/bin.js
  76. 0  narwhal/tusk/bundle.js b/lib/narwhal/tusk/bundle.js
  77. 0  narwhal/tusk/catalog.js b/lib/narwhal/tusk/catalog.js
  78. 0  narwhal/tusk/clone.js b/lib/narwhal/tusk/clone.js
  79. 0  narwhal/tusk/consolidate.js b/lib/narwhal/tusk/consolidate.js
  80. 0  narwhal/tusk/engine.js b/lib/narwhal/tusk/engine.js
  81. 0  narwhal/tusk/freeze.js b/lib/narwhal/tusk/freeze.js
  82. 0  narwhal/tusk/init.js b/lib/narwhal/tusk/init.js
  83. 0  narwhal/tusk/list.js b/lib/narwhal/tusk/list.js
  84. 0  narwhal/tusk/orphans.js b/lib/narwhal/tusk/orphans.js
  85. 0  narwhal/tusk/reheat.js b/lib/narwhal/tusk/reheat.js
  86. 0  narwhal/tusk/remove.js b/lib/narwhal/tusk/remove.js
  87. 0  narwhal/tusk/search.js b/lib/narwhal/tusk/search.js
  88. 0  narwhal/tusk/update.js b/lib/narwhal/tusk/update.js
  89. 0  narwhal/tusk/upgrade.js b/lib/narwhal/tusk/upgrade.js
  90. 0  os-engine.js b/engines/default/lib/os-engine.js
  91. 0  os/popen.md b/docs/lib/os/popen.md
  92. 0  packages-engine.js b/engines/rhino/lib/packages-engine.js
  93. 0  packages/.gitignore
  94. 0  printf.js b/lib/printf.js
  95. 0  process.js b/engines/rhino/lib/process.js
  96. 0  promise.js b/lib/promise.js
  97. 0  reactor.js b/engines/browser/lib/reactor.js
  98. 0  reactor.js b/engines/default/lib/reactor.js
  99. 0  regexp.js b/lib/regexp.js
  100. 0  sandbox-engine.js b/engines/rhino/lib/sandbox-engine.js
  101. 0  sha.js b/lib/sha.js
  102. 0  struct.js b/lib/struct.js
  103. 0  system.js b/engines/browser/lib/system.js
  104. 0  system.js b/engines/default/lib/system.js
  105. 0  system.js b/engines/rhino/lib/system.js
  106. 0  system.js b/engines/secure/lib/system.js
  107. 0  system.js b/engines/template/lib/system.js
  108. 0  test/assert.js b/lib/test/assert.js
  109. 0  test/equiv.js b/lib/test/equiv.js
  110. 0  test/runner.js b/lib/test/runner.js
  111. 215  tests/args/domain.js
  112. 36  tests/args/options.js
  113. 92  tests/args/shifting.js
  114. 31  tests/args/validation.js
  115. 0  tests/base64.js
  116. 0  tests/file/all-tests.js
  117. 102  tests/file/match.js
  118. 0  tests/global.js
  119. 0  tests/global/array.js
  120. 0  tests/io/stringio.js
  121. 0  tests/iojs/absolute/b.js
  122. 0  tests/iojs/absolute/program.js
  123. 0  tests/iojs/absolute/submodule/a.js
  124. 0  tests/iojs/absolute/test.js
  125. 0  tests/iojs/config.js
  126. 0  tests/iojs/cyclic/a.js
  127. 0  tests/iojs/cyclic/b.js
  128. 0  tests/iojs/cyclic/program.js
  129. 0  tests/iojs/cyclic/test.js
  130. 0  tests/iojs/determinism/program.js
  131. 0  tests/iojs/determinism/submodule/a.js
  132. 0  tests/iojs/determinism/submodule/b.js
  133. 0  tests/iojs/determinism/test.js
  134. 0  tests/iojs/exactExports/a.js
  135. 0  tests/iojs/exactExports/program.js
  136. 0  tests/iojs/exactExports/test.js
  137. 0  tests/iojs/hasOwnProperty/hasOwnProperty.js
  138. 0  tests/iojs/hasOwnProperty/program.js
  139. 0  tests/iojs/hasOwnProperty/test.js
  140. 0  tests/iojs/hasOwnProperty/toString.js
  141. 0  tests/iojs/method/a.js
  142. 0  tests/iojs/method/program.js
  143. 0  tests/iojs/method/test.js
  144. 0  tests/iojs/missing/program.js
  145. 0  tests/iojs/missing/test.js
  146. 0  tests/iojs/monkeys/a.js
  147. 0  tests/iojs/monkeys/program.js
  148. 0  tests/iojs/monkeys/test.js
  149. 0  tests/iojs/nested/program.js
  150. 0  tests/iojs/nested/test.js
  151. 0  tests/iojs/relative/program.js
  152. 0  tests/iojs/relative/submodule/a.js
  153. 0  tests/iojs/relative/submodule/b.js
  154. 0  tests/iojs/relative/test.js
  155. 0  tests/iojs/transitive/a.js
  156. 0  tests/iojs/transitive/b.js
  157. 0  tests/iojs/transitive/c.js
  158. 0  tests/iojs/transitive/program.js
  159. 0  tests/iojs/transitive/test.js
  160. 0  tests/os/all-tests.js
  161. 0  tests/os/popen.js
  162. 0  tests/printf.js
  163. 0  tests/sandbox/byte-io.js
  164. 0  tests/sandbox/fileName.js
  165. 0  tests/sandbox/foo.js
  166. 0  tests/sandbox/reload.js
  167. 0  tests/serverjs/all-tests.js
  168. 0  tests/serverjs/bytearray-encodings-tests.js
  169. 0  tests/serverjs/bytestring-encodings-tests.js
  170. 0  tests/serverjs/bytestring-tests.js
  171. 0  tests/serverjs/file-tests.js
  172. 0  tests/serverjs/file/dirname.js
  173. 0  tests/serverjs/file/extension.js
  174. 0  tests/serverjs/file/is-absolute.js
  175. 0  tests/serverjs/file/iterator.js
  176. 0  tests/serverjs/file/normal.js
  177. 0  tests/serverjs/file/relative.js
  178. 0  tests/serverjs/file/resolve.js
  179. 0  tests/serverjs/module-tests.js
  180. 0  tests/util/array.js
  181. 0  tests/util/array/is-arguments.js
  182. 0  tests/util/array/is-array-like.js
  183. 0  tests/util/case.js
  184. 0  tests/util/eq.js
  185. 0  tests/util/object.js
  186. 0  tests/util/operator.js
  187. 0  tests/util/repr.js
  188. 0  tests/util/string.js
  189. 0  unload.js b/lib/unload.js
  190. 0  utf8.js b/lib/utf8.js
  191. 0  xregexp.js b/lib/xregexp.js
0  README.md 100644 → 100755
Source Rendered
File mode changed
0  array.js b/engines/default/lib/array.js 100644 → 100755
File mode changed
0  base16.js b/lib/base16.js 100644 → 100755
File mode changed
0  base64.js b/lib/base64.js 100644 → 100755
File mode changed
0  bin/activate.bash 100644 → 100755
File mode changed
1  bin/all-tests.cmd
1  bin/cgi-test.sh
2  bin/fcgi-test.sh
2  bin/jackup
1  bin/jackup.cmd
0  binary-engine.js b/engines/default/lib/binary-engine.js 100644 → 100755
File mode changed
0  binary.js b/engines/browser/lib/binary.js 100644 → 100755
File mode changed
0  binary.wiki b/docs/lib/binary.wiki 100644 → 100755
Source Rendered
File mode changed
0  c/d.js b/tests/iojs/nested/a/b/c/d.js 100644 → 100755
File mode changed
0  codec/base64.js b/lib/codec/base64.js 100644 → 100755
File mode changed
0  date.js b/engines/default/lib/date.js 100644 → 100755
File mode changed
0  docs/.gitignore 100644 → 100755
File mode changed
0  docs/browser-deployment.md → docs/browser-api-plan.md
Source Rendered
File renamed without changes
153  docs/browser-api.md
Source Rendered
... ...
@@ -0,0 +1,153 @@
  1
+
  2
+Browser Deployment
  3
+==================
  4
+
  5
+To use modules on the client side, one option is to use a
  6
+JSGI application provided with Narwhal.
  7
+
  8
+    var SERVER = require("narwhal/server");
  9
+    var app = ...
  10
+    app = SERVER.App(app, options);
  11
+    ...
  12
+
  13
+Options:
  14
+
  15
+ * `debug`: causes the loader to favor debug information over
  16
+   performance.  This disables bundling, minification,
  17
+   and caching (maybe).
  18
+ * `path`: overrides the path used for server-hosted modules.
  19
+   For example, "javascript/" instead of the default, ".js/".
  20
+   This is intended to avoid collisions with existing services
  21
+   down the routing cascade.
  22
+ * `proxy`: Alternate URL to search for scripts.
  23
+
  24
+This option has not been implemented yet:
  25
+
  26
+ * `catalog`: Alternate URLs for individual scripts or
  27
+   script bundles.
  28
+
  29
+This introduces an API to the "env" for all subsequent
  30
+poritions of the request route.  The first form loads a module
  31
+and its transitive dependencies:
  32
+
  33
+    env.script.require(id)
  34
+
  35
+The second form aynchronously loads the given modules and
  36
+their transitive dependencies, but does not invoke any
  37
+of them.
  38
+
  39
+    env.script.preload([id...])
  40
+
  41
+You can also embed a call to require a module and its transitive dependencies
  42
+instead of loading them with asynchronous script injection.
  43
+
  44
+    env.script.embed("main")
  45
+
  46
+If you just need to install the loader and you intend to use the loader
  47
+manually, you can inject it.  The `script.loader` function will return a bit of
  48
+JavaScript that will return an expression that evaluates to the `require`
  49
+object in JavaScript.  The first time it's called, this will be the full text
  50
+of the loader, but thereafter it will simply be the global `require` variable.
  51
+
  52
+    env.script.loader()
  53
+
  54
+These functions return unescaped JavaScript text
  55
+suitable for inserting in an HTML `<script>` tag.  The intent
  56
+is for you to use these functions through whatever template
  57
+formatting system your site uses, as in this speculative
  58
+example:
  59
+
  60
+    <script>{{env.script.require("main")|javascript}}</script>
  61
+
  62
+Or, with a higher level API that could be implemented to look like:
  63
+
  64
+    {% script.require "main" %}
  65
+
  66
+If you intend to use modules in inline scripts, you will need to wait for the
  67
+desired modules to load before you execute your code.  The `require.when`
  68
+function executes a block of code when a module is *ready* to be required.
  69
+
  70
+    <script>
  71
+        require.when("main", function () {
  72
+            var MAIN = require("main");
  73
+            ...
  74
+        });
  75
+    </script>
  76
+
  77
+You can also use promises directly with the `require.async` call, which
  78
+performs an asynchronous require that fulfills the returned promise with the
  79
+required module's exports.
  80
+
  81
+    <script>
  82
+        (function () {
  83
+            var Q = require("promise");
  84
+            Q.when(require.async("main"), function (MAIN) {
  85
+                ...
  86
+            });
  87
+        })();
  88
+    </script>
  89
+
  90
+The synchronous `require` call may throw an error if you use it without
  91
+ensuring that the module you want has been loaded.
  92
+
  93
+    {{env.script.preload(["foo"])|javascript}}
  94
+    <script>
  95
+        require("bar"); // throws up
  96
+    </script>
  97
+
  98
+However, you can make asynchronous require calls without preloading the
  99
+corresponding modules.  Missing dependencies will be fetched on demand in a
  100
+dynamic, albeit chatty fashion that may not take full advantage of the network
  101
+capacity.
  102
+
  103
+    {{env.script.loader()|javascript}}
  104
+    <script>
  105
+        (function () {
  106
+            var Q = require("promise");
  107
+            Q.when(require.async("bar"), function (MAIN) {
  108
+                ...
  109
+            });
  110
+        })();
  111
+    </script>
  112
+
  113
+
  114
+Fin
  115
+===
  116
+
  117
+Features below this line have not been implemented.
  118
+
  119
+
  120
+*****
  121
+
  122
+If you want to use modules but are not using a JSGI application
  123
+to host them, you will need to use "tusk" to build a module
  124
+root.  You will need to do this every time any of your
  125
+modules change.
  126
+
  127
+    tusk ...
  128
+
  129
+To load the modules in the browser, use the require script
  130
+with the name of the desired root module as the anchor.
  131
+
  132
+    <script src="require.js#main"></script>
  133
+
  134
+Or
  135
+
  136
+    <script src="require.js"></script>
  137
+    <script>
  138
+        require.load("main");
  139
+        require.ready(function () {
  140
+            var MAIN = require("main");
  141
+        });
  142
+    </script>
  143
+
  144
+Or use tusk to generate a script that you can include in
  145
+your static HTML.
  146
+
  147
+    tusk ...
  148
+
  149
+Or, if you can't tolerate a build step, and are willing to
  150
+host your package tree from origin, you can use the XHR loader.
  151
+
  152
+    <script src="require-xhr.js#main"></script>
  153
+
0  docs/engines.md 100644 → 100755
Source Rendered
File mode changed
0  docs/modules.md 100644 → 100755
Source Rendered
File mode changed
0  docs/narwhal.md 100644 → 100755
Source Rendered
File mode changed
0  docs/packages.md 100644 → 100755
Source Rendered
File mode changed
0  docs/posts/2009-07-29-hello-0.1.md 100644 → 100755
Source Rendered
File mode changed
0  docs/sea.md 100644 → 100755
Source Rendered
File mode changed
60  engines/browser/inline.js
... ...
@@ -1,60 +0,0 @@
1  
-(function (ids, id, path) {
2  
-
3  
-    var factories = {};
4  
-    var pending;
5  
-
6  
-    var require = this.require = function (id, baseId) {
7  
-        // defer to require set later from the sandbox module
8  
-        require(id, baseId);
9  
-    };
10  
-
11  
-    require.register = function (id, factory) {
12  
-        factories[id] = factory;
13  
-        if (!--pending)
14  
-            main();
15  
-    };
16  
-
17  
-    var pending = ids.length;
18  
-    var head = document.getElementsByTagName('head')[0];
19  
-    for (var i = 0; i < pending; i++) {
20  
-        var script = document.createElement('script');
21  
-        script.src = path + ids[i] + '.js';
22  
-        head.appendChild(script);
23  
-        // TODO
24  
-        //document.documentElement.insertBefore(script, document.documentElement.firstChild);
25  
-        // prepend instead of append to avoid KB917927
26  
-        // - Kean Tan <http://www.karmagination.com/>
27  
-    };
28  
-
29  
-    function main() {
30  
-
31  
-        var system = {};
32  
-        system.print = function () {
33  
-            if (typeof console != "undefined") {
34  
-                console.log(Array.prototype.join.call(arguments, ' '));
35  
-            }
36  
-        };
37  
-
38  
-        var loader = {};
39  
-        loader.reload = function (topId) {
40  
-            return factories[topId];
41  
-        };
42  
-        loader.load = function (topId) {
43  
-            return loader.reload(topId);
44  
-        };
45  
-
46  
-        var sandbox = {};
47  
-        loader.load('sandbox')(
48  
-            null,
49  
-            sandbox,
50  
-            {},
51  
-            system,
52  
-            system.print
53  
-        );
54  
-        require = sandbox.Sandbox({loader: loader});
55  
-        loader.resolve = sandbox.resolve;
56  
-        require(id);
57  
-
58  
-    }
59  
-
60  
-})
1,450  engines/browser/lib/modules.js
... ...
@@ -1,1450 +0,0 @@
1  
-
2  
-/*preamble-kriskowal
3  
-    Copyright (c) 2002-2009 Kris Kowal <http://cixar.com/~kris.kowal>
4  
-    MIT License
5  
-*/
6  
-
7  
-/*
8  
-    isolate the module loader in an enclosure by creating an
9  
-    annonymous function and then--at the end of this file--
10  
-    calling it.
11  
-
12  
-    also, take the evalGlobal function as an argument so that it can be
13  
-    declared in global scope.  this prevents the eval function
14  
-    from inheriting variables from the modulesjs enclosure scope.
15  
-*/
16  
-(function (evalGlobal) {
17  
-
18  
-    /*
19  
-        kernel module factory functions.  this module bootstrapper script
20  
-        can also be used as a module, since it contains module
21  
-        factory functions that can be used to bootstrap platform-specific
22  
-        modules.  to that end, we export the module factory functions if
23  
-        there is an ambient "exports" object
24  
-    */
25  
-    var factories = typeof exports == "undefined" ? {} : exports;
26  
-    /* kernel module instances */
27  
-    var modules = {};
28  
-
29  
-    /*
30  
-        a rudimentary require function to jumpstart
31  
-        the module system
32  
-    */
33  
-    var require = function (id) {
34  
-        if (!Object.prototype.hasOwnProperty.call(modules, id)) {
35  
-            var exports = {};
36  
-            modules[id] = exports;
37  
-            factories[id](require, exports, system);
38  
-        }
39  
-        return modules[id];
40  
-    };
41  
-
42  
-    /* a permissive system for kernel modules */
43  
-    var system = {
44  
-        window: window,
45  
-        evalGlobal: evalGlobal
46  
-    };
47  
-
48  
-    factories.main = function (require, exports, system) {
49  
-
50  
-        var FILE = 'modules'; /* used to find the corresponding <script> */
51  
-
52  
-        var urls = require('urls');
53  
-        var browser = require('browser');
54  
-        var console = require('console');
55  
-
56  
-        var window = system.window;
57  
-        var document = window.document;
58  
-        system.print = console.print;
59  
-        system.messages = console.messages;
60  
-
61  
-        /* grab the URL of modules.js relative to the containing page,
62  
-           and remove the <script> tag that invoked this module loader
63  
-           from the DOM for maximum stealth.
64  
-        */
65  
-        var PATH = urls.resolve(function () { /* enclosure */
66  
-            var scripts = document.getElementsByTagName("script");
67  
-            for (var i = 0; i < scripts.length; i++) {
68  
-                var script = scripts[i];
69  
-                if (browser.hasAttr(script, "src")) {
70  
-                    var src = script.getAttribute("src");
71  
-                    src = urls.parse(src);
72  
-                    if (src.file == FILE) {
73  
-                        script.parentNode.removeChild(script);
74  
-                        return urls.resolve(src, window.location.href);
75  
-                    }
76  
-                }
77  
-            }
78  
-            throw new Error("could not find '" + FILE + "' <script>");
79  
-        }());
80  
-
81  
-        /* wait for the DOM to be fully loaded */
82  
-        browser.observeDomReady(function () {
83  
-
84  
-            var sandbox = require('sandbox');
85  
-            sandbox.execUrl(PATH, PATH, system);
86  
-
87  
-            /* note for CSS that JavaScript is enabled, and ready */
88  
-            document.body.className = document.body.className + ' javascript';
89  
-
90  
-        });
91  
-
92  
-    };
93  
-
94  
-    factories.sandbox = function (require, exports, system) {
95  
-
96  
-        var http = require('http');
97  
-        var urls = require('urls');
98  
-        var evalGlobal = system.evalGlobal;
99  
-
100  
-        exports.Loader = function (options) {
101  
-            options = options || {};
102  
-            var factories = options.factories || {};
103  
-            var path = options.path;
104  
-            var exportsLocal = options.exportsLocal;
105  
-            var importsLocal = options.importsLocal;
106  
-
107  
-            var loader = {};
108  
-
109  
-            loader.fetch = function (id) {
110  
-                var url = urls.resolve(id, path) + '.js';
111  
-                return http.requestContent(url);
112  
-            };
113  
-
114  
-            loader.evaluate = function (text, id) {
115  
-                var iojs = /"use iojs";/.test(text);
116  
-                /* optionally bring imports into scope with include */
117  
-                if (importsLocal && !iojs)
118  
-                    text = "with (imports||{}) {" + text + "}";
119  
-                /* optional bring exports into scope when assigned to exports */
120  
-                if (exportsLocal && !iojs)
121  
-                    text = "with (exports) {" + text + "}";
122  
-                /* safeguard "var" declarations from being
123  
-                 * applied to the "with" object in ES3-non-conformant browsers
124  
-                 * (really only Safari < 3) */
125  
-                if ((importsLocal || exportsLocal) && !iojs)
126  
-                    text = "(function () {" + text + "}).apply(this, arguments)";
127  
-                if (iojs)
128  
-                    text = "include = undefined; " + text;
129  
-                text = (
130  
-                    "(function (require, exports, module, system, print, include, imports) {" +
131  
-                        text +
132  
-                    "})"
133  
-                );
134  
-                /* annotate with the module id */
135  
-                if (id)
136  
-                    text = '/* ' + id + ' */ ' + text;
137  
-                return evalGlobal(text);
138  
-            };
139  
-
140  
-            loader.resolve = function (id, baseId) {
141  
-                if (typeof id != "string")
142  
-                    throw new Error("module id '" + id + "' is not a String");
143  
-                if (!baseId) {
144  
-                    baseId = path;
145  
-                }
146  
-                if (id.charAt(0) != ".") {
147  
-                    baseId = path;
148  
-                }
149  
-                return urls.resolve(id, baseId);
150  
-            };
151  
-
152  
-            loader.load = function (id) {
153  
-                if (!Object.prototype.hasOwnProperty.call(factories, id)) {
154  
-                    factories[id] = loader.evaluate(loader.fetch(id), id);
155  
-                }
156  
-                return factories[id];
157  
-            };
158  
-
159  
-            loader.getPath = function () {
160  
-                return path;
161  
-            };
162  
-
163  
-            return loader;
164  
-        };
165  
-
166  
-        exports.Sandbox = function (options) {
167  
-            options = options || {};
168  
-            var loader = options.loader || exports.Loader(options);
169  
-            var sandboxSystem = options.system || system;
170  
-            var modules = options.modules || {};
171  
-            var debug = options.debug === true;
172  
-            var main;
173  
-
174  
-            var debugDepth = 0;
175  
-
176  
-            var sandbox = function (id, baseId) {
177  
-
178  
-                id = loader.resolve(id, baseId);
179  
-
180  
-                /* populate memo with module instance */
181  
-                if (!Object.prototype.hasOwnProperty.call(modules, id)) {
182  
-
183  
-
184  
-                    if (debug) {
185  
-                        debugDepth++;
186  
-                        var debugAcc = "";
187  
-                        for (var i = 0; i < debugDepth; i++) debugAcc += "+";
188  
-                        system.print(debugAcc + " " + id, 'module');
189  
-                    }
190  
-
191  
-                    var exports = modules[id] = new Module();
192  
-                    var factory = loader.load(id);
193  
-                    var require = Require(id);
194  
-                    var module = {id: id};
195  
-                    var imports = {};
196  
-                    var include = Include(require, imports);
197  
-                    try {
198  
-                        factory.call(
199  
-                            exports,
200  
-                            require,
201  
-                            exports,
202  
-                            module,
203  
-                            sandboxSystem,
204  
-                            sandboxSystem.print,
205  
-                            include,
206  
-                            imports
207  
-                        );
208  
-                    } catch (exception) {
209  
-                        delete modules[id];
210  
-                        throw exception;
211  
-                    }
212  
-
213  
-                    if (debug) {
214  
-                        var debugAcc = "";
215  
-                        for (var i = 0; i < debugDepth; i++) debugAcc += "-";
216  
-                        system.print(debugAcc + " " + id, 'module');
217  
-                        debugDepth--;
218  
-                    }
219  
-
220  
-
221  
-                }
222  
-
223  
-                /* snapshot exports with requested bound methods */
224  
-                var exports = modules[id];
225  
-                var imports = new Module();
226  
-                var importsUsed = false;
227  
-                for (var name in exports) {
228  
-                    if (
229  
-                        exports[name] !== undefined &&
230  
-                        exports[name] !== null &&
231  
-                        exports[name].xChironCurryId
232  
-                    ) {
233  
-                        importsUsed = true;
234  
-                        imports[name] = (function (callback) {
235  
-                            var curried = function () {
236  
-                                return callback.apply(
237  
-                                    this,
238  
-                                    [baseId].concat(Array.prototype.slice.call(arguments, 0))
239  
-                                );
240  
-                            };
241  
-                            curried.xChironCurryId = callback;
242  
-                            return curried;
243  
-                        })(exports[name].xChironCurryId);
244  
-                    } else {
245  
-                        imports[name] = exports[name];
246  
-                    }
247  
-                }
248  
-
249  
-                if (!importsUsed)
250  
-                    imports = exports;
251  
-
252  
-                return imports;
253  
-            };
254  
-
255  
-            var Require = function (baseId) {
256  
-                var require = function (id) {
257  
-                    try {
258  
-                        return sandbox(id, baseId);
259  
-                    } catch (exception) {
260  
-                        if (exception && !exception.message)
261  
-                            exception.message = 'Error';
262  
-                        try {
263  
-                            try {
264  
-                                eval("throw new Error()");
265  
-                            } catch (deliberate) {
266  
-                                if (deliberate.lineNumber !== undefined)
267  
-                                    exception.message += ' at ' + (exception.lineNumber - deliberate.lineNumber + 1);
268  
-                            }
269  
-                            exception.message += ' in ' + baseId;
270  
-                        } catch (ignore) {
271  
-                        }
272  
-                        throw exception;
273  
-                    }
274  
-                };
275  
-
276  
-                require.loader = loader;
277  
-
278  
-                /* extensions */
279  
-                require.xChironModule = Module;
280  
-                require.xChironId = baseId;
281  
-                require.main = main;
282  
-                require.xChironCurryId = function (callback) {
283  
-                    var curried = function () {
284  
-                        return callback.apply(
285  
-                            this,
286  
-                            [baseId].concat(Array.prototype.slice.call(arguments))
287  
-                        );
288  
-                    };
289  
-                    curried.curryId = callback;
290  
-                    return curried;
291  
-                };
292  
-                require.xChironIsLoaded = function (id) {
293  
-                    return Object.prototype.hasOwnProperty.call(modules, urls.resolve(id, baseId));
294  
-                };
295  
-                return require;
296  
-            };
297  
-
298  
-            var Include = function (require, imports) {
299  
-                return function (id) {
300  
-                    var exports = require(id);
301  
-                    for (var name in exports) {
302  
-                        imports[name] = exports[name];
303  
-                    };
304  
-                    return exports;
305  
-                };
306  
-            };
307  
-
308  
-            sandbox.main = function (id, baseId) {
309  
-                main = loader.resolve(id, baseId);
310  
-                return sandbox(main);
311  
-            };
312  
-
313  
-            /* just for use as a base prototype */
314  
-            var Module = function () {};
315  
-
316  
-            return sandbox;
317  
-        };
318  
-
319  
-        /* execUrl is a utility method of this ipmlementation, not necessary
320  
-         * for the interoperable modules specification. */
321  
-        exports.execUrl = function (url, PATH, sandboxSystem) {
322  
-
323  
-            /* populate a list of initial ids from the query string of the PATH */
324  
-            var mainIds = [];
325  
-            var url = urls.parse(url);
326  
-            if (url.query != "") {
327  
-                mainIds = url.query.split("&");
328  
-                if (/^path=(.*)/.test(mainIds[0])) {
329  
-                    PATH = urls.resolve(/^path=(.*)/.exec(mainIds[0])[1], system.window.location.href);
330  
-                    mainIds.shift();
331  
-                }
332  
-            }
333  
-
334  
-            /* load main modules */
335  
-            sandboxSystem.moduleFactories = system.moduleFactories || {};
336  
-            var sandbox = exports.Sandbox({
337  
-                path: PATH,
338  
-                importsLocal: true,
339  
-                exportsLocal: true,
340  
-                system: sandboxSystem//,
341  
-                //factories: sandboxSystem.moduleFactories
342  
-            });
343  
-            for (var i = 0; i < mainIds.length; i++) {
344  
-                try {
345  
-                    sandbox.main(mainIds[i], system.window.location.href);
346  
-                } catch (exception) {
347  
-                    sandboxSystem.print('' + exception, 'error');
348  
-                    throw exception;
349  
-                }
350  
-            }
351  
-
352  
-            /* notify the user that all main modules have finished loading */
353  
-            sandboxSystem.print('ready', 'info');
354  
-
355  
-        };
356  
-
357  
-    };
358  
-
359  
-    factories.environment = function (require, exports, system) {
360  
-
361  
-        if (system.window) {
362  
-            var window = system.window;
363  
-            var navigator = window.navigator;
364  
-
365  
-            exports.isIE = navigator.appVersion.indexOf("MSIE") >= 0;
366  
-            exports.isSafari = navigator.appVersion.indexOf("Safari") >= 0;
367  
-            exports.isOpera = !!window.opera;
368  
-        }
369  
-
370  
-    };
371  
-
372  
-    factories.console = function (require, exports, system) {
373  
-
374  
-        var window = system.window;
375  
-        var console = system.console || window.console;
376  
-
377  
-        /*** exports
378  
-        */
379  
-        exports.messages = [];
380  
-
381  
-        /*** print
382  
-
383  
-            accepts:
384  
-             - a ``message`` and 
385  
-             - an optional ``label``.
386  
-
387  
-            The label, by convention, is one of `"log"``, ``"info"``,
388  
-            ``"warn"``, or ``"error"``.  Custom loggers treat labels like
389  
-            ``"module"``, ``"pass"``, or ``"fail"``.  Attempts to write
390  
-            the message to `window.console`, progressively handling
391  
-            `console` implementations that provide a function for the 
392  
-            given ``label``, or defaulting to `log` depending on
393  
-            availability.
394  
-
395  
-            Also adds a ``[message, label]`` array to the end
396  
-            of `messages`.  ``label`` is one of ``"log"``,
397  
-            ``"warn"``, ``"info"``, or ``"error"`` by convention.
398  
-            In Safari, `log` writes to the Javascript debug console, which
399  
-            is only available if you set the preference::
400  
-
401  
-                defaults write com.apple.Safari IncludeDebugMenu 1
402  
-
403  
-            Or in Safari 3::
404  
-
405  
-                defaults write com.apple.Safari IncludeDevelopMenu 1
406  
-
407  
-            And in Safari 4, the preference has been exposed
408  
-            in the Advanced tab; check "Show Develop Menu".
409  
-
410  
-            In Firefox, you can get a debug console with Firebug,
411  
-            http://getfirebug.com.
412  
-
413  
-            You can override the behavior of `log` by assigning
414  
-            a different function to ``require('environment').log``
415  
-            in any module.
416  
-
417  
-            Chiron can create a debug console for the purpose of
418  
-            unit testing or page debugging.  To debug a web page,
419  
-            use `modules.js` to include `debug.js` on a page.
420  
-            To run a unit test, view `run.html`, `lite.html`,
421  
-            or `edit.html` with the `moduleId` of the unit test
422  
-            as a query string.
423  
-
424  
-        */
425  
-        exports.print = function (message, label) {
426  
-
427  
-            label = label || 'log';
428  
-
429  
-            /*
430  
-                buffer messages so that console overrides
431  
-                can retrieve and display them later.
432  
-            */
433  
-            exports.messages.push([message, label]);
434  
-
435  
-            /*
436  
-                attempt to send the message to window.console if it
437  
-                exists, progressively handling the availability
438  
-                of a logging function crafted especially for the
439  
-                requested label, or defaulting to 'log'.
440  
-            */
441  
-
442  
-            if (console) {
443  
-                if (console.print) {
444  
-                    console.print(message, label);
445  
-                } else if (console[label]) {
446  
-                    console[label](message);
447  
-                } else if (console.log) {
448  
-                    console.log(message);
449  
-                }
450  
-            }
451  
-
452  
-        };
453  
-
454  
-    };
455  
-
456  
-    factories.browser = function (require, exports, system) {
457  
-
458  
-        var environment = require('environment');
459  
-        var window = system.window;
460  
-        var document = window.document;
461  
-        var top = window.top;
462  
-
463  
-        exports.hasAttr = function (element, key) {
464  
-            if (element.hasAttribute) {
465  
-                exports.hasAttr = function (element, key) {
466  
-                    return element.hasAttribute(key);
467  
-                };
468  
-                return exports.hasAttr(element, key);
469  
-            } else {
470  
-                exports.hasAttr = function (element, key) {
471  
-                    var node = element.getAttributeNode(key);
472  
-                    return node && node.specified;
473  
-                };
474  
-                return exports.hasAttr(element, key);
475  
-            }
476  
-        };
477  
-
478  
-        var isDomReady = false;
479  
-        exports.observeDomReady = function (callback) {
480  
-
481  
-            /* call immediately if we've already noted a DOM
482  
-             * ready event */
483  
-            if (isDomReady)
484  
-                return callback();
485  
-
486  
-            /* arrange to call back exactly once, even if multiple
487  
-             * methods of detecting dom completion call "ready" */
488  
-            var hasCalledBack = false;
489  
-            var ready = function () {
490  
-                if (hasCalledBack)
491  
-                    return;
492  
-                hasCalledBack = true;
493  
-                isDomReady = true;
494  
-                callback();
495  
-            };
496  
-
497  
-            /*
498  
-                wait for the DOM and CSS to be ready, but don't wait
499  
-                for images unless they're absolutely necessary.
500  
-                
501  
-                ported from jQuery's event.js, with previous implementations
502  
-                taking from similar sources, including Dean Edwards
503  
-                and PPK.
504  
-            */
505  
-
506  
-            /*
507  
-                Opera uses DOMContentLoaded but has special code for
508  
-                pending style sheets.
509  
-            */
510  
-            if (environment.isOpera)
511  
-                document.addEventListener("DOMContentLoaded", function () {
512  
-                    if (isDomReady) return;
513  
-                    for (var i = 0; i < document.styleSheets.length; i++)
514  
-                        if (document.styleSheets[i].disabled) {
515  
-                            window.setTimeout(arguments.callee, 0);
516  
-                            return;
517  
-                        }
518  
-                    // and execute any waiting functions
519  
-                    ready();
520  
-                }, false);
521  
-
522  
-            /* Mozilla and WebKit nightlies currently support this event */
523  
-            if (document.addEventListener)
524  
-                /* Use the handy event callback */
525  
-                document.addEventListener("DOMContentLoaded", ready, false);
526  
-
527  
-            /*
528  
-                If IE is used and is not in a frame,
529  
-                continually check to see whether the document is ready.
530  
-            */
531  
-            if (environment.isIE && window == top) (function () {
532  
-                if (isDomReady) return;
533  
-                try {
534  
-                    /*
535  
-                        If IE is used, use the trick by Diego Perini
536  
-                        http://javascript.nwbox.com/IEContentLoaded/
537  
-                    */
538  
-                    document.documentElement.doScroll("left");
539  
-                } catch (error) {
540  
-                    /*
541  
-                        using setTimeout with a 0 milisecond dellay
542  
-                        is effectively the equivalent of a "yield"
543  
-                        in a cooperative multi-task language.
544  
-                        This permits the browser to breathe before
545  
-                        we check whether we're ready again.
546  
-                    */
547  
-                    window.setTimeout(arguments.callee, 0);
548  
-                    return;
549  
-                }
550  
-                ready();
551  
-            })();
552  
-
553  
-            if (environment.isSafari) {
554  
-                (function () {
555  
-                    if (isDomReady) return;
556  
-                    if (
557  
-                        document.readyState != "loaded" &&
558  
-                        document.readyState != "complete"
559  
-                    ) {
560  
-                        window.setTimeout(arguments.callee, 0);
561  
-                        return;
562  
-                    }
563  
-                    var numStyles = document.getElementsByTagName('style').length;
564  
-                    var links = document.getElementsByTagName('link');
565  
-                    for (var i = 0; i < links.length; i++) {
566  
-                        var link = links[i];
567  
-                        numStyles += (
568  
-                            link.hasAttribute('rel') &&
569  
-                            link.getAttribute('rel').toLowerCase() ==
570  
-                            'stylesheet'
571  
-                        );
572  
-                    }
573  
-                    if (document.styleSheets.length != numStyles) {
574  
-                        window.setTimeout(arguments.callee, 0);
575  
-                        return;
576  
-                    }
577  
-                    ready();
578  
-                })();
579  
-            }
580  
-
581  
-            /*
582  
-                for other browsers, give up on the time saving
583  
-                techniques and wait for all the images to load.
584  
-                also, do this in other browsers just in case they missed
585  
-                the boat.
586  
-            */
587  
-            if (window.onload) {
588  
-                /* if there's already an onload listener, call ready after it,
589  
-                preserving first-come-first-serve event observation */
590  
-                window.onload = (function (onload) {
591  
-                    return function () {
592  
-                        onload.call(this);
593  
-                        ready();
594  
-                    };
595  
-                })(window.onload);
596  
-            } else {
597  
-                window.onload = ready;
598  
-            }
599  
-
600  
-        };
601  
-
602  
-    };
603  
-
604  
-    factories.urls = function (require, exports, system) {
605  
-        
606  
-        /**** keys
607  
-            members of a parsed URI object.
608  
-        */
609  
-        exports.keys = [
610  
-            "url",
611  
-            "protocol",
612  
-            "authorityRoot",
613  
-            "authority",
614  
-                "userInfo",
615  
-                    "user",
616  
-                    "password",
617  
-                "domain",
618  
-                    "domains",
619  
-                "port",
620  
-            "path",
621  
-                "root",
622  
-                "directory",
623  
-                    "directories",
624  
-                "file",
625  
-            "query",
626  
-            "anchor"
627  
-        ];
628  
-
629  
-        /**** expressionKeys
630  
-            members of a parsed URI object that you get
631  
-            from evaluting the strict regular expression.
632  
-        */
633  
-        exports.expressionKeys = [
634  
-            "url",
635  
-            "protocol",
636  
-            "authorityRoot",
637  
-            "authority",
638  
-                "userInfo",
639  
-                    "user",
640  
-                    "password",
641  
-                "domain",
642  
-                "port",
643  
-            "path",
644  
-                "root",
645  
-                "directory",
646  
-                "file",
647  
-            "query",
648  
-            "anchor"
649  
-        ];
650  
-
651  
-        /**** strictExpression
652  
-        */
653  
-        exports.strictExpression = new RegExp( /* url */
654  
-            "^" +
655  
-            "(?:" +
656  
-                "([^:/?#]+):" + /* protocol */
657  
-            ")?" +
658  
-            "(?:" +
659  
-                "(//)" + /* authorityRoot */
660  
-                "(" + /* authority */
661  
-                    "(?:" +
662  
-                        "(" + /* userInfo */
663  
-                            "([^:@]*)" + /* user */
664  
-                            ":?" +
665  
-                            "([^:@]*)" + /* password */
666  
-                        ")?" +
667  
-                        "@" +
668  
-                    ")?" +
669  
-                    "([^:/?#]*)" + /* domain */
670  
-                    "(?::(\\d*))?" + /* port */
671  
-                ")" +
672  
-            ")?" +
673  
-            "(" + /* path */
674  
-                "(/?)" + /* root */
675  
-                "((?:[^?#/]*/)*)" +
676  
-                "([^?#]*)" + /* file */
677  
-            ")" +
678  
-            "(?:\\?([^#]*))?" + /* query */
679  
-            "(?:#(.*))?" /*anchor */
680  
-        );
681  
-
682  
-        /**** Parser
683  
-            returns a URI parser function given
684  
-            a regular expression that renders 
685  
-            `expressionKeys` and returns an `Object`
686  
-            mapping all `keys` to values.
687  
-        */
688  
-        exports.Parser = function (expression) {
689  
-            return function (url) {
690  
-                if (typeof url == "undefined")
691  
-                    throw new Error("HttpError: URL is undefined");
692  
-                if (typeof url != "string") return new Object(url);
693  
-
694  
-                var items = {};
695  
-                var parts = expression.exec(url);
696  
-
697  
-                for (var i = 0; i < parts.length; i++) {
698  
-                    items[exports.expressionKeys[i]] = parts[i] ? parts[i] : "";
699  
-                }
700  
-
701  
-                items.root = (items.root || items.authorityRoot) ? '/' : '';
702  
-
703  
-                items.directories = items.directory.split("/");
704  
-                if (items.directories[items.directories.length - 1] == "") {
705  
-                    items.directories.pop();
706  
-                }
707  
-
708  
-                /* normalize */
709  
-                var directories = [];
710  
-                for (var i = 0; i < items.directories.length; i++) {
711  
-                    var directory = items.directories[i];
712  
-                    if (directory == '.') {
713  
-                    } else if (directory == '..') {
714  
-                        if (directories.length && directories[directories.length - 1] != '..')
715  
-                            directories.pop();
716  
-                        else
717  
-                            directories.push('..');
718  
-                    } else {
719  
-                        directories.push(directory);
720  
-                    }
721  
-                }
722  
-                items.directories = directories;
723  
-
724  
-                items.domains = items.domain.split(".");
725  
-
726  
-                return items;
727  
-            };
728  
-        };
729  
-
730  
-        /**** parse
731  
-            a strict URI parser.
732  
-        */
733  
-        exports.parse = exports.Parser(exports.strictExpression);
734  
-
735  
-        /**** format
736  
-            accepts a parsed URI object and returns
737  
-            the corresponding string.
738  
-        */
739  
-        exports.format = function (object) {
740  
-            if (typeof(object) == 'undefined')
741  
-                throw new Error("UrlError: URL undefined for urls#format");
742  
-            if (object instanceof String || typeof(object) == 'string')
743  
-                return object;
744  
-            var domain =
745  
-                object.domains ?
746  
-                object.domains.join(".") :
747  
-                object.domain;
748  
-            var userInfo = (
749  
-                    object.user ||
750  
-                    object.password 
751  
-                ) ?
752  
-                (
753  
-                    (object.user || "") + 
754  
-                    (object.password ? ":" + object.password : "") 
755  
-                ) :
756  
-                object.userInfo;
757  
-            var authority = (
758  
-                    userInfo ||
759  
-                    domain ||
760  
-                    object.port
761  
-                ) ? (
762  
-                    (userInfo ? userInfo + "@" : "") +
763  
-                    (domain || "") + 
764  
-                    (object.port ? ":" + object.port : "")
765  
-                ) :
766  
-                object.authority;
767  
-            var directory =
768  
-                object.directories ?
769  
-                object.directories.join("/") :
770  
-                object.directory;
771  
-            var path =
772  
-                directory || object.file ?
773  
-                (
774  
-                    (directory ? directory + "/" : "") +
775  
-                    (object.file || "")
776  
-                ) :
777  
-                object.path;
778  
-            return (
779  
-                (object.protocol ? object.protocol + ":" : "") +
780  
-                (authority ? "//" + authority : "") +
781  
-                (object.root || (authority && path) ? "/" : "") +
782  
-                (path ? path : "") +
783  
-                (object.query ? "?" + object.query : "") +
784  
-                (object.anchor ? "#" + object.anchor : "")
785  
-            ) || object.url || "";
786  
-        };
787  
-
788  
-        /**** resolveObject
789  
-            returns an object representing a URL resolved from
790