Skip to content

Commit 0c51a12

Browse files
committed
commented out import core-js, deleted ComponentData from import of backend.types, unused initialstart variable, post message that was a duplicate of running post message above updateSnapshottree function, removed newpropdata deprecated and commented out code
1 parent 5c39744 commit 0c51a12

File tree

1 file changed

+3
-75
lines changed

1 file changed

+3
-75
lines changed

src/backend/linkFiber.ts

Lines changed: 3 additions & 75 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
@@ -351,60 +336,3 @@ function createTree(
351336
}
352337
return tree;
353338
}
354-
355-
/**
356-
* @method linkFiber
357-
* @param snap The current snapshot
358-
* @param mode The current mode (i.e. jumping, time-traveling, or paused)
359-
* @return a function to be invoked by index.js that initiates snapshot monitoring
360-
* linkFiber contains core module functionality, exported as an anonymous function.
361-
*/
362-
export default (snap: Snapshot, mode: Mode): (() => void) => {
363-
// checks for visiblity of document
364-
function onVisibilityChange(): void {
365-
// hidden property = background tab/minimized window
366-
doWork = !document.hidden;
367-
}
368-
return () => {
369-
// react devtools global hook is a global object that was injected by the React Devtools content script, allows access to fiber nodes and react version
370-
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
371-
// check if reactDev Tools is installed
372-
if (!devTools) { return; }
373-
window.postMessage({
374-
action: 'devToolsInstalled',
375-
payload: 'devToolsInstalled'
376-
}, '*');
377-
// reactInstance returns an object of the react, 1st element in map
378-
const reactInstance = devTools.renderers.get(1);
379-
// if no React Instance found then target is not a compatible app
380-
if (!reactInstance) { return; }
381-
window.postMessage({
382-
action: 'aReactApp',
383-
payload: 'aReactApp'
384-
}, '*');
385-
386-
const throttledUpdateSnapshot = throttle(() => { updateSnapShotTree(snap, mode); }, 70);
387-
document.addEventListener('visibilitychange', onVisibilityChange);
388-
389-
if (reactInstance && reactInstance.version) {
390-
fiberRoot = devTools.getFiberRoots(1).values().next().value;
391-
// React has inherent methods that are called with react fiber
392-
// we attach new functionality without compromising the original work that onCommitFiberRoot does
393-
const addOneMoreStep = function (original) {
394-
return function (...args) {
395-
// eslint-disable-next-line prefer-destructuring
396-
fiberRoot = args[1];
397-
// this is the additional functionality we added
398-
if (doWork) {
399-
throttledUpdateSnapshot();
400-
}
401-
// after our added work is completed we invoke the original function
402-
return original(...args);
403-
};
404-
};
405-
devTools.onCommitFiberRoot = addOneMoreStep(devTools.onCommitFiberRoot);
406-
407-
throttledUpdateSnapshot(); // only runs on start up
408-
}
409-
};
410-
};

0 commit comments

Comments
 (0)