@teambit/ts-server 0.0.59 → 0.0.61
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.
- package/dist/format-diagnostics.js +38 -32
- package/dist/format-diagnostics.js.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/modules-resolver.js +43 -46
- package/dist/modules-resolver.js.map +1 -1
- package/dist/process-based-tsserver.js +238 -227
- package/dist/process-based-tsserver.js.map +1 -1
- package/dist/ts-server-client.d.ts +1 -1
- package/dist/ts-server-client.js +348 -328
- package/dist/ts-server-client.js.map +1 -1
- package/dist/tsp-command-types.js +170 -166
- package/dist/tsp-command-types.js.map +1 -1
- package/dist/utils.js +15 -11
- package/dist/utils.js.map +1 -1
- package/package.json +22 -8
- package/types/asset.d.ts +15 -3
- package/dist/preview-1734020193676.js +0 -7
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatDiagnostic = formatDiagnostic;
|
|
7
|
+
exports.formatDiagnostics = formatDiagnostics;
|
|
4
8
|
/**
|
|
5
9
|
* mostly taken from ts repo, src/compiler/program.ts "formatDiagnosticsWithColorAndContext" method.
|
|
6
10
|
* sadly, it's impossible to use that method for the diagnostic format coming from ts-server. it only
|
|
7
11
|
* works with the diagnostic format of "ts" APIs.
|
|
8
12
|
*/
|
|
9
13
|
function formatDiagnostics(diagnostics, filePath) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
let output = '';
|
|
15
|
+
for (const diagnostic of diagnostics) {
|
|
16
|
+
output += formatDiagnostic(diagnostic, filePath);
|
|
17
|
+
}
|
|
18
|
+
return output;
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
const diagnosticCategoryName = (diagnostic) => diagnostic.category;
|
|
20
|
+
const diagnosticCategoryName = diagnostic => diagnostic.category;
|
|
18
21
|
function formatDiagnostic(diagnostic, filePath) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const errorMessage = `${diagnosticCategoryName(diagnostic)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.text, '\n')}${'\n'}`;
|
|
23
|
+
const {
|
|
24
|
+
line,
|
|
25
|
+
offset
|
|
26
|
+
} = diagnostic.start;
|
|
27
|
+
return `${filePath}(${line},${offset}): ${errorMessage}`;
|
|
22
28
|
}
|
|
23
|
-
exports.formatDiagnostic = formatDiagnostic;
|
|
24
29
|
function flattenDiagnosticMessageText(diag, newLine, indent = 0) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
30
|
+
if (typeof diag === 'string') {
|
|
31
|
+
return diag;
|
|
32
|
+
}
|
|
33
|
+
if (diag === undefined) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
let result = '';
|
|
37
|
+
if (indent) {
|
|
38
|
+
result += newLine;
|
|
39
|
+
for (let i = 0; i < indent; i += 1) {
|
|
40
|
+
result += ' ';
|
|
37
41
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
}
|
|
43
|
+
result += diag.messageText;
|
|
44
|
+
indent += 1;
|
|
45
|
+
if (diag.next) {
|
|
46
|
+
for (const kid of diag.next) {
|
|
47
|
+
result += flattenDiagnosticMessageText(kid, newLine, indent);
|
|
44
48
|
}
|
|
45
|
-
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
46
51
|
}
|
|
52
|
+
|
|
47
53
|
//# sourceMappingURL=format-diagnostics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["formatDiagnostics","diagnostics","filePath","output","diagnostic","formatDiagnostic","diagnosticCategoryName","category","errorMessage","code","flattenDiagnosticMessageText","text","line","offset","start","diag","newLine","indent","undefined","result","i","messageText","next","kid"],"sources":["format-diagnostics.ts"],"sourcesContent":["import { DiagnosticMessageChain, server } from 'typescript';\n\ntype Diagnostic = server.protocol.Diagnostic;\n\n/**\n * mostly taken from ts repo, src/compiler/program.ts \"formatDiagnosticsWithColorAndContext\" method.\n * sadly, it's impossible to use that method for the diagnostic format coming from ts-server. it only\n * works with the diagnostic format of \"ts\" APIs.\n */\nexport function formatDiagnostics(diagnostics: readonly Diagnostic[], filePath: string): string {\n let output = '';\n\n for (const diagnostic of diagnostics) {\n output += formatDiagnostic(diagnostic, filePath);\n }\n return output;\n}\n\nconst diagnosticCategoryName = (diagnostic: Diagnostic) => diagnostic.category;\n\nexport function formatDiagnostic(diagnostic: Diagnostic, filePath: string): string {\n const errorMessage = `${diagnosticCategoryName(diagnostic)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(\n diagnostic.text,\n '\\n'\n )}${'\\n'}`;\n\n const { line, offset } = diagnostic.start;\n return `${filePath}(${line},${offset}): ${errorMessage}`;\n}\n\nfunction flattenDiagnosticMessageText(\n diag: string | DiagnosticMessageChain | undefined,\n newLine: string,\n indent = 0\n): string {\n if (typeof diag === 'string') {\n return diag;\n }\n if (diag === undefined) {\n return '';\n }\n let result = '';\n if (indent) {\n result += newLine;\n\n for (let i = 0; i < indent; i += 1) {\n result += ' ';\n }\n }\n result += diag.messageText;\n indent += 1;\n if (diag.next) {\n for (const kid of diag.next) {\n result += flattenDiagnosticMessageText(kid, newLine, indent);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAiBA,CAACC,WAAkC,EAAEC,QAAgB,EAAU;EAC9F,IAAIC,MAAM,GAAG,EAAE;EAEf,KAAK,MAAMC,UAAU,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}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TsserverClient", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _tsServerClient().TsserverClient;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function _tsServerClient() {
|
|
13
|
+
const data = require("./ts-server-client");
|
|
14
|
+
_tsServerClient = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_tsServerClient","data","require"],"sources":["index.ts"],"sourcesContent":["export type { TsserverClientOpts } from './ts-server-client';\nexport { TsserverClient } from './ts-server-client';\n"],"mappings":";;;;;;;;;;;AACA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
package/dist/modules-resolver.js
CHANGED
|
@@ -1,63 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findPathToModule = findPathToModule;
|
|
7
|
+
exports.findPathToYarnSdk = findPathToYarnSdk;
|
|
8
|
+
function fs() {
|
|
9
|
+
const data = _interopRequireWildcard(require("fs"));
|
|
10
|
+
fs = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function path() {
|
|
16
|
+
const data = _interopRequireWildcard(require("path"));
|
|
17
|
+
path = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
2
24
|
/**
|
|
3
25
|
* copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/modules-resolver.ts
|
|
4
26
|
* modified to accommodate Bit needs
|
|
5
27
|
*/
|
|
6
|
-
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.findPathToYarnSdk = exports.findPathToModule = void 0;
|
|
28
|
+
|
|
31
29
|
/*
|
|
32
30
|
* Copyright (C) 2017, 2018 TypeFox and others.
|
|
33
31
|
*
|
|
34
32
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
35
33
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
36
34
|
*/
|
|
37
|
-
|
|
38
|
-
const path = __importStar(require("path"));
|
|
35
|
+
|
|
39
36
|
function findPathToModule(dir, moduleName) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
try {
|
|
38
|
+
return require.resolve(moduleName, {
|
|
39
|
+
paths: [dir]
|
|
40
|
+
});
|
|
41
|
+
} catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
|
-
exports.findPathToModule = findPathToModule;
|
|
48
45
|
function findPathToYarnSdk(dir, moduleName) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
46
|
+
const stat = fs().statSync(dir);
|
|
47
|
+
if (stat.isDirectory()) {
|
|
48
|
+
const candidate = path().resolve(dir, '.yarn', 'sdks', moduleName);
|
|
49
|
+
if (fs().existsSync(candidate)) {
|
|
50
|
+
return candidate;
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
}
|
|
53
|
+
const parent = path().resolve(dir, '..');
|
|
54
|
+
if (parent !== dir) {
|
|
55
|
+
return findPathToYarnSdk(parent, moduleName);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
61
58
|
}
|
|
62
|
-
|
|
59
|
+
|
|
63
60
|
//# sourceMappingURL=modules-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["fs","data","_interopRequireWildcard","require","path","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","findPathToModule","dir","moduleName","resolve","paths","undefined","findPathToYarnSdk","stat","statSync","isDirectory","candidate","existsSync","parent"],"sources":["modules-resolver.ts"],"sourcesContent":["/**\n * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/modules-resolver.ts\n * modified to accommodate Bit needs\n */\n\n/*\n * Copyright (C) 2017, 2018 TypeFox and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n */\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport function findPathToModule(dir: string, moduleName: string): string | undefined {\n try {\n return require.resolve(moduleName, { paths: [dir] });\n } catch {\n return undefined;\n }\n}\n\nexport function findPathToYarnSdk(dir: string, moduleName: string): string | undefined {\n const stat = fs.statSync(dir);\n if (stat.isDirectory()) {\n const candidate = path.resolve(dir, '.yarn', 'sdks', moduleName);\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n }\n const parent = path.resolve(dir, '..');\n if (parent !== dir) {\n return findPathToYarnSdk(parent, moduleName);\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AAWA,SAAAA,GAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,EAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EA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