UNPKG

@vue/devtools

Version:
1 lines 186 kB
"use strict";(self["webpackChunk_vue_devtools"]=self["webpackChunk_vue_devtools"]||[]).push([[2501],{32501:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n \"getJavaScriptWorker\": () => (/* binding */ getJavaScriptWorker),\n \"getTypeScriptWorker\": () => (/* binding */ getTypeScriptWorker),\n \"setupJavaScript\": () => (/* binding */ setupJavaScript),\n \"setupTypeScript\": () => (/* binding */ setupTypeScript)\n});\n\n// EXTERNAL MODULE: ../../node_modules/monaco-editor/esm/vs/language/typescript/fillers/monaco-editor-core.js\nvar monaco_editor_core = __webpack_require__(67181);\n;// CONCATENATED MODULE: ../../node_modules/monaco-editor/esm/vs/language/typescript/workerManager.js\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\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\nvar WorkerManager = /** @class */ (function () {\n function WorkerManager(modeId, defaults) {\n var _this = this;\n this._modeId = modeId;\n this._defaults = defaults;\n this._worker = null;\n this._client = null;\n this._configChangeListener = this._defaults.onDidChange(function () { return _this._stopWorker(); });\n this._updateExtraLibsToken = 0;\n this._extraLibsChangeListener = this._defaults.onDidExtraLibsChange(function () {\n return _this._updateExtraLibs();\n });\n }\n WorkerManager.prototype._stopWorker = function () {\n if (this._worker) {\n this._worker.dispose();\n this._worker = null;\n }\n this._client = null;\n };\n WorkerManager.prototype.dispose = function () {\n this._configChangeListener.dispose();\n this._extraLibsChangeListener.dispose();\n this._stopWorker();\n };\n WorkerManager.prototype._updateExtraLibs = function () {\n return __awaiter(this, void 0, void 0, function () {\n var myToken, proxy;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this._worker) {\n return [2 /*return*/];\n }\n myToken = ++this._updateExtraLibsToken;\n return [4 /*yield*/, this._worker.getProxy()];\n case 1:\n proxy = _a.sent();\n if (this._updateExtraLibsToken !== myToken) {\n // avoid multiple calls\n return [2 /*return*/];\n }\n proxy.updateExtraLibs(this._defaults.getExtraLibs());\n return [2 /*return*/];\n }\n });\n });\n };\n WorkerManager.prototype._getClient = function () {\n var _this = this;\n if (!this._client) {\n this._worker = monaco_editor_core/* editor.createWebWorker */.j6.createWebWorker({\n // module that exports the create() method and returns a `TypeScriptWorker` instance\n moduleId: 'vs/language/typescript/tsWorker',\n label: this._modeId,\n keepIdleModels: true,\n // passed in to the create() method\n createData: {\n compilerOptions: this._defaults.getCompilerOptions(),\n extraLibs: this._defaults.getExtraLibs(),\n customWorkerPath: this._defaults.workerOptions.customWorkerPath\n }\n });\n var p = this._worker.getProxy();\n if (this._defaults.getEagerModelSync()) {\n p = p.then(function (worker) {\n if (_this._worker) {\n return _this._worker.withSyncedResources(monaco_editor_core/* editor.getModels */.j6.getModels()\n .filter(function (model) { return model.getModeId() === _this._modeId; })\n .map(function (model) { return model.uri; }));\n }\n return worker;\n });\n }\n this._client = p;\n }\n return this._client;\n };\n WorkerManager.prototype.getLanguageServiceWorker = function () {\n var _this = this;\n var resources = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n resources[_i] = arguments[_i];\n }\n var _client;\n return this._getClient()\n .then(function (client) {\n _client = client;\n })\n .then(function (_) {\n if (_this._worker) {\n return _this._worker.withSyncedResources(resources);\n }\n })\n .then(function (_) { return _client; });\n };\n return WorkerManager;\n}());\n\n\n;// CONCATENATED MODULE: ../../node_modules/monaco-editor/esm/vs/language/typescript/lib/lib.index.js\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// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`\n//\n/** Contains all the lib files */\nvar libFileSet = {};\nlibFileSet['lib.d.ts'] = true;\nlibFileSet['lib.dom.d.ts'] = true;\nlibFileSet['lib.dom.iterable.d.ts'] = true;\nlibFileSet['lib.es2015.collection.d.ts'] = true;\nlibFileSet['lib.es2015.core.d.ts'] = true;\nlibFileSet['lib.es2015.d.ts'] = true;\nlibFileSet['lib.es2015.generator.d.ts'] = true;\nlibFileSet['lib.es2015.iterable.d.ts'] = true;\nlibFileSet['lib.es2015.promise.d.ts'] = true;\nlibFileSet['lib.es2015.proxy.d.ts'] = true;\nlibFileSet['lib.es2015.reflect.d.ts'] = true;\nlibFileSet['lib.es2015.symbol.d.ts'] = true;\nlibFileSet['lib.es2015.symbol.wellknown.d.ts'] = true;\nlibFileSet['lib.es2016.array.include.d.ts'] = true;\nlibFileSet['lib.es2016.d.ts'] = true;\nlibFileSet['lib.es2016.full.d.ts'] = true;\nlibFileSet['lib.es2017.d.ts'] = true;\nlibFileSet['lib.es2017.full.d.ts'] = true;\nlibFileSet['lib.es2017.intl.d.ts'] = true;\nlibFileSet['lib.es2017.object.d.ts'] = true;\nlibFileSet['lib.es2017.sharedmemory.d.ts'] = true;\nlibFileSet['lib.es2017.string.d.ts'] = true;\nlibFileSet['lib.es2017.typedarrays.d.ts'] = true;\nlibFileSet['lib.es2018.asyncgenerator.d.ts'] = true;\nlibFileSet['lib.es2018.asynciterable.d.ts'] = true;\nlibFileSet['lib.es2018.d.ts'] = true;\nlibFileSet['lib.es2018.full.d.ts'] = true;\nlibFileSet['lib.es2018.intl.d.ts'] = true;\nlibFileSet['lib.es2018.promise.d.ts'] = true;\nlibFileSet['lib.es2018.regexp.d.ts'] = true;\nlibFileSet['lib.es2019.array.d.ts'] = true;\nlibFileSet['lib.es2019.d.ts'] = true;\nlibFileSet['lib.es2019.full.d.ts'] = true;\nlibFileSet['lib.es2019.object.d.ts'] = true;\nlibFileSet['lib.es2019.string.d.ts'] = true;\nlibFileSet['lib.es2019.symbol.d.ts'] = true;\nlibFileSet['lib.es2020.bigint.d.ts'] = true;\nlibFileSet['lib.es2020.d.ts'] = true;\nlibFileSet['lib.es2020.full.d.ts'] = true;\nlibFileSet['lib.es2020.intl.d.ts'] = true;\nlibFileSet['lib.es2020.promise.d.ts'] = true;\nlibFileSet['lib.es2020.sharedmemory.d.ts'] = true;\nlibFileSet['lib.es2020.string.d.ts'] = true;\nlibFileSet['lib.es2020.symbol.wellknown.d.ts'] = true;\nlibFileSet['lib.es5.d.ts'] = true;\nlibFileSet['lib.es6.d.ts'] = true;\nlibFileSet['lib.esnext.d.ts'] = true;\nlibFileSet['lib.esnext.full.d.ts'] = true;\nlibFileSet['lib.esnext.intl.d.ts'] = true;\nlibFileSet['lib.esnext.promise.d.ts'] = true;\nlibFileSet['lib.esnext.string.d.ts'] = true;\nlibFileSet['lib.esnext.weakref.d.ts'] = true;\nlibFileSet['lib.scripthost.d.ts'] = true;\nlibFileSet['lib.webworker.d.ts'] = true;\nlibFileSet['lib.webworker.importscripts.d.ts'] = true;\nlibFileSet['lib.webworker.iterable.d.ts'] = true;\n\n;// CONCATENATED MODULE: ../../node_modules/monaco-editor/esm/vs/language/typescript/languageFeatures.js\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\nvar __extends = (undefined && undefined.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar languageFeatures_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar languageFeatures_generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\n\n//#region utils copied from typescript to prevent loading the entire typescriptServices ---\nvar IndentStyle;\n(function (IndentStyle) {\n IndentStyle[IndentStyle[\"None\"] = 0] = \"None\";\n IndentStyle[IndentStyle[\"Block\"] = 1] = \"Block\";\n IndentStyle[IndentStyle[\"Smart\"] = 2] = \"Smart\";\n})(IndentStyle || (IndentStyle = {}));\nfunction flattenDiagnosticMessageText(diag, newLine, indent) {\n if (indent === void 0) { indent = 0; }\n if (typeof diag === 'string') {\n return diag;\n }\n else if (diag === undefined) {\n return '';\n }\n var result = '';\n if (indent) {\n result += newLine;\n for (var i = 0; i < indent; i++) {\n result += ' ';\n }\n }\n result += diag.messageText;\n indent++;\n if (diag.next) {\n for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {\n var kid = _a[_i];\n result += flattenDiagnosticMessageText(kid, newLine, indent);\n }\n }\n return result;\n}\nfunction displayPartsToString(displayParts) {\n if (displayParts) {\n return displayParts.map(function (displayPart) { return displayPart.text; }).join('');\n }\n return '';\n}\n//#endregion\nvar Adapter = /** @class */ (function () {\n function Adapter(_worker) {\n this._worker = _worker;\n }\n // protected _positionToOffset(model: editor.ITextModel, position: monaco.IPosition): number {\n // \treturn model.getOffsetAt(position);\n // }\n // protected _offsetToPosition(model: editor.ITextModel, offset: number): monaco.IPosition {\n // \treturn model.getPositionAt(offset);\n // }\n Adapter.prototype._textSpanToRange = function (model, span) {\n var p1 = model.getPositionAt(span.start);\n var p2 = model.getPositionAt(span.start + span.length);\n var startLineNumber = p1.lineNumber, startColumn = p1.column;\n var endLineNumber = p2.lineNumber, endColumn = p2.column;\n return { startLineNumber: startLineNumber, startColumn: startColumn, endLineNumber: endLineNumber, endColumn: endColumn };\n };\n return Adapter;\n}());\n\n// --- lib files\nvar LibFiles = /** @class */ (function () {\n function LibFiles(_worker) {\n this._worker = _worker;\n this._libFiles = {};\n this._hasFetchedLibFiles = false;\n this._fetchLibFilesPromise = null;\n }\n LibFiles.prototype.isLibFile = function (uri) {\n if (!uri) {\n return false;\n }\n if (uri.path.indexOf('/lib.') === 0) {\n return !!libFileSet[uri.path.slice(1)];\n }\n return false;\n };\n LibFiles.prototype.getOrCreateModel = function (uri) {\n var model = monaco_editor_core/* editor.getModel */.j6.getModel(uri);\n if (model) {\n return model;\n }\n if (this.isLibFile(uri) && this._hasFetchedLibFiles) {\n return monaco_editor_core/* editor.createModel */.j6.createModel(this._libFiles[uri.path.slice(1)], 'typescript', uri);\n }\n return null;\n };\n LibFiles.prototype._containsLibFile = function (uris) {\n for (var _i = 0, uris_1 = uris; _i < uris_1.length; _i++) {\n var uri = uris_1[_i];\n if (this.isLibFile(uri)) {\n return true;\n }\n }\n return false;\n };\n LibFiles.prototype.fetchLibFilesIfNecessary = function (uris) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this._containsLibFile(uris)) {\n // no lib files necessary\n return [2 /*return*/];\n }\n return [4 /*yield*/, this._fetchLibFiles()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n LibFiles.prototype._fetchLibFiles = function () {\n var _this = this;\n if (!this._fetchLibFilesPromise) {\n this._fetchLibFilesPromise = this._worker()\n .then(function (w) { return w.getLibFiles(); })\n .then(function (libFiles) {\n _this._hasFetchedLibFiles = true;\n _this._libFiles = libFiles;\n });\n }\n return this._fetchLibFilesPromise;\n };\n return LibFiles;\n}());\n\n// --- diagnostics --- ---\nvar DiagnosticCategory;\n(function (DiagnosticCategory) {\n DiagnosticCategory[DiagnosticCategory[\"Warning\"] = 0] = \"Warning\";\n DiagnosticCategory[DiagnosticCategory[\"Error\"] = 1] = \"Error\";\n DiagnosticCategory[DiagnosticCategory[\"Suggestion\"] = 2] = \"Suggestion\";\n DiagnosticCategory[DiagnosticCategory[\"Message\"] = 3] = \"Message\";\n})(DiagnosticCategory || (DiagnosticCategory = {}));\nvar DiagnosticsAdapter = /** @class */ (function (_super) {\n __extends(DiagnosticsAdapter, _super);\n function DiagnosticsAdapter(_libFiles, _defaults, _selector, worker) {\n var _this = _super.call(this, worker) || this;\n _this._libFiles = _libFiles;\n _this._defaults = _defaults;\n _this._selector = _selector;\n _this._disposables = [];\n _this._listener = Object.create(null);\n var onModelAdd = function (model) {\n if (model.getModeId() !== _selector) {\n return;\n }\n var maybeValidate = function () {\n var onlyVisible = _this._defaults.getDiagnosticsOptions().onlyVisible;\n if (onlyVisible) {\n if (model.isAttachedToEditor()) {\n _this._doValidate(model);\n }\n }\n else {\n _this._doValidate(model);\n }\n };\n var handle;\n var changeSubscription = model.onDidChangeContent(function () {\n clearTimeout(handle);\n handle = setTimeout(maybeValidate, 500);\n });\n var visibleSubscription = model.onDidChangeAttached(function () {\n var onlyVisible = _this._defaults.getDiagnosticsOptions().onlyVisible;\n if (onlyVisible) {\n if (model.isAttachedToEditor()) {\n // this model is now attached to an editor\n // => compute diagnostics\n maybeValidate();\n }\n else {\n // this model is no longer attached to an editor\n // => clear existing diagnostics\n monaco_editor_core/* editor.setModelMarkers */.j6.setModelMarkers(model, _this._selector, []);\n }\n }\n });\n _this._listener[model.uri.toString()] = {\n dispose: function () {\n changeSubscription.dispose();\n visibleSubscription.dispose();\n clearTimeout(handle);\n }\n };\n maybeValidate();\n };\n var onModelRemoved = function (model) {\n monaco_editor_core/* editor.setModelMarkers */.j6.setModelMarkers(model, _this._selector, []);\n var key = model.uri.toString();\n if (_this._listener[key]) {\n _this._listener[key].dispose();\n delete _this._listener[key];\n }\n };\n _this._disposables.push(monaco_editor_core/* editor.onDidCreateModel */.j6.onDidCreateModel(function (model) { return onModelAdd(model); }));\n _this._disposables.push(monaco_editor_core/* editor.onWillDisposeModel */.j6.onWillDisposeModel(onModelRemoved));\n _this._disposables.push(monaco_editor_core/* editor.onDidChangeModelLanguage */.j6.onDidChangeModelLanguage(function (event) {\n onModelRemoved(event.model);\n onModelAdd(event.model);\n }));\n _this._disposables.push({\n dispose: function () {\n for (var _i = 0, _a = monaco_editor_core/* editor.getModels */.j6.getModels(); _i < _a.length; _i++) {\n var model = _a[_i];\n onModelRemoved(model);\n }\n }\n });\n var recomputeDiagostics = function () {\n // redo diagnostics when options change\n for (var _i = 0, _a = monaco_editor_core/* editor.getModels */.j6.getModels(); _i < _a.length; _i++) {\n var model = _a[_i];\n onModelRemoved(model);\n onModelAdd(model);\n }\n };\n _this._disposables.push(_this._defaults.onDidChange(recomputeDiagostics));\n _this._disposables.push(_this._defaults.onDidExtraLibsChange(recomputeDiagostics));\n monaco_editor_core/* editor.getModels */.j6.getModels().forEach(function (model) { return onModelAdd(model); });\n return _this;\n }\n DiagnosticsAdapter.prototype.dispose = function () {\n this._disposables.forEach(function (d) { return d && d.dispose(); });\n this._disposables = [];\n };\n DiagnosticsAdapter.prototype._doValidate = function (model) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var worker, promises, _a, noSyntaxValidation, noSemanticValidation, noSuggestionDiagnostics, allDiagnostics, diagnostics, relatedUris;\n var _this = this;\n return languageFeatures_generator(this, function (_b) {\n switch (_b.label) {\n case 0: return [4 /*yield*/, this._worker(model.uri)];\n case 1:\n worker = _b.sent();\n if (model.isDisposed()) {\n // model was disposed in the meantime\n return [2 /*return*/];\n }\n promises = [];\n _a = this._defaults.getDiagnosticsOptions(), noSyntaxValidation = _a.noSyntaxValidation, noSemanticValidation = _a.noSemanticValidation, noSuggestionDiagnostics = _a.noSuggestionDiagnostics;\n if (!noSyntaxValidation) {\n promises.push(worker.getSyntacticDiagnostics(model.uri.toString()));\n }\n if (!noSemanticValidation) {\n promises.push(worker.getSemanticDiagnostics(model.uri.toString()));\n }\n if (!noSuggestionDiagnostics) {\n promises.push(worker.getSuggestionDiagnostics(model.uri.toString()));\n }\n return [4 /*yield*/, Promise.all(promises)];\n case 2:\n allDiagnostics = _b.sent();\n if (!allDiagnostics || model.isDisposed()) {\n // model was disposed in the meantime\n return [2 /*return*/];\n }\n diagnostics = allDiagnostics\n .reduce(function (p, c) { return c.concat(p); }, [])\n .filter(function (d) {\n return (_this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore || []).indexOf(d.code) ===\n -1;\n });\n relatedUris = diagnostics\n .map(function (d) { return d.relatedInformation || []; })\n .reduce(function (p, c) { return c.concat(p); }, [])\n .map(function (relatedInformation) {\n return relatedInformation.file ? monaco_editor_core/* Uri.parse */.Sf.parse(relatedInformation.file.fileName) : null;\n });\n return [4 /*yield*/, this._libFiles.fetchLibFilesIfNecessary(relatedUris)];\n case 3:\n _b.sent();\n if (model.isDisposed()) {\n // model was disposed in the meantime\n return [2 /*return*/];\n }\n monaco_editor_core/* editor.setModelMarkers */.j6.setModelMarkers(model, this._selector, diagnostics.map(function (d) { return _this._convertDiagnostics(model, d); }));\n return [2 /*return*/];\n }\n });\n });\n };\n DiagnosticsAdapter.prototype._convertDiagnostics = function (model, diag) {\n var diagStart = diag.start || 0;\n var diagLength = diag.length || 1;\n var _a = model.getPositionAt(diagStart), startLineNumber = _a.lineNumber, startColumn = _a.column;\n var _b = model.getPositionAt(diagStart + diagLength), endLineNumber = _b.lineNumber, endColumn = _b.column;\n var tags = [];\n if (diag.reportsUnnecessary) {\n tags.push(monaco_editor_core/* MarkerTag.Unnecessary */.eB.Unnecessary);\n }\n if (diag.reportsDeprecated) {\n tags.push(monaco_editor_core/* MarkerTag.Deprecated */.eB.Deprecated);\n }\n return {\n severity: this._tsDiagnosticCategoryToMarkerSeverity(diag.category),\n startLineNumber: startLineNumber,\n startColumn: startColumn,\n endLineNumber: endLineNumber,\n endColumn: endColumn,\n message: flattenDiagnosticMessageText(diag.messageText, '\\n'),\n code: diag.code.toString(),\n tags: tags,\n relatedInformation: this._convertRelatedInformation(model, diag.relatedInformation)\n };\n };\n DiagnosticsAdapter.prototype._convertRelatedInformation = function (model, relatedInformation) {\n var _this = this;\n if (!relatedInformation) {\n return;\n }\n var result = [];\n relatedInformation.forEach(function (info) {\n var relatedResource = model;\n if (info.file) {\n var relatedResourceUri = monaco_editor_core/* Uri.parse */.Sf.parse(info.file.fileName);\n relatedResource = _this._libFiles.getOrCreateModel(relatedResourceUri);\n }\n if (!relatedResource) {\n return;\n }\n var infoStart = info.start || 0;\n var infoLength = info.length || 1;\n var _a = relatedResource.getPositionAt(infoStart), startLineNumber = _a.lineNumber, startColumn = _a.column;\n var _b = relatedResource.getPositionAt(infoStart + infoLength), endLineNumber = _b.lineNumber, endColumn = _b.column;\n result.push({\n resource: relatedResource.uri,\n startLineNumber: startLineNumber,\n startColumn: startColumn,\n endLineNumber: endLineNumber,\n endColumn: endColumn,\n message: flattenDiagnosticMessageText(info.messageText, '\\n')\n });\n });\n return result;\n };\n DiagnosticsAdapter.prototype._tsDiagnosticCategoryToMarkerSeverity = function (category) {\n switch (category) {\n case DiagnosticCategory.Error:\n return monaco_editor_core/* MarkerSeverity.Error */.ZL.Error;\n case DiagnosticCategory.Message:\n return monaco_editor_core/* MarkerSeverity.Info */.ZL.Info;\n case DiagnosticCategory.Warning:\n return monaco_editor_core/* MarkerSeverity.Warning */.ZL.Warning;\n case DiagnosticCategory.Suggestion:\n return monaco_editor_core/* MarkerSeverity.Hint */.ZL.Hint;\n }\n return monaco_editor_core/* MarkerSeverity.Info */.ZL.Info;\n };\n return DiagnosticsAdapter;\n}(Adapter));\n\nvar SuggestAdapter = /** @class */ (function (_super) {\n __extends(SuggestAdapter, _super);\n function SuggestAdapter() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Object.defineProperty(SuggestAdapter.prototype, \"triggerCharacters\", {\n get: function () {\n return ['.'];\n },\n enumerable: false,\n configurable: true\n });\n SuggestAdapter.prototype.provideCompletionItems = function (model, position, _context, token) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var wordInfo, wordRange, resource, offset, worker, info, suggestions;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n wordInfo = model.getWordUntilPosition(position);\n wordRange = new monaco_editor_core/* Range */.e6(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);\n resource = model.uri;\n offset = model.getOffsetAt(position);\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, worker.getCompletionsAtPosition(resource.toString(), offset)];\n case 2:\n info = _a.sent();\n if (!info || model.isDisposed()) {\n return [2 /*return*/];\n }\n suggestions = info.entries.map(function (entry) {\n var _a;\n var range = wordRange;\n if (entry.replacementSpan) {\n var p1 = model.getPositionAt(entry.replacementSpan.start);\n var p2 = model.getPositionAt(entry.replacementSpan.start + entry.replacementSpan.length);\n range = new monaco_editor_core/* Range */.e6(p1.lineNumber, p1.column, p2.lineNumber, p2.column);\n }\n var tags = [];\n if (((_a = entry.kindModifiers) === null || _a === void 0 ? void 0 : _a.indexOf('deprecated')) !== -1) {\n tags.push(monaco_editor_core/* languages.CompletionItemTag.Deprecated */.Mj.CompletionItemTag.Deprecated);\n }\n return {\n uri: resource,\n position: position,\n offset: offset,\n range: range,\n label: entry.name,\n insertText: entry.name,\n sortText: entry.sortText,\n kind: SuggestAdapter.convertKind(entry.kind),\n tags: tags\n };\n });\n return [2 /*return*/, {\n suggestions: suggestions\n }];\n }\n });\n });\n };\n SuggestAdapter.prototype.resolveCompletionItem = function (item, token) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var myItem, resource, position, offset, worker, details;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n myItem = item;\n resource = myItem.uri;\n position = myItem.position;\n offset = myItem.offset;\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n return [4 /*yield*/, worker.getCompletionEntryDetails(resource.toString(), offset, myItem.label)];\n case 2:\n details = _a.sent();\n if (!details) {\n return [2 /*return*/, myItem];\n }\n return [2 /*return*/, {\n uri: resource,\n position: position,\n label: details.name,\n kind: SuggestAdapter.convertKind(details.kind),\n detail: displayPartsToString(details.displayParts),\n documentation: {\n value: SuggestAdapter.createDocumentationString(details)\n }\n }];\n }\n });\n });\n };\n SuggestAdapter.convertKind = function (kind) {\n switch (kind) {\n case Kind.primitiveType:\n case Kind.keyword:\n return monaco_editor_core/* languages.CompletionItemKind.Keyword */.Mj.CompletionItemKind.Keyword;\n case Kind.variable:\n case Kind.localVariable:\n return monaco_editor_core/* languages.CompletionItemKind.Variable */.Mj.CompletionItemKind.Variable;\n case Kind.memberVariable:\n case Kind.memberGetAccessor:\n case Kind.memberSetAccessor:\n return monaco_editor_core/* languages.CompletionItemKind.Field */.Mj.CompletionItemKind.Field;\n case Kind.function:\n case Kind.memberFunction:\n case Kind.constructSignature:\n case Kind.callSignature:\n case Kind.indexSignature:\n return monaco_editor_core/* languages.CompletionItemKind.Function */.Mj.CompletionItemKind.Function;\n case Kind.enum:\n return monaco_editor_core/* languages.CompletionItemKind.Enum */.Mj.CompletionItemKind.Enum;\n case Kind.module:\n return monaco_editor_core/* languages.CompletionItemKind.Module */.Mj.CompletionItemKind.Module;\n case Kind.class:\n return monaco_editor_core/* languages.CompletionItemKind.Class */.Mj.CompletionItemKind.Class;\n case Kind.interface:\n return monaco_editor_core/* languages.CompletionItemKind.Interface */.Mj.CompletionItemKind.Interface;\n case Kind.warning:\n return monaco_editor_core/* languages.CompletionItemKind.File */.Mj.CompletionItemKind.File;\n }\n return monaco_editor_core/* languages.CompletionItemKind.Property */.Mj.CompletionItemKind.Property;\n };\n SuggestAdapter.createDocumentationString = function (details) {\n var documentationString = displayPartsToString(details.documentation);\n if (details.tags) {\n for (var _i = 0, _a = details.tags; _i < _a.length; _i++) {\n var tag = _a[_i];\n documentationString += \"\\n\\n\" + tagToString(tag);\n }\n }\n return documentationString;\n };\n return SuggestAdapter;\n}(Adapter));\n\nfunction tagToString(tag) {\n var tagLabel = \"*@\" + tag.name + \"*\";\n if (tag.name === 'param' && tag.text) {\n var _a = tag.text.split(' '), paramName = _a[0], rest = _a.slice(1);\n tagLabel += \"`\" + paramName + \"`\";\n if (rest.length > 0)\n tagLabel += \" \\u2014 \" + rest.join(' ');\n }\n else if (tag.text) {\n tagLabel += \" \\u2014 \" + tag.text;\n }\n return tagLabel;\n}\nvar SignatureHelpAdapter = /** @class */ (function (_super) {\n __extends(SignatureHelpAdapter, _super);\n function SignatureHelpAdapter() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.signatureHelpTriggerCharacters = ['(', ','];\n return _this;\n }\n SignatureHelpAdapter._toSignatureHelpTriggerReason = function (context) {\n switch (context.triggerKind) {\n case monaco_editor_core/* languages.SignatureHelpTriggerKind.TriggerCharacter */.Mj.SignatureHelpTriggerKind.TriggerCharacter:\n if (context.triggerCharacter) {\n if (context.isRetrigger) {\n return { kind: 'retrigger', triggerCharacter: context.triggerCharacter };\n }\n else {\n return { kind: 'characterTyped', triggerCharacter: context.triggerCharacter };\n }\n }\n else {\n return { kind: 'invoked' };\n }\n case monaco_editor_core/* languages.SignatureHelpTriggerKind.ContentChange */.Mj.SignatureHelpTriggerKind.ContentChange:\n return context.isRetrigger ? { kind: 'retrigger' } : { kind: 'invoked' };\n case monaco_editor_core/* languages.SignatureHelpTriggerKind.Invoke */.Mj.SignatureHelpTriggerKind.Invoke:\n default:\n return { kind: 'invoked' };\n }\n };\n SignatureHelpAdapter.prototype.provideSignatureHelp = function (model, position, token, context) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var resource, offset, worker, info, ret;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n resource = model.uri;\n offset = model.getOffsetAt(position);\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, worker.getSignatureHelpItems(resource.toString(), offset, {\n triggerReason: SignatureHelpAdapter._toSignatureHelpTriggerReason(context)\n })];\n case 2:\n info = _a.sent();\n if (!info || model.isDisposed()) {\n return [2 /*return*/];\n }\n ret = {\n activeSignature: info.selectedItemIndex,\n activeParameter: info.argumentIndex,\n signatures: []\n };\n info.items.forEach(function (item) {\n var signature = {\n label: '',\n parameters: []\n };\n signature.documentation = {\n value: displayPartsToString(item.documentation)\n };\n signature.label += displayPartsToString(item.prefixDisplayParts);\n item.parameters.forEach(function (p, i, a) {\n var label = displayPartsToString(p.displayParts);\n var parameter = {\n label: label,\n documentation: {\n value: displayPartsToString(p.documentation)\n }\n };\n signature.label += label;\n signature.parameters.push(parameter);\n if (i < a.length - 1) {\n signature.label += displayPartsToString(item.separatorDisplayParts);\n }\n });\n signature.label += displayPartsToString(item.suffixDisplayParts);\n ret.signatures.push(signature);\n });\n return [2 /*return*/, {\n value: ret,\n dispose: function () { }\n }];\n }\n });\n });\n };\n return SignatureHelpAdapter;\n}(Adapter));\n\n// --- hover ------\nvar QuickInfoAdapter = /** @class */ (function (_super) {\n __extends(QuickInfoAdapter, _super);\n function QuickInfoAdapter() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n QuickInfoAdapter.prototype.provideHover = function (model, position, token) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var resource, offset, worker, info, documentation, tags, contents;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n resource = model.uri;\n offset = model.getOffsetAt(position);\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, worker.getQuickInfoAtPosition(resource.toString(), offset)];\n case 2:\n info = _a.sent();\n if (!info || model.isDisposed()) {\n return [2 /*return*/];\n }\n documentation = displayPartsToString(info.documentation);\n tags = info.tags ? info.tags.map(function (tag) { return tagToString(tag); }).join(' \\n\\n') : '';\n contents = displayPartsToString(info.displayParts);\n return [2 /*return*/, {\n range: this._textSpanToRange(model, info.textSpan),\n contents: [\n {\n value: '```typescript\\n' + contents + '\\n```\\n'\n },\n {\n value: documentation + (tags ? '\\n\\n' + tags : '')\n }\n ]\n }];\n }\n });\n });\n };\n return QuickInfoAdapter;\n}(Adapter));\n\n// --- occurrences ------\nvar OccurrencesAdapter = /** @class */ (function (_super) {\n __extends(OccurrencesAdapter, _super);\n function OccurrencesAdapter() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n OccurrencesAdapter.prototype.provideDocumentHighlights = function (model, position, token) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var resource, offset, worker, entries;\n var _this = this;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n resource = model.uri;\n offset = model.getOffsetAt(position);\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, worker.getOccurrencesAtPosition(resource.toString(), offset)];\n case 2:\n entries = _a.sent();\n if (!entries || model.isDisposed()) {\n return [2 /*return*/];\n }\n return [2 /*return*/, entries.map(function (entry) {\n return {\n range: _this._textSpanToRange(model, entry.textSpan),\n kind: entry.isWriteAccess\n ? monaco_editor_core/* languages.DocumentHighlightKind.Write */.Mj.DocumentHighlightKind.Write\n : monaco_editor_core/* languages.DocumentHighlightKind.Text */.Mj.DocumentHighlightKind.Text\n };\n })];\n }\n });\n });\n };\n return OccurrencesAdapter;\n}(Adapter));\n\n// --- definition ------\nvar DefinitionAdapter = /** @class */ (function (_super) {\n __extends(DefinitionAdapter, _super);\n function DefinitionAdapter(_libFiles, worker) {\n var _this = _super.call(this, worker) || this;\n _this._libFiles = _libFiles;\n return _this;\n }\n DefinitionAdapter.prototype.provideDefinition = function (model, position, token) {\n return languageFeatures_awaiter(this, void 0, void 0, function () {\n var resource, offset, worker, entries, result, _i, entries_1, entry, uri, refModel;\n return languageFeatures_generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n resource = model.uri;\n offset = model.getOffsetAt(position);\n return [4 /*yield*/, this._worker(resource)];\n case 1:\n worker = _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, worker.getDefinitionAtPosition(resource.toString(), offset)];\n case 2:\n entries = _a.sent();\n if (!entries || model.isDisposed()) {\n return [2 /*return*/];\n }\n // Fetch lib files if necessary\n return [4 /*yield*/, this._libFiles.fetchLibFilesIfNecessary(entries.map(function (entry) { return monaco_editor_core/* Uri.parse */.Sf.parse(entry.fileName); }))];\n case 3:\n // Fetch lib files if necessary\n _a.sent();\n if (model.isDisposed()) {\n return [2 /*return*/];\n }\n