1- import * as vscode from 'vscode'
2- import * as CR from 'typings'
31import * as path from 'path'
2+ import * as CR from 'typings'
3+ import * as vscode from 'vscode'
44
55/**
66 * Manages React webview panels
@@ -71,7 +71,7 @@ class ReactWebView {
7171if ( callback ) {
7272// listen for when webview is loaded
7373// unfortunately there is no easy way of doing this
74- let webPanelListener = setInterval ( ( ) => {
74+ const webPanelListener = setInterval ( ( ) => {
7575if ( this . loaded ) {
7676setTimeout ( callback )
7777clearInterval ( webPanelListener )
@@ -80,6 +80,27 @@ class ReactWebView {
8080}
8181}
8282
83+ public async postMessage ( action :CR . Action ) :Promise < void > {
84+ // Send a message to the webview webview.
85+ // You can send any JSON serializable data.
86+ const success = await this . panel . webview . postMessage ( action )
87+ if ( ! success ) {
88+ throw new Error ( `Message post failure:${ JSON . stringify ( action ) } ` )
89+ }
90+ }
91+
92+ public dispose ( ) :void {
93+ // Clean up our resources
94+ this . panel . dispose ( )
95+
96+ while ( this . disposables . length ) {
97+ const x = this . disposables . pop ( )
98+ if ( x ) {
99+ x . dispose ( )
100+ }
101+ }
102+ }
103+
83104private createWebviewPanel ( column :number ) :vscode . WebviewPanel {
84105const viewType = 'CodeRoad'
85106const title = 'CodeRoad'
@@ -103,27 +124,6 @@ class ReactWebView {
103124return text
104125}
105126
106- public async postMessage ( action :CR . Action ) :Promise < void > {
107- // Send a message to the webview webview.
108- // You can send any JSON serializable data.
109- const success = await this . panel . webview . postMessage ( action )
110- if ( ! success ) {
111- throw new Error ( `Message post failure:${ JSON . stringify ( action ) } ` )
112- }
113- }
114-
115- public dispose ( ) :void {
116- // Clean up our resources
117- this . panel . dispose ( )
118-
119- while ( this . disposables . length ) {
120- const x = this . disposables . pop ( )
121- if ( x ) {
122- x . dispose ( )
123- }
124- }
125- }
126-
127127private getHtmlForWebview ( ) :string {
128128// eslint-disable-next-line
129129const manifest = require ( path . join ( this . extensionPath , 'build' , 'asset-manifest.json' ) )
@@ -151,6 +151,8 @@ class ReactWebView {
151151 <meta name="theme-color" content="#000000">
152152 <title>React App</title>
153153 <link rel="manifest" href="./manifest.json" />
154+ <!-- TODO: load styles through package -->
155+ <link rel="stylesheet" href="https://unpkg.com/@alifd/next/dist/next.css" />
154156 <link rel="stylesheet" type="text/css" href="${ styleUri } ">
155157 <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:;">
156158 <base href="${ vscode . Uri . file ( path . join ( this . extensionPath , 'build' ) ) . with ( {