Skip to content

Commit 89eb2df

Browse files
committed
merged tree ts
2 parents 47544c4 + 59c20e8 commit 89eb2df

File tree

8 files changed

+28
-18328
lines changed

8 files changed

+28
-18328
lines changed

package-lock.json

Lines changed: 0 additions & 18318 deletions
This file was deleted.

src/app/components/Diff.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function Diff(props: DiffProps) {
7474

7575
if (previous === undefined || delta === undefined) {
7676
// console.log('reacthtml parser -->', ReactHtmlParser(html), typeof ReactHtmlParser(html));
77-
return <div className="noState"> No state change detected. Trigger an event to change state </div>;
77+
return <div className="no-data-message"> No state change detected. Trigger an event to change state </div>;
7878
}
7979
return <div>{ReactHtmlParser(html)}</div>;
8080
}

src/app/reducers/mainReducer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ export default (state, action) => produce(state, draft => {
2525

2626
const objChildArray = [];
2727
// eslint-disable-next-line no-restricted-syntax
28-
for (const objChild of obj.children) {
29-
objChildArray.push(findName(index, objChild));
28+
if (obj) {
29+
for (const objChild of obj.children) {
30+
objChildArray.push(findName(index, objChild));
31+
}
3032
}
3133
// eslint-disable-next-line no-restricted-syntax
3234
for (const objChildName of objChildArray) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.json-tree {
22
margin: 10px;
33
padding: 0;
4+
width: 900px;
45
background-color: $brand-color;
56
list-style: none;
67
}

src/app/styles/layout/_stateContainer.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343

4444
.no-data-message {
4545
font: 1.2em sans-serif;
46+
color: white;
4647
padding: 10px;
47-
// margin: 10px;
48-
color: hsl(0%, 50%, 50%);
4948
}
5049

5150
.state-container {

src/backend/helpers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ export const throttle = (f, t) => {
5151
// Helper function to grab the getters/setters from `elementType`
5252
export const getHooksNames = elementType => {
5353
// Initialize empty object to store the setters and getter
54-
let ast = JSXParser.parse(elementType);
54+
let ast;
55+
try {
56+
ast = JSXParser.parse(elementType);
57+
} catch(e) {
58+
return ['unknown'];
59+
}
5560
const hookState = {};
5661
const hooksNames = {};
5762

src/backend/tree.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ function scrubUnserializableMembers(tree: Tree): Tree {
1818
return tree;
1919
}
2020

21+
function serializeState(state) {
22+
try {
23+
return JSON.parse(JSON.stringify(state));
24+
} catch (e) {
25+
return 'circularState';
26+
};
27+
}
28+
2129
/**
2230
*
23-
*
31+
* This is the current snapshot that is being sent to the snapshots array.
2432
*
2533
*/
2634
class Tree {
@@ -43,7 +51,7 @@ class Tree {
4351
parent: Tree
4452

4553
constructor(state : string | {}, name = 'nameless', componentData: {} = {}) {
46-
this.state = state === 'root' ? 'root' : JSON.parse(JSON.stringify(state));
54+
this.state = state === 'root' ? 'root' : serializeState(state); // JSON.parse(JSON.stringify(state));
4755
this.name = name;
4856
this.componentData = componentData ? JSON.parse(JSON.stringify(componentData)) : {};
4957
this.children = [];
@@ -69,10 +77,10 @@ class Tree {
6977
*/
7078
cleanTreeCopy(): Tree {
7179
/**
72-
* @object circularComponentTable : Clears circular component
73-
* table only on first call, not recursive ones
80+
* @object circularComponentTable : Clears circular component table only on first call, not recursive ones
7481
*
7582
*/
83+
//
7684
if (copyInstances === 0) {
7785
copyInstances++;
7886
circularComponentTable.clear();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules/*
2+
!/node_modules/reactime
3+
.DS_Store

0 commit comments

Comments
 (0)