# @mythosthesia/visualize-rust-code-execution

> Vite plugin that adds call-stack visualizations to rust code in reveal.js slides

Latest version **0.1.1** (published 2023-09-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mythosthesia/visualize-rust-code-execution
pnpm add @mythosthesia/visualize-rust-code-execution
yarn add @mythosthesia/visualize-rust-code-execution
bun add @mythosthesia/visualize-rust-code-execution
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-09-06 |
| First published | 2023-09-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 58.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | guillem.cordoba |

## Links

- npm: https://www.npmjs.com/package/@mythosthesia/visualize-rust-code-execution
- npm.io page: https://npm.io/package/@mythosthesia/visualize-rust-code-execution

## Dependencies (7)

- [lit](https://npm.io/package/lit.md) ^2.8.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [@mdi/js](https://npm.io/package/@mdi/js.md) ^7.2.96
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.10.1
- [@lit-labs/motion](https://npm.io/package/@lit-labs/motion.md) ^1.0.4
- [reveal.js-script-fragment](https://npm.io/package/reveal.js-script-fragment.md) ^0.1.0
- [reveal.js-animate-fragments](https://npm.io/package/reveal.js-animate-fragments.md) ^0.1.0

## Recent versions

- 0.1.1 (latest) — 2023-09-06
- 0.1.0 — 2023-09-04

## README

# @mythosthesia/visualize-rust-code-execution

Vite plugin that adds call-stack visualizations to rust code in reveal.js slides.

## Installation

0. Install `vite` with:

```bash
npm install -D vite
```

1. Install with:

```bash
npm install -D @mythosthesia/visualize-rust-code-execution
```

2. If you haven't already, install [rust](https://www.rust-lang.org/), and make sure that the rust built-in component `rust-gdb` is available as an executable in your terminal.

## Setup

1. In your `vite.config.js`, add the `visualizeRustCodeExecution` plugin:

```js
import { defineConfig } from "vite";
import visualizeRustCodeExecution from "../dist/index.js";

export default defineConfig({
  plugins: [visualizeRustCodeExecution()],
});
```

> This will parse the rust code from the slides, compile and run it, and add the execution steps to the reveal.js slides as fragments in the end of the code.

2. In the reveal.js setup, import `reveal.js-script-fragment` and the `rust-execution-visualizer` element:

```html
<script type="module">
  import Reveal from "reveal.js";
  import RevealHighlight from "reveal.js/plugin/highlight/highlight.esm.js";
  import RevealScriptFragment from "reveal.js-script-fragment";
  import "@mythosthesia/visualize-rust-code-execution/dist/elements/rust-execution-visualizer.js";

  let deck = new Reveal({
    plugins: [RevealHighlight, RevealScriptFragment],
  });
  deck.initialize({});
</script>
```

This package depends on [`reveal.js-script-fragment`](https://npmjs.com/package/reveal.js-script-fragment), so it won't work if it isn't available on the reveal.js slides.

## Usage

Add `data-visualize-execution` to any `<code class="rust">` that you'd like to add visualization to:

```html
        <section>
<pre><code class="rust" data-visualize-execution data-trim data-noescape>
let s = String::from("mystring");
ref_function(&s);
ownership_function(s);

fn ref_function(s: &String) {}
fn ownership_function(s: String) {}
</code></pre>
        </section>
```

---
_Source: https://npm.io/package/@mythosthesia/visualize-rust-code-execution · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
