Skip to content

Commit d52a6fc

Browse files
committed
minor cleanups
1 parent efcb3ee commit d52a6fc

File tree

4 files changed

+5
-240
lines changed

4 files changed

+5
-240
lines changed

dev-reactime/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
*/
55
import 'core-js';
66
import 'regenerator-runtime/runtime';
7-
import { exist } from 'acorn-jsx/xhtml';
87

98
// * State snapshot object initialized here
109
const snapShot = {
11-
tree: null,
12-
unfilteredTree: null
10+
tree: null,
11+
unfilteredTree: null
1312
};
1413

15-
1614
const mode = {
1715
jumping: false,
1816
paused: false,

dev-reactime/linkFiber.js

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ module.exports = (snap, mode) => {
253253
fiberRoot = _internalRoot || _reactRootContainer;
254254
}
255255
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
256-
console.log('this is devTools', devTools)
257256
const reactInstance = devTools ? devTools.renderers.get(1) : null;
258257

259258
if (reactInstance && reactInstance.version) {
@@ -277,82 +276,3 @@ module.exports = (snap, mode) => {
277276
});
278277
};
279278
};
280-
281-
282-
283-
284-
// function createUnfilteredTree(currentFiber, tree = new Tree('root')) {
285-
// // Base case: child or sibling pointed to null
286-
// if (!currentFiber) return tree;
287-
288-
// const { sibling, stateNode, child, memoizedState, elementType,
289-
// tag, actualDuration, actualStartTime, selfBaseDuration, treeBaseDuration,
290-
// } = currentFiber;
291-
292-
// const extraProps = {
293-
// tag, actualDuration, actualStartTime, selfBaseDuration, treeBaseDuration,
294-
// };
295-
296-
// let nextTree = tree;
297-
// let nextTreeUnfiltered = unfilteredTreeNode = new UnfilteredTreeNode('root');
298-
299-
// // Check if stateful component
300-
// if (stateNode && stateNode.state) {
301-
// nextTree = tree.appendChild(stateNode); // Add component to tree
302-
// changeSetState(stateNode); // Change setState functionality
303-
// }
304-
// nextTreeUnfiltered = unfilteredTreeNode.appendChild(stateNode);
305-
306-
// // TODO: handle Hooks cases...
307-
308-
// // Recurse on siblings
309-
// createTree(sibling, tree);
310-
// // Recurse on children
311-
// createTree(child, nextTree);
312-
313-
// return tree;
314-
// }
315-
316-
317-
318-
// Check if the component uses hooks
319-
// if (memoizedState && Object.hasOwnProperty.call(memoizedState, 'baseState')) {
320-
// // 'catch-all' for suspense elements (experimental)
321-
// if (typeof elementType.$$typeof === 'symbol') return;
322-
// // Traverse through the currentFiber and extract the getters/setters
323-
// astHooks = astParser(elementType);
324-
// saveState(astHooks);
325-
// // Create a traversed property and assign to the evaluated result of
326-
// // invoking traverseHooks with memoizedState
327-
// memoizedState.traversed = traverseHooks(memoizedState);
328-
// nextTree = tree.appendChild(memoizedState);
329-
// }
330-
331-
332-
333-
334-
335-
336-
337-
338-
// function createTree(currentFiber, tree = new Tree('root')) {
339-
// // Base case: child or sibling pointed to null
340-
// if (!currentFiber) return tree;
341-
342-
// const { sibling, stateNode, child, memoizedState, elementType } = currentFiber;
343-
344-
// let nextTree = tree;
345-
346-
// // Check if stateful component
347-
// if (stateNode && stateNode.state) {
348-
// nextTree = tree.appendChild(stateNode); // Add component to tree
349-
// changeSetState(stateNode); // Change setState functionality
350-
// }
351-
352-
// // Recurse on siblings
353-
// createTree(sibling, tree);
354-
// // Recurse on children
355-
// createTree(child, nextTree);
356-
357-
// return tree;
358-
// }

dev-reactime/timeJump.js

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module.exports = (origin, mode) => {
4040
target.state.hooksState.forEach(hooksState => {
4141
if (component && component.dispatch) {
4242
const hooksComponent = componentActionsRecord.getComponentByIndex(hooksState[1]);
43+
console.log('dispatch going back to hooks state: ', target.state.hooksState[0]);
4344
hooksComponent.dispatch(target.state.hooksState[0]);
4445
}
4546
});
@@ -49,47 +50,6 @@ module.exports = (origin, mode) => {
4950
if ((!component || !component.state) && !target.state.hooksState) {
5051
target.children.forEach(child => jump(child));
5152
}
52-
53-
54-
55-
/*
56-
if (originNode.component.setState) {
57-
console.log('stateful component jump, originNode: ', originNode.component);
58-
console.log('new target is:', target);
59-
// * Use the function argument when setting state to account for any state properties
60-
// * that may not have existed in the past
61-
originNode.component.setState(prevState => {
62-
Object.keys(prevState).forEach(key => {
63-
if (target.state[key] === undefined) {
64-
target.state[key] = undefined;
65-
}
66-
});
67-
return target.state;
68-
}, () => {
69-
// Iterate through new children once state has been set
70-
// gabi :: Will the target and origin have the same amount of dependents?
71-
// carlos: i don't know wtf
72-
jump(target.children[0], originNode.children[0]);
73-
});
74-
} else {
75-
// If component uses hooks, traverse through the memoize tree
76-
let current = originNode.component;
77-
//console.log("changing state of hooks component:", current);
78-
//console.log("new state is:", target);
79-
let index = 0;
80-
const hooks = returnState();
81-
// While loop through the memoize tree
82-
console.log('hooks:', hooks);
83-
while (current && current.queue) { // allows time travel with useEffect
84-
console.log('about to call hooks dispatch, target state is: ', target);
85-
//console.log('calling dispatch with arg:', target.state[hooks[index]]);
86-
current.queue.dispatch(target.state[hooks[index]]);
87-
// Reassign the current value
88-
current = current.next;
89-
index += 2;
90-
}
91-
}
92-
*/
9353
}
9454

9555
return target => {

dev-reactime/tree.js

Lines changed: 2 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -44,72 +44,7 @@ class Tree {
4444
});
4545
}
4646
return copy;
47-
48-
// This is a regular old tree version of the above, but above version
49-
// is better suited for D3 chart displays
50-
// class Tree {
51-
// constructor(state, name = 'nameless', index) {
52-
// this.state = state === 'root' ? 'root' : JSON.parse(JSON.stringify(state));
53-
// this.name = name;
54-
// this.index = index;
55-
// this.child = null;
56-
// this.sibling = null;
57-
// }
58-
59-
// setNode(state, name, index) {
60-
// this.state = { ...this.child.state, ...state };
61-
// this.name = name;
62-
// this.index = index;
63-
// }
64-
65-
// appendToChild(state, name = this.name, index = this.index) {
66-
// if (this.child) {
67-
// this.child.state = { ...this.child.state, ...state };
68-
// this.child.name = name;
69-
// this.child.index = index;
70-
// } else {
71-
// this.child = new Tree(state, name, index);
72-
// }
73-
// }
74-
75-
// appendToSibling(state, name = this.name, index = this.index) {
76-
// if (this.sibling) {
77-
// state = { ...this.sibling.state, ...state };
78-
// this.sibling.name = name;
79-
// this.sibling.index = index;
80-
// } else {
81-
// this.sibling = new Tree(state, name, index);
82-
// }
83-
// }
84-
85-
// cleanTreeCopy() {
86-
// const copy = new Tree(this.state, this.name, this.index);
87-
// if (this.sibling) {
88-
// copy.sibling = new Tree(this.sibling.state, this.sibling.name, this.sibling.index);
89-
// copy.sibling = scrubUnserializableMembers(copy.sibling);
90-
// copy.sibling = this.sibling.sibling;
91-
// copy.sibling.cleanTreeCopy();
92-
// }
93-
94-
// if (this.child) {
95-
// copy.child = new Tree(this.child.state, this.child.name, this.child.index);
96-
// copy.child = scrubUnserializableMembers(copy.child);
97-
// copy.child = this.child.child;
98-
// copy.child.cleanTreeCopy();
99-
// }
100-
//
101-
// // unfinished:
102-
// cleanD3Copy(children = []) {
103-
// copy = D3Tree(this.state, this.name, this.index, this.isStateless);
104-
// let nextSibling = this.sibling;
105-
// while(nextSibling = this.sibling) {
106-
// copy.cleanD3Copy(copy.)
107-
// }
108-
109-
}
110-
111-
// return copy;
112-
// }
47+
}
11348

11449
// print out the tree structure in the console
11550
// DEV: Process may be different for useState components
@@ -132,52 +67,4 @@ class Tree {
13267
}
13368
}
13469

135-
// class UnfilteredTreeNode extends Tree {
136-
// constructor(component, useStateInstead = false, name, unfilteredProps) {
137-
// super(component, useStateInstead, name);
138-
// // this.isStateful = unfilteredProps.isStateful;
139-
// // this.tagLabel = reactWorkTags[unfilteredProps.tag];
140-
// if(unfilteredProps) {
141-
// this.tag = unfilteredProps.tag;
142-
// this.actualDuration = unfilteredProps.actualDuration;
143-
// this.actualStartTime = unfilteredProps.actualStartTime;
144-
// this.selfBaseDuration = unfilteredProps.selfBaseDuration;
145-
// this.treeBaseDuration = unfilteredProps.treeBaseDuration;
146-
// }
147-
// }
148-
149-
// appendChild(component) {
150-
// const newChild = new UnfilteredTreeNode(component);
151-
// this.children.push(newChild);
152-
// return newChild;
153-
// }
154-
// }
155-
156-
module.exports = Tree
157-
// module.exports = {
158-
// Tree,
159-
// UnfilteredTreeNode,
160-
// };
161-
162-
163-
164-
165-
// // print out the tree structure in the console
166-
// // DEV: Process may be different for useState components
167-
// // BUG FIX: Don't print the Router as a component
168-
// // Change how the children are printed
169-
// print() {
170-
// console.log("current tree structure for *this : ", this);
171-
// const children = ['children: '];
172-
// // DEV: What should we push instead for components using hooks (it wouldn't be state)
173-
// this.children.forEach(child => { // if this.children is always initialized to empty array, when would there ever be anything to iterate through here?
174-
// children.push(child.state || child.component.state);
175-
// });
176-
// if (this.name) console.log("this.name if exists: ", this.name);
177-
// if (children.length === 1) {
178-
// console.log(`children length 1. ${this.state ? `this.state: ` : `this.component.state: `}`, this.state || this.component.state);
179-
// } else console.log(`children length !== 1. ${this.state ? `this.state: ` : `this.component.state, children: `}`, this.state || this.component.state, ...children);
180-
// this.children.forEach(child => {
181-
// child.print();
182-
// });
183-
// }
70+
module.exports = Tree;

0 commit comments

Comments
 (0)