Skip to content

Commit

Permalink
Merge pull request #150 from kieler/nre/sprotty012
Browse files Browse the repository at this point in the history
Update to Sprotty 0.12
  • Loading branch information
NiklasRentzCAU authored Aug 8, 2023
2 parents 9146c18 + 4ad0e40 commit 65120a0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 44 deletions.
9 changes: 5 additions & 4 deletions applications/klighd-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"devDependencies": {
"@types/node": "^12.11.7",
"@types/vscode": "^1.56.0",
"@types/vscode-webview": "^1.56.0",
"css-loader": "^5.2.4",
"file-loader": "6.2.0",
"ovsx": "^0.2.0",
Expand All @@ -165,12 +166,12 @@
},
"dependencies": {
"@kieler/klighd-core": "^0.4.2",
"inversify": "^5.0.1",
"inversify": "^5.1.1",
"nanoid": "^3.1.23",
"reflect-metadata": "^0.1.13",
"sprotty": "0.11.1",
"sprotty-vscode": "^0.2.0",
"sprotty-vscode-webview": "^0.2.0",
"sprotty": "0.12.0",
"sprotty-vscode": "^0.3.1",
"sprotty-vscode-webview": "^0.3.1",
"vscode-languageclient": "^7.0.0"
}
}
7 changes: 5 additions & 2 deletions applications/klighd-vscode/src-webview/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
VscodeDiagramWidgetFactory
} from "sprotty-vscode-webview";
import { DisabledKeyTool } from "sprotty-vscode-webview/lib/disabled-keytool";
import { VsCodeApi } from "sprotty-vscode-webview/lib/services";
import { KlighdDiagramWidget } from "./klighd-widget";
import { MessageConnection } from "./message-connection";
import { MessagePersistenceStorage } from "./persistence-storage";
Expand Down Expand Up @@ -71,8 +72,8 @@ export class KLighDSprottyStarter extends SprottyStarter {
}

protected override createContainer(diagramIdentifier: SprottyDiagramIdentifier): Container {
const connection = new MessageConnection();
const persistenceStorage = new MessagePersistenceStorage();
const connection = new MessageConnection(this.vscodeApi);
const persistenceStorage = new MessagePersistenceStorage(this.vscodeApi);
const container = createKlighdDiagramContainer(diagramIdentifier.clientId);
bindServices(container, { connection, sessionStorage, persistenceStorage });

Expand All @@ -90,6 +91,8 @@ export class KLighDSprottyStarter extends SprottyStarter {
container: Container,
diagramIdentifier: SprottyDiagramIdentifier
): void {
container.bind(VsCodeApi).toConstantValue(this.vscodeApi)

container.bind(VscodeDiagramWidget).toSelf().inSingletonScope();
container.bind(VscodeDiagramWidgetFactory).toFactory((context) => {
return () => context.container.get<VscodeDiagramWidget>(VscodeDiagramWidget);
Expand Down
12 changes: 7 additions & 5 deletions applications/klighd-vscode/src-webview/message-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { inject, injectable } from "inversify";
import { ServerStatusAction } from "sprotty";
import { ActionMessage, isActionMessage } from "sprotty-protocol";
import { VscodeDiagramWidgetFactory } from "sprotty-vscode-webview";
import { vscodeApi } from "sprotty-vscode-webview/lib/vscode-api";
import { VsCodeApi } from "sprotty-vscode-webview/lib/services";

/**
* Message based {@link Connection} to the VS Code extension. `sprotty-vscode` is used in
Expand All @@ -31,10 +31,13 @@ import { vscodeApi } from "sprotty-vscode-webview/lib/vscode-api";
export class MessageConnection implements Connection {
private messageHandlers: ((message: ActionMessage) => void)[] = [];

vscodeApi: VsCodeApi

@inject(VscodeDiagramWidgetFactory)
private diagramWidgetFactory!: VscodeDiagramWidgetFactory;

constructor() {
constructor(vscodeApi: VsCodeApi) {
this.vscodeApi = vscodeApi
this.messageHandlers.push(this.statusMessageHandler);
this.messageHandlers.push(this.logHandler);

Expand Down Expand Up @@ -63,8 +66,7 @@ export class MessageConnection implements Connection {
console.groupCollapsed(`MessageConnection sends ${message.action.kind} action:`);
console.log(message);
console.groupEnd();

vscodeApi.postMessage(message);
this.vscodeApi.postMessage(message);
}

sendNotification<T extends Record<string, unknown>>(type: NotificationType, payload: T): void {
Expand All @@ -75,7 +77,7 @@ export class MessageConnection implements Connection {
// SprottyLSPWebview sends a message with the language client, if it
// has a method property and passes a params property as the second argument
// to languageClient.sendNotification.
vscodeApi.postMessage({ method: type, params: payload });
this.vscodeApi.postMessage({ method: type, params: payload });
}

onMessageReceived(handler: (message: ActionMessage) => void): void {
Expand Down
10 changes: 7 additions & 3 deletions applications/klighd-vscode/src-webview/persistence-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
*/

import { PersistenceStorage } from "@kieler/klighd-core";
import { vscodeApi } from "sprotty-vscode-webview/lib/vscode-api";
import { VsCodeApi } from "sprotty-vscode-webview/lib/services";
import { PersistenceMessage } from "../src/storage/messages";

/**
* {@link PersistenceStorage} that syncs the data with the extension via messages
* so they can be stored in workspace storage.
*/
export class MessagePersistenceStorage implements PersistenceStorage {

vscodeApi: VsCodeApi;

/** Local cache of reported data to speed up reads. */
private cache: Record<string, any>;

Expand All @@ -39,7 +42,8 @@ export class MessagePersistenceStorage implements PersistenceStorage {
/** Callbacks which will be called when a clear change is reported by the extension */
private onClearListeners: (() => void)[] = [];

constructor() {
constructor(vscodeApi: VsCodeApi) {
this.vscodeApi = vscodeApi
this.cache = {};
this.state = "initializing";

Expand Down Expand Up @@ -94,7 +98,7 @@ export class MessagePersistenceStorage implements PersistenceStorage {
}

private sendToExtension<T>(msg: PersistenceMessage<T>) {
vscodeApi.postMessage(msg);
this.vscodeApi.postMessage(msg);
}

private handleMessageEvent(event: MessageEvent<PersistenceMessage>) {
Expand Down
4 changes: 2 additions & 2 deletions packages/klighd-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@kieler/klighd-interactive": "^0.4.2",
"@types/file-saver": "^2.0.5",
"feather-icons": "^4.28.0",
"inversify": "^5.0.1",
"sprotty": "0.11.1"
"inversify": "^5.1.1",
"sprotty": "0.12.0"
},
"devDependencies": {
"@types/feather-icons": "^4.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/klighd-interactive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"publish:next": "yarn publish --new-version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" --tag next --no-git-tag-version"
},
"dependencies": {
"sprotty": "0.11.1"
"sprotty": "0.12.0"
},
"devDependencies": {
"rimraf": "^4.4.0",
Expand Down
59 changes: 32 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,11 @@
dependencies:
source-map "^0.6.1"

"@types/vscode-webview@^1.56.0":
version "1.57.0"
resolved "https://registry.yarnpkg.com/@types/vscode-webview/-/vscode-webview-1.57.0.tgz#bad5194d45ae8d03afc1c0f67f71ff5e7a243bbf"
integrity sha512-x3Cb/SMa1IwRHfSvKaZDZOTh4cNoG505c3NjTqGlMC082m++x/ETUmtYniDsw6SSmYzZXO8KBNhYxR0+VqymqA==

"@types/vscode@^1.56.0":
version "1.57.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.57.0.tgz#cc648e0573b92f725cd1baf2621f8da9f8bc689f"
Expand Down Expand Up @@ -5256,7 +5261,7 @@ invariant@^2.2.2:
dependencies:
loose-envify "^1.0.0"

inversify@^5.0.1:
inversify@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/inversify/-/inversify-5.1.1.tgz#6fbd668c591337404e005a1946bfe0d802c08730"
integrity sha512-j8grHGDzv1v+8T1sAQ+3boTCntFPfvxLCkNcxB1J8qA0lUN+fAlSyYd+RXKvaPRL4AGyPxViutBEJHNXOyUdFQ==
Expand Down Expand Up @@ -8734,49 +8739,49 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

sprotty-protocol@~0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/sprotty-protocol/-/sprotty-protocol-0.11.0.tgz#f8ff89121155520b4e32ea0c05927e7a56173b99"
integrity sha512-OxRKrKx8mNOxX8CBKsP4epu7YGjT4XvaGwNfAwtVQVh2OPQq98t78A86XGjJThw9axm950QX0KQWGbrzX7FJuQ==
sprotty-protocol@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/sprotty-protocol/-/sprotty-protocol-0.12.0.tgz#542eb6396a645f85f8cfc2e7ef1d9b90c7b1980b"
integrity sha512-vbov+XfbmSeMYb46vm6dJvK3q7YKUvg0q7JnM6H7Ca5qY8TaZCEZ5Vc8zHKFZGWchcwnQYKqLTzwDItsMikD0A==

sprotty-vscode-protocol@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/sprotty-vscode-protocol/-/sprotty-vscode-protocol-0.2.0.tgz#b9ee32fa4c2c19f6c08b6db3add3f3f2452b38e5"
integrity sha512-iF8Gs4xpyCwuEHU0IUgD/+ZAhf8/SpYht5oWbnhLqJtGHirck2pwcfERukcSKSsPVt1rVyABHJYws8i+Dn/fsA==
sprotty-vscode-protocol@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/sprotty-vscode-protocol/-/sprotty-vscode-protocol-0.3.0.tgz#8b3be8945af0cf90eeb0b0556f8de85305948cf7"
integrity sha512-p7PguMSJ6HC5Jo2FOdoazH/KbJZzO4Dtob72HCKkR90Wa1/3e57ETMvUCbjOf1xSFlO0OJ4ygjNgOhiJDocIPQ==
dependencies:
path "^0.12.7"
sprotty-protocol "~0.11.0"
sprotty-protocol "~0.12.0"
vscode-languageserver-protocol "^3.16.0"

sprotty-vscode-webview@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/sprotty-vscode-webview/-/sprotty-vscode-webview-0.2.0.tgz#da36ce5edcdaa9b8c45232cbf279152e6df8e852"
integrity sha512-koeoSZt4sFHymJr2rEU1IMuTfCConsjccru0FsuNr4ETXs/Tl7fw/7m7JIOd/xrUuLvUexbYXrihtCkQYGDJ1Q==
sprotty-vscode-webview@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/sprotty-vscode-webview/-/sprotty-vscode-webview-0.3.1.tgz#4865de05228ff8ec8df6aa94974764f2457471fb"
integrity sha512-DoZSFvwxWj70aON/aPu02YM5Qu0PXloBJqKQGt0+jBu9smMQ+cRG8ZpHRS7WSgfvYZhQnx3c3U5W7VMe/BNCVg==
dependencies:
sprotty "~0.11.1"
sprotty-vscode-protocol "~0.2.0"
sprotty "~0.12.0"
sprotty-vscode-protocol "~0.3.0"
vscode-uri "^3.0.2"

sprotty-vscode@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/sprotty-vscode/-/sprotty-vscode-0.2.0.tgz#8989bbdb817da2e8bef8a05e6a56fc033745889e"
integrity sha512-E84bAZ76pfm7NYFwZRxNvDFFCft8Iru5USDkdXwPUFqw7/oxWf9EHMShlswtuVG10Qf3C9Th8zojyrgK4i+Vcg==
sprotty-vscode@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/sprotty-vscode/-/sprotty-vscode-0.3.1.tgz#f44b65a9ea7f230d00e2a69d49739eb3672ca177"
integrity sha512-o6eP+FVInFPJNe0GdsN56IdxRJCaOaGv1FGUdN7orxbEgzMTYOhbMmSiGeEBdGb1E92sf6RVQ+VPRHTJ023Zjg==
dependencies:
path "^0.12.7"
sprotty-vscode-protocol "~0.2.0"
sprotty-vscode-protocol "~0.3.0"
vscode-languageclient "^7.0.0"

sprotty@0.11.1, sprotty@~0.11.1:
version "0.11.1"
resolved "https://registry.yarnpkg.com/sprotty/-/sprotty-0.11.1.tgz#3a04703cf10efe8bd89f02ecd6bb33637d9312c5"
integrity sha512-wHeDbhZeGPgZebJqoWpqrkQQlpfJ1uiXIjLgIIJOhY8+bkTkGClQDMget7H6Zun7yU56x/XtwgesDyMXA4BVFg==
sprotty@0.12.0, sprotty@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/sprotty/-/sprotty-0.12.0.tgz#693432346d9321bb19f368c6806641539962db99"
integrity sha512-0RjRn3iR9McDt+LZ+cyySfdBdWyzR4kPbg4xESumvoSPziHphs6TdM7CvJ9ywTMmG131nKUF6GgbzhQZ+L6cGg==
dependencies:
"@vscode/codicons" "^0.0.25"
autocompleter "^5.1.0"
file-saver "^2.0.2"
inversify "^5.0.1"
inversify "^5.1.1"
snabbdom "^3.0.3"
sprotty-protocol "~0.11.0"
sprotty-protocol "~0.12.0"
tinyqueue "^2.0.3"

sshpk@^1.7.0:
Expand Down

0 comments on commit 65120a0

Please sign in to comment.