Skip to content

Commit 33d1b94

Browse files
committed
add a few clarifying comments
1 parent e49d90f commit 33d1b94

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

src/backend/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ const mode: Mode = {
2626
paused: false,
2727
locked: false,
2828
};
29-
console.log("linkFiberStart in index.ts:" + linkFiberStart);
30-
const linkFiber = linkFiberStart(snapShot, mode);
31-
console.log('linkFiber in index.ts: ' + linkFiber);
29+
// console.log("linkFiberStart in index.ts:" + linkFiberStart);
30+
const linkFiber = linkFiberStart(snapShot, mode); // grabbing existing tree from react devtools
31+
// console.log('linkFiber in index.ts: ' + linkFiber);
3232
const timeJump = timeJumpStart(snapShot, mode);
3333

34+
/*
3435
function getRouteURL(node: SnapshotNode): string {
3536
if (node.name === 'Router') {
3637
return node.state.location.pathname;
@@ -42,10 +43,12 @@ function getRouteURL(node: SnapshotNode): string {
4243
}
4344
}
4445
}
45-
46+
*/
4647
// * Event listener for time-travel actions
4748
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
48-
console.log('linkFiber in index.ts: ' + linkFiber);
49+
// console.log('linkFiber in index.ts: ' + linkFiber);
50+
// console.log('action:', action);
51+
// console.log('payload:', payload);
4952
switch (action) {
5053
case 'jumpToSnap':
5154
timeJump(payload, true); // * This sets state with given payload

src/backend/linkFiber.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,25 @@ let rtid = null;
5252
let recoilDomNode = {};
5353

5454
// Simple check for whether our target app uses Recoil
55-
if (window[`$recoilDebugStates`]) {
55+
if (window['$recoilDebugStates']) {
56+
console.log('this is a recoil app!');
5657
isRecoil = true;
5758
}
5859

60+
// function getRecoilState(): any {
61+
// const RecoilSnapshotsLength = window[`$recoilDebugStates`].length;
62+
// const lastRecoilSnapshot =
63+
// window[`$recoilDebugStates`][RecoilSnapshotsLength - 1];
64+
// const nodeToNodeSubs = lastRecoilSnapshot.nodeToNodeSubscriptions;
65+
// const nodeToNodeSubsKeys = lastRecoilSnapshot.nodeToNodeSubscriptions.keys();
66+
// nodeToNodeSubsKeys.forEach((node) => {
67+
// nodeToNodeSubs
68+
// .get(node)
69+
// .forEach((nodeSubs) =>
70+
// allAtomsRelationship.push([node, nodeSubs, 'atoms and selectors'])
71+
// );
72+
// });
73+
// }
5974

6075
/**
6176
* @method sendSnapshot
@@ -75,6 +90,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
7590
const payload = snap.tree.cleanTreeCopy();
7691
// if it's Recoil - run different actions?
7792
if (isRecoil) {
93+
// getRecoilState()
7894
payload.atomsComponents = atomsComponents;
7995
payload.atomSelectors = atomsSelectors;
8096
payload.recoilDomNode = recoilDomNode
@@ -101,8 +117,8 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
101117
function updateSnapShotTree(snap: Snapshot, mode: Mode): void {
102118
// this is the currently active root fiber(the mutable root of the tree)
103119
let fiberRootCurrent = fiberRoot.current;
104-
console.log("fiber root props: ", Object.entries(fiberRootCurrent));
105-
console.log("fiberroot sibling:", fiberRootCurrent.sibling, "fiberroot stateNode:", fiberRootCurrent.stateNode, "fiberroot child:", fiberRootCurrent.child, "fiberroot memoizedState:", fiberRootCurrent.memoizedState, "fiberroot memoizedProps:", fiberRootCurrent.memoizedProps, "fiberRootCurrent.elementType:",fiberRootCurrent.elementType, "fiberRootCurrent.tag: ", fiberRootCurrent.tag, "fiberRootCurrent.actualDuration: ", fiberRootCurrent.actualDuration, "fiberRootCurrent.actualStartTime: ", fiberRootCurrent.actualStartTime, "fiberRootCurrent.selfBaseDuration: ", fiberRootCurrent.selfBaseDuration, "fiberRootCurrent.treeBaseDuration:", fiberRootCurrent.treeBaseDuration);
120+
// console.log("fiber root props: ", Object.entries(fiberRootCurrent));
121+
// console.log("fiberroot sibling:", fiberRootCurrent.sibling, "fiberroot stateNode:", fiberRootCurrent.stateNode, "fiberroot child:", fiberRootCurrent.child, "fiberroot memoizedState:", fiberRootCurrent.memoizedState, "fiberroot memoizedProps:", fiberRootCurrent.memoizedProps, "fiberRootCurrent.elementType:",fiberRootCurrent.elementType, "fiberRootCurrent.tag: ", fiberRootCurrent.tag, "fiberRootCurrent.actualDuration: ", fiberRootCurrent.actualDuration, "fiberRootCurrent.actualStartTime: ", fiberRootCurrent.actualStartTime, "fiberRootCurrent.selfBaseDuration: ", fiberRootCurrent.selfBaseDuration, "fiberRootCurrent.treeBaseDuration:", fiberRootCurrent.treeBaseDuration);
106122

107123
if (fiberRoot) {
108124
const { current } = fiberRoot;
@@ -486,14 +502,14 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
486502
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
487503
const reactInstance = devTools ? devTools.renderers.get(1) : null;
488504
fiberRoot = devTools.getFiberRoots(1).values().next().value;
489-
console.log("fiberRoot in export default: " + Object.entries(fiberRoot));
505+
// console.log("fiberRoot in export default: " + Object.entries(fiberRoot));
490506
const throttledUpdateSnapshot = throttle(() => updateSnapShotTree(snap, mode), 70);
491507
document.addEventListener('visibilitychange', onVisibilityChange);
492508

493509
if (reactInstance && reactInstance.version) {
494510
devTools.onCommitFiberRoot = (function (original) {
495511
return function (...args) {
496-
console.log("args in onCommitFiberRoot: ", args)
512+
// console.log("args in onCommitFiberRoot: ", args)
497513
// eslint-disable-next-line prefer-destructuring
498514
fiberRoot = args[1];
499515
if (doWork) {

src/backend/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Tree {
6464
}
6565

6666
addChild(state: string | {}, name: string, componentData: {}, rtid: any, recoilDomNode:any): Tree {
67-
console.log("arguments in addChild: "+ arguments.length)
67+
// console.log("arguments in addChild: "+ arguments.length)
6868
const newChild: Tree = new Tree(state, name, componentData, rtid, recoilDomNode);
6969
newChild.parent = this;
7070
this.children.push(newChild);

src/extension/contentScript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ window.addEventListener('message', msg => { // runs automatically every second
2121
});
2222

2323
// listening for messages from the UI
24-
chrome.runtime.onMessage.addListener(request => { // seems to never fire
24+
chrome.runtime.onMessage.addListener(request => {
2525
// send the message to npm package
2626
const { action }: { action: string } = request;
2727
switch (action) {

0 commit comments

Comments
 (0)