Skip to content

Commit

Permalink
Release 1.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed Jun 23, 2012
1 parent 2e1e84e commit 9e6a771
Show file tree
Hide file tree
Showing 34 changed files with 4,702 additions and 4,510 deletions.
4 changes: 2 additions & 2 deletions _base/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ define(["../has", "./config", "require", "module"], function(has, config, requir
this.revision = 0;
}
=====*/
var rev = "$Rev: 27913 $".match(/\d+/);
var rev = "$Rev: 28982 $".match(/\d+/);
dojo.version = {
major: 1, minor: 7, patch: 2, flag: "",
major: 1, minor: 7, patch: 3, flag: "",
revision: rev ? +rev[0] : NaN,
toString: function(){
var v = dojo.version;
Expand Down
95 changes: 71 additions & 24 deletions _base/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,89 @@ define(["./kernel", "../has", "require", "module", "./json", "./lang", "./array"
checkDojoRequirePlugin();
},

// checkDojoRequirePlugin inspects all of the modules demanded by a dojo/require!<module-list> dependency
// to see if they have arrived. The loader does not release *any* of these modules to be instantiated
// until *all* of these modules are on board, thereby preventing the evaluation of a module with dojo.require's
// that reference modules that are not available.
//
// The algorithm works by traversing the dependency graphs (remember, there can be cycles so they are not trees)
// of each module in the dojoRequireModuleStack array (which contains the list of modules demanded by dojo/require!).
// The moment a single module is discovered that is missing, the algorithm gives up and indicates that not all
// modules are on board. dojo/loadInit! and dojo/require! are ignored because there dependencies are inserted
// directly in dojoRequireModuleStack. For example, if "your/module" module depends on "dojo/require!my/module", then
// *both* "dojo/require!my/module" and "my/module" will be in dojoRequireModuleStack. Obviously, if "my/module"
// is on board, then "dojo/require!my/module" is also satisfied, so the algorithm doesn't check for "dojo/require!my/module".
//
// Note: inserting a dojo/require!<some-module-list> dependency in the dojoRequireModuleStack achieves nothing
// with the current algorithm; however, having such modules present makes it possible to optimize the algorithm
//
// Note: prior versions of this algorithm had an optimization that signaled loaded on dojo/require! dependencies
// individually (rather than waiting for them all to be resolved). The implementation proved problematic with cycles
// and plugins. However, it is possible to reattach that strategy in the future.

// a set from module-id to {undefined | 1 | 0}, where...
// undefined => the module has not been inspected
// 0 => the module or at least one of its dependencies has not arrived
// 1 => the module is a loadInit! or require! plugin resource, or is currently being traversed (therefore, assume
// OK until proven otherwise), or has been completely traversed and all dependencies have arrived
touched,

traverse = function(m){
if(touched[m.mid] || /loadInit\!/.test(m.mid)){
// loadInit plugin modules are dependencies of modules in dojoRequireModuleStack...
// which would cause a circular dependency chain that would never be resolved if checked here
// notice all dependencies of any particular loadInit plugin module will already
// be checked since those are pushed into dojoRequireModuleStack explicitly by the
// plugin...so if a particular loadInitPlugin module's dependencies are not really
// on board, that *will* be detected elsewhere in the traversal.
return true;
}
touched[m.mid] = 1;
if(m.injected!==arrived && !m.executed){
return false;
}
for(var deps = m.deps || [], i= 0; i<deps.length; i++){
if(!traverse(deps[i])){
return false;
for(var t, module, deps = m.deps || [], i= 0; i<deps.length; i++){
module = deps[i];
if(!(t = touched[module.mid])){
if(t===0 || !traverse(module)){
touched[m.mid] = 0;
return false;
}
}
}
return true;
},

checkDojoRequirePlugin = function(){
// initialize the touched hash with easy-to-compute values that help short circuit recursive algorithm;
// recall loadInit/require plugin modules are dependencies of modules in dojoRequireModuleStack...
// which would cause a circular dependency chain that would never be resolved if checked here
// notice all dependencies of any particular loadInit/require plugin module will already
// be checked since those are pushed into dojoRequireModuleStack explicitly by the
// plugin...so if a particular loadInitPlugin module's dependencies are not really
// on board, that *will* be detected elsewhere in the traversal.
var module, mid;
touched = {};
dojoRequireModuleStack = array.filter(dojoRequireModuleStack, function(module){
return !traverse(module);
});
if(!dojoRequireModuleStack.length){
loaderVars.holdIdle();
var oldCallbacks = dojoRequireCallbacks;
dojoRequireCallbacks = [];
array.forEach(oldCallbacks, function(cb){cb(1);});
loaderVars.releaseIdle();
for(mid in modules){
module = modules[mid];
// this could be improved by remembering the result of the regex tests
if(module.executed || module.noReqPluginCheck){
touched[mid] = 1;
}else{
if(module.noReqPluginCheck!==0){
// tag the module as either a loadInit or require plugin or not for future reference
module.noReqPluginCheck = /loadInit\!/.test(mid) || /require\!/.test(mid) ? 1 : 0;
}
if(module.noReqPluginCheck){
touched[mid] = 1;
}else if(module.injected!==arrived){
// not executed, has not arrived, and is not a loadInit or require plugin resource
touched[mid] = 0;
}// else, leave undefined and we'll traverse the dependencies
}
}

for(var t, i = 0, end = dojoRequireModuleStack.length; i<end; i++){
module = dojoRequireModuleStack[i];
if(!(t = touched[module.mid])){
if(t===0 || !traverse(module)){
return;
}
}
}
loaderVars.holdIdle();
var oldCallbacks = dojoRequireCallbacks;
dojoRequireCallbacks = [];
array.forEach(oldCallbacks, function(cb){cb(1);});
loaderVars.releaseIdle();
},

dojoLoadInitPlugin = function(mid, require, loaded){
Expand Down
8 changes: 4 additions & 4 deletions _base/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define([
return typeof XMLHttpRequest !== 'undefined';
});

if(has("dojo-xhr-factory")){
if(has("dojo-xhr-factory") && require.getXhr){
dojo._xhrObj = require.getXhr;
}else if (has("native-xhr")){
dojo._xhrObj = function(){
Expand Down Expand Up @@ -521,11 +521,11 @@ define([
if(dojo.config.debugAtAllCosts){
func.call(this);
}else{
// try{
try{
func.call(this);
/* }catch(e){
}catch(e){
dfd.errback(e);
}*/
}
}
}
}
Expand Down
90 changes: 54 additions & 36 deletions dojo.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,19 @@
return now && has(name);
};

has.add("host-node", typeof process == "object" && /node(\.exe)?$/.test(process.execPath));
has.add("host-node", userConfig.has && "host-node" in userConfig.has ?
userConfig.has["host-node"] :
(typeof process == "object" && process.versions && process.versions.node && process.versions.v8));
if(has("host-node")){
// fixup the default config for node.js environment
require("./_base/configNode.js").config(defaultConfig);
// remember node's require (with respect to baseUrl==dojo's root)
defaultConfig.loaderPatch.nodeRequire = require;
}

has.add("host-rhino", typeof load == "function" && (typeof Packages == "function" || typeof Packages == "object"));
has.add("host-rhino", userConfig.has && "host-rhino" in userConfig.has ?
userConfig.has["host-rhino"] :
(typeof load == "function" && (typeof Packages == "function" || typeof Packages == "object")));
if(has("host-rhino")){
// owing to rhino's lame feature that hides the source of the script, give the user a way to specify the baseUrl...
for(var baseUrl = userConfig.baseUrl || ".", arg, rhinoArgs = this.arguments, i = 0; i < rhinoArgs.length;){
Expand Down Expand Up @@ -304,7 +308,7 @@
//
var eval_ =
// use the function constructor so our eval is scoped close to (but not in) in the global space with minimal pollution
new Function("__text", 'return eval(__text);');
new Function('return eval(arguments[0]);');

req.eval =
function(text, hint){
Expand Down Expand Up @@ -426,14 +430,21 @@

if(has("dojo-config-api")){
var consumePendingCacheInsert = function(referenceModule){
for(var p in pendingCacheInsert){
var match = p.match(/^url\:(.+)/);
var p, item, match, now;
for(p in pendingCacheInsert){
item = pendingCacheInsert[p];
match = p.match(/^url\:(.+)/);
if(match){
cache[toUrl(match[1], referenceModule)] = pendingCacheInsert[p];
cache[toUrl(match[1], referenceModule)] = item;
}else if(p=="*now"){
now = item;
}else if(p!="*noref"){
cache[getModuleInfo(p, referenceModule).mid] = pendingCacheInsert[p];
cache[getModuleInfo(p, referenceModule).mid] = item;
}
}
if(now){
now(createRequire(referenceModule));
}
pendingCacheInsert = {};
},

Expand Down Expand Up @@ -753,6 +764,21 @@
req.undef(mid, module);
};
}
if(has("dojo-sync-loader")){
result.syncLoadNls = function(mid){
var nlsModuleInfo = getModuleInfo(mid, module),
nlsModule = modules[nlsModuleInfo.mid];
if(!nlsModule || !nlsModule.executed){
cached = cache[nlsModuleInfo.mid] || cache[nlsModuleInfo.cacheId];
if(cached){
evalModuleText(cached);
nlsModule = modules[nlsModuleInfo.mid];
}
}
return nlsModule && nlsModule.executed && nlsModule.result;
};
}

}
return result;
},
Expand Down Expand Up @@ -964,15 +990,14 @@
},

toUrl = req.toUrl = function(name, referenceModule){
// name must include a filetype; fault tolerate to allow no filetype (but things like "path/to/version2.13" will assume filetype of ".13")
var match = name.match(/(.+)(\.[^\/\.]+?)$/),
root = (match && match[1]) || name,
ext = (match && match[2]) || "",
moduleInfo = getModuleInfo(root, referenceModule),
url= moduleInfo.url;
// recall, getModuleInfo always returns a url with a ".js" suffix iff pid; therefore, we've got to trim it
url= typeof moduleInfo.pid == "string" ? url.substring(0, url.length - 3) : url;
return fixupUrl(url + ext);
var moduleInfo = getModuleInfo(name+"/x", referenceModule),
url = moduleInfo.url;
return fixupUrl(moduleInfo.pid===0 ?
// if pid===0, then name had a protocol or absolute path; either way, toUrl is the identify function in such cases
name :
// "/x.js" since getModuleInfo automatically appends ".js" and we appended "/x" to make name look likde a module id
url.substring(0, url.length-5)
);
},

nonModuleProps = {
Expand Down Expand Up @@ -1211,7 +1236,6 @@
checkComplete();
};

setRequested(module);
if(plugin.load){
plugin.load(module.prid, module.req, onLoad);
}else if(plugin.loadQ){
Expand All @@ -1221,16 +1245,9 @@
// dependencies of some other module because this may cause circles when the plugin
// loadQ is run; also, generally, we want plugins to run early since they may load
// several other modules and therefore can potentially unblock many modules
plugin.loadQ = [module];
execQ.unshift(plugin);
injectModule(plugin);

// maybe the module was cached and is now defined...
if(plugin.load){
plugin.load(module.prid, module.req, onLoad);
}else{
// nope; queue up the plugin resource to be loaded after the plugin module is loaded
plugin.loadQ = [module];
}
}
},

Expand Down Expand Up @@ -1276,6 +1293,7 @@
if(module.executed || module.injected || waiting[mid] || (module.url && ((module.pack && waiting[module.url]===module.pack) || waiting[module.url]==1))){
return;
}
setRequested(module);

if(has("dojo-combo-api")){
var viaCombo = 0;
Expand All @@ -1290,7 +1308,6 @@
viaCombo = req.combo.add(0, module.mid, module.url, req);
}
if(viaCombo){
setRequested(module);
comboPending= 1;
return;
}
Expand All @@ -1301,7 +1318,6 @@
return;
} // else a normal module (not a plugin)

setRequested(module);

var onLoadCallback = function(){
runDefQ(module);
Expand Down Expand Up @@ -1467,7 +1483,6 @@
runDefQ = function(referenceModule, mids){
// defQ is an array of [id, dependencies, factory]
// mids (if any) is a vector of mids given by a combo service
consumePendingCacheInsert(referenceModule);
var definedModules = [],
module, args;
while(defQ.length){
Expand All @@ -1476,10 +1491,13 @@
// explicit define indicates possible multiple modules in a single file; delay injecting dependencies until defQ fully
// processed since modules earlier in the queue depend on already-arrived modules that are later in the queue
// TODO: what if no args[0] and no referenceModule
module = args[0] && getModule(args[0]) || referenceModule;
definedModules.push(defineModule(module, args[1], args[2]));
module = (args[0] && getModule(args[0])) || referenceModule;
definedModules.push([module, args[1], args[2]]);
}
forEach(definedModules, injectDependencies);
consumePendingCacheInsert(referenceModule);
forEach(definedModules, function(args){
injectDependencies(defineModule.apply(null, args));
});
};
}

Expand Down Expand Up @@ -1634,10 +1652,10 @@
if(arity == 1 && isFunction(mid)){
dependencies = [];
mid.toString()
.replace(/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg, "")
.replace(/require\(["']([\w\!\-_\.\/]+)["']\)/g, function (match, dep){
.replace(/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg, "")
.replace(/require\(["']([\w\!\-_\.\/]+)["']\)/g, function (match, dep){
dependencies.push(dep);
});
});
args = [0, defaultDeps.concat(dependencies), mid];
}
}
Expand Down Expand Up @@ -1776,8 +1794,8 @@
}

if(has("dojo-config-api")){
var bootDeps = defaultConfig.deps || userConfig.deps || dojoSniffConfig.deps,
bootCallback = defaultConfig.callback || userConfig.callback || dojoSniffConfig.callback;
var bootDeps = dojoSniffConfig.deps || userConfig.deps || defaultConfig.deps,
bootCallback = dojoSniffConfig.callback || userConfig.callback || defaultConfig.callback;
req.boot = (bootDeps || bootCallback) ? [bootDeps || [], bootCallback] : 0;
}
if(!has("dojo-built")){
Expand Down
Loading

0 comments on commit 9e6a771

Please sign in to comment.