zforg 1.0.1

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