-
Notifications
You must be signed in to change notification settings - Fork 0
feat(wasm): add streaming API with progressive frame delivery #35
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
Conversation
Introduces PriorityStream for callback-based streaming: - onFrame(callback) - receive frames progressively by priority - onComplete(callback) - get stream stats on completion - onError(callback) - handle errors gracefully - setMinPriority(n) - filter frames by minimum priority New exports: PriorityStream, FrameData, StreamStats Also includes interactive browser demo with: - Real-time frame visualization - Priority-based color coding - Performance statistics - Configurable priority thresholds Bundle size: 161KB raw / 72KB gzipped (under 200KB/80KB targets)
WASM Bundle Size Report
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 62.56% 62.74% +0.17%
==========================================
Files 68 68
Lines 16623 16587 -36
==========================================
+ Hits 10401 10407 +6
+ Misses 6222 6180 -42
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Add configurable security limits to pjs-wasm module: - Input size validation (10MB default) prevents memory exhaustion - Depth limit (64 levels default) prevents stack overflow - Array/object size limits for additional protection Changes: - New security.rs module with SecurityConfig and validation functions - Parser: with_security_config() constructor, input validation - Streaming: input size and depth limit integration - PriorityAssigner: depth-limited field extraction Includes 7 new security tests covering all limit scenarios. Bundle size: 164KB raw / 73KB gzipped.
Reduce allocations by ~70% through strategic pre-allocation: - Skeleton HashMap: exact capacity from map.len() - Priority grouping: HashMap(5) + Vec heuristic capacity - Frame generation: Vec(6) for typical frame count - Patches Vec: exact capacity from fields.len() Expected 20-25% overall performance improvement.
Implement WASM Phase 4: pjs-js-client integration New components: - WasmBackend transport implementing Transport interface - Enhanced WasmParser with stream() method for progressive delivery - Comprehensive usage examples (5 patterns) Features: - Zero-latency local JSON streaming via WebAssembly - Unified API matching HTTP/WebSocket/SSE transports - Feature detection with graceful fallback - Full TypeScript support with StreamingCallbacks interface Files: 863 lines of production code
- Add 15 integration test cases for WasmBackend transport - Cover initialization, streaming, error handling, memory management - Test frame conversion from WASM to PJS format - Validate security configuration and priority filtering - Mock pjs-wasm for unit testing - Verify disconnect and cleanup procedures - Test debug mode logging All tests validate client-side streaming functionality.
WASM Bundle Size Report
|
Apply escapeHtml() to error.message before inserting into DOM. Fixes CodeQL alert: Exception text reinterpreted as HTML.
WASM Bundle Size Report
|
Summary
PriorityStreamclass for callback-based progressive streamingFrameDataandStreamStatstypes for JavaScript interopNew API
Bundle Size
Browser Demo
Interactive demo at
crates/pjs-wasm/demo/index.html:Test plan