@opensumi/cli-engine 2.1.0

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.
Files changed (88) hide show
  1. package/README.md +7 -0
  2. package/lib/browser/1.browser.js +1 -0
  3. package/lib/browser/1.worker-host.js +1 -0
  4. package/lib/browser/2.browser.js +1 -0
  5. package/lib/browser/3.browser.js +1 -0
  6. package/lib/browser/assets.json +79 -0
  7. package/lib/browser/browser.js +2 -0
  8. package/lib/browser/browser.js.LICENSE.txt +98 -0
  9. package/lib/browser/fonts/boolean-dark.svg +3 -0
  10. package/lib/browser/fonts/boolean-light.svg +3 -0
  11. package/lib/browser/fonts/breakpoint-conditional-disabled.svg +4 -0
  12. package/lib/browser/fonts/breakpoint-conditional-unverified.svg +4 -0
  13. package/lib/browser/fonts/breakpoint-conditional.svg +4 -0
  14. package/lib/browser/fonts/breakpoint-disabled.svg +4 -0
  15. package/lib/browser/fonts/breakpoint-hint.svg +4 -0
  16. package/lib/browser/fonts/breakpoint-log-disabled.svg +4 -0
  17. package/lib/browser/fonts/breakpoint-log-unverified.svg +4 -0
  18. package/lib/browser/fonts/breakpoint-log.svg +4 -0
  19. package/lib/browser/fonts/breakpoint-unsupported.svg +4 -0
  20. package/lib/browser/fonts/breakpoint-unverified.svg +4 -0
  21. package/lib/browser/fonts/breakpoint.svg +4 -0
  22. package/lib/browser/fonts/class-dark.svg +3 -0
  23. package/lib/browser/fonts/class-light.svg +3 -0
  24. package/lib/browser/fonts/codicon.ttf +0 -0
  25. package/lib/browser/fonts/constant-dark.svg +4 -0
  26. package/lib/browser/fonts/constant-light.svg +4 -0
  27. package/lib/browser/fonts/current-and-breakpoint.svg +4 -0
  28. package/lib/browser/fonts/current-arrow.svg +4 -0
  29. package/lib/browser/fonts/enumerator-dark.svg +3 -0
  30. package/lib/browser/fonts/enumerator-item-dark.svg +3 -0
  31. package/lib/browser/fonts/enumerator-item-light.svg +3 -0
  32. package/lib/browser/fonts/enumerator-light.svg +3 -0
  33. package/lib/browser/fonts/event-dark.svg +3 -0
  34. package/lib/browser/fonts/event-light.svg +3 -0
  35. package/lib/browser/fonts/field-dark.svg +3 -0
  36. package/lib/browser/fonts/field-light.svg +3 -0
  37. package/lib/browser/fonts/file-dark.svg +3 -0
  38. package/lib/browser/fonts/file-light.svg +3 -0
  39. package/lib/browser/fonts/indexer-dark.svg +3 -0
  40. package/lib/browser/fonts/indexer-light.svg +3 -0
  41. package/lib/browser/fonts/interface-dark.svg +3 -0
  42. package/lib/browser/fonts/interface-light.svg +3 -0
  43. package/lib/browser/fonts/keyword-dark.svg +3 -0
  44. package/lib/browser/fonts/keyword-light.svg +3 -0
  45. package/lib/browser/fonts/loading-dark.svg +52 -0
  46. package/lib/browser/fonts/loading-hc.svg +52 -0
  47. package/lib/browser/fonts/loading.svg +52 -0
  48. package/lib/browser/fonts/method-dark.svg +3 -0
  49. package/lib/browser/fonts/method-light.svg +3 -0
  50. package/lib/browser/fonts/namespace-dark.svg +3 -0
  51. package/lib/browser/fonts/namespace-light.svg +3 -0
  52. package/lib/browser/fonts/numeric-dark.svg +3 -0
  53. package/lib/browser/fonts/numeric-light.svg +3 -0
  54. package/lib/browser/fonts/operator-dark.svg +3 -0
  55. package/lib/browser/fonts/operator-light.svg +3 -0
  56. package/lib/browser/fonts/property-dark.svg +3 -0
  57. package/lib/browser/fonts/property-light.svg +3 -0
  58. package/lib/browser/fonts/snippet-dark.svg +3 -0
  59. package/lib/browser/fonts/snippet-light.svg +3 -0
  60. package/lib/browser/fonts/stackframe-and-breakpoint.svg +4 -0
  61. package/lib/browser/fonts/stackframe-arrow.svg +4 -0
  62. package/lib/browser/fonts/string-dark.svg +3 -0
  63. package/lib/browser/fonts/string-light.svg +3 -0
  64. package/lib/browser/fonts/structure-dark.svg +3 -0
  65. package/lib/browser/fonts/structure-light.svg +3 -0
  66. package/lib/browser/fonts/template-dark.svg +3 -0
  67. package/lib/browser/fonts/template-light.svg +3 -0
  68. package/lib/browser/fonts/variable-dark.svg +3 -0
  69. package/lib/browser/fonts/variable-light.svg +3 -0
  70. package/lib/browser/index.html +42 -0
  71. package/lib/browser/loader.js +1747 -0
  72. package/lib/browser/main.css +1 -0
  73. package/lib/browser/worker-host.js +40 -0
  74. package/lib/hosted/1.ext.process.js +1 -0
  75. package/lib/hosted/ext.process.js +37 -0
  76. package/lib/node/env.d.ts +2 -0
  77. package/lib/node/env.js +35 -0
  78. package/lib/node/index.d.ts +1 -0
  79. package/lib/node/index.js +45 -0
  80. package/lib/node/modules.d.ts +2 -0
  81. package/lib/node/modules.js +6 -0
  82. package/lib/node/openBrowser.d.ts +5 -0
  83. package/lib/node/openBrowser.js +116 -0
  84. package/lib/node/server.d.ts +18 -0
  85. package/lib/node/server.js +171 -0
  86. package/lib/node/webview/index.html +12 -0
  87. package/lib/node/webview/webview.js +1 -0
  88. package/package.json +84 -0
@@ -0,0 +1,1747 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ /*---------------------------------------------------------------------------------------------
7
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8
+ * Licensed under the MIT License. See License.txt in the project root for license information.
9
+ *--------------------------------------------------------------------------------------------*/
10
+ /*---------------------------------------------------------------------------------------------
11
+ *---------------------------------------------------------------------------------------------
12
+ *---------------------------------------------------------------------------------------------
13
+ *---------------------------------------------------------------------------------------------
14
+ *---------------------------------------------------------------------------------------------
15
+ * Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
16
+ *---------------------------------------------------------------------------------------------
17
+ *---------------------------------------------------------------------------------------------
18
+ *---------------------------------------------------------------------------------------------
19
+ *---------------------------------------------------------------------------------------------
20
+ *--------------------------------------------------------------------------------------------*/
21
+ this.amdLoader = {};
22
+ var _amdLoaderGlobal = this.amdLoader;
23
+ var _commonjsGlobal = typeof global === 'object' ? global : {};
24
+ var AMDLoader;
25
+ (function (AMDLoader) {
26
+ AMDLoader.global = _amdLoaderGlobal;
27
+ var Environment = (function () {
28
+ function Environment() {
29
+ this._detected = false;
30
+ this._isWindows = false;
31
+ this._isNode = false;
32
+ this._isElectronRenderer = false;
33
+ this._isWebWorker = false;
34
+ }
35
+ Object.defineProperty(Environment.prototype, "isWindows", {
36
+ get: function () {
37
+ this._detect();
38
+ return this._isWindows;
39
+ },
40
+ enumerable: true,
41
+ configurable: true
42
+ });
43
+ Object.defineProperty(Environment.prototype, "isNode", {
44
+ get: function () {
45
+ this._detect();
46
+ return this._isNode;
47
+ },
48
+ enumerable: true,
49
+ configurable: true
50
+ });
51
+ Object.defineProperty(Environment.prototype, "isElectronRenderer", {
52
+ get: function () {
53
+ this._detect();
54
+ return this._isElectronRenderer;
55
+ },
56
+ enumerable: true,
57
+ configurable: true
58
+ });
59
+ Object.defineProperty(Environment.prototype, "isWebWorker", {
60
+ get: function () {
61
+ this._detect();
62
+ return this._isWebWorker;
63
+ },
64
+ enumerable: true,
65
+ configurable: true
66
+ });
67
+ Environment.prototype._detect = function () {
68
+ if (this._detected) {
69
+ return;
70
+ }
71
+ this._detected = true;
72
+ this._isWindows = Environment._isWindows();
73
+ this._isNode = (typeof module !== 'undefined' && !!module.exports);
74
+ this._isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
75
+ this._isWebWorker = (typeof AMDLoader.global.importScripts === 'function');
76
+ };
77
+ Environment._isWindows = function () {
78
+ if (typeof navigator !== 'undefined') {
79
+ if (navigator.userAgent && navigator.userAgent.indexOf('Windows') >= 0) {
80
+ return true;
81
+ }
82
+ }
83
+ if (typeof process !== 'undefined') {
84
+ return (process.platform === 'win32');
85
+ }
86
+ return false;
87
+ };
88
+ return Environment;
89
+ }());
90
+ AMDLoader.Environment = Environment;
91
+ })(AMDLoader || (AMDLoader = {}));
92
+ /*---------------------------------------------------------------------------------------------
93
+ * Copyright (c) Microsoft Corporation. All rights reserved.
94
+ * Licensed under the MIT License. See License.txt in the project root for license information.
95
+ *--------------------------------------------------------------------------------------------*/
96
+ var AMDLoader;
97
+ (function (AMDLoader) {
98
+ var LoaderEvent = (function () {
99
+ function LoaderEvent(type, detail, timestamp) {
100
+ this.type = type;
101
+ this.detail = detail;
102
+ this.timestamp = timestamp;
103
+ }
104
+ return LoaderEvent;
105
+ }());
106
+ AMDLoader.LoaderEvent = LoaderEvent;
107
+ var LoaderEventRecorder = (function () {
108
+ function LoaderEventRecorder(loaderAvailableTimestamp) {
109
+ this._events = [new LoaderEvent(1 /* LoaderAvailable */, '', loaderAvailableTimestamp)];
110
+ }
111
+ LoaderEventRecorder.prototype.record = function (type, detail) {
112
+ this._events.push(new LoaderEvent(type, detail, AMDLoader.Utilities.getHighPerformanceTimestamp()));
113
+ };
114
+ LoaderEventRecorder.prototype.getEvents = function () {
115
+ return this._events;
116
+ };
117
+ return LoaderEventRecorder;
118
+ }());
119
+ AMDLoader.LoaderEventRecorder = LoaderEventRecorder;
120
+ var NullLoaderEventRecorder = (function () {
121
+ function NullLoaderEventRecorder() {
122
+ }
123
+ NullLoaderEventRecorder.prototype.record = function (type, detail) {
124
+ // Nothing to do
125
+ };
126
+ NullLoaderEventRecorder.prototype.getEvents = function () {
127
+ return [];
128
+ };
129
+ return NullLoaderEventRecorder;
130
+ }());
131
+ NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();
132
+ AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder;
133
+ })(AMDLoader || (AMDLoader = {}));
134
+ /*---------------------------------------------------------------------------------------------
135
+ * Copyright (c) Microsoft Corporation. All rights reserved.
136
+ * Licensed under the MIT License. See License.txt in the project root for license information.
137
+ *--------------------------------------------------------------------------------------------*/
138
+ var AMDLoader;
139
+ (function (AMDLoader) {
140
+ var Utilities = (function () {
141
+ function Utilities() {
142
+ }
143
+ /**
144
+ * This method does not take care of / vs \
145
+ */
146
+ Utilities.fileUriToFilePath = function (isWindows, uri) {
147
+ uri = decodeURI(uri).replace(/%23/g, '#');
148
+ if (isWindows) {
149
+ if (/^file:\/\/\//.test(uri)) {
150
+ // This is a URI without a hostname => return only the path segment
151
+ return uri.substr(8);
152
+ }
153
+ if (/^file:\/\//.test(uri)) {
154
+ return uri.substr(5);
155
+ }
156
+ }
157
+ else {
158
+ if (/^file:\/\//.test(uri)) {
159
+ return uri.substr(7);
160
+ }
161
+ }
162
+ // Not sure...
163
+ return uri;
164
+ };
165
+ Utilities.startsWith = function (haystack, needle) {
166
+ return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;
167
+ };
168
+ Utilities.endsWith = function (haystack, needle) {
169
+ return haystack.length >= needle.length && haystack.substr(haystack.length - needle.length) === needle;
170
+ };
171
+ // only check for "?" before "#" to ensure that there is a real Query-String
172
+ Utilities.containsQueryString = function (url) {
173
+ return /^[^\#]*\?/gi.test(url);
174
+ };
175
+ /**
176
+ * Does `url` start with http:// or https:// or file:// or / ?
177
+ */
178
+ Utilities.isAbsolutePath = function (url) {
179
+ return /^((http:\/\/)|(https:\/\/)|(file:\/\/)|(\/))/.test(url);
180
+ };
181
+ Utilities.forEachProperty = function (obj, callback) {
182
+ if (obj) {
183
+ var key = void 0;
184
+ for (key in obj) {
185
+ if (obj.hasOwnProperty(key)) {
186
+ callback(key, obj[key]);
187
+ }
188
+ }
189
+ }
190
+ };
191
+ Utilities.isEmpty = function (obj) {
192
+ var isEmpty = true;
193
+ Utilities.forEachProperty(obj, function () {
194
+ isEmpty = false;
195
+ });
196
+ return isEmpty;
197
+ };
198
+ Utilities.recursiveClone = function (obj) {
199
+ if (!obj || typeof obj !== 'object') {
200
+ return obj;
201
+ }
202
+ var result = Array.isArray(obj) ? [] : {};
203
+ Utilities.forEachProperty(obj, function (key, value) {
204
+ if (value && typeof value === 'object') {
205
+ result[key] = Utilities.recursiveClone(value);
206
+ }
207
+ else {
208
+ result[key] = value;
209
+ }
210
+ });
211
+ return result;
212
+ };
213
+ Utilities.generateAnonymousModule = function () {
214
+ return '===anonymous' + (Utilities.NEXT_ANONYMOUS_ID++) + '===';
215
+ };
216
+ Utilities.isAnonymousModule = function (id) {
217
+ return Utilities.startsWith(id, '===anonymous');
218
+ };
219
+ Utilities.getHighPerformanceTimestamp = function () {
220
+ if (!this.PERFORMANCE_NOW_PROBED) {
221
+ this.PERFORMANCE_NOW_PROBED = true;
222
+ this.HAS_PERFORMANCE_NOW = (AMDLoader.global.performance && typeof AMDLoader.global.performance.now === 'function');
223
+ }
224
+ return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now());
225
+ };
226
+ return Utilities;
227
+ }());
228
+ Utilities.NEXT_ANONYMOUS_ID = 1;
229
+ Utilities.PERFORMANCE_NOW_PROBED = false;
230
+ Utilities.HAS_PERFORMANCE_NOW = false;
231
+ AMDLoader.Utilities = Utilities;
232
+ })(AMDLoader || (AMDLoader = {}));
233
+ /*---------------------------------------------------------------------------------------------
234
+ * Copyright (c) Microsoft Corporation. All rights reserved.
235
+ * Licensed under the MIT License. See License.txt in the project root for license information.
236
+ *--------------------------------------------------------------------------------------------*/
237
+ var AMDLoader;
238
+ (function (AMDLoader) {
239
+ var ConfigurationOptionsUtil = (function () {
240
+ function ConfigurationOptionsUtil() {
241
+ }
242
+ /**
243
+ * Ensure configuration options make sense
244
+ */
245
+ ConfigurationOptionsUtil.validateConfigurationOptions = function (options) {
246
+ function defaultOnError(err) {
247
+ if (err.errorCode === 'load') {
248
+ console.error('Loading "' + err.moduleId + '" failed');
249
+ console.error('Detail: ', err.detail);
250
+ if (err.detail && err.detail.stack) {
251
+ console.error(err.detail.stack);
252
+ }
253
+ console.error('Here are the modules that depend on it:');
254
+ console.error(err.neededBy);
255
+ return;
256
+ }
257
+ if (err.errorCode === 'factory') {
258
+ console.error('The factory method of "' + err.moduleId + '" has thrown an exception');
259
+ console.error(err.detail);
260
+ if (err.detail && err.detail.stack) {
261
+ console.error(err.detail.stack);
262
+ }
263
+ return;
264
+ }
265
+ }
266
+ options = options || {};
267
+ if (typeof options.baseUrl !== 'string') {
268
+ options.baseUrl = '';
269
+ }
270
+ if (typeof options.isBuild !== 'boolean') {
271
+ options.isBuild = false;
272
+ }
273
+ if (typeof options.paths !== 'object') {
274
+ options.paths = {};
275
+ }
276
+ if (typeof options.config !== 'object') {
277
+ options.config = {};
278
+ }
279
+ if (typeof options.catchError === 'undefined') {
280
+ options.catchError = false;
281
+ }
282
+ if (typeof options.urlArgs !== 'string') {
283
+ options.urlArgs = '';
284
+ }
285
+ if (typeof options.onError !== 'function') {
286
+ options.onError = defaultOnError;
287
+ }
288
+ if (typeof options.ignoreDuplicateModules !== 'object' || !Array.isArray(options.ignoreDuplicateModules)) {
289
+ options.ignoreDuplicateModules = [];
290
+ }
291
+ if (options.baseUrl.length > 0) {
292
+ if (!AMDLoader.Utilities.endsWith(options.baseUrl, '/')) {
293
+ options.baseUrl += '/';
294
+ }
295
+ }
296
+ if (typeof options.cspNonce !== 'string') {
297
+ options.cspNonce = '';
298
+ }
299
+ if (!Array.isArray(options.nodeModules)) {
300
+ options.nodeModules = [];
301
+ }
302
+ if (typeof options.nodeCachedData === 'object') {
303
+ if (typeof options.nodeCachedData.seed !== 'string') {
304
+ options.nodeCachedData.seed = 'seed';
305
+ }
306
+ if (typeof options.nodeCachedData.writeDelay !== 'number' || options.nodeCachedData.writeDelay < 0) {
307
+ options.nodeCachedData.writeDelay = 1000 * 7;
308
+ }
309
+ if (typeof options.nodeCachedData.onData !== 'function') {
310
+ options.nodeCachedData.onData = function (err) {
311
+ if (err && err.errorCode === 'cachedDataRejected') {
312
+ console.warn('Rejected cached data from file: ' + err.path);
313
+ }
314
+ else if (err && err.errorCode) {
315
+ console.error('Problems handling cached data file: ' + err.path);
316
+ console.error(err.detail);
317
+ }
318
+ else if (err) {
319
+ console.error(err);
320
+ }
321
+ };
322
+ }
323
+ if (!options.nodeCachedData.path || typeof options.nodeCachedData.path !== 'string') {
324
+ options.nodeCachedData.onData('INVALID cached data configuration, \'path\' MUST be set');
325
+ options.nodeCachedData = undefined;
326
+ }
327
+ }
328
+ return options;
329
+ };
330
+ ConfigurationOptionsUtil.mergeConfigurationOptions = function (overwrite, base) {
331
+ if (overwrite === void 0) { overwrite = null; }
332
+ if (base === void 0) { base = null; }
333
+ var result = AMDLoader.Utilities.recursiveClone(base || {});
334
+ // Merge known properties and overwrite the unknown ones
335
+ AMDLoader.Utilities.forEachProperty(overwrite, function (key, value) {
336
+ if (key === 'ignoreDuplicateModules' && typeof result.ignoreDuplicateModules !== 'undefined') {
337
+ result.ignoreDuplicateModules = result.ignoreDuplicateModules.concat(value);
338
+ }
339
+ else if (key === 'paths' && typeof result.paths !== 'undefined') {
340
+ AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.paths[key2] = value2; });
341
+ }
342
+ else if (key === 'config' && typeof result.config !== 'undefined') {
343
+ AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.config[key2] = value2; });
344
+ }
345
+ else {
346
+ result[key] = AMDLoader.Utilities.recursiveClone(value);
347
+ }
348
+ });
349
+ return ConfigurationOptionsUtil.validateConfigurationOptions(result);
350
+ };
351
+ return ConfigurationOptionsUtil;
352
+ }());
353
+ AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil;
354
+ var Configuration = (function () {
355
+ function Configuration(env, options) {
356
+ this._env = env;
357
+ this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);
358
+ this._createIgnoreDuplicateModulesMap();
359
+ this._createNodeModulesMap();
360
+ this._createSortedPathsRules();
361
+ if (this.options.baseUrl === '') {
362
+ if (this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename && this._env.isNode) {
363
+ var nodeMain = this.options.nodeRequire.main.filename;
364
+ var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
365
+ this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
366
+ }
367
+ if (this.options.nodeMain && this._env.isNode) {
368
+ var nodeMain = this.options.nodeMain;
369
+ var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
370
+ this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
371
+ }
372
+ }
373
+ }
374
+ Configuration.prototype._createIgnoreDuplicateModulesMap = function () {
375
+ // Build a map out of the ignoreDuplicateModules array
376
+ this.ignoreDuplicateModulesMap = {};
377
+ for (var i = 0; i < this.options.ignoreDuplicateModules.length; i++) {
378
+ this.ignoreDuplicateModulesMap[this.options.ignoreDuplicateModules[i]] = true;
379
+ }
380
+ };
381
+ Configuration.prototype._createNodeModulesMap = function () {
382
+ // Build a map out of nodeModules array
383
+ this.nodeModulesMap = Object.create(null);
384
+ for (var _i = 0, _a = this.options.nodeModules; _i < _a.length; _i++) {
385
+ var nodeModule = _a[_i];
386
+ this.nodeModulesMap[nodeModule] = true;
387
+ }
388
+ };
389
+ Configuration.prototype._createSortedPathsRules = function () {
390
+ var _this = this;
391
+ // Create an array our of the paths rules, sorted descending by length to
392
+ // result in a more specific -> less specific order
393
+ this.sortedPathsRules = [];
394
+ AMDLoader.Utilities.forEachProperty(this.options.paths, function (from, to) {
395
+ if (!Array.isArray(to)) {
396
+ _this.sortedPathsRules.push({
397
+ from: from,
398
+ to: [to]
399
+ });
400
+ }
401
+ else {
402
+ _this.sortedPathsRules.push({
403
+ from: from,
404
+ to: to
405
+ });
406
+ }
407
+ });
408
+ this.sortedPathsRules.sort(function (a, b) {
409
+ return b.from.length - a.from.length;
410
+ });
411
+ };
412
+ /**
413
+ * Clone current configuration and overwrite options selectively.
414
+ * @param options The selective options to overwrite with.
415
+ * @result A new configuration
416
+ */
417
+ Configuration.prototype.cloneAndMerge = function (options) {
418
+ return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(options, this.options));
419
+ };
420
+ /**
421
+ * Get current options bag. Useful for passing it forward to plugins.
422
+ */
423
+ Configuration.prototype.getOptionsLiteral = function () {
424
+ return this.options;
425
+ };
426
+ Configuration.prototype._applyPaths = function (moduleId) {
427
+ var pathRule;
428
+ for (var i = 0, len = this.sortedPathsRules.length; i < len; i++) {
429
+ pathRule = this.sortedPathsRules[i];
430
+ if (AMDLoader.Utilities.startsWith(moduleId, pathRule.from)) {
431
+ var result = [];
432
+ for (var j = 0, lenJ = pathRule.to.length; j < lenJ; j++) {
433
+ result.push(pathRule.to[j] + moduleId.substr(pathRule.from.length));
434
+ }
435
+ return result;
436
+ }
437
+ }
438
+ return [moduleId];
439
+ };
440
+ Configuration.prototype._addUrlArgsToUrl = function (url) {
441
+ if (AMDLoader.Utilities.containsQueryString(url)) {
442
+ return url + '&' + this.options.urlArgs;
443
+ }
444
+ else {
445
+ return url + '?' + this.options.urlArgs;
446
+ }
447
+ };
448
+ Configuration.prototype._addUrlArgsIfNecessaryToUrl = function (url) {
449
+ if (this.options.urlArgs) {
450
+ return this._addUrlArgsToUrl(url);
451
+ }
452
+ return url;
453
+ };
454
+ Configuration.prototype._addUrlArgsIfNecessaryToUrls = function (urls) {
455
+ if (this.options.urlArgs) {
456
+ for (var i = 0, len = urls.length; i < len; i++) {
457
+ urls[i] = this._addUrlArgsToUrl(urls[i]);
458
+ }
459
+ }
460
+ return urls;
461
+ };
462
+ /**
463
+ * Transform a module id to a location. Appends .js to module ids
464
+ */
465
+ Configuration.prototype.moduleIdToPaths = function (moduleId) {
466
+ if (this.nodeModulesMap[moduleId] === true) {
467
+ // This is a node module...
468
+ if (this.isBuild()) {
469
+ // ...and we are at build time, drop it
470
+ return ['empty:'];
471
+ }
472
+ else {
473
+ // ...and at runtime we create a `shortcut`-path
474
+ return ['node|' + moduleId];
475
+ }
476
+ }
477
+ var result = moduleId;
478
+ var results;
479
+ if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.isAbsolutePath(result)) {
480
+ results = this._applyPaths(result);
481
+ for (var i = 0, len = results.length; i < len; i++) {
482
+ if (this.isBuild() && results[i] === 'empty:') {
483
+ continue;
484
+ }
485
+ if (!AMDLoader.Utilities.isAbsolutePath(results[i])) {
486
+ results[i] = this.options.baseUrl + results[i];
487
+ }
488
+ if (!AMDLoader.Utilities.endsWith(results[i], '.js') && !AMDLoader.Utilities.containsQueryString(results[i])) {
489
+ results[i] = results[i] + '.js';
490
+ }
491
+ }
492
+ }
493
+ else {
494
+ if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.containsQueryString(result)) {
495
+ result = result + '.js';
496
+ }
497
+ results = [result];
498
+ }
499
+ return this._addUrlArgsIfNecessaryToUrls(results);
500
+ };
501
+ /**
502
+ * Transform a module id or url to a location.
503
+ */
504
+ Configuration.prototype.requireToUrl = function (url) {
505
+ var result = url;
506
+ if (!AMDLoader.Utilities.isAbsolutePath(result)) {
507
+ result = this._applyPaths(result)[0];
508
+ if (!AMDLoader.Utilities.isAbsolutePath(result)) {
509
+ result = this.options.baseUrl + result;
510
+ }
511
+ }
512
+ return this._addUrlArgsIfNecessaryToUrl(result);
513
+ };
514
+ /**
515
+ * Flag to indicate if current execution is as part of a build.
516
+ */
517
+ Configuration.prototype.isBuild = function () {
518
+ return this.options.isBuild;
519
+ };
520
+ /**
521
+ * Test if module `moduleId` is expected to be defined multiple times
522
+ */
523
+ Configuration.prototype.isDuplicateMessageIgnoredFor = function (moduleId) {
524
+ return this.ignoreDuplicateModulesMap.hasOwnProperty(moduleId);
525
+ };
526
+ /**
527
+ * Get the configuration settings for the provided module id
528
+ */
529
+ Configuration.prototype.getConfigForModule = function (moduleId) {
530
+ if (this.options.config) {
531
+ return this.options.config[moduleId];
532
+ }
533
+ };
534
+ /**
535
+ * Should errors be caught when executing module factories?
536
+ */
537
+ Configuration.prototype.shouldCatchError = function () {
538
+ return this.options.catchError;
539
+ };
540
+ /**
541
+ * Should statistics be recorded?
542
+ */
543
+ Configuration.prototype.shouldRecordStats = function () {
544
+ return this.options.recordStats;
545
+ };
546
+ /**
547
+ * Forward an error to the error handler.
548
+ */
549
+ Configuration.prototype.onError = function (err) {
550
+ this.options.onError(err);
551
+ };
552
+ return Configuration;
553
+ }());
554
+ AMDLoader.Configuration = Configuration;
555
+ })(AMDLoader || (AMDLoader = {}));
556
+ /*---------------------------------------------------------------------------------------------
557
+ * Copyright (c) Microsoft Corporation. All rights reserved.
558
+ * Licensed under the MIT License. See License.txt in the project root for license information.
559
+ *--------------------------------------------------------------------------------------------*/
560
+ var AMDLoader;
561
+ (function (AMDLoader) {
562
+ /**
563
+ * Load `scriptSrc` only once (avoid multiple <script> tags)
564
+ */
565
+ var OnlyOnceScriptLoader = (function () {
566
+ function OnlyOnceScriptLoader(env) {
567
+ this._env = env;
568
+ this._scriptLoader = null;
569
+ this._callbackMap = {};
570
+ }
571
+ OnlyOnceScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
572
+ var _this = this;
573
+ if (!this._scriptLoader) {
574
+ this._scriptLoader = (this._env.isWebWorker
575
+ ? new WorkerScriptLoader()
576
+ : this._env.isNode
577
+ ? new NodeScriptLoader(this._env)
578
+ : new BrowserScriptLoader());
579
+ }
580
+ var scriptCallbacks = {
581
+ callback: callback,
582
+ errorback: errorback
583
+ };
584
+ if (this._callbackMap.hasOwnProperty(scriptSrc)) {
585
+ this._callbackMap[scriptSrc].push(scriptCallbacks);
586
+ return;
587
+ }
588
+ this._callbackMap[scriptSrc] = [scriptCallbacks];
589
+ this._scriptLoader.load(moduleManager, scriptSrc, function () { return _this.triggerCallback(scriptSrc); }, function (err) { return _this.triggerErrorback(scriptSrc, err); });
590
+ };
591
+ OnlyOnceScriptLoader.prototype.triggerCallback = function (scriptSrc) {
592
+ var scriptCallbacks = this._callbackMap[scriptSrc];
593
+ delete this._callbackMap[scriptSrc];
594
+ for (var i = 0; i < scriptCallbacks.length; i++) {
595
+ scriptCallbacks[i].callback();
596
+ }
597
+ };
598
+ OnlyOnceScriptLoader.prototype.triggerErrorback = function (scriptSrc, err) {
599
+ var scriptCallbacks = this._callbackMap[scriptSrc];
600
+ delete this._callbackMap[scriptSrc];
601
+ for (var i = 0; i < scriptCallbacks.length; i++) {
602
+ scriptCallbacks[i].errorback(err);
603
+ }
604
+ };
605
+ return OnlyOnceScriptLoader;
606
+ }());
607
+ var BrowserScriptLoader = (function () {
608
+ function BrowserScriptLoader() {
609
+ }
610
+ /**
611
+ * Attach load / error listeners to a script element and remove them when either one has fired.
612
+ * Implemented for browssers supporting HTML5 standard 'load' and 'error' events.
613
+ */
614
+ BrowserScriptLoader.prototype.attachListeners = function (script, callback, errorback) {
615
+ var unbind = function () {
616
+ script.removeEventListener('load', loadEventListener);
617
+ script.removeEventListener('error', errorEventListener);
618
+ };
619
+ var loadEventListener = function (e) {
620
+ unbind();
621
+ callback();
622
+ };
623
+ var errorEventListener = function (e) {
624
+ unbind();
625
+ errorback(e);
626
+ };
627
+ script.addEventListener('load', loadEventListener);
628
+ script.addEventListener('error', errorEventListener);
629
+ };
630
+ BrowserScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
631
+ var script = document.createElement('script');
632
+ script.setAttribute('async', 'async');
633
+ script.setAttribute('type', 'text/javascript');
634
+ this.attachListeners(script, callback, errorback);
635
+ script.setAttribute('src', scriptSrc);
636
+ // Propagate CSP nonce to dynamically created script tag.
637
+ var cspNonce = moduleManager.getConfig().getOptionsLiteral().cspNonce;
638
+ if (cspNonce) {
639
+ script.setAttribute('nonce', cspNonce);
640
+ }
641
+ document.getElementsByTagName('head')[0].appendChild(script);
642
+ };
643
+ return BrowserScriptLoader;
644
+ }());
645
+ var WorkerScriptLoader = (function () {
646
+ function WorkerScriptLoader() {
647
+ }
648
+ WorkerScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
649
+ try {
650
+ importScripts(scriptSrc);
651
+ callback();
652
+ }
653
+ catch (e) {
654
+ errorback(e);
655
+ }
656
+ };
657
+ return WorkerScriptLoader;
658
+ }());
659
+ var NodeScriptLoader = (function () {
660
+ function NodeScriptLoader(env) {
661
+ this._env = env;
662
+ this._didInitialize = false;
663
+ this._didPatchNodeRequire = false;
664
+ this._hasCreateCachedData = false;
665
+ }
666
+ NodeScriptLoader.prototype._init = function (nodeRequire) {
667
+ if (this._didInitialize) {
668
+ return;
669
+ }
670
+ this._didInitialize = true;
671
+ // capture node modules
672
+ this._fs = nodeRequire('fs');
673
+ this._vm = nodeRequire('vm');
674
+ this._path = nodeRequire('path');
675
+ this._crypto = nodeRequire('crypto');
676
+ // check for `createCachedData`-api
677
+ this._hasCreateCachedData = typeof (new this._vm.Script('').createCachedData) === 'function';
678
+ };
679
+ // patch require-function of nodejs such that we can manually create a script
680
+ // from cached data. this is done by overriding the `Module._compile` function
681
+ NodeScriptLoader.prototype._initNodeRequire = function (nodeRequire, moduleManager) {
682
+ var nodeCachedData = moduleManager.getConfig().getOptionsLiteral().nodeCachedData;
683
+ if (!nodeCachedData || this._didPatchNodeRequire) {
684
+ return;
685
+ }
686
+ this._didPatchNodeRequire = true;
687
+ var that = this;
688
+ var Module = nodeRequire('module');
689
+ function makeRequireFunction(mod) {
690
+ var Module = mod.constructor;
691
+ var require = function require(path) {
692
+ try {
693
+ return mod.require(path);
694
+ }
695
+ finally {
696
+ // nothing
697
+ }
698
+ };
699
+ require.resolve = function resolve(request) {
700
+ return Module._resolveFilename(request, mod);
701
+ };
702
+ require.main = process.mainModule;
703
+ require.extensions = Module._extensions;
704
+ require.cache = Module._cache;
705
+ return require;
706
+ }
707
+ Module.prototype._compile = function (content, filename) {
708
+ // remove shebang
709
+ content = content.replace(/^#!.*/, '');
710
+ // create wrapper function
711
+ var wrapper = Module.wrap(content);
712
+ var cachedDataPath = that._getCachedDataPath(nodeCachedData.seed, nodeCachedData.path, filename);
713
+ var options = { filename: filename };
714
+ try {
715
+ options.cachedData = that._fs.readFileSync(cachedDataPath);
716
+ }
717
+ catch (e) {
718
+ options.produceCachedData = !that._hasCreateCachedData;
719
+ }
720
+ var script = new that._vm.Script(wrapper, options);
721
+ var compileWrapper = script.runInThisContext(options);
722
+ var dirname = that._path.dirname(filename);
723
+ var require = makeRequireFunction(this);
724
+ var args = [this.exports, require, this, filename, dirname, process, _commonjsGlobal, Buffer];
725
+ var result = compileWrapper.apply(this.exports, args);
726
+ that._processCachedData(moduleManager, script, wrapper, cachedDataPath, !options.cachedData);
727
+ return result;
728
+ };
729
+ };
730
+ NodeScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
731
+ var _this = this;
732
+ var opts = moduleManager.getConfig().getOptionsLiteral();
733
+ var nodeRequire = (opts.nodeRequire || AMDLoader.global.nodeRequire);
734
+ var nodeInstrumenter = (opts.nodeInstrumenter || function (c) { return c; });
735
+ this._init(nodeRequire);
736
+ this._initNodeRequire(nodeRequire, moduleManager);
737
+ var recorder = moduleManager.getRecorder();
738
+ if (/^node\|/.test(scriptSrc)) {
739
+ var pieces = scriptSrc.split('|');
740
+ var moduleExports_1 = null;
741
+ try {
742
+ moduleExports_1 = nodeRequire(pieces[1]);
743
+ }
744
+ catch (err) {
745
+ errorback(err);
746
+ return;
747
+ }
748
+ moduleManager.enqueueDefineAnonymousModule([], function () { return moduleExports_1; });
749
+ callback();
750
+ }
751
+ else {
752
+ scriptSrc = AMDLoader.Utilities.fileUriToFilePath(this._env.isWindows, scriptSrc);
753
+ this._fs.readFile(scriptSrc, { encoding: 'utf8' }, function (err, data) {
754
+ if (err) {
755
+ errorback(err);
756
+ return;
757
+ }
758
+ var normalizedScriptSrc = _this._path.normalize(scriptSrc);
759
+ var vmScriptSrc = normalizedScriptSrc;
760
+ // Make the script src friendly towards electron
761
+ if (_this._env.isElectronRenderer) {
762
+ var driveLetterMatch = vmScriptSrc.match(/^([a-z])\:(.*)/i);
763
+ if (driveLetterMatch) {
764
+ // windows
765
+ vmScriptSrc = "file:///" + (driveLetterMatch[1].toUpperCase() + ':' + driveLetterMatch[2]).replace(/\\/g, '/');
766
+ }
767
+ else {
768
+ // nix
769
+ vmScriptSrc = "file://" + vmScriptSrc;
770
+ }
771
+ }
772
+ var contents, prefix = '(function (require, define, __filename, __dirname) { ', suffix = '\n});';
773
+ if (data.charCodeAt(0) === NodeScriptLoader._BOM) {
774
+ contents = prefix + data.substring(1) + suffix;
775
+ }
776
+ else {
777
+ contents = prefix + data + suffix;
778
+ }
779
+ contents = nodeInstrumenter(contents, normalizedScriptSrc);
780
+ if (!opts.nodeCachedData) {
781
+ _this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, { filename: vmScriptSrc }, recorder, callback, errorback);
782
+ }
783
+ else {
784
+ var cachedDataPath_1 = _this._getCachedDataPath(opts.nodeCachedData.seed, opts.nodeCachedData.path, scriptSrc);
785
+ _this._fs.readFile(cachedDataPath_1, function (_err, cachedData) {
786
+ // create script options
787
+ var options = {
788
+ filename: vmScriptSrc,
789
+ produceCachedData: !_this._hasCreateCachedData && typeof cachedData === 'undefined',
790
+ cachedData: cachedData
791
+ };
792
+ var script = _this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder, callback, errorback);
793
+ _this._processCachedData(moduleManager, script, contents, cachedDataPath_1, !options.cachedData);
794
+ });
795
+ }
796
+ });
797
+ }
798
+ };
799
+ NodeScriptLoader.prototype._loadAndEvalScript = function (moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder, callback, errorback) {
800
+ // create script, run script
801
+ recorder.record(31 /* NodeBeginEvaluatingScript */, scriptSrc);
802
+ var script = new this._vm.Script(contents, options);
803
+ var r = script.runInThisContext(options);
804
+ var globalDefineFunc = moduleManager.getGlobalAMDDefineFunc();
805
+ var receivedDefineCall = false;
806
+ var localDefineFunc = function () {
807
+ receivedDefineCall = true;
808
+ return globalDefineFunc.apply(null, arguments);
809
+ };
810
+ localDefineFunc.amd = globalDefineFunc.amd;
811
+ r.call(AMDLoader.global, moduleManager.getGlobalAMDRequireFunc(), localDefineFunc, vmScriptSrc, this._path.dirname(scriptSrc));
812
+ // signal done
813
+ recorder.record(32 /* NodeEndEvaluatingScript */, scriptSrc);
814
+ if (receivedDefineCall) {
815
+ callback();
816
+ }
817
+ else {
818
+ errorback(new Error("Didn't receive define call in " + scriptSrc + "!"));
819
+ }
820
+ return script;
821
+ };
822
+ NodeScriptLoader.prototype._getCachedDataPath = function (seed, basedir, filename) {
823
+ var hash = this._crypto.createHash('md5').update(filename, 'utf8').update(seed, 'utf8').digest('hex');
824
+ var basename = this._path.basename(filename).replace(/\.js$/, '');
825
+ return this._path.join(basedir, basename + "-" + hash + ".code");
826
+ };
827
+ NodeScriptLoader.prototype._processCachedData = function (moduleManager, script, contents, cachedDataPath, createCachedData) {
828
+ var _this = this;
829
+ if (script.cachedDataRejected) {
830
+ // data rejected => delete cache file
831
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData({
832
+ errorCode: 'cachedDataRejected',
833
+ path: cachedDataPath
834
+ });
835
+ NodeScriptLoader._runSoon(function () {
836
+ return _this._fs.unlink(cachedDataPath, function (err) {
837
+ if (err) {
838
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData({
839
+ errorCode: 'unlink',
840
+ path: cachedDataPath,
841
+ detail: err
842
+ });
843
+ }
844
+ });
845
+ }, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay / 2);
846
+ }
847
+ else if (script.cachedDataProduced) {
848
+ // data produced => tell outside world
849
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData(undefined, {
850
+ path: cachedDataPath
851
+ });
852
+ // data produced => write cache file
853
+ NodeScriptLoader._runSoon(function () {
854
+ return _this._fs.writeFile(cachedDataPath, script.cachedData, function (err) {
855
+ if (err) {
856
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData({
857
+ errorCode: 'writeFile',
858
+ path: cachedDataPath,
859
+ detail: err
860
+ });
861
+ }
862
+ });
863
+ }, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay);
864
+ }
865
+ else if (this._hasCreateCachedData && createCachedData) {
866
+ // NEW world
867
+ // data produced => tell outside world
868
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData(undefined, {
869
+ path: cachedDataPath
870
+ });
871
+ // soon'ish create and save cached data
872
+ NodeScriptLoader._runSoon(function () {
873
+ var data = script.createCachedData(contents);
874
+ _this._fs.writeFile(cachedDataPath, data, function (err) {
875
+ if (!err) {
876
+ return;
877
+ }
878
+ moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData({
879
+ errorCode: 'writeFile',
880
+ path: cachedDataPath,
881
+ detail: err
882
+ });
883
+ });
884
+ }, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay);
885
+ }
886
+ };
887
+ NodeScriptLoader._runSoon = function (callback, minTimeout) {
888
+ var timeout = minTimeout + Math.ceil(Math.random() * minTimeout);
889
+ setTimeout(callback, timeout);
890
+ };
891
+ return NodeScriptLoader;
892
+ }());
893
+ NodeScriptLoader._BOM = 0xFEFF;
894
+ function createScriptLoader(env) {
895
+ return new OnlyOnceScriptLoader(env);
896
+ }
897
+ AMDLoader.createScriptLoader = createScriptLoader;
898
+ })(AMDLoader || (AMDLoader = {}));
899
+ /*---------------------------------------------------------------------------------------------
900
+ * Copyright (c) Microsoft Corporation. All rights reserved.
901
+ * Licensed under the MIT License. See License.txt in the project root for license information.
902
+ *--------------------------------------------------------------------------------------------*/
903
+ var AMDLoader;
904
+ (function (AMDLoader) {
905
+ // ------------------------------------------------------------------------
906
+ // ModuleIdResolver
907
+ var ModuleIdResolver = (function () {
908
+ function ModuleIdResolver(fromModuleId) {
909
+ var lastSlash = fromModuleId.lastIndexOf('/');
910
+ if (lastSlash !== -1) {
911
+ this.fromModulePath = fromModuleId.substr(0, lastSlash + 1);
912
+ }
913
+ else {
914
+ this.fromModulePath = '';
915
+ }
916
+ }
917
+ /**
918
+ * Normalize 'a/../name' to 'name', etc.
919
+ */
920
+ ModuleIdResolver._normalizeModuleId = function (moduleId) {
921
+ var r = moduleId, pattern;
922
+ // replace /./ => /
923
+ pattern = /\/\.\//;
924
+ while (pattern.test(r)) {
925
+ r = r.replace(pattern, '/');
926
+ }
927
+ // replace ^./ => nothing
928
+ r = r.replace(/^\.\//g, '');
929
+ // replace /aa/../ => / (BUT IGNORE /../../)
930
+ pattern = /\/(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//;
931
+ while (pattern.test(r)) {
932
+ r = r.replace(pattern, '/');
933
+ }
934
+ // replace ^aa/../ => nothing (BUT IGNORE ../../)
935
+ r = r.replace(/^(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//, '');
936
+ return r;
937
+ };
938
+ /**
939
+ * Resolve relative module ids
940
+ */
941
+ ModuleIdResolver.prototype.resolveModule = function (moduleId) {
942
+ var result = moduleId;
943
+ if (!AMDLoader.Utilities.isAbsolutePath(result)) {
944
+ if (AMDLoader.Utilities.startsWith(result, './') || AMDLoader.Utilities.startsWith(result, '../')) {
945
+ result = ModuleIdResolver._normalizeModuleId(this.fromModulePath + result);
946
+ }
947
+ }
948
+ return result;
949
+ };
950
+ return ModuleIdResolver;
951
+ }());
952
+ ModuleIdResolver.ROOT = new ModuleIdResolver('');
953
+ AMDLoader.ModuleIdResolver = ModuleIdResolver;
954
+ // ------------------------------------------------------------------------
955
+ // Module
956
+ var Module = (function () {
957
+ function Module(id, strId, dependencies, callback, errorback, moduleIdResolver) {
958
+ this.id = id;
959
+ this.strId = strId;
960
+ this.dependencies = dependencies;
961
+ this._callback = callback;
962
+ this._errorback = errorback;
963
+ this.moduleIdResolver = moduleIdResolver;
964
+ this.exports = {};
965
+ this.exportsPassedIn = false;
966
+ this.unresolvedDependenciesCount = this.dependencies.length;
967
+ this._isComplete = false;
968
+ }
969
+ Module._safeInvokeFunction = function (callback, args) {
970
+ try {
971
+ return {
972
+ returnedValue: callback.apply(AMDLoader.global, args),
973
+ producedError: null
974
+ };
975
+ }
976
+ catch (e) {
977
+ return {
978
+ returnedValue: null,
979
+ producedError: e
980
+ };
981
+ }
982
+ };
983
+ Module._invokeFactory = function (config, strModuleId, callback, dependenciesValues) {
984
+ if (config.isBuild() && !AMDLoader.Utilities.isAnonymousModule(strModuleId)) {
985
+ return {
986
+ returnedValue: null,
987
+ producedError: null
988
+ };
989
+ }
990
+ if (config.shouldCatchError()) {
991
+ return this._safeInvokeFunction(callback, dependenciesValues);
992
+ }
993
+ return {
994
+ returnedValue: callback.apply(AMDLoader.global, dependenciesValues),
995
+ producedError: null
996
+ };
997
+ };
998
+ Module.prototype.complete = function (recorder, config, dependenciesValues) {
999
+ this._isComplete = true;
1000
+ var producedError = null;
1001
+ if (this._callback) {
1002
+ if (typeof this._callback === 'function') {
1003
+ recorder.record(21 /* BeginInvokeFactory */, this.strId);
1004
+ var r = Module._invokeFactory(config, this.strId, this._callback, dependenciesValues);
1005
+ producedError = r.producedError;
1006
+ recorder.record(22 /* EndInvokeFactory */, this.strId);
1007
+ if (!producedError && typeof r.returnedValue !== 'undefined' && (!this.exportsPassedIn || AMDLoader.Utilities.isEmpty(this.exports))) {
1008
+ this.exports = r.returnedValue;
1009
+ }
1010
+ }
1011
+ else {
1012
+ this.exports = this._callback;
1013
+ }
1014
+ }
1015
+ if (producedError) {
1016
+ config.onError({
1017
+ errorCode: 'factory',
1018
+ moduleId: this.strId,
1019
+ detail: producedError
1020
+ });
1021
+ }
1022
+ this.dependencies = null;
1023
+ this._callback = null;
1024
+ this._errorback = null;
1025
+ this.moduleIdResolver = null;
1026
+ };
1027
+ /**
1028
+ * One of the direct dependencies or a transitive dependency has failed to load.
1029
+ */
1030
+ Module.prototype.onDependencyError = function (err) {
1031
+ if (this._errorback) {
1032
+ this._errorback(err);
1033
+ return true;
1034
+ }
1035
+ return false;
1036
+ };
1037
+ /**
1038
+ * Is the current module complete?
1039
+ */
1040
+ Module.prototype.isComplete = function () {
1041
+ return this._isComplete;
1042
+ };
1043
+ return Module;
1044
+ }());
1045
+ AMDLoader.Module = Module;
1046
+ var ModuleIdProvider = (function () {
1047
+ function ModuleIdProvider() {
1048
+ this._nextId = 0;
1049
+ this._strModuleIdToIntModuleId = new Map();
1050
+ this._intModuleIdToStrModuleId = [];
1051
+ // Ensure values 0, 1, 2 are assigned accordingly with ModuleId
1052
+ this.getModuleId('exports');
1053
+ this.getModuleId('module');
1054
+ this.getModuleId('require');
1055
+ }
1056
+ ModuleIdProvider.prototype.getMaxModuleId = function () {
1057
+ return this._nextId;
1058
+ };
1059
+ ModuleIdProvider.prototype.getModuleId = function (strModuleId) {
1060
+ var id = this._strModuleIdToIntModuleId.get(strModuleId);
1061
+ if (typeof id === 'undefined') {
1062
+ id = this._nextId++;
1063
+ this._strModuleIdToIntModuleId.set(strModuleId, id);
1064
+ this._intModuleIdToStrModuleId[id] = strModuleId;
1065
+ }
1066
+ return id;
1067
+ };
1068
+ ModuleIdProvider.prototype.getStrModuleId = function (moduleId) {
1069
+ return this._intModuleIdToStrModuleId[moduleId];
1070
+ };
1071
+ return ModuleIdProvider;
1072
+ }());
1073
+ var RegularDependency = (function () {
1074
+ function RegularDependency(id) {
1075
+ this.id = id;
1076
+ }
1077
+ return RegularDependency;
1078
+ }());
1079
+ RegularDependency.EXPORTS = new RegularDependency(0 /* EXPORTS */);
1080
+ RegularDependency.MODULE = new RegularDependency(1 /* MODULE */);
1081
+ RegularDependency.REQUIRE = new RegularDependency(2 /* REQUIRE */);
1082
+ AMDLoader.RegularDependency = RegularDependency;
1083
+ var PluginDependency = (function () {
1084
+ function PluginDependency(id, pluginId, pluginParam) {
1085
+ this.id = id;
1086
+ this.pluginId = pluginId;
1087
+ this.pluginParam = pluginParam;
1088
+ }
1089
+ return PluginDependency;
1090
+ }());
1091
+ AMDLoader.PluginDependency = PluginDependency;
1092
+ var ModuleManager = (function () {
1093
+ function ModuleManager(env, scriptLoader, defineFunc, requireFunc, loaderAvailableTimestamp) {
1094
+ if (loaderAvailableTimestamp === void 0) { loaderAvailableTimestamp = 0; }
1095
+ this._env = env;
1096
+ this._scriptLoader = scriptLoader;
1097
+ this._loaderAvailableTimestamp = loaderAvailableTimestamp;
1098
+ this._defineFunc = defineFunc;
1099
+ this._requireFunc = requireFunc;
1100
+ this._moduleIdProvider = new ModuleIdProvider();
1101
+ this._config = new AMDLoader.Configuration(this._env);
1102
+ this._modules2 = [];
1103
+ this._knownModules2 = [];
1104
+ this._inverseDependencies2 = [];
1105
+ this._inversePluginDependencies2 = new Map();
1106
+ this._currentAnnonymousDefineCall = null;
1107
+ this._recorder = null;
1108
+ this._buildInfoPath = [];
1109
+ this._buildInfoDefineStack = [];
1110
+ this._buildInfoDependencies = [];
1111
+ }
1112
+ ModuleManager.prototype.reset = function () {
1113
+ return new ModuleManager(this._env, this._scriptLoader, this._defineFunc, this._requireFunc, this._loaderAvailableTimestamp);
1114
+ };
1115
+ ModuleManager.prototype.getGlobalAMDDefineFunc = function () {
1116
+ return this._defineFunc;
1117
+ };
1118
+ ModuleManager.prototype.getGlobalAMDRequireFunc = function () {
1119
+ return this._requireFunc;
1120
+ };
1121
+ ModuleManager._findRelevantLocationInStack = function (needle, stack) {
1122
+ var normalize = function (str) { return str.replace(/\\/g, '/'); };
1123
+ var normalizedPath = normalize(needle);
1124
+ var stackPieces = stack.split(/\n/);
1125
+ for (var i = 0; i < stackPieces.length; i++) {
1126
+ var m = stackPieces[i].match(/(.*):(\d+):(\d+)\)?$/);
1127
+ if (m) {
1128
+ var stackPath = m[1];
1129
+ var stackLine = m[2];
1130
+ var stackColumn = m[3];
1131
+ var trimPathOffset = Math.max(stackPath.lastIndexOf(' ') + 1, stackPath.lastIndexOf('(') + 1);
1132
+ stackPath = stackPath.substr(trimPathOffset);
1133
+ stackPath = normalize(stackPath);
1134
+ if (stackPath === normalizedPath) {
1135
+ var r = {
1136
+ line: parseInt(stackLine, 10),
1137
+ col: parseInt(stackColumn, 10)
1138
+ };
1139
+ if (r.line === 1) {
1140
+ r.col -= '(function (require, define, __filename, __dirname) { '.length;
1141
+ }
1142
+ return r;
1143
+ }
1144
+ }
1145
+ }
1146
+ throw new Error('Could not correlate define call site for needle ' + needle);
1147
+ };
1148
+ ModuleManager.prototype.getBuildInfo = function () {
1149
+ if (!this._config.isBuild()) {
1150
+ return null;
1151
+ }
1152
+ var result = [], resultLen = 0;
1153
+ for (var i = 0, len = this._modules2.length; i < len; i++) {
1154
+ var m = this._modules2[i];
1155
+ if (!m) {
1156
+ continue;
1157
+ }
1158
+ var location_1 = this._buildInfoPath[m.id] || null;
1159
+ var defineStack = this._buildInfoDefineStack[m.id] || null;
1160
+ var dependencies = this._buildInfoDependencies[m.id];
1161
+ result[resultLen++] = {
1162
+ id: m.strId,
1163
+ path: location_1,
1164
+ defineLocation: (location_1 && defineStack ? ModuleManager._findRelevantLocationInStack(location_1, defineStack) : null),
1165
+ dependencies: dependencies,
1166
+ shim: null,
1167
+ exports: m.exports
1168
+ };
1169
+ }
1170
+ return result;
1171
+ };
1172
+ ModuleManager.prototype.getRecorder = function () {
1173
+ if (!this._recorder) {
1174
+ if (this._config.shouldRecordStats()) {
1175
+ this._recorder = new AMDLoader.LoaderEventRecorder(this._loaderAvailableTimestamp);
1176
+ }
1177
+ else {
1178
+ this._recorder = AMDLoader.NullLoaderEventRecorder.INSTANCE;
1179
+ }
1180
+ }
1181
+ return this._recorder;
1182
+ };
1183
+ ModuleManager.prototype.getLoaderEvents = function () {
1184
+ return this.getRecorder().getEvents();
1185
+ };
1186
+ /**
1187
+ * Defines an anonymous module (without an id). Its name will be resolved as we receive a callback from the scriptLoader.
1188
+ * @param dependecies @see defineModule
1189
+ * @param callback @see defineModule
1190
+ */
1191
+ ModuleManager.prototype.enqueueDefineAnonymousModule = function (dependencies, callback) {
1192
+ if (this._currentAnnonymousDefineCall !== null) {
1193
+ throw new Error('Can only have one anonymous define call per script file');
1194
+ }
1195
+ var stack = null;
1196
+ if (this._config.isBuild()) {
1197
+ stack = new Error('StackLocation').stack;
1198
+ }
1199
+ this._currentAnnonymousDefineCall = {
1200
+ stack: stack,
1201
+ dependencies: dependencies,
1202
+ callback: callback
1203
+ };
1204
+ };
1205
+ /**
1206
+ * Creates a module and stores it in _modules. The manager will immediately begin resolving its dependencies.
1207
+ * @param strModuleId An unique and absolute id of the module. This must not collide with another module's id
1208
+ * @param dependencies An array with the dependencies of the module. Special keys are: "require", "exports" and "module"
1209
+ * @param callback if callback is a function, it will be called with the resolved dependencies. if callback is an object, it will be considered as the exports of the module.
1210
+ */
1211
+ ModuleManager.prototype.defineModule = function (strModuleId, dependencies, callback, errorback, stack, moduleIdResolver) {
1212
+ var _this = this;
1213
+ if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(strModuleId); }
1214
+ var moduleId = this._moduleIdProvider.getModuleId(strModuleId);
1215
+ if (this._modules2[moduleId]) {
1216
+ if (!this._config.isDuplicateMessageIgnoredFor(strModuleId)) {
1217
+ console.warn('Duplicate definition of module \'' + strModuleId + '\'');
1218
+ }
1219
+ // Super important! Completely ignore duplicate module definition
1220
+ return;
1221
+ }
1222
+ var m = new Module(moduleId, strModuleId, this._normalizeDependencies(dependencies, moduleIdResolver), callback, errorback, moduleIdResolver);
1223
+ this._modules2[moduleId] = m;
1224
+ if (this._config.isBuild()) {
1225
+ this._buildInfoDefineStack[moduleId] = stack;
1226
+ this._buildInfoDependencies[moduleId] = m.dependencies.map(function (dep) { return _this._moduleIdProvider.getStrModuleId(dep.id); });
1227
+ }
1228
+ // Resolving of dependencies is immediate (not in a timeout). If there's a need to support a packer that concatenates in an
1229
+ // unordered manner, in order to finish processing the file, execute the following method in a timeout
1230
+ this._resolve(m);
1231
+ };
1232
+ ModuleManager.prototype._normalizeDependency = function (dependency, moduleIdResolver) {
1233
+ if (dependency === 'exports') {
1234
+ return RegularDependency.EXPORTS;
1235
+ }
1236
+ if (dependency === 'module') {
1237
+ return RegularDependency.MODULE;
1238
+ }
1239
+ if (dependency === 'require') {
1240
+ return RegularDependency.REQUIRE;
1241
+ }
1242
+ // Normalize dependency and then request it from the manager
1243
+ var bangIndex = dependency.indexOf('!');
1244
+ if (bangIndex >= 0) {
1245
+ var strPluginId = moduleIdResolver.resolveModule(dependency.substr(0, bangIndex));
1246
+ var pluginParam = moduleIdResolver.resolveModule(dependency.substr(bangIndex + 1));
1247
+ var dependencyId = this._moduleIdProvider.getModuleId(strPluginId + '!' + pluginParam);
1248
+ var pluginId = this._moduleIdProvider.getModuleId(strPluginId);
1249
+ return new PluginDependency(dependencyId, pluginId, pluginParam);
1250
+ }
1251
+ return new RegularDependency(this._moduleIdProvider.getModuleId(moduleIdResolver.resolveModule(dependency)));
1252
+ };
1253
+ ModuleManager.prototype._normalizeDependencies = function (dependencies, moduleIdResolver) {
1254
+ var result = [], resultLen = 0;
1255
+ for (var i = 0, len = dependencies.length; i < len; i++) {
1256
+ result[resultLen++] = this._normalizeDependency(dependencies[i], moduleIdResolver);
1257
+ }
1258
+ return result;
1259
+ };
1260
+ ModuleManager.prototype._relativeRequire = function (moduleIdResolver, dependencies, callback, errorback) {
1261
+ if (typeof dependencies === 'string') {
1262
+ return this.synchronousRequire(dependencies, moduleIdResolver);
1263
+ }
1264
+ this.defineModule(AMDLoader.Utilities.generateAnonymousModule(), dependencies, callback, errorback, null, moduleIdResolver);
1265
+ };
1266
+ /**
1267
+ * Require synchronously a module by its absolute id. If the module is not loaded, an exception will be thrown.
1268
+ * @param id The unique and absolute id of the required module
1269
+ * @return The exports of module 'id'
1270
+ */
1271
+ ModuleManager.prototype.synchronousRequire = function (_strModuleId, moduleIdResolver) {
1272
+ if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(_strModuleId); }
1273
+ var dependency = this._normalizeDependency(_strModuleId, moduleIdResolver);
1274
+ var m = this._modules2[dependency.id];
1275
+ if (!m) {
1276
+ throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This is the first mention of this module!');
1277
+ }
1278
+ if (!m.isComplete()) {
1279
+ throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This module has not been resolved completely yet.');
1280
+ }
1281
+ return m.exports;
1282
+ };
1283
+ ModuleManager.prototype.configure = function (params, shouldOverwrite) {
1284
+ var oldShouldRecordStats = this._config.shouldRecordStats();
1285
+ if (shouldOverwrite) {
1286
+ this._config = new AMDLoader.Configuration(this._env, params);
1287
+ }
1288
+ else {
1289
+ this._config = this._config.cloneAndMerge(params);
1290
+ }
1291
+ if (this._config.shouldRecordStats() && !oldShouldRecordStats) {
1292
+ this._recorder = null;
1293
+ }
1294
+ };
1295
+ ModuleManager.prototype.getConfig = function () {
1296
+ return this._config;
1297
+ };
1298
+ /**
1299
+ * Callback from the scriptLoader when a module has been loaded.
1300
+ * This means its code is available and has been executed.
1301
+ */
1302
+ ModuleManager.prototype._onLoad = function (moduleId) {
1303
+ if (this._currentAnnonymousDefineCall !== null) {
1304
+ var defineCall = this._currentAnnonymousDefineCall;
1305
+ this._currentAnnonymousDefineCall = null;
1306
+ // Hit an anonymous define call
1307
+ this.defineModule(this._moduleIdProvider.getStrModuleId(moduleId), defineCall.dependencies, defineCall.callback, null, defineCall.stack);
1308
+ }
1309
+ };
1310
+ ModuleManager.prototype._createLoadError = function (moduleId, err) {
1311
+ var _this = this;
1312
+ var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
1313
+ var neededBy = (this._inverseDependencies2[moduleId] || []).map(function (intModuleId) { return _this._moduleIdProvider.getStrModuleId(intModuleId); });
1314
+ return {
1315
+ errorCode: 'load',
1316
+ moduleId: strModuleId,
1317
+ neededBy: neededBy,
1318
+ detail: err
1319
+ };
1320
+ };
1321
+ /**
1322
+ * Callback from the scriptLoader when a module hasn't been loaded.
1323
+ * This means that the script was not found (e.g. 404) or there was an error in the script.
1324
+ */
1325
+ ModuleManager.prototype._onLoadError = function (moduleId, err) {
1326
+ var error = this._createLoadError(moduleId, err);
1327
+ // Find any 'local' error handlers, walk the entire chain of inverse dependencies if necessary.
1328
+ var seenModuleId = [];
1329
+ for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
1330
+ seenModuleId[i] = false;
1331
+ }
1332
+ var someoneNotified = false;
1333
+ var queue = [];
1334
+ queue.push(moduleId);
1335
+ seenModuleId[moduleId] = true;
1336
+ while (queue.length > 0) {
1337
+ var queueElement = queue.shift();
1338
+ var m = this._modules2[queueElement];
1339
+ if (m) {
1340
+ someoneNotified = m.onDependencyError(error) || someoneNotified;
1341
+ }
1342
+ var inverseDeps = this._inverseDependencies2[queueElement];
1343
+ if (inverseDeps) {
1344
+ for (var i = 0, len = inverseDeps.length; i < len; i++) {
1345
+ var inverseDep = inverseDeps[i];
1346
+ if (!seenModuleId[inverseDep]) {
1347
+ queue.push(inverseDep);
1348
+ seenModuleId[inverseDep] = true;
1349
+ }
1350
+ }
1351
+ }
1352
+ }
1353
+ if (!someoneNotified) {
1354
+ this._config.onError(error);
1355
+ }
1356
+ };
1357
+ /**
1358
+ * Walks (recursively) the dependencies of 'from' in search of 'to'.
1359
+ * Returns true if there is such a path or false otherwise.
1360
+ * @param from Module id to start at
1361
+ * @param to Module id to look for
1362
+ */
1363
+ ModuleManager.prototype._hasDependencyPath = function (fromId, toId) {
1364
+ var from = this._modules2[fromId];
1365
+ if (!from) {
1366
+ return false;
1367
+ }
1368
+ var inQueue = [];
1369
+ for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
1370
+ inQueue[i] = false;
1371
+ }
1372
+ var queue = [];
1373
+ // Insert 'from' in queue
1374
+ queue.push(from);
1375
+ inQueue[fromId] = true;
1376
+ while (queue.length > 0) {
1377
+ // Pop first inserted element of queue
1378
+ var element = queue.shift();
1379
+ var dependencies = element.dependencies;
1380
+ if (dependencies) {
1381
+ // Walk the element's dependencies
1382
+ for (var i = 0, len = dependencies.length; i < len; i++) {
1383
+ var dependency = dependencies[i];
1384
+ if (dependency.id === toId) {
1385
+ // There is a path to 'to'
1386
+ return true;
1387
+ }
1388
+ var dependencyModule = this._modules2[dependency.id];
1389
+ if (dependencyModule && !inQueue[dependency.id]) {
1390
+ // Insert 'dependency' in queue
1391
+ inQueue[dependency.id] = true;
1392
+ queue.push(dependencyModule);
1393
+ }
1394
+ }
1395
+ }
1396
+ }
1397
+ // There is no path to 'to'
1398
+ return false;
1399
+ };
1400
+ /**
1401
+ * Walks (recursively) the dependencies of 'from' in search of 'to'.
1402
+ * Returns cycle as array.
1403
+ * @param from Module id to start at
1404
+ * @param to Module id to look for
1405
+ */
1406
+ ModuleManager.prototype._findCyclePath = function (fromId, toId, depth) {
1407
+ if (fromId === toId || depth === 50) {
1408
+ return [fromId];
1409
+ }
1410
+ var from = this._modules2[fromId];
1411
+ if (!from) {
1412
+ return null;
1413
+ }
1414
+ // Walk the element's dependencies
1415
+ var dependencies = from.dependencies;
1416
+ for (var i = 0, len = dependencies.length; i < len; i++) {
1417
+ var path = this._findCyclePath(dependencies[i].id, toId, depth + 1);
1418
+ if (path !== null) {
1419
+ path.push(fromId);
1420
+ return path;
1421
+ }
1422
+ }
1423
+ return null;
1424
+ };
1425
+ /**
1426
+ * Create the local 'require' that is passed into modules
1427
+ */
1428
+ ModuleManager.prototype._createRequire = function (moduleIdResolver) {
1429
+ var _this = this;
1430
+ var result = (function (dependencies, callback, errorback) {
1431
+ return _this._relativeRequire(moduleIdResolver, dependencies, callback, errorback);
1432
+ });
1433
+ result.toUrl = function (id) {
1434
+ return _this._config.requireToUrl(moduleIdResolver.resolveModule(id));
1435
+ };
1436
+ result.getStats = function () {
1437
+ return _this.getLoaderEvents();
1438
+ };
1439
+ result.__$__nodeRequire = AMDLoader.global.nodeRequire;
1440
+ return result;
1441
+ };
1442
+ ModuleManager.prototype._loadModule = function (moduleId) {
1443
+ var _this = this;
1444
+ if (this._modules2[moduleId] || this._knownModules2[moduleId]) {
1445
+ // known module
1446
+ return;
1447
+ }
1448
+ this._knownModules2[moduleId] = true;
1449
+ var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
1450
+ var paths = this._config.moduleIdToPaths(strModuleId);
1451
+ var scopedPackageRegex = /^@[^\/]+\/[^\/]+$/; // matches @scope/package-name
1452
+ if (this._env.isNode && (strModuleId.indexOf('/') === -1 || scopedPackageRegex.test(strModuleId))) {
1453
+ paths.push('node|' + strModuleId);
1454
+ }
1455
+ var lastPathIndex = -1;
1456
+ var loadNextPath = function (err) {
1457
+ lastPathIndex++;
1458
+ if (lastPathIndex >= paths.length) {
1459
+ // No more paths to try
1460
+ _this._onLoadError(moduleId, err);
1461
+ }
1462
+ else {
1463
+ var currentPath_1 = paths[lastPathIndex];
1464
+ var recorder_1 = _this.getRecorder();
1465
+ if (_this._config.isBuild() && currentPath_1 === 'empty:') {
1466
+ _this._buildInfoPath[moduleId] = currentPath_1;
1467
+ _this.defineModule(_this._moduleIdProvider.getStrModuleId(moduleId), [], null, null, null);
1468
+ _this._onLoad(moduleId);
1469
+ return;
1470
+ }
1471
+ recorder_1.record(10 /* BeginLoadingScript */, currentPath_1);
1472
+ _this._scriptLoader.load(_this, currentPath_1, function () {
1473
+ if (_this._config.isBuild()) {
1474
+ _this._buildInfoPath[moduleId] = currentPath_1;
1475
+ }
1476
+ recorder_1.record(11 /* EndLoadingScriptOK */, currentPath_1);
1477
+ _this._onLoad(moduleId);
1478
+ }, function (err) {
1479
+ recorder_1.record(12 /* EndLoadingScriptError */, currentPath_1);
1480
+ loadNextPath(err);
1481
+ });
1482
+ }
1483
+ };
1484
+ loadNextPath(null);
1485
+ };
1486
+ /**
1487
+ * Resolve a plugin dependency with the plugin loaded & complete
1488
+ * @param module The module that has this dependency
1489
+ * @param pluginDependency The semi-normalized dependency that appears in the module. e.g. 'vs/css!./mycssfile'. Only the plugin part (before !) is normalized
1490
+ * @param plugin The plugin (what the plugin exports)
1491
+ */
1492
+ ModuleManager.prototype._loadPluginDependency = function (plugin, pluginDependency) {
1493
+ var _this = this;
1494
+ if (this._modules2[pluginDependency.id] || this._knownModules2[pluginDependency.id]) {
1495
+ // known module
1496
+ return;
1497
+ }
1498
+ this._knownModules2[pluginDependency.id] = true;
1499
+ // Delegate the loading of the resource to the plugin
1500
+ var load = (function (value) {
1501
+ _this.defineModule(_this._moduleIdProvider.getStrModuleId(pluginDependency.id), [], value, null, null);
1502
+ });
1503
+ load.error = function (err) {
1504
+ _this._config.onError(_this._createLoadError(pluginDependency.id, err));
1505
+ };
1506
+ plugin.load(pluginDependency.pluginParam, this._createRequire(ModuleIdResolver.ROOT), load, this._config.getOptionsLiteral());
1507
+ };
1508
+ /**
1509
+ * Examine the dependencies of module 'module' and resolve them as needed.
1510
+ */
1511
+ ModuleManager.prototype._resolve = function (module) {
1512
+ var _this = this;
1513
+ var dependencies = module.dependencies;
1514
+ for (var i = 0, len = dependencies.length; i < len; i++) {
1515
+ var dependency = dependencies[i];
1516
+ if (dependency === RegularDependency.EXPORTS) {
1517
+ module.exportsPassedIn = true;
1518
+ module.unresolvedDependenciesCount--;
1519
+ continue;
1520
+ }
1521
+ if (dependency === RegularDependency.MODULE) {
1522
+ module.unresolvedDependenciesCount--;
1523
+ continue;
1524
+ }
1525
+ if (dependency === RegularDependency.REQUIRE) {
1526
+ module.unresolvedDependenciesCount--;
1527
+ continue;
1528
+ }
1529
+ var dependencyModule = this._modules2[dependency.id];
1530
+ if (dependencyModule && dependencyModule.isComplete()) {
1531
+ module.unresolvedDependenciesCount--;
1532
+ continue;
1533
+ }
1534
+ if (this._hasDependencyPath(dependency.id, module.id)) {
1535
+ console.warn('There is a dependency cycle between \'' + this._moduleIdProvider.getStrModuleId(dependency.id) + '\' and \'' + this._moduleIdProvider.getStrModuleId(module.id) + '\'. The cyclic path follows:');
1536
+ var cyclePath = this._findCyclePath(dependency.id, module.id, 0);
1537
+ cyclePath.reverse();
1538
+ cyclePath.push(dependency.id);
1539
+ console.warn(cyclePath.map(function (id) { return _this._moduleIdProvider.getStrModuleId(id); }).join(' => \n'));
1540
+ // Break the cycle
1541
+ module.unresolvedDependenciesCount--;
1542
+ continue;
1543
+ }
1544
+ // record inverse dependency
1545
+ this._inverseDependencies2[dependency.id] = this._inverseDependencies2[dependency.id] || [];
1546
+ this._inverseDependencies2[dependency.id].push(module.id);
1547
+ if (dependency instanceof PluginDependency) {
1548
+ var plugin = this._modules2[dependency.pluginId];
1549
+ if (plugin && plugin.isComplete()) {
1550
+ this._loadPluginDependency(plugin.exports, dependency);
1551
+ continue;
1552
+ }
1553
+ // Record dependency for when the plugin gets loaded
1554
+ var inversePluginDeps = this._inversePluginDependencies2.get(dependency.pluginId);
1555
+ if (!inversePluginDeps) {
1556
+ inversePluginDeps = [];
1557
+ this._inversePluginDependencies2.set(dependency.pluginId, inversePluginDeps);
1558
+ }
1559
+ inversePluginDeps.push(dependency);
1560
+ this._loadModule(dependency.pluginId);
1561
+ continue;
1562
+ }
1563
+ this._loadModule(dependency.id);
1564
+ }
1565
+ if (module.unresolvedDependenciesCount === 0) {
1566
+ this._onModuleComplete(module);
1567
+ }
1568
+ };
1569
+ ModuleManager.prototype._onModuleComplete = function (module) {
1570
+ var _this = this;
1571
+ var recorder = this.getRecorder();
1572
+ if (module.isComplete()) {
1573
+ // already done
1574
+ return;
1575
+ }
1576
+ var dependencies = module.dependencies;
1577
+ var dependenciesValues = [];
1578
+ for (var i = 0, len = dependencies.length; i < len; i++) {
1579
+ var dependency = dependencies[i];
1580
+ if (dependency === RegularDependency.EXPORTS) {
1581
+ dependenciesValues[i] = module.exports;
1582
+ continue;
1583
+ }
1584
+ if (dependency === RegularDependency.MODULE) {
1585
+ dependenciesValues[i] = {
1586
+ id: module.strId,
1587
+ config: function () {
1588
+ return _this._config.getConfigForModule(module.strId);
1589
+ }
1590
+ };
1591
+ continue;
1592
+ }
1593
+ if (dependency === RegularDependency.REQUIRE) {
1594
+ dependenciesValues[i] = this._createRequire(module.moduleIdResolver);
1595
+ continue;
1596
+ }
1597
+ var dependencyModule = this._modules2[dependency.id];
1598
+ if (dependencyModule) {
1599
+ dependenciesValues[i] = dependencyModule.exports;
1600
+ continue;
1601
+ }
1602
+ dependenciesValues[i] = null;
1603
+ }
1604
+ module.complete(recorder, this._config, dependenciesValues);
1605
+ // Fetch and clear inverse dependencies
1606
+ var inverseDeps = this._inverseDependencies2[module.id];
1607
+ this._inverseDependencies2[module.id] = null;
1608
+ if (inverseDeps) {
1609
+ // Resolve one inverse dependency at a time, always
1610
+ // on the lookout for a completed module.
1611
+ for (var i = 0, len = inverseDeps.length; i < len; i++) {
1612
+ var inverseDependencyId = inverseDeps[i];
1613
+ var inverseDependency = this._modules2[inverseDependencyId];
1614
+ inverseDependency.unresolvedDependenciesCount--;
1615
+ if (inverseDependency.unresolvedDependenciesCount === 0) {
1616
+ this._onModuleComplete(inverseDependency);
1617
+ }
1618
+ }
1619
+ }
1620
+ var inversePluginDeps = this._inversePluginDependencies2.get(module.id);
1621
+ if (inversePluginDeps) {
1622
+ // This module is used as a plugin at least once
1623
+ // Fetch and clear these inverse plugin dependencies
1624
+ this._inversePluginDependencies2.delete(module.id);
1625
+ // Resolve plugin dependencies one at a time
1626
+ for (var i = 0, len = inversePluginDeps.length; i < len; i++) {
1627
+ this._loadPluginDependency(module.exports, inversePluginDeps[i]);
1628
+ }
1629
+ }
1630
+ };
1631
+ return ModuleManager;
1632
+ }());
1633
+ AMDLoader.ModuleManager = ModuleManager;
1634
+ })(AMDLoader || (AMDLoader = {}));
1635
+ var define;
1636
+ var AMDLoader;
1637
+ (function (AMDLoader) {
1638
+ var env = new AMDLoader.Environment();
1639
+ var moduleManager = null;
1640
+ var DefineFunc = function (id, dependencies, callback) {
1641
+ if (typeof id !== 'string') {
1642
+ callback = dependencies;
1643
+ dependencies = id;
1644
+ id = null;
1645
+ }
1646
+ if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
1647
+ callback = dependencies;
1648
+ dependencies = null;
1649
+ }
1650
+ if (!dependencies) {
1651
+ dependencies = ['require', 'exports', 'module'];
1652
+ }
1653
+ if (id) {
1654
+ moduleManager.defineModule(id, dependencies, callback, null, null);
1655
+ }
1656
+ else {
1657
+ moduleManager.enqueueDefineAnonymousModule(dependencies, callback);
1658
+ }
1659
+ };
1660
+ DefineFunc.amd = {
1661
+ jQuery: true
1662
+ };
1663
+ var _requireFunc_config = function (params, shouldOverwrite) {
1664
+ if (shouldOverwrite === void 0) { shouldOverwrite = false; }
1665
+ moduleManager.configure(params, shouldOverwrite);
1666
+ };
1667
+ var RequireFunc = function () {
1668
+ if (arguments.length === 1) {
1669
+ if ((arguments[0] instanceof Object) && !Array.isArray(arguments[0])) {
1670
+ _requireFunc_config(arguments[0]);
1671
+ return;
1672
+ }
1673
+ if (typeof arguments[0] === 'string') {
1674
+ return moduleManager.synchronousRequire(arguments[0]);
1675
+ }
1676
+ }
1677
+ if (arguments.length === 2 || arguments.length === 3) {
1678
+ if (Array.isArray(arguments[0])) {
1679
+ moduleManager.defineModule(AMDLoader.Utilities.generateAnonymousModule(), arguments[0], arguments[1], arguments[2], null);
1680
+ return;
1681
+ }
1682
+ }
1683
+ throw new Error('Unrecognized require call');
1684
+ };
1685
+ RequireFunc.config = _requireFunc_config;
1686
+ RequireFunc.getConfig = function () {
1687
+ return moduleManager.getConfig().getOptionsLiteral();
1688
+ };
1689
+ RequireFunc.reset = function () {
1690
+ moduleManager = moduleManager.reset();
1691
+ };
1692
+ RequireFunc.getBuildInfo = function () {
1693
+ return moduleManager.getBuildInfo();
1694
+ };
1695
+ RequireFunc.getStats = function () {
1696
+ return moduleManager.getLoaderEvents();
1697
+ };
1698
+ RequireFunc.define = function () {
1699
+ return DefineFunc.apply(null, arguments);
1700
+ };
1701
+ function init() {
1702
+ if (typeof AMDLoader.global.require !== 'undefined' || typeof require !== 'undefined') {
1703
+ var _nodeRequire_1 = (AMDLoader.global.require || require);
1704
+ if (typeof _nodeRequire_1 === 'function' && typeof _nodeRequire_1.resolve === 'function') {
1705
+ // re-expose node's require function
1706
+ var nodeRequire = function (what) {
1707
+ moduleManager.getRecorder().record(33 /* NodeBeginNativeRequire */, what);
1708
+ try {
1709
+ return _nodeRequire_1(what);
1710
+ }
1711
+ finally {
1712
+ moduleManager.getRecorder().record(34 /* NodeEndNativeRequire */, what);
1713
+ }
1714
+ };
1715
+ AMDLoader.global.nodeRequire = nodeRequire;
1716
+ RequireFunc.nodeRequire = nodeRequire;
1717
+ RequireFunc.__$__nodeRequire = nodeRequire;
1718
+ }
1719
+ }
1720
+ if (env.isNode && !env.isElectronRenderer) {
1721
+ module.exports = RequireFunc;
1722
+ require = RequireFunc;
1723
+ }
1724
+ else {
1725
+ if (!env.isElectronRenderer) {
1726
+ AMDLoader.global.define = DefineFunc;
1727
+ }
1728
+ AMDLoader.global.require = RequireFunc;
1729
+ }
1730
+ }
1731
+ AMDLoader.init = init;
1732
+ if (typeof AMDLoader.global.define !== 'function' || !AMDLoader.global.define.amd) {
1733
+ moduleManager = new AMDLoader.ModuleManager(env, AMDLoader.createScriptLoader(env), DefineFunc, RequireFunc, AMDLoader.Utilities.getHighPerformanceTimestamp());
1734
+ // The global variable require can configure the loader
1735
+ if (typeof AMDLoader.global.require !== 'undefined' && typeof AMDLoader.global.require !== 'function') {
1736
+ RequireFunc.config(AMDLoader.global.require);
1737
+ }
1738
+ // This define is for the local closure defined in node in the case that the loader is concatenated
1739
+ define = function () {
1740
+ return DefineFunc.apply(null, arguments);
1741
+ };
1742
+ define.amd = DefineFunc.amd;
1743
+ if (typeof doNotInitLoader === 'undefined') {
1744
+ init();
1745
+ }
1746
+ }
1747
+ })(AMDLoader || (AMDLoader = {}));