mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Add support for web TS Server logging over postMessage
For https://github.com/microsoft/TypeScript/pull/39656
This commit is contained in:
@@ -3,10 +3,16 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import type * as Proto from '../protocol';
|
||||
import { TypeScriptServiceConfiguration } from '../utils/configuration';
|
||||
import { memoize } from '../utils/memoize';
|
||||
import { TsServerProcess, TsServerProcessKind } from './server';
|
||||
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
declare const Worker: any;
|
||||
declare type Worker = any;
|
||||
|
||||
@@ -37,6 +43,11 @@ export class WorkerServerProcess implements TsServerProcess {
|
||||
args: readonly string[],
|
||||
) {
|
||||
worker.addEventListener('message', (msg: any) => {
|
||||
if (msg.data.type === 'log') {
|
||||
this.output.appendLine(msg.data.body);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const handler of this._onDataHandlers) {
|
||||
handler(msg.data);
|
||||
}
|
||||
@@ -44,6 +55,11 @@ export class WorkerServerProcess implements TsServerProcess {
|
||||
worker.postMessage(args);
|
||||
}
|
||||
|
||||
@memoize
|
||||
private get output(): vscode.OutputChannel {
|
||||
return vscode.window.createOutputChannel(localize('channelName', 'TypeScript Server Log'));
|
||||
}
|
||||
|
||||
write(serverRequest: Proto.Request): void {
|
||||
this.worker.postMessage(serverRequest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user