1
1
/**
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.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
22
22
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode,
23
- version = '2.1.0 ',
23
+ version = '2.1.1 ',
24
24
jsSuffixRegExp = /\.js$/,
25
25
commandOption = '',
26
26
useLibLoaded = {},
@@ -105,7 +105,7 @@ var requirejs, require, define;
105
105
}
106
106
107
107
/** 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.
109
109
* Available via the MIT or new BSD license.
110
110
* see: http://github.com/jrburke/requirejs for details
111
111
*/
@@ -118,7 +118,7 @@ var requirejs, require, define;
118
118
(function (global) {
119
119
var req, s, head, baseElement, dataMain, src,
120
120
interactiveScript, currentlyAddingScript, mainScript, subPath,
121
- version = '2.1.0 ',
121
+ version = '2.1.1 ',
122
122
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
123
123
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
124
124
jsSuffixRegExp = /\.js$/,
@@ -206,9 +206,6 @@ var requirejs, require, define;
206
206
/**
207
207
* Simple function to mix in properties from source into target,
208
208
* 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.
212
209
*/
213
210
function mixin(target, source, force, deepStringMixin) {
214
211
if (source) {
@@ -301,7 +298,9 @@ var requirejs, require, define;
301
298
baseUrl: './',
302
299
paths: {},
303
300
pkgs: {},
304
- shim: {}
301
+ shim: {},
302
+ map: {},
303
+ config: {}
305
304
},
306
305
registry = {},
307
306
undefEvents = {},
@@ -1273,6 +1272,25 @@ var requirejs, require, define;
1273
1272
};
1274
1273
}
1275
1274
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
+
1276
1294
context = {
1277
1295
config: config,
1278
1296
contextName: contextName,
@@ -1300,20 +1318,23 @@ var requirejs, require, define;
1300
1318
//they are additive.
1301
1319
var pkgs = config.pkgs,
1302
1320
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
+ };
1312
1326
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
+ });
1317
1338
1318
1339
//Merge shim
1319
1340
if (cfg.shim) {
@@ -1394,8 +1415,8 @@ var requirejs, require, define;
1394
1415
makeRequire: function (relMap, options) {
1395
1416
options = options || {};
1396
1417
1397
- function require (deps, callback, errback) {
1398
- var id, map, requireMod, args ;
1418
+ function localRequire (deps, callback, errback) {
1419
+ var id, map, requireMod;
1399
1420
1400
1421
if (options.enableBuildCallback && callback && isFunction(callback)) {
1401
1422
callback.__requireJsBuild = true;
@@ -1434,23 +1455,15 @@ var requirejs, require, define;
1434
1455
return defined[id];
1435
1456
}
1436
1457
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();
1451
1460
1452
1461
//Mark all the dependencies as needing to be loaded.
1453
1462
context.nextTick(function () {
1463
+ //Some defines could have been added since the
1464
+ //require call, collect them.
1465
+ intakeDefines();
1466
+
1454
1467
requireMod = getModule(makeModuleMap(null, relMap));
1455
1468
1456
1469
//Store if map config should be applied to this require
@@ -1464,10 +1477,10 @@ var requirejs, require, define;
1464
1477
checkLoaded();
1465
1478
});
1466
1479
1467
- return require ;
1480
+ return localRequire ;
1468
1481
}
1469
1482
1470
- mixin(require , {
1483
+ mixin(localRequire , {
1471
1484
isBrowser: isBrowser,
1472
1485
1473
1486
/**
@@ -1500,7 +1513,7 @@ var requirejs, require, define;
1500
1513
1501
1514
//Only allow undef on top level require calls
1502
1515
if (!relMap) {
1503
- require .undef = function (id) {
1516
+ localRequire .undef = function (id) {
1504
1517
//Bind any waiting define() calls to this context,
1505
1518
//fix for #408
1506
1519
takeGlobalQueue();
@@ -1525,7 +1538,7 @@ var requirejs, require, define;
1525
1538
};
1526
1539
}
1527
1540
1528
- return require ;
1541
+ return localRequire ;
1529
1542
},
1530
1543
1531
1544
/**
@@ -2132,13 +2145,17 @@ var requirejs, require, define;
2132
2145
//In Node 0.7+ existsSync is on fs.
2133
2146
exists = fs.existsSync || path.existsSync;
2134
2147
2148
+ function syncTick(fn) {
2149
+ fn();
2150
+ }
2151
+
2135
2152
//Supply an implementation that allows synchronous get of a module.
2136
2153
req.get = function (context, moduleName, relModuleMap) {
2137
2154
if (moduleName === "require" || moduleName === "exports" || moduleName === "module") {
2138
2155
req.onError(new Error("Explicit require of " + moduleName + " is not allowed."));
2139
2156
}
2140
2157
2141
- var ret,
2158
+ var ret, oldTick,
2142
2159
moduleMap = context.makeModuleMap(moduleName, relModuleMap);
2143
2160
2144
2161
//Normalize module name, if it contains . or ..
@@ -2148,14 +2165,35 @@ var requirejs, require, define;
2148
2165
ret = context.defined[moduleName];
2149
2166
} else {
2150
2167
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);
2153
2187
2154
- //Enable the module
2155
- context.enable(moduleMap, relModuleMap);
2188
+ //Enable the module
2189
+ context.enable(moduleMap, relModuleMap);
2156
2190
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
+ }
2159
2197
}
2160
2198
}
2161
2199
@@ -13509,13 +13547,13 @@ function (file, pragma, parse, lang, logger, commonJs) {
13509
13547
oldInit = moduleProto.init,
13510
13548
oldCallPlugin = moduleProto.callPlugin;
13511
13549
13512
- //For build contexts, do everything sync
13513
- context.nextTick = function (fn) {
13514
- fn();
13515
- };
13516
-
13517
13550
//Only do this for the context used for building.
13518
13551
if (name === '_') {
13552
+ //For build contexts, do everything sync
13553
+ context.nextTick = function (fn) {
13554
+ fn();
13555
+ };
13556
+
13519
13557
context.needFullExec = {};
13520
13558
context.fullExec = {};
13521
13559
context.plugins = {};
@@ -14437,8 +14475,7 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
14437
14475
override = moduleIndex === 0 || moduleIndex > 0 ?
14438
14476
config.modules[moduleIndex].override : null;
14439
14477
if (override) {
14440
- cfg = {};
14441
- lang.mixin(cfg, config, override, true);
14478
+ cfg = build.createOverrideConfig(config, override);
14442
14479
} else {
14443
14480
cfg = config;
14444
14481
}
@@ -14550,25 +14587,27 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
14550
14587
});
14551
14588
}
14552
14589
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
+ };
14567
14601
14568
14602
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;
14572
14611
};
14573
14612
14574
14613
/**
@@ -15141,6 +15180,24 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
15141
15180
return layer;
15142
15181
};
15143
15182
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
+
15144
15201
/**
15145
15202
* Uses the module build config object to create an flattened version
15146
15203
* of the module, with deep dependencies included.
@@ -15156,25 +15213,26 @@ define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma
15156
15213
* included in the flattened module text.
15157
15214
*/
15158
15215
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
-
15167
15216
var path, reqIndex, fileContents, currContents,
15168
15217
i, moduleName, shim, packageConfig,
15169
- parts, builder, writeApi,
15218
+ parts, builder, writeApi, tempPragmas,
15219
+ namespace, namespaceWithDot, stubModulesByName,
15220
+ newConfig = {},
15170
15221
context = layer.context,
15171
15222
buildFileContents = "",
15172
- namespace = config.namespace || '',
15173
- namespaceWithDot = namespace ? namespace + '.' : '',
15174
- stubModulesByName = (config.stubModules && config.stubModules._byName) || {},
15175
15223
onLayerEnds = [],
15176
15224
onLayerEndAdded = {};
15177
15225
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
+
15178
15236
//Start build output for the module.
15179
15237
buildFileContents += "\n" +
15180
15238
(config.dir ? module._buildPath.replace(config.dir, "") : module._buildPath) +
0 commit comments