1
- // import 'core-js';
2
- /* eslint-disable max-len */
3
- /* eslint-disable no-param-reassign */
4
- /* eslint-disable function-paren-newline */
5
- /* eslint-disable implicit-arrow-linebreak */
6
-
7
- import snapshots from "../app/components/snapshots" ;
8
-
1
+ // import snapshots from "../app/components/snapshots";
2
+ import 'core-js' ;
9
3
// store ports in an array
10
4
const portsArr = [ ] ;
11
5
const reloaded = { } ;
12
6
const firstSnapshotReceived = { } ;
13
7
// there will be the same number of objects in here as there are reactime tabs open for each user application being worked on
14
8
const tabsObj = { } ;
15
-
9
+ console . log ( "hello from background" )
16
10
function createTabObj ( title ) {
17
11
// update tabsObj
18
12
return {
@@ -25,7 +19,7 @@ function createTabObj(title) {
25
19
index : 0 ,
26
20
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
27
21
currLocation : null ,
28
- // points the node that will generate the next child set by newest node or jump
22
+ // points to the node that will generate the next child set by newest node or jump
29
23
currParent : 0 ,
30
24
// points to the current branch
31
25
currBranch : 0 ,
@@ -44,14 +38,9 @@ function createTabObj(title) {
44
38
45
39
class Node {
46
40
constructor ( obj , tabObj ) {
47
- // eslint-disable-next-line no-param-reassign
48
- // eslint-disable-next-line no-multi-assign
49
- // eslint-disable-next-line no-plusplus
50
41
// continues the order of number of total state changes
51
- // eslint-disable-next-line no-plusplus
52
42
this . index = tabObj . index ++ ;
53
43
// continues the order of number of states changed from that parent
54
- // eslint-disable-next-line no-multi-assign
55
44
this . name = tabObj . currParent += 1 ;
56
45
// marks from what branch this node is originated
57
46
this . branch = tabObj . currBranch ;
@@ -76,9 +65,9 @@ function sendToHierarchy(tabObj, newNode) {
76
65
tabObj . currLocation = newNode ;
77
66
}
78
67
}
79
-
68
+ // used for map visualization
80
69
function changeCurrLocation ( tabObj , rootNode , index , name ) {
81
- // index comes from the app's main reducer to locate the right current location on tabObj
70
+ // index comes from the app's main reducer to locate the correct current location on tabObj
82
71
// check if current node has the index wanted
83
72
if ( rootNode . index === index ) {
84
73
tabObj . currLocation = rootNode ;
@@ -99,7 +88,7 @@ function changeCurrLocation(tabObj, rootNode, index, name) {
99
88
}
100
89
}
101
90
102
- // establishing connection with devtools
91
+ // establishing incoming connection with devtools
103
92
chrome . runtime . onConnect . addListener ( ( port ) => {
104
93
// port is one end of the connection - an object
105
94
@@ -124,7 +113,7 @@ chrome.runtime.onConnect.addListener((port) => {
124
113
}
125
114
} ) ;
126
115
127
- // receive snapshot from devtools and send it to contentScript -
116
+ // listen for message containing a snapshot from devtools and send it to contentScript -
128
117
port . onMessage . addListener ( ( msg ) => {
129
118
// msg is action denoting a time jump in devtools
130
119
@@ -182,13 +171,13 @@ chrome.runtime.onConnect.addListener((port) => {
182
171
break ;
183
172
default :
184
173
}
185
-
174
+ // one time request sent to content s
186
175
chrome . tabs . sendMessage ( tabId , msg ) ;
187
176
return true ; // attempt to fix message port closing error, consider return Promise
188
177
} ) ;
189
178
} ) ;
190
179
191
- // background.js recieves message from contentScript.js
180
+ // background.js listening for a message from contentScript.js
192
181
chrome . runtime . onMessage . addListener ( ( request , sender ) => {
193
182
// IGNORE THE AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED
194
183
if ( request . type === 'SIGN_CONNECT' ) {
@@ -199,7 +188,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
199
188
const { action, index, name } = request ;
200
189
let isReactTimeTravel = false ;
201
190
202
- // Filter out tabs that don't have reactime
191
+ // Filter out tabs that don't have reactime, tabs that dont use react?
203
192
if (
204
193
action === 'tabReload' ||
205
194
action === 'recordSnap' ||
@@ -251,6 +240,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
251
240
// resets hierarchy to page initial state recorded when emptied
252
241
tabsObj [ tabId ] . hierarchy = tabsObj [ tabId ] . initialHierarchy ;
253
242
} else {
243
+ // triggered with new tab opened
254
244
// resets snapshots to page initial state
255
245
tabsObj [ tabId ] . snapshots . splice ( 1 ) ;
256
246
// checks if hierarchy before reset
@@ -346,6 +336,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
346
336
347
337
// when tab is closed, remove the tabid from the tabsObj
348
338
chrome . tabs . onRemoved . addListener ( ( tabId ) => {
339
+ console . log ( 'tab is deleted.' )
349
340
// tell devtools which tab to delete
350
341
if ( portsArr . length > 0 ) {
351
342
portsArr . forEach ( ( bg ) =>
@@ -364,6 +355,7 @@ chrome.tabs.onRemoved.addListener((tabId) => {
364
355
365
356
// when a new url is loaded on the same tab, this remove the tabid from the tabsObj, recreate the tab and inject the script
366
357
chrome . tabs . onUpdated . addListener ( ( tabId , changeInfo ) => {
358
+ console . log ( "new site loaded." )
367
359
// check if the tab title changed to see if tab need to restart
368
360
if ( changeInfo && tabsObj [ tabId ] ) {
369
361
if ( changeInfo . title && changeInfo . title !== tabsObj [ tabId ] . title ) {
@@ -388,8 +380,9 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
388
380
}
389
381
} ) ;
390
382
391
- // when tab is view change , put the tabid as the current tab
383
+ // when tab view is changed , put the tabid as the current tab
392
384
chrome . tabs . onActivated . addListener ( ( info ) => {
385
+ console . log ( "tab view has changed" )
393
386
// tell devtools which tab to be the current
394
387
if ( portsArr . length > 0 ) {
395
388
portsArr . forEach ( ( bg ) =>
@@ -414,6 +407,7 @@ chrome.runtime.onInstalled.addListener(() => {
414
407
// when context menu is clicked, listen for the menuItemId,
415
408
// if user clicked on reactime, open the devtools window
416
409
chrome . contextMenus . onClicked . addListener ( ( { menuItemId } ) => {
410
+ console . log ( 'inspect clicked reactime' )
417
411
const options = {
418
412
type : 'panel' ,
419
413
left : 0 ,
0 commit comments