@ms-atlas/datastudio 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @ms-atlas/datastudio might be problematic. Click here for more details.

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