Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cujojs/curl
...
head fork: unscriptable/curl
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 154 files changed
  • 0 commit comments
  • 1 contributor
Showing with 3 additions and 36,409 deletions.
  1. 0  .gitmodules
  2. +0 −24 LICENSE.txt
  3. +3 −0  README
  4. +0 −755 README.md
  5. +0 −15 bin/compile.sh
  6. +0 −13 bin/make-all.sh
  7. +0 −36 bin/make.sh
  8. +0 −57 dist/README.md
  9. +0 −23 dist/curl-for-dojo1.6/curl.js
  10. +0 −26 dist/curl-for-jQuery/curl.js
  11. +0 −1,526 dist/curl-for-ssjs/curl.js
  12. +0 −41 dist/curl-kitchen-sink/curl.js
  13. +0 −25 dist/curl-with-js-and-domReady/curl.js
  14. +0 −20 dist/curl/curl.js
  15. +0 −120 docs/release-notes.md
  16. +0 −39 package.json
  17. +0 −1,266 src/curl.js
  18. +0 −82 src/curl/debug.js
  19. +0 −135 src/curl/domReady.js
  20. +0 −120 src/curl/loader/cjsm11.js
  21. +0 −22 src/curl/plugin/README.md
  22. +0 −82 src/curl/plugin/async.js
  23. +0 −178 src/curl/plugin/builder/css.js
  24. +0 −14 src/curl/plugin/builder/i18n.js
  25. +0 −56 src/curl/plugin/builder/text.js
  26. +0 −581 src/curl/plugin/css.js
  27. +0 −33 src/curl/plugin/domReady.js
  28. +0 −190 src/curl/plugin/i18n.js
  29. +0 −202 src/curl/plugin/js.js
  30. +0 −95 src/curl/plugin/link.js
  31. +0 −78 src/curl/plugin/text.js
  32. +0 −66 src/curl/shim/dojo16.js
  33. +0 −140 src/curl/shim/ssjs.js
  34. +0 −316 src/curl/tdd/runner.js
  35. +0 −56 src/curl/tdd/undefine.js
  36. +0 −43 test/apiAfter.html
  37. +0 −34 test/apiConflict.html
  38. +0 −33 test/apiConflict2.html
  39. +0 −49 test/apiName.html
  40. +0 −49 test/apiName2.html
  41. +0 −60 test/basic.html
  42. +0 −61 test/cjsModules1.1.html
  43. +0 −49 test/cjsm1.1-prewrapped.html
  44. +0 −101 test/config.html
  45. +0 −65 test/cycle-correction-hybrid.html
  46. +0 −61 test/debug.html
  47. +0 −45 test/defineAfter.html
  48. +0 −73 test/defineConflict.html
  49. +0 −28 test/defineConflict2.html
  50. +0 −50 test/defineContext.html
  51. +0 −47 test/defineContext2.html
  52. +0 −49 test/dist-kitchen-sink.html
  53. +0 −12,027 test/domReady.html
  54. +0 −95 test/dontAddFileExt.html
  55. +0 −66 test/i18n.html
  56. +0 −16 test/i18n/strings.js
  57. +0 −16 test/i18n/strings/en-gb.js
  58. +0 −57 test/issue20.html
  59. +0 −71 test/issue28.html
  60. +0 −45 test/issue34.html
  61. +0 −48 test/issue37.html
  62. +0 −48 test/issue53.html
  63. +0 −61 test/jquery-ready.html
  64. +0 −56 test/js-load-once-issue30.html
  65. +0 −48 test/js-test-option-failure.html
  66. +0 −49 test/js-test-option-success.html
  67. +0 −53 test/link-parent-path-issue108.html
  68. +0 −53 test/link.html
  69. +0 −79 test/local-require.html
  70. +0 −115 test/many-css-resources.html
  71. +0 −42 test/many-plugin-callbacks.html
  72. +0 −85 test/module-returns-undefined.html
  73. +0 −91 test/multiple_curl_calls.html
  74. +0 −82 test/next.html
  75. +0 −74 test/package-specific-config.html
  76. +0 −53 test/packages-as-object.html
  77. +0 −178 test/packages.html
  78. +0 −135 test/paths.html
  79. +0 −52 test/plainOldJs.html
  80. +0 −50 test/plugin-errback.html
  81. +0 −57 test/plugin-relative-ids.html
  82. +0 −63 test/plugin-specific-paths.html
  83. +0 −62 test/pluginConfig.html
  84. +0 −61 test/preload.html
  85. +0 −57 test/protocol-relative-urls.html
  86. +0 −51 test/relative-plugins.html
  87. +0 −46 test/simple-plugin.html
  88. +0 −17 test/stuff/aView/controller.js
  89. +0 −3  test/stuff/aView/css.css
  90. +0 −1  test/stuff/aView/template.html
  91. +0 −1  test/stuff/bad-import.css
  92. +0 −4 test/stuff/base.css
  93. 0  test/stuff/blank.css
  94. +0 −5 test/stuff/cascade-end.css
  95. +0 −6 test/stuff/cascade-middle.css
  96. +0 −12 test/stuff/cascade-start.css
  97. +0 −3  test/stuff/css-on-cdn.js
  98. +0 −1  test/stuff/foo.defineModule.js
  99. +0 −7 test/stuff/increments.js
  100. +0 −3  test/stuff/issue53.js
  101. +0 −1  test/stuff/module-without-ext
  102. +0 −5 test/stuff/nls/strings.js
  103. +0 −7 test/stuff/one.js
  104. +0 −11,978 test/stuff/plain_old.js
  105. +0 −2  test/stuff/plain_old_2.js
  106. +0 −1  test/stuff/random.js
  107. +0 −3  test/stuff/second.css
  108. +0 −1  test/stuff/template.html
  109. +0 −6 test/stuff/three.js
  110. +0 −6 test/stuff/two.js
  111. +0 −3  test/stuff/undefined-module.js
  112. +0 −3  test/stuff/wants-js-and-css.js
  113. +0 −1  test/stuff/xdtext.html
  114. +0 −1  test/stuff/zero.js
  115. +0 −3  test/support/commonjs/exports.js
  116. +0 −3  test/support/commonjs/folder/deep/returnMain.js
  117. +0 −3  test/support/commonjs/folder/non-cjs.js
  118. +0 −3  test/support/commonjs/folder/returnMain.js
  119. +0 −3  test/support/commonjs/foo.js
  120. +0 −6 test/support/commonjs/hybrid.js
  121. +0 −16 test/support/commonjs/loop/hybrid-loop1.js
  122. +0 −16 test/support/commonjs/loop/hybrid-loop2.js
  123. +0 −16 test/support/commonjs/loop/hybrid-loop3.js
  124. +0 −3  test/support/commonjs/main-with-relative-dep.js
  125. +0 −3  test/support/commonjs/main.js
  126. +0 −3  test/support/commonjs/main2.js
  127. +0 −3  test/support/commonjs/module.js
  128. +0 −4 test/support/commonjs/nakedDependentCjsm1.1.js
  129. +0 −4 test/support/commonjs/nakedSimpleCjsm1.1.js
  130. +0 −5 test/support/commonjs/named-main.js
  131. +0 −15 test/support/commonjs/package.json
  132. +0 −3  test/support/commonjs/relative-dep.js
  133. +0 −1  test/support/commonjs/return-config.js
  134. +0 −7 test/support/commonjs/this.js
  135. +0 −16 test/support/fake.js
  136. +0 −5 test/support/foo-bar-define/simple.js
  137. +0 −3  test/support/loop/loop-start.js
  138. +0 −3  test/support/loop/loop1.js
  139. +0 −3  test/support/loop/loop2.js
  140. +0 −3  test/support/loop/loop3.js
  141. +0 −8 test/support/main-plugin.js
  142. +0 −5 test/support/requires-fake.js
  143. +0 −8 test/support/simple-plugin.js
  144. +0 −31 test/support/underscore-amdjs-1.3.1/underscore-min.js
  145. +0 −1,005 test/support/underscore-amdjs-1.3.1/underscore-orig.js
  146. +0 −1,008 test/support/underscore-amdjs-1.3.1/underscore.js
  147. +0 −170 test/tdd-runner.html
  148. +0 −25 test/tdd/MethodSpy.js
  149. +0 −20 test/tdd/Spy.js
  150. +0 −29 test/tdd/configureAsserts.js
  151. +0 −111 test/then.html
  152. +0 −64 test/top-level-plugin.html
  153. +0 −67 test/undefine.html
  154. +0 −53 test/underscore.html
View
0  .gitmodules
No changes.
View
24 LICENSE.txt
@@ -1,24 +0,0 @@
-Open Source Initiative OSI - The MIT License
-
-http://www.opensource.org/licenses/mit-license.php
-
-Copyright (c) 2012 Brian Cavalier and John Hann
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
3  README
@@ -0,0 +1,3 @@
+The Force has brought you here, I see. However, the answer to your quest can only be found at https://github.com/cujojs/curl
+
+(Luke, you must update the url in your .git/config!)
View
755 README.md
@@ -1,755 +0,0 @@
-curl (cujo resource loader)
-=====================
-
-Check out the newly updated [wiki](https://github.com/cujojs/curl/wiki)!
-
-See the [wiki](https://github.com/cujojs/curl/wiki) for information about using
-curl.js with jQuery, dojo, or underscore.
-
-Please Note: this project has moved from unscriptable/curl to cujojs/curl.
-Any existing forks have been automatically moved to cujojs/curl. However,
-you will need to update your clone and submodule remotes manually.
-
-Update the url in your .git/config, and also .gitmodules for submodules:
- git://github.com/cujojs/curl.git
- https://cujojs@github.com/cujojs/curl.git
-
-Helpful link for updating submodules:
-[Git Submodules: Adding, Using, Removing, Updating](http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/)
-
-What's New?
-=======
-
-IE10 compatibility: the following commits are compatible with IE10 (and Safari 6):
-
-* [anything 0.7.x or higher](https://github.com/cujojs/curl)
-* [0.6.8](https://github.com/cujojs/curl/tree/3568bea941a6a6068995bfbeb56fa72c65835056)
-* [0.6.2a](https://github.com/cujojs/curl/tree/2683057e4cdf45eec44dd69dfd814ece75b7ae70)
-
-* 0.7.3
- * css! plugin no longer fails when sniffing for Opera (Fixes #147)
- * new curl.config() API method
- * curl(config) and curl.config() can be called repeatedly (fixes #146)
- * new "main" {String|Array} config option to init loading of main modules
- for an application
- * new i18n plugin (fixes #26)
-* 0.7.2
- * css! plugin now works everywhere (closed an Opera-XDomain issue).
- * css! plugin now returns the stylesheet created (as it used to, but for
- all browsers).
- * curl() error handler is called even if no success handler is specified.
-* 0.7.1
- * fixed inability to load non-anonymous "main" modules (packages) (also #138)
- * restored ability to use urls in place of module ids as dependencies
- * fixed duplicate downloads/execution of modules if dev specified
- module in two different ways (e.g. as module and as url) (#137)
- * fixed early callback in IE under load (#136)
- * restored plugin-specific config and paths
-* 0.7.0
- * new module.config() method when using CommonJS-wrapped modules
- * dontAddFileExt config option (RegExp or string) decides whether or not
- to add a .js file extension to module urls.
- * Implement error callbacks in require() and plugin load() methods.
- * Improved css! plugin no longer fails on blank stylesheets and supports
- all features in all browsers (except for error callbacks in Opera, IE6,
- Safari 5 (and below) and Firefox 8 (and below)).
- * shell scripts now work in more environments
- * many other fixes
-
-TODO:
-
-* document plugin configuration options and how to use each plugin
-* notes about using JSONP (it works for objects, arrays, functions, numbers
- and strings! use ?callback=define)
-
-----------------------------------------
-
-What is curl.js?
-================
-
-curl.js is a small and very fast AMD-compliant asynchronous loader.
-Size: 5KB (2.5KB gzipped) using Google's Closure Compiler.
-
-If you'd like to use curl.js for non-AMD modules (ordinary javascript files),
-you'll want to use a version with the js! plugin built in. You may also
-want to build-in the domReady module. The combined curl+js+domReady loader
-is still only 6.5KB (3KB gzipped).
-
-What the heck is "cujo"? cujo.js is a web app development platform.
-See the bottom of this file for more info.
-
-What is "cram"? cram (cujo resource assembler) is the build tool companion to
-curl.js. You use cram to compile all of your modules into a small number of
-javascript files which are loaded much faster into the browsers.
-
-----------------------------------------
-
-Features at a glance:
-=====================
-
-* Loads CommonJS AMD-formatted javascript modules in parallel (fast!)
-* Loads CommonJS Modules (v1.1 when wrapped in a `define()`) (fast!)
-* Loads CommonJS Packages (v1.1 modules wrapped in a `define()`) (fast!)
-* Loads non-AMD javascript files in parallel, too (fast! via js! plugin)
-* Loads CSS files and text files in parallel (fast! via plugins)
-* Waits for dependencies (js, css, text, etc) before executing javascript
-* Waits for domReady, if/when desired
-* Allows for virtually limitless combinations of files and dependencies
-* Tested with Chrome, FF3+, Safari 3.2+, IE6-8, Opera 9.5+
-
-Oh, did we mention? It's fast! It's even faster than the leading non-AMD
-script loaders.
-
-----------------------------------------
-
-How to get support
-===============
-
-1. Go to the issues section of the curl repo (https://github.com/cujojs/curl/issues)
- and search for an answer to your question or problem.
-2. If no answer exists, file a new ticket! Somebody will typically respond within a
- few hours.
-
-It's that easy.
-
-Got more in-depth questions? Browse the [cujojs discussion group](https://groups.google.com/d/forum/cujojs).
-
-----------------------------------------
-
-API at a glance
-===============
-
-For a complete description, check out the [wiki](https://github.com/cujojs/curl/wiki).
-
-```javascript
-curl(['dep1', 'dep2', 'dep3' /* etc */], callback);
-```
-
-Loads dependencies and the executes callback.
-
-* ['dep1', 'dep2', 'dep3']: Module names or plugin-prefixed resource files
-* callback: Function to receive modules or resources. This is where you'd
- typically start up your app.
-
----------
-
-```javascript
-curl(['dep1', 'dep2', 'dep3' /* etc */])
- .then(callback, errorback);
-```
-
-Promises-based API for executing callbacks.
-
-* ['dep1', 'dep2', 'dep3']: Module names or plugin-prefixed resource files
-* callback: Function to receive modules or resources
-* errorback: Function to call if an exception occurred while loading
-* For full CommonJS Promises/A compliance, use [when.js](https://github.com/cujojs/when)
- * `when(curl(['dep1'])).then(callback);`
-
----------
-
-```javascript
-curl(config, ['dep1', 'dep2', 'dep3' /* etc */], callback);
-```
-Specify configuration options, load dependencies, and execute callback.
-
-* config: Object containing curl configuration options (paths, etc.)
-* ['dep1', 'dep2', 'dep3']: Module names or plugin-prefixed resource files
-* callback: Function to receive modules or resources
-
----------
-
-```javascript
-curl(['domReady!', 'dep2', 'dep3' /* etc */])
- .then(
- callback,
- errorback
- );
-curl(['dep1', 'dep2', 'domReady!' /* etc */], function (dep1, dep2) {
- // do something here
-});
-```
-
-Executes the callback when the dom is ready for manipulation AND
-all dependencies have loaded.
-
-* callback: No parameters except the domReady object
-* errorback: Function to call if an exception occurred while loading
-
----------
-
-```javascript
-curl(['domReady!', 'js!nonAMD.js!order', 'js!another.js!order']), function () {
- /* do something cool here */
-});
-```
-
-Executes the function when the non-AMD javascript files are loaded and
-the dom is ready. The another.js file will wait for the nonAMD.js file
-before executing.
-
----------
-
-```javascript
-curl(['js!nonAMD.js'])
- .next(['dep1', 'dep2', 'dep3'], function (dep1, dep2, dep3) {
- // do something before the dom is ready
- })
- .next(['domReady!'])
- .then(
- function () {
- // do something after the dom is ready
- },
- function (ex) {
- // show an error to the user
- }
- );
-```
-
-Executes callbacks in stages using `.next(deps, callback)`.
-
----------
-
-```javascript
-curl = {
- baseUrl: '/path/to/my/js',
- pluginPath: 'for/some/reason/plugins/r/here',
- paths: {
- curl: 'curl/src/curl',
- cssx: 'cssx/src/cssx',
- my: '../../my-lib/'
- },
- apiName: 'someOtherName'
-};
-```
-
-If called before the `<script>` that loads curl.js, configures curl.js. All of
-the configuration parameters are optional. curl.js tries to do something sensible
-in their absence. :)
-
-* baseUrl: the root folder to find all modules, default is the document's folder
-* paths: a mapping of module paths to relative paths (from baseUrl)
-* pluginPath: the place to find plugins when they are specified without a path
-(e.g. "css!myCssFile" vs. "cssx/css!myCssFile") and there is no paths
-mapping that applies.
-* apiName: an alternate name to `curl` and `require` for curl.js's global
- variable
-* apiContext: an object, rather than `window`, to place curl on when using
- `apiName`
-
----------
-
-```javascript
-define(['dep1', 'dep2', 'dep3' /* etc */], definition);
-define(['dep1', 'dep2', 'dep3' /* etc */], module);
-define(['dep1', 'dep2', 'dep3' /* etc */], promise);
-define(module);
-define(name, ['dep1', 'dep2', 'dep3' /* etc */], definition);
-define(name, ['dep1', 'dep2', 'dep3' /* etc */], module);
-define(name, ['dep1', 'dep2', 'dep3' /* etc */], promise);
-define(name, module);
-```
-
-Defines a module per the CommonJS AMD proposed specification.
-
-* ['dep1', 'dep2', 'dep3']: Module names or plugin-prefixed resource files.
-Dependencies may be named 'require', 'exports', or 'module' and will behave
-as defined in the CommonJS Modules 1.1 proposal.
-* definition: Function called to define the module
-* module: Any javascript object, function, constructor, or primitive
-* name: String used to name a module (not necessary nor recommended)
-
-----------------------------------------
-
-Very Simple Example
-===================
-
-```html
-<script>
-
- // configure curl
- curl = {
- paths: {
- cssx: 'cssx/src/cssx/',
- stuff: 'my/stuff/'
- }
- };
-
-</script>
-<script src="../js/curl.js" type="text/javascript"></script>
-<script type="text/javascript">
-
- curl(
- // fetch all of these resources ("dependencies")
- [
- 'stuff/three', // an AMD module
- 'cssx/css!stuff/base', // a css file
- 'i18n!stuff/nls/strings', // a translation file
- 'text!stuff/template.html', // an html template
- 'domReady!'
- ]
- )
- // when they are loaded
- .then(
- // execute this callback, passing all dependencies as params
- function (three, link, strings, template) {
- var body = document.body;
- if (body) {
- body.appendChild(document.createTextNode('three == ' + three.toString() + ' '));
- body.appendChild(document.createElement('br'));
- body.appendChild(document.createTextNode(strings.hello));
- body.appendChild(document.createElement('div')).innerHTML = template;
- }
- },
- // execute this callback if there was a problem
- function (ex) {
- var msg = 'OH SNAP: ' + ex.message;
- alert(msg);
- }
- );
-
-</script>
-```
-
-The file structure for this example would look as follows:
-
- js/
- curl/
- plugin/
- i18n.js
- text.js
- domReady.js
- cssx/
- src/
- cssx/
- css.js
- my/
- stuff/
- nls/
- strings.js
- base.css
- template.html
- three.js
- curl.js
-
-----------------------------------------
-
-What is an asynchronous loader?
-===============================
-
-Web apps, especially large ones, require many modules and resources. Most of
-these modules and resources need to be loaded at page load, but some may be
-loaded later, either in the background or "just in time". They also need to be
-loaded as quickly as possible.
-
-The traditional way to load javascript modules is via a `<SCRIPT>` element in
-an HTML page. Similarly, CSS files are loaded via a `<LINK>` element, and
-text resources are either loaded in the page or via XHR calls.
-
-The problem with `<SCRIPT>` and `<LINK>` elements is that a browser must execute
-them sequentially since it has no idea if one may depend on another. It just
-assumes the developer has placed them in the correct order and that there are
-dependencies. (The term "synchronous loading" is used to describe this process
-since the elements are executed in a single timeline.)
-
-If there are no dependencies between two files, loading them sequentially is
-a waste of time. These files could be loaded and executed in parallel (i.e
-at the same time).
-
-An asynchronous loader does just that: it loads javascript files (and
-other types of files) in parallel whenever possible.
-
-curl.js has lots of company. Other async loaders include LABjs, Steal.js,
-yepnope.js, $script.js, the Backdraft loader (bdLoad), and RequireJS.
-
-[(a more complete list)](https://spreadsheets.google.com/ccc?key=0Aqln2akPWiMIdERkY3J2OXdOUVJDTkNSQ2ZsV3hoWVE&hl=en#gid=2)
-
-----------------------------------------
-
-What is AMD?
-============
-
-Asynchronous Module Definition is the CommonJS proposed standard for
-javascript modules that can be loaded by asynchronous loaders. It defines
-a simple API that developers can use to write their javascript modules so
-that they may be loaded by any AMD-compliant loader.
-
-[CommonJS AMD Proposal](http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition)
-
-The AMD proposal follows the [CommonJS Modules](http://wiki.commonjs.org/wiki/Modules/1.1)
-proposal as much as possible. Because of the way browsers load and
-evaluate scripts, AMD can't follow it completely without causing significant
-processing overhead. Instead, AMD allows us to place a lightweight wrapper
-around javascript modules to help work around the shortcomings.
-
-Ultimately, both proposals (AMD and Modules 1.1) are in preparation for an
-official [javascript modules](http://wiki.ecmascript.org/doku.php?id=harmony:modules)
-specification and eventual implementation in browsers.
-
-If you don't want to wait for official javascript modules, then don't. The future
-is now. AMD works now -- and it's awesome.
-
-AMD's API focuses on one globally-available function: `define()` and some
-CommonJS-inspired variables, `require()`, `exports`, and `module`.
-`require()` specifies a list of dependent modules or resources that must be
-loaded before running a set of code. This code resides in a callback function
-that is executed asynchronously, i.e. it runs later, not in the current
-"thread". Specifically, it executes when all of the dependencies are loaded
-and ready.
-
-The proposal does not mandate that `require()` be specified globally. In fact,
-at a global level, the concerns of a loader are about application bootstrapping
-and not about finding dependencies. To keep the confusion about these two
-concepts to a minimum, curl.js uses `curl()` for the public API. You may rename
-this API back to `require()` by supplying the `apiName` config param
-(`apiName: "require"`), but this is not receommended.
-
-It's more important that the `define()` method be consistent. This is the
-method that tells the loader what modules have been loaded by a script.
-`define()` also specifies a list of dependencies and a callback function that
-defines and/or creates the resource when the dependencies are ready.
-Optionally, `define()` also takes a name parameter, but this is mainly for build
-tools and optimizers.
-
-Inside the `define()`, the `require()` method acts like other AMD loaders.
-
-AMD's API also helps code reuse by providing compatibility with CommonJS
-(server) modules. AMD-compliant loaders support the same `require()` syntax and
-argument signatures as server-side javascript (ssjs) modules.
-
-Not all async loaders are AMD-compliant. Of the list above, only the following
-are AMD-compliant:
-
-curl.js <http://github.com/cujojs/curl>
-
-RequireJS <http://requirejs.org/>
-
-backdraft loader <http://bdframework.org/bdLoad>
-
-The beauty of AMD loaders is their ability to remove the drudgery of manually
-managing dependencies. Since all dependencies are listed within the
-modules, the loader will ensure that everything is loaded into the browser --
-and in the right order.
-
-----------------------------------------
-
-What makes curl different from other AMD loaders?
-=================================================
-
-curl.js is much smaller than other AMD loaders. Less than 1/2 the size of the
-others in the list above. It's able to achieve this via a Promises-based
-design. (Promises are another [CommonJS proposed standard](http://wiki.commonjs.org/wiki/Promises).)
-
-curl.js communicates with it's plugins via Promises, rather than a simple
-callback function. This allows proactive error handling, rather than detecting
-problems via a timeout, which can be tricky to set correctly. curl does this in
-a backwards-compatible way so AMD-compliant plugins will still work in curl.
-
-curl.js will also return a promise from `curl()` calls. This allows you to
-write code like this:
-
-```javascript
-curl(
- [
- 'myApp/moduleA',
- 'myApp/moduleB'
- ],
-).then(
- function success (A, B) {
- // load myApp here!
- },
- function failure (ex) {
- alert('myApp didn't load. reason: ' + ex.message);
- }
-);
-```
-
-(When using `require` as a dependency, it does not return a promise.
-This is so that 100% CommonJS compliance is assured inside modules.)
-
-----------------------------------------
-
-Can curl.js work with non-AMD javascript files?
-===============================================
-
-Yes, but why would you? Once you start using AMD, you'll never go back! :)
-
-You may use non-AMD javascript files by specifying the js! plugin prefix
-like this:
-
-```javascript
-curl(
- [
- 'js!plainOldJsFile1.js!order',
- 'js!anotherPlainOldJsFile.js!order'
- ]
-).then(
- function () {
- /* do something with your plain, boring javascript files */
- },
- function () {
- /* do something if any fail to load */
- }
-);
-```
-
-The !order suffix instructs curl.js to wait for previous scripts to execute
-before executing the current script. All scripts download in parallel, though,
-unless you specify `prefetch: false` in the config. Be sure to have proper
-cache headers set if you plan to use `prefetch: true` or scripts will get
-downloaded twice in browsers that don't support `async="false"`.
-
-----------------------------------------
-
-Can curl.js load non-javascript files?
-=======================
-
-Yes, curl.js follows the CommonJS Loader Plugin specification, so you can use
-any compatible plugin. The following plugins are included:
-
-js! -- loads non-AMD javascript files. more info on the [wiki](https://github.com/cujojs/curl/wiki/js)
-
-text! -- loads text files
-
-link! -- loads css files via a link element (simple, fast)
-
-css! -- loads css files (lots of options)
-
-domReady! -- resolves when the dom is ready for manipulation
-
-async! -- resolves when a module signals it's ready
-
-The following plugins are in progress:
-
-i18n! -- loads text strings and other locale-specific constants
-
-Complete plugin docs are on the [wiki](https://github.com/cujojs/curl/wiki/Plugins).
-
-----------------------------------------
-
-How are modules loaded?
-=======================
-
-curl.js uses `<script>` element injection rather than XHR/eval. This allows
-curl.js to load cross-domain scripts as well as local scripts.
-
-To find scripts and other resources, curl.js uses module names. A module name
-looks just like a file path, but typically without the file extension. If a
-module requires a plugin in order to load correctly, it will have a prefix
-delimited by a "!" and will also often have a file extension when a plugin
-may load different types of files.
-
-Some examples of module names:
-
-* dojo/store/JsonRest
-* my/lib/string/format
-* js!my/lib/js/plain-old-js.js
-* css!my/styles/reset.css
-* http://some-cdn/uber/module
-
-By default, curl.js will look in the same folder as the current document's location.
-For instance, if your web page is located at `http://my-domain/apps/myApp.html`,
-curl.js will look for the JsonRest module at `http://my-domain/apps/dojo/store/JsonRest.js`.
-
-You can tell curl.js to find modules in other locations by specifying a baseUrl or
-individual paths for each of your libraries. For example, if you specify a baseUrl of
-`/resources/` and the following paths:
-
-```javascript
-paths: {
- dojo: "third-party/dojo",
- css: "third-party/cssmojo/css",
- my: "my-cool-app-v1.3",
- "my/lib/js": "old-js-libs"
-}
-```
-
-Then the modules listed above will be sought in the following locations:
-
-* /resources/third-party/dojo/store/JsonRest.js
-* /resources/my-cool-app-v1.3/lib/string/format.js
-* /resources/old-js-libs/plain-old-js.js
-* /resources/my-cool-app-v1.3/styles/reset.css
-* http://some-cdn/uber/module.js
-
-Note: you will need to create a path to curl.js's plugins and other modules if
-the curl folder isn't directly under the same folder as your web page. curl.js
-uses the same mechanism to find its own modules.
-
-----------------------------------------
-
-What are AMD plugins?
-=====================
-
-AMD supports the notion of plugins. Plugins are AMD modules that can be used to
-load javascript modules -- or other types of resources. curl comes with several
-plugins already, including a text plugin (for templates or other text
-resources), two different css plugins, a dojo 1.6 compatibility plugin,
-a dom-ready plugin and a debug plugin (for collecting and logging details of the
-inner workings of curl).
-
-Plugins are designated by a prefix on the name of the module or resource to be
-loaded. They are delineated by a ! symbol. The following example shows the use
-of some plugins:
-
-```javascript
-define(
- [
- 'text!myTemplate.html',
- 'css!myCssFile'
- ],
- function (templateString, cssLinkNode) {
- // do something with the template and css here
- }
-);
-```
-
-Since plugins are just AMD modules, they would typically be referenced using
-their fully-pathed names. curl provides a pluginPath configuration option that
-allows you to specify the folder where [most of] your plugins reside so you
-don't have to specify their full paths. This also helps with compatibility
-with other AMD loaders that assume that certain plugins are bundled and
-internally mapped.
-
-If one or more of your plugins does not reside in the folder specified by the
-pluginPath config option, you can use its full path or you can specify a path
-for it in curl's paths config object.
-
-```javascript
-// example of a fully-pathed plugin under the cssx folder
-define(['/css!myCssFile'], function (cssxDef) {
- // do some awesome css stuff here
-});
-```
-
-Plugins can also have configuration options. Global options can be specified
-on curl's configuration object. Options can also be supplied to plugins via
-suffixes. Suffixes are also delineated by the ! symbol. Here's an example of
-a plugin using options:
-
-```javascript
-// don't try to repair IE6-8 opacity issues in my css file
-define(['css!myCssFile!ignore:opacity'], function (cssxDef) {
- // do some awesome css stuff here
-});
-```
-
-----------------------------------------
-
-How do I use curl.js?
-=====================
-
-1. Learn about AMD-formatted javascript modules if you don't already know how.
-2. Clone or download curl to your local machine or server.
-3. Figure out the baseUrl and paths configuration that makes sense for your
- project.
-4. Check out the "API at a glance" section above to figure out which loading
- methodology you want to use.
-5. Study the "Very Simple Example" and some of the test files.
-6. Try it on your own files.
-
-----------------------------------------
-
-Too Many Modules!
-=================
-
-I have dozens (or hundreds) of modules. Even with parallel loading, the
-performance sucks! What can I do about that?
-
-True! No parallel loader can lessen the latency required to create an HTTP
-connection. If you have dozens or hundreds of files to download, it's going to
-take time to initiate each of the connections.
-
-However, there are tools to that are designed to fix this problem! There are
-builders and compilers. dojo users are probably already familiar with dojo's
-build tool and optimizer. RequireJS comes with a build tool and Google's
-Closure compiler.
-
-The build tool is used to concatenate several modules (and/or resources)
-into just a few files. It does this by following the dependency chain
-specified in the define() and require() calls. You can specify which top-level
-modules or resources are in each file and the build tool finds the rest.
-
-After the build tool creates the concatenated files, the files can be passed
-into a compiler (also called a shrinker or compressor).
-
-We're writing curl to be compatible with RequireJS's build tool, but there's
-also another cujo project in the pipeline: [cram](https://github.com/cujojs/cram).
-Cram is the Cujo Resource Assembler.
-
-----------------------------------------
-
-CommonJS Package Support
-========================
-
-cujo.js supports the CommonJS Packages 1.1 specification. Packages are
-defined in the packages configuration parameter:
-
-```javascript
-cujo = {
- baseUrl: 'path/to/js',
- packages: {
- 'my-package': {
- path: 'path/to/my-package',
- main: 'main/main-module-file',
- lib: 'location/of/other/modules'
- }
- }
-};
-```
-
-The path property describes where to find the package in relation to the
-baseUrl parameter. The main and lib properties describe where to find modules
-inside the package. The main property gives the relative path to the package's
-main module. The lib property reflects the path to all other modules in the
-package.
-
-In the example above, the main module of the package can be obtained as follows
-
-```javascript
-curl(['my-package'], callback);
-```
-
-and will be fetched from the following path:
-
- path/to/js/path/to/my-package/main/main-module-file.js
-
-Some other file in the package would be obtained as follows:
-
-```javascript
-curl(['my-package/other-module'], callback);
-```
-
-and will be fetched from the following path:
-
- path/to/js/path/to/my-package/location/of/other/modules/other-module.js
-
-----------------------------------------
-
-What is cujo?
-=====================
-
-cujo.js is a web app development platform. It employs MVC, IOC, AMD
-and lots of other TLAs. :) curl.js is one of the many micro-libs we're pulling
-out of cujo.js. Our goal is to make the advanced concepts in cujo.js more
-palatable by breaking them down into easier-to-grok chunks. Other cujo.js
-libs include:
-
-* [canhaz](https://github.com/cujojs/canhaz): a project and code bootstrapping tool that will save you tons of typing.
-* [wire](https://github.com/cujojs/wire): A light, fast, flexible Javascript IOC container
-* [when.js](https://github.com/cujojs/when): A small, fast Promises/A compliant promises implementation
-* [cram](https://github.com/cujojs/cram): a javascript compressor, concatenator, and optimizer meant to be used with curl.js
-
-Kudos
-=================
-
-Many thanks to Bryan Forbes ([@bryanforbes](http://www.twitter.com/bryanforbes)) for helping to clean up my code and
-for making cujo's domReady much more robust.
-More about Bryan: <http://www.reigndropsfall.net/>
-
-Kudos also to James Burke ([@jrburke](http://www.twitter.com/jrburke)) who instigated the CommonJS AMD proposal
-and paved the way to create AMD-style loaders.
-More about James: <http://tagneto.blogspot.com/>
-
-Shout out to Kris Zyp ([@kriszyp](http://www.twitter.com/kriszyp)) for excellent ideas and feedback and to Kyle
-Simpson ([@getify](http://www.twitter.com/getify)) who is inarguably the godfather of javascript loading.
View
15 bin/compile.sh
@@ -1,15 +0,0 @@
-#!/bin/sh
-# run a file through google closure compiler
-
-# TODO: start using a js_externs parameter:
-# paths and other config params
-# full promise api (for communicating with plugins)
-# -d js_externs=promise.then=function(cb,eb){};promise.resolve=function(val){};promise.reject=function(ex){};
-
-curl \
- --data-urlencode "js_code@$1" \
- -d compilation_level=$2 \
- -d output_info=compiled_code \
- -d output_format=text \
- -d 'output_wrapper=(function(){%25output%25}).call(this);' \
- http://closure-compiler.appspot.com/compile
View
13 bin/make-all.sh
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-# make simple, compiled curl.js
-./make.sh ../dist/curl/curl.js ../src/curl.js
-
-# make other versions of curl
-./make.sh ../dist/curl-with-js-and-domReady/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/plugin/js.js ../src/curl/plugin/domReady.js
-./make.sh ../dist/curl-for-dojo1.6/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/shim/dojo16.js ../src/curl/plugin/domReady.js
-./make.sh ../dist/curl-kitchen-sink/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/shim/dojo16.js ../src/curl/plugin/js.js ../src/curl/plugin/text.js ../src/curl/plugin/async.js ../src/curl/plugin/css.js ../src/curl/plugin/link.js ../src/curl/plugin/domReady.js ../src/curl/loader/cjsm11.js ../src/curl/shim/ssjs.js
-./make.sh ../dist/curl-for-jQuery/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/plugin/js.js ../src/curl/plugin/link.js ../src/curl/plugin/domReady.js
-
-#make minimally-compressed ssjs
-./make.sh --NONE ../dist/curl-for-ssjs/curl.js ../src/curl.js ../src/curl/loader/cjsm11.js ../src/curl/shim/ssjs.js
View
36 bin/make.sh
@@ -1,36 +0,0 @@
-#!/usr/bin/env bash
-
-# get optional optimization instruction
-opt=$1
-if [ "${opt:0:2}" = "--" ]; then
- opt=${opt:2}
- shift
-else
- opt=ADVANCED_OPTIMIZATIONS
-fi
-
-# grab the output file
-out=$1
-tmpfile=$(mktemp -t cram.XXXXXX)
-
-# use all of the remaining parameters as files to be concatenated
-shift
-
-echo "making $out"
-echo "optimization level is $opt"
-
-# concatenate all of the files to a temp file
-cat $@ | sed -e "s:\/\*==::g" -e "s:==\*\/::g" > "$tmpfile"
-
-if [ "$opt" = "NONE" ]; then
- # cat files to the output file
- cat "$tmpfile" > "$out"
-else
- # compile files to the output file
- ./compile.sh "$tmpfile" "$opt" > "$out"
-fi
-
-# remove the temporary concatenated file
-rm "$tmpfile"
-
-echo "created $out"
View
57 dist/README.md
@@ -1,57 +0,0 @@
-Distribution Files
-==================
-
-These are "compiled" versions of curl.js for your convenience.
-
-Please note: these versions have been processed with Google Closure Compiler
-in Advanced Mode. Advanced Mode obfuscates any identifiers that haven't
-been specifically declared as "exported".
-Therefore, any modules/files that aren't compiled at the same time
-may not work together after being compiled.
-
-curl.js only exports identifiers needed for AMD compatibility or needed
-to process configuration settings. What this means to you:
-
-If you plan to use any of curl's plugins or other auxiliary modules,
-you may have to compile them into curl.js (see below) -- or
-compile curl.js into your application's optimized files. If you see "method
-not defined" or similar errors within curl.js, this is likely the problem.
-
-Use curl/curl.js if you are only loading AMD-formatted javascript modules.
-
-Use curl-with-js-and-domReady/curl.js if you wish to use non-AMD javascript
-files and don't have an alternative domReady implementation handy.
-
-Use curl-for-jQuery for a version of curl that has instructions for
-jQuery 1.7 to register as an AMD module and has the js! and link! plugins
-built in. This is an adequate configuration for many simple jQuery projects
-(and some sophisticated ones, too).
-
-curl-for-dojo1.6 has the domReady! plugin built in as well as some
-compatibility shims for dojo 1.6 and dojo 1.7.
-
-You can build your own custom version of curl.js by using the `make.sh` script
-in the /bin/ folder. You must run it from the /bin/ folder. Syntax:
-
- ./make.sh destination/curl.js ../src/curl.js [files to concat into curl.js]
-
-The following files can be concatenated into curl.js using make.sh:
-
-* ../src/curl/plugin/js.js (the js! plugin)
-* ../src/curl/plugin/text.js (the text! plugin)
-* ../src/curl/plugin/i18n.js (the i18n! plugin)
-* ../src/curl/plugin/css.js (the css! plugin)
-* ../src/curl/plugin/link.js (the link! plugin)
-* ../src/curl/plugin/domReady.js (the domReady plugin)
-* ../src/curl/domReady.js (the domReady module)
-* ../src/curl/shim/dojo16.js (the dojo 1.6 compatibility shim / module)
-* ../src/curl/loader/cjsm11.js (the CommonJS Modules/1.1 compatibility shim / module)
-* Any named AMD module (does not support anonymous modules, yet!)
-* Any non-AMD javascript file
-
-For example, to make a version of curl with the js! and text! plugins built-in:
-
- ./make.sh destination/curl.js ../src/curl.js ../src/curl/plugin/js.js ../src/curl/plugin/text.js
-
-Note: you will need a fairly recent version of `curl` (the unix utility, not
-curl.js!) to run `make.sh`. Version 7.18 or later is fine.
View
23 dist/curl-for-dojo1.6/curl.js
@@ -1,23 +0,0 @@
-(function(){/*
- MIT License (c) copyright B Cavalier & J Hann */
-var h=!0,i=!1,k=this.window||"undefined"!=typeof global&&global||this;function n(){}function r(a,b){return 0==aa.call(a).indexOf("[object "+b)}function s(a){return a&&"/"==a.charAt(a.length-1)?a.substr(0,a.length-1):a}function t(a,b){var c,d,e,f;c=1;d=a;"."==d.charAt(0)&&(e=h,d=d.replace(ba,function(a,b,d,e){d&&c++;return e||""}));if(e){e=b.split("/");f=e.length-c;if(0>f)return a;e.splice(f,c);return e.concat(d||[]).join("/")}return d}
-function u(a){var b=a.indexOf("!");return{m:a.substr(b+1),j:0<=b&&a.substr(0,b)}}function v(){}function w(a,b){v.prototype=a||x;var c=new v;v.prototype=x;for(var d in b)c[d]=b[d];return c}
-function y(){function a(a,b,e){d.push([a,b,e])}function b(a,b){for(var e,c=0;e=d[c++];)(e=e[a])&&e(b)}var c,d,e;c=this;d=[];e=function(c,g){a=c?function(a){a&&a(g)}:function(a,b){b&&b(g)};e=n;b(c?0:1,g);b=n;d=z};this.Z=function(b,d,e){a(b,d,e)};this.h=function(a){c.ka=a;e(h,a)};this.f=function(a){c.ja=a;e(i,a)};this.u=function(a){b(2,a)}}function B(a,b,c,d){a instanceof y?a.Z(b,c,d):b(a)}function C(a,b,c){var d;return function(){0<=--a&&b&&(d=b.apply(z,arguments));0==a&&c&&c(d);return d}}
-function D(){var a=[].slice.call(arguments),b;r(a[0],"Object")&&(b=a.shift(),E(b));return new ca(a[0],a[1],a[2])}function E(a){a&&(F.L(a),G=F.a(a),F.N(a),"main"in a&&setTimeout(function(){var b;b=F.d(G,z,[].concat(a.main));F.g(b)},0))}function ca(a,b,c,d){var e;e=F.d(G,z,[].concat(a));this.then=a=function(a,b){B(e,function(b){a&&a.apply(z,b)},function(a){if(b)b(a);else throw a;});return this};this.next=function(a,b,d){return new ca(a,b,d,e)};this.config=E;(b||c)&&a(b,c);B(d,function(){F.g(e)})}
-function da(a){var b,c;b=a.id;if(b==z)if(J!==z)J={C:"Multiple anonymous defines in url"};else if(!(b=F.W()))J=a;if(b!=z){c=K[b];b in K||(c=F.l(b,G),c=F.z(c.a,b),K[b]=c);if(!(c instanceof y))throw Error("duplicate define: "+b);c.$=i;F.A(c,a)}}function L(){var a=F.T(arguments);da(a)}
-var G,M,N,O=k.document,P=O&&(O.head||O.getElementsByTagName("head")[0]),ea=P&&P.getElementsByTagName("base")[0]||null,fa={},ga={},Q={},ha="addEventListener"in k?{}:{loaded:1,complete:1},x={},aa=x.toString,z,K={},R={},S=i,J,ia=/^\/|^[^:]+:\/\//,ba=/(\.)(\.?)(?:$|\/([^\.\/]+.*)?)/g,ja=/\/\*[\s\S]*?\*\/|(?:[^\\])\/\/.*?[\n\r]/g,ka=/require\s*\(\s*["']([^"']+)["']\s*\)|(?:[^\\]?)(["'])/g,T,F;
-F={n:function(a,b,c){var d,a=t(a,b);if("."==a.charAt(0))return a;d=u(a);a=(b=d.j)||d.m;a in c.c&&(a=c.c[a].H||a);b&&(0>b.indexOf("/")&&!(b in c.c)&&(a=s(c.J)+"/"+b),a=a+"!"+d.m);return a},d:function(a,b,c,d){function e(b){return F.n(b,g.id,a)}function f(b,c,f){var j;j=c&&function(a){c.apply(z,a)};if(r(b,"String")){if(j)throw Error("require(id, callback) not allowed");f=e(b);b=K[f];if(!(f in K))throw Error("Module not resolved: "+f);return(f=b instanceof y&&b.b)||b}B(F.g(F.d(a,g.id,b,d)),j,f)}var g;
-g=new y;g.id=b||"";g.X=d;g.B=c;g.a=a;g.k=f;f.toUrl=function(b){return F.l(e(b),a).url};g.n=e;return g},z:function(a,b,c){var d,e,f;d=F.d(a,b,z,c);e=d.h;f=C(1,function(a){d.q=a;try{return F.P(d)}catch(b){d.f(b)}});d.h=function(a){B(c||S,function(){e(K[d.id]=R[d.url]=f(a))})};d.D=function(a){B(c||S,function(){d.b&&(f(a),d.u(ga))})};return d},O:function(a,b,c,d){return F.d(a,c,z,d)},V:function(a){return a.k},F:function(a){return a.b||(a.b={})},U:function(a){var b=a.r;b||(b=a.r={id:a.id,uri:F.G(a),exports:F.F(a),
-config:function(){return a.a}},b.b=b.exports);return b},G:function(a){return a.url||(a.url=F.w(a.k.toUrl(a.id),a.a))},L:function(a){var b,c,d,e,f;b="curl";c="define";d=e=k;if(a&&(f=a.overwriteApi||a.ha,b=a.apiName||a.ba||b,d=a.apiContext||a.aa||d,c=a.defineName||a.da||c,e=a.defineContext||a.ca||e,M&&r(M,"Function")&&(k.curl=M),M=null,N&&r(N,"Function")&&(k.define=N),N=null,!f)){if(d[b]&&d[b]!=D)throw Error(b+" already exists");if(e[c]&&e[c]!=L)throw Error(c+" already exists");}d[b]=D;e[c]=L},a:function(a){function b(a,
-b){var d,c,g,p,H;for(H in a){g=a[H];r(g,"String")&&(g={path:a[H]});g.name=g.name||H;p=e;c=u(s(g.name));d=c.m;if(c=c.j)p=f[c],p||(p=f[c]=w(e),p.c=w(e.c),p.e=[]),delete a[H];if(b){c=g;var I=void 0;c.path=s(c.path||c.location||"");I=c.main||"./main";"."==I.charAt(0)||(I="./"+I);c.H=t(I,c.name+"/");c.a=c.config;c.a&&(c.a=w(e,c.a))}else c={path:s(g.path)};c.M=d.split("/").length;d?(p.c[d]=c,p.e.push(d)):p.o=F.K(g.path,e)}}function c(a){var b=a.c;a.I=RegExp("^("+a.e.sort(function(a,c){return b[c].M-b[a].M}).join("|").replace(/\/|\./g,
-"\\$&")+")(?=\\/|$)");delete a.e}var d,e,f,g;"baseUrl"in a&&(a.o=a.baseUrl);"main"in a&&(a.H=a.main);"preloads"in a&&(a.ia=a.preloads);"pluginPath"in a&&(a.J=a.pluginPath);if("dontAddFileExt"in a||a.i)a.i=RegExp(a.dontAddFileExt||a.i);d=G;e=w(d,a);e.c=w(d.c);f=a.plugins||{};e.plugins=w(d.plugins);e.t=w(d.t,a.t);e.s=w(d.s,a.s);e.e=[];b(a.packages,h);b(a.paths,i);for(g in f)a=F.n(g+"!","",e),e.plugins[a.substr(0,a.length-1)]=f[g];f=e.plugins;for(g in f)if(f[g]=w(e,f[g]),a=f[g].e)f[g].e=a.concat(e.e),
-c(f[g]);for(g in d.c)e.c.hasOwnProperty(g)||e.e.push(g);c(e);return e},N:function(a){var b;(b=a&&a.preloads)&&0<b.length&&B(S,function(){S=F.g(F.d(G,z,b,h))})},l:function(a,b){var c,d,e,f;c=b.c;e=ia.test(a)?a:a.replace(b.I,function(a){d=c[a]||{};f=d.a;return d.path||""});return{a:f||G,url:F.K(e,b)}},K:function(a,b){var c=b.o;return c&&!ia.test(a)?s(c)+"/"+a:a},w:function(a,b){return a+((b||G).i.test(a)?"":".js")},Y:function(a,b,c){var d=O.createElement("script");d.onload=d.onreadystatechange=function(c){c=
-c||k.event;if("load"==c.type||ha[d.readyState])delete Q[a.id],d.onload=d.onreadystatechange=d.onerror="",b()};d.onerror=function(){c(Error("Syntax or http error: "+a.url))};d.type=a.ea||"text/javascript";d.charset="utf-8";d.async=!a.ga;d.src=a.url;Q[a.id]=d;P.insertBefore(d,ea);return d},Q:function(a){var b=[],c;("string"==typeof a?a:a.toSource?a.toSource():a.toString()).replace(ja,"").replace(ka,function(a,e,f){f?c=c==f?z:c:c||b.push(e);return""});return b},T:function(a){var b,c,d,e,f,g;f=a.length;
-d=a[f-1];e=r(d,"Function")?d.length:-1;2==f?r(a[0],"Array")?c=a[0]:b=a[0]:3==f&&(b=a[0],c=a[1]);!c&&0<e&&(g=h,c=["require","exports","module"].slice(0,e).concat(F.Q(d)));return{id:b,q:c||[],v:0<=e?d:function(){return d},p:g}},P:function(a){var b;b=a.v.apply(a.p?a.b:z,a.q);b===z&&a.b&&(b=a.r?a.b=a.r.b:a.b);return b},A:function(a,b){a.v=b.v;a.p=b.p;a.B=b.q;F.g(a)},g:function(a){function b(a,b,c){g[b]=a;c&&m(a,b)}function c(b,c){var d,e,f,g;d=C(1,function(a){e(a);j(a,c)});e=C(1,function(a){m(a,c)});
-f=F.R(b,a);(g=f instanceof y&&f.b)&&e(g);B(f,d,a.f,a.b&&function(a){f.b&&(a==fa?e(f.b):a==ga&&d(f.b))})}function d(){a.h(g)}var e,f,g,q,l,m,j;g=[];f=a.B;q=f.length;0==f.length&&d();m=C(q,b,function(){a.D&&a.D(g)});j=C(q,b,d);for(e=0;e<q;e++)l=f[e],l in T?(j(T[l](a),e,h),a.b&&a.u(fa)):l?c(l,e):j(z,e,h);return a},S:function(a){F.G(a);F.Y(a,function(){var b=J;J=z;a.$!==i&&(!b||b.C?a.f(Error(b&&b.C||"define() missing or duplicated: "+a.url)):F.A(a,b))},a.f);return a},R:function(a,b){var c,d,e,f,g,q,l,
-m,j,A,p;c=b.n;d=b.X;e=b.a||G;f=u(c(a));l=f.m;g=f.j||l;m=F.l(g,e);if(f.j)q=g;else if(q=m.a.moduleLoader||m.a.fa)l=g,g=q,m=F.l(q,e);g in K?j=K[g]:m.url in R?j=K[g]=R[m.url]:(j=F.z(m.a,g,d),j.url=F.w(m.url,m.a),K[g]=R[m.url]=j,F.S(j));g==q&&(A=new y,p=e.plugins[q]||e,B(j,function(a){var b,e,f;f=a.dynamic;l="normalize"in a?a.normalize(l,c,j.a)||"":c(l);e=q+"!"+l;b=K[e];if(!(e in K)){b=F.O(p,e,l,d);f||(K[e]=b);var g=function(a){b.h(a);f||(K[e]=a)};g.resolve=g;g.reject=g.error=b.f;a.load(l,b.k,g,p)}A!=
-b&&B(b,A.h,A.f,A.u)},A.f));return A||j},W:function(){var a;if(!r(k.opera,"Opera"))for(var b in Q)if("interactive"==Q[b].readyState){a=b;break}return a}};T={require:F.V,exports:F.F,module:F.U};D.version="0.7.3";D.config=E;L.amd={plugins:h,jQuery:h,curl:"0.7.3"};G={o:"",J:"curl/plugin",i:/\?|\.js\b/,t:{},s:{},plugins:{},c:{},I:/$^/};M=k.curl;N=k.define;!M||r(M,"Function")?F.L():(k.curl=z,E(M));K.curl=D;K["curl/_privileged"]={core:F,cache:K,config:function(){return G},_define:da,_curl:D,Promise:y};
-var U=this.document;function la(){if(!U.body)return i;V||(V=U.createTextNode(""));try{return U.body.removeChild(U.body.appendChild(V)),V=ma,h}catch(a){return i}}function W(){var a;a=na[U[X]]&&la();if(!Y&&a){Y=h;for(clearTimeout(Z);oa=pa.pop();)oa();qa&&(U[X]="complete");for(var b;b=ra.shift();)b()}return a}function sa(){W();Y||(Z=setTimeout(sa,ta))}var X="readyState",na={loaded:1,interactive:1,complete:1},ra=[],qa=U&&"string"!=typeof U[X],Y=i,ta=10,$,oa,pa=[],Z,ma,V;
-$="addEventListener"in this?function(a,b){a.addEventListener(b,W,i);return function(){a.removeEventListener(b,W,i)}}:function(a,b){a.attachEvent("on"+b,W);return function(){a.detachEvent(b,W)}};U&&!W()&&(pa=[$(this,"load"),$(U,"readystatechange"),$(this,"DOMContentLoaded")],Z=setTimeout(sa,ta));define("curl/domReady",function(){function a(a){Y?a():ra.push(a)}a.then=a;a.amd=h;return a});var ua;
-define("curl/shim/dojo16",["curl/_privileged","curl/domReady"],function(a,b){function c(a){a.ready||(a.ready=function(a){b(a)});a.nameToUrl||(a.nameToUrl=function(b,c){return a.toUrl(b+(c||""))});a.cache||(a.cache={})}var d=a._curl,e=a.core.d;c(d);"undefined"==typeof ua&&(ua=d);a.core.d=function(){var a=e.apply(this,arguments);c(a.k);return a};return h});define("curl/plugin/domReady",["../domReady"],function(a){return{load:function(b,c,d){a(d)}}});
-}).call(this);
View
26 dist/curl-for-jQuery/curl.js
@@ -1,26 +0,0 @@
-(function(){/*
- MIT License (c) copyright B Cavalier & J Hann */
-var h=!0,l=!1,m=this.window||"undefined"!=typeof global&&global||this;function aa(){}function n(a,b){return 0==ba.call(a).indexOf("[object "+b)}function s(a){return a&&"/"==a.charAt(a.length-1)?a.substr(0,a.length-1):a}function ca(a,b){var d,c,e,g;d=1;c=a;"."==c.charAt(0)&&(e=h,c=c.replace(da,function(a,b,c,e){c&&d++;return e||""}));if(e){e=b.split("/");g=e.length-d;if(0>g)return a;e.splice(g,d);return e.concat(c||[]).join("/")}return c}
-function u(a){var b=a.indexOf("!");return{l:a.substr(b+1),j:0<=b&&a.substr(0,b)}}function v(){}function x(a,b){v.prototype=a||y;var d=new v;v.prototype=y;for(var c in b)d[c]=b[c];return d}
-function z(){function a(a,b,e){c.push([a,b,e])}function b(a,b){for(var e,d=0;e=c[d++];)(e=e[a])&&e(b)}var d,c,e;d=this;c=[];e=function(d,f){a=d?function(a){a&&a(f)}:function(a,b){b&&b(f)};e=aa;b(d?0:1,f);b=aa;c=A};this.z=function(b,c,e){a(b,c,e)};this.g=function(a){d.w=a;e(h,a)};this.e=function(a){d.la=a;e(l,a)};this.t=function(a){b(2,a)}}function B(a,b,d,c){a instanceof z?a.z(b,d,c):b(a)}function D(a,b,d){var c;return function(){0<=--a&&b&&(c=b.apply(A,arguments));0==a&&d&&d(c);return c}}
-function E(){var a=[].slice.call(arguments),b;n(a[0],"Object")&&(b=a.shift(),F(b));return new ea(a[0],a[1],a[2])}function F(a){a&&(G.P(a),H=G.b(a),G.R(a),"main"in a&&setTimeout(function(){var b;b=G.f(H,A,[].concat(a.main));G.h(b)},0))}function ea(a,b,d,c){var e;e=G.f(H,A,[].concat(a));this.then=a=function(a,b){B(e,function(b){a&&a.apply(A,b)},function(a){if(b)b(a);else throw a;});return this};this.next=function(a,b,c){return new ea(a,b,c,e)};this.config=F;(b||d)&&a(b,d);B(c,function(){G.h(e)})}
-function fa(a){var b,d;b=a.id;if(b==A)if(I!==A)I={F:"Multiple anonymous defines in url"};else if(!(b=G.$()))I=a;if(b!=A){d=J[b];b in J||(d=G.k(b,H),d=G.B(d.b,b),J[b]=d);if(!(d instanceof z))throw Error("duplicate define: "+b);d.da=l;G.C(d,a)}}function K(){var a=G.X(arguments);fa(a)}
-var H,L,M,N=m.document,O=N&&(N.head||N.getElementsByTagName("head")[0]),ga=O&&O.getElementsByTagName("base")[0]||null,ja={},ka={},P={},la="addEventListener"in m?{}:{loaded:1,complete:1},y={},ba=y.toString,A,J={},Q={},R=l,I,ma=/^\/|^[^:]+:\/\//,da=/(\.)(\.?)(?:$|\/([^\.\/]+.*)?)/g,na=/\/\*[\s\S]*?\*\/|(?:[^\\])\/\/.*?[\n\r]/g,oa=/require\s*\(\s*["']([^"']+)["']\s*\)|(?:[^\\]?)(["'])/g,S,G;
-G={m:function(a,b,d){var c,a=ca(a,b);if("."==a.charAt(0))return a;c=u(a);a=(b=c.j)||c.l;a in d.c&&(a=d.c[a].K||a);b&&(0>b.indexOf("/")&&!(b in d.c)&&(a=s(d.N)+"/"+b),a=a+"!"+c.l);return a},f:function(a,b,d,c){function e(b){return G.m(b,f.id,a)}function g(b,d,g){var i;i=d&&function(a){d.apply(A,a)};if(n(b,"String")){if(i)throw Error("require(id, callback) not allowed");g=e(b);b=J[g];if(!(g in J))throw Error("Module not resolved: "+g);return(g=b instanceof z&&b.a)||b}B(G.h(G.f(a,f.id,b,c)),i,g)}var f;
-f=new z;f.id=b||"";f.aa=c;f.D=d;f.b=a;f.u=g;g.toUrl=function(b){return G.k(e(b),a).url};f.m=e;return f},B:function(a,b,d){var c,e,g;c=G.f(a,b,A,d);e=c.g;g=D(1,function(a){c.p=a;try{return G.T(c)}catch(b){c.e(b)}});c.g=function(a){B(d||R,function(){e(J[c.id]=Q[c.url]=g(a))})};c.G=function(a){B(d||R,function(){c.a&&(g(a),c.t(ka))})};return c},S:function(a,b,d,c){return G.f(a,d,A,c)},Z:function(a){return a.u},H:function(a){return a.a||(a.a={})},Y:function(a){var b=a.q;b||(b=a.q={id:a.id,uri:G.I(a),exports:G.H(a),
-config:function(){return a.b}},b.a=b.exports);return b},I:function(a){return a.url||(a.url=G.A(a.u.toUrl(a.id),a.b))},P:function(a){var b,d,c,e,g;b="curl";d="define";c=e=m;if(a&&(g=a.overwriteApi||a.ja,b=a.apiName||a.fa||b,c=a.apiContext||a.ea||c,d=a.defineName||a.ha||d,e=a.defineContext||a.ga||e,L&&n(L,"Function")&&(m.curl=L),L=null,M&&n(M,"Function")&&(m.define=M),M=null,!g)){if(c[b]&&c[b]!=E)throw Error(b+" already exists");if(e[d]&&e[d]!=K)throw Error(d+" already exists");}c[b]=E;e[d]=K},b:function(a){function b(a,
-b){var c,d,f,p,t;for(t in a){f=a[t];n(f,"String")&&(f={path:a[t]});f.name=f.name||t;p=e;d=u(s(f.name));c=d.l;if(d=d.j)p=g[d],p||(p=g[d]=x(e),p.c=x(e.c),p.d=[]),delete a[t];if(b){d=f;var w=void 0;d.path=s(d.path||d.location||"");w=d.main||"./main";"."==w.charAt(0)||(w="./"+w);d.K=ca(w,d.name+"/");d.b=d.config;d.b&&(d.b=x(e,d.b))}else d={path:s(f.path)};d.Q=c.split("/").length;c?(p.c[c]=d,p.d.push(c)):p.n=G.O(f.path,e)}}function d(a){var b=a.c;a.M=RegExp("^("+a.d.sort(function(a,c){return b[c].Q-b[a].Q}).join("|").replace(/\/|\./g,
-"\\$&")+")(?=\\/|$)");delete a.d}var c,e,g,f;"baseUrl"in a&&(a.n=a.baseUrl);"main"in a&&(a.K=a.main);"preloads"in a&&(a.ka=a.preloads);"pluginPath"in a&&(a.N=a.pluginPath);if("dontAddFileExt"in a||a.i)a.i=RegExp(a.dontAddFileExt||a.i);c=H;e=x(c,a);e.c=x(c.c);g=a.plugins||{};e.plugins=x(c.plugins);e.s=x(c.s,a.s);e.r=x(c.r,a.r);e.d=[];b(a.packages,h);b(a.paths,l);for(f in g)a=G.m(f+"!","",e),e.plugins[a.substr(0,a.length-1)]=g[f];g=e.plugins;for(f in g)if(g[f]=x(e,g[f]),a=g[f].d)g[f].d=a.concat(e.d),
-d(g[f]);for(f in c.c)e.c.hasOwnProperty(f)||e.d.push(f);d(e);return e},R:function(a){var b;(b=a&&a.preloads)&&0<b.length&&B(R,function(){R=G.h(G.f(H,A,b,h))})},k:function(a,b){var d,c,e,g;d=b.c;e=ma.test(a)?a:a.replace(b.M,function(a){c=d[a]||{};g=c.b;return c.path||""});return{b:g||H,url:G.O(e,b)}},O:function(a,b){var d=b.n;return d&&!ma.test(a)?s(d)+"/"+a:a},A:function(a,b){return a+((b||H).i.test(a)?"":".js")},J:function(a,b,d){var c=N.createElement("script");c.onload=c.onreadystatechange=function(d){d=
-d||m.event;if("load"==d.type||la[c.readyState])delete P[a.id],c.onload=c.onreadystatechange=c.onerror="",b()};c.onerror=function(){d(Error("Syntax or http error: "+a.url))};c.type=a.L||"text/javascript";c.charset="utf-8";c.async=!a.ba;c.src=a.url;P[a.id]=c;O.insertBefore(c,ga);return c},U:function(a){var b=[],d;("string"==typeof a?a:a.toSource?a.toSource():a.toString()).replace(na,"").replace(oa,function(a,e,g){g?d=d==g?A:d:d||b.push(e);return""});return b},X:function(a){var b,d,c,e,g,f;g=a.length;
-c=a[g-1];e=n(c,"Function")?c.length:-1;2==g?n(a[0],"Array")?d=a[0]:b=a[0]:3==g&&(b=a[0],d=a[1]);!d&&0<e&&(f=h,d=["require","exports","module"].slice(0,e).concat(G.U(c)));return{id:b,p:d||[],v:0<=e?c:function(){return c},o:f}},T:function(a){var b;b=a.v.apply(a.o?a.a:A,a.p);b===A&&a.a&&(b=a.q?a.a=a.q.a:a.a);return b},C:function(a,b){a.v=b.v;a.o=b.o;a.D=b.p;G.h(a)},h:function(a){function b(a,b,c){f[b]=a;c&&j(a,b)}function d(b,c){var d,e,f,g;d=D(1,function(a){e(a);i(a,c)});e=D(1,function(a){j(a,c)});
-f=G.V(b,a);(g=f instanceof z&&f.a)&&e(g);B(f,d,a.e,a.a&&function(a){f.a&&(a==ja?e(f.a):a==ka&&d(f.a))})}function c(){a.g(f)}var e,g,f,k,q,j,i;f=[];g=a.D;k=g.length;0==g.length&&c();j=D(k,b,function(){a.G&&a.G(f)});i=D(k,b,c);for(e=0;e<k;e++)q=g[e],q in S?(i(S[q](a),e,h),a.a&&a.t(ja)):q?d(q,e):i(A,e,h);return a},W:function(a){G.I(a);G.J(a,function(){var b=I;I=A;a.da!==l&&(!b||b.F?a.e(Error(b&&b.F||"define() missing or duplicated: "+a.url)):G.C(a,b))},a.e);return a},V:function(a,b){var d,c,e,g,f,k,
-q,j,i,r,p;d=b.m;c=b.aa;e=b.b||H;g=u(d(a));q=g.l;f=g.j||q;j=G.k(f,e);if(g.j)k=f;else if(k=j.b.moduleLoader||j.b.ia)q=f,f=k,j=G.k(k,e);f in J?i=J[f]:j.url in Q?i=J[f]=Q[j.url]:(i=G.B(j.b,f,c),i.url=G.A(j.url,j.b),J[f]=Q[j.url]=i,G.W(i));f==k&&(r=new z,p=e.plugins[k]||e,B(i,function(a){var b,e,f;f=a.dynamic;q="normalize"in a?a.normalize(q,d,i.b)||"":d(q);e=k+"!"+q;b=J[e];if(!(e in J)){b=G.S(p,e,q,c);f||(J[e]=b);var g=function(a){b.g(a);f||(J[e]=a)};g.resolve=g;g.reject=g.error=b.e;a.load(q,b.u,g,p)}r!=
-b&&B(b,r.g,r.e,r.t)},r.e));return r||i},$:function(){var a;if(!n(m.opera,"Opera"))for(var b in P)if("interactive"==P[b].readyState){a=b;break}return a}};S={require:G.Z,exports:G.H,module:G.Y};E.version="0.7.3";E.config=F;K.amd={plugins:h,jQuery:h,curl:"0.7.3"};H={n:"",N:"curl/plugin",i:/\?|\.js\b/,s:{},r:{},plugins:{},c:{},M:/$^/};L=m.curl;M=m.define;!L||n(L,"Function")?G.P():(m.curl=A,F(L));J.curl=E;J["curl/_privileged"]={core:G,cache:J,config:function(){return H},_define:fa,_curl:E,Promise:z};
-var T=this.document;function pa(){if(!T.body)return l;U||(U=T.createTextNode(""));try{return T.body.removeChild(T.body.appendChild(U)),U=qa,h}catch(a){return l}}function V(){var a;a=ra[T[W]]&&pa();if(!X&&a){X=h;for(clearTimeout(Y);sa=ta.pop();)sa();ua&&(T[W]="complete");for(var b;b=va.shift();)b()}return a}function wa(){V();X||(Y=setTimeout(wa,xa))}var W="readyState",ra={loaded:1,interactive:1,complete:1},va=[],ua=T&&"string"!=typeof T[W],X=l,xa=10,Z,sa,ta=[],Y,qa,U;
-Z="addEventListener"in this?function(a,b){a.addEventListener(b,V,l);return function(){a.removeEventListener(b,V,l)}}:function(a,b){a.attachEvent("on"+b,V);return function(){a.detachEvent(b,V)}};T&&!V()&&(ta=[Z(this,"load"),Z(T,"readystatechange"),Z(this,"DOMContentLoaded")],Y=setTimeout(wa,xa));define("curl/domReady",function(){function a(a){X?a():va.push(a)}a.then=a;a.amd=h;return a});var ya=this.document;function za(a){try{return eval(a)}catch(b){}}
-define("curl/plugin/js",["curl/_privileged"],function(a){function b(b,c,d){function e(){g||(f<new Date?d():setTimeout(e,10))}var f,g,k;f=(new Date).valueOf()+(b.ca||3E5);d&&b.a&&setTimeout(e,10);k=a.core.J(b,function(){g=h;b.a&&(b.w=za(b.a));!b.a||b.w?c(k):d()},function(a){g=h;d(a)})}function d(a,c){b(a,function(){var b=e.shift();k=0<e.length;b&&d.apply(null,b);c.g(a.w||h)},function(a){c.e(a)})}var c={},e=[],g=ya&&ya.createElement("script").async==h,f,k;f=a.Promise;return{dynamic:h,normalize:function(a,
-b){var c=a.indexOf("!");return 0<=c?b(a.substr(0,c))+a.substr(c):b(a)},load:function(a,j,i,r){function p(a){(i.error||function(a){throw a;})(a)}var t,w,ha,ia,C;t=0<a.indexOf("!order");w=a.indexOf("!exports=");ha=0<w&&a.substr(w+9);ia="prefetch"in r?r.prefetch:h;a=t||0<w?a.substr(0,a.indexOf("!")):a;j=j.toUrl(a);C=j.lastIndexOf(".")<=j.lastIndexOf("/")?j+".js":j;C in c?c[C]instanceof f?c[C].z(i,p):i(c[C]):(a={name:a,url:C,ba:t,a:ha,ca:r.timeout},c[C]=r=new f,r.z(function(a){c[C]=a;i(a)},p),t&&!g&&
-k?(e.push([a,r]),ia&&(a.L="text/cache",b(a,function(a){a&&a.parentNode.removeChild(a)},function(){}),a.L="")):(k=k||t,d(a,r)))}}});var $=this.document,Aa=/^\/\//,Ba;$&&(Ba=$.head||($.head=$.getElementsByTagName("head")[0]));
-define("curl/plugin/link",{load:function(a,b,d,c){a=b.toUrl(a);a=a.lastIndexOf(".")<=a.lastIndexOf("/")?a+".css":a;c=a=(c="fixSchemalessUrls"in c?c.fixSchemalessUrls:$.location.protocol)?a.replace(Aa,c+"//"):a;a=$.createElement("link");a.rel="stylesheet";a.type="text/css";a.href=c;Ba.appendChild(a);d(a.sheet||a.styleSheet)}});define("curl/plugin/domReady",["../domReady"],function(a){return{load:function(b,d,c){a(c)}}});
-}).call(this);
View
1,526 dist/curl-for-ssjs/curl.js
@@ -1,1526 +0,0 @@
-/** @license MIT License (c) copyright B Cavalier & J Hann */
-
-/**
- * curl (cujo resource loader)
- * An AMD-compliant javascript module and resource loader
- *
- * curl is part of the cujo.js family of libraries (http://cujojs.com/)
- *
- * Licensed under the MIT License at:
- * http://www.opensource.org/licenses/mit-license.php
- *
- */
-(function (global) {
-//"use strict"; don't restore this until the config routine is refactored
- var
- version = '0.7.3',
- curlName = 'curl',
- defineName = 'define',
- userCfg,
- prevCurl,
- prevDefine,
- doc = global.document,
- head = doc && (doc['head'] || doc.getElementsByTagName('head')[0]),
- // to keep IE from crying, we need to put scripts before any
- // <base> elements, but after any <meta>. this should do it:
- insertBeforeEl = head && head.getElementsByTagName('base')[0] || null,
- // constants / flags
- msgUsingExports = {},
- msgFactoryExecuted = {},
- // this is the list of scripts that IE is loading. one of these will
- // be the "interactive" script. too bad IE doesn't send a readystatechange
- // event to tell us exactly which one.
- activeScripts = {},
- // readyStates for IE6-9
- readyStates = 'addEventListener' in global ? {} : { 'loaded': 1, 'complete': 1 },
- // these are always handy :)
- cleanPrototype = {},
- toString = cleanPrototype.toString,
- undef,
- // local cache of resource definitions (lightweight promises)
- cache = {},
- // local url cache
- urlCache = {},
- // preload are files that must be loaded before any others
- preload = false,
- // net to catch anonymous define calls' arguments (non-IE browsers)
- argsNet,
- // RegExp's used later, pre-compiled here
- dontAddExtRx = /\?|\.js\b/,
- absUrlRx = /^\/|^[^:]+:\/\//,
- findDotsRx = /(\.)(\.?)(?:$|\/([^\.\/]+.*)?)/g,
- removeCommentsRx = /\/\*[\s\S]*?\*\/|(?:[^\\])\/\/.*?[\n\r]/g,
- findRValueRequiresRx = /require\s*\(\s*["']([^"']+)["']\s*\)|(?:[^\\]?)(["'])/g,
- cjsGetters,
- core;
-
- function noop () {}
-
- function isType (obj, type) {
- return toString.call(obj).indexOf('[object ' + type) == 0;
- }
-
- function normalizePkgDescriptor (descriptor) {
- var main;
-
- descriptor.path = removeEndSlash(descriptor['path'] || descriptor['location'] || '');
- main = descriptor['main'] || './main';
- if (!isRelUrl(main)) main = './' + main;
- // trailing slashes trick reduceLeadingDots to see them as base ids
- descriptor.main = reduceLeadingDots(main, descriptor.name + '/');
- //if (isRelUrl(descriptor.main)) throw new Error('invalid main (' + main + ') in ' + descriptor.name);
- descriptor.config = descriptor['config'];
-
- return descriptor;
- }
-
- function isRelUrl (it) {
- return it.charAt(0) == '.';
- }
-
- function isAbsUrl (it) {
- return absUrlRx.test(it);
- }
-
- function joinPath (path, file) {
- return removeEndSlash(path) + '/' + file;
- }
-
- function removeEndSlash (path) {
- return path && path.charAt(path.length - 1) == '/' ? path.substr(0, path.length - 1) : path;
- }
-
- function reduceLeadingDots (childId, baseId) {
- // this algorithm is similar to dojo's compactPath, which interprets
- // module ids of "." and ".." as meaning "grab the module whose name is
- // the same as my folder or parent folder". These special module ids
- // are not included in the AMD spec but seem to work in node.js, too.
- var removeLevels, normId, levels, isRelative, diff;
-
- removeLevels = 1;
- normId = childId;
-
- // remove leading dots and count levels
- if (isRelUrl(normId)) {
- isRelative = true;
- normId = normId.replace(findDotsRx, function (m, dot, doubleDot, remainder) {
- if (doubleDot) removeLevels++;
- return remainder || '';
- });
- }
-
- if (isRelative) {
- levels = baseId.split('/');
- diff = levels.length - removeLevels;
- if (diff < 0) {
- // this is an attempt to navigate above parent module.
- // maybe dev wants a url or something. punt and return url;
- return childId;
- }
- levels.splice(diff, removeLevels);
- // normId || [] prevents concat from adding extra "/" when
- // normId is reduced to a blank string
- return levels.concat(normId || []).join('/');
- }
- else {
- return normId;
- }
- }
-
- function pluginParts (id) {
- var delPos = id.indexOf('!');
- return {
- resourceId: id.substr(delPos + 1),
- // resourceId can be zero length
- pluginId: delPos >= 0 && id.substr(0, delPos)
- };
- }
-
- function Begetter () {}
-
- function beget (parent, mixin) {
- Begetter.prototype = parent || cleanPrototype;
- var child = new Begetter();
- Begetter.prototype = cleanPrototype;
- for (var p in mixin) child[p] = mixin[p];
- return child;
- }
-
- function Promise () {
-
- var self, thens, complete;
-
- self = this;
- thens = [];
-
- function then (resolved, rejected, progressed) {
- // capture calls to callbacks
- thens.push([resolved, rejected, progressed]);
- }
-
- function notify (which, arg) {
- // complete all callbacks
- var aThen, cb, i = 0;
- while ((aThen = thens[i++])) {
- cb = aThen[which];
- if (cb) cb(arg);
- }
- }
-
- complete = function promiseComplete (success, arg) {
- // switch over to sync then()
- then = success ?
- function (resolved, rejected) { resolved && resolved(arg); } :
- function (resolved, rejected) { rejected && rejected(arg); };
- // we no longer throw during multiple calls to resolve or reject
- // since we don't really provide useful information anyways.
- complete = noop;
- // complete all callbacks
- notify(success ? 0 : 1, arg);
- // no more notifications
- notify = noop;
- // release memory
- thens = undef;
- };
-
- this.then = function (resolved, rejected, progressed) {
- then(resolved, rejected, progressed);
- return self;
- };
- this.resolve = function (val) {
- self.resolved = val;
- complete(true, val);
- };
- this.reject = function (ex) {
- self.rejected = ex;
- complete(false, ex);
- };
- this.progress = function (msg) {
- notify(2, msg);
- }
-
- }
-
- function isPromise (o) {
- return o instanceof Promise;
- }
-
- function when (promiseOrValue, callback, errback, progback) {
- // we can't just sniff for then(). if we do, resources that have a
- // then() method will make dependencies wait!
- if (isPromise(promiseOrValue)) {
- return promiseOrValue.then(callback, errback, progback);
- }
- else {
- return callback(promiseOrValue);
- }
- }
-
- /**
- * Returns a function that when executed, executes a lambda function,
- * but only executes it the number of times stated by howMany.
- * When done executing, it executes the completed function. Each callback
- * function receives the same parameters that are supplied to the
- * returned function each time it executes. In other words, they
- * are passed through.
- * @private
- * @param howMany {Number} must be greater than zero
- * @param lambda {Function} executed each time
- * @param completed {Function} only executes once when the counter
- * reaches zero
- * @returns {Function}
- */
- function countdown (howMany, lambda, completed) {
- var result;
- return function () {
- if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
- // we want ==, not <=, since some callers expect call-once functionality
- if (howMany == 0 && completed) completed(result);
- return result;
- }
- }
-
- core = {
-
- /**
- * * reduceLeadingDots of id against parentId
- * - if there are too many dots (path goes beyond parent), it's a url
- * - return reduceLeadingDots of id against baseUrl + parentId;
- * * if id is a url (starts with dots or slash or protocol)
- * - pathInfo = { config: userCfg, url: url }
- * * if not a url, id-to-id transform here.
- * - main module expansion
- * - plugin prefix expansion
- * - coordinate main module expansion with plugin expansion
- * - main module expansion happens first
- * - future: other transforms?
- * @param id
- * @param parentId
- * @param cfg
- * @return {*}
- */
- toAbsId: function (id, parentId, cfg) {
- var absId, pluginId, parts;
-
- absId = reduceLeadingDots(id, parentId);
-
- // if this is still a relative path, it must be a url
- // so just punt, otherwise...
- if (isRelUrl(absId)) return absId;
-
- // plugin id split
- parts = pluginParts(absId);
- pluginId = parts.pluginId;
- absId = pluginId || parts.resourceId;
-
- // main id expansion
- if (absId in cfg.pathMap) {
- absId = cfg.pathMap[absId].main || absId;
- }
-
- // plugin id expansion
- if (pluginId) {
- if (pluginId.indexOf('/') < 0 && !(pluginId in cfg.pathMap)) {
- absId = joinPath(cfg.pluginPath, pluginId);
- }
- absId = absId + '!' + parts.resourceId;
- }
-
- return absId;
- },
-
- createContext: function (cfg, baseId, depNames, isPreload) {
-
- var def;
-
- def = new Promise();
- def.id = baseId || ''; // '' == global
- def.isPreload = isPreload;
- def.depNames = depNames;
- def.config = cfg;
-
- // functions that dependencies will use:
-
- function toAbsId (childId) {
- return core.toAbsId(childId, def.id, cfg);
- }
-
- function toUrl (n) {
- // the AMD spec states that we should not append an extension
- // in this function since it could already be appended.
- // we need to use toAbsId in case this is a module id.
- return core.resolvePathInfo(toAbsId(n), cfg).url;
- }
-
- function localRequire (ids, callback, errback) {
- var cb, rvid, childDef, earlyExport;
-
- // this is public, so send pure function
- // also fixes issue #41
- cb = callback && function () { callback.apply(undef, arguments[0]); };
-
- // RValue require (CommonJS)
- if (isType(ids, 'String')) {
- if (cb) {
- throw new Error('require(id, callback) not allowed');
- }
- // return resource
- rvid = toAbsId(ids);
- childDef = cache[rvid];
- if (!(rvid in cache)) {
- // this should only happen when devs attempt their own
- // manual wrapping of cjs modules or get confused with
- // the callback syntax:
- throw new Error('Module not resolved: ' + rvid);
- }
- earlyExport = isPromise(childDef) && childDef.exports;
- return earlyExport || childDef;
- }
- else {
- when(core.getDeps(core.createContext(cfg, def.id, ids, isPreload)), cb, errback);
- }
- }
-
- def.require = localRequire;
- localRequire['toUrl'] = toUrl;
- def.toAbsId = toAbsId;
-
- return def;
- },
-
- createResourceDef: function (cfg, id, isPreload) {
- var def, origResolve, execute;
-
- def = core.createContext(cfg, id, undef, isPreload);
- origResolve = def.resolve;
-
- // using countdown to only execute definition function once
- execute = countdown(1, function (deps) {
- def.deps = deps;
- try {
- return core.executeDefFunc(def);
- }
- catch (ex) {
- def.reject(ex);
- }
- });
-
- // intercept resolve function to execute definition function
- // before resolving
- def.resolve = function resolve (deps) {
- when(isPreload || preload, function () {
- origResolve((cache[def.id] = urlCache[def.url] = execute(deps)));
- });
- };
-
- // track exports
- def.exportsReady = function executeFactory (deps) {
- when(isPreload || preload, function () {
- // only resolve early if we also use exports (to avoid
- // circular dependencies). def.exports will have already
- // been set by the getDeps loop before we get here.
- if (def.exports) {
- execute(deps);
- def.progress(msgFactoryExecuted);
- }
- });
- };
-
- return def;
- },
-
- createPluginDef: function (cfg, id, resId, isPreload) {
- var def;
-
- // use resource id for local require and toAbsId
- def = core.createContext(cfg, resId, undef, isPreload);
-
- return def;
- },
-
- getCjsRequire: function (def) {
- return def.require;
- },
-
- getCjsExports: function (def) {
- return def.exports || (def.exports = {});
- },
-
- getCjsModule: function (def) {
- var module = def.module;
- if (!module) {
- module = def.module = {
- 'id': def.id,
- 'uri': core.getDefUrl(def),
- 'exports': core.getCjsExports(def),
- 'config': function () { return def.config; }
- };
- module.exports = module['exports']; // oh closure compiler!
- }
- return module;
- },
-
- getDefUrl: function (def) {
- // note: this is used by cjs module.uri
- return def.url || (def.url = core.checkToAddJsExt(def.require['toUrl'](def.id), def.config));
- },
-
- /**
- * Sets the curl() and define() APIs.
- * @param [cfg] {Object|Null} set of config params. If missing or null,
- * this function will set the default API!
- */
- setApi: function (cfg) {
- /*
- scenarios:
- 1. global config sets apiName: "require"
- - first call to config sets api
- - second and later calls are ignored
- - prevCurl cannot exist
- 2. no global config, first call to config() sets api
- - first call to config has no api info
- - second call to config sets api
- - third and later calls must be ignored
- 3. global config that doesn't set api, first call does though
- - same as #2
- 4. api info is never set
- - how to know when to stop ignoring?
-
- objectives:
- 1. fail before mistakenly overwriting global[curlName]
- 2. allow rename/relocate of curl() and define()
- 3. restore curl() if we overwrote it
- */
-
- var apiName, defName, apiObj, defObj,
- failMsg, okToOverwrite;
-
- apiName = curlName;
- defName = defineName;
- apiObj = defObj = global;
- failMsg = ' already exists';
-
- // if we're not setting defaults
- if (cfg) {
- // is it ok to overwrite existing api functions?
- okToOverwrite = cfg['overwriteApi'] || cfg.overwriteApi;
- // allow dev to rename/relocate curl() to another object
- apiName = cfg['apiName'] || cfg.apiName || apiName;
- apiObj = cfg['apiContext'] || cfg.apiContext || apiObj;
- // define() too
- defName = cfg['defineName'] || cfg.defineName || defName;
- defObj = cfg['defineContext'] || cfg.defineContext || defObj;
-
- // curl() already existed, restore it if this is not a
- // setDefaults pass. dev must be a good citizen and set
- // apiName/apiContext (see below).
- if (prevCurl && isType(prevCurl, 'Function')) {
- // restore previous curl()
- global[curlName] = prevCurl;
- }
- prevCurl = null; // don't check ever again
- // ditto for define()
- if (prevDefine && isType(prevDefine, 'Function')) {
- // restore previous curl()
- global[defineName] = prevDefine;
- }
- prevDefine = null; // don't check ever again
-
- // check if we're mistakenly overwriting either api
- // if we're configuring, and there's a curl(), and it's not
- // ours -- and we're not explicitly overwriting -- throw!
- // Note: if we're setting defaults, we *must* overwrite curl
- // so that dev can configure it. This is no different than
- // noConflict()-type methods.
- if (!okToOverwrite) {
- if (apiObj[apiName] && apiObj[apiName] != _curl) {
- throw new Error(apiName + failMsg);
- }
- // check if we're overwriting amd api
- if (defObj[defName] && defObj[defName] != define) {
- throw new Error(defName + failMsg);
- }
- }
-
- }
-
- // set curl api
- apiObj[apiName] = _curl;
-
- // set AMD public api: define()
- defObj[defName] = define;
-
- },
-
- config: function (cfg) {
- var prevCfg, newCfg, pluginCfgs, p;
-
- // convert from closure-safe names
- if ('baseUrl' in cfg) cfg.baseUrl = cfg['baseUrl'];
- if ('main' in cfg) cfg.main = cfg['main'];
- if ('preloads' in cfg) cfg.preloads = cfg['preloads'];
- if ('pluginPath' in cfg) cfg.pluginPath = cfg['pluginPath'];
- if ('dontAddFileExt' in cfg || cfg.dontAddFileExt) {
- cfg.dontAddFileExt = new RegExp(cfg['dontAddFileExt'] || cfg.dontAddFileExt);
- }
-
- prevCfg = userCfg;
- newCfg = beget(prevCfg, cfg);
-
- // create object to hold path map.
- // each plugin and package will have its own pathMap, too.
- newCfg.pathMap = beget(prevCfg.pathMap);
- pluginCfgs = cfg['plugins'] || {};
- newCfg.plugins = beget(prevCfg.plugins);
- newCfg.paths = beget(prevCfg.paths, cfg.paths);
- newCfg.packages = beget(prevCfg.packages, cfg.packages);
-
- // temporary arrays of paths. this will be converted