mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Update vendor/requirejs.
Former-commit-id: 90bd5bc12f9159b65d485c540474404a61cad7ef
This commit is contained in:
67
vendor/requirejs/require.js
vendored
67
vendor/requirejs/require.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
/** vim: et:ts=4:sw=4:sts=4
|
/** vim: et:ts=4:sw=4:sts=4
|
||||||
* @license RequireJS 2.1.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
* @license RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
||||||
* Available via the MIT or new BSD license.
|
* Available via the MIT or new BSD license.
|
||||||
* see: http://github.com/jrburke/requirejs for details
|
* see: http://github.com/jrburke/requirejs for details
|
||||||
*/
|
*/
|
||||||
@@ -12,7 +12,7 @@ var requirejs, require, define;
|
|||||||
(function (global) {
|
(function (global) {
|
||||||
var req, s, head, baseElement, dataMain, src,
|
var req, s, head, baseElement, dataMain, src,
|
||||||
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
||||||
version = '2.1.4',
|
version = '2.1.5',
|
||||||
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
||||||
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
||||||
jsSuffixRegExp = /\.js$/,
|
jsSuffixRegExp = /\.js$/,
|
||||||
@@ -191,15 +191,21 @@ var requirejs, require, define;
|
|||||||
var inCheckLoaded, Module, context, handlers,
|
var inCheckLoaded, Module, context, handlers,
|
||||||
checkLoadedTimeoutId,
|
checkLoadedTimeoutId,
|
||||||
config = {
|
config = {
|
||||||
|
//Defaults. Do not set a default for map
|
||||||
|
//config to speed up normalize(), which
|
||||||
|
//will run faster if there is no default.
|
||||||
waitSeconds: 7,
|
waitSeconds: 7,
|
||||||
baseUrl: './',
|
baseUrl: './',
|
||||||
paths: {},
|
paths: {},
|
||||||
pkgs: {},
|
pkgs: {},
|
||||||
shim: {},
|
shim: {},
|
||||||
map: {},
|
|
||||||
config: {}
|
config: {}
|
||||||
},
|
},
|
||||||
registry = {},
|
registry = {},
|
||||||
|
//registry of just enabled modules, to speed
|
||||||
|
//cycle breaking code when lots of modules
|
||||||
|
//are registered, but not activated.
|
||||||
|
enabledRegistry = {},
|
||||||
undefEvents = {},
|
undefEvents = {},
|
||||||
defQueue = [],
|
defQueue = [],
|
||||||
defined = {},
|
defined = {},
|
||||||
@@ -295,7 +301,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Apply map config if available.
|
//Apply map config if available.
|
||||||
if (applyMap && (baseParts || starMap) && map) {
|
if (applyMap && map && (baseParts || starMap)) {
|
||||||
nameParts = name.split('/');
|
nameParts = name.split('/');
|
||||||
|
|
||||||
for (i = nameParts.length; i > 0; i -= 1) {
|
for (i = nameParts.length; i > 0; i -= 1) {
|
||||||
@@ -576,6 +582,7 @@ var requirejs, require, define;
|
|||||||
function cleanRegistry(id) {
|
function cleanRegistry(id) {
|
||||||
//Clean up machinery used for waiting modules.
|
//Clean up machinery used for waiting modules.
|
||||||
delete registry[id];
|
delete registry[id];
|
||||||
|
delete enabledRegistry[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function breakCycle(mod, traced, processed) {
|
function breakCycle(mod, traced, processed) {
|
||||||
@@ -624,7 +631,7 @@ var requirejs, require, define;
|
|||||||
inCheckLoaded = true;
|
inCheckLoaded = true;
|
||||||
|
|
||||||
//Figure out the state of all the modules.
|
//Figure out the state of all the modules.
|
||||||
eachProp(registry, function (mod) {
|
eachProp(enabledRegistry, function (mod) {
|
||||||
map = mod.map;
|
map = mod.map;
|
||||||
modId = map.id;
|
modId = map.id;
|
||||||
|
|
||||||
@@ -805,7 +812,7 @@ var requirejs, require, define;
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks is the module is ready to define itself, and if so,
|
* Checks if the module is ready to define itself, and if so,
|
||||||
* define it.
|
* define it.
|
||||||
*/
|
*/
|
||||||
check: function () {
|
check: function () {
|
||||||
@@ -883,7 +890,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Clean up
|
//Clean up
|
||||||
delete registry[id];
|
cleanRegistry(id);
|
||||||
|
|
||||||
this.defined = true;
|
this.defined = true;
|
||||||
}
|
}
|
||||||
@@ -1049,6 +1056,7 @@ var requirejs, require, define;
|
|||||||
},
|
},
|
||||||
|
|
||||||
enable: function () {
|
enable: function () {
|
||||||
|
enabledRegistry[this.map.id] = this;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
|
|
||||||
//Set flag mentioning that the module is enabling,
|
//Set flag mentioning that the module is enabling,
|
||||||
@@ -1208,6 +1216,7 @@ var requirejs, require, define;
|
|||||||
Module: Module,
|
Module: Module,
|
||||||
makeModuleMap: makeModuleMap,
|
makeModuleMap: makeModuleMap,
|
||||||
nextTick: req.nextTick,
|
nextTick: req.nextTick,
|
||||||
|
onError: onError,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a configuration for the context.
|
* Set a configuration for the context.
|
||||||
@@ -1234,6 +1243,9 @@ var requirejs, require, define;
|
|||||||
eachProp(cfg, function (value, prop) {
|
eachProp(cfg, function (value, prop) {
|
||||||
if (objs[prop]) {
|
if (objs[prop]) {
|
||||||
if (prop === 'map') {
|
if (prop === 'map') {
|
||||||
|
if (!config.map) {
|
||||||
|
config.map = {};
|
||||||
|
}
|
||||||
mixin(config[prop], value, true, true);
|
mixin(config[prop], value, true, true);
|
||||||
} else {
|
} else {
|
||||||
mixin(config[prop], value, true);
|
mixin(config[prop], value, true);
|
||||||
@@ -1345,7 +1357,7 @@ var requirejs, require, define;
|
|||||||
//Synchronous access to one module. If require.get is
|
//Synchronous access to one module. If require.get is
|
||||||
//available (as in the Node adapter), prefer that.
|
//available (as in the Node adapter), prefer that.
|
||||||
if (req.get) {
|
if (req.get) {
|
||||||
return req.get(context, deps, relMap);
|
return req.get(context, deps, relMap, localRequire);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Normalize module name, if it contains . or ..
|
//Normalize module name, if it contains . or ..
|
||||||
@@ -1396,7 +1408,7 @@ var requirejs, require, define;
|
|||||||
* plain URLs like nameToUrl.
|
* plain URLs like nameToUrl.
|
||||||
*/
|
*/
|
||||||
toUrl: function (moduleNamePlusExt) {
|
toUrl: function (moduleNamePlusExt) {
|
||||||
var ext, url,
|
var ext,
|
||||||
index = moduleNamePlusExt.lastIndexOf('.'),
|
index = moduleNamePlusExt.lastIndexOf('.'),
|
||||||
segment = moduleNamePlusExt.split('/')[0],
|
segment = moduleNamePlusExt.split('/')[0],
|
||||||
isRelative = segment === '.' || segment === '..';
|
isRelative = segment === '.' || segment === '..';
|
||||||
@@ -1408,9 +1420,8 @@ var requirejs, require, define;
|
|||||||
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
|
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
url = context.nameToUrl(normalize(moduleNamePlusExt,
|
return context.nameToUrl(normalize(moduleNamePlusExt,
|
||||||
relMap && relMap.id, true), ext || '.fake');
|
relMap && relMap.id, true), ext, true);
|
||||||
return ext ? url : url.substring(0, url.length - 5);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
defined: function (id) {
|
defined: function (id) {
|
||||||
@@ -1529,7 +1540,7 @@ var requirejs, require, define;
|
|||||||
* it is assumed to have already been normalized. This is an
|
* it is assumed to have already been normalized. This is an
|
||||||
* internal API, not a public one. Use toUrl for the public API.
|
* internal API, not a public one. Use toUrl for the public API.
|
||||||
*/
|
*/
|
||||||
nameToUrl: function (moduleName, ext) {
|
nameToUrl: function (moduleName, ext, skipExt) {
|
||||||
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
|
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
|
||||||
parentPath;
|
parentPath;
|
||||||
|
|
||||||
@@ -1578,7 +1589,7 @@ var requirejs, require, define;
|
|||||||
|
|
||||||
//Join the path parts together, then figure out if baseUrl is needed.
|
//Join the path parts together, then figure out if baseUrl is needed.
|
||||||
url = syms.join('/');
|
url = syms.join('/');
|
||||||
url += (ext || (/\?/.test(url) ? '' : '.js'));
|
url += (ext || (/\?/.test(url) || skipExt ? '' : '.js'));
|
||||||
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
|
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1817,7 +1828,7 @@ var requirejs, require, define;
|
|||||||
node.attachEvent('onreadystatechange', context.onScriptLoad);
|
node.attachEvent('onreadystatechange', context.onScriptLoad);
|
||||||
//It would be great to add an error handler here to catch
|
//It would be great to add an error handler here to catch
|
||||||
//404s in IE9+. However, onreadystatechange will fire before
|
//404s in IE9+. However, onreadystatechange will fire before
|
||||||
//the error handler, so that does not help. If addEvenListener
|
//the error handler, so that does not help. If addEventListener
|
||||||
//is used, then IE will fire error before load, but we cannot
|
//is used, then IE will fire error before load, but we cannot
|
||||||
//use that pathway given the connect.microsoft.com issue
|
//use that pathway given the connect.microsoft.com issue
|
||||||
//mentioned above about not doing the 'script execute,
|
//mentioned above about not doing the 'script execute,
|
||||||
@@ -1846,16 +1857,24 @@ var requirejs, require, define;
|
|||||||
|
|
||||||
return node;
|
return node;
|
||||||
} else if (isWebWorker) {
|
} else if (isWebWorker) {
|
||||||
//In a web worker, use importScripts. This is not a very
|
try {
|
||||||
//efficient use of importScripts, importScripts will block until
|
//In a web worker, use importScripts. This is not a very
|
||||||
//its script is downloaded and evaluated. However, if web workers
|
//efficient use of importScripts, importScripts will block until
|
||||||
//are in play, the expectation that a build has been done so that
|
//its script is downloaded and evaluated. However, if web workers
|
||||||
//only one script needs to be loaded anyway. This may need to be
|
//are in play, the expectation that a build has been done so that
|
||||||
//reevaluated if other use cases become common.
|
//only one script needs to be loaded anyway. This may need to be
|
||||||
importScripts(url);
|
//reevaluated if other use cases become common.
|
||||||
|
importScripts(url);
|
||||||
|
|
||||||
//Account for anonymous modules
|
//Account for anonymous modules
|
||||||
context.completeLoad(moduleName);
|
context.completeLoad(moduleName);
|
||||||
|
} catch (e) {
|
||||||
|
context.onError(makeError('importscripts',
|
||||||
|
'importScripts failed for ' +
|
||||||
|
moduleName + ' at ' + url,
|
||||||
|
e,
|
||||||
|
[moduleName]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user