@@ -544,92 +544,6 @@ export const getLatestFiber = (fiber: Fiber): Fiber => {
544
544
return fiber ;
545
545
} ;
546
546
547
- interface FiberDiff {
548
- path : ( 'child' | 'sibling' ) [ ] ;
549
- type : 'props' | 'state' | 'type' | 'ref' | 'children' ;
550
- thisFiber : Fiber ;
551
- otherFiber : Fiber ;
552
- }
553
-
554
- export const diffFiber = ( thisFiber : Fiber , otherFiber : Fiber ) : FiberDiff [ ] => {
555
- const path : FiberDiff [ 'path' ] = [ ] ;
556
- const diffs : FiberDiff [ ] = [ ] ;
557
-
558
- const traverse = ( current : Fiber , other : Fiber , currentPath : ( 'child' | 'sibling' ) [ ] ) => {
559
- if ( current . type !== other . type ) {
560
- diffs . push ( {
561
- path : [ ...currentPath ] ,
562
- type : 'type' ,
563
- thisFiber : current ,
564
- otherFiber : other
565
- } ) ;
566
- }
567
-
568
- if ( current . ref !== other . ref ) {
569
- diffs . push ( {
570
- path : [ ...currentPath ] ,
571
- type : 'ref' ,
572
- thisFiber : current ,
573
- otherFiber : other
574
- } ) ;
575
- }
576
-
577
- // Compare props
578
- const currentProps = current . memoizedProps || { } ;
579
- const otherProps = other . memoizedProps || { } ;
580
- const allProps = new Set ( [ ...Object . keys ( currentProps ) , ...Object . keys ( otherProps ) ] ) ;
581
-
582
- for ( const prop of allProps ) {
583
- if ( currentProps [ prop ] !== otherProps [ prop ] ) {
584
- diffs . push ( {
585
- path : [ ...currentPath ] ,
586
- type : 'props' ,
587
- thisFiber : current ,
588
- otherFiber : other
589
- } ) ;
590
- break ; // Only record one props difference per fiber
591
- }
592
- }
593
-
594
- // Compare state
595
- if ( current . memoizedState !== other . memoizedState ) {
596
- diffs . push ( {
597
- path : [ ...currentPath ] ,
598
- type : 'state' ,
599
- thisFiber : current ,
600
- otherFiber : other
601
- } ) ;
602
- }
603
-
604
- // Recursively traverse children
605
- if ( current . child && other . child ) {
606
- traverse ( current . child , other . child , [ ...currentPath , 'child' ] ) ;
607
- } else if ( current . child || other . child ) {
608
- diffs . push ( {
609
- path : [ ...currentPath ] ,
610
- type : 'children' ,
611
- thisFiber : current ,
612
- otherFiber : other
613
- } ) ;
614
- }
615
-
616
- // Recursively traverse siblings
617
- if ( current . sibling && other . sibling ) {
618
- traverse ( current . sibling , other . sibling , [ ...currentPath , 'sibling' ] ) ;
619
- } else if ( current . sibling || other . sibling ) {
620
- diffs . push ( {
621
- path : [ ...currentPath ] ,
622
- type : 'children' ,
623
- thisFiber : current ,
624
- otherFiber : other
625
- } ) ;
626
- }
627
- } ;
628
-
629
- traverse ( thisFiber , otherFiber , path ) ;
630
- return diffs ;
631
- } ;
632
-
633
547
export type RenderPhase = 'mount' | 'update' | 'unmount' ;
634
548
635
549
export type RenderHandler = < S > (
0 commit comments