{"version":3,"sources":["out-editor/vs/loader.js"],"sourcesContent":["/*!-----------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)\n * Released under the MIT license\n * https://github.com/microsoft/vscode/blob/main/LICENSE.txt\n *-----------------------------------------------------------*/\n\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n/*---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n * Please make sure to make edits in the .ts file at https://github.com/microsoft/vscode-loader/\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *---------------------------------------------------------------------------------------------\n *--------------------------------------------------------------------------------------------*/\nconst _amdLoaderGlobal = this;\nconst _commonjsGlobal = typeof global === 'object' ? global : {};\nvar AMDLoader;\n(function (AMDLoader) {\n AMDLoader.global = _amdLoaderGlobal;\n class Environment {\n get isWindows() {\n this._detect();\n return this._isWindows;\n }\n get isNode() {\n this._detect();\n return this._isNode;\n }\n get isElectronRenderer() {\n this._detect();\n return this._isElectronRenderer;\n }\n get isWebWorker() {\n this._detect();\n return this._isWebWorker;\n }\n get isElectronNodeIntegrationWebWorker() {\n this._detect();\n return this._isElectronNodeIntegrationWebWorker;\n }\n constructor() {\n this._detected = false;\n this._isWindows = false;\n this._isNode = false;\n this._isElectronRenderer = false;\n this._isWebWorker = false;\n this._isElectronNodeIntegrationWebWorker = false;\n }\n _detect() {\n if (this._detected) {\n return;\n }\n this._detected = true;\n this._isWindows = Environment._isWindows();\n this._isNode = (typeof module !== 'undefined' && !!module.exports);\n this._isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');\n this._isWebWorker = (typeof AMDLoader.global.importScripts === 'function');\n this._isElectronNodeIntegrationWebWorker = this._isWebWorker && (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'worker');\n }\n static _isWindows() {\n if (typeof navigator !== 'undefined') {\n if (navigator.userAgent && navigator.userAgent.indexOf('Windows') >= 0) {\n return true;\n }\n }\n if (typeof process !== 'undefined') {\n return (process.platform === 'win32');\n }\n return false;\n }\n }\n AMDLoader.Environment = Environment;\n})(AMDLoader || (AMDLoader = {}));\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nvar AMDLoader;\n(function (AMDLoader) {\n class LoaderEvent {\n constructor(type, detail, timestamp) {\n this.type = type;\n this.detail = detail;\n this.timestamp = timestamp;\n }\n }\n AMDLoader.LoaderEvent = LoaderEvent;\n class LoaderEventRecorder {\n constructor(loaderAvailableTimestamp) {\n this._events = [new LoaderEvent(1 /* LoaderEventType.LoaderAvailable */, '', loaderAvailableTimestamp)];\n }\n record(type, detail) {\n this._events.push(new LoaderEvent(type, detail, AMDLoader.Utilities.getHighPerformanceTimestamp()));\n }\n getEvents() {\n return this._events;\n }\n }\n AMDLoader.LoaderEventRecorder = LoaderEventRecorder;\n class NullLoaderEventRecorder {\n record(type, detail) {\n // Nothing to do\n }\n getEvents() {\n return [];\n }\n }\n NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();\n AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder;\n})(AMDLoader || (AMDLoader = {}));\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nvar AMDLoader;\n(function (AMDLoader) {\n class Utilities {\n /**\n * This method does not take care of / vs \\\n */\n static fileUriToFilePath(isWindows, uri) {\n uri = decodeURI(uri).replace(/%23/g, '#');\n if (isWindows) {\n if (/^file:\\/\\/\\//.test(uri)) {\n // This is a URI without a hostname => return only the path segment\n return uri.substr(8);\n }\n if (/^file:\\/\\//.test(uri)) {\n return uri.substr(5);\n }\n }\n else {\n if (/^file:\\/\\//.test(uri)) {\n return uri.substr(7);\n }\n }\n // Not sure...\n return uri;\n }\n static startsWith(haystack, needle) {\n return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;\n }\n static endsWith(haystack, needle) {\n return haystack.length >= needle.length && haystack.substr(haystack.length - needle.length) === needle;\n }\n // only check for \"?\" before \"#\" to ensure that there is a real Query-String\n static containsQueryString(url) {\n return /^[^\\#]*\\?/gi.test(url);\n }\n /**\n * Does `url` start with http:// or https:// or file:// or / ?\n */\n static isAbsolutePath(url) {\n return /^((http:\\/\\/)|(https:\\/\\/)|(file:\\/\\/)|(\\/))/.test(url);\n }\n static forEachProperty(obj, callback) {\n if (obj) {\n let key;\n for (key in obj) {\n if (obj.hasOwnProperty(key)) {\n callback(key, obj[key]);\n }\n }\n }\n }\n static isEmpty(obj) {\n let isEmpty = true;\n Utilities.forEachProperty(obj, () => {\n isEmpty = false;\n });\n return isEmpty;\n }\n static recursiveClone(obj) {\n if (!obj || typeof obj !== 'object' || obj instanceof RegExp) {\n return obj;\n }\n if (!Array.isArray(obj) && Object.getPrototypeOf(obj) !== Object.prototype) {\n // only clone \"simple\" objects\n return obj;\n }\n let result = Array.isArray(obj) ? [] : {};\n Utilities.forEachProperty(obj, (key, value) => {\n if (value && typeof value === 'object') {\n result[key] = Utilities.recursiveClone(value);\n }\n else {\n result[key] = value;\n }\n });\n return result;\n }\n static generateAnonymousModule() {\n return '===anonymous' + (Utilities.NEXT_ANONYMOUS_ID++) + '===';\n }\n static isAnonymousModule(id) {\n return Utilities.startsWith(id, '===anonymous');\n }\n static getHighPerformanceTimestamp() {\n if (!this.PERFORMANCE_NOW_PROBED) {\n this.PERFORMANCE_NOW_PROBED = true;\n this.HAS_PERFORMANCE_NOW = (AMDLoader.global.performance && typeof AMDLoader.global.performance.now === 'function');\n }\n return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now());\n }\n }\n Utilities.NEXT_ANONYMOUS_ID = 1;\n Utilities.PERFORMANCE_NOW_PROBED = false;\n Utilities.HAS_PERFORMANCE_NOW = false;\n AMDLoader.Utilities = Utilities;\n})(AMDLoader || (AMDLoader = {}));\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nvar AMDLoader;\n(function (AMDLoader) {\n function ensureError(err) {\n if (err instanceof Error) {\n return err;\n }\n const result = new Error(err.message || String(err) || 'Unknown Error');\n if (err.stack) {\n result.stack = err.stack;\n }\n return result;\n }\n AMDLoader.ensureError = ensureError;\n ;\n class ConfigurationOptionsUtil {\n /**\n * Ensure configuration options make sense\n */\n static validateConfigurationOptions(options) {\n function defaultOnError(err) {\n if (err.phase === 'loading') {\n console.error('Loading \"' + err.moduleId + '\" failed');\n console.error(err);\n console.error('Here are the modules that depend on it:');\n console.error(err.neededBy);\n return;\n }\n if (err.phase === 'factory') {\n console.error('The factory function of \"' + err.moduleId + '\" has thrown an exception');\n console.error(err);\n console.error('Here are the modules that depend on it:');\n console.error(err.neededBy);\n return;\n }\n }\n options = options || {};\n if (typeof options.baseUrl !== 'string') {\n options.baseUrl = '';\n }\n if (typeof options.isBuild !== 'boolean') {\n options.isBuild = false;\n }\n if (typeof options.paths !== 'object') {\n options.paths = {};\n }\n if (typeof options.config !== 'object') {\n options.config = {};\n }\n if (typeof options.catchError === 'undefined') {\n options.catchError = false;\n }\n if (typeof options.recordStats === 'undefined') {\n options.recordStats = false;\n }\n if (typeof options.urlArgs !== 'string') {\n options.urlArgs = '';\n }\n if (typeof options.onError !== 'function') {\n options.onError = defaultOnError;\n }\n if (!Array.isArray(options.ignoreDuplicateModules)) {\n options.ignoreDuplicateModules = [];\n }\n if (options.baseUrl.length > 0) {\n if (!AMDLoader.Utilities.endsWith(options.baseUrl, '/')) {\n options.baseUrl += '/';\n }\n }\n if (typeof options.cspNonce !== 'string') {\n options.cspNonce = '';\n }\n if (typeof options.preferScriptTags === 'undefined') {\n options.preferScriptTags = false;\n }\n if (options.nodeCachedData && typeof options.nodeCachedData === 'object') {\n if (typeof options.nodeCachedData.seed !== 'string') {\n options.nodeCachedData.seed = 'seed';\n }\n if (typeof options.nodeCachedData.writeDelay !== 'number' || options.nodeCachedData.writeDelay < 0) {\n options.nodeCachedData.writeDelay = 1000 * 7;\n }\n if (!options.nodeCachedData.path || typeof options.nodeCachedData.path !== 'string') {\n const err = ensureError(new Error('INVALID cached data configuration, \\'path\\' MUST be set'));\n err.phase = 'configuration';\n options.onError(err);\n options.nodeCachedData = undefined;\n }\n }\n return options;\n }\n static mergeConfigurationOptions(overwrite = null, base = null) {\n let result = AMDLoader.Utilities.recursiveClone(base || {});\n // Merge known properties and overwrite the unknown ones\n AMDLoader.Utilities.forEachProperty(overwrite, (key, value) => {\n if (key === 'ignoreDuplicateModules' && typeof result.ignoreDuplicateModules !== 'undefined') {\n result.ignoreDuplicateModules = result.ignoreDuplicateModules.concat(value);\n }\n else if (key === 'paths' && typeof result.paths !== 'undefined') {\n AMDLoader.Utilities.forEachProperty(value, (key2, value2) => result.paths[key2] = value2);\n }\n else if (key === 'config' && typeof result.config !== 'undefined') {\n AMDLoader.Utilities.forEachProperty(value, (key2, value2) => result.config[key2] = value2);\n }\n else {\n result[key] = AMDLoader.Utilities.recursiveClone(value);\n }\n });\n return ConfigurationOptionsUtil.validateConfigurationOptions(result);\n }\n }\n AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil;\n class Configuration {\n constructor(env, options) {\n this._env = env;\n this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);\n this._createIgnoreDuplicateModulesMap();\n this._createSortedPathsRules();\n if (this.options.baseUrl === '') {\n if (this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename && this._env.isNode) {\n let nodeMain = this.options.nodeRequire.main.filename;\n let dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\\\'));\n this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);\n }\n }\n }\n _createIgnoreDuplicateModulesMap() {\n // Build a map out of the ignoreDuplicateModules array\n this.ignoreDuplicateModulesMap = {};\n for (let i = 0; i < this.options.ignoreDuplicateModules.length; i++) {\n this.ignoreDuplicateModulesMap[this.options.ignoreDuplicateModules[i]] = true;\n }\n }\n _createSortedPathsRules() {\n // Create an array our of the paths rules, sorted descending by length to\n // result in a more specific -> less specific order\n this.sortedPathsRules = [];\n AMDLoader.Utilities.forEachProperty(this.options.paths, (from, to) => {\n if (!Array.isArray(to)) {\n this.sortedPathsRules.push({\n from: from,\n to: [to]\n });\n }\n else {\n this.sortedPathsRules.push({\n from: from,\n to: to\n });\n }\n });\n this.sortedPathsRules.sort((a, b) => {\n return b.from.length - a.from.length;\n });\n }\n /**\n * Clone current configuration and overwrite options selectively.\n * @param options The selective options to overwrite with.\n * @result A new configuration\n */\n cloneAndMerge(options) {\n return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(options, this.options));\n }\n /**\n * Get current options bag. Useful for passing it forward to plugins.\n */\n getOptionsLiteral() {\n return this.options;\n }\n _applyPaths(moduleId) {\n let pathRule;\n for (let i = 0, len = this.sortedPathsRules.length; i < len; i++) {\n pathRule = this.sortedPathsRules[i];\n if (AMDLoader.Utilities.startsWith(moduleId, pathRule.from)) {\n let result = [];\n for (let j = 0, lenJ = pathRule.to.length; j < lenJ; j++) {\n result.push(pathRule.to[j] + moduleId.substr(pathRule.from.length));\n }\n return result;\n }\n }\n return [moduleId];\n }\n _addUrlArgsToUrl(url) {\n if (AMDLoader.Utilities.containsQueryString(url)) {\n return url + '&' + this.options.urlArgs;\n }\n else {\n return url + '?' + this.options.urlArgs;\n }\n }\n _addUrlArgsIfNecessaryToUrl(url) {\n if (this.options.urlArgs) {\n return this._addUrlArgsToUrl(url);\n }\n return url;\n }\n _addUrlArgsIfNecessaryToUrls(urls) {\n if (this.options.urlArgs) {\n for (let i = 0, len = urls.length; i < len; i++) {\n urls[i] = this._addUrlArgsToUrl(urls[i]);\n }\n }\n return urls;\n }\n /**\n * Transform a module id to a location. Appends .js to module ids\n */\n moduleIdToPaths(moduleId) {\n if (this._env.isNode) {\n const isNodeModule = (this.options.amdModulesPattern instanceof RegExp\n && !this.options.amdModulesPattern.test(moduleId));\n if (isNodeModule) {\n // This is a node module...\n if (this.isBuild()) {\n // ...and we are at build time, drop it\n return ['empty:'];\n }\n else {\n // ...and at runtime we create a `shortcut`-path\n return ['node|' + moduleId];\n }\n }\n }\n let result = moduleId;\n let results;\n if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.isAbsolutePath(result)) {\n results = this._applyPaths(result);\n for (let i = 0, len = results.length; i < len; i++) {\n if (this.isBuild() && results[i] === 'empty:') {\n continue;\n }\n if (!AMDLoader.Utilities.isAbsolutePath(results[i])) {\n results[i] = this.options.baseUrl + results[i];\n }\n if (!AMDLoader.Utilities.endsWith(results[i], '.js') && !AMDLoader.Utilities.containsQueryString(results[i])) {\n results[i] = results[i] + '.js';\n }\n }\n }\n else {\n if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.containsQueryString(result)) {\n result = result + '.js';\n }\n results = [result];\n }\n return this._addUrlArgsIfNecessaryToUrls(results);\n }\n /**\n * Transform a module id or url to a location.\n */\n requireToUrl(url) {\n let result = url;\n if (!AMDLoader.Utilities.isAbsolutePath(result)) {\n result = this._applyPaths(result)[0];\n if (!AMDLoader.Utilities.isAbsolutePath(result)) {\n result = this.options.baseUrl + result;\n }\n }\n return this._addUrlArgsIfNecessaryToUrl(result);\n }\n /**\n * Flag to indicate if current execution is as part of a build.\n */\n isBuild() {\n return this.options.isBuild;\n }\n shouldInvokeFactory(strModuleId) {\n if (!this.options.isBuild) {\n // outside of a build, all factories should be invoked\n return true;\n }\n // during a build, only explicitly marked or anonymous modules get their factories invoked\n if (AMDLoader.Utilities.isAnonymousModule(strModuleId)) {\n return true;\n }\n if (this.options.buildForceInvokeFactory && this.options.buildForceInvokeFactory[strModuleId]) {\n return true;\n }\n return false;\n }\n /**\n * Test if module `moduleId` is expected to be defined multiple times\n */\n isDuplicateMessageIgnoredFor(moduleId) {\n return this.ignoreDuplicateModulesMap.hasOwnProperty(moduleId);\n }\n /**\n * Get the configuration settings for the provided module id\n */\n getConfigForModule(moduleId) {\n if (this.options.config) {\n return this.options.config[moduleId];\n }\n }\n /**\n * Should errors be caught when executing module factories?\n */\n shouldCatchError() {\n return this.options.catchError;\n }\n /**\n * Should statistics be recorded?\n */\n shouldRecordStats() {\n return this.options.recordStats;\n }\n /**\n * Forward an error to the error handler.\n */\n onError(err) {\n this.options.onError(err);\n }\n }\n AMDLoader.Configuration = Configuration;\n})(AMDLoader || (AMDLoader = {}));\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nvar AMDLoader;\n(function (AMDLoader) {\n /**\n * Load `scriptSrc` only once (avoid multiple