From 165ac11f045035f1125528ca1c4241d8baaa6039 Mon Sep 17 00:00:00 2001 From: Will Yang Date: Wed, 4 Dec 2024 13:53:47 -0600 Subject: [PATCH] Update External API Documentation in README Signed-off-by: William Yang --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d24d391..aa34a20 100644 --- a/README.md +++ b/README.md @@ -303,16 +303,16 @@ yarn playwright test --retries VSCode Trace Extension provides an external API that adopter extensions can rely on for communication. Currently the API is limited to the following: -```javascript -getActiveExperiment(): Experiment | undefined -getActiveWebviewPanels(): { [key: string]: TraceViewerPanel | undefined; } -getActiveWebviews(): vscode.WebviewView[] -onWebviewCreated(listener: (data: vscode.WebviewView) => void): void -onWebviewPanelCreated(listener: (data: vscode.WebviewPanel) => void): void -onSignalManagerSignal(event: string | symbol, listener: (...args: unknown[]) => void): void; -offSignalManagerSignal(event: string | symbol, listener: (...args: unknown[]) => void): void; +```typescript +getActiveExperiment(): Experiment | undefined; +getActiveWebviewPanels(): { [key: string]: TraceViewerPanel | undefined; }; +getActiveWebviews(): vscode.WebviewView[]; +onWebviewCreated(listener: (data: vscode.WebviewView) => void): void; +onWebviewPanelCreated(listener: (data: vscode.WebviewPanel) => void): void; addTraceServerContributor(contributor: TraceServerContributor): void; setHandleTraceResourceType(handleFiles: boolean, handleFolders: boolean): void; +onSignalManagerSignal(event: K extends SignalType, listener: (...args: [...SignalArgs]) => void | Promise): void; +offSignalManagerSignal(event: K extends SignalType, listener: (...args: [...SignalArgs]) => void | Promise): void; ``` ### Using the API from Adopter Extensions @@ -374,9 +374,9 @@ const _onExperimentOpened = (experiment: Experiment): void => { console.log(experiment.UUID); }; //Add a listener -importedApi.onSignalManagerSignal('experiment opened', _onExperimentOpened); +importedApi.onSignalManagerSignal('EXPERIMENT_OPENED', _onExperimentOpened); //Remove a listener -importedApi.offSignalManagerSignal('experiment opened', _onExperimentOpened); +importedApi.offSignalManagerSignal('EXPERIMENT_OPENED', _onExperimentOpened); ``` If the adopter extensions needs to add a custom hook to the trace server's start/stop API, a contribution can be made by calling `addTraceServerContributor`.