Skip to content

Commit be65439

Browse files
committed
Added comment for index file & remove old test files
1 parent 6abab2f commit be65439

File tree

6 files changed

+40
-382
lines changed

6 files changed

+40
-382
lines changed

src/backend/__tests__/linkFiber.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('linkFiber', () => {
5252
};
5353
mode = {
5454
jumping: false,
55-
paused: false,
5655
};
5756
// Initialize Fiber Root:
5857
fiberRoot = { current: root };

src/backend/index.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
/* eslint-disable consistent-return */
3-
/* eslint-disable import/no-extraneous-dependencies */
4-
/* eslint-disable import/order */
5-
/* eslint-disable @typescript-eslint/no-unused-vars */
61
/**
72
* 'reactime' module has a single export
83
* @function linkFiber
94
*/
5+
// --------------------------START OF IMPORT------------------------------------
106
// regenerator runtime supports async functionality
117
import 'regenerator-runtime/runtime';
128
import linkFiberInitialization from './routers/linkFiber';
139
import timeJumpInitialization from './controllers/timeJump';
1410
import { Snapshot, Status, MsgData } from './types/backendTypes';
1511
import routes from './models/routes';
1612

17-
// * State snapshot object initialized here
13+
// -------------------------INITIALIZE SNAPSHOT & MODE--------------------------
14+
/** The snapshot of the current ReactFiber tree */
1815
const snapShot: Snapshot = {
1916
tree: null,
2017
};
2118

19+
/** Indicate if mode is jumping/not jumping or navigating during jumping */
2220
const mode: Status = {
2321
jumping: false,
24-
paused: false,
2522
};
2623

27-
// linkFiber is now assigned the default function exported from the file linkFiber.ts
28-
29-
console.log('Index ts Initiation');
24+
// ---------------------INITIALIZE LINKFIBER & TIMEJUMP-------------------------
25+
// linkFiber is now assigned the default ASYNC function exported from the file linkFiber.ts
3026
const linkFiber = linkFiberInitialization(snapShot, mode);
31-
// timeJump is now assigned the default function exported from the file timeJump.ts
27+
// timeJump is now assigned the default ASYNC function exported from the file timeJump.ts
3228
const timeJump = timeJumpInitialization(mode);
3329

34-
// * Event listener for time-travel actions
30+
/**
31+
* Invoke linkFiber to perform the follwoing:
32+
* 1. Check for ReactDev installation, valid target React App
33+
* 2. Obtain the intial ReactFiber Tree from target React App
34+
* 3. Send a snapshot of ReactFiber Tree to frontend/Chrome Extension
35+
*/
36+
linkFiber();
37+
38+
// -----------------SET UP EVENT LISTENER FOR TIME TRAVEL-----------------------
39+
/**
40+
* On the chrome extension, if user click left/right arrow or the play button (a.k.a time travel functionality), frontend will send a message jumpToSnap with payload of the cached snapShot tree at the current step
41+
* 1. Set jumping mode to true => dictate we are jumping => no new snapshot will be sent to frontend
42+
* 2. If navigate to a new route during jumping => cache timeJump in navigate.
43+
* Otherwise, invoke timeJump to update ReactFiber tree with cached data from the snapshot payload
44+
*/
3545
window.addEventListener('message', async ({ data: { action, payload } }: MsgData) => {
3646
switch (action) {
3747
case 'jumpToSnap':
38-
console.log('Index ts - jumpToSnap', { payload });
3948
// Set mode to jumping to prevent snapShot being sent to frontEnd
4049
// NOTE: mode.jumping is set to false inside the timeJump.ts
4150
mode.jumping = true;
4251
// Check if we are navigating to another route
4352
const navigating: boolean = routes.navigate(payload.route);
4453
// If need to navigate
4554
if (navigating) {
46-
// Pass timeJump function to mode.navigating => which will be invoked during onCommitFiberRoot:
55+
// Cache timeJump function in mode.navigating => which will be invoked during onCommitFiberRoot:
4756
mode.navigating = () => timeJump(payload);
4857
}
49-
// If not navitating, invoke timeJump immediately to update React Application FiberTree based on the snapshotTree
58+
// If not navitating, invoke timeJump immediately to update React Application FiberTree based on the snapshotTree payload
5059
else {
5160
await timeJump(payload); // * This sets state with given payload
5261
}
5362
break;
54-
5563
default:
5664
break;
5765
}
5866
});
59-
// connect to dev tools and new fiber,
60-
// invokes anonymous function from linkFiber.ts set to linkFiber on line 30
61-
linkFiber();

src/backend/linkFiberOLDtest.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/backend/timeJumpOLDtest.ts

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)