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
Copy file name to clipboardExpand all lines: src/backend/snapShot.ts
+29-31Lines changed: 29 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -5,21 +5,43 @@ import Tree from './tree';
5
5
importcomponentActionsRecordfrom'./masterState';
6
6
importroutesfrom'./routes';
7
7
import{createTree}from'./linkFiber';
8
+
9
+
// ---------------------------UPDATE TREE SNAP SHOT-----------------------------
10
+
/**
11
+
* - Create a new `snapShot` tree with the provided `fiberRoot`. This runs after every Fiber commit.
12
+
* - Middleware: Updates snapShot object with latest snapshot, using `sendSnapshot`
13
+
* @param snapShot The current snapshot
14
+
* @param mode The current mode (i.e. jumping, time-traveling, or paused)
15
+
* @param fiberRoot The `fiberRootNode`, which is the root node of a tree of React component. The `current` property of `fiberRoot` has data structure of a Tree, which can be used to traverse and obtain all child component data.
16
+
*/
17
+
// updating tree depending on current mode on the panel (pause, etc)
18
+
exportdefaultfunctionupdateSnapShotTree(
19
+
snapShot: Snapshot,
20
+
mode: Status,
21
+
fiberRoot: FiberRoot,
22
+
): void{
23
+
console.log('snapShot.ts - Update');
24
+
// this is the currently active root fiber(the mutable root of the tree)
25
+
const{ current }=fiberRoot;
26
+
componentActionsRecord.clear();
27
+
// creates snapshot that is a tree based on properties in fiberRoot object
28
+
snapShot.tree=createTree(current);
29
+
// sends the updated tree back
30
+
sendSnapshot(snapShot,mode);
31
+
}
32
+
33
+
// -------------------SEND TREE SNAP SHOT TO FRONT END--------------------------
8
34
/**
9
-
* @method sendSnapshot
35
+
* Gets a copy of the current snapShot.tree and posts a recordSnap message to the window
10
36
* @param snapShot The current snapshot
11
37
* @param mode The current mode (i.e. jumping, time-traveling, or paused)
12
-
* @returnNothing.
38
+
* @returnvoid
13
39
*
14
-
* Middleware: Gets a copy of the current snapShot.tree and posts a recordSnap message to the window
0 commit comments