@teambit/ts-server 0.0.75 → 0.0.76
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.
|
@@ -64,8 +64,11 @@ export declare class TsserverClient {
|
|
|
64
64
|
*
|
|
65
65
|
* the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors
|
|
66
66
|
* were found or not.
|
|
67
|
+
*
|
|
68
|
+
* @param files files to check
|
|
69
|
+
* @param batchSize if provided, files will be processed in batches to avoid overwhelming tsserver
|
|
67
70
|
*/
|
|
68
|
-
getDiagnostic(files?: string[]): Promise<any>;
|
|
71
|
+
getDiagnostic(files?: string[], batchSize?: number): Promise<any>;
|
|
69
72
|
/**
|
|
70
73
|
* avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project
|
|
71
74
|
*/
|
package/dist/ts-server-client.js
CHANGED
|
@@ -175,13 +175,27 @@ class TsserverClient {
|
|
|
175
175
|
*
|
|
176
176
|
* the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors
|
|
177
177
|
* were found or not.
|
|
178
|
+
*
|
|
179
|
+
* @param files files to check
|
|
180
|
+
* @param batchSize if provided, files will be processed in batches to avoid overwhelming tsserver
|
|
178
181
|
*/
|
|
179
|
-
async getDiagnostic(files = this.files) {
|
|
182
|
+
async getDiagnostic(files = this.files, batchSize) {
|
|
180
183
|
this.lastDiagnostics = [];
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
if (!batchSize || files.length <= batchSize) {
|
|
185
|
+
return this.tsServer?.request(_tspCommandTypes().CommandTypes.Geterr, {
|
|
186
|
+
delay: 0,
|
|
187
|
+
files
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Process files in batches
|
|
192
|
+
for (let i = 0; i < files.length; i += batchSize) {
|
|
193
|
+
const batch = files.slice(i, i + batchSize);
|
|
194
|
+
await this.tsServer?.request(_tspCommandTypes().CommandTypes.Geterr, {
|
|
195
|
+
delay: 0,
|
|
196
|
+
files: batch
|
|
197
|
+
});
|
|
198
|
+
}
|
|
185
199
|
}
|
|
186
200
|
|
|
187
201
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_watcher","_commandExists","_modulesResolver","_processBasedTsserver","_tspCommandTypes","_utils","_formatDiagnostics","e","__esModule","default","TsserverClient","lastDiagnostics","serverRunning","diagnosticData","constructor","projectPath","logger","options","files","init","tsServer","ProcessBasedTsServer","tsserverPath","findTsserverPath","logToConsole","verbose","onEvent","onTsserverEvent","bind","start","then","catch","err","error","length","openPromises","map","file","open","Promise","all","promise","failedFiles","filter","Error","checkTypesIfNeeded","debug","shouldCheckTypes","Date","now","getDiagnostic","end","msg","consoleFailure","consoleSuccess","console","Boolean","checkTypes","onFileChange","changed","CheckTypes","ChangedFile","undefined","killTsServer","kill","isServerRunning","request","CommandTypes","Geterr","delay","getDiagnosticAllProject","requestedByFile","GeterrForProject","getQuickInfo","position","absFile","convertFileToAbsoluteIfNeeded","openIfNeeded","Quickinfo","line","offset","character","getTypeDefinition","TypeDefinition","getDefinition","response","Definition","success","warn","getReferences","References","getSignatureHelp","SignatureHelp","configure","configureArgs","Configure","includes","push","notify","Open","projectRootPath","close","Close","openFile","Change","endLine","endOffset","insertString","content","fs","readFile","event","EventName","semanticDiag","syntaxDiag","publishDiagnostic","filepath","path","isAbsolute","join","message","body","diagnostics","printTypeErrors","aggregateDiagnosticData","relative","forEach","diag","formatted","formatDiagnostic","diagnostic","tsServerPath","bundled","findPathToModule","__dirname","commandExists","sync","getTsserverExecutable","exports"],"sources":["ts-server-client.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport type { Logger } from '@teambit/logger';\nimport path from 'path';\nimport type ts from 'typescript/lib/tsserverlibrary';\nimport { CheckTypes } from '@teambit/watcher';\nimport type { Position } from 'vscode-languageserver-types';\nimport commandExists from 'command-exists';\nimport { findPathToModule } from './modules-resolver';\nimport { ProcessBasedTsServer } from './process-based-tsserver';\nimport { CommandTypes, EventName } from './tsp-command-types';\nimport { getTsserverExecutable } from './utils';\nimport type { Diagnostic } from './format-diagnostics';\nimport { formatDiagnostic } from './format-diagnostics';\n\nexport type TsserverClientOpts = {\n verbose?: boolean; // print tsserver events to the console.\n tsServerPath?: string; // if not provided, it'll use findTsserverPath() strategies.\n checkTypes?: CheckTypes; // whether errors/warnings are monitored and printed to the console.\n printTypeErrors?: boolean; // whether print typescript errors to the console.\n aggregateDiagnosticData?: boolean; // whether to aggregate diagnostic data instead of printing them to the console.\n};\n\nexport type DiagnosticData = {\n file: string;\n diagnostic: Diagnostic;\n formatted: string;\n};\n\nexport class TsserverClient {\n private tsServer: ProcessBasedTsServer | null;\n public lastDiagnostics: ts.server.protocol.DiagnosticEventBody[] = [];\n private serverRunning = false;\n public diagnosticData: DiagnosticData[] = [];\n constructor(\n /**\n * absolute root path of the project.\n */\n private projectPath: string,\n private logger: Logger,\n private options: TsserverClientOpts = {},\n /**\n * provide files if you want to check types on init. (options.checkTypes should be enabled).\n * paths should be absolute.\n */\n private files: string[] = []\n ) {}\n\n /**\n * start the ts-server and keep its process alive.\n * this methods returns pretty fast. if checkTypes is enabled, it runs the process in the background and\n * doesn't wait for it.\n */\n async init(): Promise<void> {\n try {\n this.tsServer = new ProcessBasedTsServer({\n logger: this.logger,\n tsserverPath: this.findTsserverPath(),\n logToConsole: this.options.verbose,\n onEvent: this.onTsserverEvent.bind(this),\n });\n\n this.tsServer\n .start()\n .then(() => {\n this.serverRunning = true;\n })\n .catch((err) => {\n this.logger.error('TsserverClient.init failed', err);\n });\n\n if (this.files.length) {\n const openPromises = this.files.map((file) => this.open(file));\n await Promise.all(openPromises.map((promise) => promise.catch((error) => error)));\n const failedFiles = openPromises.filter((promise) => promise instanceof Error);\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n this.checkTypesIfNeeded();\n }\n this.logger.debug('TsserverClient.init completed');\n } catch (err) {\n this.logger.error('TsserverClient.init failed', err);\n }\n }\n\n private checkTypesIfNeeded(files = this.files) {\n if (!this.shouldCheckTypes()) {\n return;\n }\n const start = Date.now();\n this.getDiagnostic(files)\n .then(() => {\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n if (this.lastDiagnostics.length) {\n this.logger.consoleFailure(`${msg}. found errors in ${this.lastDiagnostics.length} files.`);\n } else {\n this.logger.consoleSuccess(`${msg}. no errors were found.`);\n }\n })\n .catch((err) => {\n const msg = `failed getting the type errors from ts-server`;\n this.logger.console(msg);\n this.logger.error(msg, err);\n });\n }\n\n private shouldCheckTypes() {\n // this also covers this.options.checkTypes !== CheckTypes.None.\n return Boolean(this.options.checkTypes);\n }\n\n /**\n * if `bit watch` or `bit start` are running in the background, this method is triggered.\n */\n async onFileChange(file: string) {\n await this.changed(file);\n const files = this.options.checkTypes === CheckTypes.ChangedFile ? [file] : undefined;\n this.checkTypesIfNeeded(files);\n }\n\n killTsServer() {\n if (this.tsServer && this.serverRunning) {\n this.tsServer.kill();\n this.tsServer = null;\n this.serverRunning = false;\n }\n }\n\n isServerRunning() {\n return this.serverRunning;\n }\n\n /**\n * get diagnostic of all files opened in the project.\n * there is little to no value of getting diagnostic for a specific file, as\n * changing a type in one file may cause errors in different files.\n *\n * the errors/diagnostic info are sent as events, see this.onTsserverEvent() for more info.\n *\n * the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors\n * were found or not.\n */\n async getDiagnostic(files = this.files): Promise<any> {\n this.lastDiagnostics = [];\n return this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files });\n }\n\n /**\n * avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project\n */\n async getDiagnosticAllProject(requestedByFile: string): Promise<any> {\n return this.tsServer?.request(CommandTypes.GeterrForProject, { file: requestedByFile, delay: 0 });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getQuickInfo(file: string, position: Position): Promise<ts.server.protocol.QuickInfoResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.Quickinfo, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getTypeDefinition(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.TypeDefinitionResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.TypeDefinition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n async getDefinition(file: string, position: Position) {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n const response = await this.tsServer?.request(CommandTypes.Definition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n\n if (!response?.success) {\n // TODO: we need a function to handle responses properly here for all.\n this.logger.warn(`For file ${absFile} tsserver failed to request definition info`);\n return response;\n }\n\n return response;\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getReferences(file: string, position: Position): Promise<ts.server.protocol.ReferencesResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.References, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getSignatureHelp(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.SignatureHelpResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n\n return this.tsServer?.request(CommandTypes.SignatureHelp, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n private async configure(\n configureArgs: ts.server.protocol.ConfigureRequestArguments = {}\n ): Promise<ts.server.protocol.ConfigureResponse | undefined> {\n return this.tsServer?.request(CommandTypes.Configure, configureArgs);\n }\n\n /**\n * ask tsserver to open a file if it was not opened before.\n * @param file absolute path of the file\n */\n async openIfNeeded(file: string) {\n if (this.files.includes(file)) {\n return;\n }\n await this.open(file);\n this.files.push(file);\n }\n\n private async open(file: string) {\n return this.tsServer?.notify(CommandTypes.Open, {\n file,\n projectRootPath: this.projectPath,\n });\n }\n\n async close(file: string) {\n await this.tsServer?.notify(CommandTypes.Close, {\n file,\n });\n this.files = this.files.filter((openFile) => openFile !== file);\n }\n\n /**\n * since Bit is not an IDE, it doesn't have the information such as the exact line/offset of the changes.\n * as a workaround, to tell tsserver what was changed, we pretend that the entire file was cleared and new text was\n * added. this is the only way I could find to tell tsserver about the change. otherwise, tsserver keep assuming that\n * the file content remained the same. (closing/re-opening the file doesn't help).\n */\n async changed(file: string) {\n // tell tsserver that all content was removed\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 99999,\n endOffset: 1,\n insertString: '',\n });\n\n const content = await fs.readFile(file, 'utf-8');\n\n // tell tsserver that all file content was added\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 1,\n endOffset: 1,\n insertString: content,\n });\n }\n\n protected onTsserverEvent(event: ts.server.protocol.Event): void {\n switch (event.event) {\n case EventName.semanticDiag:\n case EventName.syntaxDiag:\n this.publishDiagnostic(event as ts.server.protocol.DiagnosticEvent);\n break;\n default:\n this.logger.debug(`ignored TsServer event: ${event.event}`);\n }\n }\n\n private convertFileToAbsoluteIfNeeded(filepath: string): string {\n if (path.isAbsolute(filepath)) {\n return filepath;\n }\n return path.join(this.projectPath, filepath);\n }\n\n private publishDiagnostic(message: ts.server.protocol.DiagnosticEvent) {\n if (!message.body?.diagnostics.length || (!this.options.printTypeErrors && !this.options.aggregateDiagnosticData)) {\n return;\n }\n this.lastDiagnostics.push(message.body);\n const file = path.relative(this.projectPath, message.body.file);\n message.body.diagnostics.forEach((diag) => {\n const formatted = formatDiagnostic(diag, file);\n if (this.options.printTypeErrors) {\n this.logger.console(formatted);\n }\n if (this.options.aggregateDiagnosticData) {\n this.diagnosticData.push({\n file,\n diagnostic: diag,\n formatted,\n });\n }\n });\n }\n\n /**\n * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/lsp-server.ts\n */\n private findTsserverPath(): string {\n if (this.options.tsServerPath) {\n return this.options.tsServerPath;\n }\n\n const tsServerPath = path.join('typescript', 'lib', 'tsserver.js');\n\n /**\n * (1) find it in the bit directory\n */\n const bundled = findPathToModule(__dirname, tsServerPath);\n\n if (bundled) {\n return bundled;\n }\n\n // (2) use globally installed tsserver\n if (commandExists.sync(getTsserverExecutable())) {\n return getTsserverExecutable();\n }\n\n throw new Error(`Couldn't find '${getTsserverExecutable()}' executable or 'tsserver.js' module`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,iBAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,gBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SA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AAC,mCAAgB,EAACC,SAAS,EAAEH,YAAY,CAAC;IAEzD,IAAIC,OAAO,EAAE;MACX,OAAOA,OAAO;IAChB;;IAEA;IACA,IAAIG,wBAAa,CAACC,IAAI,CAAC,IAAAC,8BAAqB,EAAC,CAAC,CAAC,EAAE;MAC/C,OAAO,IAAAA,8BAAqB,EAAC,CAAC;IAChC;IAEA,MAAM,IAAI7F,KAAK,CAAC,kBAAkB,IAAA6F,8BAAqB,EAAC,CAAC,sCAAsC,CAAC;EAClG;AACF;AAACC,OAAA,CAAAhI,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_watcher","_commandExists","_modulesResolver","_processBasedTsserver","_tspCommandTypes","_utils","_formatDiagnostics","e","__esModule","default","TsserverClient","lastDiagnostics","serverRunning","diagnosticData","constructor","projectPath","logger","options","files","init","tsServer","ProcessBasedTsServer","tsserverPath","findTsserverPath","logToConsole","verbose","onEvent","onTsserverEvent","bind","start","then","catch","err","error","length","openPromises","map","file","open","Promise","all","promise","failedFiles","filter","Error","checkTypesIfNeeded","debug","shouldCheckTypes","Date","now","getDiagnostic","end","msg","consoleFailure","consoleSuccess","console","Boolean","checkTypes","onFileChange","changed","CheckTypes","ChangedFile","undefined","killTsServer","kill","isServerRunning","batchSize","request","CommandTypes","Geterr","delay","i","batch","slice","getDiagnosticAllProject","requestedByFile","GeterrForProject","getQuickInfo","position","absFile","convertFileToAbsoluteIfNeeded","openIfNeeded","Quickinfo","line","offset","character","getTypeDefinition","TypeDefinition","getDefinition","response","Definition","success","warn","getReferences","References","getSignatureHelp","SignatureHelp","configure","configureArgs","Configure","includes","push","notify","Open","projectRootPath","close","Close","openFile","Change","endLine","endOffset","insertString","content","fs","readFile","event","EventName","semanticDiag","syntaxDiag","publishDiagnostic","filepath","path","isAbsolute","join","message","body","diagnostics","printTypeErrors","aggregateDiagnosticData","relative","forEach","diag","formatted","formatDiagnostic","diagnostic","tsServerPath","bundled","findPathToModule","__dirname","commandExists","sync","getTsserverExecutable","exports"],"sources":["ts-server-client.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport type { Logger } from '@teambit/logger';\nimport path from 'path';\nimport type ts from 'typescript/lib/tsserverlibrary';\nimport { CheckTypes } from '@teambit/watcher';\nimport type { Position } from 'vscode-languageserver-types';\nimport commandExists from 'command-exists';\nimport { findPathToModule } from './modules-resolver';\nimport { ProcessBasedTsServer } from './process-based-tsserver';\nimport { CommandTypes, EventName } from './tsp-command-types';\nimport { getTsserverExecutable } from './utils';\nimport type { Diagnostic } from './format-diagnostics';\nimport { formatDiagnostic } from './format-diagnostics';\n\nexport type TsserverClientOpts = {\n verbose?: boolean; // print tsserver events to the console.\n tsServerPath?: string; // if not provided, it'll use findTsserverPath() strategies.\n checkTypes?: CheckTypes; // whether errors/warnings are monitored and printed to the console.\n printTypeErrors?: boolean; // whether print typescript errors to the console.\n aggregateDiagnosticData?: boolean; // whether to aggregate diagnostic data instead of printing them to the console.\n};\n\nexport type DiagnosticData = {\n file: string;\n diagnostic: Diagnostic;\n formatted: string;\n};\n\nexport class TsserverClient {\n private tsServer: ProcessBasedTsServer | null;\n public lastDiagnostics: ts.server.protocol.DiagnosticEventBody[] = [];\n private serverRunning = false;\n public diagnosticData: DiagnosticData[] = [];\n constructor(\n /**\n * absolute root path of the project.\n */\n private projectPath: string,\n private logger: Logger,\n private options: TsserverClientOpts = {},\n /**\n * provide files if you want to check types on init. (options.checkTypes should be enabled).\n * paths should be absolute.\n */\n private files: string[] = []\n ) {}\n\n /**\n * start the ts-server and keep its process alive.\n * this methods returns pretty fast. if checkTypes is enabled, it runs the process in the background and\n * doesn't wait for it.\n */\n async init(): Promise<void> {\n try {\n this.tsServer = new ProcessBasedTsServer({\n logger: this.logger,\n tsserverPath: this.findTsserverPath(),\n logToConsole: this.options.verbose,\n onEvent: this.onTsserverEvent.bind(this),\n });\n\n this.tsServer\n .start()\n .then(() => {\n this.serverRunning = true;\n })\n .catch((err) => {\n this.logger.error('TsserverClient.init failed', err);\n });\n\n if (this.files.length) {\n const openPromises = this.files.map((file) => this.open(file));\n await Promise.all(openPromises.map((promise) => promise.catch((error) => error)));\n const failedFiles = openPromises.filter((promise) => promise instanceof Error);\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n this.checkTypesIfNeeded();\n }\n this.logger.debug('TsserverClient.init completed');\n } catch (err) {\n this.logger.error('TsserverClient.init failed', err);\n }\n }\n\n private checkTypesIfNeeded(files = this.files) {\n if (!this.shouldCheckTypes()) {\n return;\n }\n const start = Date.now();\n this.getDiagnostic(files)\n .then(() => {\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n if (this.lastDiagnostics.length) {\n this.logger.consoleFailure(`${msg}. found errors in ${this.lastDiagnostics.length} files.`);\n } else {\n this.logger.consoleSuccess(`${msg}. no errors were found.`);\n }\n })\n .catch((err) => {\n const msg = `failed getting the type errors from ts-server`;\n this.logger.console(msg);\n this.logger.error(msg, err);\n });\n }\n\n private shouldCheckTypes() {\n // this also covers this.options.checkTypes !== CheckTypes.None.\n return Boolean(this.options.checkTypes);\n }\n\n /**\n * if `bit watch` or `bit start` are running in the background, this method is triggered.\n */\n async onFileChange(file: string) {\n await this.changed(file);\n const files = this.options.checkTypes === CheckTypes.ChangedFile ? [file] : undefined;\n this.checkTypesIfNeeded(files);\n }\n\n killTsServer() {\n if (this.tsServer && this.serverRunning) {\n this.tsServer.kill();\n this.tsServer = null;\n this.serverRunning = false;\n }\n }\n\n isServerRunning() {\n return this.serverRunning;\n }\n\n /**\n * get diagnostic of all files opened in the project.\n * there is little to no value of getting diagnostic for a specific file, as\n * changing a type in one file may cause errors in different files.\n *\n * the errors/diagnostic info are sent as events, see this.onTsserverEvent() for more info.\n *\n * the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors\n * were found or not.\n *\n * @param files files to check\n * @param batchSize if provided, files will be processed in batches to avoid overwhelming tsserver\n */\n async getDiagnostic(files = this.files, batchSize?: number): Promise<any> {\n this.lastDiagnostics = [];\n\n if (!batchSize || files.length <= batchSize) {\n return this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files });\n }\n\n // Process files in batches\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n await this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files: batch });\n }\n }\n\n /**\n * avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project\n */\n async getDiagnosticAllProject(requestedByFile: string): Promise<any> {\n return this.tsServer?.request(CommandTypes.GeterrForProject, { file: requestedByFile, delay: 0 });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getQuickInfo(file: string, position: Position): Promise<ts.server.protocol.QuickInfoResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.Quickinfo, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getTypeDefinition(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.TypeDefinitionResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.TypeDefinition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n async getDefinition(file: string, position: Position) {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n const response = await this.tsServer?.request(CommandTypes.Definition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n\n if (!response?.success) {\n // TODO: we need a function to handle responses properly here for all.\n this.logger.warn(`For file ${absFile} tsserver failed to request definition info`);\n return response;\n }\n\n return response;\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getReferences(file: string, position: Position): Promise<ts.server.protocol.ReferencesResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.References, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getSignatureHelp(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.SignatureHelpResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n\n return this.tsServer?.request(CommandTypes.SignatureHelp, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n private async configure(\n configureArgs: ts.server.protocol.ConfigureRequestArguments = {}\n ): Promise<ts.server.protocol.ConfigureResponse | undefined> {\n return this.tsServer?.request(CommandTypes.Configure, configureArgs);\n }\n\n /**\n * ask tsserver to open a file if it was not opened before.\n * @param file absolute path of the file\n */\n async openIfNeeded(file: string) {\n if (this.files.includes(file)) {\n return;\n }\n await this.open(file);\n this.files.push(file);\n }\n\n private async open(file: string) {\n return this.tsServer?.notify(CommandTypes.Open, {\n file,\n projectRootPath: this.projectPath,\n });\n }\n\n async close(file: string) {\n await this.tsServer?.notify(CommandTypes.Close, {\n file,\n });\n this.files = this.files.filter((openFile) => openFile !== file);\n }\n\n /**\n * since Bit is not an IDE, it doesn't have the information such as the exact line/offset of the changes.\n * as a workaround, to tell tsserver what was changed, we pretend that the entire file was cleared and new text was\n * added. this is the only way I could find to tell tsserver about the change. otherwise, tsserver keep assuming that\n * the file content remained the same. (closing/re-opening the file doesn't help).\n */\n async changed(file: string) {\n // tell tsserver that all content was removed\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 99999,\n endOffset: 1,\n insertString: '',\n });\n\n const content = await fs.readFile(file, 'utf-8');\n\n // tell tsserver that all file content was added\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 1,\n endOffset: 1,\n insertString: content,\n });\n }\n\n protected onTsserverEvent(event: ts.server.protocol.Event): void {\n switch (event.event) {\n case EventName.semanticDiag:\n case EventName.syntaxDiag:\n this.publishDiagnostic(event as ts.server.protocol.DiagnosticEvent);\n break;\n default:\n this.logger.debug(`ignored TsServer event: ${event.event}`);\n }\n }\n\n private convertFileToAbsoluteIfNeeded(filepath: string): string {\n if (path.isAbsolute(filepath)) {\n return filepath;\n }\n return path.join(this.projectPath, filepath);\n }\n\n private publishDiagnostic(message: ts.server.protocol.DiagnosticEvent) {\n if (!message.body?.diagnostics.length || (!this.options.printTypeErrors && !this.options.aggregateDiagnosticData)) {\n return;\n }\n this.lastDiagnostics.push(message.body);\n const file = path.relative(this.projectPath, message.body.file);\n message.body.diagnostics.forEach((diag) => {\n const formatted = formatDiagnostic(diag, file);\n if (this.options.printTypeErrors) {\n this.logger.console(formatted);\n }\n if (this.options.aggregateDiagnosticData) {\n this.diagnosticData.push({\n file,\n diagnostic: diag,\n formatted,\n });\n }\n });\n }\n\n /**\n * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/lsp-server.ts\n */\n private findTsserverPath(): string {\n if (this.options.tsServerPath) {\n return this.options.tsServerPath;\n }\n\n const tsServerPath = path.join('typescript', 'lib', 'tsserver.js');\n\n /**\n * (1) find it in the bit directory\n */\n const bundled = findPathToModule(__dirname, tsServerPath);\n\n if (bundled) {\n return bundled;\n }\n\n // (2) use globally installed tsserver\n if (commandExists.sync(getTsserverExecutable())) {\n return getTsserverExecutable();\n }\n\n throw new Error(`Couldn't find '${getTsserverExecutable()}' executable or 'tsserver.js' module`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAA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G,8BAAqB,EAAC,CAAC,sCAAsC,CAAC;EAClG;AACF;AAACC,OAAA,CAAApI,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/ts-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/typescript/ts-server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.typescript",
|
|
8
8
|
"name": "ts-server",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.76"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"typescript": "5.9.2",
|
package/ts-server-client.ts
CHANGED
|
@@ -143,10 +143,22 @@ export class TsserverClient {
|
|
|
143
143
|
*
|
|
144
144
|
* the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors
|
|
145
145
|
* were found or not.
|
|
146
|
+
*
|
|
147
|
+
* @param files files to check
|
|
148
|
+
* @param batchSize if provided, files will be processed in batches to avoid overwhelming tsserver
|
|
146
149
|
*/
|
|
147
|
-
async getDiagnostic(files = this.files): Promise<any> {
|
|
150
|
+
async getDiagnostic(files = this.files, batchSize?: number): Promise<any> {
|
|
148
151
|
this.lastDiagnostics = [];
|
|
149
|
-
|
|
152
|
+
|
|
153
|
+
if (!batchSize || files.length <= batchSize) {
|
|
154
|
+
return this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Process files in batches
|
|
158
|
+
for (let i = 0; i < files.length; i += batchSize) {
|
|
159
|
+
const batch = files.slice(i, i + batchSize);
|
|
160
|
+
await this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files: batch });
|
|
161
|
+
}
|
|
150
162
|
}
|
|
151
163
|
|
|
152
164
|
/**
|