Skip to content

Commit 4d9c089

Browse files
committed
feat: fiber architecture rewrite with lane-based scheduler and type safety
BREAKING CHANGE: Replaces the old hook-based reconciler with a full fiber architecture modeled after React's internals. The public API surface remains compatible, but the internal reconciliation engine is completely new. ## New Architecture - **Fiber tree**: work-in-progress / current dual tree for interruptible renders - **Work loop**: and - **Begin / Complete work**: separate phases for building and finalizing fibers - **Commit phase**: mutation + layout effects, then passive effects flush - **Lane-based priority system**: 16-bit branded / with merge, intersect, highest-priority selection, and entanglement - **Scheduler**: binary min-heap () with , , and priority-based task ordering - **Concurrent rendering groundwork**: time-slicing ready, sync path still default ## Type Safety Hardening - Centralised unsafe-cast boundary: — all / / conversions live here; zero stray elsewhere - alias resolves impossible branded-type incompatibilities - (bitwise OR produces naturally) - Compile-time enforcement: with directives ## New Modules - — branded type conversion helpers - — binary min-heap for scheduler task queue - — work loop + sync + concurrent rendering paths - — begin work phase - — complete work phase - — DOM mutation helpers - — commit root orchestration - — priority task scheduler - — lane priority system - — child reconciliation with key-based diff - — hook implementations for fiber architecture - — effect collection and execution - — WIP tree management - — fiber factory functions - — runtime type guards and assertions - — SSR hydration support - — serialization / deserialization for SSR - — live Vite-powered browser demo ## Tests - 9 new test modules covering previously untested internals - 473 tests, 0 failures, 1,526 expectations across 38 files ## Verification ```bash bun test # 473 pass, 0 fail bun run typecheck # 0 errors ```
1 parent 12c42ee commit 4d9c089

100 files changed

Lines changed: 14496 additions & 5651 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ jobs:
2222
- name: 📦 Install dependencies
2323
run: bun install
2424

25-
- name: 🧪 Run tests
26-
run: bun test
27-
2825
- name: 🔍 Lint and format check
2926
run: bun run check
3027

28+
- name: 🔎 Typecheck
29+
run: bun run typecheck
30+
31+
- name: 🧪 Run tests
32+
run: bun test
33+
3134
- name: 🏗️ Test build
3235
run: bun run build
3336

.trae/rules/project_rules.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,28 @@ Each phase includes clear specifications, working implementations, and extensive
6060

6161
## Current Status
6262

63-
🆕 **Current Phase**: Stable Release Track - Phase 12**COMPLETE**
63+
🆕 **Current Phase**: Stable Release Track - Phase 13**COMPLETE**
6464

6565
**Latest Achievements**:
6666

67-
-**Phase 12 Complete**: Performance Optimization Suite - memo, useMemo, useCallback with comprehensive test coverage
68-
-**Enhanced Performance**: React.memo equivalent for component memoization and optimization hooks
69-
-**272 Tests Passing**: Comprehensive test suite covering all functionality including performance optimizations
70-
-**Zero Linter Issues**: Clean codebase with consistent formatting and biome configuration
71-
-**Complete Performance Toolkit**: memo, useMemo, useCallback hooks for production-grade optimization
72-
-**Production-Ready**: Robust error handling, TypeScript support, and comprehensive edge case coverage
73-
-**Package Preparation**: Ready for npm registry publication with performance features
67+
-**Fiber Reconciler**: Real React-like fiber architecture with work loop, begin/complete work, and commit phases
68+
-**Lane-Based Priorities**: Branded `Lane`/`Lanes` type system with priority scheduling and lane merging
69+
-**Scheduler**: Binary min-heap task queue with `scheduleCallback`, `shouldYield`, and priority levels
70+
-**Concurrent Rendering Groundwork**: `performConcurrentWorkOnRoot` with time-slicing support
71+
-**Type Safety Hardening**: Centralised unsafe-cast boundary (`bitwise.ts`), zero stray `as number` casts, compile-time enforcement
72+
-**473 Tests Passing**: Comprehensive test suite across 38 files with 1,526 expectations
73+
-**Zero Type Errors**: `bun typecheck` clean (0 errors)
74+
-**Interactive Showcase**: Live browser demo at `examples/interactive-showcase/`
7475

75-
**Stable Release Progress**: 1/9 phases complete (11% complete) 🚀
76+
**Stable Release Progress**: 2/9 phases complete (22% complete) 🚀
7677

7778
**Immediate Milestones**:
7879

79-
- 🚀 **npm Package Publication**: Package will be available on npm registry soon
80-
- 📦 **Alpha Release v0.1.0**: Complete core React-like functionality now available
81-
- 📚 **Documentation & Examples**: Comprehensive guides and demo applications
80+
- 🚀 **npm Package v0.3.0**: Published with fiber reconciler and performance toolkit
81+
- 📚 **Documentation & Examples**: Interactive showcase + updated API docs
82+
- 🧪 **Testing & Quality Assurance**: Phase 19 test coverage underway
8283

83-
**Post-Alpha Roadmap**: 12 additional phases planned for stable v1.0.0 release with advanced features including concurrent rendering, SSR, dev tools, and production optimizations.
84+
**Post-Alpha Roadmap**: 11 additional phases planned for stable v1.0.0 release with advanced features including concurrent rendering, SSR, dev tools, and production optimizations.
8485

8586
---
8687

@@ -378,7 +379,7 @@ const App = () => {
378379

379380
### 📋 Testing & Quality
380381

381-
- **261 Comprehensive Tests**: Full test coverage for all features and edge cases including all hooks
382+
- **473 Comprehensive Tests**: Full test coverage for all features and edge cases including all hooks
382383
- **TypeScript Support**: Full type safety with detailed type definitions
383384
- **Linting & Formatting**: Biome-based code quality and consistent formatting
384385
- **Error Handling**: Graceful degradation and helpful error messages
@@ -581,7 +582,7 @@ mini-react/
581582
- ✅ Advanced rendering (Portals, Fragments)
582583
- ✅ Production-ready reconciliation engine
583584
- ✅ Comprehensive TypeScript support
584-
-261 tests with full coverage
585+
-473 tests with full coverage
585586
- ✅ Developer-friendly API matching React patterns
586587
- ✅ npm package ready for publication
587588

biome.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
"noUnusedImports": "error",
3232
"noUnusedVariables": "error"
3333
},
34+
"complexity": {
35+
"useLiteralKeys": "off"
36+
},
37+
"style": {
38+
"noNonNullAssertion": "error"
39+
},
3440
"security": {
3541
"noGlobalEval": "warn"
3642
}

bun.lock

Lines changed: 19 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)