diff --git a/src/panels/minecraft-diagnostics.ts b/src/panels/minecraft-diagnostics.ts index 1f1af7b..ae97d5b 100644 --- a/src/panels/minecraft-diagnostics.ts +++ b/src/panels/minecraft-diagnostics.ts @@ -55,6 +55,7 @@ export class MinecraftDiagnosticsPanel { this._statsTracker.setSpeed(message.speed); break; default: + console.error('Unknown message type:', message.type); break; } }); @@ -96,16 +97,16 @@ export class MinecraftDiagnosticsPanel { } public static render(extensionUri: Uri, statsTracker: StatsProvider) { - const statsTrackerId = statsTracker.getUniqueId(); + const statsTrackerId = statsTracker.uniqueId; const existingPanel = MinecraftDiagnosticsPanel.activeDiagnosticsPanels.find( - panel => panel._statsTracker.getUniqueId() === statsTrackerId + panel => panel._statsTracker.uniqueId === statsTrackerId ); if (existingPanel) { existingPanel._panel.reveal(ViewColumn.One); } else { const panel = window.createWebviewPanel( statsTrackerId, - `Minecraft Diagnostics - [${statsTracker.getName()}]`, + `Minecraft Diagnostics - [${statsTracker.name}]`, ViewColumn.Active, { retainContextWhenHidden: true, diff --git a/src/stats/replay-stats-provider.ts b/src/stats/replay-stats-provider.ts index be98d64..5acb3e0 100644 --- a/src/stats/replay-stats-provider.ts +++ b/src/stats/replay-stats-provider.ts @@ -30,7 +30,7 @@ export class ReplayStatsProvider extends StatsProvider { this._replayFilePath = replayFilePath; this._replayStreamReader = null; this._simTickFreqency = this.DEFAULT_SPEED; - this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency; // ms per tick + this._simTickPeriod = this._calcSimPeriod(this._simTickFreqency); this._simTickCurrent = 0; this._simTimeoutId = null; this._pendingStats = []; @@ -60,7 +60,7 @@ export class ReplayStatsProvider extends StatsProvider { } this._replayStreamReader?.close(); this._simTickFreqency = this.DEFAULT_SPEED; - this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency; + this._simTickPeriod = this._calcSimPeriod(this._simTickFreqency); this._simTickCurrent = 0; this._simTimeoutId = null; this._pendingStats = []; @@ -89,7 +89,7 @@ export class ReplayStatsProvider extends StatsProvider { if (this._simTickFreqency > this.MAX_SPEED) { this._simTickFreqency = this.MAX_SPEED; } - this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency; + this._simTickPeriod = this._calcSimPeriod(this._simTickFreqency); this._fireSpeedChanged(); } @@ -98,7 +98,7 @@ export class ReplayStatsProvider extends StatsProvider { if (this._simTickFreqency < this.MIN_SPEED) { this._simTickFreqency = this.MIN_SPEED; } - this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency; + this._simTickPeriod = this._calcSimPeriod(this._simTickFreqency); this._fireSpeedChanged(); } @@ -109,7 +109,7 @@ export class ReplayStatsProvider extends StatsProvider { } else if (this._simTickFreqency > this.MAX_SPEED) { this._simTickFreqency = this.MAX_SPEED; } - this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency; + this._simTickPeriod = this._calcSimPeriod(this._simTickFreqency); this._fireSpeedChanged(); } @@ -171,4 +171,8 @@ export class ReplayStatsProvider extends StatsProvider { listener.onPauseUpdated(this._simTimeoutId == null); }); } + + private _calcSimPeriod(simFrequency: number): number { + return this.MILLIS_PER_SECOND / simFrequency; + } } diff --git a/src/stats/stats-provider.ts b/src/stats/stats-provider.ts index 11c4d5f..df40380 100644 --- a/src/stats/stats-provider.ts +++ b/src/stats/stats-provider.ts @@ -30,37 +30,39 @@ export interface StatsListener { } export class StatsProvider { - private _name: string; - private _uniqueId: string; protected _statListeners: StatsListener[]; - constructor(name: string, id: string) { - this._name = name; - this._uniqueId = id; + constructor(public readonly name: string, public readonly uniqueId: string) { this._statListeners = []; } - public getName(): string { - return this._name; - } - - public getUniqueId(): string { - return this._uniqueId; - } - public setStats(stats: StatMessageModel) { for (const stat of stats.stats) { this._fireStatUpdated(stat, stats.tick); } } - public start() {} - public stop() {} - public pause() {} - public resume() {} - public faster() {} - public slower() {} - public setSpeed(speed: string) {} + public start() { + throw new Error('Method not implemented.'); + } + public stop() { + throw new Error('Method not implemented.'); + } + public pause() { + throw new Error('Method not implemented.'); + } + public resume() { + throw new Error('Method not implemented.'); + } + public faster() { + throw new Error('Method not implemented.'); + } + public slower() { + throw new Error('Method not implemented.'); + } + public setSpeed(speed: string) { + throw new Error('Method not implemented.'); + } public manualControl(): boolean { return false; } diff --git a/webview-ui/src/diagnostics_panel/controls/ReplayControls.tsx b/webview-ui/src/diagnostics_panel/controls/ReplayControls.tsx index e62ce93..e746ca7 100644 --- a/webview-ui/src/diagnostics_panel/controls/ReplayControls.tsx +++ b/webview-ui/src/diagnostics_panel/controls/ReplayControls.tsx @@ -59,4 +59,4 @@ const ReplayControls: React.FC = ({ ); }; -export default ReplayControls; +export default React.memo(ReplayControls); diff --git a/webview-ui/src/home_panel/controls/CommandSection.tsx b/webview-ui/src/home_panel/controls/CommandSection.tsx index a4139ad..165747c 100644 --- a/webview-ui/src/home_panel/controls/CommandSection.tsx +++ b/webview-ui/src/home_panel/controls/CommandSection.tsx @@ -1,4 +1,3 @@ - // Copyright (C) Microsoft Corporation. All rights reserved. import React from 'react'; @@ -54,6 +53,6 @@ const CommandSection: React.FC = ({ ))} ); -} +}; -export default CommandSection; +export default React.memo(CommandSection); diff --git a/webview-ui/src/home_panel/controls/GeneralSection.tsx b/webview-ui/src/home_panel/controls/GeneralSection.tsx index 6ec718e..b94f846 100644 --- a/webview-ui/src/home_panel/controls/GeneralSection.tsx +++ b/webview-ui/src/home_panel/controls/GeneralSection.tsx @@ -30,4 +30,4 @@ const GeneralSection: React.FC = ({ ); }; -export default GeneralSection; +export default React.memo(GeneralSection); diff --git a/webview-ui/src/home_panel/controls/ProfilerSection.tsx b/webview-ui/src/home_panel/controls/ProfilerSection.tsx index f3d3c60..a388e31 100644 --- a/webview-ui/src/home_panel/controls/ProfilerSection.tsx +++ b/webview-ui/src/home_panel/controls/ProfilerSection.tsx @@ -1,4 +1,3 @@ - // Copyright (C) Microsoft Corporation. All rights reserved. import React from 'react'; @@ -34,7 +33,7 @@ const ProfilerSection: React.FC = ({ onStopProfiler, isProfilerCapturing, supportsProfiler, - debuggerConnected + debuggerConnected, }) => { return (
@@ -44,9 +43,7 @@ const ProfilerSection: React.FC = ({ - onCaptureBasePathEdited(event as React.ChangeEvent) - } + onChange={event => onCaptureBasePathEdited(event as React.ChangeEvent)} className="capture-path-input" /> @@ -59,9 +56,9 @@ const ProfilerSection: React.FC = ({ onClick={isProfilerCapturing ? onStopProfiler : onStartProfiler} disabled={!debuggerConnected || !supportsProfiler || capturesBasePath === ''} > - {isProfilerCapturing ? "Stop Profiler" : "Start Profiler"} + {isProfilerCapturing ? 'Stop Profiler' : 'Start Profiler'} -
+

Captures

= ({ {captureItems.map(captureItem => (
onSelectCaptureItem(captureItem)} > - - {captureItem.fileName} - + {captureItem.fileName}