1
+ /* eslint-disable guard-for-in */
2
+ /* eslint-disable no-restricted-syntax */
1
3
/* eslint-disable @typescript-eslint/no-explicit-any */
2
4
/* eslint-disable max-len */
3
5
// import 'core-js';
@@ -207,20 +209,20 @@ function traverseHooks(memoizedState: any): HookStates {
207
209
// This runs after every Fiber commit. It creates a new snapshot
208
210
let atomsSelectors = { } ;
209
211
let atomsComponents = { } ;
210
-
211
- function convertFunctionToString ( obj : { } ) {
212
- const newPropData = { } ;
212
+ const exclude = [ 'alternate' , '_owner' , '_store' , 'get key' , 'ref' , '_self' , '_source' , 'firstBaseUpdate' , 'updateQueue' , 'lastBaseUpdate' , 'shared' , 'responders' , 'pending' , 'lanes' , 'childLanes' , 'effects' , 'memoizedState' , 'pendingProps' , 'lastEffect' , 'firstEffect' , 'tag' , 'baseState' , 'baseQueue' , 'dependencies' , 'Consumer' , 'context' , '_currentRenderer' , '_currentRenderer2' , 'mode' , 'flags' , 'nextEffect' , 'sibling' , 'create' , 'deps' , 'next' , 'destroy' , 'parentSub' , 'child' , 'key' , 'return' , 'children' , '$$typeof' , '_threadCount' , '_calculateChangedBits' , '_currentValue' , '_currentValue2' , 'Provider' , '_context' , 'stateNode' , 'elementType' , 'type' ] ;
213
+ function convertFunctionToString ( newObj , oldObj ) {
214
+ const newPropData = oldObj || { } ;
213
215
// const newPropData = Array.isArray(obj) === true ? {} : [];
214
- for ( const key in obj ) {
215
- if ( typeof obj [ key ] === 'function' ) {
216
+ for ( const key in newObj ) {
217
+ if ( typeof newObj [ key ] === 'function' ) {
216
218
newPropData [ key ] = 'function' ;
217
219
// console.log('we changed the function', newPropData[key]);
218
- } else if ( typeof obj [ key ] === 'object' ) {
219
- // console.log('this is going to enter a recursive call', obj [key]);
220
- // convertFunctionToString(obj [key]);
221
- newPropData [ key ] = JSON . stringify ( obj [ key ] ) ;
222
- } else {
223
- newPropData [ key ] = obj [ key ] ;
220
+ } else if ( typeof newObj [ key ] === 'object' && exclude . includes ( key ) !== true ) {
221
+ console . log ( 'in the recursive call' , key , newObj [ key ] , key ) ;
222
+ newPropData [ key ] = convertFunctionToString ( newObj [ key ] , null ) ;
223
+ } else if ( exclude . includes ( key ) !== true ) {
224
+ console . log ( 'there should be no objects here' , key , typeof newObj [ key ] , newObj [ key ] ) ;
225
+ newPropData [ key ] = newObj [ key ] ;
224
226
}
225
227
}
226
228
// console.log(newPropData);
@@ -233,8 +235,6 @@ function createTree(
233
235
tree : Tree = new Tree ( 'root' , 'root' ) ,
234
236
fromSibling = false
235
237
) {
236
-
237
- console . log ( 'CurrentFiber: ' , currentFiber ) ;
238
238
// Base case: child or sibling pointed to null
239
239
if ( ! currentFiber ) return null ;
240
240
if ( ! tree ) return tree ;
@@ -255,18 +255,20 @@ function createTree(
255
255
treeBaseDuration,
256
256
} = currentFiber ;
257
257
// new feature adds props/state into the component
258
+ // console.log('CurrentFiber & tag: ', tag, currentFiber);
258
259
259
260
if ( tag === 5 ) {
260
261
try {
261
262
// console.log('this is the tree', tree);
262
263
263
264
if ( memoizedProps . children [ 0 ] . _owner . memoizedProps !== undefined ) {
264
265
const propsData = memoizedProps . children [ 0 ] . _owner . memoizedProps ;
265
- const newPropData = convertFunctionToString ( propsData ) ;
266
+ const newPropData = convertFunctionToString ( propsData , tree . componentData . props ? tree . componentData . props : null ) ;
266
267
tree . componentData = {
267
268
...tree . componentData ,
268
269
props : newPropData
269
270
} ;
271
+ console . log ( 'this is the new tree with errthang' , tree . componentData ) ;
270
272
}
271
273
// console.log('CHECKING THE TREE FOR THE DATA', tree);
272
274
// console.log('looking for the owner', memoizedProps.children);
@@ -277,6 +279,7 @@ function createTree(
277
279
// console.log('this is the error', error);
278
280
}
279
281
}
282
+ console . log ( 'show me the tree' , tree ) ;
280
283
// Checks Recoil Atom and Selector Relationships
281
284
if (
282
285
currentFiber . memoizedState
@@ -333,8 +336,14 @@ function createTree(
333
336
actualStartTime ?: number ;
334
337
selfBaseDuration ?: number ;
335
338
treeBaseDuration ?: number ;
339
+ props ?: any ,
336
340
} = { } ;
337
341
let componentFound = false ;
342
+ if ( memoizedProps ) {
343
+ // console.log('memoized props with the tag name', tag, memoizedProps, convertFunctionToString(memoizedProps, null));
344
+ // console.log('looking at memoizedProps ', memoizedProps);
345
+ componentData . props = convertFunctionToString ( memoizedProps , null ) ;
346
+ }
338
347
339
348
// Check if node is a stateful class component
340
349
if ( stateNode && stateNode . state && ( tag === 0 || tag === 1 || tag === 2 ) ) {
@@ -493,7 +502,6 @@ function createTree(
493
502
// console.log('no next effect');
494
503
// }
495
504
// console.log('we are in addsibling and this is the rtid and element name', rtid, elementType.name, 'this is the current fiber', currentFiber);
496
- console . log ( 'looking at this circuclar componnent table in sibling' , circularComponentTable ) ;
497
505
newNode = tree . addSibling (
498
506
newState ,
499
507
elementType ? elementType . name : 'nameless' ,
@@ -509,7 +517,6 @@ function createTree(
509
517
// console.log('no next effect');
510
518
// }
511
519
// console.log('we are in addchild and this is the rtid and element name', rtid, elementType.name, 'this is the current fiber', currentFiber);
512
- console . log ( 'looking at this circuclar componnent table in child' , circularComponentTable ) ;
513
520
newNode = tree . addChild (
514
521
newState ,
515
522
elementType ? elementType . name : 'nameless' ,
@@ -519,7 +526,6 @@ function createTree(
519
526
) ;
520
527
}
521
528
} else {
522
- console . log ( 'why do we go here will the duplicate come here' , tree ) ;
523
529
newNode = tree ;
524
530
}
525
531
@@ -562,8 +568,8 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
562
568
console . log ( 'THIS IS THE FIBER ROOOT' , fiberRoot ) ;
563
569
const throttledUpdateSnapshot = throttle (
564
570
( ) => {
565
- console . log ( 'how many times in line 497' ) ;
566
- console . log ( 'THIS IS SNAP AND MODEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE' , snap , mode ) ;
571
+ // console.log('how many times in line 497');
572
+ // console.log('THIS IS SNAP AND MODEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE', snap, mode);
567
573
updateSnapShotTree ( snap , mode ) ;
568
574
} ,
569
575
70
0 commit comments