2
2
/* eslint-disable no-restricted-syntax */
3
3
/* eslint-disable @typescript-eslint/no-explicit-any */
4
4
/* eslint-disable max-len */
5
- // import 'core-js';
6
5
/* eslint-disable indent */
7
6
/* eslint-disable brace-style */
8
7
/* eslint-disable comma-dangle */
9
8
/* eslint-disable no-underscore-dangle */
10
9
/* eslint-disable func-names */
11
10
/* eslint-disable no-use-before-define */
12
11
/* eslint-disable no-param-reassign */
12
+ /* eslint-disable-next-line no-mixed-operators */
13
13
14
14
// import typescript types
15
15
import {
16
16
// tree
17
17
Snapshot ,
18
18
// jump, pause
19
19
Mode ,
20
- ComponentData ,
21
20
// array of state and component
22
21
HookStates ,
23
22
// object with tree structure
24
23
Fiber ,
25
24
} from './types/backendTypes' ;
26
25
// import function that creates a tree
27
26
import Tree from './tree' ;
28
- // passes the data down to its components ?
27
+ // passes the data down to its components
29
28
import componentActionsRecord from './masterState' ;
30
29
import routes from './routes' ;
31
30
@@ -43,7 +42,6 @@ declare global {
43
42
let fiberRoot = null ;
44
43
let doWork = true ;
45
44
const circularComponentTable = new Set ( ) ;
46
- let initialstart = false ;
47
45
let rtidCounter = 0 ;
48
46
let rtid = null ;
49
47
@@ -102,20 +100,9 @@ function updateSnapShotTree(snap: Snapshot, mode: Mode): void {
102
100
sendSnapshot ( snap , mode ) ;
103
101
}
104
102
105
- // updating tree depending on current mode on the panel (pause, etc)
106
- // function sendDevToolsInfo(snap: Snapshot, mode: Mode): void {
107
- // window.postMessage(
108
- // {
109
- // action: 'recordSnap',
110
- // payload,
111
- // },
112
- // '*'
113
- // );
114
- // }
115
-
116
103
/**
117
104
* @method traverseHooks
118
- * @param memoizedState memoizedState property on a stateful fctnl component's FiberNode object
105
+ * @param memoizedState memoizedState property on a stateful functional component's FiberNode object
119
106
* @return An array of array of HookStateItem objects
120
107
*
121
108
* Helper function to traverse through memoizedState and inject instrumentation to update our state tree
@@ -155,7 +142,6 @@ const exclude = ['alternate', '_owner', '_store', 'get key', 'ref', '_self', '_s
155
142
// react elements throw errors on client side of application - convert react/functions into string
156
143
function convertDataToString ( newObj , oldObj ) {
157
144
const newPropData = oldObj || { } ;
158
- // const newPropData = Array.isArray(obj) === true ? {} : [];
159
145
for ( const key in newObj ) {
160
146
if ( typeof newObj [ key ] === 'function' ) {
161
147
newPropData [ key ] = 'function' ;
@@ -292,7 +278,6 @@ function createTree(
292
278
let newNode = null ;
293
279
294
280
// We want to add this fiber node to the snapshot
295
- // eslint-disable-next-line no-mixed-operators
296
281
if ( componentFound || newState === 'stateless' && ! newState . hooksState ) {
297
282
if (
298
283
currentFiber . child
@@ -351,60 +336,3 @@ function createTree(
351
336
}
352
337
return tree ;
353
338
}
354
-
355
- /**
356
- * @method linkFiber
357
- * @param snap The current snapshot
358
- * @param mode The current mode (i.e. jumping, time-traveling, or paused)
359
- * @return a function to be invoked by index.js that initiates snapshot monitoring
360
- * linkFiber contains core module functionality, exported as an anonymous function.
361
- */
362
- export default ( snap : Snapshot , mode : Mode ) : ( ( ) => void ) => {
363
- // checks for visiblity of document
364
- function onVisibilityChange ( ) : void {
365
- // hidden property = background tab/minimized window
366
- doWork = ! document . hidden ;
367
- }
368
- return ( ) => {
369
- // react devtools global hook is a global object that was injected by the React Devtools content script, allows access to fiber nodes and react version
370
- const devTools = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ ;
371
- // check if reactDev Tools is installed
372
- if ( ! devTools ) { return ; }
373
- window . postMessage ( {
374
- action : 'devToolsInstalled' ,
375
- payload : 'devToolsInstalled'
376
- } , '*' ) ;
377
- // reactInstance returns an object of the react, 1st element in map
378
- const reactInstance = devTools . renderers . get ( 1 ) ;
379
- // if no React Instance found then target is not a compatible app
380
- if ( ! reactInstance ) { return ; }
381
- window . postMessage ( {
382
- action : 'aReactApp' ,
383
- payload : 'aReactApp'
384
- } , '*' ) ;
385
-
386
- const throttledUpdateSnapshot = throttle ( ( ) => { updateSnapShotTree ( snap , mode ) ; } , 70 ) ;
387
- document . addEventListener ( 'visibilitychange' , onVisibilityChange ) ;
388
-
389
- if ( reactInstance && reactInstance . version ) {
390
- fiberRoot = devTools . getFiberRoots ( 1 ) . values ( ) . next ( ) . value ;
391
- // React has inherent methods that are called with react fiber
392
- // we attach new functionality without compromising the original work that onCommitFiberRoot does
393
- const addOneMoreStep = function ( original ) {
394
- return function ( ...args ) {
395
- // eslint-disable-next-line prefer-destructuring
396
- fiberRoot = args [ 1 ] ;
397
- // this is the additional functionality we added
398
- if ( doWork ) {
399
- throttledUpdateSnapshot ( ) ;
400
- }
401
- // after our added work is completed we invoke the original function
402
- return original ( ...args ) ;
403
- } ;
404
- } ;
405
- devTools . onCommitFiberRoot = addOneMoreStep ( devTools . onCommitFiberRoot ) ;
406
-
407
- throttledUpdateSnapshot ( ) ; // only runs on start up
408
- }
409
- } ;
410
- } ;
0 commit comments