Skip to content

Commit c292448

Browse files
authored
Merge pull request #2 from dangitbobbeh/master
changed script injection
2 parents e7dbe79 + 03535f3 commit c292448

File tree

7 files changed

+9915
-8998
lines changed

7 files changed

+9915
-8998
lines changed

src/app/containers/ActionContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function ActionContainer(props) {
5454
};
5555
// the hierarchy gets set on the first click in the page
5656
// when page in refreshed we may not have a hierarchy so we need to check if hierarchy was initialized
57-
// if true involk displayArray to display the hierarchy
57+
// if true invoke displayArray to display the hierarchy
5858
if (hierarchy) displayArray(hierarchy);
5959

6060
// handles keyboard presses, function passes an event and index of each action-component

src/app/containers/MainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const mixpanel = require('mixpanel').init('12fa2800ccbf44a5c36c37bc9776e4c0', {
2020

2121
function MainContainer(): any {
2222
const [store, dispatch] = useStoreContext();
23+
console.log("storecont:", useStoreContext());
2324
const { tabs, currentTab, port: currentPort } = store;
2425
const [actionView, setActionView] = useState(true);
2526
//this function handles Time Jump sidebar view

src/app/reducers/mainReducer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import * as types from '../constants/actionTypes.ts';
44

55
export default (state, action) =>
66
produce(state, (draft) => {
7+
console.log("export state", state)
78
const { port, currentTab, tabs } = draft;
9+
console.log("currentTab Reducer:", currentTab)
10+
console.log("reducer action:", action)
811
const { hierarchy, snapshots, mode, intervalId, viewIndex, sliderIndex } =
912
tabs[currentTab] || {};
1013

@@ -154,6 +157,7 @@ export default (state, action) =>
154157
}
155158
case types.EMPTY: {
156159
port.postMessage({ action: 'emptySnap', tabId: currentTab });
160+
console.log("mainreducer line 159")
157161
tabs[currentTab].sliderIndex = 0;
158162
tabs[currentTab].viewIndex = -1;
159163
tabs[currentTab].playing = false;

src/backend/linkFiber.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function getRecoilState(): any {
8282
* Middleware: Gets a copy of the current snap.tree and posts a recordSnap message to the window
8383
*/
8484
function sendSnapshot(snap: Snapshot, mode: Mode): void {
85+
console.log('This is sendSnapshot!')
8586
// Don't send messages while jumping or while paused
8687
if (mode.jumping || mode.paused) return;
8788
// If there is no current tree creates a new one
@@ -91,6 +92,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
9192
const payload = snap.tree.cleanTreeCopy();
9293
// if it's Recoil - run different actions?
9394
if (isRecoil) {
95+
console.log('This is recoil and we\'re in sendSnapshot!')
9496
// getRecoilState()
9597
payload.atomsComponents = atomsComponents;
9698
payload.atomSelectors = atomsSelectors;
@@ -121,6 +123,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
121123

122124
//updating tree depending on current mode on the panel (pause, etc)
123125
function updateSnapShotTree(snap: Snapshot, mode: Mode): void {
126+
console.log('This is updateSnapShotTree!')
124127
// this is the currently active root fiber(the mutable root of the tree)
125128
if (fiberRoot) {
126129
const { current } = fiberRoot;
@@ -147,6 +150,7 @@ function traverseRecoilHooks(
147150
//Props of the fiber that were used to create the output during the previous render.
148151
memoizedProps: any
149152
): HookStates {
153+
console.log('This is traverseRecoilHooks!')
150154
const hooksStates: HookStates = [];
151155
while (memoizedState && memoizedState.queue) {
152156
if (
@@ -177,6 +181,7 @@ function traverseRecoilHooks(
177181
* every time a hooks component changes state
178182
*/
179183
function traverseHooks(memoizedState: any): HookStates {
184+
console.log('This is traverseHooks!')
180185
const hooksStates: HookStates = [];
181186
while (memoizedState && memoizedState.queue) {
182187
if (memoizedState.memoizedState) {
@@ -213,6 +218,7 @@ function createTree(
213218
tree: Tree = new Tree('root', 'root'),
214219
fromSibling = false
215220
) {
221+
console.log('currentFiber: ', currentFiber);
216222
// Base case: child or sibling pointed to null
217223
if (!currentFiber) return null;
218224
if (!tree) return tree;
@@ -343,6 +349,7 @@ function createTree(
343349
(tag === 0 || tag === 1 || tag === 2 || tag === 10) &&
344350
isRecoil === false
345351
) {
352+
console.log("Node uses regular react hooks")
346353
if (memoizedState.queue) {
347354
// Hooks states are stored as a linked list using memoizedState.next,
348355
// so we must traverse through the list and get the states.
@@ -488,6 +495,7 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
488495
doWork = !document.hidden;
489496
}
490497
return () => {
498+
console.log("exporting LinkFiber!")
491499
// react devtools global hook is a global object that was injected by the React Devtools content script, allows access to fiber nodes and react version
492500
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
493501
const reactInstance = devTools ? devTools.renderers.get(1) : null;

src/extension/background.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const metrics = {};
1212

1313
// This function will create the first instance of the test app's tabs object
1414
// which will hold test app's snapshots, link fiber tree info, chrome tab info, etc.
15+
//console.log("hello from background.js");
1516
function createTabObj(title) {
1617
// update tabsObj
1718
return {
@@ -240,6 +241,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
240241
const script = document.createElement('script');
241242
script.setAttribute('type', 'text/javascript');
242243
script.setAttribute('src', file);
244+
document.title=${tabId} + '-' + document.title
243245
htmlBody.appendChild(script);
244246
};
245247
injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body');
@@ -334,12 +336,13 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
334336
tabsObj[tabId],
335337
new Node(request.payload, tabsObj[tabId])
336338
);
337-
} else {
338-
sendToHierarchy(
339-
tabsObj[tabId],
340-
new NewNode(request.payload, tabsObj[tabId])
341-
);
342339
}
340+
// else {
341+
// sendToHierarchy(
342+
// tabsObj[tabId],
343+
// new NewNode(request.payload, tabsObj[tabId])
344+
// );
345+
// }
343346
}
344347
// sends new tabs obj to devtools
345348
if (portsArr.length > 0) {

src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Reactime",
2+
"name": "ReactimeX",
33
"version": "8.0.0",
44
"devtools_page": "devtools.html",
55
"description": "A Chrome extension that helps debug React applications by memorizing the state of components with every render.",

0 commit comments

Comments
 (0)