|
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 |
2 | 8 |
|
3 | 9 | ## Components |
4 | 10 |
|
5 | | -```mermaid |
| 11 | + |
| 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). |
6 | 22 |
|
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) |
8 | 34 |
|
9 | 35 | ## CDP Bindings |
10 | 36 |
|
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*. | |
12 | 47 |
|
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