Skip to content

Commit 4543a32

Browse files
committed
add README
Signed-off-by: Teo Koon Peng <[email protected]>
1 parent 031c86c commit 4543a32

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

diagram-editor/README.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Rsbuild project
1+
# bevy_impulse_diagram_editor
2+
3+
![](./docs/assets/diagram-editor-preview.webp)
4+
5+
This contains a SPA React web app to create and edit a `bevy_impulse` diagram and an axum router to serve it.
26

37
## Setup
48

@@ -8,22 +12,59 @@ Install the dependencies:
812
pnpm install
913
```
1014

11-
## Get started
15+
## Embedding the Diagram Editor into a `bevy_impulse` app
16+
17+
The frontend is built using `rsbuild` and embedded inside the crate. The library exposes an axum router that can be used to serve both the frontend and backend:
18+
19+
```rs
20+
use bevy_impulse_diagram_editor::{new_router, ServerOptions};
21+
22+
fn main() {
23+
let mut registry = DiagramElementRegistry::new();
24+
// register node builders, section builders etc.
1225

13-
Start the dev server:
26+
let mut app = bevy_app::App::new();
27+
app.add_plugins(ImpulseAppPlugin::default());
28+
let router = new_router(&mut app, registry, ServerOptions::default());
29+
let listener = tokio::net::TcpListener::bind(("localhost", 3000))
30+
.await
31+
.unwrap();
32+
axum::serve(listener, router).await?;
33+
}
34+
```
35+
36+
To omit the frontend and serve only the backend API, disable the default features:
37+
38+
```toml
39+
[dependencies]
40+
bevy_impulse_diagram_editor = { version = "0.0.1", default-features = false }
41+
```
42+
43+
See the [calculator demo](../examples/diagram/calculator) for more examples.
44+
45+
## Local development server
46+
47+
Normally the web stack is not required by using this crate as a dependency, but it is required when developing the frontend.
48+
49+
Requirements:
50+
51+
* nodejs
52+
* pnpm
53+
54+
First start the `dev` backend server:
1455

1556
```bash
16-
pnpm dev
57+
pnpm dev:backend
1758
```
1859

19-
Build the app for production:
60+
then in another terminal, start the frontend `dev` server:
2061

2162
```bash
22-
pnpm build
63+
pnpm dev
2364
```
2465

25-
Preview the production build locally:
66+
When there are breaking changes in `bevy_impulse`, the typescript definitions need to be regenerated:
2667

2768
```bash
28-
pnpm preview
69+
pnpm generate-types
2970
```
Binary file not shown.

0 commit comments

Comments
 (0)