@@ -22,6 +22,7 @@ import componentActionsRecord from './masterState';
2222import { throttle , getHooksNames } from './helpers' ;
2323import { Console } from 'console' ;
2424import AtomsRelationship from '../app/components/AtomsRelationship' ;
25+ import { isNull } from 'util' ;
2526
2627// Set global variables to use in exported module and helper functions
2728declare global {
@@ -35,6 +36,9 @@ const circularComponentTable = new Set();
3536let isRecoil = false ;
3637let allAtomsRelationship = [ ] ;
3738let initialstart = false ;
39+ let rtidCounter = 0 ;
40+ let rtid = null ;
41+ let recoilStateNode = { } ;
3842
3943// Simple check for whether our target app uses Recoil
4044if ( window [ `$recoilDebugStates` ] ) {
@@ -78,7 +82,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
7882 payload . atomSelectors = atomsSelectors ;
7983 }
8084
81-
85+ console . log ( recoilStateNode )
8286 window . postMessage (
8387 {
8488 action : 'recordSnap' ,
@@ -183,6 +187,17 @@ function createTree(
183187 if ( ! currentFiber ) return null ;
184188 if ( ! tree ) return tree ;
185189
190+ if ( currentFiber . tag === 0 || currentFiber . tag === 1 || currentFiber . tag === 2 ) {
191+ if ( currentFiber . child && currentFiber . child . stateNode ) {
192+ // console.log('Sanjays algo', currentFiber)
193+ rtid = "fromLinkFiber" + rtidCounter
194+ // if (currentFiber.child.stateNode.setAttribute) {
195+ currentFiber . child . stateNode . setAttribute ( "id" , rtid ) ;
196+ // }
197+ }
198+ rtidCounter ++ ;
199+ }
200+
186201 // These have the newest state. We update state and then
187202 // called updateSnapshotTree()
188203
@@ -200,6 +215,7 @@ function createTree(
200215 treeBaseDuration,
201216 } = currentFiber ;
202217
218+
203219 //Checks Recoil Atom and Selector Relationships
204220 if (
205221 currentFiber . memoizedState &&
@@ -282,6 +298,7 @@ function createTree(
282298 ( tag === 0 || tag === 1 || tag === 2 || tag === 10 ) &&
283299 isRecoil === true
284300 ) {
301+ // console.log('Recoil Hooks Algo', currentFiber)
285302 if ( memoizedState . queue ) {
286303 // Hooks states are stored as a linked list using memoizedState.next,
287304 // so we must traverse through the list and get the states.
@@ -315,6 +332,7 @@ function createTree(
315332 ( tag === 0 || tag === 1 || tag === 2 || tag === 10 ) &&
316333 isRecoil === false
317334 ) {
335+ // console.log('Regular Hooks Algo', currentFiber)
318336 if ( memoizedState . queue ) {
319337 // Hooks states are stored as a linked list using memoizedState.next,
320338 // so we must traverse through the list and get the states.
@@ -343,6 +361,7 @@ function createTree(
343361
344362 // This grabs stateless components
345363 if ( ! componentFound && ( tag === 0 || tag === 1 || tag === 2 ) ) {
364+ // console.log('Stateless Algo', currentFiber)
346365 newState = 'stateless' ;
347366 }
348367
@@ -356,19 +375,47 @@ function createTree(
356375 } ;
357376
358377 let newNode = null ;
378+
359379 // We want to add this fiber node to the snapshot
360380 if ( componentFound || newState === 'stateless' ) {
361381 if ( fromSibling ) {
382+
383+ console . log ( currentFiber )
384+
385+
386+ if ( currentFiber . elementType . name ) {
387+ if ( ! recoilStateNode [ currentFiber . elementType . name ] ) {
388+ recoilStateNode [ currentFiber . elementType . name ] = [ ] ;
389+ }
390+ }
391+
392+ let pointer = currentFiber
393+ while ( pointer !== null ) {
394+ if ( pointer . stateNode !== null ) {
395+ rtid = "fromLinkFiber" + rtidCounter ++
396+ recoilStateNode [ currentFiber . elementType . name ] . push ( pointer . stateNode ) }
397+ pointer . stateNode . setAttribute ( "id" , rtid )
398+ pointer = pointer . child
399+ }
400+
401+ // console.log(currentFiber)
402+
403+ // currentFiber.child.stateNode.setAttribute("id", rtid);
362404 newNode = tree . addSibling (
363405 newState ,
364406 elementType ? elementType . name : 'nameless' ,
365- componentData
407+ componentData ,
408+ rtid
366409 ) ;
367410 } else {
411+ // console.log(currentFiber)
412+ rtid = "fromLinkFiber" + rtidCounter ++
413+ // currentFiber.child.stateNode.setAttribute("id", rtid);
368414 newNode = tree . addChild (
369415 newState ,
370416 elementType ? elementType . name : 'nameless' ,
371- componentData
417+ componentData ,
418+ rtid
372419 ) ;
373420 }
374421 } else {
@@ -382,13 +429,13 @@ function createTree(
382429 // Otherwise, attach children to this same node.
383430 circularComponentTable . add ( child ) ;
384431 createTree ( child , newNode ) ;
432+
385433 }
386434 // Recurse on siblings
387435 if ( sibling && ! circularComponentTable . has ( sibling ) ) {
388436 circularComponentTable . add ( sibling ) ;
389437 createTree ( sibling , newNode , true ) ;
390438 }
391-
392439 return tree ;
393440}
394441
0 commit comments