Skip to content

Commit a9f4f6e

Browse files
committed
Add more revisions
1 parent 7656962 commit a9f4f6e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

readme_2.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ In the *src* folder, there are three directories we care about: *app*, *backend*
99
```
1010
src/
1111
├── app/ # Frontend code
12+
│ │ #
1213
│   ├── __tests__/ #
1314
│   ├── actions/ # Redux action creators
1415
│   ├── components/ # React components
@@ -21,6 +22,7 @@ src/
2122
│   └── store.tsx #
2223
2324
├── backend/ # "Backend" code
25+
│ │ #
2426
│   ├── __tests__/ #
2527
│   ├── types/ # Typescript interfaces
2628
│   ├── astParser.js # TODO: Remove? Duplicate in helpers.js.
@@ -37,7 +39,7 @@ src/
3739
│   └── tree.ts # Custom structure to send to background
3840
3941
├── extension/ # Chrome Extension code
40-
│ │
42+
│ │ #
4143
│   ├── build/ # Destination for bundles
4244
│   │ # and manifest.json (Chrome config file)
4345
│ │ #
@@ -56,8 +58,8 @@ src/
5658
- These two files help us handle requests both from the web browser and from the Reactime extension itself
5759

5860
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:
6163

6264
> Content scripts are files that run in the context of web pages.
6365
>
@@ -89,8 +91,9 @@ The general flow of data is described in the following steps:
8991

9092
![demo](./AppStructureDiagram.png)
9193

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).
9395

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.
9597

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

Comments
 (0)