File tree Expand file tree Collapse file tree
src/programflow-visualization Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // This script builds the artifacts for the web-view of the visualization.
2+ // It translates typescript to javascript and replaces placeholders in html files.
3+
14import * as esbuild from "esbuild" ;
25import fs from "fs" ;
36import path from "path" ;
Original file line number Diff line number Diff line change @@ -22,27 +22,28 @@ graph TB
2222 subgraph backend["Backend (Python)"]
2323 trace["Trace Generator"]
2424 end
25-
25+
2626 subgraph extension["Extension Host (VS Code)"]
2727 panel["VisualizationPanel"]
2828 end
29-
29+
3030 subgraph webview["Webview (Sandboxed)"]
3131 ui["webview.ts<br/>(UI + Navigation)"]
3232 gen["html-generator.ts<br/>(Rendering)"]
3333 end
34-
34+
3535 subgraph editor["Editor"]
3636 highlight["Line Highlighting"]
3737 end
38-
38+
3939 trace -->|trace array via IPC| panel
40- panel -->|postMessage reset/append| webview
41-
42- webview -->|custom events| adapter["vscode-host-adapter.ts"]
40+ panel -->|postMessage reset/append| adapter
41+
42+ webview -->|custom event: programflow:highlight| adapter["vscode-host-adapter.ts"]
43+ adapter -->|custom event: programflow:reset, programflow:append| webview
4344 adapter -->|postMessage highlight| panel
4445 panel -->|updateLineHighlight| editor
45-
46+
4647 ui -->|local navigation| gen
4748 gen -->|innerHTML| ui
4849```
@@ -58,4 +59,4 @@ graph TB
5859
5960## WebDev
6061
61- You can develop the design of the visualization using an example trace in your browser. For concrete instructions check out base-repo README.
62+ You can develop the design of the visualization using an example trace in your browser. For concrete instructions check out base-repo README.
Original file line number Diff line number Diff line change @@ -86,9 +86,13 @@ export class VisualizationPanel {
8686
8787 this . _panel . webview . onDidReceiveMessage (
8888 async ( msg ) => {
89- if ( msg ?. command !== "highlight" ) { return ; }
90- if ( typeof msg . filePath !== "string" || typeof msg . line !== "number" ) { return ; }
91- await this . updateLineHighlight ( false , msg . filePath , msg . line ) ;
89+ if (
90+ msg ?. command === "highlight" &&
91+ typeof msg . filePath === "string" &&
92+ typeof msg . line === "number"
93+ ) {
94+ await this . updateLineHighlight ( false , msg . filePath , msg . line ) ;
95+ }
9296 } ,
9397 undefined ,
9498 context . subscriptions
@@ -187,10 +191,10 @@ export class VisualizationPanel {
187191 let traceFile : string ;
188192 let traceLine : number ;
189193
190- if ( typeof overrideFile === "string" && typeof overrideLine === "number" ) {
194+ if ( overrideFile !== undefined && overrideLine !== undefined ) {
191195 traceFile = overrideFile ;
192196 traceLine = overrideLine ;
193- } else if ( typeof this . _highlightFilePath === "string" && typeof this . _highlightLine === "number" ) {
197+ } else if ( this . _highlightFilePath !== undefined && this . _highlightLine !== undefined ) {
194198 traceFile = this . _highlightFilePath ;
195199 traceLine = this . _highlightLine ;
196200 } else {
Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ window.addEventListener("programflow:reset", (e: Event) => {
240240 trace = msg . trace ?? [ ] ;
241241 traceComplete = ! ! msg . complete ;
242242 renderCurrent ( ) ;
243+ postCurrentHighlight ( ) ;
243244} ) ;
244245
245246window . addEventListener ( "programflow:append" , ( e : Event ) => {
@@ -280,7 +281,7 @@ function setupUi() {
280281 // Optional: example trace mode
281282 const anyWin = window as any ;
282283 const staticTrace : StaticTrace | undefined = anyWin . __PROGRAMFLOW_TRACE__ ;
283-
284+
284285 if ( staticTrace ?. trace ) {
285286 trace = staticTrace . trace ;
286287 traceComplete = ! ! staticTrace . complete ;
@@ -289,4 +290,4 @@ function setupUi() {
289290 }
290291}
291292
292- document . addEventListener ( "DOMContentLoaded" , setupUi ) ;
293+ document . addEventListener ( "DOMContentLoaded" , setupUi ) ;
You can’t perform that action at this time.
0 commit comments