1
- /* eslint-disable func-names */
2
1
/* eslint-disable no-use-before-define */
3
2
/* eslint-disable no-param-reassign */
4
3
// links component state tree to library
@@ -13,6 +12,7 @@ module.exports = (snap, mode) => {
13
12
// DEV: So that when we are jumping to an old snapshot it wouldn't think we want to create new snapshots
14
13
if ( mode . jumping || mode . paused ) return ;
15
14
const payload = snap . tree . getCopy ( ) ;
15
+ console . log ( payload ) ;
16
16
// console.log('payload', payload);
17
17
window . postMessage ( {
18
18
action : 'recordSnap' ,
@@ -103,55 +103,20 @@ module.exports = (snap, mode) => {
103
103
snap . tree = createTree ( current ) ;
104
104
}
105
105
106
- // return container => {
107
- // // console.log('Container', container);
108
- // const {
109
- // _reactRootContainer: { _internalRoot },
110
- // _reactRootContainer,
111
- // } = container;
112
- // // console.log('Root container', _reactRootContainer);
113
- // // only assign internal root if it actually exists
114
- // fiberRoot = _internalRoot || _reactRootContainer;
115
- // updateSnapShotTree();
116
-
117
- // // send the initial snapshot once the content script has started up
118
- // window.addEventListener('message', ({ data: { action } }) => {
119
- // if (action === 'contentScriptStarted') sendSnapshot();
120
- // });
121
- // };
106
+ return container => {
107
+ // console.log('Container', container);
108
+ const {
109
+ _reactRootContainer : { _internalRoot } ,
110
+ _reactRootContainer,
111
+ } = container ;
112
+ // console.log('Root container', _reactRootContainer);
113
+ // only assign internal root if it actually exists
114
+ fiberRoot = _internalRoot || _reactRootContainer ;
115
+ updateSnapShotTree ( ) ;
122
116
123
- return {
124
- main ( container ) {
125
- // console.log('Container', container);
126
- const {
127
- _reactRootContainer : { _internalRoot } ,
128
- _reactRootContainer,
129
- } = container ;
130
- // console.log('Root container', _reactRootContainer);
131
- // only assign internal root if it actually exists
132
- fiberRoot = _internalRoot || _reactRootContainer ;
133
- updateSnapShotTree ( ) ;
134
-
135
- // send the initial snapshot once the content script has started up
136
- window . addEventListener ( 'message' , ( { data : { action } } ) => {
137
- if ( action === 'contentScriptStarted' ) sendSnapshot ( ) ;
138
- } ) ;
139
- } ,
140
- changeUseState ( useState ) {
141
- return function ( initial ) {
142
- // running the original useState and storing its result (state and dispatch function)
143
- const toReturn = useState ( initial ) ;
144
- console . log ( toReturn ) ;
145
- // storing the original dispatch function definition somewhere
146
- const oldDispatch = toReturn [ 1 ] ;
147
- // redefining the dispatch function so we can inject our code
148
- toReturn [ 1 ] = function ( callback ) {
149
- oldDispatch ( callback ) ;
150
- updateSnapShotTree ( ) ;
151
- sendSnapshot ( ) ;
152
- } ;
153
- return toReturn ;
154
- } ;
155
- } ,
117
+ // send the initial snapshot once the content script has started up
118
+ window . addEventListener ( 'message' , ( { data : { action } } ) => {
119
+ if ( action === 'contentScriptStarted' ) sendSnapshot ( ) ;
120
+ } ) ;
156
121
} ;
157
- } ;
122
+ } ;
0 commit comments