Permalink
Browse files

fixing merge

  • Loading branch information...
Christoph Dorn
Christoph Dorn committed Sep 16, 2009
1 parent ea0f1d9 commit e3c8f204803f112fda21de5ce0cfb8d243ef6bed
Showing with 1,377 additions and 1,899 deletions.
  1. 0 README.md
  2. 0 bin/activate.bash
  3. +1 −0 bin/all-tests.cmd
  4. +1 −0 bin/cgi-test.sh
  5. +1 −1 bin/fcgi-test.sh
  6. +1 −1 bin/jackup
  7. +1 −0 bin/jackup.cmd
  8. 0 docs/.gitignore
  9. 0 docs/{browser-deployment.md → browser-api-plan.md}
  10. +153 −0 docs/browser-api.md
  11. 0 docs/engines.md
  12. 0 docs/lib/binary.wiki
  13. 0 docs/lib/file.wiki
  14. 0 docs/lib/os/popen.md
  15. 0 docs/modules.md
  16. 0 docs/narwhal.md
  17. 0 docs/packages.md
  18. 0 docs/posts/2009-07-29-hello-0.1.md
  19. 0 docs/sea.md
  20. +0 −60 engines/browser/inline.js
  21. 0 engines/browser/lib/binary.js
  22. +0 −1,450 engines/browser/lib/modules.js
  23. 0 engines/browser/lib/reactor.js
  24. 0 engines/browser/lib/system.js
  25. 0 engines/default/lib/array.js
  26. 0 engines/default/lib/binary-engine.js
  27. 0 engines/default/lib/date.js
  28. 0 engines/default/lib/file-engine.js
  29. 0 engines/default/lib/function.js
  30. 0 engines/default/lib/global.js
  31. 0 engines/default/lib/io-engine.js
  32. 0 engines/default/lib/json.js
  33. 0 engines/default/lib/os-engine.js
  34. 0 engines/default/lib/reactor.js
  35. 0 engines/default/lib/system.js
  36. +1 −1 engines/rhino/bin/narwhal-rhino
  37. +1 −1 engines/rhino/bin/narwhal-rhino.cmd
  38. BIN engines/rhino/jars/jline.jar
  39. BIN engines/rhino/jars/jna.jar
  40. BIN engines/rhino/jars/js.jar
  41. 0 engines/rhino/lib/http-engine.js
  42. +1 −2 engines/rhino/lib/io-engine.js
  43. 0 engines/rhino/lib/md5-engine.js
  44. +16 −0 engines/rhino/lib/os-engine.js
  45. 0 engines/rhino/lib/packages-engine.js
  46. 0 engines/rhino/lib/process.js
  47. 0 engines/rhino/lib/sandbox-engine.js
  48. 0 engines/rhino/lib/system.js
  49. +1 −10 engines/rhino/lib/zip.js
  50. 0 engines/rhino/package.json
  51. 0 engines/secure/lib/file.js
  52. 0 engines/secure/lib/system.js
  53. 0 engines/template/bootstrap.js
  54. 0 engines/template/lib/file-engine.js
  55. 0 engines/template/lib/system.js
  56. +35 −0 examples/browser-deployment-jackconfig.js
  57. 0 examples/not-quite-a-quine.js
  58. 0 lib/base16.js
  59. 0 lib/base64.js
  60. 0 lib/codec/base64.js
  61. +78 −16 lib/file.js
  62. 0 lib/hash.js
  63. 0 lib/hashp.js
  64. 0 lib/http.js
  65. 0 lib/io.js
  66. 0 lib/jsmin.js
  67. 0 lib/jsonpath.js
  68. 0 lib/md4.js
  69. 0 lib/md5.js
  70. 0 lib/mime.js
  71. 0 lib/narwhal.js
  72. +254 −0 lib/narwhal/client.js
  73. +104 −0 lib/narwhal/inline.js
  74. 0 lib/narwhal/json.md
  75. 0 lib/narwhal/repl.js
  76. +1 −0 lib/narwhal/server-test.js
  77. +202 −149 lib/narwhal/server.js
  78. +4 −10 lib/narwhal/tusk.js
  79. 0 lib/narwhal/tusk/bin.js
  80. 0 lib/narwhal/tusk/bundle.js
  81. 0 lib/narwhal/tusk/catalog.js
  82. 0 lib/narwhal/tusk/clone.js
  83. 0 lib/narwhal/tusk/consolidate.js
  84. 0 lib/narwhal/tusk/engine.js
  85. 0 lib/narwhal/tusk/freeze.js
  86. 0 lib/narwhal/tusk/init.js
  87. +31 −189 lib/narwhal/tusk/install.js
  88. 0 lib/narwhal/tusk/list.js
  89. 0 lib/narwhal/tusk/orphans.js
  90. 0 lib/narwhal/tusk/reheat.js
  91. 0 lib/narwhal/tusk/remove.js
  92. 0 lib/narwhal/tusk/search.js
  93. 0 lib/narwhal/tusk/update.js
  94. 0 lib/narwhal/tusk/upgrade.js
  95. +10 −8 lib/os.js
  96. +1 −1 lib/packages.js
  97. 0 lib/printf.js
  98. 0 lib/promise.js
  99. 0 lib/regexp.js
  100. 0 lib/sha.js
  101. 0 lib/struct.js
  102. +3 −0 lib/term.js
  103. 0 lib/test/assert.js
  104. 0 lib/test/equiv.js
  105. 0 lib/test/runner.js
  106. 0 lib/unload.js
  107. 0 lib/utf8.js
  108. 0 lib/xregexp.js
  109. 0 local.json.template
  110. 0 narwhal.conf.template
  111. 0 narwhal.gemspec
  112. 0 packages/.gitignore
  113. +215 −0 tests/args/domain.js
  114. +36 −0 tests/args/options.js
  115. +92 −0 tests/args/shifting.js
  116. +31 −0 tests/args/validation.js
  117. 0 tests/base64.js
  118. 0 tests/file/all-tests.js
  119. +102 −0 tests/file/match.js
  120. 0 tests/global.js
  121. 0 tests/global/array.js
  122. 0 tests/io/stringio.js
  123. 0 tests/iojs/absolute/b.js
  124. 0 tests/iojs/absolute/program.js
  125. 0 tests/iojs/absolute/submodule/a.js
  126. 0 tests/iojs/absolute/test.js
  127. 0 tests/iojs/config.js
  128. 0 tests/iojs/cyclic/a.js
  129. 0 tests/iojs/cyclic/b.js
  130. 0 tests/iojs/cyclic/program.js
  131. 0 tests/iojs/cyclic/test.js
  132. 0 tests/iojs/determinism/program.js
  133. 0 tests/iojs/determinism/submodule/a.js
  134. 0 tests/iojs/determinism/submodule/b.js
  135. 0 tests/iojs/determinism/test.js
  136. 0 tests/iojs/exactExports/a.js
  137. 0 tests/iojs/exactExports/program.js
  138. 0 tests/iojs/exactExports/test.js
  139. 0 tests/iojs/hasOwnProperty/hasOwnProperty.js
  140. 0 tests/iojs/hasOwnProperty/program.js
  141. 0 tests/iojs/hasOwnProperty/test.js
  142. 0 tests/iojs/hasOwnProperty/toString.js
  143. 0 tests/iojs/method/a.js
  144. 0 tests/iojs/method/program.js
  145. 0 tests/iojs/method/test.js
  146. 0 tests/iojs/missing/program.js
  147. 0 tests/iojs/missing/test.js
  148. 0 tests/iojs/monkeys/a.js
  149. 0 tests/iojs/monkeys/program.js
  150. 0 tests/iojs/monkeys/test.js
  151. 0 tests/iojs/nested/a/b/c/d.js
  152. 0 tests/iojs/nested/program.js
  153. 0 tests/iojs/nested/test.js
  154. 0 tests/iojs/relative/program.js
  155. 0 tests/iojs/relative/submodule/a.js
  156. 0 tests/iojs/relative/submodule/b.js
  157. 0 tests/iojs/relative/test.js
  158. 0 tests/iojs/transitive/a.js
  159. 0 tests/iojs/transitive/b.js
  160. 0 tests/iojs/transitive/c.js
  161. 0 tests/iojs/transitive/program.js
  162. 0 tests/iojs/transitive/test.js
  163. 0 tests/os/all-tests.js
  164. 0 tests/os/popen.js
  165. 0 tests/printf.js
  166. 0 tests/sandbox/byte-io.js
  167. 0 tests/sandbox/fileName.js
  168. 0 tests/sandbox/foo.js
  169. 0 tests/sandbox/reload.js
  170. 0 tests/serverjs/all-tests.js
  171. 0 tests/serverjs/bytearray-encodings-tests.js
  172. 0 tests/serverjs/bytestring-encodings-tests.js
  173. 0 tests/serverjs/bytestring-tests.js
  174. 0 tests/serverjs/file-tests.js
  175. 0 tests/serverjs/file/dirname.js
  176. 0 tests/serverjs/file/extension.js
  177. 0 tests/serverjs/file/is-absolute.js
  178. 0 tests/serverjs/file/iterator.js
  179. 0 tests/serverjs/file/normal.js
  180. 0 tests/serverjs/file/relative.js
  181. 0 tests/serverjs/file/resolve.js
  182. 0 tests/serverjs/module-tests.js
  183. 0 tests/util/array.js
  184. 0 tests/util/array/is-arguments.js
  185. 0 tests/util/array/is-array-like.js
  186. 0 tests/util/case.js
  187. 0 tests/util/eq.js
  188. 0 tests/util/object.js
  189. 0 tests/util/operator.js
  190. 0 tests/util/repr.js
  191. 0 tests/util/string.js
View
0 README.md 100644 → 100755
No changes.
View
0 bin/activate.bash 100644 → 100755
No changes.
View
View
View
View
View
View
0 docs/.gitignore 100644 → 100755
No changes.
File renamed without changes.
View
@@ -0,0 +1,153 @@
+
+Browser Deployment
+==================
+
+To use modules on the client side, one option is to use a
+JSGI application provided with Narwhal.
+
+ var SERVER = require("narwhal/server");
+ var app = ...
+ app = SERVER.App(app, options);
+ ...
+
+Options:
+
+ * `debug`: causes the loader to favor debug information over
+ performance. This disables bundling, minification,
+ and caching (maybe).
+ * `path`: overrides the path used for server-hosted modules.
+ For example, "javascript/" instead of the default, ".js/".
+ This is intended to avoid collisions with existing services
+ down the routing cascade.
+ * `proxy`: Alternate URL to search for scripts.
+
+This option has not been implemented yet:
+
+ * `catalog`: Alternate URLs for individual scripts or
+ script bundles.
+
+This introduces an API to the "env" for all subsequent
+poritions of the request route. The first form loads a module
+and its transitive dependencies:
+
+ env.script.require(id)
+
+The second form aynchronously loads the given modules and
+their transitive dependencies, but does not invoke any
+of them.
+
+ env.script.preload([id...])
+
+You can also embed a call to require a module and its transitive dependencies
+instead of loading them with asynchronous script injection.
+
+ env.script.embed("main")
+
+If you just need to install the loader and you intend to use the loader
+manually, you can inject it. The `script.loader` function will return a bit of
+JavaScript that will return an expression that evaluates to the `require`
+object in JavaScript. The first time it's called, this will be the full text
+of the loader, but thereafter it will simply be the global `require` variable.
+
+ env.script.loader()
+
+These functions return unescaped JavaScript text
+suitable for inserting in an HTML `<script>` tag. The intent
+is for you to use these functions through whatever template
+formatting system your site uses, as in this speculative
+example:
+
+ <script>{{env.script.require("main")|javascript}}</script>
+
+Or, with a higher level API that could be implemented to look like:
+
+ {% script.require "main" %}
+
+If you intend to use modules in inline scripts, you will need to wait for the
+desired modules to load before you execute your code. The `require.when`
+function executes a block of code when a module is *ready* to be required.
+
+ <script>
+ require.when("main", function () {
+ var MAIN = require("main");
+ ...
+ });
+ </script>
+
+You can also use promises directly with the `require.async` call, which
+performs an asynchronous require that fulfills the returned promise with the
+required module's exports.
+
+ <script>
+ (function () {
+ var Q = require("promise");
+ Q.when(require.async("main"), function (MAIN) {
+ ...
+ });
+ })();
+ </script>
+
+The synchronous `require` call may throw an error if you use it without
+ensuring that the module you want has been loaded.
+
+ {{env.script.preload(["foo"])|javascript}}
+ <script>
+ require("bar"); // throws up
+ </script>
+
+However, you can make asynchronous require calls without preloading the
+corresponding modules. Missing dependencies will be fetched on demand in a
+dynamic, albeit chatty fashion that may not take full advantage of the network
+capacity.
+
+ {{env.script.loader()|javascript}}
+ <script>
+ (function () {
+ var Q = require("promise");
+ Q.when(require.async("bar"), function (MAIN) {
+ ...
+ });
+ })();
+ </script>
+
+
+Fin
+===
+
+Features below this line have not been implemented.
+
+
+*****
+
+If you want to use modules but are not using a JSGI application
+to host them, you will need to use "tusk" to build a module
+root. You will need to do this every time any of your
+modules change.
+
+ tusk ...
+
+To load the modules in the browser, use the require script
+with the name of the desired root module as the anchor.
+
+ <script src="require.js#main"></script>
+
+Or
+
+ <script src="require.js"></script>
+ <script>
+ require.load("main");
+ require.ready(function () {
+ var MAIN = require("main");
+ });
+ </script>
+
+Or use tusk to generate a script that you can include in
+your static HTML.
+
+ tusk ...
+
+Or, if you can't tolerate a build step, and are willing to
+host your package tree from origin, you can use the XHR loader.
+
+ <script src="require-xhr.js#main"></script>
+
View
0 docs/engines.md 100644 → 100755
No changes.
View
0 docs/lib/binary.wiki 100644 → 100755
No changes.
View
0 docs/lib/file.wiki 100644 → 100755
No changes.
View
0 docs/lib/os/popen.md 100644 → 100755
No changes.
View
0 docs/modules.md 100644 → 100755
No changes.
View
0 docs/narwhal.md 100644 → 100755
No changes.
View
0 docs/packages.md 100644 → 100755
No changes.
View
No changes.
View
0 docs/sea.md 100644 → 100755
No changes.
View
@@ -1,60 +0,0 @@
-(function (ids, id, path) {
-
- var factories = {};
- var pending;
-
- var require = this.require = function (id, baseId) {
- // defer to require set later from the sandbox module
- require(id, baseId);
- };
-
- require.register = function (id, factory) {
- factories[id] = factory;
- if (!--pending)
- main();
- };
-
- var pending = ids.length;
- var head = document.getElementsByTagName('head')[0];
- for (var i = 0; i < pending; i++) {
- var script = document.createElement('script');
- script.src = path + ids[i] + '.js';
- head.appendChild(script);
- // TODO
- //document.documentElement.insertBefore(script, document.documentElement.firstChild);
- // prepend instead of append to avoid KB917927
- // - Kean Tan <http://www.karmagination.com/>
- };
-
- function main() {
-
- var system = {};
- system.print = function () {
- if (typeof console != "undefined") {
- console.log(Array.prototype.join.call(arguments, ' '));
- }
- };
-
- var loader = {};
- loader.reload = function (topId) {
- return factories[topId];
- };
- loader.load = function (topId) {
- return loader.reload(topId);
- };
-
- var sandbox = {};
- loader.load('sandbox')(
- null,
- sandbox,
- {},
- system,
- system.print
- );
- require = sandbox.Sandbox({loader: loader});
- loader.resolve = sandbox.resolve;
- require(id);
-
- }
-
-})
View
0 engines/browser/lib/binary.js 100644 → 100755
No changes.
Oops, something went wrong.

0 comments on commit e3c8f20

Please sign in to comment.