Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
753b852
Merge pull request #2 from reactrewind/dev
victorvrv Mar 1, 2019
1027fd2
Merge pull request #3 from victorvrv/master
victorvrv Mar 1, 2019
fcb0c1e
commit to handle merges
victorvrv Mar 1, 2019
bbdf7d7
Minor change in how React app connect actions to the state and action…
victorvrv Mar 1, 2019
509c3dc
Delete devtools_bundle.js
victorvrv Mar 2, 2019
1bc9f2e
Delete devtools_bundle.js.map
victorvrv Mar 2, 2019
8537156
added doubly linked list data structure
victorvrv Mar 2, 2019
8afe649
Merge branch 'master' of https://github.com/victorvrv/react-rewind
victorvrv Mar 2, 2019
aecd748
Merge pull request #4 from reactrewind/dev
victorvrv Mar 2, 2019
6c07872
Solved merge conficts
victorvrv Mar 2, 2019
9a0dae3
Merge pull request #6 from reactrewind/dev
victorvrv Mar 2, 2019
d95fea0
Added buttons back and forth time travel functionality
victorvrv Mar 2, 2019
1f59e3b
Merge branch 'dev' of https://github.com/victorvrv/react-rewind
victorvrv Mar 2, 2019
43d9933
Merge branch 'victor-dev'
victorvrv Mar 2, 2019
0039064
Merge last PR with the current chrome dev tools version.
victorvrv Mar 2, 2019
7a0780f
removed console.log from extension
victorvrv Mar 2, 2019
86e2dbd
deleted console.log
victorvrv Mar 2, 2019
e4fea21
Merge pull request #7 from reactrewind/dev
victorvrv Mar 4, 2019
73e4455
Minor change to background, extension and inject_script. Commiting be…
victorvrv Mar 4, 2019
9eed7c1
merged parser pull
victorvrv Mar 4, 2019
81bc3a9
Merge pull request #8 from reactrewind/dev
victorvrv Mar 4, 2019
28e3349
Merge pull request #9 from reactrewind/dev
victorvrv Mar 4, 2019
49ecd68
commiting handle of merge conflicts before new pull
victorvrv Mar 4, 2019
85a6236
Merge branch 'dev' of https://github.com/victorvrv/react-rewind into …
victorvrv Mar 4, 2019
457d39a
Connecting parser and chrome dev tools. Code is full of console.logs.
victorvrv Mar 4, 2019
fec8eae
Merge pull request #10 from victorvrv/victor-dev
victorvrv Mar 4, 2019
d064c77
Merge pull request #11 from reactrewind/dev
victorvrv Mar 6, 2019
208fa48
Connected dev tools with page. Injected script working, parsing worki…
victorvrv Mar 6, 2019
c989af1
Merge branch 'dev' of https://github.com/victorvrv/react-rewind into …
victorvrv Mar 6, 2019
4d3b80e
fixed wrong type for expected Number on TimeSlider
victorvrv Mar 7, 2019
5930cfd
Created long lived port between App and background. This is gonna be …
victorvrv Mar 7, 2019
6bf6647
Merge pull request #13 from reactrewind/dev
victorvrv Mar 7, 2019
67d7b4b
merged last PR into local branch
victorvrv Mar 7, 2019
2ac155d
Added turn on button
victorvrv Mar 7, 2019
8387ced
Update App.jsx
victorvrv Mar 7, 2019
37a836a
converted timeTravelTracker from Array to DoublyLinkedList
victorvrv Mar 7, 2019
9be10a6
Merge branch 'victor-dev' of https://github.com/victorvrv/react-rewin…
victorvrv Mar 7, 2019
6a5a428
Merge pull request #14 from reactrewind/dev
victorvrv Mar 7, 2019
9ec7b2d
Merge pull request #15 from reactrewind/dev
victorvrv Mar 7, 2019
b90eb96
Connected frontend changes with chrome extension. Play button now cha…
victorvrv Mar 11, 2019
0f8174c
Merge pull request #16 from reactrewind/dev
victorvrv Mar 11, 2019
1193141
Merged new parser script that deals with webpack bundled scripts.
victorvrv Mar 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/app/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, Component } from 'react';
import React, { Component } from 'react';
import { createGlobalStyle } from 'styled-components';

// containers
Expand Down Expand Up @@ -48,7 +48,7 @@ class App extends Component {
};

this.portToExtension = null;

this.addActionToView = this.addActionToView.bind(this);
this.toTheFuture = this.toTheFuture.bind(this);
this.toThePast = this.toThePast.bind(this);
Expand Down Expand Up @@ -82,6 +82,7 @@ class App extends Component {
}));
});
});
}

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

actionInPlay() {
let { isPlayingIndex } = this.state;
if (isPlayingIndex >= this.state.data.length - 1) isPlayingIndex = 0;
const { isPlaying, data } = this.state;

if (isPlayingIndex >= data.length - 1) isPlayingIndex = 0;

this.setState({ isPlayingIndex: isPlayingIndex + 1 });
const { id, action, state } = this.state.data[isPlayingIndex + 1];
const { id, action, state } = data[isPlayingIndex + 1];
this.toTheFuture();

setTimeout(() => {
this.setState((prev, props) => {
return { ...prev, id, action, state };
});
if (this.state.isPlaying && isPlayingIndex + 1 < this.state.data.length - 1) {
if (isPlaying && isPlayingIndex + 1 < data.length - 1) {
this.actionInPlay();
} else {
this.setState({ isPlaying: false });
Expand All @@ -153,12 +157,12 @@ class App extends Component {
// filter search bar results
searchChange(e) {
const { data } = this.state;

// grab user entry from filter bar
const compareSearchValue = e.target.value;

// set state with compare value
this.setState({ searchField: compareSearchValue })
this.setState({ searchField: compareSearchValue });

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

render() {
console.log(this.state.isPlayingIndex);
const {
action,
id,
Expand Down
6 changes: 2 additions & 4 deletions src/app/components/DetailCards/DetailsNav.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { useState } from 'react';

let NavLink = require('react-router-dom').NavLink;

import React from 'react';
// styled component imports
import { Buttons, Button, DetailsNavWrapper } from '../../styles/Nav.jsx';

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

export default function RightNav(props) {
return (
Expand Down
1 change: 0 additions & 1 deletion src/app/container/Details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import StateDisplay from '../components/DetailCards/State/StateDisplay.jsx'


export default function Details(props) {

// destructuring required info that's being passed down from App.jsx
// passing these props onto children
const {
Expand Down
23 changes: 21 additions & 2 deletions src/browser/chrome/background.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
const parseAndGenerate = require('./scripts/parser');

let portToDevtools;
const msgsToPanel = [];

chrome.tabs.onUpdated.addListener((id, info, tab) => {
if (tab.status !== 'complete' || tab.url.startsWith('chrome')) return;

// active page action button and inject extension.js
chrome.pageAction.show(tab.id);
chrome.tabs.executeScript(null, {
file: 'extension.js',
runAt: 'document_end',
});

// refresh devtool panel everytime we refresh webpage
// console.log('port: ', portToDevtools);
// if (portToDevtools) portToDevtools.postMessage({ action: 'refresh_devtool' });
// else msgsToPanel.push({ action: 'refresh_devtool' });
});


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

sendMessageToContent(parseAndGenerate(syncRequest.responseText));

Expand All @@ -40,6 +48,18 @@ function handleRequest(request) {
// The App on the devtools panel start a connection so that it can
// tell us when to start intercepting the script requests.
chrome.runtime.onConnect.addListener((port) => {
portToDevtools = port;

// if (msgsToPanel.length > 0) {
// for (let msg of msgsToPanel) port.postMessage(msg);
// }
// we change the port to null when we disconnect, so that when we refresh
// the page by start recording, we can check if (!port) and not refresh
// the devtools page.
port.onDisconnect.addListener(() => {
portToDevtools = null;
});

port.onMessage.addListener((msg) => {
if (!msg.turnOnDevtool) return;
interceptedUrl = msg.url;
Expand All @@ -64,7 +84,6 @@ function addScriptInterception() {
let reqIndex = 0;
function sendMessageToContent(codeString) {
const index = reqIndex++;
console.log(`Sending request ${index}.`);
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { codeString, index });
});
Expand Down
6 changes: 5 additions & 1 deletion src/browser/chrome/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ chrome.devtools.panels.create('React Rewind',
'devtools.html',
(extensionPanel) => {
const port = chrome.runtime.connect({ name: 'devtools' });
port.onMessage.addListener(() => {});
port.onMessage.addListener((msg) => {
// console.log('got msg: ', msg);
if (msg.action === 'refresh_devtool') extensionPanel.setPage('devtools.html');
});

extensionPanel.onShown.addListener((panelWindow) => {
panelWindow.backgroundPort = port;
});
Expand Down
10 changes: 6 additions & 4 deletions src/browser/chrome/scripts/inject_script_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
// We need this because our content-injected scripts are executed in an "isolated
// world" environment. BUT for the scripts below, we want the edited-React libraries
// to have access to the their functionalities.
const linkedListScript = document.createElement('script');
linkedListScript.src = chrome.runtime.getURL('scripts/linked_list.js');
(document.head || document.documentElement).appendChild(linkedListScript);

// const linkedListScript = document.createElement('script');
// linkedListScript.src = chrome.runtime.getURL('scripts/linked_list.js');
// (document.head || document.documentElement).appendChild(linkedListScript);

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

linkedListScript.onload = timeTravelScript.onload = function removeScriptTag() {
// linkedListScript.onload =
timeTravelScript.onload = function removeScriptTag() {
this.remove();
};

Expand Down
8 changes: 5 additions & 3 deletions src/browser/chrome/scripts/linked_list.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
class DoublyLinkedListNode {
constructor(value, next = null, previous = null) {
constructor(value, next = null, prev = null) {
this.value = value;
this.next = next;
this.previous = previous;
this.prev = prev;
}
}

class DoublyLinkedList {
constructor() {
this.head = null;
this.tail = null;
this.current = null;
}
Expand All @@ -16,11 +17,12 @@ class DoublyLinkedList {
const newDLLNode = new DoublyLinkedListNode(fiberNode);

if (!this.head) {
this.head = newDLLNode;
this.tail = newDLLNode;
this.current = newDLLNode;
} else {
this.tail.next = newDLLNode;
newDLLNode.previous = this.tail;
newDLLNode.prev = this.tail;
this.tail = newDLLNode;
}

Expand Down
13 changes: 8 additions & 5 deletions src/browser/chrome/scripts/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function useReducerReplacement() {
const dispatcher = resolveDispatcher();
function reducerWithTracker(state, action) {
const newState = reducer(state, action);
timeTravelTracker[timeTravelTracker.length - 1].actionDispatched = true;
timeTravelLList.tail.value.actionDispatched = true;
window.postMessage({
type: 'DISPATCH',
data: {
Expand Down Expand Up @@ -52,7 +52,8 @@ function commitAllHostEffectsReplacement() {
switch (primaryEffectTag) {
case Placement:
{
timeTravelTracker.push({
// editbyme
timeTravelLList.append({
primaryEffectTag: 'PLACEMENT',
effect: _.cloneDeep(nextEffect),
});
Expand All @@ -72,7 +73,8 @@ function commitAllHostEffectsReplacement() {
}
case Update:
{
timeTravelTracker.push({
// editbyme
timeTravelLList.append({
primaryEffectTag: 'UPDATE',
effect: _.cloneDeep(nextEffect),
current: _.cloneDeep(nextEffect.alternate),
Expand All @@ -84,7 +86,8 @@ function commitAllHostEffectsReplacement() {
}
case Deletion:
{
timeTravelTracker.push({
// editbyme
timeTravelLList.append({
primaryEffectTag: 'DELETION',
effect: _.cloneDeep(nextEffect),
});
Expand Down Expand Up @@ -167,7 +170,7 @@ const parseAndGenerate = (codeString) => {
// parse react code
injectableUseReducer = esprima.parseScript(useReducerReplacement.toString());
traverseTree(injectableUseReducer, 'useReducer', ast);

const code = escodegen.generate(ast);
console.log('returning code.');
return code;
Expand Down
Loading