Skip to content

Commit 62ae44a

Browse files
committed
2.1.1 snapshot
1 parent d56a20a commit 62ae44a

File tree

1 file changed

+142
-84
lines changed

1 file changed

+142
-84
lines changed

dist/r.js

Lines changed: 142 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 2.1.0 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 2.1.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode,
23-
version = '2.1.0',
23+
version = '2.1.1',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
useLibLoaded = {},
@@ -105,7 +105,7 @@ var requirejs, require, define;
105105
}
106106

107107
/** vim: et:ts=4:sw=4:sts=4
108-
* @license RequireJS 2.1.0 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
108+
* @license RequireJS 2.1.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
109109
* Available via the MIT or new BSD license.
110110
* see: http://github.com/jrburke/requirejs for details
111111
*/
@@ -118,7 +118,7 @@ var requirejs, require, define;
118118
(function (global) {
119119
var req, s, head, baseElement, dataMain, src,
120120
interactiveScript, currentlyAddingScript, mainScript, subPath,
121-
version = '2.1.0',
121+
version = '2.1.1',
122122
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
123123
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
124124
jsSuffixRegExp = /\.js$/,
@@ -206,9 +206,6 @@ var requirejs, require, define;
206206
/**
207207
* Simple function to mix in properties from source into target,
208208
* but only if target does not already have a property of the same name.
209-
* This is not robust in IE for transferring methods that match
210-
* Object.prototype names, but the uses of mixin here seem unlikely to
211-
* trigger a problem related to that.
212209
*/
213210
function mixin(target, source, force, deepStringMixin) {
214211
if (source) {
@@ -301,7 +298,9 @@ var requirejs, require, define;
301298
baseUrl: './',
302299
paths: {},
303300
pkgs: {},
304-
shim: {}
301+
shim: {},
302+
map: {},
303+
config: {}
305304
},
306305
registry = {},
307306
undefEvents = {},
@@ -1273,6 +1272,25 @@ var requirejs, require, define;
12731272
};
12741273
}
12751274

1275+
function intakeDefines() {
1276+
var args;
1277+
1278+
//Any defined modules in the global queue, intake them now.
1279+
takeGlobalQueue();
1280+
1281+
//Make sure any remaining defQueue items get properly processed.
1282+
while (defQueue.length) {
1283+
args = defQueue.shift();
1284+
if (args[0] === null) {
1285+
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
1286+
} else {
1287+
//args are id, deps, factory. Should be normalized by the
1288+
//define() function.
1289+
callGetModule(args);
1290+
}
1291+
}
1292+
}
1293+
12761294
context = {
12771295
config: config,
12781296
contextName: contextName,
@@ -1300,20 +1318,23 @@ var requirejs, require, define;
13001318
//they are additive.
13011319
var pkgs = config.pkgs,
13021320
shim = config.shim,
1303-
paths = config.paths,
1304-
map = config.map;
1305-
1306-
//Mix in the config values, favoring the new values over
1307-
//existing ones in context.config.
1308-
mixin(config, cfg, true);
1309-
1310-
//Merge paths.
1311-
config.paths = mixin(paths, cfg.paths, true);
1321+
objs = {
1322+
paths: true,
1323+
config: true,
1324+
map: true
1325+
};
13121326

1313-
//Merge map
1314-
if (cfg.map) {
1315-
config.map = mixin(map || {}, cfg.map, true, true);
1316-
}
1327+
eachProp(cfg, function (value, prop) {
1328+
if (objs[prop]) {
1329+
if (prop === 'map') {
1330+
mixin(config[prop], value, true, true);
1331+
} else {
1332+
mixin(config[prop], value, true);
1333+
}
1334+
} else {
1335+
config[prop] = value;
1336+
}
1337+
});
13171338

13181339
//Merge shim
13191340
if (cfg.shim) {
@@ -1394,8 +1415,8 @@ var requirejs, require, define;
13941415
makeRequire: function (relMap, options) {
13951416
options = options || {};
13961417

1397-
function require(deps, callback, errback) {
1398-
var id, map, requireMod, args;
1418+
function localRequire(deps, callback, errback) {
1419+
var id, map, requireMod;
13991420

14001421
if (options.enableBuildCallback && callback && isFunction(callback)) {
14011422
callback.__requireJsBuild = true;
@@ -1434,23 +1455,15 @@ var requirejs, require, define;
14341455
return defined[id];
14351456
}
14361457

1437-
//Any defined modules in the global queue, intake them now.
1438-
takeGlobalQueue();
1439-
1440-
//Make sure any remaining defQueue items get properly processed.
1441-
while (defQueue.length) {
1442-
args = defQueue.shift();
1443-
if (args[0] === null) {
1444-
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
1445-
} else {
1446-
//args are id, deps, factory. Should be normalized by the
1447-
//define() function.
1448-
callGetModule(args);
1449-
}
1450-
}
1458+
//Grab defines waiting in the global queue.
1459+
intakeDefines();
14511460

14521461
//Mark all the dependencies as needing to be loaded.
14531462
context.nextTick(function () {
1463+
//Some defines could have been added since the
1464+
//require call, collect them.
1465+
intakeDefines();
1466+
14541467
requireMod = getModule(makeModuleMap(null, relMap));
14551468

14561469
//Store if map config should be applied to this require
@@ -1464,10 +1477,10 @@ var requirejs, require, define;
14641477
checkLoaded();
14651478
});
14661479

1467-
return require;
1480+
return localRequire;
14681481
}
14691482

1470-
mixin(require, {
1483+
mixin(localRequire, {
14711484
isBrowser: isBrowser,
14721485

14731486
/**
@@ -1500,7 +1513,7 @@ var requirejs, require, define;
15001513

15011514
//Only allow undef on top level require calls
15021515
if (!relMap) {
1503-
require.undef = function (id) {
1516+
localRequire.undef = function (id) {
15041517
//Bind any waiting define() calls to this context,
15051518
//fix for #408
15061519
takeGlobalQueue();
@@ -1525,7 +1538,7 @@ var requirejs, require, define;
15251538
};
15261539
}
15271540

1528-
return require;
1541+
return localRequire;
15291542
},
15301543

15311544
/**
@@ -2132,13 +2145,17 @@ var requirejs, require, define;
21322145
//In Node 0.7+ existsSync is on fs.
21332146
exists = fs.existsSync || path.existsSync;
21342147

2148+
function syncTick(fn) {
2149+
fn();
2150+
}
2151+
21352152
//Supply an implementation that allows synchronous get of a module.
21362153
req.get = function (context, moduleName, relModuleMap) {
21372154
if (moduleName === "require" || moduleName === "exports" || moduleName === "module") {
21382155
req.onError(new Error("Explicit require of " + moduleName + " is not allowed."));
21392156
}
21402157

2141-
var ret,
2158+
var ret, oldTick,
21422159
moduleMap = context.makeModuleMap(moduleName, relModuleMap);
21432160

21442161
//Normalize module name, if it contains . or ..
@@ -2148,14 +2165,35 @@ var requirejs, require, define;
21482165
ret = context.defined[moduleName];
21492166
} else {
21502167
if (ret === undefined) {
2151-
//Try to dynamically fetch it.
2152-
req.load(context, moduleName, moduleMap.url);
2168+
//Make sure nextTick for this type of call is sync-based.
2169+
oldTick = context.nextTick;
2170+
context.nextTick = syncTick;
2171+
try {
2172+
if (moduleMap.prefix) {
2173+
//A plugin, call requirejs to handle it. Now that
2174+
//nextTick is syncTick, the require will complete
2175+
//synchronously.
2176+
context.require([moduleMap.originalName]);
2177+
2178+
//Now that plugin is loaded, can regenerate the moduleMap
2179+
//to get the final, normalized ID.
2180+
moduleMap = context.makeModuleMap(moduleMap.originalName, relModuleMap);
2181+
2182+
//The above calls are sync, so can do the next thing safely.
2183+
ret = context.defined[moduleMap.id];
2184+
} else {
2185+
//Try to dynamically fetch it.
2186+
req.load(context, moduleName, moduleMap.url);
21532187

2154-
//Enable the module
2155-
context.enable(moduleMap, relModuleMap);
2188+
//Enable the module
2189+
context.enable(moduleMap, relModuleMap);
21562190

2157-
//The above calls are sync, so can do the next thing safely.
2158-
ret = context.defined[moduleName];
2191+
//The above calls are sync, so can do the next thing safely.
2192+
ret = context.defined[moduleName];
2193+
}
2194+
} finally {
2195+
context.nextTick = oldTick;
2196+
}
21592197
}
21602198
}
21612199

@@ -13509,13 +13547,13 @@ function (file, pragma, parse, lang, logger, commonJs) {
1350913547
oldInit = moduleProto.init,
1351013548
oldCallPlugin = moduleProto.callPlugin;
1351113549

13512-
//For build contexts, do everything sync
13513-
context.nextTick = function (fn) {
13514-
fn();
13515-
};
13516-
1351713550
//Only do this for the context used for building.
1351813551
if (name === '_') {
13552+
//For build contexts, do everything sync
13553+
context.nextTick = function (fn) {
13554+
fn();
13555+
};
13556+
1351913557
context.needFullExec = {};
1352013558
context.fullExec = {};
1352113559
context.plugins = {};
@@ -14437,8 +14475,7 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
1443714475
override = moduleIndex === 0 || moduleIndex > 0 ?
1443814476
config.modules[moduleIndex].override : null;
1443914477
if (override) {
14440-
cfg = {};
14441-
lang.mixin(cfg, config, override, true);
14478+
cfg = build.createOverrideConfig(config, override);
1444214479
} else {
1444314480
cfg = config;
1444414481
}
@@ -14550,25 +14587,27 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
1455014587
});
1455114588
}
1455214589

14553-
//Used by convertArrayToObject to convert some things from prop.name=value
14554-
//to a prop: { name: value}
14555-
build.dotProps = [
14556-
'paths.',
14557-
'wrap.',
14558-
'pragmas.',
14559-
'pragmasOnSave.',
14560-
'has.',
14561-
'hasOnSave.',
14562-
'wrap.',
14563-
'uglify.',
14564-
'closure.',
14565-
'map.'
14566-
];
14590+
build.objProps = {
14591+
paths: true,
14592+
wrap: true,
14593+
pragmas: true,
14594+
pragmasOnSave: true,
14595+
has: true,
14596+
hasOnSave: true,
14597+
uglify: true,
14598+
closure: true,
14599+
map: true
14600+
};
1456714601

1456814602
build.hasDotPropMatch = function (prop) {
14569-
return build.dotProps.some(function (dotProp) {
14570-
return prop.indexOf(dotProp) === 0;
14571-
});
14603+
var dotProp,
14604+
index = prop.indexOf('.');
14605+
14606+
if (index !== -1) {
14607+
dotProp = prop.substring(0, index);
14608+
return build.objProps.hasOwnProperty(dotProp);
14609+
}
14610+
return false;
1457214611
};
1457314612

1457414613
/**
@@ -15141,6 +15180,24 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
1514115180
return layer;
1514215181
};
1514315182

15183+
build.createOverrideConfig = function (config, override) {
15184+
var cfg = {};
15185+
15186+
lang.mixin(cfg, config, true);
15187+
lang.eachProp(override, function (value, prop) {
15188+
if (build.objProps.hasOwnProperty(prop)) {
15189+
//An object property, merge keys. Start a new object
15190+
//so that source object in config does not get modified.
15191+
cfg[prop] = {};
15192+
lang.mixin(cfg[prop], config[prop], true);
15193+
lang.mixin(cfg[prop], override[prop], true);
15194+
} else {
15195+
cfg[prop] = override[prop];
15196+
}
15197+
});
15198+
return cfg;
15199+
};
15200+
1514415201
/**
1514515202
* Uses the module build config object to create an flattened version
1514615203
* of the module, with deep dependencies included.
@@ -15156,25 +15213,26 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
1515615213
* included in the flattened module text.
1515715214
*/
1515815215
build.flattenModule = function (module, layer, config) {
15159-
15160-
//Use override settings, particularly for pragmas
15161-
//Do this before the var readings since it reads config values.
15162-
if (module.override) {
15163-
config = lang.mixin({}, config, true);
15164-
lang.mixin(config, module.override, true);
15165-
}
15166-
1516715216
var path, reqIndex, fileContents, currContents,
1516815217
i, moduleName, shim, packageConfig,
15169-
parts, builder, writeApi,
15218+
parts, builder, writeApi, tempPragmas,
15219+
namespace, namespaceWithDot, stubModulesByName,
15220+
newConfig = {},
1517015221
context = layer.context,
1517115222
buildFileContents = "",
15172-
namespace = config.namespace || '',
15173-
namespaceWithDot = namespace ? namespace + '.' : '',
15174-
stubModulesByName = (config.stubModules && config.stubModules._byName) || {},
1517515223
onLayerEnds = [],
1517615224
onLayerEndAdded = {};
1517715225

15226+
//Use override settings, particularly for pragmas
15227+
//Do this before the var readings since it reads config values.
15228+
if (module.override) {
15229+
config = build.createOverrideConfig(config, module.override);
15230+
}
15231+
15232+
namespace = config.namespace || '';
15233+
namespaceWithDot = namespace ? namespace + '.' : '';
15234+
stubModulesByName = (config.stubModules && config.stubModules._byName) || {};
15235+
1517815236
//Start build output for the module.
1517915237
buildFileContents += "\n" +
1518015238
(config.dir ? module._buildPath.replace(config.dir, "") : module._buildPath) +

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy