Skip to content

Commit c4a2b3c

Browse files
committed
pull master
2 parents 7cd7eaa + f5cc313 commit c4a2b3c

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

src/app/containers/MainContainer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function MainContainer(): any {
8484
// if viewIndex is -1, then use the sliderIndex instead
8585
const snapshotView = viewIndex === -1 ? snapshots[sliderIndex] : snapshots[viewIndex];
8686
// gabi :: cleannign hierarchy and snapshotView from stateless data
87-
const statelessCleanning = (
87+
const statelessCleaning = (
8888
obj:{name?:string; componentData?:object; state?:string|any;stateSnaphot?:object; children?:any[];}) => {
8989
const newObj = { ...obj };
9090
if (newObj.name === 'nameless') {
@@ -97,23 +97,23 @@ function MainContainer(): any {
9797
delete newObj.state;
9898
}
9999
if (newObj.stateSnaphot) {
100-
newObj.stateSnaphot = statelessCleanning(obj.stateSnaphot);
100+
newObj.stateSnaphot = statelessCleaning(obj.stateSnaphot);
101101
}
102102
if (newObj.children) {
103103
newObj.children = [];
104104
if (obj.children.length > 0) {
105105
obj.children.forEach((element:{state?:object|string, children?:[]}) => {
106106
if (element.state !== 'stateless' || element.children.length > 0) {
107-
const clean = statelessCleanning(element);
107+
const clean = statelessCleaning(element);
108108
newObj.children.push(clean);
109109
}
110110
});
111111
}
112112
}
113113
return newObj;
114114
};
115-
const snapshotDisplay = statelessCleanning(snapshotView);
116-
const hierarchyDisplay = statelessCleanning(hierarchy);
115+
const snapshotDisplay = statelessCleaning(snapshotView);
116+
const hierarchyDisplay = statelessCleaning(hierarchy);
117117
return (
118118
<div className="main-container">
119119
<HeadContainer />

src/backend/linkFiber.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import 'core-js';
3838
// const componentActionsRecord = require('./masterState');
3939

4040
import {
41+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4142
Snapshot, Mode, ComponentData, HookStates, Fiber
4243
} from './types/backendTypes';
4344
import Tree from './tree';
@@ -114,7 +115,14 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
114115
} = currentFiber;
115116

116117
let newState: any | {hooksState?: any[]} = {};
117-
let componentData: ComponentData = {};
118+
let componentData: {
119+
hooksState?: any[],
120+
hooksIndex?: number,
121+
index?: number,
122+
actualDuration?: number,
123+
actualStartTime?: number,
124+
selfBaseDuration?: number,
125+
treeBaseDuration?: number} = {};
118126
let componentFound = false;
119127

120128
// Check if node is a stateful setState component
@@ -138,16 +146,14 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
138146
const hooksNames = getHooksNames(elementType.toString());
139147
hooksStates.forEach((state, i) => {
140148
hooksIndex = componentActionsRecord.saveNew(state.state, state.component);
149+
componentData.hooksIndex = hooksIndex;
141150
if (newState && newState.hooksState) {
142-
newState.hooksState.push({ [hooksNames[i]]: state.state, componentData: { index: hooksIndex } });
143-
// newState.hooksState.push([{ [hooksNames[i]]: state.state }, hooksIndex]);
151+
newState.hooksState.push({ [hooksNames[i]]: state.state });
144152
} else if (newState) {
145-
newState.hooksState = [{ [hooksNames[i]]: state.state, componentData: { index: hooksIndex } }];
146-
// newState.hooksState = [{ [hooksNames[i]]: state.state }, hooksIndex];
153+
newState.hooksState = [{ [hooksNames[i]]: state.state }];
147154
} else {
148-
// newState = { hooksState: [{ [hooksNames[i]]: state.state }, hooksIndex] };
149155
newState = { hooksState: [] };
150-
newState.hooksState.push({ [hooksNames[i]]: state.state, componentData: { index: hooksIndex } });
156+
newState.hooksState.push({ [hooksNames[i]]: state.state });
151157
}
152158
componentFound = true;
153159
});
@@ -232,7 +238,6 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
232238
const reactInstance = devTools ? devTools.renderers.get(1) : null;
233239
fiberRoot = devTools.getFiberRoots(1).values().next().value;
234240
const throttledUpdateSnapshot = throttle(updateSnapShotTree, 140);
235-
236241
document.addEventListener('visibilitychange', onVisibilityChange);
237242
if (reactInstance && reactInstance.version) {
238243
devTools.onCommitFiberRoot = (function (original) {

src/backend/timeJump.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,13 @@ export default (origin, mode) => {
4545

4646
// Check for hooks state and set it with dispatch()
4747
if (target.state && target.state.hooksState) {
48-
console.log('SNAPSHOT TARGET: ', target);
49-
// const hooksComponent = componentActionsRecord.getComponentByIndex(target.state.hooksState[1]);
5048
target.state.hooksState.forEach(hook => {
51-
console.log('HOOK IS:', JSON.stringify(hook));
52-
if (!hook.componentData) return;
53-
const hooksComponent = componentActionsRecord.getComponentByIndex(hook.componentData.index);
54-
// const [hooksState] = [target.state.hooksState];
55-
delete hook.componentData;
56-
const hooksState = Object.values(hook);
49+
const hooksComponent = componentActionsRecord.getComponentByIndex(target.componentData.hooksIndex);
50+
const hookState = Object.values(hook);
5751
if (hooksComponent && hooksComponent.dispatch) {
58-
// hooksComponent.dispatch(Object.values(target.state.hooksState[0])[0]);
59-
hooksComponent.dispatch(hooksState);
52+
hooksComponent.dispatch(hookState[0]);
6053
}
6154
});
62-
//target.children.forEach(child => jump(child));
63-
6455
}
6556

6657
target.children.forEach(child => {

src/backend/types/backendTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface MsgData {
2828

2929
export interface ComponentData {
3030
index?: number;
31+
hooksIndex?: number;
3132
actualDuration?: number;
3233
actualStartTime?: number;
3334
selfBaseDuration?: number;

0 commit comments

Comments
 (0)