Skip to content

Commit 286a6e3

Browse files
committed
Added AtomsComponents and AtomsSelectors as typescript properties in StateRouteProps interface
1 parent cb087db commit 286a6e3

File tree

5 files changed

+65
-47
lines changed

5 files changed

+65
-47
lines changed

src/app/components/StateRoute.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ interface StateRouteProps {
3131
state?: string | object;
3232
stateSnaphot?: object;
3333
children?: any[];
34-
AtomsRelationship?: any[];
34+
AtomsComponents?: any;
35+
AtomsSelectors?: any;
36+
3537
};
3638
hierarchy: any;
3739
snapshots: [];
@@ -41,7 +43,7 @@ interface StateRouteProps {
4143
const StateRoute = (props: StateRouteProps) => {
4244
const { snapshot, hierarchy, snapshots, viewIndex } = props;
4345

44-
const isRecoil = snapshot.AtomsRelationship ? true : false;
46+
const isRecoil = snapshot.AtomsComponents ? true : false;
4547
const [noRenderData, setNoRenderData] = useState(false);
4648

4749
// component map zoom state
@@ -79,7 +81,7 @@ const StateRoute = (props: StateRouteProps) => {
7981
};
8082

8183
const renderAtomsRelationship = () => (
82-
<AtomsRelationship atomsRel={snapshot.AtomsRelationship} />
84+
<AtomsRelationship atomsRel={snapshot.AtomsComponents} />
8385
);
8486

8587
// the hierarchy gets set on the first click in the page

src/app/containers/StateContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const StateContainer = (props:StateContainerProps): unknown => {
2828
snapshot, hierarchy, snapshots, viewIndex,
2929
} = props;
3030
const [Text, setText] = useState('State');
31+
32+
console.log(props)
33+
3134
return (
3235
<Router>
3336
<div className="state-container">

src/backend/linkFiber.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ let initialstart = false;
4040
if (window[`$recoilDebugStates`]) {
4141
isRecoil = true;
4242
}
43-
function getRecoilState(): any {
44-
const RecoilSnapshotsLength = window[`$recoilDebugStates`].length;
45-
const lastRecoilSnapshot =
46-
window[`$recoilDebugStates`][RecoilSnapshotsLength - 1];
47-
const nodeToNodeSubs = lastRecoilSnapshot.nodeToNodeSubscriptions;
48-
const nodeToNodeSubsKeys = lastRecoilSnapshot.nodeToNodeSubscriptions.keys();
49-
nodeToNodeSubsKeys.forEach((node) => {
50-
nodeToNodeSubs
51-
.get(node)
52-
.forEach((nodeSubs) =>
53-
allAtomsRelationship.push([node, nodeSubs, 'atoms and selectors'])
54-
);
55-
});
56-
}
43+
44+
// function getRecoilState(): any {
45+
// const RecoilSnapshotsLength = window[`$recoilDebugStates`].length;
46+
// const lastRecoilSnapshot =
47+
// window[`$recoilDebugStates`][RecoilSnapshotsLength - 1];
48+
// const nodeToNodeSubs = lastRecoilSnapshot.nodeToNodeSubscriptions;
49+
// const nodeToNodeSubsKeys = lastRecoilSnapshot.nodeToNodeSubscriptions.keys();
50+
// nodeToNodeSubsKeys.forEach((node) => {
51+
// nodeToNodeSubs
52+
// .get(node)
53+
// .forEach((nodeSubs) =>
54+
// allAtomsRelationship.push([node, nodeSubs, 'atoms and selectors'])
55+
// );
56+
// });
57+
// }
5758

5859
/**
5960
* @method sendSnapshot
@@ -72,11 +73,14 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
7273
}
7374

7475
const payload = snap.tree.cleanTreeCopy();
76+
7577
if (isRecoil) {
76-
getRecoilState();
77-
payload.AtomsRelationship = allAtomsRelationship;
78+
// getRecoilState();
79+
payload.AtomsComponents = atomsComponents;
80+
payload.AtomsSelectors = atomsSelectors;
7881
}
7982

83+
8084
window.postMessage(
8185
{
8286
action: 'recordSnap',

src/backend/tree.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class Tree {
4545

4646
parent: Tree
4747

48-
AtomsRelationship: any;
48+
AtomsComponents: any;
49+
50+
AtomsSelectors: any;
4951

5052
constructor(state: string | {}, name = 'nameless', componentData: {} = {}) {
5153
this.state = state === 'root' ? 'root' : serializeState(state);

src/extension/background.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ function changeCurrLocation(tabObj, rootNode, index, name) {
9191
}
9292

9393
if (rootNode.children) {
94-
rootNode.children.forEach(child => {
94+
rootNode.children.forEach((child) => {
9595
changeCurrLocation(tabObj, child, index, name);
9696
});
9797
}
9898
}
9999

100100
// establishing connection with devtools
101-
chrome.runtime.onConnect.addListener(port => {
101+
chrome.runtime.onConnect.addListener((port) => {
102102
// port is one end of the connection - an object
103103

104104
// push every port connected to the ports array
@@ -113,7 +113,7 @@ chrome.runtime.onConnect.addListener(port => {
113113
}
114114

115115
// every time devtool is closed, remove the port from portsArr
116-
port.onDisconnect.addListener(e => {
116+
port.onDisconnect.addListener((e) => {
117117
for (let i = 0; i < portsArr.length; i += 1) {
118118
if (portsArr[i] === e) {
119119
portsArr.splice(i, 1);
@@ -123,7 +123,7 @@ chrome.runtime.onConnect.addListener(port => {
123123
});
124124

125125
// receive snapshot from devtools and send it to contentScript -
126-
port.onMessage.addListener(msg => {
126+
port.onMessage.addListener((msg) => {
127127
// msg is action denoting a time jump in devtools
128128

129129
// ---------------------------------------------------------------
@@ -146,13 +146,20 @@ chrome.runtime.onConnect.addListener(port => {
146146
// records snapshot of page initial state
147147
tabsObj[tabId].initialSnapshot.push(tabsObj[tabId].snapshots[0]);
148148
// reset snapshots to page last state recorded
149-
tabsObj[tabId].snapshots = [tabsObj[tabId].snapshots[tabsObj[tabId].snapshots.length - 1]];
149+
tabsObj[tabId].snapshots = [
150+
tabsObj[tabId].snapshots[tabsObj[tabId].snapshots.length - 1],
151+
];
150152
// records hierarchy of page initial state
151-
tabsObj[tabId].initialHierarchy = { ...tabsObj[tabId].hierarchy, children: [] };
153+
tabsObj[tabId].initialHierarchy = {
154+
...tabsObj[tabId].hierarchy,
155+
children: [],
156+
};
152157
// resets hierarchy
153158
tabsObj[tabId].hierarchy.children = [];
154159
// resets hierarchy to page last state recorded
155-
tabsObj[tabId].hierarchy.stateSnapshot = { ...tabsObj[tabId].snapshots[0] };
160+
tabsObj[tabId].hierarchy.stateSnapshot = {
161+
...tabsObj[tabId].snapshots[0],
162+
};
156163
// resets currLocation to page last state recorded
157164
tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy;
158165
// resets index
@@ -192,10 +199,10 @@ chrome.runtime.onMessage.addListener((request, sender) => {
192199

193200
// Filter out tabs that don't have reactime
194201
if (
195-
action === 'tabReload'
196-
|| action === 'recordSnap'
197-
|| action === 'jumpToSnap'
198-
|| action === 'injectScript'
202+
action === 'tabReload' ||
203+
action === 'recordSnap' ||
204+
action === 'jumpToSnap' ||
205+
action === 'injectScript'
199206
) {
200207
isReactTimeTravel = true;
201208
} else {
@@ -263,11 +270,11 @@ chrome.runtime.onMessage.addListener((request, sender) => {
263270
tabsObj[tabId].currBranch = 0;
264271

265272
// send a message to devtools
266-
portsArr.forEach(bg =>
273+
portsArr.forEach((bg) =>
267274
bg.postMessage({
268275
action: 'initialConnectSnapshots',
269276
payload: tabsObj,
270-
}),
277+
})
271278
);
272279
}
273280
reloaded[tabId] = true;
@@ -285,14 +292,14 @@ chrome.runtime.onMessage.addListener((request, sender) => {
285292

286293
sendToHierarchy(
287294
tabsObj[tabId],
288-
new Node(request.payload, tabsObj[tabId]),
295+
new Node(request.payload, tabsObj[tabId])
289296
);
290297
if (portsArr.length > 0) {
291-
portsArr.forEach(bg =>
298+
portsArr.forEach((bg) =>
292299
bg.postMessage({
293300
action: 'initialConnectSnapshots',
294301
payload: tabsObj,
295-
}),
302+
})
296303
);
297304
}
298305
break;
@@ -306,17 +313,17 @@ chrome.runtime.onMessage.addListener((request, sender) => {
306313
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
307314
sendToHierarchy(
308315
tabsObj[tabId],
309-
new Node(request.payload, tabsObj[tabId]),
316+
new Node(request.payload, tabsObj[tabId])
310317
);
311318
}
312319
// send message to devtools
313320
if (portsArr.length > 0) {
314-
portsArr.forEach(bg =>
321+
portsArr.forEach((bg) =>
315322
bg.postMessage({
316323
action: 'sendSnapshots',
317324
payload: tabsObj,
318325
sourceTab,
319-
}),
326+
})
320327
);
321328
}
322329
break;
@@ -328,14 +335,14 @@ chrome.runtime.onMessage.addListener((request, sender) => {
328335
});
329336

330337
// when tab is closed, remove the tabid from the tabsObj
331-
chrome.tabs.onRemoved.addListener(tabId => {
338+
chrome.tabs.onRemoved.addListener((tabId) => {
332339
// tell devtools which tab to delete
333340
if (portsArr.length > 0) {
334-
portsArr.forEach(bg =>
341+
portsArr.forEach((bg) =>
335342
bg.postMessage({
336343
action: 'deleteTab',
337344
payload: tabId,
338-
}),
345+
})
339346
);
340347
}
341348

@@ -352,11 +359,11 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
352359
if (changeInfo.title && changeInfo.title !== tabsObj[tabId].title) {
353360
// tell devtools which tab to delete
354361
if (portsArr.length > 0) {
355-
portsArr.forEach(bg =>
362+
portsArr.forEach((bg) =>
356363
bg.postMessage({
357364
action: 'deleteTab',
358365
payload: tabId,
359-
}),
366+
})
360367
);
361368
}
362369

@@ -372,14 +379,14 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
372379
});
373380

374381
// when tab is view change, put the tabid as the current tab
375-
chrome.tabs.onActivated.addListener(info => {
382+
chrome.tabs.onActivated.addListener((info) => {
376383
// tell devtools which tab to be the current
377384
if (portsArr.length > 0) {
378-
portsArr.forEach(bg =>
385+
portsArr.forEach((bg) =>
379386
bg.postMessage({
380387
action: 'changeTab',
381388
payload: info,
382-
}),
389+
})
383390
);
384391
}
385392
});

0 commit comments

Comments
 (0)