probe-web / @probe-web/client / index / Client
Class: Client
Defined in: index.ts:375
A connection to probe-rs over one Transport: lists probes and chips, and attaches to a target to get a Session. Create one with Client.connect; call Client.close when done.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
transport | readonly | "websocket" | "webusb" | Which transport this client uses. | index.ts:389 |
Accessors
crashReason
Get Signature
get crashReason(): string | null;Defined in: index.ts:380
Why the local worker died, or null while it is alive (always null over WebSocket).
Returns
string | null
Methods
close()
close(): void;Defined in: index.ts:398
Close the transport: terminates the worker (releasing the USB device and the cross-tab lock) or drops the WebSocket. The client is unusable after.
Returns
void
connect()
static connect(transport): Promise<Client>;Defined in: index.ts:422
Connect to probe-rs. Loads the wasm module first (once per page).
Over WebSocket this opens the connection to probe-rs serve. Over WebUSB it starts the worker (or uses transport.worker) and watches it, so that if it dies later, calls fail with kind: 'worker-crashed' and the reason (also in Client.crashReason).
Parameters
| Parameter | Type |
|---|---|
transport | Transport |
Returns
Promise<Client>
Example
// probe-rs in this tab, over WebUSB (the probe must already be granted to the page) …
const client = await Client.connect({ kind: 'webusb' });
// … or a native `probe-rs serve`, from any browser or Node
const remote = await Client.connect({ kind: 'websocket', url: 'ws://127.0.0.1:3000', token: 'secret' });capabilities()
capabilities(): {
unsupportedEndpoints: string[];
unsupportedTopics: string[];
};Defined in: index.ts:447
RPC endpoint and topic paths the connected server does not implement. The WebUSB worker leaves out a few, such as core/disassemble.
Returns
{
unsupportedEndpoints: string[];
unsupportedTopics: string[];
}| Name | Type | Defined in |
|---|---|---|
unsupportedEndpoints | string[] | index.ts:447 |
unsupportedTopics | string[] | index.ts:447 |
supports()
supports(path): boolean;Defined in: index.ts:451
Whether the server implements an RPC endpoint path, e.g. "stack_trace/scopes".
Parameters
| Parameter | Type |
|---|---|
path | keyof Endpoints |
Returns
boolean
listProbes()
listProbes(): Promise<DebugProbeEntry[]>;Defined in: index.ts:459
The probes probe-rs can see. Over WebUSB that is only the probes already granted to the page; over WebSocket, those connected to the server's machine.
Returns
Promise<DebugProbeEntry[]>
listChipFamilies()
listChipFamilies(): Promise<ChipFamily[]>;Defined in: index.ts:463
Every chip family probe-rs knows, including any added with Client.loadChipFamily.
Returns
Promise<ChipFamily[]>
chipInfo()
chipInfo(name): Promise<ChipData>;Defined in: index.ts:467
Details (cores, memory map) of one chip by its probe-rs name.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Promise<ChipData>
loadChipFamily()
loadChipFamily(yaml): Promise<void>;Defined in: index.ts:474
Teach probe-rs a chip family from target YAML, for chips it does not ship. The YAML can come from a CMSIS pack via @probe-web/client/targets.
Parameters
| Parameter | Type |
|---|---|
yaml | string |
Returns
Promise<void>
info()
info(opts, onEvent): Promise<void>;Defined in: index.ts:479
Enumerate what is behind a probe (DP/AP, ROM tables, IDCODEs) with no chip definition.
Parameters
| Parameter | Type |
|---|---|
opts | { probe: DebugProbeEntry; protocol?: "Swd" | "Jtag"; speedKhz?: number; connectUnderReset?: boolean; targetSel?: number; scanChain?: number[]; } |
opts.probe | DebugProbeEntry |
opts.protocol? | "Swd" | "Jtag" |
opts.speedKhz? | number |
opts.connectUnderReset? | boolean |
opts.targetSel? | number |
opts.scanChain? | number[] |
onEvent | (e) => void |
Returns
Promise<void>
attach()
attach(opts): Promise<Session>;Defined in: index.ts:499
Attach to a target through a probe and return a Session for it.
On WebUSB this also takes a cross-tab lock on the probe, because Chrome claims the USB interface per tab: a second tab gets kind: 'probe-in-use-other-tab' rather than an opaque USB failure. The lock is released by Client.close.
Parameters
| Parameter | Type |
|---|---|
opts | AttachOptions |
Returns
Promise<Session>