├── .DS_Store ├── LICENSE.txt ├── README.md ├── TODO.md ├── bin ├── compile.sh ├── make-all.sh └── make.sh ├── bower.json ├── dist ├── README.md ├── curl-for-dojo1.6 │ └── curl.js ├── curl-for-dojo1.8 │ └── curl.js ├── curl-for-jQuery │ └── curl.js ├── curl-for-ssjs │ └── curl.js ├── curl-kitchen-sink │ └── curl.js ├── curl-with-js-and-domReady │ └── curl.js ├── curl │ └── curl.js └── debug │ └── curl.js ├── docs └── release-notes.md ├── package.json ├── src ├── curl.js └── curl │ ├── .DS_Store │ ├── cram │ ├── _define.js │ ├── _stringify.js │ ├── cjsm11.js │ ├── css.js │ ├── i18n.js │ ├── js.js │ ├── jsEncode.js │ ├── json.js │ ├── legacy.js │ └── text.js │ ├── debug.js │ ├── domReady.js │ ├── loader │ ├── README.md │ ├── cjsm11.js │ └── legacy.js │ ├── plugin │ ├── README.md │ ├── _fetchText.js │ ├── async.js │ ├── css.js │ ├── domReady.js │ ├── i18n.js │ ├── img.js │ ├── js.js │ ├── json.js │ ├── link.js │ ├── locale.js │ ├── style.js │ └── text.js │ ├── shim │ ├── _fetchText.js │ ├── dojo16.js │ ├── dojo18.js │ └── ssjs.js │ └── tdd │ ├── .DS_Store │ ├── runner.js │ └── undefine.js └── test ├── apiAfter.html ├── apiConflict.html ├── apiConflict2.html ├── apiName.html ├── apiName2.html ├── basic.html ├── cjsModules1.1.html ├── cjsm1.1-prewrapped.html ├── config.html ├── cycle-correction-hybrid.html ├── data-curl-run-failover.html ├── data-curl-run.html ├── debug.html ├── defineAfter.html ├── defineConflict.html ├── defineConflict2.html ├── defineContext.html ├── defineContext2.html ├── dist-jquery.html ├── dist-kitchen-sink.html ├── domReady.html ├── dontAddFileExt.html ├── i18n.html ├── i18n ├── strings.js └── strings │ └── en-gb.js ├── img.html ├── img ├── circle.png └── rect.png ├── issue20.html ├── issue28.html ├── issue34.html ├── issue37.html ├── issue53.html ├── jquery-ready.html ├── js-load-once-issue30.html ├── js-test-option-failure.html ├── js-test-option-success.html ├── json.html ├── json └── data.json ├── legacy.html ├── link-parent-path-issue108.html ├── link.html ├── local-require.html ├── many-css-resources.html ├── many-plugin-callbacks.html ├── module-returns-undefined.html ├── multiple_curl_calls.html ├── next.html ├── package-specific-config.html ├── packages-as-object.html ├── packages.html ├── paths.html ├── plainOldJs.html ├── plugin-errback.html ├── plugin-relative-ids.html ├── plugin-specific-paths.html ├── pluginConfig.html ├── preload.html ├── protocol-relative-urls.html ├── relative-plugins.html ├── simple-plugin.html ├── stuff ├── aView │ ├── controller.js │ ├── css.css │ └── template.html ├── bad-import.css ├── base.css ├── blank.css ├── cascade-end.css ├── cascade-middle.css ├── cascade-start.css ├── css-on-cdn.js ├── dep-on-test1-in-define.js ├── dep-on-test1.js ├── foo.defineModule.js ├── increments.js ├── issue53.js ├── module-without-ext ├── nls │ └── strings.js ├── one.js ├── plain_old.js ├── plain_old_2.js ├── random.js ├── run-script.js ├── second.css ├── template.html ├── three.js ├── two.js ├── undefined-module.js ├── wants-js-and-css.js ├── xdtext.html └── zero.js ├── support ├── commonjs │ ├── exports.js │ ├── folder │ │ ├── deep │ │ │ └── returnMain.js │ │ ├── non-cjs.js │ │ └── returnMain.js │ ├── foo.js │ ├── hybrid.js │ ├── loop │ │ ├── hybrid-loop1.js │ │ ├── hybrid-loop2.js │ │ └── hybrid-loop3.js │ ├── main-with-relative-dep.js │ ├── main.js │ ├── main2.js │ ├── module.js │ ├── nakedDependentCjsm1.1.js │ ├── nakedSimpleCjsm1.1.js │ ├── named-main.js │ ├── package.json │ ├── relative-dep.js │ ├── return-config.js │ └── this.js ├── fake.js ├── foo-bar-define │ └── simple.js ├── loop │ ├── loop-start.js │ ├── loop1.js │ ├── loop2.js │ └── loop3.js ├── main-plugin.js ├── requires-fake.js ├── simple-plugin.js └── underscore-amdjs-1.3.1 │ ├── underscore-min.js │ ├── underscore-orig.js │ └── underscore.js ├── tdd-runner.html ├── tdd ├── MethodSpy.js ├── Spy.js └── configureAsserts.js ├── then.html ├── top-level-plugin.html ├── undefine.html └── underscore.html /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cujojs/curl/13170edcbeb9dc55c48ea00e5fec890eec75b59f/.DS_Store -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Open Source Initiative OSI - The MIT License 2 | 3 | http://www.opensource.org/licenses/mit-license.php 4 | 5 | Copyright (c) 2010-2013 Brian Cavalier and John Hann 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files (the 9 | "Software"), to deal in the Software without restriction, including 10 | without limitation the rights to use, copy, modify, merge, publish, 11 | distribute, sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, subject to 13 | the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | ## before 0.7.4 release 4 | 5 | * investigate all variations of data-curl-run 6 | * split path from file name. path = baseUrl, file = main 7 | * if comma-sep (data-curl-run="js/bundle,js/run"), 8 | main = "run", not "bundle" ??? 9 | * document data-curl-run and link from [Configuring curl.js] 10 | * Investigate IE intermittent silent failure issues 11 | 12 | ## possibly before 0.7.4 release 13 | 14 | * move docs from wiki to docs folder 15 | -------------------------------------------------------------------------------- /bin/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # run a file through google closure compiler 3 | 4 | # TODO: start using a js_externs parameter: 5 | # paths and other config params 6 | # full promise api (for communicating with plugins) 7 | # -d js_externs=promise.then=function(cb,eb){};promise.resolve=function(val){};promise.reject=function(ex){}; 8 | 9 | curl \ 10 | --data-urlencode "js_code@$1" \ 11 | -d compilation_level=$2 \ 12 | -d output_info=compiled_code \ 13 | -d output_format=text \ 14 | -d 'output_wrapper=(function(){%25output%25}).call(this);' \ 15 | http://closure-compiler.appspot.com/compile 16 | -------------------------------------------------------------------------------- /bin/make-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # make simple, compiled curl.js 4 | ./make.sh ../dist/curl/curl.js ../src/curl.js 5 | 6 | # make curl-debug.js 7 | ./make.sh --NONE ../dist/debug/curl.js ../src/curl.js ../src/curl/debug.js 8 | 9 | # make other versions of curl 10 | ./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 11 | ./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 12 | ./make.sh ../dist/curl-for-dojo1.8/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/shim/dojo18.js ../src/curl/plugin/domReady.js 13 | ./make.sh ../dist/curl-kitchen-sink/curl.js ../src/curl.js ../src/curl/domReady.js ../src/curl/shim/dojo18.js ../src/curl/plugin/js.js ../src/curl/plugin/_fetchText.js ../src/curl/plugin/text.js ../src/curl/plugin/async.js ../src/curl/plugin/css.js ../src/curl/plugin/link.js ../src/curl/plugin/json.js ../src/curl/plugin/domReady.js ../src/curl/shim/_fetchText.js ../src/curl/shim/ssjs.js ../src/curl/loader/cjsm11.js ../src/curl/plugin/locale.js ../src/curl/plugin/i18n.js ../src/curl/loader/legacy.js 14 | ./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 15 | 16 | #make minimally-compressed ssjs 17 | ./make.sh --NONE ../dist/curl-for-ssjs/curl.js ../src/curl.js ../src/curl/plugin/_fetchText.js ../src/curl/shim/_fetchText.js ../src/curl/shim/ssjs.js ../src/curl/loader/cjsm11.js 18 | -------------------------------------------------------------------------------- /bin/make.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | # get optional optimization instruction 6 | opt=$1 7 | if [ "${opt:0:2}" = "--" ]; then 8 | opt=${opt:2} 9 | shift 10 | else 11 | opt=ADVANCED_OPTIMIZATIONS 12 | fi 13 | 14 | # grab the output file 15 | out=$1 16 | tmpfile=$(mktemp -t cram.XXXXXX) 17 | 18 | # use all of the remaining parameters as files to be concatenated 19 | shift 20 | 21 | echo "making $out" 22 | echo "optimization level is $opt" 23 | 24 | # concatenate all of the files to a temp file 25 | cat $@ | sed -e "s:\/\*==::g" -e "s:==\*\/::g" > "$tmpfile" 26 | 27 | # get version number 28 | CURLJS_VERSION=$(sed -n "s|.*version.*\(['\"]\)\([^'\"]*\)\1.*|\2|p" < ../src/curl.js) 29 | 30 | # prepend valid version number 31 | if [ -z "${CURLJS_VERSION//[0-9.]/}" ] && ! [ -z "$CURLJS_VERSION" ]; then 32 | echo "/* version: ${CURLJS_VERSION} */" > "$out" 33 | else 34 | echo "incorrect/missing version number (${CURLJS_VERSION})" >&2 35 | echo -n > "$out" 36 | fi 37 | 38 | if [ "$opt" = "NONE" ]; then 39 | # cat files to the output file 40 | cat "$tmpfile" >> "$out" 41 | else 42 | # compile files to the output file 43 | "$DIR"/compile.sh "$tmpfile" "$opt" >> "$out" 44 | fi 45 | 46 | # remove the temporary concatenated file 47 | rm "$tmpfile" 48 | 49 | echo "created $out" 50 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "curl", 3 | "moduleType": [ "amd", "node" ], 4 | "main": "./src/curl.js", 5 | "description": "curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.", 6 | "ignore": ["bin", "docs", "test"] 7 | } 8 | -------------------------------------------------------------------------------- /dist/README.md: -------------------------------------------------------------------------------- 1 | Distribution Files 2 | ================== 3 | 4 | These are "compiled" versions of curl.js for your convenience. 5 | 6 | Please note: these versions have been processed with Google Closure Compiler 7 | in Advanced Mode. Advanced Mode obfuscates any identifiers that haven't 8 | been specifically declared as "exported". 9 | Therefore, any modules/files that aren't compiled at the same time 10 | may not work together after being compiled. 11 | 12 | curl.js only exports identifiers needed for AMD compatibility or needed 13 | to process configuration settings. What this means to you: 14 | 15 | If you plan to use any of curl's plugins or other auxiliary modules, 16 | you may have to compile them into curl.js (see below) -- or 17 | compile curl.js into your application's optimized files. If you see "method 18 | not defined" or similar errors within curl.js, this is likely the problem. 19 | 20 | Use curl/curl.js if you are only loading AMD-formatted javascript modules. 21 | 22 | Use curl-with-js-and-domReady/curl.js if you wish to use non-AMD javascript 23 | files and don't have an alternative domReady implementation handy. 24 | 25 | Use curl-for-jQuery for a version of curl that has instructions for 26 | jQuery 1.7+ to register as an AMD module and has the js! and link! plugins 27 | built in. This is an adequate configuration for many simple jQuery projects. 28 | 29 | curl-for-dojo1.8 has the domReady! plugin built in as well as a 30 | compatibility shim for dojo 1.8 and dojo 1.9. 31 | 32 | You can build your own custom version of curl.js by using the `make.sh` script 33 | in the /bin/ folder. You must run it from the /bin/ folder. Syntax: 34 | 35 | ``` 36 | ./make.sh destination/curl.js ../src/curl.js [files to concat into curl.js] 37 | ``` 38 | 39 | The following files can be concatenated into curl.js using make.sh: 40 | 41 | * ../src/curl/plugin/js.js (the js! plugin) 42 | * ../src/curl/plugin/text.js (the text! plugin) 43 | * ../src/curl/plugin/i18n.js (the i18n! plugin) 44 | * ../src/curl/plugin/css.js (the css! plugin) 45 | * ../src/curl/plugin/link.js (the link! plugin) 46 | * ../src/curl/plugin/domReady.js (the domReady plugin) 47 | * ../src/curl/domReady.js (the domReady module) 48 | * ../src/curl/shim/dojo16.js (the dojo 1.6 compatibility shim / module) 49 | * ../src/curl/shim/dojo18.js (the dojo 1.6 compatibility shim / module) 50 | * ../src/curl/loader/cjsm11.js (a CommonJS Modules/1.1 and node.js loader) 51 | * ../src/curl/loader/ssjs.js (a shim that allows curl.js to run in node.js) 52 | * ../src/curl/loader/legacy.js (a better alternative to the js! plugin) 53 | * Any named AMD module (does not support anonymous modules, yet!) 54 | * Any non-AMD javascript file 55 | 56 | For example, to make a version of curl with the js! and css! plugins built-in: 57 | 58 | ``` 59 | ./make.sh destination/curl.js ../src/curl.js ../src/curl/plugin/js.js ../src/curl/plugin/css.js 60 | ``` 61 | 62 | Note: The make.sh bash script is not smart. You must tell it to concat 63 | dependencies -- and in the right order. For instance, to use the text! 64 | and json! plugins, you must also include the _fetchText.js module (in the 65 | same folder) *before the plugins that depend on it*. 66 | 67 | Note: you will need a fairly recent version of `curl` (the unix utility, not 68 | curl.js!) to run `make.sh`. Version 7.18 or later is fine. 69 | -------------------------------------------------------------------------------- /dist/curl/curl.js: -------------------------------------------------------------------------------- 1 | /* version: 0.8.13 */ 2 | (function(){/* 3 | MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 4 | (function(m){function U(){}function u(a,b){return 0==aa.call(a).indexOf("[object "+b)}function I(a){return a&&"/"==a.charAt(a.length-1)?a.substr(0,a.length-1):a}function V(a,b){var d,c,e,f;d=1;c=a;"."==c.charAt(0)&&(e=!0,c=c.replace(ba,function(a,b,c,e){c&&d++;return e||""}));if(e){e=b.split("/");f=e.length-d;if(0>f)return a;e.splice(f,d);return e.concat(c||[]).join("/")}return c}function J(a){var b=a.indexOf("!");return{h:a.substr(b+1),f:0<=b&&a.substr(0,b)}}function P(){}function v(a,b){P.prototype= 5 | a||Q;var d=new P;P.prototype=Q;for(var c in b)d[c]=b[c];return d}function K(){function a(a,b,d){c.push([a,b,d])}function b(a,b){for(var d,e=0;d=c[e++];)(d=d[a])&&d(b)}var d,c,e;d=this;c=[];e=function(d,g){a=d?function(a){a&&a(g)}:function(a,b){b&&b(g)};e=U;b(d?0:1,g);b=U;c=k};this.then=function(b,c,e){a(b,c,e);return d};this.resolve=function(a){d.va=a;e(!0,a)};this.reject=function(a){d.ua=a;e(!1,a)};this.D=function(a){b(2,a)}}function L(a){return a instanceof K||a instanceof B}function w(a,b,d,c){L(a)? 6 | a.then(b,d,c):b(a)}function C(a,b,d){var c;return function(){0<=--a&&b&&(c=b.apply(k,arguments));0==a&&d&&d(c);return c}}function A(){var a,b;D="";a=[].slice.call(arguments);u(a[0],"Object")&&(b=a.shift(),b=M(b));return new B(a[0],a[1],a[2],b)}function M(a,b,d){var c;D="";if(a&&(h.V(a),x=h.a(a),"preloads"in a&&(c=new B(a.preloads,k,d,E,!0),h.m(function(){E=c})),a=a.main))return new B(a,b,d)}function B(a,b,d,c,e){var f;f=h.j(x,k,[].concat(a),e);this.then=this.then=a=function(a,b){w(f,function(b){a&& 7 | a.apply(k,b)},function(a){if(b)b(a);else throw a;});return this};this.next=function(a,b,c){return new B(a,b,c,f)};this.config=M;(b||d)&&a(b,d);h.m(function(){w(e||E,function(){w(c,function(){h.w(f)},d)})})}function W(a){var b,d;b=a.id;b==k&&(F!==k?F={L:"Multiple anonymous defines encountered"}:(b=h.ha())||(F=a));if(b!=k){d=l[b];b in l||(d=h.i(b,x),d=h.I(d.a,b),l[b]=d);if(!L(d))throw Error("duplicate define: "+b);d.ja=!1;h.J(d,a)}}function R(){var a=h.ea(arguments);W(a)}var D,x,y,G,z=m.document,S= 8 | z&&(z.head||z.getElementsByTagName("head")[0]),ca=S&&S.getElementsByTagName("base")[0]||null,X={},Y={},N={},da="addEventListener"in m?{}:{loaded:1,complete:1},Q={},aa=Q.toString,k,l={},O={},E=!1,F,Z=/^\/|^[^:]+:\/\/|^[A-Za-z]:[\\/]/,ba=/(\.)(\.?)(?:$|\/([^\.\/]+.*)?)/g,ea=/\/\*[\s\S]*?\*\/|\/\/.*?[\n\r]/g,fa=/require\s*\(\s*(["'])(.*?[^\\])\1\s*\)|[^\\]?(["'])/g,ga=/\s*,\s*/,T,h;h={o:function(a,b,d){var c;a=V(a,b);if("."==a.charAt(0))return a;c=J(a);a=(b=c.f)||c.h;a in d.c&&(a=d.c[a].R||a);b&&(0> 9 | b.indexOf("/")&&!(b in d.c)&&(a=I(d.T)+"/"+b),a=a+"!"+c.h);return a},j:function(a,b,d,c){function e(b,c){var d,f;d=h.o(b,g.id,a);if(!c)return d;f=J(d);if(!f.f)return d;d=l[f.f];f.h="normalize"in d?d.normalize(f.h,e,g.a)||"":e(f.h);return f.f+"!"+f.h}function f(b,d,f){var p;p=d&&function(a){d.apply(k,a)};if(u(b,"String")){if(p)throw Error("require(id, callback) not allowed");f=e(b,!0);b=l[f];if(!(f in l))throw Error("Module not resolved: "+f);return(f=L(b)&&b.b)||b}w(h.w(h.j(a,g.id,b,c)),p,f)}var g; 10 | g=new K;g.id=b||"";g.ia=c;g.K=d;g.a=a;g.F=f;f.toUrl=function(b){return h.i(e(b,!0),a).url};g.o=e;return g},I:function(a,b,d){var c,e,f;c=h.j(a,b,k,d);e=c.resolve;f=C(1,function(a){c.v=a;try{return h.Z(c)}catch(b){c.reject(b)}});c.resolve=function(a){w(d||E,function(){e(l[c.id]=O[c.url]=f(a))})};c.M=function(a){w(d||E,function(){c.b&&(f(a),c.D(Y))})};return c},Y:function(a,b,d,c){return h.j(a,d,k,c)},ga:function(a){return a.F},N:function(a){return a.b||(a.b={})},fa:function(a){var b=a.A;b||(b=a.A= 11 | {id:a.id,uri:h.O(a),exports:h.N(a),config:function(){return a.a}},b.b=b.exports);return b},O:function(a){return a.url||(a.url=h.H(a.F.toUrl(a.id),a.a))},V:function(a){var b,d,c,e,f;b="curl";d="define";c=e=m;if(a&&(f=a.overwriteApi||a.sa,b=a.apiName||a.la||b,c=a.apiContext||a.ka||c,d=a.defineName||a.na||d,e=a.defineContext||a.ma||e,y&&u(y,"Function")&&(m.curl=y),y=null,G&&u(G,"Function")&&(m.define=G),G=null,!f)){if(c[b]&&c[b]!=A)throw Error(b+" already exists");if(e[d]&&e[d]!=R)throw Error(d+" already exists"); 12 | }c[b]=A;e[d]=R},a:function(a){function b(a,b){var d,c,g,n,q;for(q in a){g=a[q];u(g,"String")&&(g={path:a[q]});g.name=g.name||q;n=e;c=J(I(g.name));d=c.h;if(c=c.f)n=f[c],n||(n=f[c]=v(e),n.c=v(e.c),n.g=[]),delete a[q];c=g;var l=b,H=void 0;c.path=I(c.path||c.location||"");l&&(H=c.main||"./main","."==H.charAt(0)||(H="./"+H),c.R=V(H,c.name+"/"));c.a=c.config;c.a&&(c.a=v(e,c.a));c.W=d.split("/").length;d?(n.c[d]=c,n.g.push(d)):n.s=h.U(g.path,e)}}function d(a){var b=a.c;a.S=new RegExp("^("+a.g.sort(function(a, 13 | c){return b[c].W-b[a].W}).join("|").replace(/\/|\./g,"\\$&")+")(?=\\/|$)");delete a.g}var c,e,f,g;"baseUrl"in a&&(a.s=a.baseUrl);"main"in a&&(a.R=a.main);"preloads"in a&&(a.ta=a.preloads);"pluginPath"in a&&(a.T=a.pluginPath);if("dontAddFileExt"in a||a.l)a.l=new RegExp(a.dontAddFileExt||a.l);c=x;e=v(c,a);e.c=v(c.c);f=a.plugins||{};e.plugins=v(c.plugins);e.C=v(c.C,a.C);e.B=v(c.B,a.B);e.g=[];b(a.packages,!0);b(a.paths,!1);for(g in f)a=h.o(g+"!","",e),e.plugins[a.substr(0,a.length-1)]=f[g];f=e.plugins; 14 | for(g in f)if(f[g]=v(e,f[g]),a=f[g].g)f[g].g=a.concat(e.g),d(f[g]);for(g in c.c)e.c.hasOwnProperty(g)||e.g.push(g);d(e);return e},i:function(a,b){var d,c,e,f;d=b.c;e=Z.test(a)?a:a.replace(b.S,function(a){c=d[a]||{};f=c.a;return c.path||""});return{a:f||x,url:h.U(e,b)}},U:function(a,b){var d=b.s;return d&&!Z.test(a)?I(d)+"/"+a:a},H:function(a,b){return a+((b||x).l.test(a)?"":".js")},P:function(a,b,d){var c=z.createElement("script");c.onload=c.onreadystatechange=function(d){d=d||m.event;if("load"== 15 | d.type||da[c.readyState])delete N[a.id],c.onload=c.onreadystatechange=c.onerror="",b()};c.onerror=function(){d(Error("Syntax or http error: "+a.url))};c.type=a.pa||"text/javascript";c.charset="utf-8";c.async=!a.ra;c.src=a.url;N[a.id]=c;S.insertBefore(c,ca);return c},$:function(a){var b=[],d;("string"==typeof a?a:a.toSource?a.toSource():a.toString()).replace(ea,"").replace(fa,function(a,e,f,g){g?d=d==g?k:d:d||b.push(f);return""});return b},ea:function(a){var b,d,c,e,f,g;f=a.length;c=a[f-1];e=u(c,"Function")? 16 | c.length:-1;2==f?u(a[0],"Array")?d=a[0]:b=a[0]:3==f&&(b=a[0],d=a[1]);!d&&0= 0 ? id.substr(0, pos) + '/' : id; 115 | } 116 | 117 | function reduceDots (id) { 118 | // remove any dots from the inside of an id 119 | // remove path-segment/../ or /./ 120 | return id.replace(/(^|\/)[^\/\.]+\/\.\.\/|\/\.\//, '/'); 121 | } 122 | 123 | function makeRelative (url, parentUrl) { 124 | // make this url relative to a parent url 125 | return url.replace(new RegExp('^' + parentUrl), ''); 126 | } 127 | 128 | }); 129 | 130 | /* 131 | define('some/id.css', function () { 132 | return '.foo { display: none; }'; 133 | }); 134 | 135 | define('curl/plugin/css!some/id.css', ['curl/plugin/style!some/id.css', 'curl/plugin/style'], function (sheet) { 136 | return sheet; 137 | }); 138 | */ 139 | -------------------------------------------------------------------------------- /src/curl/cram/i18n.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl i18n! cram plugin 5 | */ 6 | define(function (require) { 7 | 8 | var i18n = require('../plugin/i18n'); 9 | var getLocale = require('../plugin/locale'); 10 | var _stringify = require('./_stringify'); 11 | var _define = require('./_define'); 12 | 13 | function bundleToString (thing) { 14 | return _stringify(thing); 15 | } 16 | 17 | bundleToString.compile = function (pluginId, resId, req, io, config) { 18 | var toId, i18nId, localeId, locales, output, count; 19 | 20 | toId = config['localeToModuleId'] || getLocale.toModuleId; 21 | i18nId = pluginId + '!' + resId; 22 | // toId() on localeId ensure it is output the same as other locales 23 | localeId = toId('curl/plugin/locale!' + resId, ''); 24 | locales = config.locales || []; 25 | if (locales.indexOf('') < 0) locales.push(''); // add default bundle 26 | output = []; 27 | count = locales.length; 28 | 29 | // use the load method of the run-time plugin, capturing bundles. 30 | locales.forEach(function (locale, i) { 31 | var cfg; 32 | 33 | loaded.error = stop; 34 | // inherit from config so we can extend it for this load 35 | cfg = Object.create(config); 36 | // load bundle with this locale 37 | cfg.locale = locale; 38 | i18n.load(resId, req, loaded, cfg); 39 | 40 | function loaded (bundle) { 41 | // each bundle captured is output as a locale!id module, e.g.: 42 | // define("locale!foo/en-us", function () { 43 | // return {/*...*/}; 44 | // }); 45 | output[i] = _define( 46 | toId(resId, locale), '', '', '', bundleToString(bundle) 47 | ); 48 | if (--count == 0) done(); 49 | } 50 | }); 51 | 52 | if (!locales.length) done(); 53 | 54 | function stop (ex) { 55 | io.warn(ex.message); 56 | if (--count == 0) done(); 57 | } 58 | 59 | function done () { 60 | // add the default i18n bundle module which uses the locale! 61 | // plugin to require() or fetch the correct bundle. e.g. 62 | // define("i18n!foo/en", ["locale!foo/en"], function (bundle) { 63 | // return bundle; 64 | // }); 65 | output.push(_define(i18nId, [localeId], ['bundle'], '', 'bundle')); 66 | io.write(output.join('')); 67 | } 68 | 69 | }; 70 | 71 | return bundleToString; 72 | 73 | }); 74 | -------------------------------------------------------------------------------- /src/curl/cram/js.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl js! cram plugin 5 | */ 6 | define(function (require) { 7 | 8 | var _define = require('./_define'); 9 | 10 | var stripOrderOptionRx = /!order/; 11 | 12 | return { 13 | 14 | normalize: function (resourceId, toAbsId) { 15 | // Remove !order option. It's not needed in a bundle. 16 | // !exports option must be preserved so that it will be 17 | // passed to the compile() method. 18 | return resourceId 19 | ? toAbsId(resourceId.replace(stripOrderOptionRx, '')) 20 | : resourceId; 21 | }, 22 | 23 | compile: function (pluginId, resId, req, io /*, config*/) { 24 | var absId, exportsPos, bangPos, exports, url; 25 | 26 | absId = pluginId + '!' + resId; 27 | exportsPos = resId.indexOf('!exports='); 28 | exports = exportsPos > 0 && resId.substr(exportsPos + 9); // must be last option! 29 | bangPos = resId.indexOf('!'); 30 | if (bangPos >= 0) resId = resId.slice(0, bangPos); 31 | 32 | url = req.toUrl(resId); 33 | if (url.substr(url.length - 3) !== ".js") { 34 | url += ".js"; 35 | } 36 | 37 | io.read(url, function (text) { 38 | var moduleText; 39 | 40 | moduleText = text + ';\n' 41 | + _define(absId, '', '', '', exports); 42 | 43 | io.write(moduleText); 44 | 45 | }, io.error); 46 | } 47 | 48 | }; 49 | 50 | }); 51 | -------------------------------------------------------------------------------- /src/curl/cram/jsEncode.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | define(function () { 4 | var map, encodeRx; 5 | 6 | map = { 34: '\\"', 13: '\\r', 12: '\\f', 10: '\\n', 9: '\\t', 8: '\\b' , 92: '\\\\'}; 7 | encodeRx = /["\n\f\t\r\b\\]/g; 8 | 9 | function jsEncode (text) { 10 | return text.replace(encodeRx, function (c) { 11 | return map[c.charCodeAt(0)]; 12 | }); 13 | } 14 | 15 | return jsEncode; 16 | 17 | }); 18 | -------------------------------------------------------------------------------- /src/curl/cram/json.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl json! cram plugin 5 | */ 6 | define(function (require) { 7 | 8 | var _define = require('./define'); 9 | 10 | return { 11 | 12 | compile: function (pluginId, resId, req, io, config) { 13 | var absId; 14 | 15 | absId = pluginId + '!' + resId; 16 | 17 | io.read( 18 | req.toUrl(resId), 19 | function (source) { 20 | var moduleText; 21 | if (config.strictJSONParse) { 22 | try { JSON.parse(source); } catch (ex) { io.error(ex); } 23 | } 24 | // write-out define(id,function(){return{/* json here */}}); 25 | moduleText = _define(absId, '', '', '', source); 26 | io.write(moduleText); 27 | }, 28 | io.error 29 | ); 30 | } 31 | }; 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /src/curl/cram/legacy.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl legacy cram plugin 5 | */ 6 | define(function (require) { 7 | 8 | var _stringify = require('./_stringify'); 9 | var _define = require('./_define'); 10 | 11 | return { 12 | 13 | compile: function (pluginId, resId, req, io, config) { 14 | var url, exports, requires, dontWrap; 15 | 16 | url = req.toUrl(resId); 17 | exports = config.exports; 18 | requires = config.requires; 19 | dontWrap = config.dontWrapLegacy; 20 | 21 | if (url.substr(url.length - 3) !== ".js") { 22 | url += ".js"; 23 | } 24 | 25 | io.read(url, function (text) { 26 | var moduleText; 27 | 28 | if (dontWrap) { 29 | moduleText = text + ';\n' 30 | + _define(resId, requires, '', '', exports); 31 | } 32 | else { 33 | moduleText = _define(resId, requires, '', text, exports); 34 | } 35 | 36 | io.write(moduleText); 37 | 38 | }, io.error); 39 | 40 | 41 | 42 | 43 | } 44 | }; 45 | 46 | }); 47 | -------------------------------------------------------------------------------- /src/curl/cram/text.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl text! cram plugin 5 | */ 6 | define(function (require) { 7 | 8 | var jsEncode = require('./jsEncode'); 9 | var _define = require('./_define'); 10 | 11 | return { 12 | 13 | compile: function (pluginId, resId, req, io, config) { 14 | var absId; 15 | 16 | absId = pluginId + '!' + resId; 17 | 18 | io.read(req.toUrl(resId), function (text) { 19 | io.write(_define(absId, '', '', '', '"' + jsEncode(text) + '"')); 20 | }, io.error); 21 | } 22 | 23 | }; 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /src/curl/debug.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl debug plugin 5 | * 6 | * Licensed under the MIT License at: 7 | * http://www.opensource.org/licenses/mit-license.php 8 | * 9 | */ 10 | 11 | /** 12 | * usage: 13 | * curl({ preloads: ['curl/debug'] }, ['my/app'], function (myApp) { 14 | * // do stuff while logging debug messages 15 | * }); 16 | * 17 | * TODO: warn when main module still has leading dots (normalizePackageDescriptor) 18 | * TODO: warn when a module id still has leading dots (toAbsId) 19 | * TODO: use curl/tdd/undefine module instead of quick-and-dirty method below 20 | * TODO: only add logging to some of the useful core functions 21 | * 22 | */ 23 | define(/*=='curl/debug',==*/ ['require', 'curl/_privileged'], function (require, priv) { 24 | "use strict"; 25 | 26 | var cache, totalWaiting, prevTotal, origDefine; 27 | 28 | if (typeof console == 'undefined') { 29 | throw new Error('`console` object must be defined to use debug module.'); 30 | } 31 | 32 | priv._curl['undefine'] = function (moduleId) { delete cache[moduleId]; }; 33 | 34 | cache = priv['cache']; 35 | 36 | // add logging to core functions 37 | for (var p in priv['core']) (function (name, orig) { 38 | priv['core'][name] = function () { 39 | var result; 40 | console.log('curl ' + name + ' arguments:', arguments); 41 | result = orig.apply(this, arguments); 42 | console.log('curl ' + name + ' return:', result); 43 | return result; 44 | }; 45 | }(p, priv['core'][p])); 46 | 47 | // add logging to define 48 | origDefine = priv._define; 49 | priv._define = function () { 50 | console.log('curl define:', arguments); 51 | return origDefine.apply(this, arguments); 52 | }; 53 | 54 | // log cache stats periodically 55 | totalWaiting = 0; 56 | 57 | function count () { 58 | totalWaiting = 0; 59 | for (var p in cache) { 60 | if (cache[p] instanceof priv['Promise']) totalWaiting++; 61 | } 62 | } 63 | count(); 64 | 65 | function periodicLogger () { 66 | count(); 67 | if (prevTotal != totalWaiting) { 68 | console.log('curl: ********** modules waiting: ' + totalWaiting); 69 | for (var p in cache) { 70 | if (cache[p] instanceof priv['Promise']) { 71 | console.log('curl: ********** module waiting: ' + p); 72 | } 73 | } 74 | } 75 | prevTotal = totalWaiting; 76 | setTimeout(periodicLogger, 500); 77 | } 78 | periodicLogger(); 79 | 80 | return true; 81 | 82 | }); 83 | -------------------------------------------------------------------------------- /src/curl/domReady.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl domReady 5 | * 6 | * Licensed under the MIT License at: 7 | * http://www.opensource.org/licenses/mit-license.php 8 | */ 9 | 10 | /** 11 | * usage: 12 | * require(['ModuleA', 'curl/domReady'], function (ModuleA, domReady) { 13 | * var a = new ModuleA(); 14 | * domReady(function () { 15 | * document.body.appendChild(a.domNode); 16 | * }); 17 | * }); 18 | * 19 | * also: check out curl's domReady! plugin 20 | * 21 | * HT to Bryan Forbes who wrote the initial domReady code: 22 | * http://www.reigndropsfall.net/ 23 | * 24 | */ 25 | (function (global, doc) { 26 | 27 | var 28 | readyState = 'readyState', 29 | // keep these quoted so closure compiler doesn't squash them 30 | readyStates = { 'loaded': 1, 'interactive': 1, 'complete': 1 }, 31 | callbacks = [], 32 | fixReadyState = doc && typeof doc[readyState] != "string", 33 | // IE needs this cuz it won't stop setTimeout if it's already queued up 34 | completed = false, 35 | pollerTime = 10, 36 | addEvent, 37 | remover, 38 | removers = [], 39 | pollerHandle, 40 | undef; 41 | 42 | function ready () { 43 | completed = true; 44 | clearTimeout(pollerHandle); 45 | while (remover = removers.pop()) remover(); 46 | if (fixReadyState) { 47 | doc[readyState] = "complete"; 48 | } 49 | // callback all queued callbacks 50 | var cb; 51 | while ((cb = callbacks.shift())) { 52 | cb(); 53 | } 54 | } 55 | 56 | var testEl; 57 | function isDomManipulable () { 58 | // question: implement Diego Perini's IEContentLoaded instead? 59 | // answer: The current impl seems more future-proof rather than a 60 | // non-standard method (doScroll). i don't care if the rest of the js 61 | // world is using doScroll! They can have fun repairing their libs when 62 | // the IE team removes doScroll in IE 13. :) 63 | if (!doc.body) return false; // no body? we're definitely not ready! 64 | if (!testEl) testEl = doc.createTextNode(''); 65 | try { 66 | // webkit needs to use body. doc 67 | doc.body.removeChild(doc.body.appendChild(testEl)); 68 | testEl = undef; 69 | return true; 70 | } 71 | catch (ex) { 72 | return false; 73 | } 74 | } 75 | 76 | function checkDOMReady (e) { 77 | var isReady; 78 | // all browsers except IE will be ready when readyState == 'interactive' 79 | // so we also must check for document.body 80 | isReady = readyStates[doc[readyState]] && isDomManipulable(); 81 | if (!completed && isReady) { 82 | ready(); 83 | } 84 | return isReady; 85 | } 86 | 87 | function poller () { 88 | checkDOMReady(); 89 | if (!completed) { 90 | pollerHandle = setTimeout(poller, pollerTime); 91 | } 92 | } 93 | 94 | // select the correct event listener function. all of our supported 95 | // browsers will use one of these 96 | if ('addEventListener' in global) { 97 | addEvent = function (node, event) { 98 | node.addEventListener(event, checkDOMReady, false); 99 | return function () { node.removeEventListener(event, checkDOMReady, false); }; 100 | }; 101 | } 102 | else { 103 | addEvent = function (node, event) { 104 | var onName = 'on' + event; 105 | node.attachEvent(onName, checkDOMReady); 106 | return function () { node.detachEvent(onName, checkDOMReady); }; 107 | }; 108 | } 109 | 110 | if (doc) { 111 | if (!checkDOMReady()) { 112 | // add event listeners and collect remover functions 113 | removers = [ 114 | addEvent(global, 'load'), 115 | addEvent(doc, 'readystatechange'), 116 | addEvent(global, 'DOMContentLoaded') 117 | ]; 118 | // additionally, poll for readystate 119 | pollerHandle = setTimeout(poller, pollerTime); 120 | } 121 | } 122 | 123 | define(/*=='curl/domReady',==*/ function () { 124 | 125 | // this is simply a callback, but make it look like a promise 126 | function domReady (cb) { 127 | if (completed) cb(); else callbacks.push(cb); 128 | } 129 | domReady['then'] = domReady; 130 | domReady['amd'] = true; 131 | 132 | return domReady; 133 | 134 | }); 135 | 136 | }(this, this.document)); 137 | -------------------------------------------------------------------------------- /src/curl/loader/README.md: -------------------------------------------------------------------------------- 1 | # curl.js module loaders 2 | 3 | Each of these modules may be used to load non-AMD modules without specifying 4 | an explicit plugin in your code. Here's how they work: 5 | 6 | 1. Organize your modules into packages. curl.js uses packages to organize 7 | and configure modules. Alternatively, you can use the `paths` config 8 | section to configure your packages if they have no "main" module or 9 | consist of a single file. 10 | 2. Define your packages in a config object. You can place the config object 11 | in your html file, but it's more typical to place it in a bootstrap 12 | file or module. See below for some examples. 13 | 3. Use the `loader` config option to specify which of these module loaders 14 | to use. Provide any options to the module loader alongside the `loader` 15 | config option. 16 | 17 | curl.js's module loaders are just AMD plugins. Therefore, you could 18 | conceivably use any plugin as a module loader. In practice, though, only 19 | a few plugins are useful. We like to use css! and json! plugins, for instance. 20 | 21 | # Examples 22 | 23 | Backbone as a legacy script and no residual global 'Backbone` variable: 24 | 25 | ```js 26 | curl.config({ 27 | // we're using `paths` here just as an example 28 | paths: { 29 | backbone: { 30 | location: 'modules/backbone-1.3.1/backbone.js', 31 | config: { 32 | // use the legacy loader 33 | loader: 'curl/loader/legacy', 34 | // remove Backbone global! yes! 35 | exports: 'Backbone.noConflict()', 36 | // make sure jQuery and lodash are loaded 37 | requires: ['jquery', 'lodash'] 38 | } 39 | } 40 | } 41 | }); 42 | ``` 43 | 44 | XYZ, a CommonJS package: 45 | 46 | ```js 47 | curl.config({ 48 | packages: [ 49 | { 50 | name: 'XYZ', 51 | location: 'modules/XYZ-1.3.1', 52 | // packages typically require a "main: module 53 | main: 'foo', 54 | config: { 55 | // use the CommonJS Modules/1.1 loader 56 | loader: 'curl/loader/cjsm11', 57 | // tell the loader not to inject //@sourceURL 58 | injectSourceUrl: false 59 | } 60 | } 61 | ] 62 | }); 63 | ``` 64 | 65 | A "theme" package of css stylesheets: 66 | 67 | ```js 68 | curl.config({ 69 | packages: [ 70 | { 71 | name: 'theme', 72 | location: '../themes/css', 73 | config: { 74 | // use the link plugin to load stylesheets dynamically 75 | loader: 'curl/plugin/link' 76 | } 77 | } 78 | ] 79 | }); 80 | ``` 81 | -------------------------------------------------------------------------------- /src/curl/loader/cjsm11.js: -------------------------------------------------------------------------------- 1 | /** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */ 2 | 3 | /** 4 | * curl CommonJS Modules/1.1 loader 5 | * 6 | * This loader loads modules that conform to the CommonJS Modules/1.1 spec. 7 | * The loader also accommodates node.js, which adds features beyond the 8 | * spec, such as `module.exports` and `this === exports`. 9 | * 10 | * CommonJS modules can't run in browser environments without help. This 11 | * loader wraps the modules in AMD and injects the CommonJS "free vars": 12 | * 13 | * define(function (require, exports, module) { 14 | * // CommonJS code goes here. 15 | * }); 16 | * 17 | * Config options: 18 | * 19 | * `injectSourceUrl` {boolean} If truthy (default), a //@sourceURL is injected 20 | * into the script so that debuggers may display a meaningful name in the 21 | * list of scripts. Setting this to false may save a few bytes. 22 | * 23 | * `injectScript` {boolean} If truthy, a 13 | 14 | 15 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/apiConflict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | noConflict api test 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 34 | 35 | -------------------------------------------------------------------------------- /test/apiConflict2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | noConflict api test 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 33 | 34 | -------------------------------------------------------------------------------- /test/apiName.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | apiName/apiContext curl test file 5 | 6 | 18 | 19 | 20 | 21 | 22 | 23 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/apiName2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | apiName/apiContext curl test file 5 | 6 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | main curl test file 5 | 6 | 15 | 16 | 17 | 53 | 54 | 55 | 56 | 57 |

This text should all be the same color if the css file loaded.

58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /test/cjsModules1.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CommonJS Modules 1.1 loading test 5 | 6 | 29 | 30 | 31 | 32 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test/cjsm1.1-prewrapped.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CommonJS Modules 1.1 loading test 5 | 6 | 16 | 17 | 18 | 19 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | config tests 5 | 6 | 23 | 24 | 25 | 26 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /test/cycle-correction-hybrid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | cycle correction for hybrid modules 5 | 6 | 17 | 18 | 19 | 20 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /test/data-curl-run-failover.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | data-curl-run test (with failover) 5 | 6 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/data-curl-run.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | data-curl-run test (run.js is a script) 5 | 6 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/debug.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl debug module test file 5 | 6 | 30 | 31 | 32 | 54 | 55 | 56 | 57 | 58 |

This text should all be the same color if the css file loaded.

59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test/defineAfter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | apiName/apiContext curl test file 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/defineConflict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | noConflict define test 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 73 | 74 | -------------------------------------------------------------------------------- /test/defineConflict2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | noConflict define test 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 28 | 29 | -------------------------------------------------------------------------------- /test/defineContext.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | defineName/defineContext curl test file 5 | 6 | 18 | 19 | 20 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /test/defineContext2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | defineName/defineContext curl test file (2) 5 | 6 | 7 | 8 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test/dist-jquery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test jquery convenience build 5 | 6 | 19 | 20 | 21 | 50 | 51 | 52 | 53 | 54 |

This text should all be the same color if the css file loaded.

55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/dist-kitchen-sink.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test kitchen sink convenience build 5 | 6 | 19 | 20 | 21 | 50 | 51 | 52 | 53 | 54 |

This text should all be the same color if the css file loaded.

55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/dontAddFileExt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Packages test 5 | 6 | 7 | 8 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /test/i18n.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | i18n tests 5 | 6 | 20 | 21 | 22 | 23 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /test/i18n/strings.js: -------------------------------------------------------------------------------- 1 | define({ 2 | 3 | labels: { 4 | beer: 'brew', 5 | abode: 'apartment', 6 | transport: 'bus' 7 | }, 8 | 9 | values: { 10 | date: '01/01/2010', 11 | number: 5, 12 | boolean: true, 13 | string: 'string' 14 | } 15 | 16 | }); -------------------------------------------------------------------------------- /test/i18n/strings/en-gb.js: -------------------------------------------------------------------------------- 1 | define({ 2 | 3 | labels: { 4 | beer: 'pint', 5 | abode: 'flat', 6 | transport: 'lorry' 7 | }, 8 | 9 | values: { 10 | date: '01/01/2010', 11 | number: 5, 12 | boolean: true, 13 | string: 'string' 14 | } 15 | 16 | }); -------------------------------------------------------------------------------- /test/img.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl loading test for img! plugin 5 | 6 | 17 | 18 | 19 | 20 | 56 | 57 | 58 | 59 | 60 |

We should know the dimensions of both images, and they should be hidden in the root of the body until loaded.

61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /test/img/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cujojs/curl/13170edcbeb9dc55c48ea00e5fec890eec75b59f/test/img/circle.png -------------------------------------------------------------------------------- /test/img/rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cujojs/curl/13170edcbeb9dc55c48ea00e5fec890eec75b59f/test/img/rect.png -------------------------------------------------------------------------------- /test/issue20.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test for github issue #20 5 | 6 | 26 | 27 | 28 | 29 | 30 | 50 | 51 | 52 | 53 | 54 |

You should see the word, "loaded".

55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/issue28.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test for github issue #28 5 | 6 | 7 | 8 | 9 | 10 | 64 | 65 | 66 | 67 | 68 |

Success or failure message below:

69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /test/issue34.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test for github issue #34 5 | 6 | 7 | 8 | 9 | 10 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/issue37.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test for github issue #37 5 | 6 | 7 | 8 | 9 | 10 | 41 | 42 | 43 | 44 | 45 |

Success or failure message below:

46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/issue53.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | issue 53 5 | 6 | 7 | 8 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/jquery-ready.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery $.ready() test file 5 | 6 | 16 | 17 | 18 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | -------------------------------------------------------------------------------- /test/js-load-once-issue30.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js! plugin load once 5 | 6 | 16 | 17 | 18 | 19 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /test/js-test-option-failure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js! plugin !test option 5 | 6 | 16 | 17 | 18 | 19 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/js-test-option-success.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js! plugin !test option 5 | 6 | 17 | 18 | 19 | 20 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/json.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | json! tests 5 | 6 | 19 | 20 | 21 | 22 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /test/json/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "beer": { 3 | "lager": { 4 | "Samuel Adams": [ "Boston Lager" ] 5 | }, 6 | "stout": { 7 | "North Coast": [ "Old Rasputin" ] 8 | }, 9 | "IPA": { 10 | "Stoneface": [ "Stoneface IPA" ], 11 | "Trillium": [ "Double Dry" ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/legacy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl loading test for plain old javascript 5 | 6 | 39 | 40 | 41 | 42 | 43 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /test/link-parent-path-issue108.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl loading test for <link>ed css 5 | 6 | 18 | 19 | 20 | 21 | 45 | 46 | 47 | 48 | 49 |

This text should all be the same color if the css file loaded.

50 |

If the second file loaded, these are all caps, too.

51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/link.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl loading test for <link>ed css 5 | 6 | 18 | 19 | 20 | 21 | 45 | 46 | 47 | 48 | 49 |

This text should all be the same color if the css file loaded.

50 |

If the second file loaded, these are all caps, too.

51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/local-require.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | local require tests 5 | 6 | 19 | 20 | 21 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /test/many-css-resources.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Many CSS Resources test 5 | 6 | 15 | 16 | 17 | 108 | 109 | 110 | 111 |
112 |

test element

113 |
114 |
115 | 116 | 117 | -------------------------------------------------------------------------------- /test/many-plugin-callbacks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | many curls test 5 | 6 | 15 | 16 | 17 | 36 | 37 | 38 | 39 | 40 |

This text should all be the same color if the css file loaded.

41 | 42 | 43 | -------------------------------------------------------------------------------- /test/module-returns-undefined.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | undefined module loads once 5 | 6 | 15 | 16 | 17 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /test/multiple_curl_calls.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | load module once test file 5 | 6 | 16 | 17 | 18 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /test/next.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test next() 5 | 6 | 29 | 30 | 31 | 75 | 76 | 77 | 78 | 79 |

This text should all be the same color if the css file loaded.

80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /test/package-specific-config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | package-specific config test 5 | 6 | 30 | 31 | 32 | 33 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /test/packages-as-object.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Packages as object test 5 | 6 | 21 | 22 | 23 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Packages test 5 | 6 | 15 | 16 | 17 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /test/paths.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Paths test 5 | 6 | 15 | 16 | 17 | 18 | 19 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /test/plainOldJs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | curl loading test for plain old javascript 5 | 6 | 17 | 18 | 19 | 20 | 21 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /test/plugin-errback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | plugin errback test 5 | 6 | 15 | 16 | 17 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /test/plugin-relative-ids.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | plugin relative ids test 5 | 6 | 15 | 16 | 17 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/plugin-specific-paths.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | plugin-specific-paths 5 | 6 | 33 | 34 | 35 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /test/pluginConfig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | plugin config test file 5 | 6 | 9 | 10 | 11 | 55 | 56 | 57 | 58 | 59 |

There should be text below if this page loaded.

60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /test/preload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | preloads test file 5 | 6 | 25 | 26 | 27 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test/protocol-relative-urls.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | protocol-relative-urls 5 | 6 | 30 | 31 | 32 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/relative-plugins.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | relative plugins and resources 5 | 6 | 7 | 8 | 9 | 44 | 45 | 46 | 47 | 48 |

49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /test/simple-plugin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | simple plugin test 5 | 6 | 18 | 19 | 20 | 21 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/stuff/aView/controller.js: -------------------------------------------------------------------------------- 1 | define(['text!./template.html', 'css!./css.css'], function (template, css) { 2 | return { 3 | render: function (node) { 4 | try { 5 | node.innerHTML = template; 6 | } 7 | catch (ex) { 8 | // firggin IE 9 | var div = node.ownerDocument.createElement('div'); 10 | div.innerHTML = template; 11 | while (div.firstChild) { 12 | node.appendChild(div.removeChild(div.firstChild)); 13 | } 14 | } 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /test/stuff/aView/css.css: -------------------------------------------------------------------------------- 1 | .aView { 2 | color: blue; 3 | } 4 | -------------------------------------------------------------------------------- /test/stuff/aView/template.html: -------------------------------------------------------------------------------- 1 |
this is a template
2 | -------------------------------------------------------------------------------- /test/stuff/bad-import.css: -------------------------------------------------------------------------------- 1 | @import url('nowhere.css'); 2 | -------------------------------------------------------------------------------- /test/stuff/base.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #00f; 3 | border: 1px solid #000; 4 | } 5 | 6 | #test-rules-applied { 7 | position: absolute; 8 | padding: 0; 9 | border: 0; 10 | margin: 0; 11 | height: 273px; 12 | width: 1px; 13 | } -------------------------------------------------------------------------------- /test/stuff/blank.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cujojs/curl/13170edcbeb9dc55c48ea00e5fec890eec75b59f/test/stuff/blank.css -------------------------------------------------------------------------------- /test/stuff/cascade-end.css: -------------------------------------------------------------------------------- 1 | #test-cascade { 2 | position: absolute; 3 | top: 33px; 4 | color: #face0f; 5 | } 6 | -------------------------------------------------------------------------------- /test/stuff/cascade-middle.css: -------------------------------------------------------------------------------- 1 | #test-cascade { 2 | position: absolute; 3 | top: 13px; 4 | left: 20px; 5 | color: #f0cc0f; 6 | } 7 | -------------------------------------------------------------------------------- /test/stuff/cascade-start.css: -------------------------------------------------------------------------------- 1 | #test-cascade-parent { 2 | position: relative; 3 | } 4 | 5 | #test-cascade { 6 | margin: 0; 7 | padding: 0; 8 | position: absolute; 9 | top: 3px; 10 | left: 0px; 11 | color: #b00bee; 12 | } 13 | -------------------------------------------------------------------------------- /test/stuff/css-on-cdn.js: -------------------------------------------------------------------------------- 1 | define(["css!dijit/claro/claro.css","css!dojo/dojo.css"], function (ss1, ss2) { 2 | return 1; 3 | }); 4 | -------------------------------------------------------------------------------- /test/stuff/dep-on-test1-in-define.js: -------------------------------------------------------------------------------- 1 | /* 2 | * depends on 'test1' 3 | */ 4 | define(['test1'], function (test1) { 5 | return test1; 6 | }); 7 | -------------------------------------------------------------------------------- /test/stuff/dep-on-test1.js: -------------------------------------------------------------------------------- 1 | /* 2 | * depends on 'test1' 3 | */ 4 | define(function (require) { 5 | return require('test1'); 6 | }); 7 | -------------------------------------------------------------------------------- /test/stuff/foo.defineModule.js: -------------------------------------------------------------------------------- 1 | foo.defineModule({ msg: 'this module doesn\'t use global define' }); -------------------------------------------------------------------------------- /test/stuff/increments.js: -------------------------------------------------------------------------------- 1 | var counter; 2 | define([], function () { 3 | if (typeof counter == 'undefined') counter = 0; 4 | else counter++; 5 | return counter; 6 | 7 | }); 8 | -------------------------------------------------------------------------------- /test/stuff/issue53.js: -------------------------------------------------------------------------------- 1 | define(['eaf.util', 'eaf.core'], function (util, core) { 2 | return "it works"; 3 | }); -------------------------------------------------------------------------------- /test/stuff/module-without-ext: -------------------------------------------------------------------------------- 1 | define({}); -------------------------------------------------------------------------------- /test/stuff/nls/strings.js: -------------------------------------------------------------------------------- 1 | define({ 2 | root: { 3 | hello: 'hi coderz!' 4 | } 5 | }); 6 | -------------------------------------------------------------------------------- /test/stuff/one.js: -------------------------------------------------------------------------------- 1 | /* 2 | * stuff/one 3 | */ 4 | //define(function () { 5 | // return 1; 6 | //}); 7 | define(1); 8 | -------------------------------------------------------------------------------- /test/stuff/plain_old_2.js: -------------------------------------------------------------------------------- 1 | testDomain.awesome = {}; 2 | testDomain.awesome.sauce = 'ketchup'; 3 | -------------------------------------------------------------------------------- /test/stuff/random.js: -------------------------------------------------------------------------------- 1 | window.random = Math.random(); 2 | -------------------------------------------------------------------------------- /test/stuff/run-script.js: -------------------------------------------------------------------------------- 1 | (function (curl, cb) { 2 | 3 | curl.config({ 4 | baseUrl: '', 5 | paths: { 6 | curl: '../src/curl' 7 | } 8 | }); 9 | curl(['stuff/one'], cb); 10 | 11 | }(curl, callback)); -------------------------------------------------------------------------------- /test/stuff/second.css: -------------------------------------------------------------------------------- 1 | P { 2 | text-transform: uppercase; 3 | } 4 | -------------------------------------------------------------------------------- /test/stuff/template.html: -------------------------------------------------------------------------------- 1 |

If you see this, you WIN!

2 | -------------------------------------------------------------------------------- /test/stuff/three.js: -------------------------------------------------------------------------------- 1 | /* 2 | * stuff/three depends on stuff/one and stuff/two 3 | */ 4 | define(['./one', './two', 'stuff/zero'], function (one, two) { 5 | return one + two; 6 | }); 7 | -------------------------------------------------------------------------------- /test/stuff/two.js: -------------------------------------------------------------------------------- 1 | /* 2 | * stuff/two depends on stuff/one 3 | */ 4 | define(['./one'], function (one) { 5 | return one + 1; 6 | }); 7 | -------------------------------------------------------------------------------- /test/stuff/undefined-module.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | // returns nothing 3 | }); -------------------------------------------------------------------------------- /test/stuff/wants-js-and-css.js: -------------------------------------------------------------------------------- 1 | define(["js!stuff/plain_old.js", "css!stuff/base.css"], function (plain, ss) { 2 | return "47%"; 3 | }); 4 | -------------------------------------------------------------------------------- /test/stuff/xdtext.html: -------------------------------------------------------------------------------- 1 | define("
this is a div fetched via jsonp
"); 2 | -------------------------------------------------------------------------------- /test/stuff/zero.js: -------------------------------------------------------------------------------- 1 | define('stuff/zero', function () { return 0; }); 2 | -------------------------------------------------------------------------------- /test/support/commonjs/exports.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports) { 2 | exports.testMessage = 'it works'; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/folder/deep/returnMain.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | exports.id = function () { return require('../..').id; }; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/folder/non-cjs.js: -------------------------------------------------------------------------------- 1 | define({ 2 | itWorks: 'it works' 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/folder/returnMain.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | exports.id = function () { return require('..').id; }; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/foo.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | exports.id = 'foo'; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/hybrid.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | 3 | var foo = require('./module'); 4 | exports.foo = function () { return foo; }; 5 | 6 | }); 7 | -------------------------------------------------------------------------------- /test/support/commonjs/loop/hybrid-loop1.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | 3 | // implements multiply(), but delegates add() and subtract() 4 | var loop2 = require('./hybrid-loop2'); 5 | var loop3 = require('./hybrid-loop3'); 6 | exports.multiply = function (a, b) { 7 | return a * b; 8 | }; 9 | exports.add = function (a, b) { 10 | return loop2.add(a, b); 11 | }; 12 | exports.subtract = function (a, b) { 13 | return loop3.subtract(a, b); 14 | }; 15 | 16 | }); -------------------------------------------------------------------------------- /test/support/commonjs/loop/hybrid-loop2.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | 3 | // implements add(), but delegates multiply() and subtract() 4 | var loop1 = require('./hybrid-loop1'); 5 | var loop3 = require('./hybrid-loop3'); 6 | exports.add = function (a, b) { 7 | return a + b; 8 | }; 9 | exports.multiply = function (a, b) { 10 | return loop1.multiply(a, b); 11 | } 12 | exports.subtract = function (a, b) { 13 | return loop3.subtract(a, b); 14 | } 15 | 16 | }); -------------------------------------------------------------------------------- /test/support/commonjs/loop/hybrid-loop3.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | 3 | // implements subtract(), but delegates multiply() and add() 4 | var loop1 = require('./hybrid-loop1'); 5 | var loop2 = require('./hybrid-loop2'); 6 | exports.multiply = function (a, b) { 7 | return loop1.multiply(a, b); 8 | }; 9 | exports.add = function (a, b) { 10 | return loop2.add(a, b); 11 | }; 12 | exports.subtract = function (a, b) { 13 | return a - b; 14 | }; 15 | 16 | }); -------------------------------------------------------------------------------- /test/support/commonjs/main-with-relative-dep.js: -------------------------------------------------------------------------------- 1 | define(['./relative-dep'], function (dep) { 2 | return dep; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/main.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | exports.id = module.id; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/main2.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | exports.id = module.id; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/module.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | this.testMessage = module.id; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/nakedDependentCjsm1.1.js: -------------------------------------------------------------------------------- 1 | // simple module with require() 2 | var simple = require('./nakedSimpleCjsm1.1'); 3 | exports.testMessage = simple.testMessage; 4 | exports.stuff = 'stuff'; 5 | -------------------------------------------------------------------------------- /test/support/commonjs/nakedSimpleCjsm1.1.js: -------------------------------------------------------------------------------- 1 | // simple module without require() 2 | exports.testMessage = 'test'; 3 | exports.uri = module.uri; 4 | exports.id = module.id; 5 | -------------------------------------------------------------------------------- /test/support/commonjs/named-main.js: -------------------------------------------------------------------------------- 1 | define('named/named-main', function (require, exports) { 2 | 3 | exports.name = 'named'; 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /test/support/commonjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commonjs-test", 3 | "version": "0.0.1", 4 | "description": "curl package test", 5 | "licenses": [ 6 | { 7 | "type": "MIT", 8 | "url": "http://www.opensource.org/licenses/mit-license.php" 9 | } 10 | ], 11 | "directories": { 12 | "lib": "." 13 | }, 14 | "main": "./main" 15 | } 16 | -------------------------------------------------------------------------------- /test/support/commonjs/relative-dep.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | return 'dep'; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/commonjs/return-config.js: -------------------------------------------------------------------------------- 1 | exports.config = function () { return module.config() }; -------------------------------------------------------------------------------- /test/support/commonjs/this.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | "use strict"; 3 | var messages = require('./folder/non-cjs'), 4 | mod = require('./module'); 5 | this.testMessage = messages.itWorks; 6 | this._module = module; 7 | }); 8 | -------------------------------------------------------------------------------- /test/support/fake.js: -------------------------------------------------------------------------------- 1 | // fake plugin 2 | 3 | define(function () { 4 | 5 | var plugin; 6 | 7 | plugin = { 8 | load: function (name, resolver, callback, config) { 9 | plugin.testValue = config.testValue; 10 | callback(config.testValue); 11 | } 12 | }; 13 | 14 | return plugin; 15 | 16 | }); 17 | -------------------------------------------------------------------------------- /test/support/foo-bar-define/simple.js: -------------------------------------------------------------------------------- 1 | foo.bar([], function () { 2 | 3 | return 1; 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /test/support/loop/loop-start.js: -------------------------------------------------------------------------------- 1 | define(['./loop1'], function (loop1) { 2 | return loop1; 3 | }); -------------------------------------------------------------------------------- /test/support/loop/loop1.js: -------------------------------------------------------------------------------- 1 | define(['./loop2'], function (loop2) { 2 | return loop2; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/loop/loop2.js: -------------------------------------------------------------------------------- 1 | define(['./loop3'], function (loop3) { 2 | return loop3; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/loop/loop3.js: -------------------------------------------------------------------------------- 1 | define(['./loop1'], function (loop1) { 2 | return 'this is from loop3'; 3 | }); 4 | -------------------------------------------------------------------------------- /test/support/main-plugin.js: -------------------------------------------------------------------------------- 1 | define(function(){ 2 | return { 3 | load: function (id, require, loaded, config) { 4 | // just echo config back 5 | loaded(config); 6 | } 7 | }; 8 | }); 9 | -------------------------------------------------------------------------------- /test/support/requires-fake.js: -------------------------------------------------------------------------------- 1 | define(['./fake!foo'], function (foo) { 2 | 3 | return {}; 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /test/support/simple-plugin.js: -------------------------------------------------------------------------------- 1 | define(function(){ 2 | return { 3 | load: function(id, require, loaded, config){ 4 | this.config = config; // just to test if config is passed correctly 5 | require([id], loaded); 6 | } 7 | }; 8 | }); 9 | -------------------------------------------------------------------------------- /test/tdd-runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tdd runner test 5 | 6 | 15 | 16 | 17 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /test/tdd/MethodSpy.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | 3 | function MethodSpy (method, context) { 4 | var count, orig; 5 | 6 | count = 0; 7 | orig = context[method]; 8 | 9 | context[method] = function () { 10 | count++; 11 | return orig.apply(context, arguments); 12 | }; 13 | 14 | return { 15 | calledNever: function () { return count == 0; }, 16 | calledOnce: function () { return count == 1; }, 17 | calledTwice: function () { return count == 2; }, 18 | calledMany: function (howMany) { return count == howMany; }, 19 | callCount: function () { return count; } 20 | }; 21 | } 22 | 23 | return MethodSpy; 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /test/tdd/Spy.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | 3 | function Spy () { 4 | var count, spy; 5 | 6 | count = 0; 7 | spy = function () {}; 8 | 9 | spy.calledNever = function () { return count == 0; }; 10 | spy.calledOnce = function () { return count == 1; }; 11 | spy.calledTwice = function () { return count == 2; }; 12 | spy.calledMany = function (howMany) { return count == howMany; }; 13 | spy.callCount = function () { return count; }; 14 | 15 | return spy; 16 | } 17 | 18 | return Spy; 19 | 20 | }); 21 | -------------------------------------------------------------------------------- /test/tdd/configureAsserts.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | 3 | return function configureAsserts (success, failure, name) { 4 | 5 | function doFail (msg) { 6 | failure(name + (msg ? ' - ' + msg : '')); 7 | } 8 | 9 | function doSuccess (msg) { 10 | success(name + (msg ? ' - ' + msg : '')); 11 | } 12 | 13 | function assert (val, msg) { 14 | (val === true ? doSuccess : doFail)(msg); 15 | } 16 | 17 | assert.equal = function equal (expected, val, msg) { 18 | if (val !== expected) { 19 | doFail(msg + ' (expected: ' + expected + '. got: ' + val + ')'); 20 | } 21 | else { 22 | doSuccess(msg); 23 | } 24 | }; 25 | 26 | return assert; 27 | }; 28 | 29 | }); 30 | -------------------------------------------------------------------------------- /test/then.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test then() 5 | 6 | 20 | 21 | 22 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /test/top-level-plugin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | top-level plugin test 5 | 6 | 20 | 21 | 22 | 23 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /test/undefine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | undefine test 5 | 6 | 17 | 18 | 19 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /test/underscore.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | underscore test file 5 | 6 | 18 | 19 | 20 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | --------------------------------------------------------------------------------