Skip to content

Commit d88f050

Browse files
committed
Document Architecture
See #48
1 parent dfca846 commit d88f050

File tree

2 files changed

+233
-8
lines changed

2 files changed

+233
-8
lines changed

ARCHITECTURE.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
1-
# Architecture Document (WIP)
1+
# Architecture
2+
3+
## Glossary
4+
5+
- *CDP*: Chrome DevTools Protocol. https://chromedevtools.github.io/devtools-protocol/
6+
- *DAP*: Debug Adapter Protocol. https://microsoft.github.io/debug-adapter-protocol/overview
7+
- *VM*: Virtual Machine
28

39
## Components
410

5-
```mermaid
11+
![Component Overview Diagram](docs/component-overview.drawio.svg)
12+
13+
RxJS-specific debugging reuses debugging sessions started by *Visual Studio Codes* built-in [JavaScript debugging extension (*js-debug*)](https://github.com/microsoft/vscode-js-debug). The *RxJS Debugging Extension* communicates through *js-debug* using CDP with the *Debugging Runtime*. The *Debugging Runtime* interacts with the *RxJS Program*, running in the *JavaScript VM* (e.g., Node.JS or browsers like Google Chrome).
14+
15+
### RxJS Debugging Extension
16+
17+
The [*RxJS Debugging Extension*](./packages/extension) integrates with *Visual Studio Codes* using its extension API and provides the relevant user interfaces and functionalities. It allows developers to use RxJS debugging features like operator log points.
18+
19+
Furthermore, it ensures that, once a *js-debug* debugging session is started, essential hooks are registered in the *JavaScript VM* using [CDP Bindings](#cdp-bindings).
20+
21+
The communication protocol to exchange data with the *Debugging Runtime* is implemented in the extensions [TelemetryBridge](./packages/extension/src/telemetryBridge/index.ts).
622

7-
```
23+
### Debugging Runtime
24+
25+
A *Debugging Runtime* interfaces with the live *RxJS Program* and forwards relevant *Telemetry Data* (e.g. a value emitted by an Observable) to the *RxJS Debugging Extension*. A *Debugging Runtime* runs in the same process as the *RxJS Program*.
26+
27+
Specific *JavaScript VM*s require specific *Debugging Runtimes*. E.g., [runtime-nodejs](./packages/runtime-nodejs) enables debugging of *RxJS Programs* executed in Node.JS. Web application bundled with Webpack require the [runtime-webpack](./packages/runtime-webpack) plugin likewise.
28+
29+
Independently from "how" a *Debugging Runtime* finds its way to the *JavaScript VM*, all of them fulfil following tasks:
30+
31+
- Use hooks registered using [CDP Bindings](#cdp-bindings) to establish communication with the *RxJS Debugging Extension*
32+
- Patch RxJS to provide required *Telemetry Data*
33+
- Communicate with the *RxJS Debugging* Extension using the runtimes [TelemetryBridge](./packages/runtime/telemetryBridge.ts)
834

935
## CDP Bindings
1036

11-
https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-addBinding
37+
A binding is a function available in a *JavaScript VM* global scope. It is created using the [Runtime.addBinding](https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-addBinding) function of a CDP client (i.e. the *RxJS Debugging Extension*). Once the *Binding* function is called, a callback in the CDP client is executed.
38+
39+
*RxJS Debugging for Visual Studio Code* uses this form of remote procedure calls (RPC) to communicate with the *Debugging Runtime* in a *JavaScript VM*.
40+
41+
Once the *RxJS Debugging Extensions* detects a new *js-debug* debugging session, following bindings are registered:
42+
43+
| Name | Payload | Notes |
44+
| --------------------------- | -------- | ------------------------------------------------------------ |
45+
| `rxJsDebuggerRuntimeReady` | None | A *Debugging Runtime* is expected to call this binding once it is ready to debug an *RxJS Program*. |
46+
| `sendRxJsDebuggerTelemetry` | `string` | Sends a JSON-encoded [TelemetryEvent](./packages/telemetry/src/index.ts) to the *RxJS Debugging Extension*. |
1247

13-
| Name | Payload | Notes |
14-
| --------------------------- | -------- | -------------------------------------------------------------------------------------------- |
15-
| `rxJsDebuggerRuntimeReady` | None | The runtime component calls this function once it finished all preparatory work. |
16-
| `sendRxJsDebuggerTelemetry` | `string` | The runtime component uses this function to pass any telemetry data to the vscode extension. |
48+
Both the *RxJS Debugging Extension* as well as the *Debugging Runtime* use a well defined communication protocol implemented by their respective telemetry bridges.

0 commit comments

Comments
 (0)