-
Notifications
You must be signed in to change notification settings - Fork 2
Diagram editor #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
koonpeng
wants to merge
175
commits into
main
Choose a base branch
from
koonpeng/diagram-editor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19,146
−32
Open
Diagram editor #99
Changes from 159 commits
Commits
Show all changes
175 commits
Select commit
Hold shift + click to select a range
cd129ef
first commit
koonpeng 1f02db5
fix section schema
koonpeng e273f86
update schemas
koonpeng 35ae56e
load diagram json into reactflow nodes
koonpeng bb28f62
successfully display a diagram
koonpeng de5902f
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 0facc77
visualize other nodes
koonpeng cf67647
organize workspace
koonpeng 6e5907d
add auto layout button
koonpeng 79ae317
filter upload files
koonpeng fa5bd64
aria-label consistent with tooltip
koonpeng cf5a186
add operations
koonpeng 6ec072f
rust crate to serve an embedded frontend
koonpeng 8d5e4bb
cleanup
koonpeng 3ff869c
add form to edit node operation; ux improvements
koonpeng d887a39
serve diagram editor from root to make url rewriting easier
koonpeng 7c67496
update comment
koonpeng 4bb6b74
fix uncaught error when base64 decode fails
koonpeng 84fec77
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng a625906
support exporting diagram
koonpeng 6a12ae2
wip syncing operation connection and react flow edges
koonpeng 4214105
add edge data when loading diagram
koonpeng b2c282e
fix loading empty diagram; add copy share link button
koonpeng 9d8255d
nextOperationToNodeId returns null for dispose
koonpeng 8901ebb
use builtin dispose as default for new ops
koonpeng 2780ce5
use small textfield for share link
koonpeng aac0121
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 086ecef
add buffer form
koonpeng b0ef111
add editing unzip edge
koonpeng a7f5edb
move edges to another directory
koonpeng 2a27f05
refactor and add custom unzip edge component
koonpeng c5ecfba
use exhaustive check when possible
koonpeng a0109dd
add definitions for all edges
koonpeng 4ca6718
add edit forms for other edges
koonpeng 65412a9
add storybook, fix some components
koonpeng abac9f7
add transform edit form
koonpeng dc70577
enable transform form
koonpeng b6ce4e1
fix formatting
koonpeng 831b8be
add registry schema
koonpeng e087b93
use string schema instead of creating raw schema
koonpeng cbc7010
use true instead of null to avoid conflict with nullable values
koonpeng 2b424ec
use any object for forward compatibility
koonpeng e47c727
cleanup testing code
koonpeng e79bbef
Merge branch 'koonpeng/registry-schema' into koonpeng/diagram-editor
koonpeng 752817c
update schema
koonpeng 46deef4
update schema
koonpeng ec39923
Merge branch 'koonpeng/registry-schema' into koonpeng/diagram-editor
koonpeng 16d6230
implement connections for scope and stream_out
koonpeng c8f93fa
fix
koonpeng 6a27657
implement stream out for scope
koonpeng 44a67ae
implement node for each operation independently
koonpeng 30c5894
refactor to avoid importing from outside a package
koonpeng 57884d0
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 631ef2e
use default export
koonpeng 7159c9a
use correct schema version on ajv
koonpeng ebe4d24
use uuid as id for new nodes
koonpeng 4b2c96a
implement delete button on all edit node forms
koonpeng 107296c
relax package private imports to allow sibliing modules
koonpeng cb63e9b
add transform form story
koonpeng 495d3df
implement edge forms
koonpeng 5c46541
handle exporting stream out edges for scope
koonpeng 6219864
handle deleting edges
koonpeng c5dfdff
fix form not updating
koonpeng fc8d3d2
cleanup
koonpeng 5fc2689
more preprocessing for json-schema-to-typescript
koonpeng 90d90d7
manage node id and op id separately to avoid ui glitches and unnecesa…
koonpeng 78fa3ef
update deps
koonpeng 2851a73
exclude build script from the crate
koonpeng 447e973
use lookup maps
koonpeng 76b6ab0
validate that the cel is valid
koonpeng b5aba98
fix auto layout
koonpeng 0b5b00f
perf optimization of the command panel
koonpeng 65d0f09
upgrade to material symbols
koonpeng df01814
fix node height to avoid recomputing dimensions causing lag spikes
koonpeng 763bb3f
fix lint
koonpeng 56f4a5b
fix and improve auto layout algorithm
koonpeng 9126b0e
fix node width
koonpeng 086aedb
ignore node_modules
koonpeng a8ed2bc
memoized edges and nodes
koonpeng 81d0e48
revert testing changes
koonpeng a7ac79f
add background
koonpeng c3655eb
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 5a28055
serve registry
koonpeng f2e02e1
serve and provide registry
koonpeng 60388c7
add script to start backend
koonpeng 8351bd5
fix
koonpeng f0e122e
assume regsitry is always available
koonpeng a205c7e
autocomplete node builder
koonpeng 7978c24
fix incremental build
koonpeng 0f03cce
wip server executor
koonpeng 15b95f6
first executor service
koonpeng db61bab
use existing app
koonpeng c7cc4bf
add placeholder debug api
koonpeng ed631dc
add bin to print schemas
koonpeng ca58219
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 955a660
use schema from the api
koonpeng 2c2f958
able to render scopes but autoLayout not working
koonpeng 8f0d5ce
fix tests
koonpeng 40e824e
workable scope layout
koonpeng fa30535
autolayout now auto calculate scope size
koonpeng d51c93e
finally functional scope sizing
koonpeng bb1ee1e
fixes
koonpeng 1057be1
support add node into scope
koonpeng ef86e52
add namespace for new operations
koonpeng d406a97
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng bb65138
increase handle size and selection area
koonpeng 51e098e
support exporting diagram with scope
koonpeng f290d4b
reduce impact of resizing glitches
koonpeng d1c98a6
remove children when parent is removed
koonpeng e4f7ef6
support adding scope operation
koonpeng c9cea9a
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 23f7ee9
remove old schema
koonpeng 4aa106d
wip templates dialog
koonpeng 80eebe8
implemented adding and deleting templates
koonpeng df5cccd
wip adding template mode for diagram editor
koonpeng f445cd7
increase edge contrast
koonpeng dd8ce56
refactor
koonpeng d08543a
add section interface nodes to add operation menu
koonpeng 9b35b49
fixes to exporting in preparation for exporting templates
koonpeng 0a624fb
more fixes for templates
koonpeng fe28715
saving and reloading nodes and edges when switch between template and…
koonpeng eb5fa9d
stricter type checks for section interfaces
koonpeng 430a61a
ellipsis long labels, increase node width, add comment on why it is h…
koonpeng c7902fa
wip exporting template
koonpeng 95b2969
rename to avoid name ambiguity
koonpeng 403bd70
successfully export template
koonpeng 7f730d1
successfully loaded a template
koonpeng 710d12e
save template on close
koonpeng b5ef3a7
check if edge is valid when connecting; add arrow marker to edges
koonpeng f59b48c
more checks when connecting edges
koonpeng b3b2acc
do not flag conflict if the edge to check is already in reactflow
koonpeng 8d1fa77
fix several edge validation errors
koonpeng 767277d
formatting
koonpeng 1549978
visual indication if an edge is connectable
koonpeng d23e22e
fix more validation bugs
koonpeng d2e5294
add forms to edit section interfaces
koonpeng 5ab12f1
form to edit a section
koonpeng f5178d7
wip supporting section connections
koonpeng fc47a7f
implemented forms for connecting section buffers
koonpeng 5fdc12f
added support for editing section edges
koonpeng d31a114
add more connection tests
koonpeng bc73def
refactor
koonpeng 2ef857e
cleanup
koonpeng a6a96b5
color code buffer handles; join node no longer allows data edges
koonpeng 5f548bc
add caption to section interface nodes
koonpeng 9b1ea9e
add script to check typescript
koonpeng b038c37
color code nodes with multiple output and input types
koonpeng 98dcaa5
add color coding to other nodes
koonpeng 031c86c
cleanup
koonpeng 4543a32
add README
koonpeng 10aaf46
test png
koonpeng d66435a
try webp
koonpeng 6c9942a
remoev test
koonpeng 9397cf3
setup pnpm
koonpeng b6bfba8
wip trace backend
koonpeng e4c869b
run workflow ui
koonpeng 289d80c
add config field to node form
koonpeng c396b6d
empty request by default
koonpeng 1694585
ignore wip test
koonpeng 9d646d5
styling
koonpeng 0552be9
Make calculator operations more flexible
mxgrey a87cbb1
Make config error more clear
mxgrey ef832c9
fix formatting
mxgrey eb17866
fix formatting
mxgrey 4807ac6
fix type generation
koonpeng 1ebf670
fix ui bugs
koonpeng 1a37bee
fix buffer input slot not updating
koonpeng bbaecb7
Merge branch 'koonpeng/diagram-editor' of github.com:open-rmf/bevy_im…
koonpeng dabc711
update icons
koonpeng cf14bf0
Merge remote-tracking branch 'origin/main' into koonpeng/diagram-editor
koonpeng 71f8bde
fix after merge
koonpeng 1a206b8
fix uncaught exceptions
koonpeng c422eaf
add instructions to install pnpm
koonpeng ad47632
proper stream out forms
koonpeng 3de5243
separate stream out to another handle
koonpeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json", | ||
"files": { | ||
"includes": [ | ||
"**/*.tsx", | ||
"**/*.ts", | ||
"**/*.mjs", | ||
"**/*.cjs", | ||
"**/*.json", | ||
"**/*.css", | ||
"!**/*.schema.json", | ||
"!node_modules/**" | ||
] | ||
}, | ||
"assist": { "actions": { "source": { "organizeImports": "on" } } }, | ||
"vcs": { | ||
"enabled": true, | ||
"clientKind": "git", | ||
"useIgnoreFile": true | ||
}, | ||
"formatter": { | ||
"indentStyle": "space" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single" | ||
} | ||
}, | ||
"css": { | ||
"parser": { | ||
"cssModules": true | ||
} | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"correctness": { | ||
"useExhaustiveDependencies": { | ||
"level": "error", | ||
"options": { | ||
"hooks": [ | ||
{ "name": "useEditorMode", "stableResult": [1] }, | ||
{ "name": "useTemplates", "stableResult": [1] } | ||
] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"includes": ["**/*.test.ts", "**/*.test.tsx"], | ||
"linter": { | ||
"rules": { | ||
"style": { | ||
"noNonNullAssertion": "off" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist | ||
|
||
*storybook.log | ||
storybook-static |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { StorybookConfig } from 'storybook-react-rsbuild'; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
'../frontend/**/*.mdx', | ||
'../frontend/**/*.stories.@(js|jsx|mjs|ts|tsx)', | ||
], | ||
addons: [], | ||
framework: 'storybook-react-rsbuild', | ||
}; | ||
export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Preview } from 'storybook-react-rsbuild'; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[package] | ||
name = "bevy_impulse_diagram_editor" | ||
version = "0.0.1" | ||
edition = "2021" | ||
authors = ["Teo Koon Peng <[email protected]>"] | ||
license = "Apache-2.0" | ||
description = "Frontend for bevy_impulse diagrams" | ||
readme = "README.md" | ||
repository = "https://github.com/open-rmf/bevy_impulse" | ||
keywords = [ | ||
"reactive", | ||
"workflow", | ||
"behavior", | ||
"agent", | ||
"bevy", | ||
"frontend", | ||
"diagram", | ||
] | ||
categories = [ | ||
"science::robotics", | ||
"asynchronous", | ||
"concurrency", | ||
"game-development", | ||
] | ||
exclude = ["/build.rs"] | ||
|
||
[lib] | ||
path = "server/lib.rs" | ||
|
||
[dependencies] | ||
axum = { version = "0.8.4", features = ["ws"] } | ||
bevy_app = "0.12.1" | ||
bevy_ecs = "0.12.1" | ||
bevy_impulse = { version = "0.0.2", path = "..", features = [ | ||
"diagram", | ||
"trace", | ||
] } | ||
flate2 = { version = "1.1.1", optional = true } | ||
futures-util = "0.3.31" | ||
indexmap = { version = "2.10.0", optional = true, features = ["serde"] } | ||
mime_guess = "2.0.5" | ||
schemars = { version = "0.9", optional = true } | ||
serde = "1.0.219" | ||
serde_json = "1.0.140" | ||
tar = { version = "0.4.44", optional = true } | ||
tokio = "1.45.1" | ||
tracing = "0.1.41" | ||
|
||
[build-dependencies] | ||
flate2 = { version = "1.1.1", optional = true } | ||
tar = { version = "0.4.44", optional = true } | ||
|
||
[dev-dependencies] | ||
futures-channel = "0.3.31" | ||
test-log = "0.2.18" | ||
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] } | ||
tower = "0.5.2" | ||
|
||
[features] | ||
default = ["frontend"] | ||
frontend = ["dep:flate2", "dep:tar"] | ||
json_schema = ["dep:schemars", "dep:indexmap"] | ||
|
||
[[bin]] | ||
name = "print_schema" | ||
path = "server/bin/print_schema.rs" | ||
required-features = ["json_schema"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# bevy_impulse_diagram_editor | ||
|
||
 | ||
|
||
This contains a SPA React web app to create and edit a `bevy_impulse` diagram and an axum router to serve it. | ||
|
||
## Setup | ||
|
||
Install the dependencies: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
## Embedding the Diagram Editor into a `bevy_impulse` app | ||
|
||
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: | ||
|
||
```rs | ||
use bevy_impulse_diagram_editor::{new_router, ServerOptions}; | ||
|
||
fn main() { | ||
let mut registry = DiagramElementRegistry::new(); | ||
// register node builders, section builders etc. | ||
|
||
let mut app = bevy_app::App::new(); | ||
app.add_plugins(ImpulseAppPlugin::default()); | ||
let router = new_router(&mut app, registry, ServerOptions::default()); | ||
let listener = tokio::net::TcpListener::bind(("localhost", 3000)) | ||
.await | ||
.unwrap(); | ||
axum::serve(listener, router).await?; | ||
} | ||
``` | ||
|
||
To omit the frontend and serve only the backend API, disable the default features: | ||
|
||
```toml | ||
[dependencies] | ||
bevy_impulse_diagram_editor = { version = "0.0.1", default-features = false } | ||
``` | ||
|
||
See the [calculator demo](../examples/diagram/calculator) for more examples. | ||
|
||
## Local development server | ||
|
||
Normally the web stack is not required by using this crate as a dependency, but it is required when developing the frontend. | ||
|
||
Requirements: | ||
|
||
* nodejs | ||
* pnpm | ||
|
||
First start the `dev` backend server: | ||
|
||
```bash | ||
pnpm dev:backend | ||
``` | ||
|
||
then in another terminal, start the frontend `dev` server: | ||
|
||
```bash | ||
pnpm dev | ||
``` | ||
|
||
When there are breaking changes in `bevy_impulse`, the typescript definitions need to be regenerated: | ||
|
||
```bash | ||
pnpm generate-types | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/// Builds the frontend and packages it into a tar.gz archive. | ||
/// This requires `pnpm` and all the js dependencies to be available. | ||
/// | ||
/// This build script is excluded from the crate, the output tarball is included instead. | ||
/// This allows downstream to build the crate without any of the js stack. | ||
|
||
#[cfg(feature = "frontend")] | ||
mod frontend { | ||
use flate2::{write::GzEncoder, Compression}; | ||
use std::fs::File; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
use tar::Builder; | ||
|
||
pub fn build_frontend() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=package.json"); | ||
println!("cargo:rerun-if-changed=../pnpm-lock.yaml"); | ||
println!("cargo:rerun-if-changed=rsbuild.config.ts"); | ||
println!("cargo:rerun-if-changed=frontend"); | ||
|
||
let status = Command::new("pnpm") | ||
.arg("install") | ||
.arg("--frozen-lockfile") | ||
.status() | ||
.expect("Failed to execute pnpm install"); | ||
|
||
if !status.success() { | ||
panic!("pnpm install failed with status: {:?}", status); | ||
} | ||
|
||
let status = Command::new("pnpm") | ||
.arg("build") | ||
.status() | ||
.expect("Failed to execute pnpm build"); | ||
|
||
if !status.success() { | ||
panic!("pnpm build failed with status: {:?}", status); | ||
} | ||
|
||
let dist_dir_path = "dist"; | ||
// We put the output in `CARGO_MANIFEST_DIR` instead of `OUT_DIR` because we want to include | ||
// it in the crate. | ||
let out_dir = | ||
PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")); | ||
let output_tar_gz_path = out_dir.join("dist.tar.gz"); | ||
|
||
if std::path::Path::new(dist_dir_path).exists() { | ||
let tar_gz_file = File::create(&output_tar_gz_path) | ||
.expect("Failed to create output tar.gz file in CARGO_MANIFEST_DIR"); | ||
let enc = GzEncoder::new(tar_gz_file, Compression::default()); | ||
let mut tar_builder = Builder::new(enc); | ||
|
||
// Add the entire "dist" directory to the archive, preserving its name within the archive. | ||
tar_builder | ||
.append_dir_all(".", dist_dir_path) | ||
.expect("Failed to add directory to tar archive"); | ||
tar_builder.finish().expect("Failed to finish tar archive"); | ||
println!( | ||
"Successfully compressed '{}' into '{:?}'", | ||
dist_dir_path, output_tar_gz_path | ||
); | ||
} else { | ||
panic!( | ||
"Directory '{}' not found after pnpm build. Frontend build might have failed.", | ||
dist_dir_path | ||
); | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
#[cfg(feature = "frontend")] | ||
frontend::build_frontend(); | ||
} |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include the instructions for setting up pnpm like what we have for
rmf-web
. Our target user base is the ROS community, who often have no experience using web tools like pnpm.