prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
Module", { value: true }); exports.Component = Component; var _react = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return ...
(Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } n
; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithCustomHook.js", "language": "javascript", "file_size": 2557, "cut_index": 563, "middle_length": 229 }
ineProperty(exports, "__esModule", { value: true }); exports.Component = Component; var _react = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () ...
for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newOb
{ return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/ContainingStringSourceMappingURL.js", "language": "javascript", "file_size": 1878, "cut_index": 537, "middle_length": 229 }
Module", { value: true }); exports.Component = Component; var _react = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return ...
(Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } n
; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/index-map/ComponentUsingHooksIndirectly.js", "language": "javascript", "file_size": 2413, "cut_index": 563, "middle_length": 229 }
tItem; exports.List = List; var React = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequir...
call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) {
rdCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/index-map/ToDoList.js", "language": "javascript", "file_size": 5027, "cut_index": 614, "middle_length": 229 }
, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const React = require('react'); const {useEffect, useState} = require('react'); function Component() { const countState = useState(0); const count...
function useIsDarkMode() { const darkModeState = useState(false); const [isDarkMode] = darkModeState; useEffect(function useEffectCreate() { // Here is where we may listen to a "theme" event... }, []); return [isDarkMode, () => {}]; } mo
Click = () => setCount(count + 1); return null; }
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/ComponentUsingHooksIndirectly.js", "language": "javascript", "file_size": 883, "cut_index": 547, "middle_length": 52 }
import {getVersionedRenderImplementation} from './utils'; describe('Fast Refresh', () => { let React; let ReactFreshRuntime; let act; let babel; let exportsObj; let freshPlugin; let store; let withErrorsOrWarningsIgnored; beforeEach(() => { global.IS_REACT_ACT_ENVIRONMENT = true; exportsObj...
: renderImplementation, getContainer} = getVersionedRenderImplementation(); function execute(source) { const compiled = babel.transform(source, { babelrc: false, presets: ['@babel/react'], plugins: [ [freshPlugin, {skip
'react-refresh/runtime'); ReactFreshRuntime.injectIntoGlobalHook(global); const utils = require('./utils'); act = utils.act; withErrorsOrWarningsIgnored = utils.withErrorsOrWarningsIgnored; }); const {render
{ "filepath": "packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js", "language": "javascript", "file_size": 9084, "cut_index": 716, "middle_length": 229 }
tItem; exports.List = List; var React = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequir...
call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) {
rdCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/react-sources-extended/index-map/ToDoList.js", "language": "javascript", "file_size": 5027, "cut_index": 614, "middle_length": 229 }
tItem; exports.List = List; var React = _interopRequireWildcard(require("react")); var _jsxFileName = ""; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequir...
call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) {
rdCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/ToDoList.js", "language": "javascript", "file_size": 5027, "cut_index": 614, "middle_length": 229 }
ng the file to begin with, // and in some cases we can avoid serializing the source code at all // (e.g. when we are in an environment that supports our custom metadata format). // // The overall flow of this file is such: // 1. Find the Set of source files defining the hooks and load them all. // Then for each sour...
ings in order to map the runtime code to the original source, // but at least the eventual source that we parse to an AST is small/fast. // // b. If no source map, pass the full source to a Worker for parsing. // Use the source to infer hook
p is used to retrieve the original source, // which is then also parsed in the Worker to infer hook names. // This is less ideal because parsing a full source map is slower, // since we need to evaluate the mapp
{ "filepath": "packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js", "language": "javascript", "file_size": 18628, "cut_index": 1331, "middle_length": 229 }
left: number, width: number, height: number}; const assign = Object.assign; // Note that the Overlay components are not affected by the active Theme, // because they highlight elements in the main Chrome window (outside of devtools). // The colors below were chosen to roughly match those used by Chrome devtools. cla...
e.borderColor = overlayStyles.padding; this.content.style.backgroundColor = overlayStyles.background; assign(this.node.style, { borderColor: overlayStyles.margin, pointerEvents: 'none', position: 'fixed', }); this.node.s
lement('div'); this.border = doc.createElement('div'); this.padding = doc.createElement('div'); this.content = doc.createElement('div'); this.border.style.borderColor = overlayStyles.border; this.padding.styl
{ "filepath": "packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js", "language": "javascript", "file_size": 9196, "cut_index": 921, "middle_length": 229 }
Stacks = true; } ReactDOMClient = require('react-dom/client'); const utils = require('./utils'); act = utils.act; }); const {render} = getVersionedRenderImplementation(); // @reactVersion >= 18.0 it('should pass through logs when there is no current fiber', () => { expect(global.consoleLo...
l([['error']]); }); // @reactVersion >= 18.0 it('should not append multiple stacks', () => { global.__REACT_DEVTOOLS_GLOBAL_HOOK__.settings.appendComponentStack = true; const Child = ({children}) => { console.warn('warn', '\n in Ch
.warn('warn'); console.error('error'); expect(global.consoleLogMock.mock.calls).toEqual([['log']]); expect(global.consoleWarnMock.mock.calls).toEqual([['warn']]); expect(global.consoleErrorMock.mock.calls).toEqua
{ "filepath": "packages/react-devtools-shared/src/__tests__/console-test.js", "language": "javascript", "file_size": 25205, "cut_index": 1331, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ describe('events', () => { let dispatcher; beforeEach(() => { const EventEmitter = require('../events').default; dispatcher = new EventEmitter(); }); // @reactVersion >=16 it('can dispatch an event...
); // @reactVersion >=16 it('notifies all attached listeners of events', () => { const callback1 = jest.fn(); const callback2 = jest.fn(); const callback3 = jest.fn(); dispatcher.addListener('event', callback1); dispatcher.addList
dispatcher.addListener('event', callback); dispatcher.addListener('event', callback); dispatcher.emit('event', 123); expect(callback).toHaveBeenCalledTimes(1); expect(callback).toHaveBeenCalledWith(123); }
{ "filepath": "packages/react-devtools-shared/src/__tests__/events-test.js", "language": "javascript", "file_size": 4194, "cut_index": 614, "middle_length": 229 }
dren; } }; }); afterEach(() => { jest.restoreAllMocks(); }); const {render: legacyRender} = getLegacyRenderImplementation(); const {render: modernRender} = getModernRenderImplementation(); const {render} = getVersionedRenderImplementation(); const Contexts = ({ children, defaultIn...
{children} </InspectedElementContextController> </TreeContextController> </SettingsContextController> </StoreContext.Provider> </BridgeContext.Provider> ); function useInspectedElement() { const
roller> <TreeContextController defaultInspectedElementID={defaultInspectedElementID} defaultInspectedElementIndex={defaultInspectedElementIndex}> <InspectedElementContextController>
{ "filepath": "packages/react-devtools-shared/src/__tests__/inspectedElement-test.js", "language": "javascript", "file_size": 90136, "cut_index": 3790, "middle_length": 229 }
import typeof ReactTestRenderer from 'react-test-renderer'; import type {Element} from 'react-devtools-shared/src/frontend/types'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type Store from 'react-devtools-shared/src/devtools/store'; import {getVersionedRenderImplementation} from './u...
lobal.store; store.collapseNodesByDefault = false; React = require('react'); TestRenderer = utils.requireTestRenderer(); BridgeContext = require('react-devtools-shared/src/devtools/views/context').BridgeContext; OwnersListContex
ersListContext; let OwnersListContextController; let StoreContext; let TreeContextController; beforeEach(() => { utils = require('./utils'); utils.beforeEachProfiling(); bridge = global.bridge; store = g
{ "filepath": "packages/react-devtools-shared/src/__tests__/ownersListContext-test.js", "language": "javascript", "file_size": 5922, "cut_index": 716, "middle_length": 229 }
se strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Component = Component; var _react = require("react"); /** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this sour...
react.useContext)(B); // prettier-ignore const c = (0, _react.useContext)(A), d = (0, _react.useContext)(B); // eslint-disable-line one-var return a + b + c + d; } //# sourceMappingURL=ComponentWithMultipleHooksPerLine.js.map?foo=bar&param=so
onst b = (0, _
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/fb-sources-extended/index-map/ComponentWithMultipleHooksPerLine.js", "language": "javascript", "file_size": 792, "cut_index": 514, "middle_length": 14 }
exports, "ComponentUsingHooksIndirectly", { enumerable: true, get: function () { return _ComponentUsingHooksIndirectly.Component; } }); Object.defineProperty(exports, "ComponentWithCustomHook", { enumerable: true, get: function () { return _ComponentWithCustomHook.Component; } }); Object.definePrope...
unction () { return _ComponentWithNestedHooks.Component; } }); Object.defineProperty(exports, "ContainingStringSourceMappingURL", { enumerable: true, get: function () { return _ContainingStringSourceMappingURL.Component; } }); Object.define
onentWithMultipleHooksPerLine", { enumerable: true, get: function () { return _ComponentWithMultipleHooksPerLine.Component; } }); Object.defineProperty(exports, "ComponentWithNestedHooks", { enumerable: true, get: f
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/external/react-sources-extended/index-map/index.js", "language": "javascript", "file_size": 3321, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import { getVersionedRenderImplementation, normalizeCodeLocInfo, } from 'react-devtools-shared/src/__tests__/utils'; describe('component stack', () => { let React; let act; let supportsOwnerStacks; before...
const Grandparent = () => <Parent />; const Parent = () => <Child />; const Child = () => { console.error('Test error.'); console.warn('Test warning.'); return null; }; act(() => render(<Grandparent />)); expect(
al') ) { supportsOwnerStacks = true; } }); const {render} = getVersionedRenderImplementation(); // @reactVersion >=16.9 it('should log the current component stack along with an error or warning', () => {
{ "filepath": "packages/react-devtools-shared/src/__tests__/componentStacks-test.js", "language": "javascript", "file_size": 3937, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {getVersionedRenderImplementation} from './utils'; describe('Store React.optimisticKey', () => { let act; let actAsync; let React; let TestRenderer; let bridge; let store; let BridgeContext; let...
=> { global.IS_REACT_ACT_ENVIRONMENT = true; store = global.store; bridge = global.bridge; React = require('react'); const utils = require('./utils'); act = utils.act; actAsync = utils.actAsync; TestRenderer = utils.requi
ototype.getClientRects = function (this: Element) { const textContent = this.textContent; return [ new DOMRect(1, 2, textContent.length, textContent.split('\n').length), ]; }; }); beforeEach(()
{ "filepath": "packages/react-devtools-shared/src/__tests__/optimisticKeyDevToolsIntegration.js", "language": "javascript", "file_size": 3387, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {getVersionedRenderImplementation} from './utils'; describe('Profiler change descriptions', () => { let React; let store; let utils; beforeEach(() => { utils = require('./utils'); utils.beforeE...
ntext(Context); return context; } function areEqual() { return true; } const MemoizedChild = React.memo(Child, areEqual); const ForwardRefChild = React.forwardRef( function RefForwardingComponent(props, ref) {
ionedRenderImplementation(); // @reactVersion >=18.0 it('should identify useContext as the cause for a re-render', () => { const Context = React.createContext(0); function Child() { const context = React.useCo
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilerChangeDescriptions-test.js", "language": "javascript", "file_size": 3921, "cut_index": 614, "middle_length": 229 }
Types = require('prop-types'); React = require('react'); }); const {render} = getVersionedRenderImplementation(); describe('props', () => { let committedClassProps; let committedFunctionProps; let inputRef; let classID; let functionID; let hostComponentID; async function mountTe...
}); return null; } inputRef = React.createRef(null); await utils.actAsync(() => render( <> <ClassComponent array={[1, 2, 3]} object={{nested: 'initial'}}
ittedClassProps = this.props; } render() { return null; } } function FunctionComponent(props) { React.useLayoutEffect(() => { committedFunctionProps = props;
{ "filepath": "packages/react-devtools-shared/src/__tests__/editing-test.js", "language": "javascript", "file_size": 29799, "cut_index": 1331, "middle_length": 229 }
= Scheduler.unstable_clearYields; const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; // polyfill waitFor as Scheduler.toFlushAndYieldThrough waitFor = expectedYields => { let actualYields = Scheduler.unstable_clearYields(); ...
} else { const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; waitFor = InternalTestUtils.waitFor; } setPerformanceMock = require('react-devtools-shared/src/backen
); } Scheduler.unstable_flushNumberOfYields(expectedYields.length); actualYields = Scheduler.unstable_clearYields(); expect(actualYields).toEqual(expectedYields); };
{ "filepath": "packages/react-devtools-shared/src/__tests__/preprocessData-test.js", "language": "javascript", "file_size": 79834, "cut_index": 3790, "middle_length": 229 }
const {printOwnersList} = require('../devtools/utils'); const {getVersionedRenderImplementation} = require('./utils'); describe('Store owners list', () => { let React; let act; let store; beforeEach(() => { store = global.store; store.collapseNodesByDefault = false; React = require('react'); ...
</div> </Intermediate> ); const Wrapper = ({children}) => children; const Leaf = () => <div>Leaf</div>; const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>; act(() => render(<Root />)); expect(store).toMatch
re.getOwnersListForElement(elementID); return printOwnersList(ownersList); } it('should drill through intermediate components', () => { const Root = () => ( <Intermediate> <div> <Leaf />
{ "filepath": "packages/react-devtools-shared/src/__tests__/storeOwners-test.js", "language": "javascript", "file_size": 6029, "cut_index": 716, "middle_length": 229 }
; const E = () => 'e'; const X = () => 'x'; const a = <A key="a" />; const b = <B key="b" />; const c = <C key="c" />; const d = <D key="d" />; const e = <E key="e" />; function Parent({children}) { return children; } // 1. Render a normal version of [a, b, c, d, e]. ...
const snapshotForABCDE = print(store); // 2. Render a version where <C /> renders an <X /> child instead of 'c'. // This is how we'll test an update to a single component. act(() => { setShowX(true); }); expect(store).toMatchInl
ineSnapshot(` [root] ▾ <Parent> <A key="a"> <B key="b"> <C key="c"> <D key="d"> <E key="e"> `); expect(container.textContent).toMatch('abcde');
{ "filepath": "packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js", "language": "javascript", "file_size": 40374, "cut_index": 2151, "middle_length": 229 }
import type Store from 'react-devtools-shared/src/devtools/store'; import {getVersionedRenderImplementation} from './utils'; describe('ProfilerStore', () => { let React; let store: Store; let utils; beforeEach(() => { global.IS_REACT_ACT_ENVIRONMENT = true; utils = require('./utils'); utils.befo...
async () => { const Parent = ({count}) => new Array(count) .fill(true) .map((_, index) => <Child key={index} duration={index} />); const Child = () => <div>Hi!</div>; utils.act(() => { render(<Parent key="A" count=
t} = getVersionedRenderImplementation(); const {render: renderOther, unmount: unmountOther} = getVersionedRenderImplementation(); // @reactVersion >= 16.9 it('should not remove profiling data when roots are unmounted',
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilerStore-test.js", "language": "javascript", "file_size": 7518, "cut_index": 716, "middle_length": 229 }
: Store; let utils; beforeEach(() => { utils = require('./utils'); utils.beforeEachProfiling(); store = global.store; store.collapseNodesByDefault = false; store.recordChangeDescriptions = true; React = require('react'); Scheduler = require('scheduler'); }); const {render} = getV...
tRankedChartData(rootID, commitIndex) { const commitTree = store.profilerStore.profilingCache.getCommitTree({ commitIndex, rootID, }); const chartData = store.profilerStore.profilingCache.getRankedChartData({ commitIndex,
tID, }); const chartData = store.profilerStore.profilingCache.getFlamegraphChartData( { commitIndex, commitTree, rootID, }, ); return {commitTree, chartData}; } function ge
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilingCharts-test.js", "language": "javascript", "file_size": 13105, "cut_index": 921, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import { getLegacyRenderImplementation, getModernRenderImplementation, } from './utils'; describe('profiling HostRoot', () => { let React; let Scheduler; let store; let utils; let getEffectDurations; l...
.beforEach() // The hook is installed as a read-only property on the window, // so for our test purposes we can just override the commit hook. const hook = global.__REACT_DEVTOOLS_GLOBAL_HOOK__; hook.onPostCommitFiberRoot = function onPostC
etEffectDurations; store = global.store; React = require('react'); Scheduler = require('scheduler'); effectDurations = []; passiveEffectDurations = []; // This is the DevTools hook installed by the env
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilingHostRoot-test.js", "language": "javascript", "file_size": 4515, "cut_index": 614, "middle_length": 229 }
t(() => render(<div />)); expect(store).toMatchInlineSnapshot(`[root]`); }); // This test is not the same cause as what's reported on GitHub, // but the resulting behavior (owner mounting after descendant) is the same. // Thec ase below is admittedly contrived and relies on side effects. // I'mnot yet su...
return Dynamic; }; const Child = () => null; await act(() => render( <> <React.Suspense fallback="Loading..."> <Owner /> </React.Suspense> <Parent /> </>, ), );
t mounts before its owner', async () => { const promise = new Promise(resolve => {}); let Dynamic = null; const Owner = () => { Dynamic = <Child />; readValue(promise); }; const Parent = () => {
{ "filepath": "packages/react-devtools-shared/src/__tests__/store-test.js", "language": "javascript", "file_size": 125653, "cut_index": 3790, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type Store from 'react-devtools-shared/src/devtools/store'; import {getVersionedRenderImplementation} from './utils'; describe('Store forcing errors', () => {...
(); // @reactVersion >= 18.0 it('resets forced error and fallback states when filters are changed', async () => { class AnyClassComponent extends React.Component { render() { return this.props.children; } } class Error
store.componentFilters = []; store.recordChangeDescriptions = true; React = require('react'); utils = require('./utils'); actAsync = utils.actAsync; }); const {render} = getVersionedRenderImplementation
{ "filepath": "packages/react-devtools-shared/src/__tests__/storeForceError-test.js", "language": "javascript", "file_size": 2442, "cut_index": 563, "middle_length": 229 }
e it('should handle a stress test with different tree operations (Legacy Mode)', () => { let setShowX; const A = () => 'a'; const B = () => 'b'; const C = () => { // We'll be manually flipping this component back and forth in the test. // We only do this for a single node in order to verif...
const e = <E key="e" />; function Parent({children}) { return children; } // 1. Render a normal version of [a, b, c, d, e]. act(() => render(<Parent>{[a, b, c, d, e]}</Parent>)); expect(store).toMatchInlineSnapshot(` [roo
return showX ? <X /> : 'c'; }; const D = () => 'd'; const E = () => 'e'; const X = () => 'x'; const a = <A key="a" />; const b = <B key="b" />; const c = <C key="c" />; const d = <D key="d" />;
{ "filepath": "packages/react-devtools-shared/src/__tests__/storeStressSync-test.js", "language": "javascript", "file_size": 43968, "cut_index": 2151, "middle_length": 229 }
on}) => { Scheduler.unstable_advanceTime(duration); return null; }; const MemoizedChild = React.memo(Child); const RootA = ({children}) => children; const RootB = ({children}) => children; const RootC = ({children}) => children; const containerA = document.createElement('div'); ...
rStore.startProfiling()); utils.act(() => legacyRender( <RootA> <Parent count={3} /> </RootA>, containerA, ), ); utils.act(() => legacyRender( <RootC> <Parent count={1} />
</RootA>, containerA, ), ); utils.act(() => legacyRender( <RootB> <Parent count={1} /> </RootB>, containerB, ), ); utils.act(() => store.profile
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilingCache-test.js", "language": "javascript", "file_size": 39492, "cut_index": 2151, "middle_length": 229 }
import type Store from 'react-devtools-shared/src/devtools/store'; import {getVersionedRenderImplementation} from './utils'; describe('commit tree', () => { let React = require('react'); let Scheduler; let store: Store; let utils; beforeEach(() => { utils = require('./utils'); utils.beforeEachProfi...
e(10); return new Array(count) .fill(true) .map((_, index) => <Child key={index} />); }; const Child = React.memo(function Child() { Scheduler.unstable_advanceTime(2); return null; }); utils.act(() => stor
); const {render} = getVersionedRenderImplementation(); // @reactVersion >= 16.9 it('should be able to rebuild the store tree for each commit', () => { const Parent = ({count}) => { Scheduler.unstable_advanceTim
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilingCommitTreeBuilder-test.js", "language": "javascript", "file_size": 7787, "cut_index": 716, "middle_length": 229 }
tent; return [ new DOMRect(1, 2, textContent.length, textContent.split('\n').length), ]; }; }); beforeEach(() => { agent = global.agent; bridge = global.bridge; store = global.store; store.collapseNodesByDefault = false; store.componentFilters = []; store.recordChang...
xpect(() => (store.componentFilters = [])).toThrow( 'Cannot modify filter preferences while profiling', ); }); // @reactVersion >= 16.0 it('should support filtering by element type', async () => { class ClassComponent extends React.Com
onst {render} = getVersionedRenderImplementation(); // @reactVersion >= 16.0 it('should throw if filters are updated while profiling', async () => { await actAsync(async () => store.profilerStore.startProfiling()); e
{ "filepath": "packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js", "language": "javascript", "file_size": 25743, "cut_index": 1331, "middle_length": 229 }
ared/src/devtools/views/Profiler/ProfilerContext').ProfilerContext; ProfilerContextController = require('react-devtools-shared/src/devtools/views/Profiler/ProfilerContext').ProfilerContextController; StoreContext = require('react-devtools-shared/src/devtools/views/context').StoreContext; TreeCon...
plementation(); const Contexts = ({ children = null, defaultInspectedElementID = null, defaultInspectedElementIndex = null, }: any) => ( <BridgeContext.Provider value={bridge}> <StoreContext.Provider value={store}> <TreeC
vtools/views/Components/TreeContext').TreeDispatcherContext; TreeStateContext = require('react-devtools-shared/src/devtools/views/Components/TreeContext').TreeStateContext; }); const {render} = getVersionedRenderIm
{ "filepath": "packages/react-devtools-shared/src/__tests__/profilerContext-test.js", "language": "javascript", "file_size": 35587, "cut_index": 2151, "middle_length": 229 }
import {CustomConsole} from '@jest/console'; import type { BackendBridge, FrontendBridge, } from 'react-devtools-shared/src/bridge'; const {getTestFlags} = require('../../../../scripts/jest/TestFlags'); // Argument is serialized when passed from jest-cli script through to setupTests. const compactConsole = proce...
stToFail = async (callback, error) => { if (callback.length > 0) { throw Error( 'Gated test helpers do not support the `done` callback. Return a ' + 'promise instead.', ); } try { const maybePromise = callback(); if (
case 'warn': return '\x1b[33m' + message + '\x1b[0m'; case 'log': default: return message; } }; global.console = new CustomConsole(process.stdout, process.stderr, formatter); } const expectTe
{ "filepath": "packages/react-devtools-shared/src/__tests__/setupTests.js", "language": "javascript", "file_size": 9153, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; const semver = require('semver'); let shouldPass; let isFocused; describe('transform-react-version-pragma', () => { const originalTest = test; // eslint-disable-next-line no-unused-vars const _test_react_vers...
rgs); }); }; // eslint-disable-next-line no-unused-vars const _test_ignore_for_react_version = (testName, cb) => { originalTest(testName, (...args) => { shouldPass = false; return cb(...args); }); }; beforeEach(() => {
ext-line no-unused-vars const _test_react_version_focus = (range, testName, cb) => { originalTest(testName, (...args) => { shouldPass = !!semver.satisfies('18.0.0', range); isFocused = true; return cb(...a
{ "filepath": "packages/react-devtools-shared/src/__tests__/transform-react-version-pragma-test.js", "language": "javascript", "file_size": 3363, "cut_index": 614, "middle_length": 229 }
import {getVersionedRenderImplementation} from './utils'; describe('useEditableValue', () => { let act; let React; let useEditableValue; beforeEach(() => { const utils = require('./utils'); act = utils.act; React = require('react'); useEditableValue = require('../devtools/views/hooks').useEd...
expect(state.parsedValue).toEqual(NaN); expect(state.hasPendingChanges).toBe(false); expect(state.isValid).toBe(true); }); it('should override editable state when external props are updated', () => { let state; function Example({value
const tuple = useEditableValue(value); state = tuple[0]; return null; } act(() => render(<Example />)); expect(state.editableValue).toEqual('NaN'); expect(state.externalValue).toEqual(NaN);
{ "filepath": "packages/react-devtools-shared/src/__tests__/useEditableValue-test.js", "language": "javascript", "file_size": 5445, "cut_index": 716, "middle_length": 229 }
d/src/devtools/store'; import type {ProfilingDataFrontend} from 'react-devtools-shared/src/devtools/views/Profiler/types'; import type {ElementType} from 'react-devtools-shared/src/frontend/types'; import type {Node as ReactNode} from 'react'; import {ReactVersion} from '../../../../ReactVersions'; const requestedRea...
'18.0.0')) { const ReactDOMTestUtils = require('react-dom/test-utils'); return ReactDOMTestUtils.act; } const React = require('react'); // This is for React 18, where act was distributed in react as unstable. if (React.unstable_act) {
semver.lt(requestedReactVersion, '17.0.0')) { require('react-dom/test-utils'); return cb => cb(); } // This is for React < 18, where act was distributed in react-dom/test-utils. if (semver.lt(requestedReactVersion,
{ "filepath": "packages/react-devtools-shared/src/__tests__/utils.js", "language": "javascript", "file_size": 13195, "cut_index": 921, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // `test` is part of Jest's serializer API export function test(maybeDehydratedValue) { const {meta} = require('react-de...
const {meta} = require('react-devtools-shared/src/hydration'); const indentation = Math.max(indent('.').indexOf('.') - 2, 0); const paddingLeft = ' '.repeat(indentation); return ( 'Dehydrated {\n' + paddingLeft + ' "preview_short": ' +
tedValue === 'object' && hasOwnProperty(meta.inspectable) && maybeDehydratedValue[meta.inspected] !== true ); } // print() is part of Jest's serializer API export function print(dehydratedValue, serialize, indent) {
{ "filepath": "packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js", "language": "javascript", "file_size": 1187, "cut_index": 518, "middle_length": 229 }
printStore} from 'react-devtools-shared/src/devtools/utils'; // `test` is part of Jest's serializer API export function test(maybeStore) { // It's important to lazy-require the Store rather than imported at the head of the module. // Because we reset modules between tests, different Store implementations will be u...
t function print(store, serialize, indent, includeSuspense = true) { return printStore(store, false, null, includeSuspense); } // Used for Jest snapshot testing. // May also be useful for visually debugging the tree, so it lives on the Store. export {pr
} // print() is part of Jest's serializer API expor
{ "filepath": "packages/react-devtools-shared/src/__tests__/__serializers__/storeSerializer.js", "language": "javascript", "file_size": 839, "cut_index": 520, "middle_length": 52 }
let ReactDOM; let bridge: FrontendBridge; let store: Store; const act = (callback: Function) => { callback(); jest.runAllTimers(); // Flush Bridge operations }; const flushPendingUpdates = () => { jest.runOnlyPendingTimers(); }; beforeEach(() => { bridge = global.bridge; store =...
dom.js'), ); React = require('react'); ReactDOM = require('react-dom'); }); describe('props', () => { let committedProps; let id; function mountTestApp() { class ClassComponent extends React.Component { componen
doesn't enable us to mock deep imports (e.g. "react/lib/Something"). jest.mock('react', () => jest.requireActual('react-15/dist/react.js')); jest.mock('react-dom', () => jest.requireActual('react-dom-15/dist/react-
{ "filepath": "packages/react-devtools-shared/src/__tests__/legacy/editing-test.js", "language": "javascript", "file_size": 16697, "cut_index": 921, "middle_length": 229 }
pectElement(bridge, false, id, path, rendererID) .then(data => backendAPI.convertInspectedElementBackendToFrontend(data.value), ); jest.runOnlyPendingTimers(); return promise; } beforeEach(() => { bridge = global.bridge; store = global.store; backendAPI = require('react-d...
equire('react-dom'); }); // @reactVersion >= 16.0 it('should inspect the currently selected element', async () => { const Example = () => null; act(() => ReactDOM.render( React.createElement(Example, {a: 1, b: 'abc'}),
ng"). jest.mock('react', () => jest.requireActual('react-15/dist/react.js')); jest.mock('react-dom', () => jest.requireActual('react-dom-15/dist/react-dom.js'), ); React = require('react'); ReactDOM = r
{ "filepath": "packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js", "language": "javascript", "file_size": 24122, "cut_index": 1331, "middle_length": 229 }
ng order within group', () => { const nodeToData = new Map([ [ {id: 1}, { rect: {left: 0, top: 0, width: 100, height: 100}, color: '#80b393', displayName: 'Node1', count: 3, }, ], [ {id: 2}, { rect: {left: 0,...
eft: 0, top: 0, width: 100, height: 100}, color: '#63b19e', displayName: 'Node2', count: 2, }, ], ]); }); test('should sort groups by lowest count in each group', () => { const nodeToData = new Map([
; expect(result).toEqual([ [ { rect: {left: 0, top: 0, width: 100, height: 100}, color: '#80b393', displayName: 'Node1', count: 3, }, { rect: {l
{ "filepath": "packages/react-devtools-shared/src/__tests__/traceUpdates-test.js", "language": "javascript", "file_size": 6053, "cut_index": 716, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {useState, useEffect} from 'react'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; // Event...
onPanelHidden() { setIsVisible(false); } bridge.addListener('extensionComponentsPanelShown', onPanelShown); bridge.addListener('extensionComponentsPanelHidden', onPanelHidden); return () => { bridge.removeListener('extensionC
ion useExtensionComponentsPanelVisibility( bridge: FrontendBridge, ): boolean { const [isVisible, setIsVisible] = useState(true); useEffect(() => { function onPanelShown() { setIsVisible(true); } function
{ "filepath": "packages/react-devtools-shared/src/frontend/hooks/useExtensionComponentsPanelVisibility.js", "language": "javascript", "file_size": 1164, "cut_index": 518, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {HostInstance} from './types'; // Some environments (e.g. React Native / Hermes) don't support the performance API yet. export c...
// So we need to detect this and use that as the public instance. // React Native. Modern. Fabric. if (typeof instance === 'object' && instance !== null) { if (typeof instance.canonical === 'object' && instance.canonical !== null) { if (
now(); // Ideally, this should be injected from Reconciler config export function getPublicInstance(instance: HostInstance): HostInstance { // Typically the PublicInstance and HostInstance is the same thing but not in Fabric.
{ "filepath": "packages/react-devtools-shared/src/backend/DevToolsNativeHost.js", "language": "javascript", "file_size": 1847, "cut_index": 537, "middle_length": 229 }
d: number, path: Array<string | number>, rendererID: number, }; type InspectElementParams = { forceFullData: boolean, id: number, path: Array<string | number> | null, rendererID: number, requestID: number, }; type InspectScreenParams = { forceFullData: boolean, id: number, path: Array<string | num...
PathType, hookID?: ?number, id: number, path: Array<string | number>, rendererID: number, }; type RenamePathParams = { type: PathType, hookID?: ?number, id: number, oldPath: Array<string | number>, newPath: Array<string | number>, rend
}; type SetInParams = { id: number, path: Array<string | number>, rendererID: number, wasForwarded?: boolean, value: any, }; type PathType = 'props' | 'hooks' | 'state' | 'context'; type DeletePathParams = { type:
{ "filepath": "packages/react-devtools-shared/src/backend/agent.js", "language": "javascript", "file_size": 38644, "cut_index": 2151, "middle_length": 229 }
SCHEDULING_PROFILER_VERSION, } from 'react-devtools-timeline/src/constants'; import {describeFiber} from './fiber/DevToolsFiberComponentStack'; // Add padding to the start/stop time of the profile. // This makes the UI nicer to use. const TIME_OFFSET = 10; let performanceTarget: Performance | null = null; // If per...
detail?: mixed, startTime?: number, } = {}; Object.defineProperty(markOptions, 'startTime', { get: function () { supportsUserTimingV3 = true; return 0; }, set: function () {}, }); try { performance.mark(CHECK_V3
ormance.mark === 'function' && // $FlowFixMe[method-unbinding] typeof performance.clearMarks === 'function'; let supportsUserTimingV3 = false; if (supportsUserTiming) { const CHECK_V3_MARK = '__v3'; const markOptions: {
{ "filepath": "packages/react-devtools-shared/src/backend/profilingHooks.js", "language": "javascript", "file_size": 28754, "cut_index": 1331, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {StyleXPlugin} from 'react-devtools-shared/src/frontend/types'; import isArray from 'react-devtools-shared/src/isArray'; const cachedStyleNameToValueMap: Map<string, string> = new Map(); export function g...
if (entry == null) { return; } if (isArray(entry)) { crawlData(entry, sources, resolvedStyles); } else { crawlObjectProperties(entry, sources, resolvedStyles); } }); } else { crawlObjectProp
es).sort(), resolvedStyles, }; } export function crawlData( data: any, sources: Set<string>, resolvedStyles: Object, ): void { if (data == null) { return; } if (isArray(data)) { data.forEach(entry => {
{ "filepath": "packages/react-devtools-shared/src/backend/StyleX/utils.js", "language": "javascript", "file_size": 3331, "cut_index": 614, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {InternalInstance} from './renderer'; export function decorate(object: Object, attr: string, fn: Function): Functio...
fns) { olds[name] = decorate(source, name, fns[name]); } return olds; } export function restoreMany(source: Object, olds: Object): void { for (const name in olds) { source[name] = olds[name]; } } // $FlowFixMe[missing-this-annot] webpack
return fn.call(this, old, arguments); }; return old; } export function decorateMany( source: Object, fns: {[attr: string]: Function, ...}, ): Object { const olds: {[string]: $FlowFixMe} = {}; for (const name in
{ "filepath": "packages/react-devtools-shared/src/backend/legacy/utils.js", "language": "javascript", "file_size": 1405, "cut_index": 524, "middle_length": 229 }
import type {Data} from './index'; import type {Rect} from '../utils'; import type {HostInstance} from '../../types'; import type Agent from '../../agent'; import {isReactNativeEnvironment} from 'react-devtools-shared/src/backend/utils'; // Note these colors are in sync with DevTools Profiler chart colors. const COLO...
w); const mergedNodes = groupAndSortNodes(nodeToData); agent.emit('drawGroupedTraceUpdatesWithNames', mergedNodes); } function drawWeb(nodeToData: Map<HostInstance, Data>) { if (canvas === null) { initialize(); } const dpr = window.deviceP
ion drawNative(nodeToData: Map<HostInstance, Data>, agent: Agent) { const nodesToDraw = []; iterateNodes(nodeToData, ({color, node}) => { nodesToDraw.push({node, color}); }); agent.emit('drawTraceUpdates', nodesToDra
{ "filepath": "packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js", "language": "javascript", "file_size": 6899, "cut_index": 716, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type Agent from 'react-devtools-shared/src/backend/agent'; import type {HostInstance} from '../../types'; import {isReactNativeEnviro...
function hideOverlay(agent: Agent): void { return isReactNativeEnvironment() ? hideOverlayNative(agent) : hideOverlayWeb(); } function showOverlayNative( elements: $ReadOnlyArray<HostInstance>, agent: Agent, ): void { agent.emit('showNati
l; function hideOverlayNative(agent: Agent): void { agent.emit('hideNativeHighlight'); } function hideOverlayWeb(): void { timeoutID = null; if (overlay !== null) { overlay.remove(); overlay = null; } } export
{ "filepath": "packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js", "language": "javascript", "file_size": 1850, "cut_index": 537, "middle_length": 229 }
rom 'react'; import {symbolicateSource} from '../symbolicateSource'; describe('utils', () => { describe('getDisplayName', () => { // @reactVersion >= 16.0 it('should return a function name', () => { function FauxComponent() {} expect(getDisplayName(FauxComponent)).toEqual('FauxComponent'); })...
toEqual('Fallback'); }); // @reactVersion >= 16.0 it('should return Anonymous for anonymous functions without a fallback', () => { expect(getDisplayName(() => {})).toEqual('Anonymous'); }); // Simulate a reported bug: // htt
expect(getDisplayName(FauxComponent)).toEqual('OverrideDisplayName'); }); // @reactVersion >= 16.0 it('should return the fallback for anonymous functions', () => { expect(getDisplayName(() => {}, 'Fallback')).
{ "filepath": "packages/react-devtools-shared/src/__tests__/utils-test.js", "language": "javascript", "file_size": 17403, "cut_index": 1331, "middle_length": 229 }
nspectedElement) { if ( maybeInspectedElement === null || typeof maybeInspectedElement !== 'object' ) { return false; } const hasOwnProperty = Object.prototype.hasOwnProperty.bind( maybeInspectedElement, ); return ( hasOwnProperty('canEditFunctionProps') && hasOwnProperty('canEditH...
uld break nested serializers. return serialize({ context: inspectedElement.context, events: inspectedElement.events, hooks: inspectedElement.hooks, id: inspectedElement.id, owners: inspectedElement.owners, props: inspectedElement.
indent) { // Don't stringify this object; that wo
{ "filepath": "packages/react-devtools-shared/src/__tests__/__serializers__/inspectedElementSerializer.js", "language": "javascript", "file_size": 981, "cut_index": 582, "middle_length": 52 }
ctDOM = require('react-dom'); }); it('should not allow a root node to be collapsed', () => { const Component = () => React.createElement('div', null, 'Hi'); act(() => ReactDOM.render( React.createElement(Component, { count: 4, }), document.createElement('div'), ...
se; }); it('should support mount and update operations', () => { const Grandparent = ({count}) => React.createElement( 'div', null, React.createElement(Parent, { count: count, }),
expect(() => store.toggleIsCollapsed(rootID, true)).toThrow( 'Root nodes cannot be collapsed', ); }); describe('collapseNodesByDefault:false', () => { beforeEach(() => { store.collapseNodesByDefault = fal
{ "filepath": "packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js", "language": "javascript", "file_size": 26988, "cut_index": 1331, "middle_length": 229 }
backwards compatibility when making changes. */ import type { Dehydrated, Unserializable, } from 'react-devtools-shared/src/hydration'; import type {ReactFunctionLocation, ReactStackTrace} from 'shared/ReactTypes'; import type {UnknownSuspendersReason} from '../constants'; export type BrowserTheme = 'dark' | 'l...
rather than re-ordering existing ones. // // Changing these types is also a backwards breaking change for the standalone shell, // since the frontend and backend must share the same values- // and the backend is embedded in certain environments (like Reac
// WARNING // The values below are referenced by ComponentFilters (which are saved via localStorage). // Do not change them or it will break previously saved user customizations. // If new element types are added, use new numbers
{ "filepath": "packages/react-devtools-shared/src/frontend/types.js", "language": "javascript", "file_size": 10485, "cut_index": 921, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import Agent from './agent'; import type {DevToolsHook, RendererID, RendererInterface} from './types'; export type InitBackend = typeof initBackend; export function...
; // Now that the Store and the renderer interface are connected, // it's time to flush the pending operation codes to the frontend. rendererInterface.flushInitialOperations(); } const subs = [ hook.sub( 'renderer-attached',
s page (maybe b'c of the contentType). return () => {}; } function registerRendererInterface( id: RendererID, rendererInterface: RendererInterface, ) { agent.registerRendererInterface(id, rendererInterface)
{ "filepath": "packages/react-devtools-shared/src/backend/index.js", "language": "javascript", "file_size": 2737, "cut_index": 563, "middle_length": 229 }
leEditor/setupNativeStyleEditor'; import type {InitBackend} from 'react-devtools-shared/src/backend'; import type {TimelineDataExport} from 'react-devtools-timeline/src/types'; import type {BackendBridge} from 'react-devtools-shared/src/bridge'; import type {ReactFunctionLocation, ReactStackTrace} from 'shared/ReactTyp...
tineHandlerPhase: WorkTag, DehydratedSuspenseComponent: WorkTag, ForwardRef: WorkTag, Fragment: WorkTag, FunctionComponent: WorkTag, HostComponent: WorkTag, HostPortal: WorkTag, HostRoot: WorkTag, HostHoistable: WorkTag, HostSingleton: Wo
Flags = number; export type ExpirationTime = number; export type WorkTagMap = { CacheComponent: WorkTag, ClassComponent: WorkTag, ContextConsumer: WorkTag, ContextProvider: WorkTag, CoroutineComponent: WorkTag, Corou
{ "filepath": "packages/react-devtools-shared/src/backend/types.js", "language": "javascript", "file_size": 18122, "cut_index": 1331, "middle_length": 229 }
{ if (internalInstance._currentElement.key) { key = String(internalInstance._currentElement.key); } const elementType = internalInstance._currentElement.type; if (typeof elementType === 'string') { displayName = elementType; } else if (typeof elementType === 'function') { display...
Instance.getPublicInstance(); if (publicInstance !== null) { return ElementTypeClass; } else { return ElementTypeFunction; } } else if (typeof elementType === 'string') { return ElementTypeHostComponent; }
here to catch undefined and null if (internalInstance._currentElement != null) { const elementType = internalInstance._currentElement.type; if (typeof elementType === 'function') { const publicInstance = internal
{ "filepath": "packages/react-devtools-shared/src/backend/legacy/renderer.js", "language": "javascript", "file_size": 39014, "cut_index": 2151, "middle_length": 229 }
tils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'})); utils.act(() => renderer.update(<Contexts />)); expect(state).toMatchInlineSnapshot(` [root] ▾ <Grandparent> → ▾ <Parent> <Child> <Child> `); utils.act(() => dispatch...
nlineSnapshot(` [root] ▾ <Grandparent> ▾ <Parent> <Child> → <Child> `); // Test stepping back to the beginning utils.act(() => dispatch({type: 'SELECT_PREVIOUS_ELEMENT_IN_T
▾ <Parent> → <Child> <Child> `); utils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'})); utils.act(() => renderer.update(<Contexts />)); expect(state).toMatchI
{ "filepath": "packages/react-devtools-shared/src/__tests__/treeContext-test.js", "language": "javascript", "file_size": 73687, "cut_index": 3790, "middle_length": 229 }
ame(hook) { const fileName = hook.hookSource ? hook.hookSource.fileName : null; if (fileName == null) { return false; } else { return fileName.indexOf('/react-devtools-shared/') > 0; } } function serializeHook(hook) { if (!hook.hookSource) return hook; // Remove user-specific portions of this file...
tests. columnNumber: 'removed by Jest serializer', lineNumber: 'removed by Jest serializer', }, subHooks, }; } // `test` is part of Jest's serializer API export function test(maybeHook) { if (maybeHook === null || typeof maybeHook
(subHooks) { subHooks = subHooks.map(serializeHook); } return { ...hook, hookSource: { ...hook.hookSource, fileName, // Otherwise changes in any test case or formatting might invalidate other
{ "filepath": "packages/react-devtools-shared/src/__tests__/__serializers__/hookSerializer.js", "language": "javascript", "file_size": 1610, "cut_index": 537, "middle_length": 229 }
m 'react-devtools-shared/src/devtools/utils'; // `test` is part of Jest's serializer API export function test(maybeState) { if (maybeState === null || typeof maybeState !== 'object') { return false; } const hasOwnProperty = Object.prototype.hasOwnProperty.bind(maybeState); // Duck typing at its finest. ...
// This is a big of a hack but it works around having to pass in a meta object e.g. {store, state}. // DevTools tests depend on a global Store object anyway (initialized via setupTest). const store = global.store; return printStore(store, false, sta
export function print(state, serialize, indent) {
{ "filepath": "packages/react-devtools-shared/src/__tests__/__serializers__/treeContextStateSerializer.js", "language": "javascript", "file_size": 850, "cut_index": 535, "middle_length": 52 }
describe('Stylex plugin utils', () => { let getStyleXData; let styleElements; function defineStyles(style) { const styleElement = document.createElement('style'); styleElement.type = 'text/css'; styleElement.appendChild(document.createTextNode(style)); styleElements.push(styleElement); docu...
}, "sources": [], } `); expect(getStyleXData(undefined)).toMatchInlineSnapshot(` { "resolvedStyles": {}, "sources": [], } `); expect(getStyleXData('')).toMatchInlineSnapshot(` { "res
ach(styleElement => { document.head.removeChild(styleElement); }); }); it('should gracefully handle empty values', () => { expect(getStyleXData(null)).toMatchInlineSnapshot(` { "resolvedStyles": {
{ "filepath": "packages/react-devtools-shared/src/backend/StyleX/__tests__/utils-test.js", "language": "javascript", "file_size": 5438, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import Agent from 'react-devtools-shared/src/backend/agent'; import {destroy as destroyCanvas, draw} from './canvas'; import {extractHOCNames, getNestedBoundingClientRect} from '../utils'; import type {HostInstance} f...
fferent types of HOCs const HOC_MARKERS = new Map([ ['Forget', '✨'], ['Memo', '🧠'], ]); // Some environments (e.g. React Native / Hermes) don't support the performance API yet. const getCurrentTime = // $FlowFixMe[method-unbinding] typeof performa
/ This can be important if we're getting a flurry of events (e.g. scroll update). const MAX_DISPLAY_DURATION = 3000; // How long should a rect be considered valid for? const REMEASUREMENT_AFTER_DURATION = 250; // Markers for di
{ "filepath": "packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js", "language": "javascript", "file_size": 4413, "cut_index": 614, "middle_length": 229 }
// This is a DevTools fork of ReactFiberComponentStack. // This fork enables DevTools to use the same "native" component stack format, // while still maintaining support for multiple renderer versions // (which use different values for ReactTypeOfWork). import type {Fiber} from 'react-reconciler/src/ReactInternalTypes...
rkTagMap, workInProgress: Fiber, currentDispatcherRef: CurrentDispatcherRef, ): string { const { HostHoistable, HostSingleton, HostComponent, LazyComponent, SuspenseComponent, SuspenseListComponent, FunctionComponent,
onentFrame, describeClassComponentFrame, describeDebugInfoFrame, } from '../shared/DevToolsComponentStackFrame'; import {formatOwnerStack} from '../shared/DevToolsOwnerStack'; export function describeFiber( workTagMap: Wo
{ "filepath": "packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js", "language": "javascript", "file_size": 7772, "cut_index": 716, "middle_length": 229 }
export interface Rect { bottom: number; height: number; left: number; right: number; top: number; width: number; } // Get the window object for the document that a node belongs to, // or return null if it cannot be found (node not attached to DOM, // etc). export function getOwnerWindow(node: HTMLElement):...
Get a bounding client rect for a node, with an // offset added to compensate for its border. export function getBoundingClientRectWithBorderOffset(node: HTMLElement): Rect { const dimensions = getElementDimensions(node); // $FlowFixMe[incompatible-var
nd (node not within iframe, etc). export function getOwnerIframe(node: HTMLElement): HTMLElement | null { const nodeWindow = getOwnerWindow(node); if (nodeWindow) { return nodeWindow.frameElement; } return null; } //
{ "filepath": "packages/react-devtools-shared/src/backend/views/utils.js", "language": "javascript", "file_size": 5211, "cut_index": 716, "middle_length": 229 }
t type {HostInstance} from 'react-devtools-shared/src/backend/types'; import type {BackendBridge} from 'react-devtools-shared/src/bridge'; import type {RendererInterface} from '../../types'; // This plug-in provides in-page highlighting of the selected element. // It is used by the browser extension and the standalone...
, clearHostInstanceHighlight); bridge.addListener('highlightHostInstance', highlightHostInstance); bridge.addListener('highlightHostInstances', highlightHostInstances); bridge.addListener('scrollToHostInstance', scrollToHostInstance); bridge.addLis
isteningTo: Set<HTMLIFrameElement> = new Set(); let inspectOnlySuspenseNodes = false; export default function setupHighlighter( bridge: BackendBridge, agent: Agent, ): void { bridge.addListener('clearHostInstanceHighlight'
{ "filepath": "packages/react-devtools-shared/src/backend/views/Highlighter/index.js", "language": "javascript", "file_size": 15398, "cut_index": 921, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {BoxStyle} from './types'; /** * This mirrors react-native/Libraries/Inspector/resolveBoxStyle.js (but without RTL support). * * Resolve a style proper...
eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const key of Object.keys(result)) { result[key] = styleForAll; } hasParts = true; } const styleForHorizontal = style[prefix + 'Horizontal']; if (styleForHorizontal != nu
refix: string, style: Object, ): BoxStyle | null { let hasParts = false; const result = { bottom: 0, left: 0, right: 0, top: 0, }; const styleForAll = style[prefix]; if (styleForAll != null) { //
{ "filepath": "packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js", "language": "javascript", "file_size": 2334, "cut_index": 563, "middle_length": 229 }
which use different values for ReactTypeOfWork). import type {CurrentDispatcherRef} from '../types'; // The shared console patching code is DEV-only. // We can't use it since DevTools only ships production builds. import {disableLogs, reenableLogs} from './DevToolsConsolePatching'; let prefix; export function descri...
FOX__) { suffix = '@unknown:0:0'; } // We use the prefix to ensure our stacks line up with native stack frames. // We use a suffix to ensure it gets parsed natively. return '\n' + prefix + name + suffix; } export function describeDebugInfoFram
nst match = x.stack.trim().match(/\n( *(at )?)/); prefix = (match && match[1]) || ''; } } let suffix = ''; if (__IS_CHROME__ || __IS_EDGE__ || __IS_NATIVE__) { suffix = ' (<anonymous>)'; } else if (__IS_FIRE
{ "filepath": "packages/react-devtools-shared/src/backend/shared/DevToolsComponentStackFrame.js", "language": "javascript", "file_size": 11892, "cut_index": 921, "middle_length": 229 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // This keeps track of Server Component logs which may come from. // This is in a shared module because Server Component logs don't come from a specific renderer // but can become associ...
// This keeps it around as long as the ComponentInfo is alive which // lets the Fiber get reparented/remounted and still observe the previous errors/warnings. // Unless we explicitly clear the logs from a Fiber. export const componentInfoToComponentLogsM
gs: Map<string, number>, warningsCount: number, };
{ "filepath": "packages/react-devtools-shared/src/backend/shared/DevToolsServerComponentLogs.js", "language": "javascript", "file_size": 961, "cut_index": 582, "middle_length": 52 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // This list should be kept updated to reflect additions to 'shared/ReactSymbols'. // DevTools can't import symbols from 'shared/ReactSymbols' directly for two reasons...
t const CONTEXT_NUMBER = 0xeace; export const CONTEXT_SYMBOL_STRING = 'Symbol(react.context)'; export const SERVER_CONTEXT_SYMBOL_STRING = 'Symbol(react.server_context)'; export const DEPRECATED_ASYNC_MODE_SYMBOL_STRING = 'Symbol(react.async_mode)'; exp
ce e.g. standalone DevTools runs in a separate process, it can't rely on its own ES capabilities. export const CONCURRENT_MODE_NUMBER = 0xeacf; export const CONCURRENT_MODE_SYMBOL_STRING = 'Symbol(react.concurrent_mode)'; expor
{ "filepath": "packages/react-devtools-shared/src/backend/shared/ReactSymbols.js", "language": "javascript", "file_size": 2949, "cut_index": 563, "middle_length": 229 }
* Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {PermissionNotGrantedError} from 'react-devtools-shared/src/errors/PermissionNotGrantedError'; type SupportedPe...
issionsOptions, callback: T, ): T | (() => Promise<ReturnType<T>>) { if (!__IS_CHROME__ && !__IS_EDGE__) { return callback; } else { return async () => { const granted = await chrome.permissions.request(options); if (granted) {
Firefox // https://bugzilla.mozilla.org/show_bug.cgi?id=1796933 // We are going to assume that requested permissions are not optional. export function withPermissionsCheck<T: (...$ReadOnlyArray<empty>) => mixed>( options: Perm
{ "filepath": "packages/react-devtools-shared/src/frontend/utils/withPermissionsCheck.js", "language": "javascript", "file_size": 1109, "cut_index": 515, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // This is a DevTools fork of shared/ConsolePatchingDev. // The shared console patching code is DEV-only. // We can't use it since DevTools only ships production build...
g() {} disabledLog.__reactDisabledLog = true; export function disableLogs(): void { if (disabledDepth === 0) { prevLog = console.log; prevInfo = console.info; prevWarn = console.warn; prevError = console.error; prevGroup = console.gr
ction was extracted eagerly. // We could also eagerly patch the method. let disabledDepth = 0; let prevLog; let prevInfo; let prevWarn; let prevError; let prevGroup; let prevGroupCollapsed; let prevGroupEnd; function disabledLo
{ "filepath": "packages/react-devtools-shared/src/backend/shared/DevToolsConsolePatching.js", "language": "javascript", "file_size": 2505, "cut_index": 563, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useCallback} from 'react'; import Icon from './Icon'; import styles from './TabBar.css'; import Tooltip from './Components/reach-ui/tooltip'; import type {IconType} f...
React.Node { if (!tabs.some(tab => tab !== null && tab.id === currentTab)) { const firstTab = ((tabs.find(tab => tab !== null): any): TabInfo); selectTab(firstTab.id); } const onChange = useCallback( ({currentTarget}: $FlowFixMe) => sel
(tabID: any) => void, tabs: Array<TabInfo | null>, type: 'navigation' | 'profiler' | 'settings', }; export default function TabBar({ currentTab, disabled = false, id: groupName, selectTab, tabs, type, }: Props):
{ "filepath": "packages/react-devtools-shared/src/devtools/views/TabBar.js", "language": "javascript", "file_size": 3507, "cut_index": 614, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // This is a DevTools fork of ReactComponentInfoStack. // This fork enables DevTools to use the same "native" component stack format, // whil...
{ try { let info = ''; // The owner stack of the current component will be where it was created, i.e. inside its owner. // There's no actual name of the currently executing component. Instead, that is available // on the regular stack th
ltInComponentFrame} from '../shared/DevToolsComponentStackFrame'; import {formatOwnerStack} from '../shared/DevToolsOwnerStack'; export function getOwnerStackByComponentInfoInDev( componentInfo: ReactComponentInfo, ): string
{ "filepath": "packages/react-devtools-shared/src/backend/flight/DevToolsComponentInfoStack.js", "language": "javascript", "file_size": 1912, "cut_index": 537, "middle_length": 229 }
th('Error: react-stack-top-frame\n')) { // V8's default formatting prefixes with the error message which we // don't want/need. stack = stack.slice(29); } let idx = stack.indexOf('react_stack_bottom_frame'); if (idx === -1) { idx = stack.indexOf('react-stack-bottom-frame'); } if (idx !== -1) {...
aller. for (let i = skipFrames; i < frames.length; i++) { const parsed = chromeFrameRegExp.exec(frames[i]); if (!parsed) { continue; } let name = parsed[1] || ''; let isAsync = parsed[8] === 'async '; if (name === '<anonymou
= stack.split('\n'); const parsedFrames: ReactStackTrace = []; // We skip top frames here since they may or may not be parseable but we // want to skip the same number of frames regardless. I.e. we can't do it // in the c
{ "filepath": "packages/react-devtools-shared/src/backend/utils/parseStackTrace.js", "language": "javascript", "file_size": 12016, "cut_index": 921, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ /************************************************************************ * This file is forked between different DevTools impl...
**************************************************** * Do not edit the code below. * It ensures this fork exports the same types as the default flags file. ************************************************************************/ import typeof * as Fea
****/ export const enableActivitySlices: boolean = false; export const enableLogger: boolean = true; export const enableStyleXFeatures: boolean = true; export const isInternalFacebookBuild: boolean = true; /********************
{ "filepath": "packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js", "language": "javascript", "file_size": 1273, "cut_index": 524, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ /************************************************************************ * This file is forked between different DevTools impl...
**************************************************** * Do not edit the code below. * It ensures this fork exports the same types as the default flags file. ************************************************************************/ import typeof * as Fea
****/ export const enableActivitySlices: boolean = false; export const enableLogger: boolean = true; export const enableStyleXFeatures: boolean = true; export const isInternalFacebookBuild: boolean = true; /********************
{ "filepath": "packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js", "language": "javascript", "file_size": 1278, "cut_index": 524, "middle_length": 229 }
ort {logEvent} from 'react-devtools-shared/src/Logger'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type {ProfilingDataBackend} from 'react-devtools-shared/src/backend/types'; import type { CommitDataFrontend, ProfilingDataForRootFrontend, ProfilingDataFrontend, SnapshotNode, }...
fter being collected from all renderers. _dataBackends: Array<ProfilingDataBackend> = []; // Data from the most recently completed profiling session, // or data that has been imported from a previously exported session. // This object contains all
Suspense cache for lazily calculating derived profiling data. _cache: ProfilingCache; // Temporary store of profiling data from the backend renderer(s). // This data will be converted to the ProfilingDataFrontend format a
{ "filepath": "packages/react-devtools-shared/src/devtools/ProfilerStore.js", "language": "javascript", "file_size": 14216, "cut_index": 921, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import ProfilerStore from './ProfilerStore'; import { getCommitTree, invalidateCommitTrees, } from 'react-devtools-shared/src/devtools/views/Profiler/CommitTreeBui...
-shared/src/devtools/views/Profiler/types'; import type {ChartData as FlamegraphChartData} from 'react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder'; import type {ChartData as RankedChartData} from 'react-devtools-shared/src/devtools/
er'; import { getChartData as getRankedChartData, invalidateChartData as invalidateRankedChartData, } from 'react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder'; import type {CommitTree} from 'react-devtools
{ "filepath": "packages/react-devtools-shared/src/devtools/ProfilingCache.js", "language": "javascript", "file_size": 2887, "cut_index": 563, "middle_length": 229 }
import type { ReactContext, Thenable, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import * as React from 'react'; import {createContext} from 'react'; // TODO (cache) Remove this cache; it is outdated and will not work with newer APIs like startTransition. // Cache implementation was for...
fully reset between profiling sessions. export type {Thenable}; export type Resource<Input, Key, Value> = { clear(): void, invalidate(Key): void, read(Input): Value, preload(Input): void, write(Key, Value): void, }; let readContext; if (typeo
on't need to be invalidated. // Profiling data is invalidated as a whole. // 2. We didn't need the added overhead of an LRU cache. // The size of this cache is bounded by how many renders were profiled, // and it will be
{ "filepath": "packages/react-devtools-shared/src/devtools/cache.js", "language": "javascript", "file_size": 5449, "cut_index": 716, "middle_length": 229 }
, supportsReloadAndProfile?: boolean, supportsTimeline?: boolean, supportsTraceUpdates?: boolean, }; const ADVANCED_PROFILING_NONE = 0; const ADVANCED_PROFILING_TIMELINE = 1; const ADVANCED_PROFILING_PERFORMANCE_TRACKS = 2; type AdvancedProfiling = 0 | 1 | 2; export type Capabilities = { supportsBasicProfilin...
class Store extends EventEmitter<{ backendVersion: [], collapseNodesByDefault: [], componentFilters: [], error: [Error], hookSettings: [$ReadOnly<DevToolsHookSettings>], hostInstanceSelected: [Element['id'] | null], settingsUpdated: [$ReadOnl
.height > 0 || rect.x > 0 || rect.y > 0; } /** * The store is the single source of truth for updates from the backend. * ContextProviders can subscribe to the Store for specific things they want to provide. */ export default
{ "filepath": "packages/react-devtools-shared/src/devtools/store.js", "language": "javascript", "file_size": 80652, "cut_index": 3790, "middle_length": 229 }
import JSON5 from 'json5'; import type {ReactFunctionLocation} from 'shared/ReactTypes'; import {ElementTypeActivity} from 'react-devtools-shared/src/frontend/types'; import type { Element, SuspenseNode, } from 'react-devtools-shared/src/frontend/types'; import type {StateContext} from './views/Components/TreeCont...
"`; } let hocDisplayNames = null; if (element.hocDisplayNames !== null) { hocDisplayNames = [...element.hocDisplayNames]; } const hocs = hocDisplayNames === null ? '' : ` [${hocDisplayNames.join('][')}]`; let mode = ''; if (element
{ prefix = element.isCollapsed ? '▸' : '▾'; } let key = ''; if (element.key !== null) { key = ` key="${element.key}"`; } let name = ''; if (element.nameProp !== null) { name = ` name="${element.nameProp}
{ "filepath": "packages/react-devtools-shared/src/devtools/utils.js", "language": "javascript", "file_size": 8524, "cut_index": 716, "middle_length": 229 }
| 'expanded' | 'export' | 'filter' | 'import' | 'log-data' | 'more' | 'next' | 'parse-hook-names' | 'previous' | 'record' | 'reload' | 'save' | 'search' | 'settings' | 'panel-left-close' | 'panel-left-open' | 'panel-right-close' | 'panel-right-open' | 'panel-bottom-open' | 'pane...
witch (type) { case 'add': pathData = PATH_ADD; break; case 'cancel': pathData = PATH_CANCEL; break; case 'clear': pathData = PATH_CLEAR; break; case 'close': pathData = PATH_CLOSE; break;
e Props = { className?: string, type: IconType, }; const panelIcons = '96 -864 768 768'; export default function ButtonIcon({className = '', type}: Props): React.Node { let pathData = null; let viewBox = '0 0 24 24'; s
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ButtonIcon.js", "language": "javascript", "file_size": 14026, "cut_index": 921, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // This is a DevTools fork of shared/ReactOwnerStackFrames. export function formatOwnerStack(error: Error): string { const pr...
idx = stack.indexOf('\n'); if (idx !== -1) { // Pop the JSX frame. stack = stack.slice(idx + 1); } idx = stack.indexOf('react_stack_bottom_frame'); if (idx === -1) { idx = stack.indexOf('react-stack-bottom-frame'); } if (idx !== -1)
ckTrace = prevPrepareStackTrace; if (stack.startsWith('Error: react-stack-top-frame\n')) { // V8's default formatting prefixes with the error message which we // don't want/need. stack = stack.slice(29); } let
{ "filepath": "packages/react-devtools-shared/src/backend/shared/DevToolsOwnerStack.js", "language": "javascript", "file_size": 1453, "cut_index": 524, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactComponentInfo, ReactDebugInfo} from 'shared/ReactTypes'; import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import type {WorkTagMap}...
any).effectTag; } export function rootSupportsProfiling(root: any): boolean { if (root.memoizedInteractions != null) { // v16 builds include this field for the scheduler/tracing API. return true; } else if ( root.current != null && roo
turn toString.call(object) === '[object Error]'; } export function getFiberFlags(fiber: Fiber): number { // The name of this field changed from "effectTag" to "flags" return fiber.flags !== undefined ? fiber.flags : (fiber:
{ "filepath": "packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js", "language": "javascript", "file_size": 2908, "cut_index": 563, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactIOInfo, ReactAsyncInfo} from 'shared/ReactTypes'; import type {SuspenseNode} from './DevToolsFiberTypes'...
ReactAsyncInfo { for (let i = 0; i < suspensedBy.length; i++) { const asyncInfo = suspensedBy[i]; if (asyncInfo.awaited === ioInfo) { return asyncInfo; } } return null; } export function getVirtualEndTime(ioInfo: ReactIOInfo): numb
estor.suspendedBy.has(ioInfo)) { return true; } ancestor = ancestor.parent; } return false; } export function getAwaitInSuspendedByFromIO( suspensedBy: Array<ReactAsyncInfo>, ioInfo: ReactIOInfo, ): null |
{ "filepath": "packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberSuspense.js", "language": "javascript", "file_size": 1211, "cut_index": 518, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // Do not add / import anything to this file. // This function could be used from multiple places, including hook. // Skips CSS and object a...
eMessage.length; ++i) { const currentChar = maybeMessage[i]; if (currentChar !== '%') { template += currentChar; continue; } const nextChar = maybeMessage[i + 1]; ++i; // Only keep CSS and objects, inline other argumen
y> { if (inputArgs.length === 0 || typeof maybeMessage !== 'string') { return [maybeMessage, ...inputArgs]; } const args = inputArgs.slice(); let template = ''; let argumentsPointer = 0; for (let i = 0; i < mayb
{ "filepath": "packages/react-devtools-shared/src/backend/utils/formatConsoleArguments.js", "language": "javascript", "file_size": 1723, "cut_index": 537, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // Do not add / import anything to this file. // This function could be used from multiple places, including hook. // Formats an array of args with a style for consol...
- Note: we assume that the string formatting that the developer uses // is correct. // 3. The first param is a string that doesn't contain string formatting // OR is not a string // - Create a formatting string where: //
n't want to affect styles that the developer deliberately set. // 2. The first param is a string that doesn't contain %c but contains // string formatting // - [`%c${args[0]}`, style, ...args.slice(1)] //
{ "filepath": "packages/react-devtools-shared/src/backend/utils/formatWithStyles.js", "language": "javascript", "file_size": 2363, "cut_index": 563, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactContext} from 'shared/ReactTypes'; import * as React from 'react'; import { createContext, useCallback, useContext, useMemo, useReducer, useRef, } from 'react'; import Button from './Butto...
canBeDismissed: boolean, content: React$Node | null, id: ID, title: React$Node | null, }; type State = { dialogs: Array<Dialog>, }; type ModalDialogContextType = { ...State, dispatch: Dispatch, }; const ModalDialogContext: ReactContext<Modal
{ type: 'SHOW', canBeDismissed?: boolean, content: React$Node, id: ID, title?: React$Node | null, }; type Action = DIALOG_ACTION_HIDE | DIALOG_ACTION_SHOW; type Dispatch = (action: Action) => void; type Dialog = {
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ModalDialog.js", "language": "javascript", "file_size": 4380, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useEffect, useRef} from 'react'; import Button from './Button'; import ButtonIcon from './ButtonIcon'; import Icon from './Icon'; import styles from './SearchInput.css'; type P...
const inputRef = useRef<HTMLInputElement | null>(null); const resetSearch = () => search(''); // $FlowFixMe[missing-local-annot] const handleChange = ({currentTarget}) => { search(currentTarget.value); }; // $FlowFixMe[missing-local-annot
ext: string, testName?: ?string, }; export default function SearchInput({ goToNextResult, goToPreviousResult, placeholder, search, searchIndex, searchResultsCount, searchText, testName, }: Props): React.Node {
{ "filepath": "packages/react-devtools-shared/src/devtools/views/SearchInput.js", "language": "javascript", "file_size": 4174, "cut_index": 614, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ /************************************************************************ * This file is forked between different DevTools impl...
********************************************************* * Do not edit the code below. * It ensures this fork exports the same types as the default flags file. ************************************************************************/ import typeof * a
****/ export const enableActivitySlices: boolean = __DEV__; export const enableLogger: boolean = false; export const enableStyleXFeatures: boolean = false; export const isInternalFacebookBuild: boolean = false; /***************
{ "filepath": "packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js", "language": "javascript", "file_size": 1284, "cut_index": 524, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment} from 'react'; import styles from './EditableValue.css'; import {useEditableValue} from '../hooks'; type OverrideValu...
alid, parsedValue} = state; const reset = () => dispatch({ type: 'RESET', externalValue: value, }); // $FlowFixMe[missing-local-annot] const handleChange = ({target}) => dispatch({ type: 'UPDATE', editableValue:
export default function EditableValue({ className = '', overrideValue, path, value, }: EditableValueProps): React.Node { const [state, dispatch] = useEditableValue(value); const {editableValue, hasPendingChanges, isV
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js", "language": "javascript", "file_size": 3042, "cut_index": 563, "middle_length": 229 }
import * as React from 'react'; import {Fragment, startTransition, useContext, useMemo, useState} from 'react'; import Store from 'react-devtools-shared/src/devtools/store'; import {ElementTypeActivity} from 'react-devtools-shared/src/frontend/types'; import ButtonIcon from '../ButtonIcon'; import {TreeDispatcherContex...
nd/types'; import styles from './Element.css'; import Icon from '../Icon'; import {useChangeOwnerAction} from './OwnersListContext'; import Tooltip from './reach-ui/tooltip'; import {useChangeActivitySliceAction} from '../SuspenseTab/ActivityList'; type
IndexableElementBadges from './IndexableElementBadges'; import IndexableDisplayName from './IndexableDisplayName'; import type {ItemData} from './Tree'; import type {Element as ElementType} from 'react-devtools-shared/src/fronte
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/Element.js", "language": "javascript", "file_size": 9110, "cut_index": 716, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Badge from './Badge'; import ForgetBadge from './ForgetBadge'; import styles from './El...
tName == null ) { return null; } return ( <div className={`${styles.Root} ${className}`}> {compiledWithForget && <ForgetBadge indexable={false} />} {environmentName != null ? <Badge>{environmentName}</Badge> : null} {hocD
ementBadges({ compiledWithForget, environmentName, hocDisplayNames, className = '', }: Props): React.Node { if ( !compiledWithForget && (hocDisplayNames == null || hocDisplayNames.length === 0) && environmen
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/ElementBadges.js", "language": "javascript", "file_size": 1290, "cut_index": 524, "middle_length": 229 }
, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import styles from './ExpandCollapseToggle.css...
<Button className={styles.ExpandCollapseToggle} disabled={disabled} onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)} title={`${isOpen ? 'Collapse' : 'Expand'} prop value`}> <ButtonIcon type={isOpen ? 'expanded' : 'colla
xpandCollapseToggleProps): React.Node { return (
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js", "language": "javascript", "file_size": 886, "cut_index": 547, "middle_length": 52 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Badge from './Badge'; import IndexableDisplayName from './IndexableDisplayName'; i...
act.Node { const {className = ''} = props; const innerView = props.indexable ? ( <IndexableDisplayName displayName="Memo" id={props.elementID} /> ) : ( 'Memo' ); const title = '✨ This component has been auto-memoized by the React Co
elementID: number, }; type PropsForNonIndexable = CommonProps & { indexable: false | void, elementID?: number, }; type Props = PropsForIndexable | PropsForNonIndexable; export default function ForgetBadge(props: Props): Re
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/ForgetBadge.js", "language": "javascript", "file_size": 1151, "cut_index": 518, "middle_length": 229 }
, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactContext} from 'shared/ReactTypes'; import type {Thenable} from 'shared/ReactTypes'; import {createContext} from 'react'; import typ...
ack 5) Hopefully we can remove this context entirely once the Webpack 5 upgrade is completed. const HookNamesModuleLoaderContext: ReactContext<Context> = createContext<Context>(null); HookNamesModuleLoaderContext.displayName = 'HookNamesModuleLoaderConte
HookNamesModuleLoaderFunction | null; // TODO (Webp
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/HookNamesModuleLoaderContext.js", "language": "javascript", "file_size": 906, "cut_index": 547, "middle_length": 52 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {createRegExp} from '../utils'; import {TreeStateContext} from './TreeContext'; import styles from '...
null && id === searchResults[searchIndex]; if (!isSearchResult || displayName === null) { return displayName; } const match = createRegExp(searchText).exec(displayName); if (match === null) { return displayName; } const startIndex
nst {searchIndex, searchResults, searchText} = useContext(TreeStateContext); const isSearchResult = useMemo(() => { return searchResults.includes(id); }, [id, searchResults]); const isCurrentResult = searchIndex !==
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/IndexableDisplayName.js", "language": "javascript", "file_size": 1590, "cut_index": 537, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Badge from './Badge'; import ForgetBadge from './ForgetBadge'; import IndexableDisplayNa...
== null || hocDisplayNames.length === 0) ) { return null; } return ( <div className={`${styles.Root} ${className}`}> {compiledWithForget && ( <ForgetBadge indexable={true} elementID={elementID} /> )} {hocDisplayNam
r, className?: string, }; export default function IndexableElementBadges({ compiledWithForget, hocDisplayNames, elementID, className = '', }: Props): React.Node { if ( !compiledWithForget && (hocDisplayNames
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/IndexableElementBadges.js", "language": "javascript", "file_size": 1387, "cut_index": 524, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useCallback, useContext, useEffect, useState} from 'react'; import {BridgeContext} from '../context';...
=> { setIsInspecting(isChecked); if (isChecked) { logEvent({event_name: 'inspect-element-button-clicked'}); bridge.send('startInspectingHost', !!onlySuspenseNodes); } else { bridge.send('stopInspectingHost');
enseNodes, }: { onlySuspenseNodes?: boolean, }): React.Node { const [isInspecting, setIsInspecting] = useState(false); const bridge = useContext(BridgeContext); const handleChange = useCallback( (isChecked: boolean)
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/InspectHostNodesToggle.js", "language": "javascript", "file_size": 1510, "cut_index": 537, "middle_length": 229 }
eContext} from './TreeContext'; import {BridgeContext, StoreContext, OptionsContext} from '../context'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import Icon from '../Icon'; import Toggle from '../Toggle'; import { ElementTypeSuspense, ElementTypeRoot, } from 'react-devtools-shared/src...
eSource'; import OpenInEditorButton from './OpenInEditorButton'; import InspectedElementViewSourceButton from './InspectedElementViewSourceButton'; import useEditorURL from '../useEditorURL'; import styles from './InspectedElement.css'; import Tooltip fro
ils'; import {LOCAL_STORAGE_ALWAYS_OPEN_IN_EDITOR} from '../../../constants'; import FetchFileWithCachingContext from './FetchFileWithCachingContext'; import {symbolicateSourceWithCache} from 'react-devtools-shared/src/symbolicat
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js", "language": "javascript", "file_size": 10634, "cut_index": 921, "middle_length": 229 }