Skip to content

Commit 18b4e4f

Browse files
committed
fixing bug and adding some comment
1 parent 39a03b7 commit 18b4e4f

File tree

4 files changed

+438
-369
lines changed

4 files changed

+438
-369
lines changed

src/backend/linkFiber.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,17 +571,37 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
571571
document.addEventListener('visibilitychange', onVisibilityChange);
572572

573573
if (reactInstance && reactInstance.version) {
574+
console.log(devTools);
575+
console.log(devTools.onCommitFiberRoot);
574576
fiberRoot = devTools.getFiberRoots(1).values().next().value;
575-
devTools.onCommitFiberRoot = (function (original) {
577+
// original is a function
578+
// devTools.onCommitFiberRoot = (function (original) {
579+
// return function (...args) {
580+
// // eslint-disable-next-line prefer-destructuring
581+
// fiberRoot = args[1];
582+
// if (doWork) {
583+
// throttledUpdateSnapshot();
584+
// }
585+
// return original(...args);
586+
// };
587+
// }(devTools.onCommitFiberRoot));
588+
589+
// React has inherent methods that are called with react fiber
590+
// we attach new functionality without compromising the original work that onCommitFiberRoot does
591+
const addOneMoreStep = function (original) {
576592
return function (...args) {
577593
// eslint-disable-next-line prefer-destructuring
578594
fiberRoot = args[1];
595+
// this is the additional functionality we added
579596
if (doWork) {
580597
throttledUpdateSnapshot();
581598
}
599+
// after our added work is completed we invoke the original function
582600
return original(...args);
583601
};
584-
}(devTools.onCommitFiberRoot));
602+
};
603+
devTools.onCommitFiberRoot = addOneMoreStep(devTools.onCommitFiberRoot);
604+
585605
throttledUpdateSnapshot(); // only runs on start up
586606
}
587607
};

src/extension/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function changeCurrLocation(tabObj, rootNode, index, name) {
122122
}
123123
}
124124

125-
// Establishing incoming connection with devtools.
125+
// Establishing incoming connection with Reactime.
126126
chrome.runtime.onConnect.addListener(port => {
127127
// port is one end of the connection - an object
128128
// push every port connected to the ports array
@@ -222,7 +222,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
222222
if (request.type === 'SIGN_CONNECT') {
223223
return true;
224224
}
225-
225+
console.log(sender, '<-- sender');
226226
const tabTitle = sender.tab.title;
227227
const tabId = sender.tab.id;
228228
const {
@@ -286,7 +286,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
286286
script.setAttribute('type', 'text/javascript');
287287
script.setAttribute('src', file);
288288
// eslint-disable-next-line prefer-template
289-
document.title = tab + '-' + document.title;
289+
// document.title = tab + '-' + document.title; // error of injecting random number
290290
htmlBody.appendChild(script);
291291
};
292292

src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Reactime",
3-
"version": "14.0.0",
3+
"version": "15.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.",
66
"manifest_version": 3,

0 commit comments

Comments
 (0)