Skip to content

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Dec 4, 2025

Summary

  • Add PriorityStream class for callback-based progressive streaming
  • Add FrameData and StreamStats types for JavaScript interop
  • Create interactive browser demo with priority visualization

New API

const stream = new PriorityStream();

stream.onFrame((frame) => {
    console.log(frame.type, frame.priority, frame.payload);
});

stream.onComplete((stats) => {
    console.log(`${stats.totalFrames} frames in ${stats.durationMs}ms`);
});

stream.setMinPriority(50); // Only MEDIUM+ frames
stream.start(jsonString);

Bundle Size

Metric Value Target Status
Raw 161 KB < 200 KB
Gzipped 72 KB < 80 KB

Browser Demo

Interactive demo at crates/pjs-wasm/demo/index.html:

  • Real-time frame visualization with color-coded priorities
  • Performance statistics (frames, bytes, duration)
  • Configurable priority threshold

Test plan

  • All 505 workspace tests pass
  • WASM build succeeds with wasm-pack
  • 30 pjs-wasm unit tests pass
  • TypeScript definitions generated

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)
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

WASM Bundle Size Report

Target Raw (KB) Gzipped (KB) Status
web 152 70 ✓ PASS
nodejs 153 70 ✓ PASS
bundler 153 70 ✓ PASS

@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 62.74% <ø> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 13 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca26e8a...e29a9a1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

WASM Bundle Size Report

Target Raw (KB) Gzipped (KB) Status
web 155 70 ✓ PASS
nodejs 156 70 ✓ PASS
bundler 155 70 ✓ PASS

Apply escapeHtml() to error.message before inserting into DOM.
Fixes CodeQL alert: Exception text reinterpreted as HTML.
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

WASM Bundle Size Report

Target Raw (KB) Gzipped (KB) Status
web 155 70 ✓ PASS
nodejs 156 70 ✓ PASS
bundler 155 70 ✓ PASS

@bug-ops bug-ops merged commit 8317d39 into main Dec 4, 2025
29 checks passed
@bug-ops bug-ops deleted the feat/wasm-phase2-streaming branch December 4, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants