@@ -3,7 +3,7 @@ import { DevtoolsPanel } from './DevtoolsPanel'
33import { log } from './utils/Logger'
44import * as path from 'path'
55
6- function getMarkup ( scriptSource : vscode . Uri | string ) : string {
6+ function getMarkup ( scriptSource : vscode . Uri | string , port : number ) : string {
77 return `<!DOCTYPE html>
88<html lang="en">
99 <head>
@@ -19,6 +19,9 @@ function getMarkup(scriptSource: vscode.Uri | string): string {
1919 href="https://fonts.googleapis.com/css?family=Nunito:400,700"
2020 rel="stylesheet"
2121 />
22+ <script type="text/javascript">
23+ window['__OVERMIND_DEVTOOLS_BACKEND_PORT__'] = "${ port } ";
24+ </script>
2225 </head>
2326 <body>
2427 <script type="text/javascript" src="${ scriptSource } "></script>
@@ -51,17 +54,19 @@ export function activate(context: vscode.ExtensionContext) {
5154 } ,
5255 }
5356
54- const DevtoolBackend = require ( 'overmind-devtools-client/DevtoolBackend' )
55- DevtoolBackend . create ( {
56- port : 3031 ,
57- onRelaunch ( ) {
58- console . log ( 'relaunch' )
59- } ,
60- storage,
61- } )
62-
6357 context . subscriptions . push (
6458 vscode . commands . registerCommand ( 'overmind-devtools.start' , ( ) => {
59+ const port : number =
60+ vscode . workspace . getConfiguration ( ) . get ( 'overmind-devtools.port' ) || 3301
61+ const DevtoolBackend = require ( 'overmind-devtools-client/DevtoolBackend' )
62+ DevtoolBackend . create ( {
63+ port : port ,
64+ onRelaunch ( ) {
65+ console . log ( 'relaunch' )
66+ } ,
67+ storage,
68+ } )
69+
6570 let scriptFile : vscode . Uri | string
6671
6772 // TODO consider https://github.com/microsoft/vscode/commit/fbcdb4c6a736ff38e60a7e9d0a3f1be5ccbaf3af ?
@@ -74,7 +79,7 @@ export function activate(context: vscode.ExtensionContext) {
7479 scriptFile = onDiskPath . with ( { scheme : 'vscode-resource' } )
7580 }
7681
77- DevtoolsPanel . markup = getMarkup ( scriptFile )
82+ DevtoolsPanel . markup = getMarkup ( scriptFile , port )
7883 DevtoolsPanel . createOrShow ( context . extensionPath ) // refactor to keep local reference to panel
7984 } )
8085 )
0 commit comments