require.js 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146
  1. /** vim: et:ts=4:sw=4:sts=4
  2. * @license RequireJS 2.3.7 Copyright jQuery Foundation and other contributors.
  3. * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
  4. */
  5. //Not using strict: uneven strict support in browsers, #392, and causes
  6. //problems with requirejs.exec()/transpiler plugins that may not be strict.
  7. /*jslint regexp: true, nomen: true, sloppy: true */
  8. /*global window, navigator, document, importScripts, setTimeout, opera */
  9. var requirejs, require, define;
  10. (function (global, setTimeout) {
  11. var req, s, head, baseElement, dataMain, src,
  12. interactiveScript, currentlyAddingScript, mainScript, subPath,
  13. version = '2.3.7',
  14. commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg,
  15. cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
  16. jsSuffixRegExp = /\.js$/,
  17. currDirRegExp = /^\.\//,
  18. op = Object.prototype,
  19. ostring = op.toString,
  20. hasOwn = op.hasOwnProperty,
  21. isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
  22. isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
  23. //PS3 indicates loaded and complete, but need to wait for complete
  24. //specifically. Sequence is 'loading', 'loaded', execution,
  25. // then 'complete'. The UA check is unfortunate, but not sure how
  26. //to feature test w/o causing perf issues.
  27. readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
  28. /^complete$/ : /^(complete|loaded)$/,
  29. defContextName = '_',
  30. //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
  31. isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
  32. contexts = {},
  33. cfg = {},
  34. globalDefQueue = [],
  35. useInteractive = false,
  36. disallowedProps = ['__proto__', 'constructor'];
  37. //Could match something like ')//comment', do not lose the prefix to comment.
  38. function commentReplace(match, singlePrefix) {
  39. return singlePrefix || '';
  40. }
  41. function isFunction(it) {
  42. return ostring.call(it) === '[object Function]';
  43. }
  44. function isArray(it) {
  45. return ostring.call(it) === '[object Array]';
  46. }
  47. /**
  48. * Helper function for iterating over an array. If the func returns
  49. * a true value, it will break out of the loop.
  50. */
  51. function each(ary, func) {
  52. if (ary) {
  53. var i;
  54. for (i = 0; i < ary.length; i += 1) {
  55. if (ary[i] && func(ary[i], i, ary)) {
  56. break;
  57. }
  58. }
  59. }
  60. }
  61. /**
  62. * Helper function for iterating over an array backwards. If the func
  63. * returns a true value, it will break out of the loop.
  64. */
  65. function eachReverse(ary, func) {
  66. if (ary) {
  67. var i;
  68. for (i = ary.length - 1; i > -1; i -= 1) {
  69. if (ary[i] && func(ary[i], i, ary)) {
  70. break;
  71. }
  72. }
  73. }
  74. }
  75. function hasProp(obj, prop) {
  76. return hasOwn.call(obj, prop);
  77. }
  78. function getOwn(obj, prop) {
  79. return hasProp(obj, prop) && obj[prop];
  80. }
  81. /**
  82. * Cycles over properties in an object and calls a function for each
  83. * property value. If the function returns a truthy value, then the
  84. * iteration is stopped.
  85. */
  86. function eachProp(obj, func) {
  87. var prop;
  88. for (prop in obj) {
  89. if (hasProp(obj, prop) && disallowedProps.indexOf(prop) == -1) {
  90. if (func(obj[prop], prop)) {
  91. break;
  92. }
  93. }
  94. }
  95. }
  96. /**
  97. * Simple function to mix in properties from source into target,
  98. * but only if target does not already have a property of the same name.
  99. */
  100. function mixin(target, source, force, deepStringMixin) {
  101. if (source) {
  102. eachProp(source, function (value, prop) {
  103. if (force || !hasProp(target, prop)) {
  104. if (deepStringMixin && typeof value === 'object' && value &&
  105. !isArray(value) && !isFunction(value) &&
  106. !(value instanceof RegExp)) {
  107. if (!target[prop]) {
  108. target[prop] = {};
  109. }
  110. mixin(target[prop], value, force, deepStringMixin);
  111. } else {
  112. target[prop] = value;
  113. }
  114. }
  115. });
  116. }
  117. return target;
  118. }
  119. //Similar to Function.prototype.bind, but the 'this' object is specified
  120. //first, since it is easier to read/figure out what 'this' will be.
  121. function bind(obj, fn) {
  122. return function () {
  123. return fn.apply(obj, arguments);
  124. };
  125. }
  126. function scripts() {
  127. return document.getElementsByTagName('script');
  128. }
  129. function defaultOnError(err) {
  130. throw err;
  131. }
  132. //Allow getting a global that is expressed in
  133. //dot notation, like 'a.b.c'.
  134. function getGlobal(value) {
  135. if (!value) {
  136. return value;
  137. }
  138. var g = global;
  139. each(value.split('.'), function (part) {
  140. g = g[part];
  141. });
  142. return g;
  143. }
  144. /**
  145. * Constructs an error with a pointer to an URL with more information.
  146. * @param {String} id the error ID that maps to an ID on a web page.
  147. * @param {String} message human readable error.
  148. * @param {Error} [err] the original error, if there is one.
  149. *
  150. * @returns {Error}
  151. */
  152. function makeError(id, msg, err, requireModules) {
  153. var e = new Error(msg + '\nhttps://requirejs.org/docs/errors.html#' + id);
  154. e.requireType = id;
  155. e.requireModules = requireModules;
  156. if (err) {
  157. e.originalError = err;
  158. }
  159. return e;
  160. }
  161. if (typeof define !== 'undefined') {
  162. //If a define is already in play via another AMD loader,
  163. //do not overwrite.
  164. return;
  165. }
  166. if (typeof requirejs !== 'undefined') {
  167. if (isFunction(requirejs)) {
  168. //Do not overwrite an existing requirejs instance.
  169. return;
  170. }
  171. cfg = requirejs;
  172. requirejs = undefined;
  173. }
  174. //Allow for a require config object
  175. if (typeof require !== 'undefined' && !isFunction(require)) {
  176. //assume it is a config object.
  177. cfg = require;
  178. require = undefined;
  179. }
  180. function newContext(contextName) {
  181. var inCheckLoaded, Module, context, handlers,
  182. checkLoadedTimeoutId,
  183. config = {
  184. //Defaults. Do not set a default for map
  185. //config to speed up normalize(), which
  186. //will run faster if there is no default.
  187. waitSeconds: 7,
  188. baseUrl: './',
  189. paths: {},
  190. bundles: {},
  191. pkgs: {},
  192. shim: {},
  193. config: {}
  194. },
  195. registry = {},
  196. //registry of just enabled modules, to speed
  197. //cycle breaking code when lots of modules
  198. //are registered, but not activated.
  199. enabledRegistry = {},
  200. undefEvents = {},
  201. defQueue = [],
  202. defined = {},
  203. urlFetched = {},
  204. bundlesMap = {},
  205. requireCounter = 1,
  206. unnormalizedCounter = 1;
  207. /**
  208. * Trims the . and .. from an array of path segments.
  209. * It will keep a leading path segment if a .. will become
  210. * the first path segment, to help with module name lookups,
  211. * which act like paths, but can be remapped. But the end result,
  212. * all paths that use this function should look normalized.
  213. * NOTE: this method MODIFIES the input array.
  214. * @param {Array} ary the array of path segments.
  215. */
  216. function trimDots(ary) {
  217. var i, part;
  218. for (i = 0; i < ary.length; i++) {
  219. part = ary[i];
  220. if (part === '.') {
  221. ary.splice(i, 1);
  222. i -= 1;
  223. } else if (part === '..') {
  224. // If at the start, or previous value is still ..,
  225. // keep them so that when converted to a path it may
  226. // still work when converted to a path, even though
  227. // as an ID it is less than ideal. In larger point
  228. // releases, may be better to just kick out an error.
  229. if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
  230. continue;
  231. } else if (i > 0) {
  232. ary.splice(i - 1, 2);
  233. i -= 2;
  234. }
  235. }
  236. }
  237. }
  238. /**
  239. * Given a relative module name, like ./something, normalize it to
  240. * a real name that can be mapped to a path.
  241. * @param {String} name the relative name
  242. * @param {String} baseName a real name that the name arg is relative
  243. * to.
  244. * @param {Boolean} applyMap apply the map config to the value. Should
  245. * only be done if this normalization is for a dependency ID.
  246. * @returns {String} normalized name
  247. */
  248. function normalize(name, baseName, applyMap) {
  249. var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
  250. foundMap, foundI, foundStarMap, starI, normalizedBaseParts,
  251. baseParts = (baseName && baseName.split('/')),
  252. map = config.map,
  253. starMap = map && map['*'];
  254. //Adjust any relative paths.
  255. if (name) {
  256. name = name.split('/');
  257. lastIndex = name.length - 1;
  258. // If wanting node ID compatibility, strip .js from end
  259. // of IDs. Have to do this here, and not in nameToUrl
  260. // because node allows either .js or non .js to map
  261. // to same file.
  262. if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
  263. name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
  264. }
  265. // Starts with a '.' so need the baseName
  266. if (name[0].charAt(0) === '.' && baseParts) {
  267. //Convert baseName to array, and lop off the last part,
  268. //so that . matches that 'directory' and not name of the baseName's
  269. //module. For instance, baseName of 'one/two/three', maps to
  270. //'one/two/three.js', but we want the directory, 'one/two' for
  271. //this normalization.
  272. normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
  273. name = normalizedBaseParts.concat(name);
  274. }
  275. trimDots(name);
  276. name = name.join('/');
  277. }
  278. //Apply map config if available.
  279. if (applyMap && map && (baseParts || starMap)) {
  280. nameParts = name.split('/');
  281. outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
  282. nameSegment = nameParts.slice(0, i).join('/');
  283. if (baseParts) {
  284. //Find the longest baseName segment match in the config.
  285. //So, do joins on the biggest to smallest lengths of baseParts.
  286. for (j = baseParts.length; j > 0; j -= 1) {
  287. mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
  288. //baseName segment has config, find if it has one for
  289. //this name.
  290. if (mapValue) {
  291. mapValue = getOwn(mapValue, nameSegment);
  292. if (mapValue) {
  293. //Match, update name to the new value.
  294. foundMap = mapValue;
  295. foundI = i;
  296. break outerLoop;
  297. }
  298. }
  299. }
  300. }
  301. //Check for a star map match, but just hold on to it,
  302. //if there is a shorter segment match later in a matching
  303. //config, then favor over this star map.
  304. if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
  305. foundStarMap = getOwn(starMap, nameSegment);
  306. starI = i;
  307. }
  308. }
  309. if (!foundMap && foundStarMap) {
  310. foundMap = foundStarMap;
  311. foundI = starI;
  312. }
  313. if (foundMap) {
  314. nameParts.splice(0, foundI, foundMap);
  315. name = nameParts.join('/');
  316. }
  317. }
  318. // If the name points to a package's name, use
  319. // the package main instead.
  320. pkgMain = getOwn(config.pkgs, name);
  321. return pkgMain ? pkgMain : name;
  322. }
  323. function removeScript(name) {
  324. if (isBrowser) {
  325. each(scripts(), function (scriptNode) {
  326. if (scriptNode.getAttribute('data-requiremodule') === name &&
  327. scriptNode.getAttribute('data-requirecontext') === context.contextName) {
  328. scriptNode.parentNode.removeChild(scriptNode);
  329. return true;
  330. }
  331. });
  332. }
  333. }
  334. function hasPathFallback(id) {
  335. var pathConfig = getOwn(config.paths, id);
  336. if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
  337. //Pop off the first array value, since it failed, and
  338. //retry
  339. pathConfig.shift();
  340. context.require.undef(id);
  341. //Custom require that does not do map translation, since
  342. //ID is "absolute", already mapped/resolved.
  343. context.makeRequire(null, {
  344. skipMap: true
  345. })([id]);
  346. return true;
  347. }
  348. }
  349. //Turns a plugin!resource to [plugin, resource]
  350. //with the plugin being undefined if the name
  351. //did not have a plugin prefix.
  352. function splitPrefix(name) {
  353. var prefix,
  354. index = name ? name.indexOf('!') : -1;
  355. if (index > -1) {
  356. prefix = name.substring(0, index);
  357. name = name.substring(index + 1, name.length);
  358. }
  359. return [prefix, name];
  360. }
  361. /**
  362. * Creates a module mapping that includes plugin prefix, module
  363. * name, and path. If parentModuleMap is provided it will
  364. * also normalize the name via require.normalize()
  365. *
  366. * @param {String} name the module name
  367. * @param {String} [parentModuleMap] parent module map
  368. * for the module name, used to resolve relative names.
  369. * @param {Boolean} isNormalized: is the ID already normalized.
  370. * This is true if this call is done for a define() module ID.
  371. * @param {Boolean} applyMap: apply the map config to the ID.
  372. * Should only be true if this map is for a dependency.
  373. *
  374. * @returns {Object}
  375. */
  376. function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
  377. var url, pluginModule, suffix, nameParts,
  378. prefix = null,
  379. parentName = parentModuleMap ? parentModuleMap.name : null,
  380. originalName = name,
  381. isDefine = true,
  382. normalizedName = '';
  383. //If no name, then it means it is a require call, generate an
  384. //internal name.
  385. if (!name) {
  386. isDefine = false;
  387. name = '_@r' + (requireCounter += 1);
  388. }
  389. nameParts = splitPrefix(name);
  390. prefix = nameParts[0];
  391. name = nameParts[1];
  392. if (prefix) {
  393. prefix = normalize(prefix, parentName, applyMap);
  394. pluginModule = getOwn(defined, prefix);
  395. }
  396. //Account for relative paths if there is a base name.
  397. if (name) {
  398. if (prefix) {
  399. if (isNormalized) {
  400. normalizedName = name;
  401. } else if (pluginModule && pluginModule.normalize) {
  402. //Plugin is loaded, use its normalize method.
  403. normalizedName = pluginModule.normalize(name, function (name) {
  404. return normalize(name, parentName, applyMap);
  405. });
  406. } else {
  407. // If nested plugin references, then do not try to
  408. // normalize, as it will not normalize correctly. This
  409. // places a restriction on resourceIds, and the longer
  410. // term solution is not to normalize until plugins are
  411. // loaded and all normalizations to allow for async
  412. // loading of a loader plugin. But for now, fixes the
  413. // common uses. Details in #1131
  414. normalizedName = name.indexOf('!') === -1 ?
  415. normalize(name, parentName, applyMap) :
  416. name;
  417. }
  418. } else {
  419. //A regular module.
  420. normalizedName = normalize(name, parentName, applyMap);
  421. //Normalized name may be a plugin ID due to map config
  422. //application in normalize. The map config values must
  423. //already be normalized, so do not need to redo that part.
  424. nameParts = splitPrefix(normalizedName);
  425. prefix = nameParts[0];
  426. normalizedName = nameParts[1];
  427. isNormalized = true;
  428. url = context.nameToUrl(normalizedName);
  429. }
  430. }
  431. //If the id is a plugin id that cannot be determined if it needs
  432. //normalization, stamp it with a unique ID so two matching relative
  433. //ids that may conflict can be separate.
  434. suffix = prefix && !pluginModule && !isNormalized ?
  435. '_unnormalized' + (unnormalizedCounter += 1) :
  436. '';
  437. return {
  438. prefix: prefix,
  439. name: normalizedName,
  440. parentMap: parentModuleMap,
  441. unnormalized: !!suffix,
  442. url: url,
  443. originalName: originalName,
  444. isDefine: isDefine,
  445. id: (prefix ?
  446. prefix + '!' + normalizedName :
  447. normalizedName) + suffix
  448. };
  449. }
  450. function getModule(depMap) {
  451. var id = depMap.id,
  452. mod = getOwn(registry, id);
  453. if (!mod) {
  454. mod = registry[id] = new context.Module(depMap);
  455. }
  456. return mod;
  457. }
  458. function on(depMap, name, fn) {
  459. var id = depMap.id,
  460. mod = getOwn(registry, id);
  461. if (hasProp(defined, id) &&
  462. (!mod || mod.defineEmitComplete)) {
  463. if (name === 'defined') {
  464. fn(defined[id]);
  465. }
  466. } else {
  467. mod = getModule(depMap);
  468. if (mod.error && name === 'error') {
  469. fn(mod.error);
  470. } else {
  471. mod.on(name, fn);
  472. }
  473. }
  474. }
  475. function onError(err, errback) {
  476. var ids = err.requireModules,
  477. notified = false;
  478. if (errback) {
  479. errback(err);
  480. } else {
  481. each(ids, function (id) {
  482. var mod = getOwn(registry, id);
  483. if (mod) {
  484. //Set error on module, so it skips timeout checks.
  485. mod.error = err;
  486. if (mod.events.error) {
  487. notified = true;
  488. mod.emit('error', err);
  489. }
  490. }
  491. });
  492. if (!notified) {
  493. req.onError(err);
  494. }
  495. }
  496. }
  497. /**
  498. * Internal method to transfer globalQueue items to this context's
  499. * defQueue.
  500. */
  501. function takeGlobalQueue() {
  502. //Push all the globalDefQueue items into the context's defQueue
  503. if (globalDefQueue.length) {
  504. each(globalDefQueue, function(queueItem) {
  505. var id = queueItem[0];
  506. if (typeof id === 'string') {
  507. context.defQueueMap[id] = true;
  508. }
  509. defQueue.push(queueItem);
  510. });
  511. globalDefQueue = [];
  512. }
  513. }
  514. handlers = {
  515. 'require': function (mod) {
  516. if (mod.require) {
  517. return mod.require;
  518. } else {
  519. return (mod.require = context.makeRequire(mod.map));
  520. }
  521. },
  522. 'exports': function (mod) {
  523. mod.usingExports = true;
  524. if (mod.map.isDefine) {
  525. if (mod.exports) {
  526. return (defined[mod.map.id] = mod.exports);
  527. } else {
  528. return (mod.exports = defined[mod.map.id] = {});
  529. }
  530. }
  531. },
  532. 'module': function (mod) {
  533. if (mod.module) {
  534. return mod.module;
  535. } else {
  536. return (mod.module = {
  537. id: mod.map.id,
  538. uri: mod.map.url,
  539. config: function () {
  540. return getOwn(config.config, mod.map.id) || {};
  541. },
  542. exports: mod.exports || (mod.exports = {})
  543. });
  544. }
  545. }
  546. };
  547. function cleanRegistry(id) {
  548. //Clean up machinery used for waiting modules.
  549. delete registry[id];
  550. delete enabledRegistry[id];
  551. }
  552. function breakCycle(mod, traced, processed) {
  553. var id = mod.map.id;
  554. if (mod.error) {
  555. mod.emit('error', mod.error);
  556. } else {
  557. traced[id] = true;
  558. each(mod.depMaps, function (depMap, i) {
  559. var depId = depMap.id,
  560. dep = getOwn(registry, depId);
  561. //Only force things that have not completed
  562. //being defined, so still in the registry,
  563. //and only if it has not been matched up
  564. //in the module already.
  565. if (dep && !mod.depMatched[i] && !processed[depId]) {
  566. if (getOwn(traced, depId)) {
  567. mod.defineDep(i, defined[depId]);
  568. mod.check(); //pass false?
  569. } else {
  570. breakCycle(dep, traced, processed);
  571. }
  572. }
  573. });
  574. processed[id] = true;
  575. }
  576. }
  577. function checkLoaded() {
  578. var err, usingPathFallback,
  579. waitInterval = config.waitSeconds * 1000,
  580. //It is possible to disable the wait interval by using waitSeconds of 0.
  581. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
  582. noLoads = [],
  583. reqCalls = [],
  584. stillLoading = false,
  585. needCycleCheck = true;
  586. //Do not bother if this call was a result of a cycle break.
  587. if (inCheckLoaded) {
  588. return;
  589. }
  590. inCheckLoaded = true;
  591. //Figure out the state of all the modules.
  592. eachProp(enabledRegistry, function (mod) {
  593. var map = mod.map,
  594. modId = map.id;
  595. //Skip things that are not enabled or in error state.
  596. if (!mod.enabled) {
  597. return;
  598. }
  599. if (!map.isDefine) {
  600. reqCalls.push(mod);
  601. }
  602. if (!mod.error) {
  603. //If the module should be executed, and it has not
  604. //been inited and time is up, remember it.
  605. if (!mod.inited && expired) {
  606. if (hasPathFallback(modId)) {
  607. usingPathFallback = true;
  608. stillLoading = true;
  609. } else {
  610. noLoads.push(modId);
  611. removeScript(modId);
  612. }
  613. } else if (!mod.inited && mod.fetched && map.isDefine) {
  614. stillLoading = true;
  615. if (!map.prefix) {
  616. //No reason to keep looking for unfinished
  617. //loading. If the only stillLoading is a
  618. //plugin resource though, keep going,
  619. //because it may be that a plugin resource
  620. //is waiting on a non-plugin cycle.
  621. return (needCycleCheck = false);
  622. }
  623. }
  624. }
  625. });
  626. if (expired && noLoads.length) {
  627. //If wait time expired, throw error of unloaded modules.
  628. err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
  629. err.contextName = context.contextName;
  630. return onError(err);
  631. }
  632. //Not expired, check for a cycle.
  633. if (needCycleCheck) {
  634. each(reqCalls, function (mod) {
  635. breakCycle(mod, {}, {});
  636. });
  637. }
  638. //If still waiting on loads, and the waiting load is something
  639. //other than a plugin resource, or there are still outstanding
  640. //scripts, then just try back later.
  641. if ((!expired || usingPathFallback) && stillLoading) {
  642. //Something is still waiting to load. Wait for it, but only
  643. //if a timeout is not already in effect.
  644. if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
  645. checkLoadedTimeoutId = setTimeout(function () {
  646. checkLoadedTimeoutId = 0;
  647. checkLoaded();
  648. }, 50);
  649. }
  650. }
  651. inCheckLoaded = false;
  652. }
  653. Module = function (map) {
  654. this.events = getOwn(undefEvents, map.id) || {};
  655. this.map = map;
  656. this.shim = getOwn(config.shim, map.id);
  657. this.depExports = [];
  658. this.depMaps = [];
  659. this.depMatched = [];
  660. this.pluginMaps = {};
  661. this.depCount = 0;
  662. /* this.exports this.factory
  663. this.depMaps = [],
  664. this.enabled, this.fetched
  665. */
  666. };
  667. Module.prototype = {
  668. init: function (depMaps, factory, errback, options) {
  669. options = options || {};
  670. //Do not do more inits if already done. Can happen if there
  671. //are multiple define calls for the same module. That is not
  672. //a normal, common case, but it is also not unexpected.
  673. if (this.inited) {
  674. return;
  675. }
  676. this.factory = factory;
  677. if (errback) {
  678. //Register for errors on this module.
  679. this.on('error', errback);
  680. } else if (this.events.error) {
  681. //If no errback already, but there are error listeners
  682. //on this module, set up an errback to pass to the deps.
  683. errback = bind(this, function (err) {
  684. this.emit('error', err);
  685. });
  686. }
  687. //Do a copy of the dependency array, so that
  688. //source inputs are not modified. For example
  689. //"shim" deps are passed in here directly, and
  690. //doing a direct modification of the depMaps array
  691. //would affect that config.
  692. this.depMaps = depMaps && depMaps.slice(0);
  693. this.errback = errback;
  694. //Indicate this module has be initialized
  695. this.inited = true;
  696. this.ignore = options.ignore;
  697. //Could have option to init this module in enabled mode,
  698. //or could have been previously marked as enabled. However,
  699. //the dependencies are not known until init is called. So
  700. //if enabled previously, now trigger dependencies as enabled.
  701. if (options.enabled || this.enabled) {
  702. //Enable this module and dependencies.
  703. //Will call this.check()
  704. this.enable();
  705. } else {
  706. this.check();
  707. }
  708. },
  709. defineDep: function (i, depExports) {
  710. //Because of cycles, defined callback for a given
  711. //export can be called more than once.
  712. if (!this.depMatched[i]) {
  713. this.depMatched[i] = true;
  714. this.depCount -= 1;
  715. this.depExports[i] = depExports;
  716. }
  717. },
  718. fetch: function () {
  719. if (this.fetched) {
  720. return;
  721. }
  722. this.fetched = true;
  723. context.startTime = (new Date()).getTime();
  724. var map = this.map;
  725. //If the manager is for a plugin managed resource,
  726. //ask the plugin to load it now.
  727. if (this.shim) {
  728. context.makeRequire(this.map, {
  729. enableBuildCallback: true
  730. })(this.shim.deps || [], bind(this, function () {
  731. return map.prefix ? this.callPlugin() : this.load();
  732. }));
  733. } else {
  734. //Regular dependency.
  735. return map.prefix ? this.callPlugin() : this.load();
  736. }
  737. },
  738. load: function () {
  739. var url = this.map.url;
  740. //Regular dependency.
  741. if (!urlFetched[url]) {
  742. urlFetched[url] = true;
  743. context.load(this.map.id, url);
  744. }
  745. },
  746. /**
  747. * Checks if the module is ready to define itself, and if so,
  748. * define it.
  749. */
  750. check: function () {
  751. if (!this.enabled || this.enabling) {
  752. return;
  753. }
  754. var err, cjsModule,
  755. id = this.map.id,
  756. depExports = this.depExports,
  757. exports = this.exports,
  758. factory = this.factory;
  759. if (!this.inited) {
  760. // Only fetch if not already in the defQueue.
  761. if (!hasProp(context.defQueueMap, id)) {
  762. this.fetch();
  763. }
  764. } else if (this.error) {
  765. this.emit('error', this.error);
  766. } else if (!this.defining) {
  767. //The factory could trigger another require call
  768. //that would result in checking this module to
  769. //define itself again. If already in the process
  770. //of doing that, skip this work.
  771. this.defining = true;
  772. if (this.depCount < 1 && !this.defined) {
  773. if (isFunction(factory)) {
  774. //If there is an error listener, favor passing
  775. //to that instead of throwing an error. However,
  776. //only do it for define()'d modules. require
  777. //errbacks should not be called for failures in
  778. //their callbacks (#699). However if a global
  779. //onError is set, use that.
  780. if ((this.events.error && this.map.isDefine) ||
  781. req.onError !== defaultOnError) {
  782. try {
  783. exports = context.execCb(id, factory, depExports, exports);
  784. } catch (e) {
  785. err = e;
  786. }
  787. } else {
  788. exports = context.execCb(id, factory, depExports, exports);
  789. }
  790. // Favor return value over exports. If node/cjs in play,
  791. // then will not have a return value anyway. Favor
  792. // module.exports assignment over exports object.
  793. if (this.map.isDefine && exports === undefined) {
  794. cjsModule = this.module;
  795. if (cjsModule) {
  796. exports = cjsModule.exports;
  797. } else if (this.usingExports) {
  798. //exports already set the defined value.
  799. exports = this.exports;
  800. }
  801. }
  802. if (err) {
  803. err.requireMap = this.map;
  804. err.requireModules = this.map.isDefine ? [this.map.id] : null;
  805. err.requireType = this.map.isDefine ? 'define' : 'require';
  806. return onError((this.error = err));
  807. }
  808. } else {
  809. //Just a literal value
  810. exports = factory;
  811. }
  812. this.exports = exports;
  813. if (this.map.isDefine && !this.ignore) {
  814. defined[id] = exports;
  815. if (req.onResourceLoad) {
  816. var resLoadMaps = [];
  817. each(this.depMaps, function (depMap) {
  818. resLoadMaps.push(depMap.normalizedMap || depMap);
  819. });
  820. req.onResourceLoad(context, this.map, resLoadMaps);
  821. }
  822. }
  823. //Clean up
  824. cleanRegistry(id);
  825. this.defined = true;
  826. }
  827. //Finished the define stage. Allow calling check again
  828. //to allow define notifications below in the case of a
  829. //cycle.
  830. this.defining = false;
  831. if (this.defined && !this.defineEmitted) {
  832. this.defineEmitted = true;
  833. this.emit('defined', this.exports);
  834. this.defineEmitComplete = true;
  835. }
  836. }
  837. },
  838. callPlugin: function () {
  839. var map = this.map,
  840. id = map.id,
  841. //Map already normalized the prefix.
  842. pluginMap = makeModuleMap(map.prefix);
  843. //Mark this as a dependency for this plugin, so it
  844. //can be traced for cycles.
  845. this.depMaps.push(pluginMap);
  846. on(pluginMap, 'defined', bind(this, function (plugin) {
  847. var load, normalizedMap, normalizedMod,
  848. bundleId = getOwn(bundlesMap, this.map.id),
  849. name = this.map.name,
  850. parentName = this.map.parentMap ? this.map.parentMap.name : null,
  851. localRequire = context.makeRequire(map.parentMap, {
  852. enableBuildCallback: true
  853. });
  854. //If current map is not normalized, wait for that
  855. //normalized name to load instead of continuing.
  856. if (this.map.unnormalized) {
  857. //Normalize the ID if the plugin allows it.
  858. if (plugin.normalize) {
  859. name = plugin.normalize(name, function (name) {
  860. return normalize(name, parentName, true);
  861. }) || '';
  862. }
  863. //prefix and name should already be normalized, no need
  864. //for applying map config again either.
  865. normalizedMap = makeModuleMap(map.prefix + '!' + name,
  866. this.map.parentMap,
  867. true);
  868. on(normalizedMap,
  869. 'defined', bind(this, function (value) {
  870. this.map.normalizedMap = normalizedMap;
  871. this.init([], function () { return value; }, null, {
  872. enabled: true,
  873. ignore: true
  874. });
  875. }));
  876. normalizedMod = getOwn(registry, normalizedMap.id);
  877. if (normalizedMod) {
  878. //Mark this as a dependency for this plugin, so it
  879. //can be traced for cycles.
  880. this.depMaps.push(normalizedMap);
  881. if (this.events.error) {
  882. normalizedMod.on('error', bind(this, function (err) {
  883. this.emit('error', err);
  884. }));
  885. }
  886. normalizedMod.enable();
  887. }
  888. return;
  889. }
  890. //If a paths config, then just load that file instead to
  891. //resolve the plugin, as it is built into that paths layer.
  892. if (bundleId) {
  893. this.map.url = context.nameToUrl(bundleId);
  894. this.load();
  895. return;
  896. }
  897. load = bind(this, function (value) {
  898. this.init([], function () { return value; }, null, {
  899. enabled: true
  900. });
  901. });
  902. load.error = bind(this, function (err) {
  903. this.inited = true;
  904. this.error = err;
  905. err.requireModules = [id];
  906. //Remove temp unnormalized modules for this module,
  907. //since they will never be resolved otherwise now.
  908. eachProp(registry, function (mod) {
  909. if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
  910. cleanRegistry(mod.map.id);
  911. }
  912. });
  913. onError(err);
  914. });
  915. //Allow plugins to load other code without having to know the
  916. //context or how to 'complete' the load.
  917. load.fromText = bind(this, function (text, textAlt) {
  918. /*jslint evil: true */
  919. var moduleName = map.name,
  920. moduleMap = makeModuleMap(moduleName),
  921. hasInteractive = useInteractive;
  922. //As of 2.1.0, support just passing the text, to reinforce
  923. //fromText only being called once per resource. Still
  924. //support old style of passing moduleName but discard
  925. //that moduleName in favor of the internal ref.
  926. if (textAlt) {
  927. text = textAlt;
  928. }
  929. //Turn off interactive script matching for IE for any define
  930. //calls in the text, then turn it back on at the end.
  931. if (hasInteractive) {
  932. useInteractive = false;
  933. }
  934. //Prime the system by creating a module instance for
  935. //it.
  936. getModule(moduleMap);
  937. //Transfer any config to this other module.
  938. if (hasProp(config.config, id)) {
  939. config.config[moduleName] = config.config[id];
  940. }
  941. try {
  942. req.exec(text);
  943. } catch (e) {
  944. return onError(makeError('fromtexteval',
  945. 'fromText eval for ' + id +
  946. ' failed: ' + e,
  947. e,
  948. [id]));
  949. }
  950. if (hasInteractive) {
  951. useInteractive = true;
  952. }
  953. //Mark this as a dependency for the plugin
  954. //resource
  955. this.depMaps.push(moduleMap);
  956. //Support anonymous modules.
  957. context.completeLoad(moduleName);
  958. //Bind the value of that module to the value for this
  959. //resource ID.
  960. localRequire([moduleName], load);
  961. });
  962. //Use parentName here since the plugin's name is not reliable,
  963. //could be some weird string with no path that actually wants to
  964. //reference the parentName's path.
  965. plugin.load(map.name, localRequire, load, config);
  966. }));
  967. context.enable(pluginMap, this);
  968. this.pluginMaps[pluginMap.id] = pluginMap;
  969. },
  970. enable: function () {
  971. enabledRegistry[this.map.id] = this;
  972. this.enabled = true;
  973. //Set flag mentioning that the module is enabling,
  974. //so that immediate calls to the defined callbacks
  975. //for dependencies do not trigger inadvertent load
  976. //with the depCount still being zero.
  977. this.enabling = true;
  978. //Enable each dependency
  979. each(this.depMaps, bind(this, function (depMap, i) {
  980. var id, mod, handler;
  981. if (typeof depMap === 'string') {
  982. //Dependency needs to be converted to a depMap
  983. //and wired up to this module.
  984. depMap = makeModuleMap(depMap,
  985. (this.map.isDefine ? this.map : this.map.parentMap),
  986. false,
  987. !this.skipMap);
  988. this.depMaps[i] = depMap;
  989. handler = getOwn(handlers, depMap.id);
  990. if (handler) {
  991. this.depExports[i] = handler(this);
  992. return;
  993. }
  994. this.depCount += 1;
  995. on(depMap, 'defined', bind(this, function (depExports) {
  996. if (this.undefed) {
  997. return;
  998. }
  999. this.defineDep(i, depExports);
  1000. this.check();
  1001. }));
  1002. if (this.errback) {
  1003. on(depMap, 'error', bind(this, this.errback));
  1004. } else if (this.events.error) {
  1005. // No direct errback on this module, but something
  1006. // else is listening for errors, so be sure to
  1007. // propagate the error correctly.
  1008. on(depMap, 'error', bind(this, function(err) {
  1009. this.emit('error', err);
  1010. }));
  1011. }
  1012. }
  1013. id = depMap.id;
  1014. mod = registry[id];
  1015. //Skip special modules like 'require', 'exports', 'module'
  1016. //Also, don't call enable if it is already enabled,
  1017. //important in circular dependency cases.
  1018. if (!hasProp(handlers, id) && mod && !mod.enabled) {
  1019. context.enable(depMap, this);
  1020. }
  1021. }));
  1022. //Enable each plugin that is used in
  1023. //a dependency
  1024. eachProp(this.pluginMaps, bind(this, function (pluginMap) {
  1025. var mod = getOwn(registry, pluginMap.id);
  1026. if (mod && !mod.enabled) {
  1027. context.enable(pluginMap, this);
  1028. }
  1029. }));
  1030. this.enabling = false;
  1031. this.check();
  1032. },
  1033. on: function (name, cb) {
  1034. var cbs = this.events[name];
  1035. if (!cbs) {
  1036. cbs = this.events[name] = [];
  1037. }
  1038. cbs.push(cb);
  1039. },
  1040. emit: function (name, evt) {
  1041. each(this.events[name], function (cb) {
  1042. cb(evt);
  1043. });
  1044. if (name === 'error') {
  1045. //Now that the error handler was triggered, remove
  1046. //the listeners, since this broken Module instance
  1047. //can stay around for a while in the registry.
  1048. delete this.events[name];
  1049. }
  1050. }
  1051. };
  1052. function callGetModule(args) {
  1053. //Skip modules already defined.
  1054. if (!hasProp(defined, args[0])) {
  1055. getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
  1056. }
  1057. }
  1058. function removeListener(node, func, name, ieName) {
  1059. //Favor detachEvent because of IE9
  1060. //issue, see attachEvent/addEventListener comment elsewhere
  1061. //in this file.
  1062. if (node.detachEvent && !isOpera) {
  1063. //Probably IE. If not it will throw an error, which will be
  1064. //useful to know.
  1065. if (ieName) {
  1066. node.detachEvent(ieName, func);
  1067. }
  1068. } else {
  1069. node.removeEventListener(name, func, false);
  1070. }
  1071. }
  1072. /**
  1073. * Given an event from a script node, get the requirejs info from it,
  1074. * and then removes the event listeners on the node.
  1075. * @param {Event} evt
  1076. * @returns {Object}
  1077. */
  1078. function getScriptData(evt) {
  1079. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1080. //all old browsers will be supported, but this one was easy enough
  1081. //to support and still makes sense.
  1082. var node = evt.currentTarget || evt.srcElement;
  1083. //Remove the listeners once here.
  1084. removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
  1085. removeListener(node, context.onScriptError, 'error');
  1086. return {
  1087. node: node,
  1088. id: node && node.getAttribute('data-requiremodule')
  1089. };
  1090. }
  1091. function intakeDefines() {
  1092. var args;
  1093. //Any defined modules in the global queue, intake them now.
  1094. takeGlobalQueue();
  1095. //Make sure any remaining defQueue items get properly processed.
  1096. while (defQueue.length) {
  1097. args = defQueue.shift();
  1098. if (args[0] === null) {
  1099. return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
  1100. args[args.length - 1]));
  1101. } else {
  1102. //args are id, deps, factory. Should be normalized by the
  1103. //define() function.
  1104. callGetModule(args);
  1105. }
  1106. }
  1107. context.defQueueMap = {};
  1108. }
  1109. context = {
  1110. config: config,
  1111. contextName: contextName,
  1112. registry: registry,
  1113. defined: defined,
  1114. urlFetched: urlFetched,
  1115. defQueue: defQueue,
  1116. defQueueMap: {},
  1117. Module: Module,
  1118. makeModuleMap: makeModuleMap,
  1119. nextTick: req.nextTick,
  1120. onError: onError,
  1121. /**
  1122. * Set a configuration for the context.
  1123. * @param {Object} cfg config object to integrate.
  1124. */
  1125. configure: function (cfg) {
  1126. //Make sure the baseUrl ends in a slash.
  1127. if (cfg.baseUrl) {
  1128. if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
  1129. cfg.baseUrl += '/';
  1130. }
  1131. }
  1132. // Convert old style urlArgs string to a function.
  1133. if (typeof cfg.urlArgs === 'string') {
  1134. var urlArgs = cfg.urlArgs;
  1135. cfg.urlArgs = function(id, url) {
  1136. return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
  1137. };
  1138. }
  1139. //Save off the paths since they require special processing,
  1140. //they are additive.
  1141. var shim = config.shim,
  1142. objs = {
  1143. paths: true,
  1144. bundles: true,
  1145. config: true,
  1146. map: true
  1147. };
  1148. eachProp(cfg, function (value, prop) {
  1149. if (objs[prop]) {
  1150. if (!config[prop]) {
  1151. config[prop] = {};
  1152. }
  1153. mixin(config[prop], value, true, true);
  1154. } else {
  1155. config[prop] = value;
  1156. }
  1157. });
  1158. //Reverse map the bundles
  1159. if (cfg.bundles) {
  1160. eachProp(cfg.bundles, function (value, prop) {
  1161. each(value, function (v) {
  1162. if (v !== prop) {
  1163. bundlesMap[v] = prop;
  1164. }
  1165. });
  1166. });
  1167. }
  1168. //Merge shim
  1169. if (cfg.shim) {
  1170. eachProp(cfg.shim, function (value, id) {
  1171. //Normalize the structure
  1172. if (isArray(value)) {
  1173. value = {
  1174. deps: value
  1175. };
  1176. }
  1177. if ((value.exports || value.init) && !value.exportsFn) {
  1178. value.exportsFn = context.makeShimExports(value);
  1179. }
  1180. shim[id] = value;
  1181. });
  1182. config.shim = shim;
  1183. }
  1184. //Adjust packages if necessary.
  1185. if (cfg.packages) {
  1186. each(cfg.packages, function (pkgObj) {
  1187. var location, name;
  1188. pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
  1189. name = pkgObj.name;
  1190. location = pkgObj.location;
  1191. if (location) {
  1192. config.paths[name] = pkgObj.location;
  1193. }
  1194. //Save pointer to main module ID for pkg name.
  1195. //Remove leading dot in main, so main paths are normalized,
  1196. //and remove any trailing .js, since different package
  1197. //envs have different conventions: some use a module name,
  1198. //some use a file name.
  1199. config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
  1200. .replace(currDirRegExp, '')
  1201. .replace(jsSuffixRegExp, '');
  1202. });
  1203. }
  1204. //If there are any "waiting to execute" modules in the registry,
  1205. //update the maps for them, since their info, like URLs to load,
  1206. //may have changed.
  1207. eachProp(registry, function (mod, id) {
  1208. //If module already has init called, since it is too
  1209. //late to modify them, and ignore unnormalized ones
  1210. //since they are transient.
  1211. if (!mod.inited && !mod.map.unnormalized) {
  1212. mod.map = makeModuleMap(id, null, true);
  1213. }
  1214. });
  1215. //If a deps array or a config callback is specified, then call
  1216. //require with those args. This is useful when require is defined as a
  1217. //config object before require.js is loaded.
  1218. if (cfg.deps || cfg.callback) {
  1219. context.require(cfg.deps || [], cfg.callback);
  1220. }
  1221. },
  1222. makeShimExports: function (value) {
  1223. function fn() {
  1224. var ret;
  1225. if (value.init) {
  1226. ret = value.init.apply(global, arguments);
  1227. }
  1228. return ret || (value.exports && getGlobal(value.exports));
  1229. }
  1230. return fn;
  1231. },
  1232. makeRequire: function (relMap, options) {
  1233. options = options || {};
  1234. function localRequire(deps, callback, errback) {
  1235. var id, map, requireMod;
  1236. if (options.enableBuildCallback && callback && isFunction(callback)) {
  1237. callback.__requireJsBuild = true;
  1238. }
  1239. if (typeof deps === 'string') {
  1240. if (isFunction(callback)) {
  1241. //Invalid call
  1242. return onError(makeError('requireargs', 'Invalid require call'), errback);
  1243. }
  1244. //If require|exports|module are requested, get the
  1245. //value for them from the special handlers. Caveat:
  1246. //this only works while module is being defined.
  1247. if (relMap && hasProp(handlers, deps)) {
  1248. return handlers[deps](registry[relMap.id]);
  1249. }
  1250. //Synchronous access to one module. If require.get is
  1251. //available (as in the Node adapter), prefer that.
  1252. if (req.get) {
  1253. return req.get(context, deps, relMap, localRequire);
  1254. }
  1255. //Normalize module name, if it contains . or ..
  1256. map = makeModuleMap(deps, relMap, false, true);
  1257. id = map.id;
  1258. if (!hasProp(defined, id)) {
  1259. return onError(makeError('notloaded', 'Module name "' +
  1260. id +
  1261. '" has not been loaded yet for context: ' +
  1262. contextName +
  1263. (relMap ? '' : '. Use require([])')));
  1264. }
  1265. return defined[id];
  1266. }
  1267. //Grab defines waiting in the global queue.
  1268. intakeDefines();
  1269. //Mark all the dependencies as needing to be loaded.
  1270. context.nextTick(function () {
  1271. //Some defines could have been added since the
  1272. //require call, collect them.
  1273. intakeDefines();
  1274. requireMod = getModule(makeModuleMap(null, relMap));
  1275. //Store if map config should be applied to this require
  1276. //call for dependencies.
  1277. requireMod.skipMap = options.skipMap;
  1278. requireMod.init(deps, callback, errback, {
  1279. enabled: true
  1280. });
  1281. checkLoaded();
  1282. });
  1283. return localRequire;
  1284. }
  1285. mixin(localRequire, {
  1286. isBrowser: isBrowser,
  1287. /**
  1288. * Converts a module name + .extension into an URL path.
  1289. * *Requires* the use of a module name. It does not support using
  1290. * plain URLs like nameToUrl.
  1291. */
  1292. toUrl: function (moduleNamePlusExt) {
  1293. var ext,
  1294. index = moduleNamePlusExt.lastIndexOf('.'),
  1295. segment = moduleNamePlusExt.split('/')[0],
  1296. isRelative = segment === '.' || segment === '..';
  1297. //Have a file extension alias, and it is not the
  1298. //dots from a relative path.
  1299. if (index !== -1 && (!isRelative || index > 1)) {
  1300. ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
  1301. moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
  1302. }
  1303. return context.nameToUrl(normalize(moduleNamePlusExt,
  1304. relMap && relMap.id, true), ext, true);
  1305. },
  1306. defined: function (id) {
  1307. return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
  1308. },
  1309. specified: function (id) {
  1310. id = makeModuleMap(id, relMap, false, true).id;
  1311. return hasProp(defined, id) || hasProp(registry, id);
  1312. }
  1313. });
  1314. //Only allow undef on top level require calls
  1315. if (!relMap) {
  1316. localRequire.undef = function (id) {
  1317. //Bind any waiting define() calls to this context,
  1318. //fix for #408
  1319. takeGlobalQueue();
  1320. var map = makeModuleMap(id, relMap, true),
  1321. mod = getOwn(registry, id);
  1322. mod.undefed = true;
  1323. removeScript(id);
  1324. delete defined[id];
  1325. delete urlFetched[map.url];
  1326. delete undefEvents[id];
  1327. //Clean queued defines too. Go backwards
  1328. //in array so that the splices do not
  1329. //mess up the iteration.
  1330. eachReverse(defQueue, function(args, i) {
  1331. if (args[0] === id) {
  1332. defQueue.splice(i, 1);
  1333. }
  1334. });
  1335. delete context.defQueueMap[id];
  1336. if (mod) {
  1337. //Hold on to listeners in case the
  1338. //module will be attempted to be reloaded
  1339. //using a different config.
  1340. if (mod.events.defined) {
  1341. undefEvents[id] = mod.events;
  1342. }
  1343. cleanRegistry(id);
  1344. }
  1345. };
  1346. }
  1347. return localRequire;
  1348. },
  1349. /**
  1350. * Called to enable a module if it is still in the registry
  1351. * awaiting enablement. A second arg, parent, the parent module,
  1352. * is passed in for context, when this method is overridden by
  1353. * the optimizer. Not shown here to keep code compact.
  1354. */
  1355. enable: function (depMap) {
  1356. var mod = getOwn(registry, depMap.id);
  1357. if (mod) {
  1358. getModule(depMap).enable();
  1359. }
  1360. },
  1361. /**
  1362. * Internal method used by environment adapters to complete a load event.
  1363. * A load event could be a script load or just a load pass from a synchronous
  1364. * load call.
  1365. * @param {String} moduleName the name of the module to potentially complete.
  1366. */
  1367. completeLoad: function (moduleName) {
  1368. var found, args, mod,
  1369. shim = getOwn(config.shim, moduleName) || {},
  1370. shExports = shim.exports;
  1371. takeGlobalQueue();
  1372. while (defQueue.length) {
  1373. args = defQueue.shift();
  1374. if (args[0] === null) {
  1375. args[0] = moduleName;
  1376. //If already found an anonymous module and bound it
  1377. //to this name, then this is some other anon module
  1378. //waiting for its completeLoad to fire.
  1379. if (found) {
  1380. break;
  1381. }
  1382. found = true;
  1383. } else if (args[0] === moduleName) {
  1384. //Found matching define call for this script!
  1385. found = true;
  1386. }
  1387. callGetModule(args);
  1388. }
  1389. context.defQueueMap = {};
  1390. //Do this after the cycle of callGetModule in case the result
  1391. //of those calls/init calls changes the registry.
  1392. mod = getOwn(registry, moduleName);
  1393. if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
  1394. if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
  1395. if (hasPathFallback(moduleName)) {
  1396. return;
  1397. } else {
  1398. return onError(makeError('nodefine',
  1399. 'No define call for ' + moduleName,
  1400. null,
  1401. [moduleName]));
  1402. }
  1403. } else {
  1404. //A script that does not call define(), so just simulate
  1405. //the call for it.
  1406. callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
  1407. }
  1408. }
  1409. checkLoaded();
  1410. },
  1411. /**
  1412. * Converts a module name to a file path. Supports cases where
  1413. * moduleName may actually be just an URL.
  1414. * Note that it **does not** call normalize on the moduleName,
  1415. * it is assumed to have already been normalized. This is an
  1416. * internal API, not a public one. Use toUrl for the public API.
  1417. */
  1418. nameToUrl: function (moduleName, ext, skipExt) {
  1419. var paths, syms, i, parentModule, url,
  1420. parentPath, bundleId,
  1421. pkgMain = getOwn(config.pkgs, moduleName);
  1422. if (pkgMain) {
  1423. moduleName = pkgMain;
  1424. }
  1425. bundleId = getOwn(bundlesMap, moduleName);
  1426. if (bundleId) {
  1427. return context.nameToUrl(bundleId, ext, skipExt);
  1428. }
  1429. //If a colon is in the URL, it indicates a protocol is used and it is just
  1430. //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
  1431. //or ends with .js, then assume the user meant to use an url and not a module id.
  1432. //The slash is important for protocol-less URLs as well as full paths.
  1433. if (req.jsExtRegExp.test(moduleName)) {
  1434. //Just a plain path, not module name lookup, so just return it.
  1435. //Add extension if it is included. This is a bit wonky, only non-.js things pass
  1436. //an extension, this method probably needs to be reworked.
  1437. url = moduleName + (ext || '');
  1438. } else {
  1439. //A module that needs to be converted to a path.
  1440. paths = config.paths;
  1441. syms = moduleName.split('/');
  1442. //For each module name segment, see if there is a path
  1443. //registered for it. Start with most specific name
  1444. //and work up from it.
  1445. for (i = syms.length; i > 0; i -= 1) {
  1446. parentModule = syms.slice(0, i).join('/');
  1447. parentPath = getOwn(paths, parentModule);
  1448. if (parentPath) {
  1449. //If an array, it means there are a few choices,
  1450. //Choose the one that is desired
  1451. if (isArray(parentPath)) {
  1452. parentPath = parentPath[0];
  1453. }
  1454. syms.splice(0, i, parentPath);
  1455. break;
  1456. }
  1457. }
  1458. //Join the path parts together, then figure out if baseUrl is needed.
  1459. url = syms.join('/');
  1460. url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
  1461. url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
  1462. }
  1463. return config.urlArgs && !/^blob\:/.test(url) ?
  1464. url + config.urlArgs(moduleName, url) : url;
  1465. },
  1466. //Delegates to req.load. Broken out as a separate function to
  1467. //allow overriding in the optimizer.
  1468. load: function (id, url) {
  1469. req.load(context, id, url);
  1470. },
  1471. /**
  1472. * Executes a module callback function. Broken out as a separate function
  1473. * solely to allow the build system to sequence the files in the built
  1474. * layer in the right sequence.
  1475. *
  1476. * @private
  1477. */
  1478. execCb: function (name, callback, args, exports) {
  1479. return callback.apply(exports, args);
  1480. },
  1481. /**
  1482. * callback for script loads, used to check status of loading.
  1483. *
  1484. * @param {Event} evt the event from the browser for the script
  1485. * that was loaded.
  1486. */
  1487. onScriptLoad: function (evt) {
  1488. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1489. //all old browsers will be supported, but this one was easy enough
  1490. //to support and still makes sense.
  1491. if (evt.type === 'load' ||
  1492. (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
  1493. //Reset interactive script so a script node is not held onto for
  1494. //to long.
  1495. interactiveScript = null;
  1496. //Pull out the name of the module and the context.
  1497. var data = getScriptData(evt);
  1498. context.completeLoad(data.id);
  1499. }
  1500. },
  1501. /**
  1502. * Callback for script errors.
  1503. */
  1504. onScriptError: function (evt) {
  1505. var data = getScriptData(evt);
  1506. if (!hasPathFallback(data.id)) {
  1507. var parents = [];
  1508. eachProp(registry, function(value, key) {
  1509. if (key.indexOf('_@r') !== 0) {
  1510. each(value.depMaps, function(depMap) {
  1511. if (depMap.id === data.id) {
  1512. parents.push(key);
  1513. return true;
  1514. }
  1515. });
  1516. }
  1517. });
  1518. return onError(makeError('scripterror', 'Script error for "' + data.id +
  1519. (parents.length ?
  1520. '", needed by: ' + parents.join(', ') :
  1521. '"'), evt, [data.id]));
  1522. }
  1523. }
  1524. };
  1525. context.require = context.makeRequire();
  1526. return context;
  1527. }
  1528. /**
  1529. * Main entry point.
  1530. *
  1531. * If the only argument to require is a string, then the module that
  1532. * is represented by that string is fetched for the appropriate context.
  1533. *
  1534. * If the first argument is an array, then it will be treated as an array
  1535. * of dependency string names to fetch. An optional function callback can
  1536. * be specified to execute when all of those dependencies are available.
  1537. *
  1538. * Make a local req variable to help Caja compliance (it assumes things
  1539. * on a require that are not standardized), and to give a short
  1540. * name for minification/local scope use.
  1541. */
  1542. req = requirejs = function (deps, callback, errback, optional) {
  1543. //Find the right context, use default
  1544. var context, config,
  1545. contextName = defContextName;
  1546. // Determine if have config object in the call.
  1547. if (!isArray(deps) && typeof deps !== 'string') {
  1548. // deps is a config object
  1549. config = deps;
  1550. if (isArray(callback)) {
  1551. // Adjust args if there are dependencies
  1552. deps = callback;
  1553. callback = errback;
  1554. errback = optional;
  1555. } else {
  1556. deps = [];
  1557. }
  1558. }
  1559. if (config && config.context) {
  1560. contextName = config.context;
  1561. }
  1562. context = getOwn(contexts, contextName);
  1563. if (!context) {
  1564. context = contexts[contextName] = req.s.newContext(contextName);
  1565. }
  1566. if (config) {
  1567. context.configure(config);
  1568. }
  1569. return context.require(deps, callback, errback);
  1570. };
  1571. /**
  1572. * Support require.config() to make it easier to cooperate with other
  1573. * AMD loaders on globally agreed names.
  1574. */
  1575. req.config = function (config) {
  1576. return req(config);
  1577. };
  1578. /**
  1579. * Execute something after the current tick
  1580. * of the event loop. Override for other envs
  1581. * that have a better solution than setTimeout.
  1582. * @param {Function} fn function to execute later.
  1583. */
  1584. req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
  1585. setTimeout(fn, 4);
  1586. } : function (fn) { fn(); };
  1587. /**
  1588. * Export require as a global, but only if it does not already exist.
  1589. */
  1590. if (!require) {
  1591. require = req;
  1592. }
  1593. req.version = version;
  1594. //Used to filter out dependencies that are already paths.
  1595. req.jsExtRegExp = /^\/|:|\?|\.js$/;
  1596. req.isBrowser = isBrowser;
  1597. s = req.s = {
  1598. contexts: contexts,
  1599. newContext: newContext
  1600. };
  1601. //Create default context.
  1602. req({});
  1603. //Exports some context-sensitive methods on global require.
  1604. each([
  1605. 'toUrl',
  1606. 'undef',
  1607. 'defined',
  1608. 'specified'
  1609. ], function (prop) {
  1610. //Reference from contexts instead of early binding to default context,
  1611. //so that during builds, the latest instance of the default context
  1612. //with its config gets used.
  1613. req[prop] = function () {
  1614. var ctx = contexts[defContextName];
  1615. return ctx.require[prop].apply(ctx, arguments);
  1616. };
  1617. });
  1618. if (isBrowser) {
  1619. head = s.head = document.getElementsByTagName('head')[0];
  1620. //If BASE tag is in play, using appendChild is a problem for IE6.
  1621. //When that browser dies, this can be removed. Details in this jQuery bug:
  1622. //http://dev.jquery.com/ticket/2709
  1623. baseElement = document.getElementsByTagName('base')[0];
  1624. if (baseElement) {
  1625. head = s.head = baseElement.parentNode;
  1626. }
  1627. }
  1628. /**
  1629. * Any errors that require explicitly generates will be passed to this
  1630. * function. Intercept/override it if you want custom error handling.
  1631. * @param {Error} err the error object.
  1632. */
  1633. req.onError = defaultOnError;
  1634. /**
  1635. * Creates the node for the load command. Only used in browser envs.
  1636. */
  1637. req.createNode = function (config, moduleName, url) {
  1638. var node = config.xhtml ?
  1639. document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
  1640. document.createElement('script');
  1641. node.type = config.scriptType || 'text/javascript';
  1642. node.charset = 'utf-8';
  1643. node.async = true;
  1644. return node;
  1645. };
  1646. /**
  1647. * Does the request to load a module for the browser case.
  1648. * Make this a separate function to allow other environments
  1649. * to override it.
  1650. *
  1651. * @param {Object} context the require context to find state.
  1652. * @param {String} moduleName the name of the module.
  1653. * @param {Object} url the URL to the module.
  1654. */
  1655. req.load = function (context, moduleName, url) {
  1656. var config = (context && context.config) || {},
  1657. node;
  1658. if (isBrowser) {
  1659. //In the browser so use a script tag
  1660. node = req.createNode(config, moduleName, url);
  1661. node.setAttribute('data-requirecontext', context.contextName);
  1662. node.setAttribute('data-requiremodule', moduleName);
  1663. //Set up load listener. Test attachEvent first because IE9 has
  1664. //a subtle issue in its addEventListener and script onload firings
  1665. //that do not match the behavior of all other browsers with
  1666. //addEventListener support, which fire the onload event for a
  1667. //script right after the script execution. See:
  1668. //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
  1669. //UNFORTUNATELY Opera implements attachEvent but does not follow the script
  1670. //script execution mode.
  1671. if (node.attachEvent &&
  1672. //Check if node.attachEvent is artificially added by custom script or
  1673. //natively supported by browser
  1674. //read https://github.com/requirejs/requirejs/issues/187
  1675. //if we can NOT find [native code] then it must NOT natively supported.
  1676. //in IE8, node.attachEvent does not have toString()
  1677. //Note the test for "[native code" with no closing brace, see:
  1678. //https://github.com/requirejs/requirejs/issues/273
  1679. !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
  1680. !isOpera) {
  1681. //Probably IE. IE (at least 6-8) do not fire
  1682. //script onload right after executing the script, so
  1683. //we cannot tie the anonymous define call to a name.
  1684. //However, IE reports the script as being in 'interactive'
  1685. //readyState at the time of the define call.
  1686. useInteractive = true;
  1687. node.attachEvent('onreadystatechange', context.onScriptLoad);
  1688. //It would be great to add an error handler here to catch
  1689. //404s in IE9+. However, onreadystatechange will fire before
  1690. //the error handler, so that does not help. If addEventListener
  1691. //is used, then IE will fire error before load, but we cannot
  1692. //use that pathway given the connect.microsoft.com issue
  1693. //mentioned above about not doing the 'script execute,
  1694. //then fire the script load event listener before execute
  1695. //next script' that other browsers do.
  1696. //Best hope: IE10 fixes the issues,
  1697. //and then destroys all installs of IE 6-9.
  1698. //node.attachEvent('onerror', context.onScriptError);
  1699. } else {
  1700. node.addEventListener('load', context.onScriptLoad, false);
  1701. node.addEventListener('error', context.onScriptError, false);
  1702. }
  1703. node.src = url;
  1704. //Calling onNodeCreated after all properties on the node have been
  1705. //set, but before it is placed in the DOM.
  1706. if (config.onNodeCreated) {
  1707. config.onNodeCreated(node, config, moduleName, url);
  1708. }
  1709. //For some cache cases in IE 6-8, the script executes before the end
  1710. //of the appendChild execution, so to tie an anonymous define
  1711. //call to the module name (which is stored on the node), hold on
  1712. //to a reference to this node, but clear after the DOM insertion.
  1713. currentlyAddingScript = node;
  1714. if (baseElement) {
  1715. head.insertBefore(node, baseElement);
  1716. } else {
  1717. head.appendChild(node);
  1718. }
  1719. currentlyAddingScript = null;
  1720. return node;
  1721. } else if (isWebWorker) {
  1722. try {
  1723. //In a web worker, use importScripts. This is not a very
  1724. //efficient use of importScripts, importScripts will block until
  1725. //its script is downloaded and evaluated. However, if web workers
  1726. //are in play, the expectation is that a build has been done so
  1727. //that only one script needs to be loaded anyway. This may need
  1728. //to be reevaluated if other use cases become common.
  1729. // Post a task to the event loop to work around a bug in WebKit
  1730. // where the worker gets garbage-collected after calling
  1731. // importScripts(): https://webkit.org/b/153317
  1732. setTimeout(function() {}, 0);
  1733. importScripts(url);
  1734. //Account for anonymous modules
  1735. context.completeLoad(moduleName);
  1736. } catch (e) {
  1737. context.onError(makeError('importscripts',
  1738. 'importScripts failed for ' +
  1739. moduleName + ' at ' + url,
  1740. e,
  1741. [moduleName]));
  1742. }
  1743. }
  1744. };
  1745. function getInteractiveScript() {
  1746. if (interactiveScript && interactiveScript.readyState === 'interactive') {
  1747. return interactiveScript;
  1748. }
  1749. eachReverse(scripts(), function (script) {
  1750. if (script.readyState === 'interactive') {
  1751. return (interactiveScript = script);
  1752. }
  1753. });
  1754. return interactiveScript;
  1755. }
  1756. //Look for a data-main script attribute, which could also adjust the baseUrl.
  1757. if (isBrowser && !cfg.skipDataMain) {
  1758. //Figure out baseUrl. Get it from the script tag with require.js in it.
  1759. eachReverse(scripts(), function (script) {
  1760. //Set the 'head' where we can append children by
  1761. //using the script's parent.
  1762. if (!head) {
  1763. head = script.parentNode;
  1764. }
  1765. //Look for a data-main attribute to set main script for the page
  1766. //to load. If it is there, the path to data main becomes the
  1767. //baseUrl, if it is not already set.
  1768. dataMain = script.getAttribute('data-main');
  1769. if (dataMain) {
  1770. //Preserve dataMain in case it is a path (i.e. contains '?')
  1771. mainScript = dataMain;
  1772. //Set final baseUrl if there is not already an explicit one,
  1773. //but only do so if the data-main value is not a loader plugin
  1774. //module ID.
  1775. if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {
  1776. //Pull off the directory of data-main for use as the
  1777. //baseUrl.
  1778. src = mainScript.split('/');
  1779. mainScript = src.pop();
  1780. subPath = src.length ? src.join('/') + '/' : './';
  1781. cfg.baseUrl = subPath;
  1782. }
  1783. //Strip off any trailing .js since mainScript is now
  1784. //like a module name.
  1785. mainScript = mainScript.replace(jsSuffixRegExp, '');
  1786. //If mainScript is still a path, fall back to dataMain
  1787. if (req.jsExtRegExp.test(mainScript)) {
  1788. mainScript = dataMain;
  1789. }
  1790. //Put the data-main script in the files to load.
  1791. cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
  1792. return true;
  1793. }
  1794. });
  1795. }
  1796. /**
  1797. * The function that handles definitions of modules. Differs from
  1798. * require() in that a string for the module should be the first argument,
  1799. * and the function to execute after dependencies are loaded should
  1800. * return a value to define the module corresponding to the first argument's
  1801. * name.
  1802. */
  1803. define = function (name, deps, callback) {
  1804. var node, context;
  1805. //Allow for anonymous modules
  1806. if (typeof name !== 'string') {
  1807. //Adjust args appropriately
  1808. callback = deps;
  1809. deps = name;
  1810. name = null;
  1811. }
  1812. //This module may not have dependencies
  1813. if (!isArray(deps)) {
  1814. callback = deps;
  1815. deps = null;
  1816. }
  1817. //If no name, and callback is a function, then figure out if it a
  1818. //CommonJS thing with dependencies.
  1819. if (!deps && isFunction(callback)) {
  1820. deps = [];
  1821. //Remove comments from the callback string,
  1822. //look for require calls, and pull them into the dependencies,
  1823. //but only if there are function args.
  1824. if (callback.length) {
  1825. callback
  1826. .toString()
  1827. .replace(commentRegExp, commentReplace)
  1828. .replace(cjsRequireRegExp, function (match, dep) {
  1829. deps.push(dep);
  1830. });
  1831. //May be a CommonJS thing even without require calls, but still
  1832. //could use exports, and module. Avoid doing exports and module
  1833. //work though if it just needs require.
  1834. //REQUIRES the function to expect the CommonJS variables in the
  1835. //order listed below.
  1836. deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
  1837. }
  1838. }
  1839. //If in IE 6-8 and hit an anonymous define() call, do the interactive
  1840. //work.
  1841. if (useInteractive) {
  1842. node = currentlyAddingScript || getInteractiveScript();
  1843. if (node) {
  1844. if (!name) {
  1845. name = node.getAttribute('data-requiremodule');
  1846. }
  1847. context = contexts[node.getAttribute('data-requirecontext')];
  1848. }
  1849. }
  1850. //Always save off evaluating the def call until the script onload handler.
  1851. //This allows multiple modules to be in a file without prematurely
  1852. //tracing dependencies, and allows for anonymous module support,
  1853. //where the module name is not known until the script onload event
  1854. //occurs. If no context, use the global queue, and get it processed
  1855. //in the onscript load callback.
  1856. if (context) {
  1857. context.defQueue.push([name, deps, callback]);
  1858. context.defQueueMap[name] = true;
  1859. } else {
  1860. globalDefQueue.push([name, deps, callback]);
  1861. }
  1862. };
  1863. define.amd = {
  1864. jQuery: true
  1865. };
  1866. /**
  1867. * Executes the text. Normally just uses eval, but can be modified
  1868. * to use a better, environment-specific call. Only used for transpiling
  1869. * loader plugins, not for plain JS modules.
  1870. * @param {String} text the text to execute/evaluate.
  1871. */
  1872. req.exec = function (text) {
  1873. /*jslint evil: true */
  1874. return eval(text);
  1875. };
  1876. //Set up with config info.
  1877. req(cfg);
  1878. }(this, (typeof setTimeout === 'undefined' ? undefined : setTimeout)));