File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 </ head >
1515 < body style ="height: 100vh; margin: 0 ">
1616 < div id ="root " style ="height: 100%; display: flex; flex-direction: column "> </ div >
17+ < script > window . __APP_INSPECTOR_CONTEXT__ = null ; </ script >
1718 < script type ="module " src ="./main.tsx "> </ script >
1819 </ body >
1920</ html >
Original file line number Diff line number Diff line change 1+ import type { DeploymentContainer } from "@localstack/appinspector-ui" ;
12import {
23 AppInspectorContextProvider ,
34 pages ,
@@ -14,8 +15,26 @@ import {
1415 Routes ,
1516} from "react-router-dom" ;
1617
18+ /* Passed by the VS Code extension when App Inspector is launched. */
19+ declare global {
20+ interface Window {
21+ __APP_INSPECTOR_CONTEXT__ : {
22+ source : "vscode" ;
23+ ideVersion : string ;
24+ extensionVersion : string ;
25+ } | null ;
26+ }
27+ }
28+
1729const APPINSPECTOR_ROUTE_PREFIX = "/appinspector" ;
1830
31+ const deploymentContainer : DeploymentContainer =
32+ window . __APP_INSPECTOR_CONTEXT__ ?? {
33+ source : "vscode" ,
34+ ideVersion : "unknown" ,
35+ extensionVersion : "unknown" ,
36+ } ;
37+
1938render (
2039 < StrictMode >
2140 < div style = { { display : "flex" , flexDirection : "column" , height : "100%" } } >
@@ -29,6 +48,7 @@ render(
2948 >
3049 < LocalStackThemeProvider useExtensionLayout = { false } >
3150 < AppInspectorContextProvider
51+ deploymentContainer = { deploymentContainer }
3252 linkComponent = { ( props ) => (
3353 < Link to = { props . to } > { props . children } </ Link >
3454 ) }
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import {
1111 TreeItem ,
1212 TreeItemCollapsibleState ,
1313 Uri ,
14+ extensions ,
15+ version as vscodeVersion ,
1416} from "vscode" ;
1517import type {
1618 ProviderResult ,
@@ -61,9 +63,15 @@ export default createPlugin(
6163 "utf-8" ,
6264 ) ;
6365 outputChannel . debug ( `html=${ html } ` ) ;
64- panel . webview . html = html . replaceAll (
65- / " ( \/ .* ?\. (?: j s | c s s ) ) " / g,
66- ( _ , asset : string ) => {
66+ const extensionVersion =
67+ (
68+ extensions . getExtension ( "localstack.localstack" ) ?. packageJSON as {
69+ version ?: string ;
70+ }
71+ ) ?. version ?? "unknown" ;
72+
73+ panel . webview . html = html
74+ . replaceAll ( / " ( \/ .* ?\. (?: j s | c s s ) ) " / g, ( _ , asset : string ) => {
6775 return JSON . stringify (
6876 panel . webview
6977 . asWebviewUri (
@@ -75,8 +83,15 @@ export default createPlugin(
7583 )
7684 . toString ( ) ,
7785 ) ;
78- } ,
79- ) ;
86+ } )
87+ . replace (
88+ "window.__APP_INSPECTOR_CONTEXT__ = null;" ,
89+ `window.__APP_INSPECTOR_CONTEXT__ = ${ JSON . stringify ( {
90+ source : "vscode" ,
91+ ideVersion : vscodeVersion ,
92+ extensionVersion,
93+ } ) } ;`,
94+ ) ;
8095 outputChannel . debug ( `html=${ panel . webview . html } ` ) ;
8196 } ) ,
8297 ) ;
You can’t perform that action at this time.
0 commit comments