@@ -43,17 +43,7 @@ import componentActionsRecord from './masterState';
43
43
44
44
import { throttle , getHooksNames } from './helpers' ;
45
45
46
- const DEBUG_MODE = false ;
47
-
48
- const alwaysLog = console . log ;
49
-
50
- console . log = ( original => {
51
- return ( ...args ) => {
52
- if ( DEBUG_MODE ) original ( ...args ) ;
53
- }
54
- } ) ( console . log ) ;
55
-
56
-
46
+ let doWork = true ;
57
47
const circularComponentTable = new Set ( ) ;
58
48
59
49
// module.exports = (snap, mode) => {
@@ -149,7 +139,7 @@ export default (snap, mode) => {
149
139
// which includes the dispatch() function we use to change their state.
150
140
const hooksStates = traverseHooks ( memoizedState ) ;
151
141
const hooksNames = getHooksNames ( elementType . toString ( ) ) ;
152
- console . log ( 'hooks names:' , hooksNames ) ;
142
+ // console.log('hooks names:', hooksNames);
153
143
hooksStates . forEach ( ( state , i ) => {
154
144
hooksIndex = componentActionsRecord . saveNew ( state . state , state . component ) ;
155
145
if ( newState && newState . hooksState ) {
@@ -160,7 +150,7 @@ export default (snap, mode) => {
160
150
newState = { hooksState : [ { [ hooksNames [ i ] ] : state . state } , hooksIndex ] } ;
161
151
}
162
152
componentFound = true ;
163
- console . log ( 'currentFiber of hooks state:' , currentFiber ) ;
153
+ // console.log('currentFiber of hooks state:', currentFiber);
164
154
} ) ;
165
155
}
166
156
}
@@ -210,14 +200,14 @@ export default (snap, mode) => {
210
200
createTree ( sibling , newNode , true ) ;
211
201
}
212
202
213
- if ( circularComponentTable . has ( child ) ) {
203
+ /* if (circularComponentTable.has(child)) {
214
204
console.log('found circular child, exiting tree loop');
215
205
}
216
206
217
207
if (circularComponentTable.has(sibling)) {
218
208
console.log('found circular sibling, exiting tree loop');
219
209
}
220
-
210
+ */
221
211
return tree ;
222
212
}
223
213
@@ -230,6 +220,11 @@ export default (snap, mode) => {
230
220
sendSnapshot ( ) ;
231
221
}
232
222
223
+ function onVisibilityChange ( ) {
224
+ doWork = ! document . hidden ;
225
+ console . log ( 'doWork is:' , doWork ) ;
226
+ }
227
+
233
228
return async ( ) => {
234
229
/* const container = document.getElementById('root');
235
230
if (container._internalRoot) {
@@ -248,12 +243,12 @@ export default (snap, mode) => {
248
243
fiberRoot = devTools . getFiberRoots ( 1 ) . values ( ) . next ( ) . value ;
249
244
const throttledUpdateSnapshot = throttle ( updateSnapShotTree , 250 ) ;
250
245
251
- console . log ( 'fiberRoot: ', fiberRoot ) ;
246
+ document . addEventListener ( 'visibilitychange ', onVisibilityChange ) ;
252
247
if ( reactInstance && reactInstance . version ) {
253
248
devTools . onCommitFiberRoot = ( function ( original ) {
254
249
return function ( ...args ) {
255
250
fiberRoot = args [ 1 ] ;
256
- throttledUpdateSnapshot ( ) ;
251
+ if ( doWork ) throttledUpdateSnapshot ( ) ;
257
252
return original ( ...args ) ;
258
253
} ;
259
254
} ( devTools . onCommitFiberRoot ) ) ;
0 commit comments