1
- /* eslint-disable guard-for-in */
2
- /* eslint-disable no-restricted-syntax */
3
1
// @ts -nocheck
4
2
import React , { useState } from 'react' ;
5
3
import FormControlLabel from '@material-ui/core/FormControlLabel' ;
@@ -18,10 +16,7 @@ import BarGraph from './BarGraph';
18
16
import BarGraphComparison from './BarGraphComparison' ;
19
17
import { useStoreContext } from '../store' ;
20
18
// import snapshots from './snapshots';
21
- import snapshots from './snapshots' ;
22
-
23
- const exclude = [ 'childExpirationTime' , 'staticContext' , '_debugSource' , 'actualDuration' , 'actualStartTime' , 'treeBaseDuration' , '_debugID' , '_debugIsCurrentlyTiming' , 'selfBaseDuration' , 'expirationTime' , 'effectTag' , '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' ] ;
24
-
19
+ import { Component } from 'react' ;
25
20
/* NOTES
26
21
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
27
22
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -31,99 +26,56 @@ to note - all snapshots do render (check HTML doc) within the chrome extension b
31
26
not display because height is not consistently passed to each bar. This side effect is only
32
27
seen in recoil apps...
33
28
*/
34
-
35
29
// typescript for PROPS from StateRoute.tsx
36
30
interface BarStackProps {
37
31
width : number ;
38
32
height : number ;
39
33
snapshots : [ ] ;
40
34
hierarchy : any ;
41
35
}
42
-
43
- const makePropsPretty = data => {
44
- const propsFormat = [ ] ;
45
- const nestedObj = [ ] ;
46
- if ( typeof data !== 'object' ) {
47
- return < p > { data } </ p > ;
48
- }
49
- for ( const key in data ) {
50
- if ( data [ key ] !== 'reactFiber' && typeof data [ key ] !== 'object' && exclude . includes ( key ) !== true ) {
51
- propsFormat . push ( < p className = "stateprops" >
52
- { `${ key } : ${ data [ key ] } ` }
53
- </ p > ) ;
54
- } else if ( data [ key ] !== 'reactFiber' && typeof data [ key ] === 'object' && exclude . includes ( key ) !== true ) {
55
- const result = makePropsPretty ( data [ key ] ) ;
56
- nestedObj . push ( result ) ;
57
- }
58
- }
59
- if ( nestedObj ) {
60
- propsFormat . push ( nestedObj ) ;
61
- }
62
- return propsFormat ;
63
- } ;
64
-
36
+ // function getComponentsArr(componentName, snapshots, node) {
37
+ // //Input: Name of component and all snapshots
38
+ // //Output: One array of each individual snapshot
39
+ // //NOTE:
40
+ // //Every snapshot is an object with a children array with a snapshot that also has a children array etc
41
+ // //Children arrays more than one signify siblings
42
+ // }
43
+ // // snapshots.map(rootNode => {
44
+ // // // rootNode.name
45
+ // // let currNode = rootNode
46
+ // // while (currNode) {
47
+ // // if (currNode.name === componentName) {
48
+ // // return currNode.componentData.props
49
+ // // } else {
50
+ // // currNode = currNode.children[0]
51
+ // // currNode = currNode.children[1]
52
+ // // }
53
+ // // }
54
+ // // })
65
55
const collectNodes = ( snaps , componentName ) => {
66
56
const componentsResult = [ ] ;
67
- const renderResult = [ ] ;
68
- let trackChanges = 0 ;
69
- let newChange = true ;
57
+ // console.log("This is the snapshots", snaps) ;
58
+ // componentsResult.splice(0, componentsResult.length); { /* We used the .splice method here to ensure that nodeList did not accumulate with page refreshes */ }
59
+ // componentsResult.push(snaps) ;
70
60
for ( let x = 0 ; x < snaps . length ; x ++ ) {
71
- const snapshotList = [ ] ;
61
+ const snapshotList = [ ]
72
62
snapshotList . push ( snaps [ x ] ) ;
73
63
for ( let i = 0 ; i < snapshotList . length ; i ++ ) {
74
64
const cur = snapshotList [ i ] ;
75
65
if ( cur . name === componentName ) {
76
- const renderTime = Number (
77
- Number . parseFloat ( cur . componentData . actualDuration ) . toPrecision ( 5 ) ,
78
- ) ;
79
- if ( renderTime === 0 ) {
80
- break ;
81
- } else {
82
- renderResult . push ( renderTime ) ;
83
- }
84
- // compare the last pushed component Data from the array to the current one to see if there are differences
85
- if ( x !== 0 && componentsResult . length !== 0 ) {
86
- // needs to be stringified because values are hard to determine if true or false if in they're seen as objects
87
- if ( JSON . stringify ( Object . values ( componentsResult [ newChange ? componentsResult . length - 1 : trackChanges ] ) [ 0 ] ) !== JSON . stringify ( cur . componentData . props ) ) {
88
- newChange = true ;
89
- // const props = { [`snapshot${x}`]: { rendertime: formatRenderTime(cur.componentData.actualDuration), ...cur.componentData.props } };
90
- const props = { [ `snapshot${ x } ` ] : { ...cur . componentData . props } } ;
91
- componentsResult . push ( props ) ;
92
- } else {
93
- newChange = false ;
94
- trackChanges = componentsResult . length - 1 ;
95
- const props = { [ `snapshot${ x } ` ] : { state : 'Same state as prior snapshot' } } ;
96
- componentsResult . push ( props ) ;
97
- }
98
- } else {
99
- // const props = { [`snapshot${x}`]: { ...cur.componentData.props}};
100
- // props[`snapshot${x}`].rendertime = formatRenderTime(cur.componentData.actualDuration);
101
- const props = { [ `snapshot${ x } ` ] : { ...cur . componentData . props } } ;
102
- componentsResult . push ( props ) ;
103
- }
66
+ componentsResult . push ( cur . componentData . props ) ;
104
67
break ;
105
68
}
106
69
if ( cur . children && cur . children . length > 0 ) {
107
- for ( const child of cur . children ) {
70
+ for ( let child of cur . children ) {
108
71
snapshotList . push ( child ) ;
109
72
}
110
73
}
111
74
}
112
75
}
113
-
114
- const finalResults = componentsResult . map ( ( e , index ) => {
115
- const name = Object . keys ( e ) [ 0 ] ;
116
- e [ name ] . rendertime = renderResult [ index ] ;
117
- return e ;
118
- } ) ;
119
- for ( let i = 0 ; i < finalResults . length ; i ++ ) {
120
- for ( const componentSnapshot in finalResults [ i ] ) {
121
- finalResults [ i ] [ componentSnapshot ] = makePropsPretty ( finalResults [ i ] [ componentSnapshot ] ) . reverse ( ) ;
122
- }
123
- }
124
- return finalResults ;
125
- } ;
126
-
76
+ //console.log('componentsResult looks like: ', componentsResult);
77
+ return componentsResult ;
78
+ }
127
79
/* DATA HANDLING HELPER FUNCTIONS */
128
80
const traverse = ( snapshot , data , snapshots , currTotalRender = 0 ) => {
129
81
if ( ! snapshot . children [ 0 ] ) return ;
@@ -148,23 +100,24 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
148
100
renderFrequency : 0 ,
149
101
totalRenderTime : 0 ,
150
102
rtid : '' ,
151
- information : { } ,
103
+ props : { } ,
152
104
} ;
153
105
if ( child . state !== 'stateless' ) data . componentData [ componentName ] . stateType = 'stateful' ;
154
106
}
155
107
// increment render frequencies
156
108
if ( renderTime > 0 ) {
109
+ // console.log('what is the child', child);
110
+ // console.log('por que?', data.componentData[componentName]);
157
111
data . componentData [ componentName ] . renderFrequency ++ ;
112
+ } else {
113
+ // console.log('what is the child', child);
114
+ // console.log('we dont increment here', data.componentData[componentName], 'and the child', child);
158
115
}
159
- // else {
160
-
161
- // }
162
-
163
116
// add to total render time
164
117
data . componentData [ componentName ] . totalRenderTime += renderTime ;
165
118
// Get rtid for the hovering feature
166
119
data . componentData [ componentName ] . rtid = child . rtid ;
167
- data . componentData [ componentName ] . information = collectNodes ( snapshots , child . name ) ;
120
+ data . componentData [ componentName ] . props = collectNodes ( snapshots , child . name ) ;
168
121
traverse ( snapshot . children [ idx ] , data , snapshots , currTotalRender ) ;
169
122
} ) ;
170
123
// reassigns total render time to max render time
@@ -174,15 +127,18 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
174
127
175
128
// Retrieve snapshot series data from Chrome's local storage.
176
129
const allStorage = ( ) => {
177
- const values = [ ] ;
178
- const keys = Object . keys ( localStorage ) ;
179
- let i = keys . length ;
180
-
181
-
182
- while ( i -- ) {
183
- const series = localStorage . getItem ( keys [ i ] ) ;
184
- values . push ( JSON . parse ( series ) ) ;
185
- }
130
+ // const values = [];
131
+ // const keys = Object.keys(localStorage);
132
+ let values = localStorage . getItem ( 'project' )
133
+ // values === null ? values = [] : values = JSON.parse(values) ;
134
+ values = values === null ? [ ] : JSON . parse ( values ) ;
135
+ // let i = keys.length;
136
+ // console.log('allstorage keys', keys);
137
+ // while (i--) {
138
+ // const series = localStorage.getItem(keys[i]);
139
+ // values.push(JSON.parse(series));
140
+ // }
141
+ console . log ( 'allstorage values' , values ) ;
186
142
return values ;
187
143
} ;
188
144
@@ -204,6 +160,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
204
160
componentData : { } ,
205
161
maxTotalRender : 0 ,
206
162
} ;
163
+ console . log ( 'show me all of the snapshots' , snapshots ) ;
207
164
snapshots . forEach ( ( snapshot , i ) => {
208
165
perfData . barStack . push ( { snapshotId : snapshotsIds [ i ] } ) ;
209
166
traverse ( snapshot , perfData , snapshots ) ;
@@ -244,6 +201,9 @@ const PerformanceVisx = (props: BarStackProps) => {
244
201
} ;
245
202
246
203
const renderComponentDetailsView = ( ) => {
204
+ console . log ( 'show me snapshots' , snapshots )
205
+ console . log ( 'what is heirarchy' , hierarchy ) ;
206
+ console . log ( 'this is the info for rendering frequency' , data . componentData ) ;
247
207
if ( hierarchy ) {
248
208
return < RenderingFrequency data = { data . componentData } /> ;
249
209
}
0 commit comments