Skip to content

Commit 8e4c4ed

Browse files
committed
map updates
1 parent c55e5a1 commit 8e4c4ed

File tree

4 files changed

+56
-29
lines changed

4 files changed

+56
-29
lines changed

src/app/components/PerfView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const PerfView = (props: PerfViewProps) => {
4040
// snapshots.forEach((snapshot) => snapshot.children[0].children.shift());
4141
// console.log('SNAPSHOTS -------------------------->', snapshots);
4242
// Figure out which snapshot index to use
43+
4344
let indexToDisplay: number | null = null;
4445
if (viewIndex < 0) indexToDisplay = snapshots.length - 1;
4546
else indexToDisplay = viewIndex;

src/backend/linkFiber.ts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
9595
state: memoizedState.memoizedState,
9696
});
9797
//console.log('MEMOIZED PROPS ------>', memoizedProps);
98-
console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
99-
console.log('HOOK STATE ------->', hooksStates);
98+
// console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
99+
// console.log('HOOK STATE ------->', hooksStates);
100100
}
101101
memoizedState =
102102
memoizedState.next !== memoizedState ? memoizedState.next : null;
@@ -170,7 +170,7 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
170170
// });
171171
atomArray.push(memoizedProps);
172172

173-
console.log('1st ATOM ARRAY', atomArray);
173+
//console.log('1st ATOM ARRAY', atomArray);
174174

175175
function traverseRecoilHooks(memoizedState: any): HookStates {
176176
const hooksStates: HookStates = [];
@@ -187,9 +187,10 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
187187
state: memoizedProps,
188188
});
189189
}
190-
console.log('MEMOIZED PROPS ------>', memoizedProps);
191-
console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
192-
console.log('HOOK STATE ------->', hooksStates);
190+
191+
// console.log('MEMOIZED PROPS ------>', memoizedProps);
192+
// console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
193+
// console.log('HOOK STATE ------->', hooksStates);
193194
}
194195
memoizedState =
195196
memoizedState.next !== memoizedState ? memoizedState.next : null;
@@ -210,22 +211,32 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
210211
// which includes the dispatch() function we use to change their state.
211212

212213
const hooksStates = traverseRecoilHooks(memoizedState);
213-
console.log("HOOK STATE BEFORE LOOPING", hooksStates)
214+
// console.log('HOOK STATE BEFORE LOOPING', hooksStates);
214215
const hooksNames = getHooksNames(elementType.toString());
215216
hooksStates.forEach((state, i) => {
216-
console.log('STATE IN SAVE NEW LOOP', state);
217+
// console.log('STATE IN SAVE NEW LOOP', state);
217218
hooksIndex = componentActionsRecord.saveNew(
218219
state.state,
219220
state.component
220221
);
221222
componentData.hooksIndex = hooksIndex;
222223

224+
// if (newState && newState.hooksState) {
225+
// newState.hooksState.push({ [hooksNames[i]]: state.state });
226+
// } else if (newState) {
227+
// newState.hooksState = [{ [hooksNames[i]]: state.state }];
228+
// } else {
229+
// newState = { hooksState: [] };
230+
// newState.hooksState.push({ [hooksNames[i]]: state.state });
231+
// }
232+
233+
//improves tree visualization but breaks jump
223234
if (newState && newState.hooksState) {
224235
newState.push(state.state);
225236
} else if (newState) {
226-
newState = [ state.state ];
237+
newState = [state.state];
227238
} else {
228-
newState.push(state.state );
239+
newState.push(state.state);
229240
}
230241
componentFound = true;
231242
});
@@ -234,9 +245,13 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
234245

235246
// Check if node is a hooks useState function
236247
//REGULAR REACT HOOKS
237-
if (memoizedState && (tag === 0 || tag === 1 || tag === 2 || tag === 10) && isRecoil === false) {
248+
if (
249+
memoizedState &&
250+
(tag === 0 || tag === 1 || tag === 2 || tag === 10) &&
251+
isRecoil === false
252+
) {
238253
if (memoizedState.queue) {
239-
console.log('Regular Hooks');
254+
//console.log('Regular Hooks');
240255
// Hooks states are stored as a linked list using memoizedState.next,
241256
// so we must traverse through the list and get the states.
242257
// We then store them along with the corresponding memoizedState.queue,
@@ -321,9 +336,9 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
321336
snap.tree = createTree(current);
322337
}
323338

324-
console.log('Fiber', fiberRoot.current);
339+
// console.log('Fiber', fiberRoot.current);
325340

326-
console.log('SNAP.TREE->', snap.tree);
341+
// console.log('SNAP.TREE->', snap.tree);
327342

328343
sendSnapshot();
329344
}

src/backend/masterState.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import 'core-js';
66

77
const componentActionsRecord = {};
88
let index = 0;
9-
109
// module.exports = {
1110
export default {
1211
saveNew: (state, component) => {
12+
//console.log("COMPONENET ACTION RECORDS",componentActionsRecord)
13+
1314
componentActionsRecord[index] = { state, component };
1415
index++;
1516
return index - 1;

src/backend/timeJump.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,44 @@ export default (origin, mode) => {
3333
if (!target) return;
3434

3535
if (target.state === 'stateless') {
36-
target.children.forEach(child => jump(child));
36+
target.children.forEach((child) => jump(child));
3737
return;
3838
}
39-
const component = componentActionsRecord.getComponentByIndex(target.componentData.index);
39+
const component = componentActionsRecord.getComponentByIndex(
40+
target.componentData.index
41+
);
4042
if (component && component.setState) {
41-
component.setState(prevState => {
42-
Object.keys(prevState).forEach(key => {
43-
if (target.state[key] === undefined) {
44-
target.state[key] = undefined;
45-
}
46-
});
47-
return target.state;
48-
// Iterate through new children after state has been set
49-
}, () => target.children.forEach(child => jump(child)));
43+
component.setState(
44+
(prevState) => {
45+
Object.keys(prevState).forEach((key) => {
46+
if (target.state[key] === undefined) {
47+
target.state[key] = undefined;
48+
}
49+
});
50+
return target.state;
51+
// Iterate through new children after state has been set
52+
},
53+
() => target.children.forEach((child) => jump(child))
54+
);
5055
}
5156

5257
// Check for hooks state and set it with dispatch()
5358
if (target.state && target.state.hooksState) {
54-
target.state.hooksState.forEach(hook => {
55-
const hooksComponent = componentActionsRecord.getComponentByIndex(target.componentData.hooksIndex);
59+
target.state.hooksState.forEach((hook) => {
60+
const hooksComponent = componentActionsRecord.getComponentByIndex(
61+
target.componentData.hooksIndex
62+
);
5663
const hookState = Object.values(hook);
64+
console.log('target', target);
5765
if (hooksComponent && hooksComponent.dispatch) {
66+
console.log('HOOKS COMPONENT', hooksComponent);
67+
console.log('HOOKS STATE of Zero', hookState[0]);
5868
hooksComponent.dispatch(hookState[0]);
5969
}
6070
});
6171
}
6272

63-
target.children.forEach(child => {
73+
target.children.forEach((child) => {
6474
if (!circularComponentTable.has(child)) {
6575
circularComponentTable.add(child);
6676
jump(child);

0 commit comments

Comments
 (0)