Skip to content

Commit 3bf00a4

Browse files
committed
working Recoil except time jump, implemented Map component
1 parent eed201c commit 3bf00a4

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ src/extension/build.crx
1010
src/extension/build.pem
1111
bower_components
1212
sandboxes/manual-tests/NextJS/.next
13-
.vscode
13+
.vscode
14+
src/app/components/Map.tsx

readme2.md renamed to readme_2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ This documentation explains the architecture of Reactime v4.
33

44
![demo](./AppStructureDiagram.png)
55

6-
In the src folder, there are three directory: app, backend, and extension.
6+
In the src folder, there are three directories: app, backend, and extension.
77

88

9-
The app folder is responsible a SPA application that you see when you open the chrome dev tools under the reactime tab.
9+
The app folder is responsible a SPA that you see when you open the chrome dev tools under the Reactime tab.
1010

11-
The backend folder is responsible for generating data and handle time jump request from the background.js scripts in extension.
11+
The backend folder is responsible for generating data and handle time-jump request from the background.js scripts in extension.
1212

1313
The extension folder is where the contentscript.js and background.js located. These two files belongs to Chrome internal to help us handle requests both from the web browser and from the chrome dev tools. Unsure what contentscripts and backgroundscripts are? The details implementation are documented in the files themselves.
1414

@@ -25,7 +25,7 @@ Just to reiterate, contentscript is use to read and modify information that is r
2525

2626
The general flow of data is described in the following steps:
2727

28-
1. When the background bundle is loaded from the browser, it injects a script into the dom. This script uses a technique called [throttle](https://medium.com/@bitupon.211/debounce-and-throttle-160affa5457b) to get the data of the state to send to the contentscript every specified miliseconds.
28+
1. When the background bundle is loaded from the browser, it injects a script into the dom. This script uses a technique called [throttle](https://medium.com/@bitupon.211/debounce-and-throttle-160affa5457b) to get the data of the state of the app to send to the contentscript every specified miliseconds (in our case, it's 70ms).
2929

3030

3131
2. This contentscript always listens to the messages being sent from the interface of the browser. The recieved data will immediately be sent to the background script which then update an object that persist in background script called **tabsObj**. Each time tabsObj is updated, the most recent version will be sent to the interface of reactime dev tools written the app folder.

src/backend/helpers.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ export const getHooksNames = (elementType) => {
101101
}
102102
});
103103

104-
// el !== undefined &&
105-
// Iterate array and determine getter/setters based on pattern
106-
// console.log('abc');
107-
console.log(3);
108104
statements.forEach((el, i) => {
109105
if (el.match(/_use/)) hookState[el] = statements[i + 2];
110106
});

src/backend/linkFiber.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ import componentActionsRecord from './masterState';
5050
import { throttle, getHooksNames } from './helpers';
5151
import ReactDOM from 'react-dom';
5252

53-
console.log(ReactDOM);
54-
5553
declare global {
5654
interface Window {
5755
__REACT_DEVTOOLS_GLOBAL_HOOK__?: any;
@@ -61,7 +59,6 @@ declare global {
6159
let doWork = true;
6260
const circularComponentTable = new Set();
6361

64-
// module.exports = (snap, mode) => {
6562
export default (snap: Snapshot, mode: Mode): (() => void) => {
6663
let fiberRoot = null;
6764

@@ -97,9 +94,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
9794
component: memoizedState.queue,
9895
state: memoizedState.memoizedState,
9996
});
100-
//console.log('MEMOIZED PROPS ------>', memoizedProps);
101-
console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
102-
console.log('HOOK STATE ------->', hooksStates);
10397
}
10498
memoizedState =
10599
memoizedState.next !== memoizedState ? memoizedState.next : null;
@@ -158,7 +152,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
158152
}
159153

160154
let hooksIndex;
161-
// RECOIL
162155
let isRecoil = false;
163156

164157
if (window[`$recoilDebugStates`]) {
@@ -173,7 +166,7 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
173166
// });
174167
atomArray.push(memoizedProps);
175168

176-
console.log('1st ATOM ARRAY', atomArray);
169+
// console.log('1st ATOM ARRAY', atomArray);
177170

178171
function traverseRecoilHooks(memoizedState: any): HookStates {
179172
const hooksStates: HookStates = [];
@@ -183,16 +176,12 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
183176
memoizedState.queue.lastRenderedReducer &&
184177
memoizedState.queue.lastRenderedReducer.name === 'basicStateReducer'
185178
) {
186-
// console.log('MEM STATE', memoizedState);
187179
if (Object.entries(memoizedProps).length !== 0) {
188180
hooksStates.push({
189181
component: memoizedState.queue,
190182
state: memoizedProps,
191183
});
192184
}
193-
console.log('MEMOIZED PROPS ------>', memoizedProps);
194-
console.log('MEMOIZEDSTATE QUEUE------>', memoizedState.queue);
195-
console.log('HOOK STATE ------->', hooksStates);
196185
}
197186
memoizedState =
198187
memoizedState.next !== memoizedState ? memoizedState.next : null;
@@ -213,10 +202,8 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
213202
// which includes the dispatch() function we use to change their state.
214203

215204
const hooksStates = traverseRecoilHooks(memoizedState);
216-
console.log("HOOK STATE BEFORE LOOPING", hooksStates)
217205
const hooksNames = getHooksNames(elementType.toString());
218206
hooksStates.forEach((state, i) => {
219-
console.log('STATE IN SAVE NEW LOOP', state);
220207
hooksIndex = componentActionsRecord.saveNew(
221208
state.state,
222209
state.component
@@ -239,7 +226,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
239226
//REGULAR REACT HOOKS
240227
if (memoizedState && (tag === 0 || tag === 1 || tag === 2 || tag === 10) && isRecoil === false) {
241228
if (memoizedState.queue) {
242-
console.log('Regular Hooks');
243229
// Hooks states are stored as a linked list using memoizedState.next,
244230
// so we must traverse through the list and get the states.
245231
// We then store them along with the corresponding memoizedState.queue,
@@ -266,7 +252,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
266252
}
267253

268254
// This grabs stateless components
269-
270255
if (!componentFound && (tag === 0 || tag === 1 || tag === 2)) {
271256
newState = 'stateless';
272257
}
@@ -324,10 +309,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
324309
snap.tree = createTree(current);
325310
}
326311

327-
console.log('Fiber', fiberRoot.current);
328-
329-
console.log('SNAP.TREE->', snap.tree);
330-
331312
sendSnapshot();
332313
}
333314

@@ -352,14 +333,10 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
352333
const reactInstance = devTools ? devTools.renderers.get(1) : null;
353334
fiberRoot = devTools.getFiberRoots(1).values().next().value;
354335

355-
console.log('FIBER ROOT', fiberRoot.current);
336+
// console.log('FIBER ROOT', fiberRoot.current);
356337

357338
const throttledUpdateSnapshot = throttle(updateSnapShotTree, 70);
358339
document.addEventListener('visibilitychange', onVisibilityChange);
359-
360-
let snapshot = useRecoilSnapshot();
361-
console.log('here is an example of snapshot', snapshot);
362-
console.log(RecoilRoot);
363340
if (reactInstance && reactInstance.version) {
364341
devTools.onCommitFiberRoot = (function (original) {
365342
return function (...args) {

src/backend/timeJump.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ export default (origin, mode) => {
4949
}, () => target.children.forEach(child => jump(child)));
5050
}
5151

52+
console.log('TARGET', target);
5253
// Check for hooks state and set it with dispatch()
5354
if (target.state && target.state.hooksState) {
5455
target.state.hooksState.forEach(hook => {
5556
const hooksComponent = componentActionsRecord.getComponentByIndex(target.componentData.hooksIndex);
5657
const hookState = Object.values(hook);
5758
if (hooksComponent && hooksComponent.dispatch) {
59+
// console.log('attempt to dispatch this', hooksComponent, hookState[0]);
5860
hooksComponent.dispatch(hookState[0]);
5961
}
6062
});

0 commit comments

Comments
 (0)