@@ -23,24 +23,35 @@ class ReactWebView {
2323
2424// Listen for when the panel is disposed
2525// This happens when the user closes the panel or when the panel is closed programatically
26- this . panel . onDidDispose ( ( ) => this . dispose ( ) , null , this . disposables )
26+ // this.panel.onDidDispose(() => this.dispose(), null, this.disposables)
2727
2828// Handle messages from the webview
2929const onReceive = ( action :string | CR . Action ) => vscode . commands . executeCommand ( 'coderoad.receive_action' , action )
3030this . panel . webview . onDidReceiveMessage ( onReceive , null , this . disposables )
3131
3232// update panel on changes
3333const updateWindows = ( ) => {
34+
3435vscode . commands . executeCommand ( 'vscode.setEditorLayout' , { orientation :0 , groups :[ { groups :[ { } ] , size :0.6 } , { groups :[ { } ] , size :0.4 } ] } )
3536this . panel . reveal ( vscode . ViewColumn . Two )
3637}
38+
39+ this . panel . onDidDispose ( ( ) => {
40+ updateWindows ( )
41+ } )
42+
43+ // this.panel.onDidChangeViewState(() => {
44+ // console.log('onDidChangeViewState')
45+ // updateWindows()
46+ // })
47+
3748// prevents new panels from going ontop of coderoad panel
3849vscode . window . onDidChangeActiveTextEditor ( ( param ) => {
3950if ( ! param || param . viewColumn !== vscode . ViewColumn . Two ) {
4051updateWindows ( )
4152}
4253} )
43- // prevents moving coderoad panel on top of left panel
54+ //// prevents moving coderoad panel on top of left panel
4455vscode . window . onDidChangeVisibleTextEditors ( ( param ) => {
4556updateWindows ( )
4657} )
@@ -52,10 +63,8 @@ class ReactWebView {
5263// If we already have a panel, show it.
5364// Otherwise, create a new panel.
5465if ( this . panel && this . panel . webview ) {
55- console . log ( 'reveal' )
5666this . panel . reveal ( column )
5767} else {
58- console . log ( 'make new panel' )
5968this . panel = this . createWebviewPanel ( column )
6069}
6170}
@@ -84,15 +93,12 @@ class ReactWebView {
8493}
8594
8695public async postMessage ( action :CR . Action ) :Promise < void > {
87- console . log ( 'webview postMessage' )
88- console . log ( action )
8996// Send a message to the webview webview.
9097// You can send any JSON serializable data.
9198const success = await this . panel . webview . postMessage ( action )
9299if ( ! success ) {
93100throw new Error ( `Message post failure:${ JSON . stringify ( action ) } ` )
94101}
95- console . log ( 'postMessage sent' )
96102}
97103
98104public dispose ( ) :void {
@@ -125,31 +131,29 @@ class ReactWebView {
125131const styleUri = stylePathOnDisk . with ( { scheme :'vscode-resource' } )
126132
127133// Use a nonce to whitelist which scripts can be run
128- const nonce = this . getNonce ( )
129- const nonce2 = this . getNonce ( )
130- const nonce3 = this . getNonce ( )
134+ const [ n1 , n2 , n3 ] = [ 1 , 2 , 3 ] . map ( this . getNonce )
131135
132136return `<!DOCTYPE html>
133137<html lang="en">
134- <head>
135- <meta charset="utf-8">
136- <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
137- <meta name="theme-color" content="#000000">
138- <title>React App</title>
139- <link rel="manifest" href="./manifest.json" />
140- <link rel="stylesheet" type="text/css" href="${ styleUri } ">
141- <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${ nonce } ' 'nonce-${ nonce2 } ' 'nonce-${ nonce3 } '; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
142- <base href="${ vscode . Uri . file ( path . join ( this . extensionPath , 'build' ) ) . with ( { scheme :'vscode-resource' } ) } /">
143- <style></style>
144- </head>
145-
146- <body>
147- <noscript>You need to enable JavaScript to run this app.</noscript>
148- <div>Loading...</div>
149- <script nonce=${ nonce } src="./webpackBuild.js"></script>
150- <script nonce=${ nonce2 } src="${ chunkUri } "></script>
151- <script nonce="${ nonce3 } " src="${ scriptUri } "></script>
152- </body>
138+ <head>
139+ <meta charset="utf-8">
140+ <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
141+ <meta name="theme-color" content="#000000">
142+ <title>React App</title>
143+ <link rel="manifest" href="./manifest.json" />
144+ <link rel="stylesheet" type="text/css" href="${ styleUri } ">
145+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${ n1 } ' 'nonce-${ n2 } ' 'nonce-${ n3 } '; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
146+ <base href="${ vscode . Uri . file ( path . join ( this . extensionPath , 'build' ) ) . with ( { scheme :'vscode-resource' } ) } /">
147+ <style></style>
148+ </head>
149+
150+ <body>
151+ <noscript>You need to enable JavaScript to run this app.</noscript>
152+ <div>Loading...</div>
153+ <script nonce=${ n1 } src="./webpackBuild.js"></script>
154+ <script nonce=${ n2 } src="${ chunkUri } "></script>
155+ <script nonce="${ n3 } " src="${ scriptUri } "></script>
156+ </body>
153157 </html>`
154158}
155159}