Skip to content

Commit ecedb85

Browse files
authored
Merge pull request #47 from victorvrv/victor-dev
Victor dev
2 parents 9a12b7c + 1193141 commit ecedb85

File tree

9 files changed

+123
-60
lines changed

9 files changed

+123
-60
lines changed

src/app/components/App.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, Component } from 'react';
1+
import React, { Component } from 'react';
22
import { createGlobalStyle } from 'styled-components';
33

44
// containers
@@ -48,7 +48,7 @@ class App extends Component {
4848
};
4949

5050
this.portToExtension = null;
51-
51+
5252
this.addActionToView = this.addActionToView.bind(this);
5353
this.toTheFuture = this.toTheFuture.bind(this);
5454
this.toThePast = this.toThePast.bind(this);
@@ -82,6 +82,7 @@ class App extends Component {
8282
}));
8383
});
8484
});
85+
}
8586

8687
// functionality to change 'play' button to 'stop'
8788
setIsPlaying() {
@@ -120,16 +121,19 @@ class App extends Component {
120121

121122
actionInPlay() {
122123
let { isPlayingIndex } = this.state;
123-
if (isPlayingIndex >= this.state.data.length - 1) isPlayingIndex = 0;
124+
const { isPlaying, data } = this.state;
125+
126+
if (isPlayingIndex >= data.length - 1) isPlayingIndex = 0;
124127

125128
this.setState({ isPlayingIndex: isPlayingIndex + 1 });
126-
const { id, action, state } = this.state.data[isPlayingIndex + 1];
129+
const { id, action, state } = data[isPlayingIndex + 1];
130+
this.toTheFuture();
127131

128132
setTimeout(() => {
129133
this.setState((prev, props) => {
130134
return { ...prev, id, action, state };
131135
});
132-
if (this.state.isPlaying && isPlayingIndex + 1 < this.state.data.length - 1) {
136+
if (isPlaying && isPlayingIndex + 1 < data.length - 1) {
133137
this.actionInPlay();
134138
} else {
135139
this.setState({ isPlaying: false });
@@ -153,12 +157,12 @@ class App extends Component {
153157
// filter search bar results
154158
searchChange(e) {
155159
const { data } = this.state;
156-
160+
157161
// grab user entry from filter bar
158162
const compareSearchValue = e.target.value;
159163

160164
// set state with compare value
161-
this.setState({ searchField: compareSearchValue })
165+
this.setState({ searchField: compareSearchValue });
162166

163167
// match results from our filter entry to data
164168
const actions = data.filter(function(item) {
@@ -200,7 +204,6 @@ class App extends Component {
200204
}
201205

202206
render() {
203-
console.log(this.state.isPlayingIndex);
204207
const {
205208
action,
206209
id,

src/app/components/DetailCards/DetailsNav.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import React, { useState } from 'react';
2-
3-
let NavLink = require('react-router-dom').NavLink;
4-
1+
import React from 'react';
52
// styled component imports
63
import { Buttons, Button, DetailsNavWrapper } from '../../styles/Nav.jsx';
74

5+
const { NavLink } = require('react-router-dom');
86

97
export default function RightNav(props) {
108
return (

src/app/container/Details.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import StateDisplay from '../components/DetailCards/State/StateDisplay.jsx'
1515

1616

1717
export default function Details(props) {
18-
1918
// destructuring required info that's being passed down from App.jsx
2019
// passing these props onto children
2120
const {

src/browser/chrome/background.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
const parseAndGenerate = require('./scripts/parser');
22

3+
let portToDevtools;
4+
const msgsToPanel = [];
5+
36
chrome.tabs.onUpdated.addListener((id, info, tab) => {
47
if (tab.status !== 'complete' || tab.url.startsWith('chrome')) return;
58

9+
// active page action button and inject extension.js
610
chrome.pageAction.show(tab.id);
711
chrome.tabs.executeScript(null, {
812
file: 'extension.js',
913
runAt: 'document_end',
1014
});
15+
16+
// refresh devtool panel everytime we refresh webpage
17+
// console.log('port: ', portToDevtools);
18+
// if (portToDevtools) portToDevtools.postMessage({ action: 'refresh_devtool' });
19+
// else msgsToPanel.push({ action: 'refresh_devtool' });
1120
});
1221

1322

@@ -29,7 +38,6 @@ function handleRequest(request) {
2938
const syncRequest = new XMLHttpRequest();
3039
syncRequest.open('GET', request.url, false);
3140
syncRequest.send(null);
32-
console.log(`Status: ${syncRequest.status} - Size of response: ${syncRequest.responseText.length}`);
3341

3442
sendMessageToContent(parseAndGenerate(syncRequest.responseText));
3543

@@ -40,6 +48,18 @@ function handleRequest(request) {
4048
// The App on the devtools panel start a connection so that it can
4149
// tell us when to start intercepting the script requests.
4250
chrome.runtime.onConnect.addListener((port) => {
51+
portToDevtools = port;
52+
53+
// if (msgsToPanel.length > 0) {
54+
// for (let msg of msgsToPanel) port.postMessage(msg);
55+
// }
56+
// we change the port to null when we disconnect, so that when we refresh
57+
// the page by start recording, we can check if (!port) and not refresh
58+
// the devtools page.
59+
port.onDisconnect.addListener(() => {
60+
portToDevtools = null;
61+
});
62+
4363
port.onMessage.addListener((msg) => {
4464
if (!msg.turnOnDevtool) return;
4565
interceptedUrl = msg.url;
@@ -64,7 +84,6 @@ function addScriptInterception() {
6484
let reqIndex = 0;
6585
function sendMessageToContent(codeString) {
6686
const index = reqIndex++;
67-
console.log(`Sending request ${index}.`);
6887
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
6988
chrome.tabs.sendMessage(tabs[0].id, { codeString, index });
7089
});

src/browser/chrome/devtools.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ chrome.devtools.panels.create('React Rewind',
33
'devtools.html',
44
(extensionPanel) => {
55
const port = chrome.runtime.connect({ name: 'devtools' });
6-
port.onMessage.addListener(() => {});
6+
port.onMessage.addListener((msg) => {
7+
// console.log('got msg: ', msg);
8+
if (msg.action === 'refresh_devtool') extensionPanel.setPage('devtools.html');
9+
});
10+
711
extensionPanel.onShown.addListener((panelWindow) => {
812
panelWindow.backgroundPort = port;
913
});

src/browser/chrome/scripts/inject_script_tags.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
// We need this because our content-injected scripts are executed in an "isolated
33
// world" environment. BUT for the scripts below, we want the edited-React libraries
44
// to have access to the their functionalities.
5-
const linkedListScript = document.createElement('script');
6-
linkedListScript.src = chrome.runtime.getURL('scripts/linked_list.js');
7-
(document.head || document.documentElement).appendChild(linkedListScript);
5+
6+
// const linkedListScript = document.createElement('script');
7+
// linkedListScript.src = chrome.runtime.getURL('scripts/linked_list.js');
8+
// (document.head || document.documentElement).appendChild(linkedListScript);
89

910
const timeTravelScript = document.createElement('script');
1011
timeTravelScript.src = chrome.runtime.getURL('scripts/time_travel.js');
1112
(document.head || document.documentElement).appendChild(timeTravelScript);
1213

13-
linkedListScript.onload = timeTravelScript.onload = function removeScriptTag() {
14+
// linkedListScript.onload =
15+
timeTravelScript.onload = function removeScriptTag() {
1416
this.remove();
1517
};
1618

src/browser/chrome/scripts/linked_list.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
class DoublyLinkedListNode {
2-
constructor(value, next = null, previous = null) {
2+
constructor(value, next = null, prev = null) {
33
this.value = value;
44
this.next = next;
5-
this.previous = previous;
5+
this.prev = prev;
66
}
77
}
88

99
class DoublyLinkedList {
1010
constructor() {
11+
this.head = null;
1112
this.tail = null;
1213
this.current = null;
1314
}
@@ -16,11 +17,12 @@ class DoublyLinkedList {
1617
const newDLLNode = new DoublyLinkedListNode(fiberNode);
1718

1819
if (!this.head) {
20+
this.head = newDLLNode;
1921
this.tail = newDLLNode;
2022
this.current = newDLLNode;
2123
} else {
2224
this.tail.next = newDLLNode;
23-
newDLLNode.previous = this.tail;
25+
newDLLNode.prev = this.tail;
2426
this.tail = newDLLNode;
2527
}
2628

src/browser/chrome/scripts/parser.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function useReducerReplacement() {
88
const dispatcher = resolveDispatcher();
99
function reducerWithTracker(state, action) {
1010
const newState = reducer(state, action);
11-
timeTravelTracker[timeTravelTracker.length - 1].actionDispatched = true;
11+
timeTravelLList.tail.value.actionDispatched = true;
1212
window.postMessage({
1313
type: 'DISPATCH',
1414
data: {
@@ -52,7 +52,8 @@ function commitAllHostEffectsReplacement() {
5252
switch (primaryEffectTag) {
5353
case Placement:
5454
{
55-
timeTravelTracker.push({
55+
// editbyme
56+
timeTravelLList.append({
5657
primaryEffectTag: 'PLACEMENT',
5758
effect: _.cloneDeep(nextEffect),
5859
});
@@ -72,7 +73,8 @@ function commitAllHostEffectsReplacement() {
7273
}
7374
case Update:
7475
{
75-
timeTravelTracker.push({
76+
// editbyme
77+
timeTravelLList.append({
7678
primaryEffectTag: 'UPDATE',
7779
effect: _.cloneDeep(nextEffect),
7880
current: _.cloneDeep(nextEffect.alternate),
@@ -84,7 +86,8 @@ function commitAllHostEffectsReplacement() {
8486
}
8587
case Deletion:
8688
{
87-
timeTravelTracker.push({
89+
// editbyme
90+
timeTravelLList.append({
8891
primaryEffectTag: 'DELETION',
8992
effect: _.cloneDeep(nextEffect),
9093
});
@@ -167,7 +170,7 @@ const parseAndGenerate = (codeString) => {
167170
// parse react code
168171
injectableUseReducer = esprima.parseScript(useReducerReplacement.toString());
169172
traverseTree(injectableUseReducer, 'useReducer', ast);
170-
173+
171174
const code = escodegen.generate(ast);
172175
console.log('returning code.');
173176
return code;

0 commit comments

Comments
 (0)