Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

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