diff --git a/BITSTREAM_INTEGRATION.md b/BITSTREAM_INTEGRATION.md index 807c52f..b9cc6b6 100644 --- a/BITSTREAM_INTEGRATION.md +++ b/BITSTREAM_INTEGRATION.md @@ -894,3 +894,58 @@ The relay uses `tokio-tungstenite` and routes: 6. **No `Serialize`/`Deserialize` on AST**: The AST types don't derive serde traits. `SignalManifest` should derive `Serialize` if you want to embed it as JSON in the compiled output. 7. **`ds-cli` doesn't depend on `ds-stream`**: The CLI can't import relay code directly. To auto-start the relay, use `std::process::Command::new("cargo").args(["run", "-p", "ds-stream"])`. + +--- + +## 🚀 Next Steps + +All spec changes are implemented. The pipeline is wired end-to-end. Here's the roadmap for what comes next: + +### Phase A: Prove It Works (High Priority) + +#### 1. End-to-End Integration Test +Write a `.ds` file with `stream main on "ws://..."`, run the relay + `dreamstack dev`, open two browser tabs, and verify signal changes propagate in real time. This is the first time compiler-generated streaming code talks to the Rust relay. + +```bash +# Terminal 1: start relay +cargo run -p ds-stream + +# Terminal 2: compile and serve +dreamstack stream examples/counter.ds + +# Open http://localhost:3000 — click buttons, verify signals stream to relay +# Open stream-receiver.html — verify it receives updates +``` + +#### 2. Receiver `.ds` Syntax Demo +Create a `receiver.ds` that uses `stream from "ws://localhost:9100"` to consume a remote stream and render it locally — closing the compiler-to-compiler loop. + +``` +let remote = stream from "ws://localhost:9100" + +view main = column [ + text "Remote count: {remote.count}" + text "Remote doubled: {remote.doubled}" +] +``` + +### Phase B: Infrastructure + +#### 3. WASM Codec +Compile `ds-stream` codec to WebAssembly so browsers share the exact same `rle_encode`/`rle_decode` as the Rust relay. Eliminates protocol drift risk from duplicated JS implementations. + +#### 4. Multi-Source Routing +Support `/source/{view_name}` on the relay so multiple views can stream independently through the same relay instance. + +#### 5. WebRTC Transport +Add WebRTC as a transport option alongside WebSocket for sub-frame latency. WebSocket adds ~1-2 frames of buffering; WebRTC data channels can eliminate this. + +### Phase C: Polish + +#### 6. Language Documentation +Add a streaming section to `DREAMSTACK.md` covering the `stream` keyword, `stream from` expression, and streaming modes. + +#### 7. Example `.ds` Files +Create compiler-native streaming examples: +- `examples/streaming-counter.ds` — basic signal streaming +- `examples/streaming-physics.ds` — scene state streaming with physics bodies