@@ -48,45 +48,30 @@ function commitAllHostEffectsReplacement() {
4848 }
4949 }
5050
51- // The following switch statement is only concerned about placement,
52- // updates, and deletions. To avoid needing to add a case for every
53- // possible bitmap value, we remove the secondary effects from the
54- // effect tag and switch on that value.
5551 let primaryEffectTag = effectTag & ( Placement | Update | Deletion ) ;
5652 switch ( primaryEffectTag ) {
5753 case Placement :
5854 {
59- // editbyme
6055 timeTravelTracker . push ( {
6156 primaryEffectTag : 'PLACEMENT' ,
6257 effect : _ . cloneDeep ( nextEffect ) ,
6358 } ) ;
6459
6560 commitPlacement ( nextEffect ) ;
66- // Clear the "placement" from effect tag so that we know that this is inserted, before
67- // any life-cycles like componentDidMount gets called.
68- // TODO: findDOMNode doesn't rely on this any more but isMounted
69- // does and isMounted is deprecated anyway so we should be able
70- // to kill this.
61+
7162 nextEffect . effectTag &= ~ Placement ;
7263 break ;
7364 }
7465 case PlacementAndUpdate :
7566 {
76- // Placement
7767 commitPlacement ( nextEffect ) ;
78- // Clear the "placement" from effect tag so that we know that this is inserted, before
79- // any life-cycles like componentDidMount gets called.
8068 nextEffect . effectTag &= ~ Placement ;
81-
82- // Update
8369 let _current = nextEffect . alternate ;
8470 commitWork ( _current , nextEffect ) ;
8571 break ;
8672 }
8773 case Update :
8874 {
89- // editbyme
9075 timeTravelTracker . push ( {
9176 primaryEffectTag : 'UPDATE' ,
9277 effect : _ . cloneDeep ( nextEffect ) ,
@@ -99,7 +84,6 @@ function commitAllHostEffectsReplacement() {
9984 }
10085 case Deletion :
10186 {
102- // editbyme
10387 timeTravelTracker . push ( {
10488 primaryEffectTag : 'DELETION' ,
10589 effect : _ . cloneDeep ( nextEffect ) ,
@@ -119,13 +103,14 @@ function commitAllHostEffectsReplacement() {
119103// regex method signatures
120104const uRsig = new RegExp ( / \b ( u s e R e d u c e r ) \b \( r e d u c e r , i n i t i a l A r g , i n i t \) / ) ;
121105const cAHEsig = new RegExp ( / \b ( f u n c t i o n ) \b \s \b ( c o m m i t A l l H o s t E f f e c t s ) \b \( \) / , 'g' ) ;
106+
122107// get replacer method bodies
123- const injectableUseReducer = esprima . parseScript ( useReducerReplacement . toString ( ) ) ;
124- const injectableUseReducerString = escodegen . generate ( injectableUseReducer . body [ 0 ] . body ) ;
108+ let injectableUseReducer = esprima . parseScript ( useReducerReplacement . toString ( ) ) ;
109+ let injectableUseReducerString = escodegen . generate ( injectableUseReducer . body [ 0 ] . body ) ;
110+
111+ let injectableCommitAllHostEffects = esprima . parseScript ( commitAllHostEffectsReplacement . toString ( ) ) ;
112+ let injectableCommitAllHostEffectsString = escodegen . generate ( injectableCommitAllHostEffects . body [ 0 ] . body ) ;
125113
126- const injectableCommitAllHostEffects = esprima . parseScript ( commitAllHostEffectsReplacement . toString ( ) ) ;
127- // const injectableCommitAllHostEffects = injectableCommitAllHostEffects.body[0].body;
128- const injectableCommitAllHostEffectsString = escodegen . generate ( injectableCommitAllHostEffects . body [ 0 ] . body ) ;
129114// traverse ast to find method and replace body with our node's body
130115function traverseTree ( replacementNode , functionName , ast ) {
131116 console . log ( 'traverse called' ) ;
@@ -169,7 +154,7 @@ const parseAndGenerate = (codeString) => {
169154 try {
170155 ast = esprima . parseModule ( codeString ) ;
171156 } catch ( error ) {
172- // exprima throws parsing error webpack devtool setting generates code
157+ // esprima throws parsing error webpack devtool setting generates code
173158 console . log ( 'unable to use esprima parser' ) ;
174159 codeString = stringParser ( codeString , injectableUseReducerString , uRsig ) ;
175160 codeString = stringParser ( codeString , injectableCommitAllHostEffectsString , cAHEsig ) ;
0 commit comments