Skip to content

Commit

Permalink
v1.0.0-theia1.27.0
Browse files Browse the repository at this point in the history
- Update Theia dependencies to 1.27.0
- Adapt code base to API breaks of 1.27.0
- Implement a temporary workaround for tunneling json-rpc connection until eclipse-theia/theia#11405 is resolved
- Update readmes

Fixes eclipse-glsp/glsp#703

Contributed on behalf of STMicroelectronics
  • Loading branch information
tortmayr committed Jul 11, 2022
1 parent e29c96e commit 256b594
Show file tree
Hide file tree
Showing 16 changed files with 694 additions and 394 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Eclipse GLSP Theia Integration Changelog

## [Upcoming - TBA]()

### Breaking Changes

- [theia] Updated Theia dependencies to `1.27.0`. Due to API breaks, Theia versions `<1.27.0` are no longer supported. [#105](https://github.com/eclipse-glsp/glsp-theia-integration/pull/105) - Contributed on behalf of STMicroelectronics <br>
This also causes breaking changes in:
- `GlspServerContribution` (and inherited classes)
- `connect` method now takes a `Channel` instead of a `Connection` parameter
- `BaseGlspServerContribution` (and inherited classes)
- `forward` method now takes a `Channel` as first parameter instead of a `Connection`

## [1.0.0 - 30/06/2022](https://github.com/eclipse-glsp/glsp-theia-integration/releases/tag/v1.0.0)

### Changes
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ For details on building the project, please see the [README file of the theia-in

## Theia Version Compatibility

The `@eclipse-glsp/theia-integration` package in version `1.0.0` is currently compatible with Theia `>=1.25.0`.
Theia releases currently have no stable public API so new Theia versions might introduce API breaks.
If that is the case, a new compatible 1.0.0 version prefixed with the supported minimal Theia version will be released (e.g. `1.0.0-theia1.27.0` for Theia >= 1.27.0).

| @eclipse-glsp/theia-integration | Theia |
| ------------------------------- | ------------------ |
| 0.8.0 | <=1.4.0 |
| 0.9.0 | >=1.20.0 |
| 0.9.0 | >=1.20.0 <= 1.25.0 |
| 1.0.0 | >=1.25.0 <= 1.26.0 |
| 1.0.0-theia1.27.0 | >=1.27.0 |
| next | >=1.27.0 |

> Note: Due to a transitive dependency to `sprotty-theia` it's currently not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project:
> Note: Due to a transitive dependency to `sprotty-theia` it's currently not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project e.g. for `1.0.0-theia1.27.0`:
```json
...
"resolutions": {
"**/@theia/core": "1.26.0",
"**/@theia/editor": "1.26.0",
"**/@theia/filesystem": "1.26.0",
"**/@theia/messages": "1.26.0",
"**/@theia/monaco": "1.26.0"
"**/@theia/core": "1.27.0",
"**/@theia/editor": "1.27.0",
"**/@theia/filesystem": "1.27.0",
"**/@theia/messages": "1.27.0",
"**/@theia/monaco": "1.27.0"
},
...
```
Expand Down
28 changes: 14 additions & 14 deletions examples/browser-app/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"private": true,
"name": "browser-app",
"version": "1.0.0",
"version": "1.0.0-theia1.27.0",
"dependencies": {
"@eclipse-glsp-examples/workflow-theia": "^1.0.0",
"@theia/core": "1.26.0",
"@theia/editor": "1.26.0",
"@theia/filesystem": "1.26.0",
"@theia/markers": "1.26.0",
"@theia/messages": "1.26.0",
"@theia/monaco": "1.26.0",
"@theia/navigator": "1.26.0",
"@theia/preferences": "1.26.0",
"@theia/process": "1.26.0",
"@theia/terminal": "1.26.0",
"@theia/workspace": "1.26.0"
"@eclipse-glsp-examples/workflow-theia": "^1.0.0-theia1.27.0",
"@theia/core": "1.27.0",
"@theia/editor": "1.27.0",
"@theia/filesystem": "1.27.0",
"@theia/markers": "1.27.0",
"@theia/messages": "1.27.0",
"@theia/monaco": "1.27.0",
"@theia/navigator": "1.27.0",
"@theia/preferences": "1.27.0",
"@theia/process": "1.27.0",
"@theia/terminal": "1.27.0",
"@theia/workspace": "1.27.0"
},
"devDependencies": {
"@theia/cli": "1.26.0"
"@theia/cli": "1.27.0"
},
"scripts": {
"prepare": "yarn build",
Expand Down
31 changes: 28 additions & 3 deletions examples/workflow-theia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@ This package contains the glue code to integrate the [GLSP Workflow example lang

This project is built with `yarn` and is available from npm via [@eclipse-glsp-examples/workflow-theia](https://www.npmjs.com/package/@eclipse-glsp-examples/workflow-theia).

## Theia Version compatibility
## Theia Version Compatibility

This package is currently compatible with Theia 1.20.0. Newer 1.xx versions should work as well, unless a breaking change has been published.
The `@eclipse-glsp/workflow-theia` package in version `1.0.0` is currently compatible with Theia `>=1.25.0`.
Theia releases currently have no stable public API so new Theia versions might introduce API breaks.
If that is the case, a new compatible 1.0.0 version prefixed with the supported minimal Theia version will be released (e.g. `1.0.0-theia1.27.0` for Theia >= 1.27.0).

| @eclipse-glsp/theia-integration | Theia |
| ------------------------------- | ------------------ |
| 0.8.0 | <=1.4.0 |
| 0.9.0 | >=1.20.0 <= 1.25.0 |
| 1.0.0 | >=1.25.0 <= 1.26.0 |
| 1.0.0-theia1.27.0 | >=1.27.0 |
| next | >=1.27.0 |

> Note: Due to a transitive dependency to `sprotty-theia` it's currently not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project e.g. for `1.0.0-theia1.27.0`:
```json
...
"resolutions": {
"**/@theia/core": "1.27.0",
"**/@theia/editor": "1.27.0",
"**/@theia/filesystem": "1.27.0",
"**/@theia/messages": "1.27.0",
"**/@theia/monaco": "1.27.0"
},
...
```

## More information

For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). If you have questions, contact us on our [spectrum chat](https://spectrum.chat/glsp/) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/).
For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/).
If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/).

![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif)
4 changes: 2 additions & 2 deletions examples/workflow-theia/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-glsp-examples/workflow-theia",
"version": "1.0.0",
"version": "1.0.0-theia1.27.0",
"description": "Theia extension for the workflow GLSP example",
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
"keywords": [
Expand Down Expand Up @@ -29,7 +29,7 @@
],
"dependencies": {
"@eclipse-glsp-examples/workflow-glsp": "1.0.0",
"@eclipse-glsp/theia-integration": "^1.0.0"
"@eclipse-glsp/theia-integration": "^1.0.0-theia1.27.0"
},
"devDependencies": {
"mvn-artifact-download": "5.1.0"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.0-theia1.27.0",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
Expand Down
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
"rimraf": "^3.0.2",
"typescript": "~4.5.5"
},
"resolutions": {
"**/@theia/core": "1.26.0",
"**/@theia/editor": "1.26.0",
"**/@theia/filesystem": "1.26.0",
"**/@theia/messages": "1.26.0",
"**/@theia/monaco": "1.26.0"
},
"workspaces": [
"packages/theia-integration",
"examples/*"
Expand Down
30 changes: 27 additions & 3 deletions packages/theia-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,37 @@ This package contains the glue code necessary to integrate diagram editors built

This project is built with `yarn` and is available from npm via [@eclipse-glsp/theia-integration](https://www.npmjs.com/package/@eclipse-glsp/theia-integration).

## Theia Version compatibility
## Theia Version Compatibility

This package is currently compatible with Theia 1.20.0. Newer 1.xx versions should work as well, unless a breaking change has been published.
The `@eclipse-glsp/theia-integration` package in version `1.0.0` is currently compatible with Theia `>=1.25.0`.
Theia releases currently have no stable public API so new Theia versions might introduce API breaks.
If that is the case, a new compatible 1.0.0 version prefixed with the supported minimal Theia version will be released (e.g. `1.0.0-theia1.27.0` for Theia >= 1.27.0).

| @eclipse-glsp/theia-integration | Theia |
| ------------------------------- | ------------------ |
| 0.8.0 | <=1.4.0 |
| 0.9.0 | >=1.20.0 <= 1.25.0 |
| 1.0.0 | >=1.25.0 <= 1.26.0 |
| 1.0.0-theia1.27.0 | >=1.27.0 |
| next | >=1.27.0 |

> Note: Due to a transitive dependency to `sprotty-theia` it's currently not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project e.g. for `1.0.0-theia1.27.0`:
```json
...
"resolutions": {
"**/@theia/core": "1.27.0",
"**/@theia/editor": "1.27.0",
"**/@theia/filesystem": "1.27.0",
"**/@theia/messages": "1.27.0",
"**/@theia/monaco": "1.27.0"
},
...
```

## More information

For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/).
If you have questions, contact us on our [spectrum chat](https://spectrum.chat/glsp/) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/).
If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/).

![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif)
5 changes: 3 additions & 2 deletions packages/theia-integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-glsp/theia-integration",
"version": "1.0.0",
"version": "1.0.0-theia1.27.0",
"description": "Glue code to integrate GLSP clients into Eclipse Theia",
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
"engines": {
Expand Down Expand Up @@ -40,7 +40,8 @@
],
"dependencies": {
"@eclipse-glsp/client": "1.0.0",
"@theia/messages": ">=1.25.0 <=1.26.0",
"@theia/core": "^1.27.0",
"@theia/messages": "^1.27.0",
"sprotty-theia": "0.12.0"
},
"scripts": {
Expand Down
84 changes: 84 additions & 0 deletions packages/theia-integration/src/browser/channel-connection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/********************************************************************************
* Copyright (c) 2022 STMicroelectronics and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Channel, Disposable, DisposableCollection, Emitter, MessageProvider } from '@theia/core';
import { createMessageConnection, Logger, Message, MessageConnection } from 'vscode-jsonrpc';
import { AbstractMessageReader, DataCallback, MessageReader } from 'vscode-jsonrpc/lib/messageReader';

import { AbstractMessageWriter, MessageWriter } from 'vscode-jsonrpc/lib/messageWriter';

// Temporary fix/workaround to enable comparability with Theia >=1.27 until https://github.com/eclipse-theia/theia/issues/11405 is resolved

/**
* A `vscode-jsonrpc` {@link MessageReader} that reads messages from an underlying {@link Channel}.
*/
export class ChannelMessageReader extends AbstractMessageReader implements MessageReader {
protected onMessageEmitter = new Emitter<Message>();
protected toDispose = new DisposableCollection();

constructor(protected readonly channel: Channel) {
super();
this.toDispose.push(this.onMessageEmitter);
this.toDispose.push(channel.onMessage(data => this.handleMessage(data)));
this.toDispose.push(channel.onClose(() => this.fireClose()));
}

protected handleMessage(msgProvider: MessageProvider): void {
const buffer = msgProvider().readBytes();
const message = JSON.parse(new TextDecoder().decode(buffer));
this.onMessageEmitter.fire(message);
}

override dispose(): void {
super.dispose();
this.toDispose.dispose();
}

listen(callback: DataCallback): void {
this.onMessageEmitter.event(callback);
}
}

/**
* A `vscode-jsonrpc` {@link MessageWriter} that writes messages to an underlying {@link Channel}.
*/
export class ChannelMessageWriter extends AbstractMessageWriter implements MessageWriter {
protected toDispose: Disposable;

constructor(protected readonly channel: Channel) {
super();
this.toDispose = channel.onClose(() => this.fireClose());
}

write(msg: Message): void {
const writeBuffer = this.channel.getWriteBuffer();
writeBuffer.writeBytes(Buffer.from(JSON.stringify(msg, undefined, 0)));
writeBuffer.commit();
}

override dispose(): void {
super.dispose();
this.toDispose.dispose();
}
}

/**
* Create a `vscode-jsonrpc` {@link MessageConnection} on top of a given {@link Channel}.
*/
export function createChannelConnection(channel: Channel, logger?: Logger): MessageConnection {
const reader = new ChannelMessageReader(channel);
const writer = new ChannelMessageWriter(channel);
return createMessageConnection(reader, writer, logger);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import '../../css/diagram.css';
import '../../css/theia-dialogs.css';
import '../../css/tool-palette.css';
import { GLSPContribution } from '../common';
import { createChannelConnection } from './channel-connection';
import { TheiaJsonrpcGLSPClient } from './theia-jsonrpc-glsp-client';

export const GLSPClientContribution = Symbol.for('GLSPClientContribution');
Expand Down Expand Up @@ -128,16 +129,17 @@ export abstract class BaseGLSPClientContribution implements GLSPClientContributi
this.connectionProvider.listen(
{
path: GLSPContribution.getPath(this),
onConnection: messageConnection => {
onConnection: channel => {
if (toStop.disposed) {
messageConnection.dispose();
channel.close();
return;
}
const languageClient = this.createGLSPCLient(messageConnection);
const connection = createChannelConnection(channel);
const languageClient = this.createGLSPCLient(connection);
this.onWillStart(languageClient);
toStop.pushAll([
messageConnection,
Disposable.create(() => {
channel.close();
languageClient.shutdownServer();
languageClient.stop();
})
Expand Down
Loading

0 comments on commit 256b594

Please sign in to comment.