Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev into master #16

Merged
merged 63 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
1a3ce77
feat(generateGraph): call endpoint on language server
Nov 7, 2023
459d19e
feat(generateGraph): added styling
Nov 7, 2023
2ec3e87
feat(generateGraph): intercept message to get the editors button to work
Nov 7, 2023
69362a7
feat(loggingForWebView): updated uvs with logging
Nov 10, 2023
28feb47
feat(generateGraph): new uvls with logging
Nov 14, 2023
b645c84
feat(language-server): reaching endpoint now
Nov 14, 2023
a373356
feat(language-server): extended port range for more than one session …
Nov 14, 2023
81d57ec
Merge branch 'feat/showGraph' into dev
Nov 14, 2023
bebb944
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
fd30055
Delete .github/workflows/playground_deployment.yml
st-vi Nov 14, 2023
1c14ce1
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
7eb926c
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
8569388
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
0c761bb
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
68084d2
Update playground_deployment_dev.yml
st-vi Nov 14, 2023
b6002d7
feat: docker compose for local dev
st-vi Nov 17, 2023
53e9d2f
feat: new uvls to support config
st-vi Nov 17, 2023
8d4e549
feat: config view in Iframe
st-vi Nov 17, 2023
31917c8
feat(language-server): Mulitplex UVLS communication
Nov 17, 2023
95b7090
feat: worked on multiplexing
st-vi Nov 17, 2023
d833422
feat(language-server): supported multiuser support
Nov 17, 2023
13d2b78
feat(uuid-support): generate uuids for files
Nov 17, 2023
95277e4
fix: added z3
st-vi Nov 17, 2023
1f17782
feat(multiplexing): worked on multiplexing
st-vi Nov 21, 2023
4d3d63b
feat(autosave): save the editor content to local browser storage and …
st-vi Nov 22, 2023
f91a80b
feat(reconnecting): if the connection to the language server is close…
st-vi Nov 22, 2023
a1169ba
fix: removed unused variable
st-vi Nov 22, 2023
2a092e4
feat(Configure-View): adapted to the new uvls that makes calling the …
Nov 22, 2023
73e0fce
feat(Configure-View): added log line to uvls to identify it as ours
Nov 24, 2023
c2a4cc8
feat(Configure-View): using middleware to improve request identification
Nov 24, 2023
e622707
feat(json-rpc): removed console log statement
Nov 24, 2023
30a1b93
feat(json-rpc): updated uvls (again) to support load_config if we wou…
Nov 24, 2023
181479b
test(traefik): pushing new config
Nov 24, 2023
3c2cdae
test(traefik): pushing new config
Nov 24, 2023
99f83d5
test(traefik): pushing new config
Nov 24, 2023
1abf5d2
test(traefik): pushing new config
Nov 24, 2023
2f4b7f8
test(traefik): pushing new config
Nov 24, 2023
a1301a7
test(traefik): pushing new config
Nov 24, 2023
2b5f7c6
test(traefik): pushing new config
Nov 24, 2023
a066b2f
test(traefik): pushing new config
Nov 24, 2023
ca13e93
test(traefik): pushing new config
Nov 24, 2023
4d6a8a1
test(traefik): pushing new config
Nov 24, 2023
9e07d37
test(traefik): pushing new config
Nov 24, 2023
0a4afc0
test(traefik): pushing new config
Nov 24, 2023
6899a39
test(traefik): pushing new config
Nov 24, 2023
3d6eb9d
test(traefik): pushing new config
Nov 24, 2023
ba08a3e
test(traefik): pushing new config
Nov 24, 2023
4afc56b
test(traefik): pushing new config
Nov 24, 2023
7806211
test(traefik): pushing new config
Nov 24, 2023
644c341
test(traefik): pushing new config
Nov 24, 2023
7ec4e2b
test(traefik): pushing new config
Nov 24, 2023
e9b8b25
test(traefik): pushing new config
Dec 1, 2023
f6975d7
test(config-view): swapped uvls file to connect to wss
Dec 1, 2023
654b1cc
test(config-view): swapped uvls file to connect to wss
Dec 1, 2023
8f663d5
test(config-view): hard coded dev address straight into uvls
Dec 1, 2023
f61c6ec
test(config-view): forgot port number
Dec 1, 2023
8026b7b
test(config-view): forgot port number
Dec 1, 2023
62ca60b
style(webpage): improved split handling for editor and configure view
Dec 5, 2023
21a0f44
feat(ops): docker compose file for local deployment with traefik
st-vi Dec 5, 2023
f081d85
Merge branch 'dev' of github.com:SoftVarE-Group/uvl-playground into dev
st-vi Dec 5, 2023
ae002b3
revert(index.ts): removed multiplexing
st-vi Dec 5, 2023
8a0cc4b
revert(client): removed config view
st-vi Dec 5, 2023
15512ff
Merge branch 'master' into dev
st-vi Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/playground_deployment_dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy UVL Playground
name: Deploy UVL Playground Dev

env:
HOSTNAME: 7470a63e-7b47-4833-a06c-1513f4fc534d.ul.bw-cloud-instance.org
Expand All @@ -22,9 +22,12 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: dev
- run: git branch -a
- run: cat ./WebSocketClient/index.html

- name: Set hostname for WebSocketLanguageServer
run: |
sed -i "s/languageServerHostName: .*/languageServerHostName: \"$HOSTNAME\",/" ./WebSocketClient/src/config.ts
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


.vscode/
.idea/
39 changes: 24 additions & 15 deletions WebSocketClient/index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css">
<title>UVL Playground</title>
</head>
<body>
<div class="container">
<h1>UVL Playground</h1>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="style.css">
<title>UVL Playground</title>
</head>
<body>
<div class="header">
<h1>UVL Playground</h1>
<h2 id="connection" style="color: red;"></h2>
</div>
<div id="flex-container" class="flex-container">
<div id="container" class="editor"></div>
<p>The Universal Variability Language (UVL) is a community effort towards a widely adopted textual specification for feature models. This playground provides the opportunity to get used to the language with syntax-highlighting, autocompletion, and simple analysis. It is based on the <a href="https://github.com/Universal-Variability-Language/uvl-lsp">UVL Language Server</a>. To fully use all features use the UVLS - Universal Variability Language Server extension for visual studio code. </p>
<div class="graph"></div>
</div>

<div class="footer">
<p>The Universal Variability Language (UVL) is a community effort towards a widely adopted textual specification
for feature models. This playground provides the opportunity to get used to the language with
syntax-highlighting, autocompletion, and simple analysis. It is based on the <a
href="https://github.com/Universal-Variability-Language/uvl-lsp">UVL Language Server</a>. To fully
use all features use the UVLS - Universal Variability Language Server extension for visual studio code. </p>
</div>



<script type="module">
import { startPythonClient } from "./src/main.ts";
import {startPythonClient} from "./src/main.ts";

startPythonClient();
</script>
</body>
</body>
</html>
32 changes: 32 additions & 0 deletions WebSocketClient/package-lock.json

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

4 changes: 4 additions & 0 deletions WebSocketClient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@types/node": "^20.8.7",
"@types/uuid": "^9.0.7",
"@types/vscode": "~1.83.0",
"typescript": "^5.0.2",
"vite": "^4.5.0",
Expand All @@ -25,10 +26,13 @@
"@codingame/monaco-vscode-textmate-service-override": "~1.83.2",
"@codingame/monaco-vscode-theme-defaults-default-extension": "~1.83.2",
"@codingame/monaco-vscode-theme-service-override": "~1.83.2",
"@viz-js/viz": "^3.2.3",
"dotenv": "^16.3.1",
"lodash": "^4.17.21",
"monaco-editor": "^0.44.0",
"monaco-editor-workers": "~0.44.0",
"monaco-languageclient": "^6.6.0",
"uuid": "^9.0.1",
"vite": "~4.4.11",
"vscode-json-languageservice": "~5.3.7",
"vscode-uri": "~3.0.8",
Expand Down
102 changes: 97 additions & 5 deletions WebSocketClient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ import { WebSocketMessageReader, WebSocketMessageWriter, toSocket } from 'vscode
import { RegisteredFileSystemProvider, registerFileSystemOverlay, RegisteredMemoryFile } from 'vscode/service-override/files';
import {LogLevel, Uri} from 'vscode';
import config from './config.js';
import { instance } from "@viz-js/viz";
import { Message } from 'vscode-jsonrpc';
import { v4 as uuidv4 } from 'uuid';
import lodash from 'lodash';
import { ExecuteCommandRequest } from 'vscode-languageserver-protocol'

import { buildWorkerDefinition } from 'monaco-editor-workers';
buildWorkerDefinition('./node_modules/monaco-editor-workers/dist/workers', new URL('', window.location.href).href, false);

const languageId = 'uvls';
let languageClient: MonacoLanguageClient;
let fileID;
let model;
const connectionText = document.getElementById("connection");

const createUrl = (hostname: string, port: number, path: string, searchParams: Record<string, any> = {}, secure: boolean): string => {
const protocol = secure ? 'wss' : 'ws';
Expand All @@ -43,7 +51,18 @@ const createUrl = (hostname: string, port: number, path: string, searchParams: R

const createWebSocket = (url: string): WebSocket => {
const webSocket = new WebSocket(url);
webSocket.onerror = () => {
if(connectionText){
connectionText.textContent = "Could not connect to language server. Reconnecting ...";
}
setTimeout(() => {
createWebSocket(url);
}, 1000);
};
webSocket.onopen = async () => {
if(connectionText){
connectionText.textContent = "";
}
const socket = toSocket(webSocket);
const reader = new WebSocketMessageReader(socket);
const writer = new WebSocketMessageWriter(socket);
Expand All @@ -52,13 +71,16 @@ const createWebSocket = (url: string): WebSocket => {
writer
});
await languageClient.start();
reader.onClose(() => languageClient.stop());
reader.onClose(() => {
languageClient.stop();
createWebSocket(url);
});
};
return webSocket;
};

const createLanguageClient = (transports: MessageTransports): MonacoLanguageClient => {
return new MonacoLanguageClient({
const client = new MonacoLanguageClient({
name: 'UVL Language Client',
clientOptions: {
// use a language id as a document selector
Expand All @@ -76,6 +98,42 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie
},
synchronize: {
fileEvents: [vscode.workspace.createFileSystemWatcher('**')]
},
connectionOptions: {
// This construct can be used to filter the messages we are receiving from the language server
messageStrategy: {
handleMessage(message: Message, next: (message: Message) => void) {
if(Message.isRequest(message)){
// Filters requests send by uvls -> Anti-Pattern in our opinion
}
else if(Message.isResponse(message)){
// Filters responses send by uvls
}
else if(Message.isNotification(message)){
// Filters Notification messages following json-rpc spec
}
// "next" is the default behaviour
next(message);
}
}
},
// The Middleware allows us to intercept all messages that would be sent to the language server
middleware: {
executeCommand(command, args, next) {
const information = {command: command, arguments: args};
if(command === "uvls/open_config") {
//we do not support config view
return;
}
else if(command === "uvls/generate_diagram") {
client?.sendRequest(ExecuteCommandRequest.type, information).then((res) => {
createDiagramFromDot(res as string);
});
}
else {
next(command, args);
}
},
}
},
// create a language client connection from the JSON RPC connection on demand
Expand All @@ -85,8 +143,16 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie
}
}
});
return client;
};

function createDiagramFromDot(res: string): void {
instance().then(viz => {
const div = document.getElementsByClassName("graph");
div[0].replaceChildren(viz.renderSVGElement(res!));
});
}

export const startPythonClient = async () => {
// init vscode-api
const useDebugLogging = config.debug ? LogLevel.Debug : LogLevel.Off;
Expand All @@ -95,7 +161,7 @@ export const startPythonClient = async () => {
...getThemeServiceOverride(),
...getTextmateServiceOverride(),
...getConfigurationServiceOverride(Uri.file('/workspace')),
...getKeybindingsServiceOverride()
...getKeybindingsServiceOverride(),
},
debugLogging: config.debug,
logLevel: useDebugLogging,
Expand Down Expand Up @@ -133,7 +199,8 @@ export const startPythonClient = async () => {
}`);

const fileSystemProvider = new RegisteredFileSystemProvider(false);
fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/fm.uvl'), 'features\n\tfeature1\n\nconstraints\n\tfeature1'));
fileID = uuidv4();
fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file(`/workspace/${fileID}.uvl`), getInitialFm()));
registerFileSystemOverlay(1, fileSystemProvider);

// create the web socket and configure to start the language client on open, can add extra parameters to the url if needed.
Expand All @@ -145,8 +212,17 @@ export const startPythonClient = async () => {
}, location.protocol === 'https:'));



// use the file create before
const modelRef = await createModelReference(monaco.Uri.file('/workspace/fm.uvl'));
const modelRef = await createModelReference(monaco.Uri.file(`/workspace/${fileID}.uvl`));
model = modelRef.object;

const debouncedSave = lodash.debounce(saveFm, 1000);
modelRef.object.onDidChangeContent(() => {
debouncedSave();
});


modelRef.object.setLanguageId(languageId);

// create monaco editor
Expand All @@ -155,3 +231,19 @@ export const startPythonClient = async () => {
automaticLayout: true
});
};

function getInitialFm(){
let initialFm = "features\n\tfeature1\n\t\tor\n\t\t\tfeature2\n\t\t\tfeature3\n\nconstraints\n\tfeature1";
const storedFm = window.localStorage.getItem("fm");
if(storedFm !== null){
initialFm = storedFm;
}
return initialFm;
}

function saveFm(){
if(model !== undefined){
const content = model.textEditorModel?.getValue();
window.localStorage.setItem("fm", content);
}
}
Loading
Loading