Skip to content

Commit a3fe508

Browse files
committed
Merge branch 'dev' into brian/feature
2 parents 6b256c8 + 2bc3c4e commit a3fe508

File tree

7 files changed

+29
-31
lines changed

7 files changed

+29
-31
lines changed

src/backend/__tests__/timeJump.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('unit testing for timeJump.ts', () => {
6262
];
6363

6464
snapShot = { tree };
65-
timeJump = timeJumpRequire(snapShot, mode);
65+
timeJump = timeJumpRequire(mode);
6666
});
6767
test('calling the initial require should return a function', () => {
6868
expect(typeof timeJumpRequire).toBe('function');

src/backend/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const mode: Mode = {
2929
// linkFiber is now assigned the default function exported from the file linkFiber.ts
3030
const linkFiber = linkFiberStart(snapShot, mode);
3131
// timeJump is now assigned the default function exported from the file timeJump.ts
32-
const timeJump = timeJumpStart(snapShot, mode);
32+
const timeJump = timeJumpStart(mode);
3333

3434
// * Event listener for time-travel actions
3535
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
3636
switch (action) {
3737
case 'jumpToSnap':
38-
timeJump(payload, true); // * This sets state with given payloa
38+
timeJump(payload, true); // * This sets state with given payload
3939
break;
4040

4141
case 'setPause':

src/backend/linkFiber.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@
22
/* eslint-disable no-restricted-syntax */
33
/* eslint-disable @typescript-eslint/no-explicit-any */
44
/* eslint-disable max-len */
5-
// import 'core-js';
65
/* eslint-disable indent */
76
/* eslint-disable brace-style */
87
/* eslint-disable comma-dangle */
98
/* eslint-disable no-underscore-dangle */
109
/* eslint-disable func-names */
1110
/* eslint-disable no-use-before-define */
1211
/* eslint-disable no-param-reassign */
12+
/* eslint-disable-next-line no-mixed-operators */
1313

1414
// import typescript types
1515
import {
1616
// tree
1717
Snapshot,
1818
// jump, pause
1919
Mode,
20-
ComponentData,
2120
// array of state and component
2221
HookStates,
2322
// object with tree structure
2423
Fiber,
2524
} from './types/backendTypes';
2625
// import function that creates a tree
2726
import Tree from './tree';
28-
// passes the data down to its components ?
27+
// passes the data down to its components
2928
import componentActionsRecord from './masterState';
3029
import routes from './routes';
3130

@@ -43,7 +42,6 @@ declare global {
4342
let fiberRoot = null;
4443
let doWork = true;
4544
const circularComponentTable = new Set();
46-
let initialstart = false;
4745
let rtidCounter = 0;
4846
let rtid = null;
4947

@@ -102,20 +100,9 @@ function updateSnapShotTree(snap: Snapshot, mode: Mode): void {
102100
sendSnapshot(snap, mode);
103101
}
104102

105-
// updating tree depending on current mode on the panel (pause, etc)
106-
// function sendDevToolsInfo(snap: Snapshot, mode: Mode): void {
107-
// window.postMessage(
108-
// {
109-
// action: 'recordSnap',
110-
// payload,
111-
// },
112-
// '*'
113-
// );
114-
// }
115-
116103
/**
117104
* @method traverseHooks
118-
* @param memoizedState memoizedState property on a stateful fctnl component's FiberNode object
105+
* @param memoizedState memoizedState property on a stateful functional component's FiberNode object
119106
* @return An array of array of HookStateItem objects
120107
*
121108
* Helper function to traverse through memoizedState and inject instrumentation to update our state tree
@@ -155,7 +142,6 @@ const exclude = ['alternate', '_owner', '_store', 'get key', 'ref', '_self', '_s
155142
// react elements throw errors on client side of application - convert react/functions into string
156143
function convertDataToString(newObj, oldObj) {
157144
const newPropData = oldObj || {};
158-
// const newPropData = Array.isArray(obj) === true ? {} : [];
159145
for (const key in newObj) {
160146
if (typeof newObj[key] === 'function') {
161147
newPropData[key] = 'function';
@@ -292,7 +278,6 @@ function createTree(
292278
let newNode = null;
293279

294280
// We want to add this fiber node to the snapshot
295-
// eslint-disable-next-line no-mixed-operators
296281
if (componentFound || newState === 'stateless' && !newState.hooksState) {
297282
if (
298283
currentFiber.child
@@ -359,7 +344,7 @@ function createTree(
359344
* @return a function to be invoked by index.js that initiates snapshot monitoring
360345
* linkFiber contains core module functionality, exported as an anonymous function.
361346
*/
362-
export default (snap: Snapshot, mode: Mode): (() => void) => {
347+
export default (snap: Snapshot, mode: Mode): (() => void) => {
363348
// checks for visiblity of document
364349
function onVisibilityChange(): void {
365350
// hidden property = background tab/minimized window

src/backend/masterState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/* eslint-disable guard-for-in */
55
/* eslint-disable no-restricted-syntax */
66

7-
// import {Hook}
87
import {
98
// eslint-disable-next-line @typescript-eslint/no-unused-vars
109
HookStateItem, // obj with state and component
@@ -18,7 +17,8 @@ import {
1817
// For functional components that utilize Hooks, there will be one "component"
1918
// for each setter/getter every time we have a new snapshot
2019
let componentActionsRecord: HookStates = [];
21-
let index = 0;
20+
let index: number;
21+
index = 0;
2222

2323
export default {
2424
clear: () => {
@@ -40,7 +40,7 @@ export default {
4040
? componentActionsRecord[inputIndex].component
4141
: undefined),
4242
// this is used for react hooks - hooks will be passed in as an array from timeJump.ts
43-
getComponentByIndexHooks: (inputIndex: Array<number> = []): any => {
43+
getComponentByIndexHooks: (inputIndex: Array<number> = []): Array<any> => {
4444
const multiDispatch = [];
4545
for (let i = 0; i < inputIndex.length; i++) {
4646
if (componentActionsRecord[inputIndex[i]]) {

src/backend/module.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
// core-js is a library that includes polyfill for many types of native js
2+
// features such as promise, symbols, collections, typed arrays, etc.
3+
// Used in reactime to make sure our newest code
4+
// can run on outdated platforms and with outdated applications
15
declare module 'core-js';
6+
// Regenerator runtime provides runtime support for compiled/transpiled async functions.
7+
// Like babel that compiles modern js into older js,
8+
// async functions are also compiled to run on engines that don't support async.
9+
// After babel does the syntax transformation or transpiles the async functions,
10+
// the resulting code uses regen runtime to run
11+
// https://stackoverflow.com/questions/65378542/what-is-regenerator-runtime-npm-package-used-for
212
declare module 'regenerator-runtime/runtime';
13+
// Acorn is a jsx parser that was experimental to be faster than than the react.js jsx parser,
14+
// however is not maintained at this time, last update was more than one year ago 10-5-21
315
declare module 'acorn-jsx';
16+
// Traspiler to traspile code to JSX AST but to use with regular es5 compliant js,
17+
// still needs babel and buble trasnpilers which use acorn-jsx under the hood
418
declare module 'acorn';

src/backend/timeJump.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Console } from 'console';
21
import routes from './routes';
32

43
/* eslint-disable @typescript-eslint/no-unused-vars */
@@ -22,10 +21,10 @@ import routes from './routes';
2221
import componentActionsRecord from './masterState';
2322

2423
const circularComponentTable = new Set();
25-
export default (origin, mode) => {
24+
export default mode => {
2625
// Recursively change state of tree
2726
// Set the state of the origin tree if the component is stateful
28-
function jump(target, firstCall = false) {
27+
function jump(target) {
2928
if (!target) return;
3029
if (target.state === 'stateless') {
3130
target.children.forEach(child => jump(child));
@@ -44,8 +43,8 @@ export default (origin, mode) => {
4443
// prevState contains the states of the snapshots we are jumping FROM, not jumping TO
4544
prevState => {
4645
Object.keys(prevState).forEach(key => {
47-
// if conditional below does not appear to ever be reached if all states are defined - leaving code in just in case codebases do have undefined states
48-
if (!target.state[key] === undefined) {
46+
// the if conditional below does not appear to ever be reached if all states are defined - leaving code in just in case codebases do have undefined states
47+
if (target.state[key] !== undefined) {
4948
target.state[key] = undefined;
5049
}
5150
});
@@ -82,6 +81,7 @@ export default (origin, mode) => {
8281
}
8382
}
8483

84+
// payload from index.ts is assigned to target
8585
return (target, firstCall = false) => {
8686
// * Setting mode disables setState from posting messages to window
8787
mode.jumping = true;

src/backend/tree.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-plusplus */
22
/* eslint-disable max-len */
33
/* eslint-disable @typescript-eslint/ban-types */
4-
// import 'core-js';
54
/* eslint-disable no-multiple-empty-lines */
65
/* eslint-disable max-classes-per-file */
76
/* eslint-disable no-console */

0 commit comments

Comments
 (0)