# PFrames Node.js native addon

## Usage

> [!TIP]
> Install using `pnpm install @milaboratories/pframes-rs-node` command.
> Check [tests](tests/pframes.test.ts) for usage examples.

## Build instructions

### Build steps

```sh
pnpm run build
```

### Artifacts

NodeJS Native Addon is places in `dist` folder.
Use `pnpm run pack` to prepare an archive (last output line is its path) and upload it to AWS S3.

Export wrapper is placed in `export_dist` folder.
Use `pnpm publish` to publish NodeJS package.

## Debugging

### Prerequisites

Debugging is only supported using VSCode with the following extencions installed (check `@recommended` section in VScode for more suggestions):

- [C/C++](vscode:extension/ms-vscode.cpptools)
- [CodeLLDB](vscode:extension/vadimcn.vscode-lldb)
- [rust-analyzer](vscode:extension/rust-lang.rust-analyzer)

### Launching debug session

1. Clone and build the latest `platforma-desktop-v2` (`git clean -dffx && npm i && npm run build`)
2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath` (default is `../platforma-desktop-v2`)
3. Build this package by following the build steps from above (for faster build use `pnpm run build`)
4. Use VSCode launch configuration for your platform to start debug session ([VSCode debugging guide](https://code.visualstudio.com/docs/debugtest/debugging))

### Performance profiling

1. Clone and build the latest `platforma-desktop-v2`
2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath`
3. Build this package by following the build steps from above
4. Launch VSCode task (Cmd+Shift+P -> Tasks: Run Task -> Perf-profile platforma-desktop) for profiling
5. Execute the test scenario and quite platforma-desktop
6. Firefox profiler with recorded performance profile would automatically open in you browser of choice
   (Warning! Firefox profiler does not work in Safari and with AdBlock enabled)

### Dump pframes requests

1. Run `platforma-desktop-v2` with `MI_DUMP_PFRAMES_RS=/absolute/path/to/dump/requests npm run dev`
2. Archive the `/absolute/path/to/dump/requests` folder and pass to the developer
