You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IndeterminateComponent,// Before we know whether it is function or class
10
+
HostRoot,// Root of a host tree. Could be nested inside another node.
11
+
HostPortal,// A subtree. Could be an entry point to a different renderer.
12
+
/**
13
+
* Host Component: a type of component that represents a native DOM element in the browser environment, such as div, span, input, h1 etc.
14
+
*/
15
+
HostComponent,// has stateNode of html elements
16
+
HostText,
17
+
Fragment,
18
+
Mode,
19
+
ContextConsumer,
20
+
ContextProvider,
21
+
ForwardRef,
22
+
Profiler,
23
+
SuspenseComponent,
24
+
MemoComponent,
25
+
SimpleMemoComponent,// A higher order component where if the component renders the same result given the same props, react skips rendering the component and uses last rendered result. Has memoizedProps/memoizedState but no stateNode
// ------------------------CREATE TREE TO SEND TO FRONT END-------------------
60
+
/**
61
+
* This is a recursive function that runs after every Fiber commit using the following logic:
62
+
* 1. Traverse from FiberRootNode
63
+
* 2. Create an instance of custom Tree class
64
+
* 3. Build a new state snapshot
65
+
* Every time a state change is made in the accompanying app, the extension creates a Tree “snapshot” of the current state, and adds it to the current “cache” of snapshots in the extension
66
+
* @param currentFiberNode A Fiber object
67
+
* @param tree A Tree object, default initialized to an instance given 'root' and 'root'
68
+
* @param fromSibling A boolean, default initialized to false
69
+
* @return An instance of a Tree object
70
+
*/
71
+
// TODO: Not sure why the ritd need to be outside of the createTree function. Want to put inside, but in case this need to be keep track for front end.
// with memoizedState we can grab the root type and construct an Abstract Syntax Tree from the hooks structure using Acorn in order to extract the hook getters and match them with their corresponding setters in an object
// ---------OBTAIN STATE & SET STATE METHODS FROM CLASS COMPONENT-----------
114
+
// Check if node is a stateful class component when user use setState.
115
+
// If user use setState to define/manage state, the state object will be stored in stateNode.state => grab the state object stored in the stateNode.state
116
+
// Example: for tic-tac-toe demo-app: Board is a stateful component that use setState to store state data.
// Save component's state and dispatch() function to our record for future time-travel state changing. Add record index to snapshot so we can retrieve.
@@ -155,6 +178,22 @@ export default function createTree(
155
178
context: {},
156
179
};
157
180
letisStatefulComponent=false;
181
+
/**
182
+
* The updated tree after adding the `componentData` obtained from `currentFiberNode`
183
+
*/
184
+
letnewNode: Tree;
185
+
186
+
// console.log('LinkFiber', {
187
+
// currentFiberNode,
188
+
// // tag,
189
+
// // elementType,
190
+
// componentName,
191
+
// // memoizedProps,
192
+
// // memoizedState,
193
+
// // stateNode,
194
+
// // dependencies,
195
+
// // _debugHookTypes,
196
+
// });
158
197
159
198
// ----------------APPEND PROP DATA FROM REACT DEV TOOL-----------------------
160
199
// check to see if the parent component has any state/props
@@ -182,6 +221,7 @@ export default function createTree(
182
221
// memoizedState
183
222
// Note: if user use ReactHook, memoizedState.memoizedState can be a falsy value such as null, false, ... => need to specify this data is not undefined
184
223
if(
224
+
!nextJSDefaultComponent.has(componentName)&&
185
225
(tag===FunctionComponent||tag===ClassComponent)&&
186
226
memoizedState?.memoizedState!==undefined
187
227
){
@@ -203,7 +243,7 @@ export default function createTree(
203
243
// if user uses useContext hook, context data will be stored in memoizedProps.value of the Context.Provider component => grab context object stored in memoizedprops
204
244
// Different from other provider, such as Routes, BrowswerRouter, ReactRedux, ..., Context.Provider does not have a displayName
205
245
// TODO: need to render this context provider when user use useContext hook.
@@ -222,7 +262,7 @@ export default function createTree(
222
262
// Check if node is a stateful class component when user use setState.
223
263
// If user use setState to define/manage state, the state object will be stored in stateNode.state => grab the state object stored in the stateNode.state
224
264
// Example: for tic-tac-toe demo-app: Board is a stateful component that use setState to store state data.
Copy file name to clipboardExpand all lines: src/backend/controllers/timeJump.ts
+21-15Lines changed: 21 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ const circularComponentTable = new Set();
15
15
* The target snapshot portrays some past state we want to travel to `jump` recursively and setState for any stateful component.
16
16
*
17
17
* @param mode - The current mode (i.e. jumping, time-traveling, or paused)
18
-
* @returns A function that takes a `target` snapshot and a boolean flag checking for `firstCall`, then invokes `jump` on that target snapshot
18
+
* @returns A function that takes a `inputTarget` snapshot and a boolean flag checking for `firstCall`, then invokes `initiateJump` on that target snapshot
19
19
*
20
20
*/
21
21
exportdefaultfunctiontimeJump(mode: Status){
@@ -28,43 +28,49 @@ export default function timeJump(mode: Status) {
28
28
*/
29
29
// IMPORTANT: DO NOT move this function into return function. This function is out here so that it will not be redefined any time the return function is invoked. This is importatnt for removeEventListener for popstate to work.
30
30
constpopStateHandler=()=>{
31
+
console.log('POP STATE');
31
32
initiateJump(target,mode);
32
33
};
33
34
34
35
/**
36
+
* This function that takes a `inputTarget` snapshot and a boolean flag checking for `firstCall`, then invokes `initiateJump` update browser to match states provided by the `inputTarget`
35
37
* @param inputTarget - The target snapshot to re-render. The payload from index.ts is assigned to inputTarget
36
38
* @param firstCall - A boolean flag checking for `firstCall`
// Determine if user is navigating to another route
46
48
// NOTE: Inside routes.navigate, if user is navigating, we will invoke history.go, which will go back/forth based on # of delta steps. This will trigger a popstate event. Since history.go is an async method, the event listener is the only way to invoke timeJump after we have arrived at the desirable route.
0 commit comments