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
* This is a recursive function that runs after every Fiber commit using the following logic:
61
+
* This is a recursive function that runs after Fiber commit, if user navigating to a new route during jumping. This function performs the following logic:
62
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
63
+
* 2. If the component is stateful, extract its update methods & push to the `componentActionRecord` array
66
64
* @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
65
+
* @param circularComponentTable A table content visited Fiber nodes
70
66
*/
71
67
// 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.
// Save component's state and setState() function to our record for future
123
-
// time-travel state changing. Add record index to snapshot so we can retrieve.
118
+
// Save component setState() method to our componentActionsRecord for use during timeJump
124
119
componentActionsRecord.saveNew(stateNode);
125
120
}
126
121
127
122
// --------OBTAIN STATE & DISPATCH METHODS FROM FUNCTIONAL COMPONENT--------
128
-
// Check if node is a hooks useState function
123
+
// Check if node is a stateful class component when user use setState.
124
+
// If user use useState to define/manage state, the state object will be stored in memoizedState.queue => grab the state object stored in the memoizedState.queue
129
125
if(
130
126
!nextJSDefaultComponent.has(componentName)&&
131
127
memoizedState&&
132
-
(tag===FunctionComponent||
133
-
// tag === ClassComponent || WE SHOULD NOT BE ABLE TO USE HOOK IN CLASS
134
-
tag===IndeterminateComponent||
135
-
tag===ContextProvider)//TODOD: Need to figure out why we need context provider
128
+
(tag===FunctionComponent||tag===IndeterminateComponent||tag===ContextProvider)//TODO: Need to figure out why we need context provider
// THIS FILE CONTAINS NECCESSARY FUNCTIONALITY FOR TIME-TRAVEL FEATURE
11
12
12
13
/**
13
-
* This file contains necessary functionality for time-travel feature.
14
-
*
15
-
* The target snapshot portrays some past state we want to travel to `jump` recursively and setState for any stateful component.
16
14
*
17
-
* @param mode - The current mode (i.e. jumping, time-traveling, or paused)
18
-
* @returns A function that takes a `inputTarget` snapshot and a boolean flag checking for `firstCall`, then invokes `initiateJump` on that target snapshot
15
+
* This is a closure function to keep track of mode (jumping or not jumping)
16
+
* @param mode - The current mode (i.e. jumping)
17
+
* @returns an async function that takes an `targetSnapshot`, then invokes `updateReactFiberTree` based on the state provided within that target snapshot
* This function is to reset jumping mode to false when user hover the mouse over the browser body
24
23
*/
25
-
lettarget;
26
-
/**
27
-
* This function is to aid the removeListener for 'popstate'
28
-
*/
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
-
constpopStateHandler=()=>{
31
-
console.log('POP STATE');
32
-
initiateJump(target,mode);
24
+
constresetJumpingMode=(): void=>{
25
+
console.log('timeJump - STOP JUMPING');
26
+
mode.jumping=false;
33
27
};
34
-
35
28
/**
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`
37
-
* @param inputTarget - The target snapshot to re-render. The payload from index.ts is assigned to inputTarget
38
-
* @param firstCall - A boolean flag checking for `firstCall`
29
+
* This function that takes a `targetSnapshot` then invokes `updateReactFiberTree` to update the React Application on the browser to match states provided by the `targetSnapshot`
30
+
* @param targetSnapshot - The target snapshot to re-render. The payload from index.ts is assigned to targetSnapshot
// Determine if user is navigating to another route
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.
Copy file name to clipboardExpand all lines: src/backend/routers/linkFiber.ts
+19-15Lines changed: 19 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -21,14 +21,13 @@ import {
21
21
FiberRoot,
22
22
}from'../types/backendTypes';
23
23
import{DevTools}from'../types/linkFiberTypes';
24
-
importupdateSnapShotTreefrom'./snapShot';
24
+
importupdateAndSendSnapShotTreefrom'./snapShot';
25
25
26
26
// throttle returns a function that can be called any number of times (possibly in quick succession) but will only invoke the callback at most once every x ms
27
27
// getHooksNames - helper function to grab the getters/setters from `elementType`
* @function throttledUpdateSnapshot - a function that will wait for at least MIN_TIME_BETWEEN_UPDATE ms, before updating the tree snapShot being displayed on the Chrome Extension.
// 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
0 commit comments