'use strict' ; import * as vscode from 'vscode' ; import * as path from 'path' ; import { ReactView } from './ReactView' ; import { ExtensionUtil } from '../util/ExtensionUtil' ; import { Reporter } from '../../extension/util/Reporter' ; export class HomeView extends ReactView { constructor ( context ) { super ( context , 'extensionHome' , 'IBM Blockchain Platform Home' ) ; } async openPanelInner ( panel ) { Reporter . instance ( ) . sendTelemetryEvent ( 'openedView' , { openedView : panel . title } ) ; const extensionPath = ExtensionUtil . getExtensionPath ( ) ; const panelIcon = vscode . Uri . file ( path . join ( extensionPath , 'resources' , 'logo.svg' ) ) ; panel . iconPath = panelIcon ; panel . webview . onDidReceiveMessage ( async ( message ) => { if ( message . command === 'telemetry' ) { Reporter . instance ( ) . sendTelemetryEvent ( 'Referral' , { source : 'homepage' , destination : message . data } ) ; } else { if ( message . data ) { await vscode . commands . executeCommand ( message . command , ... message . data ) ; } else { await vscode . commands . executeCommand ( message . command ) ; } } } ) ; await this . loadComponent ( panel ) ; } async loadComponent ( panel ) { const packageJson = await ExtensionUtil . getPackageJSON ( ) ; const version = packageJson . version ; panel . webview . postMessage ( { path : '/home' , version } ) ; } }