Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Backport changes from #17 and #18
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Mar 23, 2023
1 parent 0b4a256 commit c1b6be6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"dependencies": {
"http-server": "~14.1.1",
"monaco-editor-wrapper": "../monaco-editor-wrapper",
"monaco-editor-wrapper": "1.6.1",
"monaco-editor-comp": "../monaco-editor-comp",
"monaco-editor-react": "../monaco-editor-react",
"monaco-editor-workers": "../monaco-editor-workers",
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco-editor-comp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"npm": "8.19.3"
},
"dependencies": {
"monaco-editor-wrapper": "1.6.0",
"monaco-editor-wrapper": "1.6.1",
"lit": "~2.6.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco-editor-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
},
"dependencies": {
"monaco-editor-workers": "0.34.2",
"monaco-editor-wrapper": "1.6.0",
"monaco-editor-wrapper": "1.6.1",
"react": "~18.2.0",
"react-dom": "~18.2.0"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/monaco-editor-wrapper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to npm module [monaco-editor-wrapper](https://www.npmjs.com/package/monaco-editor-wrapper) are documented in this file.

## [1.6.1] - 2023-03-23

- Enable to update/restart the language client [#18](https://github.com/TypeFox/monaco-components/pull/18)
- Add language client initialization options [#17](https://github.com/TypeFox/monaco-components/pull/17)

## [1.6.0] - 2022-12-21

- Fix error in `disposeLanguageClient` preventing proper editor disposal
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco-editor-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-editor-wrapper",
"version": "1.6.0",
"version": "1.6.1",
"license": "MIT",
"description": "Monaco-Editor and Monaco Languageclient Wrapper",
"keywords": [
Expand Down
21 changes: 20 additions & 1 deletion packages/monaco-editor-wrapper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export class CodeEditorConfig {

// languageclient related configuration
private useLanguageClient = false;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private initializationOptions: any = undefined;
// create config type web socket / web worker
private useWebSocket = true;
private lcConfigOptions = this.useWebSocket ? this.getDefaultWebSocketConfig() : this.getDefaultWorkerConfig();
Expand Down Expand Up @@ -193,6 +195,16 @@ export class CodeEditorConfig {
this.lcConfigOptions = lcConfigOptions;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
getInitializationOptions(): any {
return this.initializationOptions;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
setInitializationOptions(options: any): void {
this.initializationOptions = options;
}

getDefaultWebSocketConfig(): WebSocketConfigOptions {
return {
wsSecured: false,
Expand Down Expand Up @@ -328,6 +340,11 @@ export class MonacoEditorLanguageClientWrapper {
}
}

async restartLanguageClient(): Promise<string> {
await this.disposeLanguageClient();
return this.startLanguageClientConnection(this.editorConfig.getLanguageClientConfigOptions());
}

private disposeEditor() {
if (this.editor) {
const model = this.editor.getModel();
Expand Down Expand Up @@ -533,7 +550,9 @@ export class MonacoEditorLanguageClientWrapper {
errorHandler: {
error: () => ({ action: ErrorAction.Continue }),
closed: () => ({ action: CloseAction.DoNotRestart })
}
},
// allow to initialize the language client with user specific options
initializationOptions: this.editorConfig.getInitializationOptions(),
},
// create a language client connection from the JSON RPC connection on demand
connectionProvider: {
Expand Down

0 comments on commit c1b6be6

Please sign in to comment.