From 44062d16b4bea0bd0764355dfa7ffec463ab5236 Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Thu, 17 Aug 2023 14:40:48 +0200 Subject: [PATCH] Directly pass the message transport --- packages/client/src/monaco-language-client.ts | 12 ++++++------ packages/examples/main/src/common.ts | 6 +----- packages/examples/main/src/langium/langiumClient.ts | 6 +----- .../examples/main/src/langium/statemachineClient.ts | 6 +----- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/client/src/monaco-language-client.ts b/packages/client/src/monaco-language-client.ts index 14e61a358..9cd00f2d9 100644 --- a/packages/client/src/monaco-language-client.ts +++ b/packages/client/src/monaco-language-client.ts @@ -13,19 +13,19 @@ export type MonacoLanguageClientOptions = { name: string; id?: string; clientOptions: LanguageClientOptions; - connectionProvider: IConnectionProvider; + messageTransports: MessageTransports; } export class MonacoLanguageClient extends BaseLanguageClient { - protected readonly connectionProvider: IConnectionProvider; + protected readonly messageTransports: MessageTransports; - constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClientOptions) { + constructor({ id, name, clientOptions, messageTransports }: MonacoLanguageClientOptions) { super(id || name.toLowerCase(), name, clientOptions); - this.connectionProvider = connectionProvider; + this.messageTransports = messageTransports; } - protected createMessageTransports(encoding: string): Promise { - return this.connectionProvider.get(encoding); + protected override createMessageTransports(_encoding: string): Promise { + return Promise.resolve(this.messageTransports); } protected override getLocale(): string { diff --git a/packages/examples/main/src/common.ts b/packages/examples/main/src/common.ts index bbd464fc1..b1e18fef6 100644 --- a/packages/examples/main/src/common.ts +++ b/packages/examples/main/src/common.ts @@ -24,11 +24,7 @@ export const createLanguageClient = (transports: MessageTransports): MonacoLangu } }, // create a language client connection from the JSON RPC connection on demand - connectionProvider: { - get: () => { - return Promise.resolve(transports); - } - } + messageTransports: transports }); }; diff --git a/packages/examples/main/src/langium/langiumClient.ts b/packages/examples/main/src/langium/langiumClient.ts index a6843f4a8..601857059 100644 --- a/packages/examples/main/src/langium/langiumClient.ts +++ b/packages/examples/main/src/langium/langiumClient.ts @@ -81,11 +81,7 @@ const run = async () => { } }, // create a language client connection to the server running in the web worker - connectionProvider: { - get: () => { - return Promise.resolve(transports); - } - } + messageTransports: transports }); } diff --git a/packages/examples/main/src/langium/statemachineClient.ts b/packages/examples/main/src/langium/statemachineClient.ts index eb9906f59..c1225a1c2 100644 --- a/packages/examples/main/src/langium/statemachineClient.ts +++ b/packages/examples/main/src/langium/statemachineClient.ts @@ -90,11 +90,7 @@ const run = async () => { } }, // create a language client connection to the server running in the web worker - connectionProvider: { - get: () => { - return Promise.resolve(transports); - } - } + messageTransports: transports }); }