@@ -65,7 +65,7 @@ export default (snap, mode) => {
65
65
66
66
if ( ! snap . tree ) {
67
67
// console.log('snapshot empty, sending root');
68
- snap . tree = new Tree ( 'root' ) ;
68
+ snap . tree = new Tree ( 'root' , 'root' ) ;
69
69
}
70
70
const payload = snap . tree . cleanTreeCopy ( ) ; // snap.tree.getCopy();
71
71
@@ -103,7 +103,7 @@ export default (snap, mode) => {
103
103
104
104
// Carlos: This runs after EVERY Fiber commit. It creates a new snapshot,
105
105
//
106
- function createTree ( currentFiber , tree = new Tree ( 'root' ) , fromSibling = false ) {
106
+ function createTree ( currentFiber , tree = new Tree ( 'root' , 'root' ) , fromSibling = false ) {
107
107
// Base case: child or sibling pointed to null
108
108
// console.log('linkFiber.js: creating tree');
109
109
if ( ! currentFiber ) return null ;
@@ -223,21 +223,23 @@ export default (snap, mode) => {
223
223
}
224
224
225
225
return async ( ) => {
226
- // if (container._internalRoot) {
227
- // fiberRoot = container._internalRoot;
228
- // } else {
229
- // const {
230
- // _reactRootContainer: { _internalRoot },
231
- // _reactRootContainer,
232
- // } = container;
233
- // // Only assign internal root if it actually exists
234
- // fiberRoot = _internalRoot || _reactRootContainer;
235
- // }
226
+
227
+ const container = document . getElementById ( 'root' ) ;
228
+ if ( container . _internalRoot ) {
229
+ fiberRoot = container . _internalRoot ;
230
+ } else {
231
+ const {
232
+ _reactRootContainer : { _internalRoot } ,
233
+ _reactRootContainer,
234
+ } = container ;
235
+ // Only assign internal root if it actually exists
236
+ fiberRoot = _internalRoot || _reactRootContainer ;
237
+ }
236
238
237
239
const devTools = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ ;
238
240
const reactInstance = devTools ? devTools . renderers . get ( 1 ) : null ;
239
- // console.log('devTools:', devTools);
240
241
242
+ //console.log('fiberRoot retrieved:', fiberRoot);
241
243
if ( reactInstance && reactInstance . version ) {
242
244
devTools . onCommitFiberRoot = ( function ( original ) {
243
245
return function ( ...args ) {
@@ -248,15 +250,16 @@ export default (snap, mode) => {
248
250
} ;
249
251
} ( devTools . onCommitFiberRoot ) ) ;
250
252
}
253
+ updateSnapShotTree ( ) ;
251
254
sendSnapshot ( ) ;
252
255
// updateSnapShotTree();
253
256
// Send the initial snapshot once the content script has started up
254
257
// This message is sent from contentScript.js in chrome extension bundles
255
- window . addEventListener ( 'message' , ( { data : { action } } ) => {
256
- if ( action === 'contentScriptStarted' ) {
257
- // console.log('content script started received at linkFiber.js')
258
- sendSnapshot ( ) ;
259
- }
260
- } ) ;
258
+ // window.addEventListener('message', ({ data: { action } }) => {
259
+ // if (action === 'contentScriptStarted') {
260
+ // // console.log('content script started received at linkFiber.js')
261
+ // sendSnapshot();
262
+ // }
263
+ // });
261
264
} ;
262
265
} ;
0 commit comments