Skip to content

Commit 348ab01

Browse files
committed
commit so i can move to another branch
1 parent f6f23f2 commit 348ab01

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed

src/app/containers/ErrorContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function ErrorContainer(): JSX.Element {
2323
const timeout = useRef(null);
2424

2525
console.log(
26-
'ErrorContainer state variables: tabs: ',
27-
tabs,
26+
'ErrorContainer state variables: tabs status: ',
27+
JSON.stringify(tabs[currentTab]?.status),
2828
'currentTab: ',
2929
currentTab,
3030
'currentTitle: ',

src/app/containers/MainContainer.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
setTab,
1313
deleteTab,
1414
noDev,
15+
aReactApp, // JR added 12.20.23 9.53pm
1516
setCurrentLocation,
1617
disconnected,
1718
endConnect,
@@ -27,7 +28,15 @@ function MainContainer(): JSX.Element {
2728
const dispatch = useDispatch();
2829

2930
const { currentTab, tabs, port }: MainState = useSelector((state: RootState) => state.main);
30-
31+
console.log(
32+
'MainContainer state at render: tabs: ',
33+
JSON.stringify(tabs[currentTab]?.status),
34+
// tabs[currentTab]?.status,
35+
'port: ',
36+
port?.name,
37+
'time: ',
38+
new Date().toLocaleString(),
39+
);
3140
//JR: check connection status
3241
const { connectionStatus }: MainState = useSelector((state: RootState) => state.main);
3342
console.log('MainContainer connectionStatus at initialization: ', connectionStatus);
@@ -72,6 +81,7 @@ function MainContainer(): JSX.Element {
7281
'MainContainer messageListener message. action: ',
7382
action,
7483
'payload: ',
84+
JSON.stringify(payload.status),
7585
payload,
7686
'sourceTab: ',
7787
sourceTab,
@@ -93,6 +103,11 @@ function MainContainer(): JSX.Element {
93103
dispatch(noDev(payload));
94104
break;
95105
}
106+
// JR 12.20.23 9.53pm added a listener case for sending aReactApp to frontend
107+
case 'aReactApp': {
108+
dispatch(aReactApp(payload));
109+
break;
110+
}
96111
case 'changeTab': {
97112
console.log('MainContainer changeTab payload: ', payload);
98113
dispatch(setTab(payload));
@@ -132,14 +147,9 @@ function MainContainer(): JSX.Element {
132147
// If messageListener exists on currentPort, remove it
133148
while (currentPort.onMessage.hasListener(messageListener))
134149
currentPort.onMessage.removeListener(messageListener);
135-
console.log('messageListener after removing: ', messageListener);
136150

137151
// Add messageListener to the currentPort
138152
currentPort.onMessage.addListener(messageListener);
139-
console.log(
140-
'currentPort hasListener? after re-adding: ',
141-
currentPort.onMessage.hasListener(messageListener),
142-
);
143153

144154
// If handleDisconnect exists on chrome.runtime, remove it
145155
while (chrome.runtime.onMessage.hasListener(handleDisconnect))

src/app/slices/mainSlice.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,32 @@ export const mainSlice = createSlice({
160160

161161
if (tabs[currentTab]) {
162162
const { reactDevToolsInstalled } = payload[currentTab].status;
163-
tabs[currentTab].status.reactDevToolsInstalled = reactDevToolsInstalled;
163+
console.log(reactDevToolsInstalled);
164+
// JR 12.20. 9.47pm this was not applying to state before
165+
state.tabs[currentTab].status.reactDevToolsInstalled = reactDevToolsInstalled;
166+
console.log(
167+
'devTools updated state: ',
168+
JSON.stringify(state.tabs[currentTab].status),
169+
'time: ',
170+
new Date().toLocaleString(),
171+
);
172+
}
173+
},
174+
175+
aReactApp: (state, action) => {
176+
const { payload } = action;
177+
const { tabs, currentTab } = state;
178+
179+
if (tabs[currentTab]) {
180+
console.log(tabs[currentTab], payload[currentTab]);
181+
// JR 12.20. 9.47pm this was not applying to state before
182+
state.tabs[currentTab].status.targetPageisaReactApp = true;
183+
console.log(
184+
'aReactApp updated state: ',
185+
JSON.stringify(state.tabs[currentTab].status),
186+
'time: ',
187+
new Date().toLocaleString(),
188+
);
164189
}
165190
},
166191

@@ -506,6 +531,7 @@ export const {
506531
setTab,
507532
deleteTab,
508533
noDev,
534+
aReactApp,
509535
setCurrentLocation,
510536
changeView,
511537
changeSlider,

src/backend/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// regenerator runtime supports async functionality : This package implements a fully-functional source transformation that takes the syntax for generators/yield from ECMAScript 2015 or ES2015 and Asynchronous Iteration proposal and spits out efficient JS-of-today (ES5) that behaves the same way.
77
import 'regenerator-runtime/runtime';
88
// linkFiberInitialization (actually uses the function linkFiber but is labeled here as linkFiberInitialization, returns a function). When this returned function is invoked, it checks if devTools is installed, checks if the website is a reactApp, adds event listeners for timetravel, and allows us to obtain the initial FiberRoot Node from react dev tool
9-
import linkFiberInitialization from './routers/linkFiber';
9+
import linkFiber from './routers/linkFiber';
1010
// timeJumpInitialization (actually uses the function timeJumpInitiation but is labeled here as linkFiberInitialization, returns a function) returns a function that sets jumping to false and handles timetravel feature
1111
import timeJumpInitialization from './controllers/timeJump';
1212
import { Snapshot, Status, MsgData } from './types/backendTypes';
@@ -20,7 +20,7 @@ const mode: Status = {
2020

2121
// ---------------------INITIALIZE LINKFIBER & TIMEJUMP-------------------------
2222
// linkFiber is now assigned the default ASYNC function exported from the file linkFiber.ts
23-
const linkFiber = linkFiberInitialization(mode);
23+
const linkFiberInit = linkFiber(mode);
2424
// timeJump is now assigned the default ASYNC function exported from the file timeJump.ts
2525
const timeJump = timeJumpInitialization(mode);
2626

@@ -30,7 +30,7 @@ const timeJump = timeJumpInitialization(mode);
3030
* 2. Obtain the initial ReactFiber Tree from target React App
3131
* 3. Send a snapshot of ReactFiber Tree to frontend/Chrome Extension
3232
*/
33-
linkFiber();
33+
linkFiberInit();
3434

3535
// --------------INITIALIZE EVENT LISTENER FOR TIME TRAVEL----------------------
3636
/**

src/extension/background.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ chrome.runtime.onConnect.addListener((port) => {
162162
163163
Again, this port object is used for communication within your extension, not for communication with external ports or tabs in the Chrome browser. If you need to interact with specific tabs or external ports, you would use other APIs or methods, such as chrome.tabs or other Chrome Extension APIs.
164164
*/
165-
console.log('tabsObj onConnect: ', tabsObj);
165+
console.log('tabsObj onConnect: ', JSON.stringify(tabsObj));
166166
portsArr.push(port); // push each Reactime communication channel object to the portsArr
167-
console.log('portsArr onConnect: ', portsArr);
167+
console.log('portsArr onConnect: ', Object.keys(portsArr));
168168

169169
// JR: CONSIDER DELETING
170170
// 12.20.23 commenting out, possible culprit of many in no target bug
171171
if (portsArr.length > 0) {
172-
portsArr.forEach((bg) => {
173-
console.log('background onConnect. Send changeTab for port ', bg);
172+
portsArr.forEach((bg, index) => {
173+
console.log('background onConnect. Send changeTab for port ', index);
174174
// go through each port object (each Reactime instance)
175175
bg.postMessage({
176176
// send passed in action object as a message to the current port
@@ -190,14 +190,14 @@ chrome.runtime.onConnect.addListener((port) => {
190190

191191
// every time devtool is closed, remove the port from portsArr
192192
port.onDisconnect.addListener((e) => {
193-
console.log('port onDisconnect triggered, portsArr: ', portsArr);
193+
console.log('port onDisconnect triggered, portsArr: ', Object.keys(portsArr));
194194
for (let i = 0; i < portsArr.length; i += 1) {
195195
if (portsArr[i] === e) {
196196
// if (portsArr.length === 1) portsArr[i].sendMessage('portDisconnect'); // JR 12.20.23 try sending message to last remaining port directly prior to it being disconnected
197197
portsArr.splice(i, 1);
198198
chrome.runtime.sendMessage({ action: 'portDisconnect', port: e.name }); // JR 12.20.23 isn't this supposed to be a port.sendMessage? chrome.runtime sends messages between content script and background.js
199199
console.log('spliced portsArr', portsArr);
200-
console.log(`port ${e.name} disconnected. Remaining portsArr: `, portsArr);
200+
console.log(`port ${e.name} disconnected. Remaining portsArr: `, Object.keys(portsArr));
201201
break;
202202
}
203203
}
@@ -333,6 +333,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
333333
// Confirmed React Dev Tools installed, send this info to frontend
334334
case 'devToolsInstalled': {
335335
tabsObj[tabId].status.reactDevToolsInstalled = true;
336+
console.log('devToolsInstalled action, update tabsObj status', tabsObj[tabId].status);
337+
336338
portsArr.forEach((bg) =>
337339
bg.postMessage({
338340
action: 'devTools',
@@ -342,8 +344,18 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
342344
break;
343345
}
344346
// Confirmed target is a react app. No need to send to frontend
347+
// JR: BUG: why wouldn't we need to send to frontend???
345348
case 'aReactApp': {
346349
tabsObj[tabId].status.targetPageisaReactApp = true;
350+
console.log('aReactApp action, update tabsObj status', tabsObj[tabId].status);
351+
352+
// JR 12.20.23 9.53pm added a message action to send to frontend
353+
portsArr.forEach((bg) =>
354+
bg.postMessage({
355+
action: 'aReactApp',
356+
payload: tabsObj,
357+
}),
358+
);
347359
break;
348360
}
349361
// This injects a script into the app that you're testing Reactime on,

0 commit comments

Comments
 (0)