Permalink
Browse files

bump to requirejs / r.js v2.1 / almond v0.2 / coffee-script 1.3.3

  • Loading branch information...
1 parent 0722276 commit 3c28c113f7f1dcf7c6839b08b616ac5d62230c94 @tkellen committed Oct 9, 2012
Showing with 1,248 additions and 1,108 deletions.
  1. +90 −36 dist/skeleton.js
  2. +1 −1 dist/skeleton.min.js
  3. +1 −1 grunt.js
  4. +3 −3 package.json
  5. +3 −2 test/runner.html
  6. +91 −36 vendor/almond.js
  7. +2 −2 vendor/coffee-script.js
  8. +754 −639 vendor/r.js
  9. +303 −388 vendor/require.js
View
@@ -2,7 +2,7 @@
var globalDefine = global.define;
/**
- * almond 0.1.2 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
+ * almond 0.2.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/almond for details
*/
@@ -13,12 +13,12 @@
var requirejs, require, define;
(function (undef) {
- var defined = {},
+ var main, req, makeMap, handlers,
+ defined = {},
waiting = {},
config = {},
defining = {},
- aps = [].slice,
- main, req;
+ aps = [].slice;
/**
* Given a relative module name, like ./something, normalize it to
@@ -29,11 +29,11 @@ var requirejs, require, define;
* @returns {String} normalized name
*/
function normalize(name, baseName) {
- var baseParts = baseName && baseName.split("/"),
+ var nameParts, nameSegment, mapValue, foundMap,
+ foundI, foundStarMap, starI, i, j, part,
+ baseParts = baseName && baseName.split("/"),
map = config.map,
- starMap = (map && map['*']) || {},
- nameParts, nameSegment, mapValue, foundMap,
- foundI, foundStarMap, starI, i, j, part;
+ starMap = (map && map['*']) || {};
//Adjust any relative paths.
if (name && name.charAt(0) === ".") {
@@ -51,7 +51,8 @@ var requirejs, require, define;
name = baseParts.concat(name.split("/"));
//start trimDots
- for (i = 0; (part = name[i]); i++) {
+ for (i = 0; i < name.length; i += 1) {
+ part = name[i];
if (part === ".") {
name.splice(i, 1);
i -= 1;
@@ -63,7 +64,7 @@ var requirejs, require, define;
//no path mapping for a path starting with '..'.
//This can still fail, but catches the most reasonable
//uses of ..
- return true;
+ break;
} else if (i > 0) {
name.splice(i - 1, 2);
i -= 2;
@@ -159,54 +160,100 @@ var requirejs, require, define;
main.apply(undef, args);
}
- if (!defined.hasOwnProperty(name)) {
+ if (!defined.hasOwnProperty(name) && !defining.hasOwnProperty(name)) {
throw new Error('No ' + name);
}
return defined[name];
}
+ //Turns a plugin!resource to [plugin, resource]
+ //with the plugin being undefined if the name
+ //did not have a plugin prefix.
+ function splitPrefix(name) {
+ var prefix,
+ index = name ? name.indexOf('!') : -1;
+ if (index > -1) {
+ prefix = name.substring(0, index);
+ name = name.substring(index + 1, name.length);
+ }
+ return [prefix, name];
+ }
+
/**
* Makes a name map, normalizing the name, and using a plugin
* for normalization if necessary. Grabs a ref to plugin
* too, as an optimization.
*/
- function makeMap(name, relName) {
- var prefix, plugin,
- index = name.indexOf('!');
+ makeMap = function (name, relName) {
+ var plugin,
+ parts = splitPrefix(name),
+ prefix = parts[0];
- if (index !== -1) {
- prefix = normalize(name.slice(0, index), relName);
- name = name.slice(index + 1);
+ name = parts[1];
+
+ if (prefix) {
+ prefix = normalize(prefix, relName);
plugin = callDep(prefix);
+ }
- //Normalize according
+ //Normalize according
+ if (prefix) {
if (plugin && plugin.normalize) {
name = plugin.normalize(name, makeNormalize(relName));
} else {
name = normalize(name, relName);
}
} else {
name = normalize(name, relName);
+ parts = splitPrefix(name);
+ prefix = parts[0];
+ name = parts[1];
+ if (prefix) {
+ plugin = callDep(prefix);
+ }
}
//Using ridiculous property names for space reasons
return {
f: prefix ? prefix + '!' + name : name, //fullName
n: name,
+ pr: prefix,
p: plugin
};
- }
+ };
function makeConfig(name) {
return function () {
return (config && config.config && config.config[name]) || {};
};
}
+ handlers = {
+ require: function (name) {
+ return makeRequire(name);
+ },
+ exports: function (name) {
+ var e = defined[name];
+ if (typeof e !== 'undefined') {
+ return e;
+ } else {
+ return (defined[name] = {});
+ }
+ },
+ module: function (name) {
+ return {
+ id: name,
+ uri: '',
+ exports: defined[name],
+ config: makeConfig(name)
+ };
+ }
+ };
+
main = function (name, deps, callback, relName) {
- var args = [],
- usingExports,
- cjsModule, depName, ret, map, i;
+ var cjsModule, depName, ret, map, i,
+ args = [],
+ usingExports;
//Use name if no relName
relName = relName || name;
@@ -218,31 +265,28 @@ var requirejs, require, define;
//values to the callback.
//Default to [require, exports, module] if no deps
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
- for (i = 0; i < deps.length; i++) {
+ for (i = 0; i < deps.length; i += 1) {
map = makeMap(deps[i], relName);
depName = map.f;
//Fast path CommonJS standard dependencies.
if (depName === "require") {
- args[i] = makeRequire(name);
+ args[i] = handlers.require(name);
} else if (depName === "exports") {
//CommonJS module spec 1.1
- args[i] = defined[name] = {};
+ args[i] = handlers.exports(name);
usingExports = true;
} else if (depName === "module") {
//CommonJS module spec 1.1
- cjsModule = args[i] = {
- id: name,
- uri: '',
- exports: defined[name],
- config: makeConfig(name)
- };
- } else if (defined.hasOwnProperty(depName) || waiting.hasOwnProperty(depName)) {
+ cjsModule = args[i] = handlers.module(name);
+ } else if (defined.hasOwnProperty(depName) ||
+ waiting.hasOwnProperty(depName) ||
+ defining.hasOwnProperty(depName)) {
args[i] = callDep(depName);
} else if (map.p) {
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
args[i] = defined[depName];
- } else if (!defining[depName]) {
+ } else {
throw new Error(name + ' missing ' + depName);
}
}
@@ -254,7 +298,7 @@ var requirejs, require, define;
//favor that over return value and exports. After that,
//favor a non-undefined return value over exports use.
if (cjsModule && cjsModule.exports !== undef &&
- cjsModule.exports !== defined[name]) {
+ cjsModule.exports !== defined[name]) {
defined[name] = cjsModule.exports;
} else if (ret !== undef || !usingExports) {
//Use the return value from the function.
@@ -268,8 +312,12 @@ var requirejs, require, define;
}
};
- requirejs = require = req = function (deps, callback, relName, forceSync) {
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
if (typeof deps === "string") {
+ if (handlers[deps]) {
+ //callback in this case is really relName
+ return handlers[deps](callback);
+ }
//Just return the module wanted. In this scenario, the
//deps arg is the module name, and second arg (if passed)
//is just the relName.
@@ -292,6 +340,13 @@ var requirejs, require, define;
//Support require(['a'])
callback = callback || function () {};
+ //If relName is a function, it is an errback handler,
+ //so remove it.
+ if (typeof relName === 'function') {
+ relName = forceSync;
+ forceSync = alt;
+ }
+
//Simulate async callback;
if (forceSync) {
main(undef, deps, callback, relName);
@@ -331,7 +386,6 @@ var requirejs, require, define;
jQuery: true
};
}());
-
define("../vendor/almond", function(){});
define('skeleton/core',[],function() {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -26,7 +26,7 @@ module.exports = function(grunt) {
});
// Load external tasks
- grunt.loadNpmTasks('grunt-contrib');
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-jasmine-task');
// Make task shortcuts
View
@@ -30,10 +30,10 @@
"test": "grunt test"
},
"devDependencies": {
- "grunt": "~0.3.11",
- "grunt-contrib": "*",
+ "grunt": "~0.3.16",
+ "grunt-contrib-requirejs": "~0.3.2",
"grunt-jasmine-task": "*",
- "requirejs": "*",
+ "requirejs": "~2.1.0",
"coffee-script": "*",
"servedir": "*"
}
View
@@ -1,6 +1,7 @@
<!doctype html>
<html>
-<head>
+<head lang="en">
+ <meta charset="utf-8"/>
<title>Test Runner</title>
<link rel="stylesheet" type="text/css" href="../vendor/jasmine/jasmine.css">
<script src="../vendor/jasmine/jasmine.js"></script>
@@ -27,7 +28,7 @@
'spec/cs'
],
function() {
- jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
+ jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
jasmine.getEnv().execute();
});
</script>
Oops, something went wrong.

0 comments on commit 3c28c11

Please sign in to comment.