1 /** vim: et:ts=4:sw=4:sts=4 |
1 /** vim: et:ts=4:sw=4:sts=4 |
2 * @license RequireJS 2.1.15 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. |
2 * @license RequireJS 2.1.18 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. |
3 * Available via the MIT or new BSD license. |
3 * Available via the MIT or new BSD license. |
4 * see: http://github.com/jrburke/requirejs for details |
4 * see: http://github.com/jrburke/requirejs for details |
5 */ |
5 */ |
6 //Not using strict: uneven strict support in browsers, #392, and causes |
6 //Not using strict: uneven strict support in browsers, #392, and causes |
7 //problems with requirejs.exec()/transpiler plugins that may not be strict. |
7 //problems with requirejs.exec()/transpiler plugins that may not be strict. |
10 |
10 |
11 var requirejs, require, define; |
11 var requirejs, require, define; |
12 (function (global) { |
12 (function (global) { |
13 var req, s, head, baseElement, dataMain, src, |
13 var req, s, head, baseElement, dataMain, src, |
14 interactiveScript, currentlyAddingScript, mainScript, subPath, |
14 interactiveScript, currentlyAddingScript, mainScript, subPath, |
15 version = '2.1.15', |
15 version = '2.1.18', |
16 commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, |
16 commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, |
17 cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, |
17 cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, |
18 jsSuffixRegExp = /\.js$/, |
18 jsSuffixRegExp = /\.js$/, |
19 currDirRegExp = /^\.\//, |
19 currDirRegExp = /^\.\//, |
20 op = Object.prototype, |
20 op = Object.prototype, |
242 // If at the start, or previous value is still .., |
242 // If at the start, or previous value is still .., |
243 // keep them so that when converted to a path it may |
243 // keep them so that when converted to a path it may |
244 // still work when converted to a path, even though |
244 // still work when converted to a path, even though |
245 // as an ID it is less than ideal. In larger point |
245 // as an ID it is less than ideal. In larger point |
246 // releases, may be better to just kick out an error. |
246 // releases, may be better to just kick out an error. |
247 if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') { |
247 if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') { |
248 continue; |
248 continue; |
249 } else if (i > 0) { |
249 } else if (i > 0) { |
250 ary.splice(i - 1, 2); |
250 ary.splice(i - 1, 2); |
251 i -= 2; |
251 i -= 2; |
252 } |
252 } |
1115 } |
1115 } |
1116 |
1116 |
1117 this.depCount += 1; |
1117 this.depCount += 1; |
1118 |
1118 |
1119 on(depMap, 'defined', bind(this, function (depExports) { |
1119 on(depMap, 'defined', bind(this, function (depExports) { |
|
1120 if (this.undefed) { |
|
1121 return; |
|
1122 } |
1120 this.defineDep(i, depExports); |
1123 this.defineDep(i, depExports); |
1121 this.check(); |
1124 this.check(); |
1122 })); |
1125 })); |
1123 |
1126 |
1124 if (this.errback) { |
1127 if (this.errback) { |
1125 on(depMap, 'error', bind(this, this.errback)); |
1128 on(depMap, 'error', bind(this, this.errback)); |
|
1129 } else if (this.events.error) { |
|
1130 // No direct errback on this module, but something |
|
1131 // else is listening for errors, so be sure to |
|
1132 // propagate the error correctly. |
|
1133 on(depMap, 'error', bind(this, function(err) { |
|
1134 this.emit('error', err); |
|
1135 })); |
1126 } |
1136 } |
1127 } |
1137 } |
1128 |
1138 |
1129 id = depMap.id; |
1139 id = depMap.id; |
1130 mod = registry[id]; |
1140 mod = registry[id]; |
1224 |
1234 |
1225 //Make sure any remaining defQueue items get properly processed. |
1235 //Make sure any remaining defQueue items get properly processed. |
1226 while (defQueue.length) { |
1236 while (defQueue.length) { |
1227 args = defQueue.shift(); |
1237 args = defQueue.shift(); |
1228 if (args[0] === null) { |
1238 if (args[0] === null) { |
1229 return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); |
1239 return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + |
|
1240 args[args.length - 1])); |
1230 } else { |
1241 } else { |
1231 //args are id, deps, factory. Should be normalized by the |
1242 //args are id, deps, factory. Should be normalized by the |
1232 //define() function. |
1243 //define() function. |
1233 callGetModule(args); |
1244 callGetModule(args); |
1234 } |
1245 } |
1311 //Adjust packages if necessary. |
1322 //Adjust packages if necessary. |
1312 if (cfg.packages) { |
1323 if (cfg.packages) { |
1313 each(cfg.packages, function (pkgObj) { |
1324 each(cfg.packages, function (pkgObj) { |
1314 var location, name; |
1325 var location, name; |
1315 |
1326 |
1316 pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; |
1327 pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj; |
1317 |
1328 |
1318 name = pkgObj.name; |
1329 name = pkgObj.name; |
1319 location = pkgObj.location; |
1330 location = pkgObj.location; |
1320 if (location) { |
1331 if (location) { |
1321 config.paths[name] = pkgObj.location; |
1332 config.paths[name] = pkgObj.location; |
1338 eachProp(registry, function (mod, id) { |
1349 eachProp(registry, function (mod, id) { |
1339 //If module already has init called, since it is too |
1350 //If module already has init called, since it is too |
1340 //late to modify them, and ignore unnormalized ones |
1351 //late to modify them, and ignore unnormalized ones |
1341 //since they are transient. |
1352 //since they are transient. |
1342 if (!mod.inited && !mod.map.unnormalized) { |
1353 if (!mod.inited && !mod.map.unnormalized) { |
1343 mod.map = makeModuleMap(id); |
1354 mod.map = makeModuleMap(id, null, true); |
1344 } |
1355 } |
1345 }); |
1356 }); |
1346 |
1357 |
1347 //If a deps array or a config callback is specified, then call |
1358 //If a deps array or a config callback is specified, then call |
1348 //require with those args. This is useful when require is defined as a |
1359 //require with those args. This is useful when require is defined as a |
1474 takeGlobalQueue(); |
1485 takeGlobalQueue(); |
1475 |
1486 |
1476 var map = makeModuleMap(id, relMap, true), |
1487 var map = makeModuleMap(id, relMap, true), |
1477 mod = getOwn(registry, id); |
1488 mod = getOwn(registry, id); |
1478 |
1489 |
|
1490 mod.undefed = true; |
1479 removeScript(id); |
1491 removeScript(id); |
1480 |
1492 |
1481 delete defined[id]; |
1493 delete defined[id]; |
1482 delete urlFetched[map.url]; |
1494 delete urlFetched[map.url]; |
1483 delete undefEvents[id]; |
1495 delete undefEvents[id]; |
1484 |
1496 |
1485 //Clean queued defines too. Go backwards |
1497 //Clean queued defines too. Go backwards |
1486 //in array so that the splices do not |
1498 //in array so that the splices do not |
1487 //mess up the iteration. |
1499 //mess up the iteration. |
1488 eachReverse(defQueue, function(args, i) { |
1500 eachReverse(defQueue, function(args, i) { |
1489 if(args[0] === id) { |
1501 if (args[0] === id) { |
1490 defQueue.splice(i, 1); |
1502 defQueue.splice(i, 1); |
1491 } |
1503 } |
1492 }); |
1504 }); |
1493 |
1505 |
1494 if (mod) { |
1506 if (mod) { |
1971 |
1983 |
1972 //Strip off any trailing .js since mainScript is now |
1984 //Strip off any trailing .js since mainScript is now |
1973 //like a module name. |
1985 //like a module name. |
1974 mainScript = mainScript.replace(jsSuffixRegExp, ''); |
1986 mainScript = mainScript.replace(jsSuffixRegExp, ''); |
1975 |
1987 |
1976 //If mainScript is still a path, fall back to dataMain |
1988 //If mainScript is still a path, fall back to dataMain |
1977 if (req.jsExtRegExp.test(mainScript)) { |
1989 if (req.jsExtRegExp.test(mainScript)) { |
1978 mainScript = dataMain; |
1990 mainScript = dataMain; |
1979 } |
1991 } |
1980 |
1992 |
1981 //Put the data-main script in the files to load. |
1993 //Put the data-main script in the files to load. |
2057 |
2069 |
2058 define.amd = { |
2070 define.amd = { |
2059 jQuery: true |
2071 jQuery: true |
2060 }; |
2072 }; |
2061 |
2073 |
2062 |
|
2063 /** |
2074 /** |
2064 * Executes the text. Normally just uses eval, but can be modified |
2075 * Executes the text. Normally just uses eval, but can be modified |
2065 * to use a better, environment-specific call. Only used for transpiling |
2076 * to use a better, environment-specific call. Only used for transpiling |
2066 * loader plugins, not for plain JS modules. |
2077 * loader plugins, not for plain JS modules. |
2067 * @param {String} text the text to execute/evaluate. |
2078 * @param {String} text the text to execute/evaluate. |