Skip to content

Commit 16fae7f

Browse files
Added and enhanced documentation
1 parent 5095b63 commit 16fae7f

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ You can develop the design of the visualization using an example trace in your b
225225

226226
* `npm install`
227227
* `npm run build`
228-
* `npm run watch:web`
228+
* `npm run watch:web` this starts a process which will build the contents of `src/programflow-visualization/web` into `out/programflow-visualization/web` on any changes
229229
* In console: `cd out/programflow-visualization/web` + `python3 -m http.server 5173`
230-
* Then open http://localhost:5173/index.web.html
231-
* Now you can edit files in `src/programflow-visualization/web`, watch:web will rebuild automatically and you can refresh your browser tab to see the changes
230+
* Then open http://localhost:5173/index.web.html in your browser
231+
* Now you can edit files in `src/programflow-visualization/web`, watch:web will rebuild automatically and you can refresh your browser tab to see the changes instantly
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Communication
2+
In `setupUi()` in [webview.ts](web/webview.ts#L276) EventListeners for clicks are attatched to Buttons, which dispatch new CustomEvent `programflow:onClick` including info on specific Button.
3+
4+
## Web
5+
6+
* [webview.ts](web/webview.ts#L241) adds an EventListener for that specific CustomEvent, if the application is running in a web environment
7+
* In this EventListener `traceIndex` is adjusted depending on which Button was pressed
8+
* `renderCurrent()` re-renders the application using the new `traceIndex`
9+
10+
## VSCode
11+
* [vscode-host-adapter.ts](web/vscode-host-adapter.ts) adds EventListeners which forward the CustomEvents to the extension via `vscode.postMessage(...)`
12+
* In [visualization_panel.ts](frontend/visualization_panel.ts#L88) the function `onClick` is then called asynchronously
13+
* Here, the `traceIndex` is updated, the view is re-rendered via asynchronous `reset`-event and the VSCode highlighting is updated according to `new traceIndex`
14+
* The `reset`-event, is caught by the EventListener in [vscode-host-adapter.ts](web/vscode-host-adapter.ts#L7), which handles incoming MessageEvents from the VSCode extension and dispatches CustomEvents for [webview.ts](web/webview.ts)
15+
* In [webview.ts](web/webview.ts#L203) the actual re-rendering happens
16+
* TLDR; [vscode-host-adapter.ts](web/vscode-host-adapter.ts) works as an event-bridge for messages between the extension and the view and keeps VSCode-specific code out of the webview component

0 commit comments

Comments
 (0)