aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-inspector-protocol/src/inspector/index.d.ts
blob: 00c0001892d78c451e4a4f3a89d73fc3fa884e64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { EventEmitter } from "node:events";
import type { JSC } from "../protocol";

export type InspectorEventMap = {
  [E in keyof JSC.EventMap]: [JSC.EventMap[E]];
} & {
  "Inspector.connecting": [string];
  "Inspector.connected": [];
  "Inspector.disconnected": [Error | undefined];
  "Inspector.error": [Error];
  "Inspector.pendingRequest": [JSC.Request];
  "Inspector.request": [JSC.Request];
  "Inspector.response": [JSC.Response];
  "Inspector.event": [JSC.Event];
};

/**
 * A client that can send and receive messages to/from a debugger.
 */
export interface Inspector extends EventEmitter<InspectorEventMap> {
  /**
   * Starts the inspector.
   */
  start(...args: unknown[]): Promise<boolean>;
  /**
   * Sends a request to the debugger.
   */
  send<M extends keyof JSC.RequestMap & keyof JSC.ResponseMap>(
    method: M,
    params?: JSC.RequestMap[M],
  ): Promise<JSC.ResponseMap[M]>;
  /**
   * If the inspector is closed.
   */
  get closed(): boolean;
  /**
   * Closes the inspector.
   */
  close(...args: unknown[]): void;
}