require-compiled.js 84 KB

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