Skip to content
rbstxtPublic

About

A TurboWarp-compatible Scratch editor reimplemented in Rust (egui + wgpu)

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,774 Commits

Folders and files

Repository files navigation

RustWarp

RustWarp is a reimplementation of the TurboWarp editor in Rust, targeting a TurboWarp-compatible, pixel-identical UI.

What it is

The editor UI — menu bar, block workspace, costume editor, sound editor, sprite pane, modals, libraries and the bundled addons — is drawn and handled in Rust with egui 0.37 + wgpu 30. The same Rust core is compiled to wasm32-unknown-unknown for the browser and to native desktop binaries.

On the Web, the project runtime and its stage rendering are TurboWarp's own JavaScript packages, unchanged (scratch-vm, scratch-render, scratch-audio, scratch-storage, scratch-svg-renderer), pinned in web/package.json. They run in the page next to the wasm app. The native build runs scratch-vm in an embedded V8 isolate and draws the stage with the Rust rw-stage-render.

browser page (web/)
├─ <canvas> scratch-render stage (below)
├─ <canvas> egui app (above; transparent where the stage is)
└─ scratch-vm (JS)  <— window.rustwarpHost —>  rw-bridge (Rust)

Every pixel is derived from TurboWarp's source: sizes, colors, radii, fonts and layout are copied from scratch-gui / scratch-blocks / scratch-paint, and parity is measured against a pinned TurboWarp build. See docs/architecture.md for the shared Web/native core and docs/pixel-parity.md for how parity is measured.

Status

The Web editor is deployed to Cloudflare Pages at https://rustwarp.1zworks.com/ after every green CI run on integration.

The desktop app supports macOS, Linux and Windows. Prebuilt archives are attached to GitHub Releases; the Native Release workflow builds them for macOS arm64, Linux x86_64 and Windows x86_64, and version tags publish the archives with SHA-256 checksums. Capabilities and remaining native work are tracked in docs/native.md; versioning and download details are in docs/release.md, and user-visible changes are listed in CHANGELOG.md.

Factual details live in the docs:

Project layout

Path Role
crates/rw-core Shared state (AppState), Command (UI → runtime) and Event (runtime → UI). No UI dependencies.
crates/rw-bridge Runtime trait; WebRuntime talks to window.rustwarpHost; the native runtime implements it in Rust.
crates/rw-host-core Native host orchestration: .sb3 ZIP IO, security policy, monitor layout, restore points.
crates/rw-theme Colors, metrics, fonts and the gui_asset! macro.
crates/rw-i18n Localized strings and block messages, using scratch-gui's message ids.
crates/rw-gui Menu bar, stage header, target pane, asset list, modals and libraries.
crates/rw-blocks Block workspace (scratch-blocks parity), toolbox and flyout.
crates/rw-paint Costume editor (scratch-paint parity).
crates/rw-sound Sound editor.
crates/rw-addons Reimplementation of the addons bundled with TurboWarp.
crates/rw-stage-render Rust/wgpu port of scratch-render; the desktop stage renderer and the opt-in Web renderer.
crates/rw-native-runtime Embedded V8 + scratch-vm runtime for the desktop app.
crates/rw-native-audio Native audio engine (CPAL) implementing scratch-audio semantics.
crates/rw-native-extensions Native implementations of the six built-in software/hardware extensions.
crates/rw-app App shell and layout; native binary and wasm entry start(canvas_id).
web/ JS host page: loads TurboWarp's runtime and the wasm app, plus build script and webpack config.
tools/pixeldiff/ Reference TurboWarp captures and pixel comparison against RustWarp.
tools/verify/ Playwright verification suites (UI batches, parity extras).
docs/ Architecture, native, parity, performance, addons, bridge and ownership notes.

Agent/contributor conventions (ownership, pixel rules, build gates) are in CLAUDE.md and docs/ownership.md.

Building

Prerequisites

The versions below are the ones CI uses (.github/workflows/ci.yml):

  • Rust 1.100.0 (rustup toolchain install 1.100.0). For Web builds also rustup target add wasm32-unknown-unknown.

  • wasm-bindgen 0.2.130 and binaryen 133 (wasm-opt) for release Web builds. web/build.sh looks them up as wasm-bindgen / wasm-opt on PATH, or takes WASM_BINDGEN / WASM_OPT.

  • Node.js 26 with npm for the Web build. tools/pixeldiff needs Node.js 22 or newer, and the pinned reference TurboWarp build is compiled with Node.js 20.

  • On Linux (native app), the development packages used by the native release workflow:

    sudo apt-get install -y libxkbcommon-dev libwayland-dev libx11-dev libxcursor-dev \
      libxrandr-dev libxi-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
      libvulkan-dev libgl1-mesa-dev libgtk-3-dev libasound2-dev libclang-dev pkg-config

    macOS needs the Xcode command line tools; Windows needs the MSVC build tools.

Expect the first native build to take a while: it compiles and links the embedded V8 static library (v8 152.2.0).

Web build

cd web
npm ci
npm run build          # sh ./build.sh --release && webpack --mode production

The result is a static site in web/dist/. Serve it over HTTP — the page needs the Document-Isolation-Policy: isolate-and-credentialless header from web/_headers for SharedArrayBuffer/threads. For development, npm run dev builds the wasm in debug mode and starts webpack's dev server on http://127.0.0.1:5173/ with the same headers. sh ./build.sh --release|--debug|--watch builds only the wasm package.

CI rejects a .wasm above 25 MiB (26214400 bytes), the Cloudflare Pages static asset limit.

Native build

cargo build --release --locked -p rw-app     # binary: target/release/rustwarp
cargo run --locked -p rw-app -- /path/to/project.sb3

Or download a prebuilt archive from GitHub Releases. Desktop behavior, smoke modes and the embedded-VM rebuild steps are described in docs/native.md. The release workflow packages RustWarp.app on macOS, a tarball on Linux and a zip on Windows.

Tests and checks

cargo test --workspace --locked
cargo build --workspace --locked
cargo clippy --workspace --all-targets --locked

Native-specific runtime and stage tests, and the headless smoke project:

CARGO_BUILD_JOBS=1 cargo test --locked -p rw-native-runtime
CARGO_BUILD_JOBS=1 cargo test --locked -p rw-app
CARGO_BUILD_JOBS=1 cargo run --locked -p rw-app -- --smoke-sb3 --builtin

Web host smoke test (needs Playwright Chromium from tools/pixeldiff, and a served web/dist/):

(cd tools/pixeldiff && npm ci && npx playwright install chromium)
RUSTWARP_URL=http://127.0.0.1:5173/ node web/tests/host-smoke.mjs

RUSTWARP_URL defaults to http://127.0.0.1:5173/. On machines without a GPU, pass the SwiftShader flags from CI through SMOKE_GPU_ARGS.

Verification (CI-first)

The full matrix runs in CI. Prefer the workflows and uploaded reports over reproducing them locally:

For targeted local runs, tools/verify documents the harness:

node tools/verify/verify_batches.mjs --suite=all

tools/pixeldiff captures the reference TurboWarp editor and RustWarp, then diffs them; method, scenarios and commands are in docs/pixel-parity.md.

Contributing

Branch from the latest origin/integration, keep the change scoped to the paths your task owns (docs/ownership.md), and open a pull request into integration. CI on the pull request is the gate. Pixel values must cite their TurboWarp source; see the pixel parity rules in CLAUDE.md.

License

RustWarp is licensed under GPL-3.0-only (LICENSE).

It reuses and ports GPL-3.0 code and assets from TurboWarp, the Scratch Foundation and Scratch Addons, and keeps their upstream copyright notices:

TurboWarp's runtime packages (scratch-vm, scratch-render, scratch-audio, scratch-storage, scratch-svg-renderer) are used as dependencies under their own licenses.

Disclaimer

RustWarp is an unofficial, independent project. It is not affiliated with, endorsed by, or supported by TurboWarp, Scratch, the Scratch Foundation, or the MIT Scratch Team. "Scratch" is a trademark of the Massachusetts Institute of Technology; RustWarp uses the name only to describe compatibility with Scratch projects.

Please report RustWarp bugs and issues in this repository's issue tracker, not to TurboWarp or the Scratch Team.

About

A TurboWarp-compatible Scratch editor reimplemented in Rust (egui + wgpu)

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages