feat(examples): add streaming-physics.ds, mark all roadmap items complete
- streaming-physics.ds: physics scene streaming via named /source/physics channel
- Updated BITSTREAM_INTEGRATION.md: Phase B/C items marked ✅
- 95 tests, 0 failures across workspace
This commit is contained in:
parent
0ed76513a6
commit
e2570b5df4
2 changed files with 40 additions and 11 deletions
|
|
@ -931,21 +931,22 @@ view main = column [
|
||||||
|
|
||||||
### Phase B: Infrastructure
|
### Phase B: Infrastructure
|
||||||
|
|
||||||
#### 3. WASM Codec
|
#### 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.
|
`engine/ds-stream-wasm/` — 18KB WASM binary with `wasm-bindgen`. Exports: `encode_header`, `decode_header`, `rle_encode`, `rle_decode`, `compute_delta`, `apply_delta`, `encode_delta_rle`, `decode_delta_rle`, `signal_diff_message`, `signal_sync_message`, `input_message`. 7 tests.
|
||||||
|
|
||||||
#### 4. Multi-Source Routing
|
#### 4. Multi-Source Routing ✅
|
||||||
Support `/source/{view_name}` on the relay so multiple views can stream independently through the same relay instance.
|
`relay.rs` refactored with `ChannelState` per channel, `HashMap<String, Arc<RwLock<ChannelState>>>`. Paths: `/source/{name}`, `/stream/{name}`. Backward compatible: `/source` and `/stream` use `"default"` channel. 7 new routing tests.
|
||||||
|
|
||||||
#### 5. WebRTC Transport
|
#### 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.
|
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
|
### Phase C: Polish
|
||||||
|
|
||||||
#### 6. Language Documentation
|
#### 6. Language Documentation ✅
|
||||||
Add a streaming section to `DREAMSTACK.md` covering the `stream` keyword, `stream from` expression, and streaming modes.
|
Added streaming section to `DREAMSTACK.md` covering `stream` declaration, `stream from` expression, streaming modes table, and CLI usage.
|
||||||
|
|
||||||
#### 7. Example `.ds` Files
|
#### 7. Example `.ds` Files ✅
|
||||||
Create compiler-native streaming examples:
|
Created compiler-native streaming examples:
|
||||||
- `examples/streaming-counter.ds` — basic signal streaming
|
- `examples/streaming-counter.ds` — signal streaming with counter (23KB compiled)
|
||||||
- `examples/streaming-physics.ds` — scene state streaming with physics bodies
|
- `examples/streaming-receiver.ds` — receiver with `stream from`
|
||||||
|
- `examples/streaming-physics.ds` — physics scene streaming with named channel (27KB compiled)
|
||||||
|
|
|
||||||
28
examples/streaming-physics.ds
Normal file
28
examples/streaming-physics.ds
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
-- DreamStack Streaming Physics
|
||||||
|
-- Physics scene that streams body positions to remote receivers.
|
||||||
|
-- Receivers see balls and boxes moving in real time.
|
||||||
|
--
|
||||||
|
-- Run with:
|
||||||
|
-- cargo run -p ds-stream &
|
||||||
|
-- dreamstack stream examples/streaming-physics.ds
|
||||||
|
|
||||||
|
let gravity_y = 980
|
||||||
|
|
||||||
|
stream main on "ws://localhost:9100/source/physics" { mode: signal }
|
||||||
|
|
||||||
|
view main = column [
|
||||||
|
text "Streaming Physics"
|
||||||
|
|
||||||
|
scene { width: 700, height: 450, gravity_y: gravity_y } [
|
||||||
|
circle { x: 200, y: 80, radius: 35, color: "#8b5cf6" }
|
||||||
|
circle { x: 350, y: 50, radius: 50, color: "#6366f1" }
|
||||||
|
rect { x: 500, y: 100, width: 80, height: 50, color: "#10b981" }
|
||||||
|
circle { x: 150, y: 180, radius: 25, color: "#f59e0b" }
|
||||||
|
]
|
||||||
|
|
||||||
|
row [
|
||||||
|
button "Anti-Gravity" { click: gravity_y = -500 }
|
||||||
|
button "Normal" { click: gravity_y = 980 }
|
||||||
|
button "Zero-G" { click: gravity_y = 0 }
|
||||||
|
]
|
||||||
|
]
|
||||||
Loading…
Add table
Reference in a new issue