typescript-language-server 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +39 -0
  3. package/README.md +43 -2
  4. package/lib/cli.js +6 -6
  5. package/lib/cli.js.map +1 -1
  6. package/lib/completion.d.ts +1 -2
  7. package/lib/completion.d.ts.map +1 -1
  8. package/lib/completion.js +38 -19
  9. package/lib/completion.js.map +1 -1
  10. package/lib/configuration-manager.d.ts +3 -10
  11. package/lib/configuration-manager.d.ts.map +1 -1
  12. package/lib/configuration-manager.js +24 -4
  13. package/lib/configuration-manager.js.map +1 -1
  14. package/lib/diagnostic-queue.d.ts +1 -1
  15. package/lib/diagnostic-queue.d.ts.map +1 -1
  16. package/lib/features/inlay-hints.js +2 -2
  17. package/lib/features/inlay-hints.js.map +1 -1
  18. package/lib/lsp-connection.d.ts +5 -5
  19. package/lib/lsp-connection.d.ts.map +1 -1
  20. package/lib/lsp-connection.js +2 -3
  21. package/lib/lsp-connection.js.map +1 -1
  22. package/lib/lsp-server.d.ts +7 -10
  23. package/lib/lsp-server.d.ts.map +1 -1
  24. package/lib/lsp-server.js +61 -115
  25. package/lib/lsp-server.js.map +1 -1
  26. package/lib/lsp-server.spec.js +382 -81
  27. package/lib/lsp-server.spec.js.map +1 -1
  28. package/lib/refactor.d.ts +2 -1
  29. package/lib/refactor.d.ts.map +1 -1
  30. package/lib/refactor.js +17 -7
  31. package/lib/refactor.js.map +1 -1
  32. package/lib/test-utils.d.ts +18 -0
  33. package/lib/test-utils.d.ts.map +1 -1
  34. package/lib/test-utils.js +24 -12
  35. package/lib/test-utils.js.map +1 -1
  36. package/lib/ts-protocol.d.ts +30 -8
  37. package/lib/ts-protocol.d.ts.map +1 -1
  38. package/lib/ts-protocol.js +7 -1
  39. package/lib/ts-protocol.js.map +1 -1
  40. package/lib/tsServer/callbackMap.d.ts +17 -0
  41. package/lib/tsServer/callbackMap.d.ts.map +1 -0
  42. package/lib/tsServer/callbackMap.js +47 -0
  43. package/lib/tsServer/callbackMap.js.map +1 -0
  44. package/lib/tsServer/cancellation.d.ts +22 -0
  45. package/lib/tsServer/cancellation.d.ts.map +1 -0
  46. package/lib/tsServer/cancellation.js +51 -0
  47. package/lib/tsServer/cancellation.js.map +1 -0
  48. package/lib/tsServer/logDirectoryProvider.d.ts +13 -0
  49. package/lib/tsServer/logDirectoryProvider.d.ts.map +1 -0
  50. package/lib/tsServer/logDirectoryProvider.js +49 -0
  51. package/lib/tsServer/logDirectoryProvider.js.map +1 -0
  52. package/lib/tsServer/requestQueue.d.ts +34 -0
  53. package/lib/tsServer/requestQueue.d.ts.map +1 -0
  54. package/lib/tsServer/requestQueue.js +74 -0
  55. package/lib/tsServer/requestQueue.js.map +1 -0
  56. package/lib/tsServer/requests.d.ts +68 -0
  57. package/lib/tsServer/requests.d.ts.map +1 -0
  58. package/lib/tsServer/requests.js +28 -0
  59. package/lib/tsServer/requests.js.map +1 -0
  60. package/lib/tsServer/server.d.ts +95 -0
  61. package/lib/tsServer/server.d.ts.map +1 -0
  62. package/lib/tsServer/server.js +209 -0
  63. package/lib/tsServer/server.js.map +1 -0
  64. package/lib/tsServer/serverError.d.ts +18 -0
  65. package/lib/tsServer/serverError.d.ts.map +1 -0
  66. package/lib/tsServer/serverError.js +53 -0
  67. package/lib/tsServer/serverError.js.map +1 -0
  68. package/lib/tsServer/serverProcess.d.ts +7 -0
  69. package/lib/tsServer/serverProcess.d.ts.map +1 -0
  70. package/lib/tsServer/serverProcess.js +238 -0
  71. package/lib/tsServer/serverProcess.js.map +1 -0
  72. package/lib/tsServer/spawner.d.ts +19 -0
  73. package/lib/tsServer/spawner.d.ts.map +1 -0
  74. package/lib/tsServer/spawner.js +130 -0
  75. package/lib/tsServer/spawner.js.map +1 -0
  76. package/lib/tsServer/tracer.d.ts +26 -0
  77. package/lib/tsServer/tracer.d.ts.map +1 -0
  78. package/lib/tsServer/tracer.js +80 -0
  79. package/lib/tsServer/tracer.js.map +1 -0
  80. package/lib/{utils → tsServer}/versionProvider.d.ts +8 -8
  81. package/lib/tsServer/versionProvider.d.ts.map +1 -0
  82. package/lib/{utils → tsServer}/versionProvider.js +28 -22
  83. package/lib/tsServer/versionProvider.js.map +1 -0
  84. package/lib/tsp-client.d.ts +25 -55
  85. package/lib/tsp-client.d.ts.map +1 -1
  86. package/lib/tsp-client.js +186 -140
  87. package/lib/tsp-client.js.map +1 -1
  88. package/lib/tsp-client.spec.js +23 -8
  89. package/lib/tsp-client.spec.js.map +1 -1
  90. package/lib/utils/api.d.ts +1 -0
  91. package/lib/utils/api.d.ts.map +1 -1
  92. package/lib/utils/api.js +1 -0
  93. package/lib/utils/api.js.map +1 -1
  94. package/lib/utils/configuration.d.ts +17 -8
  95. package/lib/utils/configuration.d.ts.map +1 -1
  96. package/lib/utils/configuration.js +43 -1
  97. package/lib/utils/configuration.js.map +1 -1
  98. package/lib/utils/logger.d.ts +65 -0
  99. package/lib/utils/logger.d.ts.map +1 -0
  100. package/lib/utils/logger.js +189 -0
  101. package/lib/utils/logger.js.map +1 -0
  102. package/lib/utils/modules-resolver.spec.js +1 -1
  103. package/lib/utils/modules-resolver.spec.js.map +1 -1
  104. package/package.json +12 -12
  105. package/lib/logger.d.ts +0 -48
  106. package/lib/logger.d.ts.map +0 -1
  107. package/lib/logger.js +0 -106
  108. package/lib/logger.js.map +0 -1
  109. package/lib/utils/versionProvider.d.ts.map +0 -1
  110. package/lib/utils/versionProvider.js.map +0 -1
@@ -0,0 +1,209 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /*
6
+ * Copyright (C) 2022 TypeFox and others.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ */
11
+ import { RequestQueue, RequestQueueingType } from './requestQueue.js';
12
+ import { ServerResponse } from './requests.js';
13
+ import { CallbackMap } from './callbackMap.js';
14
+ import { TypeScriptServerError } from './serverError.js';
15
+ export var ExecutionTarget;
16
+ (function (ExecutionTarget) {
17
+ ExecutionTarget[ExecutionTarget["Semantic"] = 0] = "Semantic";
18
+ ExecutionTarget[ExecutionTarget["Syntax"] = 1] = "Syntax";
19
+ })(ExecutionTarget = ExecutionTarget || (ExecutionTarget = {}));
20
+ export class ProcessBasedTsServer {
21
+ constructor(_serverId, _serverSource, _process, _tsServerLogFile, _requestCanceller, _version, _tracer) {
22
+ this._serverId = _serverId;
23
+ this._serverSource = _serverSource;
24
+ this._process = _process;
25
+ this._tsServerLogFile = _tsServerLogFile;
26
+ this._requestCanceller = _requestCanceller;
27
+ this._version = _version;
28
+ this._tracer = _tracer;
29
+ this._requestQueue = new RequestQueue();
30
+ this._callbacks = new CallbackMap();
31
+ this._pendingResponses = new Set();
32
+ this._eventHandlers = new Set();
33
+ this._exitHandlers = new Set();
34
+ this._errorHandlers = new Set();
35
+ this._process.onData(msg => {
36
+ this.dispatchMessage(msg);
37
+ });
38
+ this._process.onExit((code, signal) => {
39
+ this._exitHandlers.forEach(handler => handler({ code, signal }));
40
+ this._callbacks.destroy('server exited');
41
+ });
42
+ this._process.onError(error => {
43
+ this._errorHandlers.forEach(handler => handler(error));
44
+ this._callbacks.destroy('server errored');
45
+ });
46
+ }
47
+ onEvent(handler) {
48
+ this._eventHandlers.add(handler);
49
+ }
50
+ onExit(handler) {
51
+ this._exitHandlers.add(handler);
52
+ }
53
+ onError(handler) {
54
+ this._errorHandlers.add(handler);
55
+ }
56
+ get tsServerLogFile() {
57
+ return this._tsServerLogFile;
58
+ }
59
+ write(serverRequest) {
60
+ this._process.write(serverRequest);
61
+ }
62
+ dispose() {
63
+ this._callbacks.destroy('server disposed');
64
+ this._pendingResponses.clear();
65
+ this._eventHandlers.clear();
66
+ this._exitHandlers.clear();
67
+ this._errorHandlers.clear();
68
+ }
69
+ kill() {
70
+ this.dispose();
71
+ this._process.kill();
72
+ }
73
+ dispatchMessage(message) {
74
+ try {
75
+ switch (message.type) {
76
+ case 'response':
77
+ if (this._serverSource) {
78
+ this.dispatchResponse({
79
+ ...message,
80
+ });
81
+ }
82
+ else {
83
+ this.dispatchResponse(message);
84
+ }
85
+ break;
86
+ case 'event': {
87
+ const event = message;
88
+ if (event.event === 'requestCompleted') {
89
+ const seq = event.body.request_seq;
90
+ const callback = this._callbacks.fetch(seq);
91
+ if (callback) {
92
+ this._tracer.traceRequestCompleted(this._serverId, 'requestCompleted', seq, callback);
93
+ callback.onSuccess(undefined);
94
+ }
95
+ }
96
+ else {
97
+ this._tracer.traceEvent(this._serverId, event);
98
+ this._eventHandlers.forEach(handler => handler(event));
99
+ }
100
+ break;
101
+ }
102
+ default:
103
+ throw new Error(`Unknown message type ${message.type} received`);
104
+ }
105
+ }
106
+ finally {
107
+ this.sendNextRequests();
108
+ }
109
+ }
110
+ tryCancelRequest(seq, command) {
111
+ try {
112
+ if (this._requestQueue.tryDeletePendingRequest(seq)) {
113
+ this.logTrace(`Canceled request with sequence number ${seq}`);
114
+ return true;
115
+ }
116
+ if (this._requestCanceller.tryCancelOngoingRequest(seq)) {
117
+ return true;
118
+ }
119
+ this.logTrace(`Tried to cancel request with sequence number ${seq}. But request got already delivered.`);
120
+ return false;
121
+ }
122
+ finally {
123
+ const callback = this.fetchCallback(seq);
124
+ callback?.onSuccess(new ServerResponse.Cancelled(`Cancelled request ${seq} - ${command}`));
125
+ }
126
+ }
127
+ dispatchResponse(response) {
128
+ const callback = this.fetchCallback(response.request_seq);
129
+ if (!callback) {
130
+ return;
131
+ }
132
+ this._tracer.traceResponse(this._serverId, response, callback);
133
+ if (response.success) {
134
+ callback.onSuccess(response);
135
+ }
136
+ else if (response.message === 'No content available.') {
137
+ // Special case where response itself is successful but there is not any data to return.
138
+ callback.onSuccess(ServerResponse.NoContent);
139
+ }
140
+ else {
141
+ callback.onError(TypeScriptServerError.create(this._serverId, this._version, response));
142
+ }
143
+ }
144
+ executeImpl(command, args, executeInfo) {
145
+ const request = this._requestQueue.createRequest(command, args);
146
+ const requestInfo = {
147
+ request,
148
+ expectsResponse: executeInfo.expectsResult,
149
+ isAsync: executeInfo.isAsync,
150
+ queueingType: ProcessBasedTsServer.getQueueingType(command, executeInfo.lowPriority),
151
+ };
152
+ let result;
153
+ if (executeInfo.expectsResult) {
154
+ result = new Promise((resolve, reject) => {
155
+ this._callbacks.add(request.seq, { onSuccess: resolve, onError: reject, queuingStartTime: Date.now(), isAsync: executeInfo.isAsync }, executeInfo.isAsync);
156
+ if (executeInfo.token) {
157
+ executeInfo.token.onCancellationRequested(() => {
158
+ this.tryCancelRequest(request.seq, command);
159
+ });
160
+ }
161
+ });
162
+ }
163
+ this._requestQueue.enqueue(requestInfo);
164
+ this.sendNextRequests();
165
+ return [result];
166
+ }
167
+ sendNextRequests() {
168
+ // console.error({ pending: this._pendingResponses.size, queue: this._requestQueue.length });
169
+ while (this._pendingResponses.size === 0 && this._requestQueue.length > 0) {
170
+ const item = this._requestQueue.dequeue();
171
+ if (item) {
172
+ this.sendRequest(item);
173
+ }
174
+ }
175
+ }
176
+ sendRequest(requestItem) {
177
+ const serverRequest = requestItem.request;
178
+ this._tracer.traceRequest(this._serverId, serverRequest, requestItem.expectsResponse, this._requestQueue.length);
179
+ if (requestItem.expectsResponse && !requestItem.isAsync) {
180
+ this._pendingResponses.add(requestItem.request.seq);
181
+ }
182
+ try {
183
+ this.write(serverRequest);
184
+ }
185
+ catch (err) {
186
+ const callback = this.fetchCallback(serverRequest.seq);
187
+ callback?.onError(err);
188
+ }
189
+ }
190
+ fetchCallback(seq) {
191
+ const callback = this._callbacks.fetch(seq);
192
+ if (!callback) {
193
+ return undefined;
194
+ }
195
+ this._pendingResponses.delete(seq);
196
+ return callback;
197
+ }
198
+ logTrace(message) {
199
+ this._tracer.logTrace(this._serverId, message);
200
+ }
201
+ static getQueueingType(command, lowPriority) {
202
+ if (ProcessBasedTsServer.fenceCommands.has(command)) {
203
+ return RequestQueueingType.Fence;
204
+ }
205
+ return lowPriority ? RequestQueueingType.LowPriority : RequestQueueingType.Normal;
206
+ }
207
+ }
208
+ ProcessBasedTsServer.fenceCommands = new Set(['change', 'close', 'open', 'updateOpen']);
209
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/tsServer/server.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AAIH,OAAO,EAAe,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAsC,MAAM,eAAe,CAAC;AAGnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,6DAAQ,CAAA;IACR,yDAAM,CAAA;AACV,CAAC,EAHW,eAAe,GAAf,eAAe,KAAf,eAAe,QAG1B;AAuDD,MAAM,OAAO,oBAAoB;IAQ7B,YACqB,SAAiB,EACjB,aAAyB,EACzB,QAAyB,EACzB,gBAAoC,EACpC,iBAA0C,EAC1C,QAA2B,EAC3B,OAAe;QANf,cAAS,GAAT,SAAS,CAAQ;QACjB,kBAAa,GAAb,aAAa,CAAY;QACzB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAyB;QAC1C,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,YAAO,GAAP,OAAO,CAAQ;QAdnB,kBAAa,GAAG,IAAI,YAAY,EAAE,CAAC;QACnC,eAAU,GAAG,IAAI,WAAW,EAAgB,CAAC;QAC7C,sBAAiB,GAAG,IA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C,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,QAAQ,CAAC,OAAe;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAIO,MAAM,CAAC,eAAe,CAC1B,OAAe,EACf,WAAqB;QAErB,IAAI,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACjD,OAAO,mBAAmB,CAAC,KAAK,CAAC;SACpC;QACD,OAAO,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC;IACtF,CAAC;;AAVuB,kCAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type tsp from 'typescript/lib/protocol.d.js';
2
+ import type { TypeScriptVersion } from './versionProvider.js';
3
+ export declare class TypeScriptServerError extends Error {
4
+ readonly serverId: string;
5
+ readonly version: TypeScriptVersion;
6
+ private readonly response;
7
+ readonly serverMessage: string | undefined;
8
+ readonly serverStack: string | undefined;
9
+ static create(serverId: string, version: TypeScriptVersion, response: tsp.Response): TypeScriptServerError;
10
+ private constructor();
11
+ get serverErrorText(): string | undefined;
12
+ get serverCommand(): string;
13
+ /**
14
+ * Given a `errorText` from a tsserver request indicating failure in handling a request.
15
+ */
16
+ private static parseErrorText;
17
+ }
18
+ //# sourceMappingURL=serverError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/tsServer/serverError.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,qBAAa,qBAAsB,SAAQ,KAAK;aAWxB,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,iBAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ;aACT,aAAa,EAAE,MAAM,GAAG,SAAS;aACjC,WAAW,EAAE,MAAM,GAAG,SAAS;WAdrC,MAAM,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ,GACvB,qBAAqB;IAKxB,OAAO;IAUP,IAAW,eAAe,IAAI,MAAM,GAAG,SAAS,CAE/C;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAmBhC"}
@@ -0,0 +1,53 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /*
6
+ * Copyright (C) 2022 TypeFox and others.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ */
11
+ export class TypeScriptServerError extends Error {
12
+ constructor(serverId, version, response, serverMessage, serverStack) {
13
+ super(`<${serverId}> TypeScript Server Error (${version.versionString})\n${serverMessage}\n${serverStack}`);
14
+ this.serverId = serverId;
15
+ this.version = version;
16
+ this.response = response;
17
+ this.serverMessage = serverMessage;
18
+ this.serverStack = serverStack;
19
+ }
20
+ static create(serverId, version, response) {
21
+ const parsedResult = TypeScriptServerError.parseErrorText(response);
22
+ return new TypeScriptServerError(serverId, version, response, parsedResult?.message, parsedResult?.stack);
23
+ }
24
+ get serverErrorText() {
25
+ return this.response.message;
26
+ }
27
+ get serverCommand() {
28
+ return this.response.command;
29
+ }
30
+ /**
31
+ * Given a `errorText` from a tsserver request indicating failure in handling a request.
32
+ */
33
+ static parseErrorText(response) {
34
+ const errorText = response.message;
35
+ if (errorText) {
36
+ const errorPrefix = 'Error processing request. ';
37
+ if (errorText.startsWith(errorPrefix)) {
38
+ const prefixFreeErrorText = errorText.substr(errorPrefix.length);
39
+ const newlineIndex = prefixFreeErrorText.indexOf('\n');
40
+ if (newlineIndex >= 0) {
41
+ // Newline expected between message and stack.
42
+ const stack = prefixFreeErrorText.substring(newlineIndex + 1);
43
+ return {
44
+ message: prefixFreeErrorText.substring(0, newlineIndex),
45
+ stack,
46
+ };
47
+ }
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+ }
53
+ //# sourceMappingURL=serverError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../src/tsServer/serverError.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AAKH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAU5C,YACoB,QAAgB,EAChB,OAA0B,EACzB,QAAsB,EACvB,aAAiC,EACjC,WAA+B;QAE/C,KAAK,CAAC,IAAI,QAAQ,8BAA8B,OAAO,CAAC,aAAa,MAAM,aAAa,KAAK,WAAW,EAAE,CAAC,CAAC;QAN5F,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAc;QACvB,kBAAa,GAAb,aAAa,CAAoB;QACjC,gBAAW,GAAX,WAAW,CAAoB;IAGnD,CAAC;IAjBM,MAAM,CAAC,MAAM,CAChB,QAAgB,EAChB,OAA0B,EAC1B,QAAsB;QAEtB,MAAM,YAAY,GAAG,qBAAqB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpE,OAAO,IAAI,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IAC9G,CAAC;IAYD,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,cAAc,CAAC,QAAsB;QAChD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC;QACnC,IAAI,SAAS,EAAE;YACX,MAAM,WAAW,GAAG,4BAA4B,CAAC;YACjD,IAAI,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACnC,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACjE,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvD,IAAI,YAAY,IAAI,CAAC,EAAE;oBACnB,8CAA8C;oBAC9C,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;oBAC9D,OAAO;wBACH,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC;wBACvD,KAAK;qBACR,CAAC;iBACL;aACJ;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -0,0 +1,7 @@
1
+ import { TsServerProcess, TsServerProcessFactory, TsServerProcessKind } from './server.js';
2
+ import type { TspClientOptions } from '../tsp-client.js';
3
+ import type { TypeScriptVersion } from './versionProvider.js';
4
+ export declare class NodeTsServerProcessFactory implements TsServerProcessFactory {
5
+ fork(version: TypeScriptVersion, args: readonly string[], kind: TsServerProcessKind, configuration: TspClientOptions): TsServerProcess;
6
+ }
7
+ //# sourceMappingURL=serverProcess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverProcess.d.ts","sourceRoot":"","sources":["../../src/tsServer/serverProcess.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,qBAAa,0BAA2B,YAAW,sBAAsB;IACrE,IAAI,CACA,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,mBAAmB,EACzB,aAAa,EAAE,gBAAgB,GAChC,eAAe;CAmBrB"}
@@ -0,0 +1,238 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /*
6
+ * Copyright (C) 2022 TypeFox and others.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ */
11
+ import ChildProcess from 'node:child_process';
12
+ import path from 'node:path';
13
+ import API from '../utils/api.js';
14
+ export class NodeTsServerProcessFactory {
15
+ fork(version, args, kind, configuration) {
16
+ const tsServerPath = version.tsServerPath;
17
+ const useIpc = version.version?.gte(API.v460);
18
+ const runtimeArgs = [...args];
19
+ if (useIpc) {
20
+ runtimeArgs.push('--useNodeIpc');
21
+ }
22
+ const childProcess = ChildProcess.fork(tsServerPath, runtimeArgs, {
23
+ silent: true,
24
+ cwd: undefined,
25
+ env: generatePatchedEnv(process.env, tsServerPath),
26
+ execArgv: getExecArgv(kind, configuration),
27
+ stdio: useIpc ? ['pipe', 'pipe', 'pipe', 'ipc'] : undefined,
28
+ });
29
+ return useIpc ? new IpcChildServerProcess(childProcess) : new StdioChildServerProcess(childProcess);
30
+ }
31
+ }
32
+ function generatePatchedEnv(env, modulePath) {
33
+ const newEnv = Object.assign({}, env);
34
+ newEnv.NODE_PATH = path.join(modulePath, '..', '..', '..');
35
+ // Ensure we always have a PATH set
36
+ newEnv.PATH = newEnv.PATH || process.env.PATH;
37
+ return newEnv;
38
+ }
39
+ function getExecArgv(kind, configuration) {
40
+ const args = [];
41
+ const debugPort = getDebugPort(kind);
42
+ if (debugPort) {
43
+ const inspectFlag = getTssDebugBrk() ? '--inspect-brk' : '--inspect';
44
+ args.push(`${inspectFlag}=${debugPort}`);
45
+ }
46
+ if (configuration.maxTsServerMemory) {
47
+ args.push(`--max-old-space-size=${configuration.maxTsServerMemory}`);
48
+ }
49
+ return args;
50
+ }
51
+ function getDebugPort(kind) {
52
+ if (kind === "syntax" /* TsServerProcessKind.Syntax */) {
53
+ // We typically only want to debug the main semantic server
54
+ return undefined;
55
+ }
56
+ const value = getTssDebugBrk() || getTssDebug();
57
+ if (value) {
58
+ const port = parseInt(value);
59
+ if (!isNaN(port)) {
60
+ return port;
61
+ }
62
+ }
63
+ return undefined;
64
+ }
65
+ function getTssDebug() {
66
+ return process.env.TSS_DEBUG;
67
+ }
68
+ function getTssDebugBrk() {
69
+ return process.env.TSS_DEBUG_BRK;
70
+ }
71
+ class IpcChildServerProcess {
72
+ constructor(_process) {
73
+ this._process = _process;
74
+ }
75
+ write(serverRequest) {
76
+ this._process.send(serverRequest);
77
+ }
78
+ onData(handler) {
79
+ this._process.on('message', handler);
80
+ }
81
+ onExit(handler) {
82
+ this._process.on('exit', handler);
83
+ }
84
+ onError(handler) {
85
+ this._process.on('error', handler);
86
+ }
87
+ kill() {
88
+ this._process.kill();
89
+ }
90
+ }
91
+ class StdioChildServerProcess {
92
+ constructor(_process) {
93
+ this._process = _process;
94
+ this._reader = new Reader(this._process.stdout);
95
+ }
96
+ get reader() {
97
+ return this._reader;
98
+ }
99
+ write(serverRequest) {
100
+ this._process.stdin.write(JSON.stringify(serverRequest) + '\r\n', 'utf8');
101
+ }
102
+ onData(handler) {
103
+ this.reader.onData(handler);
104
+ }
105
+ onExit(handler) {
106
+ this._process.on('exit', handler);
107
+ }
108
+ onError(handler) {
109
+ this._process.on('error', handler);
110
+ this.reader.onError(handler);
111
+ }
112
+ kill() {
113
+ this._process.kill();
114
+ this.reader.dispose();
115
+ this._reader = null;
116
+ }
117
+ }
118
+ class Reader {
119
+ constructor(readable) {
120
+ this.buffer = new ProtocolBuffer();
121
+ this.nextMessageLength = -1;
122
+ this._onError = (_error) => { };
123
+ this._onData = (_data) => { };
124
+ this.isDisposed = false;
125
+ readable.on('data', data => this.onLengthData(data));
126
+ }
127
+ dispose() {
128
+ this.isDisposed = true;
129
+ this._onError = (_error) => { };
130
+ this._onData = (_data) => { };
131
+ }
132
+ onError(handler) {
133
+ this._onError = handler;
134
+ }
135
+ onData(handler) {
136
+ this._onData = handler;
137
+ }
138
+ onLengthData(data) {
139
+ if (this.isDisposed) {
140
+ return;
141
+ }
142
+ try {
143
+ this.buffer.append(data);
144
+ // eslint-disable-next-line no-constant-condition
145
+ while (true) {
146
+ if (this.nextMessageLength === -1) {
147
+ this.nextMessageLength = this.buffer.tryReadContentLength();
148
+ if (this.nextMessageLength === -1) {
149
+ return;
150
+ }
151
+ }
152
+ const msg = this.buffer.tryReadContent(this.nextMessageLength);
153
+ if (msg === null) {
154
+ return;
155
+ }
156
+ this.nextMessageLength = -1;
157
+ const json = JSON.parse(msg);
158
+ this._onData(json);
159
+ }
160
+ }
161
+ catch (e) {
162
+ this._onError(e);
163
+ }
164
+ }
165
+ }
166
+ const defaultSize = 8192;
167
+ const contentLength = 'Content-Length: ';
168
+ const contentLengthSize = Buffer.byteLength(contentLength, 'utf8');
169
+ const blank = Buffer.from(' ', 'utf8')[0];
170
+ const backslashR = Buffer.from('\r', 'utf8')[0];
171
+ const backslashN = Buffer.from('\n', 'utf8')[0];
172
+ class ProtocolBuffer {
173
+ constructor() {
174
+ this.index = 0;
175
+ this.buffer = Buffer.allocUnsafe(defaultSize);
176
+ }
177
+ append(data) {
178
+ let toAppend = null;
179
+ if (Buffer.isBuffer(data)) {
180
+ toAppend = data;
181
+ }
182
+ else {
183
+ toAppend = Buffer.from(data, 'utf8');
184
+ }
185
+ if (this.buffer.length - this.index >= toAppend.length) {
186
+ toAppend.copy(this.buffer, this.index, 0, toAppend.length);
187
+ }
188
+ else {
189
+ const newSize = (Math.ceil((this.index + toAppend.length) / defaultSize) + 1) * defaultSize;
190
+ if (this.index === 0) {
191
+ this.buffer = Buffer.allocUnsafe(newSize);
192
+ toAppend.copy(this.buffer, 0, 0, toAppend.length);
193
+ }
194
+ else {
195
+ this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
196
+ }
197
+ }
198
+ this.index += toAppend.length;
199
+ }
200
+ tryReadContentLength() {
201
+ let result = -1;
202
+ let current = 0;
203
+ // we are utf8 encoding...
204
+ while (current < this.index && (this.buffer[current] === blank || this.buffer[current] === backslashR || this.buffer[current] === backslashN)) {
205
+ current++;
206
+ }
207
+ if (this.index < current + contentLengthSize) {
208
+ return result;
209
+ }
210
+ current += contentLengthSize;
211
+ const start = current;
212
+ while (current < this.index && this.buffer[current] !== backslashR) {
213
+ current++;
214
+ }
215
+ if (current + 3 >= this.index || this.buffer[current + 1] !== backslashN || this.buffer[current + 2] !== backslashR || this.buffer[current + 3] !== backslashN) {
216
+ return result;
217
+ }
218
+ const data = this.buffer.toString('utf8', start, current);
219
+ result = parseInt(data);
220
+ this.buffer = this.buffer.slice(current + 4);
221
+ this.index = this.index - (current + 4);
222
+ return result;
223
+ }
224
+ tryReadContent(length) {
225
+ if (this.index < length) {
226
+ return null;
227
+ }
228
+ const result = this.buffer.toString('utf8', 0, length);
229
+ let sourceStart = length;
230
+ while (sourceStart < this.index && (this.buffer[sourceStart] === backslashR || this.buffer[sourceStart] === backslashN)) {
231
+ sourceStart++;
232
+ }
233
+ this.buffer.copy(this.buffer, 0, sourceStart);
234
+ this.index = this.index - sourceStart;
235
+ return result;
236
+ }
237
+ }
238
+ //# sourceMappingURL=serverProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverProcess.js","sourceRoot":"","sources":["../../src/tsServer/serverProcess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AAEH,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAGlC,MAAM,OAAO,0BAA0B;IACnC,IAAI,CACA,OAA0B,EAC1B,IAAuB,EACvB,IAAyB,EACzB,aAA+B;QAE/B,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE9C,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9B,IAAI,MAAM,EAAE;YACR,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACpC;QAED,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE;YAC9D,MAAM,EAAE,IAAI;YACZ,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC;YAClD,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC;YAC1C,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;SAC9D,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,uBAAuB,CAAC,YAAY,CAAC,CAAC;IACxG,CAAC;CACJ;AAED,SAAS,kBAAkB,C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,GAAG,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,cAAc,CAAC,MAAc;QAChC,IAAI,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE;YACrB,OAAO,IAAI,CAAC;SACf;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QACvD,IAAI,WAAW,GAAG,MAAM,CAAC;QACzB,OAAO,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,UAAU,CAAC,EAAE;YACrH,WAAW,EAAE,CAAC;SACjB;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QACtC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
@@ -0,0 +1,19 @@
1
+ import API from '../utils/api.js';
2
+ import { Logger } from '../utils/logger.js';
3
+ import type { TspClientOptions } from '../tsp-client.js';
4
+ import type { ILogDirectoryProvider } from './logDirectoryProvider.js';
5
+ import { ITypeScriptServer } from './server.js';
6
+ import type Tracer from './tracer.js';
7
+ import type { TypeScriptVersion } from './versionProvider.js';
8
+ export declare class TypeScriptServerSpawner {
9
+ private readonly _apiVersion;
10
+ private readonly _logDirectoryProvider;
11
+ private readonly _logger;
12
+ private readonly _tracer;
13
+ constructor(_apiVersion: API, _logDirectoryProvider: ILogDirectoryProvider, _logger: Logger, _tracer: Tracer);
14
+ spawn(version: TypeScriptVersion, configuration: TspClientOptions): ITypeScriptServer;
15
+ private kindToServerType;
16
+ private getTsServerArgs;
17
+ private isLoggingEnabled;
18
+ }
19
+ //# sourceMappingURL=spawner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.d.ts","sourceRoot":"","sources":["../../src/tsServer/spawner.ts"],"names":[],"mappings":"AAYA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC,OAAO,EAAE,MAAM,EAAY,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAA6C,MAAM,aAAa,CAAC;AAE3F,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,WAAW,EAAE,GAAG,EAChB,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM;IAG7B,KAAK,CACR,OAAO,EAAE,iBAAiB,EAC1B,aAAa,EAAE,gBAAgB,GAChC,iBAAiB;IA0BpB,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,eAAe;IA8EvB,OAAO,CAAC,gBAAgB;CAG3B"}