You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme_2.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ In the *src* folder, there are three directories we care about: *app*, *backend*
9
9
```
10
10
src/
11
11
├── app/ # Frontend code
12
+
│ │ #
12
13
│ ├── __tests__/ #
13
14
│ ├── actions/ # Redux action creators
14
15
│ ├── components/ # React components
@@ -21,6 +22,7 @@ src/
21
22
│ └── store.tsx #
22
23
│
23
24
├── backend/ # "Backend" code
25
+
│ │ #
24
26
│ ├── __tests__/ #
25
27
│ ├── types/ # Typescript interfaces
26
28
│ ├── astParser.js # TODO: Remove? Duplicate in helpers.js.
@@ -37,7 +39,7 @@ src/
37
39
│ └── tree.ts # Custom structure to send to background
38
40
│
39
41
├── extension/ # Chrome Extension code
40
-
│ │
42
+
│ │ #
41
43
│ ├── build/ # Destination for bundles
42
44
│ │ # and manifest.json (Chrome config file)
43
45
│ │ #
@@ -56,8 +58,8 @@ src/
56
58
- These two files help us handle requests both from the web browser and from the Reactime extension itself
57
59
58
60
Still unsure about what contents scripts and background scripts do for Reactime, or for a chrome extensions in general?
59
-
The implementation details [can be found](./src/extension/background.js)[in the files](./src/extension/contentScript.ts) themselves.<br />
60
-
We also encourage you to dive into [the official Chrome Developer Docs](https://developer.chrome.com/home).<br />Some relevant sections are reproduced below:
61
+
-The implementation details [can be found](./src/extension/background.js)[in the files](./src/extension/contentScript.ts) themselves.
62
+
-We also encourage you to dive into [the official Chrome Developer Docs](https://developer.chrome.com/home).Some relevant sections are reproduced below:
61
63
62
64
> Content scripts are files that run in the context of web pages.
63
65
>
@@ -89,8 +91,9 @@ The general flow of data is described in the following steps:
89
91
90
92

91
93
92
-
1. When the background bundle is loaded by the browser, it executes a script injection into the dom. (see previous section on the backend folder) 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 content script every specified miliseconds (in our case, this interval is 70ms).
94
+
1. When the background bundle is loaded by the browser, it executes a script injection into the dom. (see section on *backend*). This script uses a technique called [throttle](https://medium.com/@bitupon.211/debounce-and-throttle-160affa5457b) to send state data from the app to the content script every specified milliseconds (in our case, this interval is 70ms).
93
95
94
-
2.This content script always listens for messages being sent from the interface of the browser. The received data will immediately be sent to the background script which then updates an object it persists 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.
96
+
2.The content script always listens for messages being passed from the extension's target application. Upon receiving data from the target app, the content script will immediately forward this data to the background script which then updates an object called `tabsObj`. Each time `tabsObj` is updated, its latest version will be passed to Reactime, where it is processed for displaying to the user by the *app* folder scripts.
95
97
96
-
3. Likewise, when there an action is emitted from Reactime -- a "jump" request for example -- a request will be made to the background script which is proxied over to the content script. This content script will talk to the browser interface to request the *state* that the user wants to jump to. One important thing to note here is that the jump action will be dispatched in backend script land, because it has direct access to the DOM.
98
+
3. Likewise, when Reactime emits an action due to user interaction -- a "jump" request for example -- a message will be passed from Reactime via the background script to the content script. Then, the content script will pass a message to the target application containing a payload that represents the state the user wants the DOM to reflect or "jump" to.
99
+
- One important thing to note here is that this jump action must be dispatched in *backend* land, because only there do we have direct access to the DOM.
0 commit comments