prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
MIT license found in the * LICENSE file in the root directory of this source tree. */ const didWarnStateUpdateForUnmountedComponent = {}; function warnNoop(publicInstance, callerName) { if (__DEV__) { const constructor = publicInstance.constructor; const componentName = (constructor && (constructor...
a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName, ); didWarnStateUpdateForUnmountedComponent[warningKey] = true; } } /** * This is the abstract API for an update que
} console.error( "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define
{ "filepath": "packages/react/src/ReactNoopUpdateQueue.js", "language": "javascript", "file_size": 3741, "cut_index": 614, "middle_length": 229 }
; const ReactNoop = require('react-noop-renderer'); // Kind of hacky, but we nullify all the instances to test the tree structure // with jasmine's deep equality function, and test the instances separate. We // also delete children props because testing them is more annoying and not // really important to verify. func...
(typeof node.rendered === 'object') { cleanNodeOrArray(node.rendered); } } describe('ReactTestRenderer', () => { beforeEach(() => { jest.resetModules(); ReactFeatureFlags.enableReactTestRendererWarning = false; }); // @gate __DEV__
null; } if (node && node.props && node.props.children) { const {children, ...props} = node.props; node.props = props; } if (Array.isArray(node.rendered)) { node.rendered.forEach(cleanNodeOrArray); } else if
{ "filepath": "packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js", "language": "javascript", "file_size": 29988, "cut_index": 1331, "middle_length": 229 }
kSettings, ProfilingSettings, } from 'react-devtools-shared/src/backend/types'; import type {StyleAndLayout as StyleAndLayoutPayload} from 'react-devtools-shared/src/backend/NativeStyleEditor/types'; // This message specifies the version of the DevTools protocol currently supported by the backend, // as well as the ...
et when the version is bumped. minNpmVersion: string, maxNpmVersion: string | null, }; // Bump protocol version whenever a backwards breaking change is made // in the messages sent between BackendBridge and FrontendBridge. // This mapping is embedded
xport type BridgeProtocol = { // Version supported by the current frontend/backend. version: number, // NPM version range of `react-devtools-inline` that also supports this version. // Note that 'maxNpmVersion' is only s
{ "filepath": "packages/react-devtools-shared/src/bridge.js", "language": "javascript", "file_size": 15090, "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 */ export { __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, __COMPILER_RUNTIME, Activity, Chil...
useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useOptimistic, useRef, useState, useSyncExternalStore, useTransition, useActionState, version, act, // DEV-only captureOwnerStack, // DEV-only } from
e, forwardRef, isValidElement, lazy, memo, cache, cacheSignal, unstable_useCacheRefresh, startTransition, useId, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useEffectEvent,
{ "filepath": "packages/react/index.stable.development.js", "language": "javascript", "file_size": 1018, "cut_index": 512, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. */ import ReactNoopUpdateQueue from './ReactNoopUpdateQueue'; import assign from 'shared/assign'; const emptyObject = {}; if (__DEV__) { Object.freeze(emptyObject); } /** * Base class helpers for the updating state of a componen...
e state. Always use this to mutate * state. You should treat `this.state` as immutable. * * There is no guarantee that `this.state` will be immediately updated, so * accessing `this.state` after calling this method may return the old value. * * There
emptyObject; // We initialize the default updater but the real one gets injected by the // renderer. this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; /** * Sets a subset of th
{ "filepath": "packages/react/src/ReactBaseClasses.js", "language": "javascript", "file_size": 4905, "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 */ export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer'; import {forEach, ma...
seMemo} from './ReactHooks'; import {forwardRef} from './ReactForwardRef'; import {lazy} from './ReactLazy'; import {memo} from './ReactMemo'; import {cache, cacheSignal} from './ReactCacheServer'; import version from 'shared/ReactVersion'; import {capture
NSITION_TYPE, } from 'shared/ReactSymbols'; import { cloneElement, createElement, isValidElement, } from './jsx/ReactJSXElement'; import {createRef} from './ReactCreateRef'; import {use, useId, useCallback, useDebugValue, u
{ "filepath": "packages/react/src/ReactServer.js", "language": "javascript", "file_size": 1603, "cut_index": 537, "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 {Dispatcher} from 'react-reconciler/src/ReactInternalTypes'; import type {AsyncDispatcher} from 'react-reconciler/src/ReactIntern...
Dispatcher, // ReactCurrentCache for Cache // enableTaint TaintRegistryObjects: WeakMap<Reference, string>, TaintRegistryValues: Map<string | bigint, TaintEntry>, TaintRegistryByteLengths: Set<number>, TaintRegistryPendingRequests: Set<RequestCl
TaintRegistryPendingRequests, } from './ReactTaintRegistry'; import {enableTaint} from 'shared/ReactFeatureFlags'; export type SharedStateServer = { H: null | Dispatcher, // ReactCurrentDispatcher for Hooks A: null | Async
{ "filepath": "packages/react/src/ReactSharedInternalsServer.js", "language": "javascript", "file_size": 1890, "cut_index": 537, "middle_length": 229 }
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import type { StartTransitionOptions, GestureProvider, GestureOptions, } from 'shared/ReactTypes'; import type {TransitionTypes} from './ReactTransitionType'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import { enableTran...
ableTransitionTracing only _updatedFibers: Set<Fiber>, // DEV-only ... }; function releaseAsyncTransition() { if (__DEV__) { ReactSharedInternals.asyncTransitions--; } } export function startTransition( scope: () => void, options?: StartT
export type Transition = { types: null | TransitionTypes, // enableViewTransition gesture: null | GestureProvider, // enableGestureTransition name: null | string, // enableTransitionTracing only startTime: number, // en
{ "filepath": "packages/react/src/ReactStartTransition.js", "language": "javascript", "file_size": 6614, "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 ReactSharedInternals from 'shared/ReactSharedInternals'; import { enableViewTransition, enableGestureTransition, } from 'shared/Re...
(transitionTypes.indexOf(type) === -1) { transitionTypes.push(type); } } else { // We're in the async gap. Simulate an implicit startTransition around it. if (__DEV__) { if (ReactSharedInternals.asyncTransitions === 0
wTransition) { const transition = ReactSharedInternals.T; if (transition !== null) { const transitionTypes = transition.types; if (transitionTypes === null) { transition.types = [type]; } else if
{ "filepath": "packages/react/src/ReactTransitionType.js", "language": "javascript", "file_size": 1650, "cut_index": 537, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import ReactVersion from 'shared/ReactVersion'; import { REACT_FRAGMENT_TYPE, REACT_PROFILER_TYPE, REACT_STRICT_MODE_TYPE, REACT_SUSPENSE_TYPE, REACT_SUSPENSE_LIST_TYPE, REACT_LEGACY_HIDDEN_TYPE, REACT_AC...
reateContext} from './ReactContext'; import {lazy} from './ReactLazy'; import {forwardRef} from './ReactForwardRef'; import {memo} from './ReactMemo'; import {cache, cacheSignal} from './ReactCacheClient'; import { getCacheForType, useCallback, useCo
ctBaseClasses'; import {createRef} from './ReactCreateRef'; import {forEach, map, count, toArray, only} from './ReactChildren'; import { createElement, cloneElement, isValidElement, } from './jsx/ReactJSXElement'; import {c
{ "filepath": "packages/react/src/ReactClient.js", "language": "javascript", "file_size": 3369, "cut_index": 614, "middle_length": 229 }
nder the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; let React; let ReactNoop; describe('arity', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); })...
/>); }); it("ensure useReducer setter's arity is correct", () => { function Component() { const [, dispatch] = React.useReducer(() => 'Halo!'); expect(dispatch.length).toBe(1); return null; } ReactNoop.render(<Component
return null; } ReactNoop.render(<Component
{ "filepath": "packages/react/src/__tests__/React-hooks-arity.js", "language": "javascript", "file_size": 930, "cut_index": 606, "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. * * @emails react-core */ 'use strict'; const spawnSync = require('child_process').spawnSync; describe('ReactClassEquivalence', () => { it('tests the same thing for es6 classes...
}); function runJest(testFile) { const cwd = process.cwd(); const extension = process.platform === 'win32' ? '.cmd' : ''; const command = process.env.npm_lifecycle_event; const defaultReporter = '--reporters=default'; const equivalenceReporter =
it('tests the same thing for es6 classes and TypeScript', () => { const result1 = runJest('ReactTypeScriptClass-test.ts'); const result2 = runJest('ReactES6Class-test.js'); compareResults(result1, result2); });
{ "filepath": "packages/react/src/__tests__/ReactClassEquivalence-test.js", "language": "javascript", "file_size": 2234, "cut_index": 563, "middle_length": 229 }
Do not use JSX syntax in this module; call React.createElement directly. describe('ReactCreateElement', () => { let ComponentClass; beforeEach(() => { jest.resetModules(); ({ act, assertConsoleErrorDev, assertConsoleWarnDev, } = require('internal-test-utils')); React = require(...
oBe(null); if (__DEV__) { expect(Object.isFrozen(element)).toBe(true); expect(Object.isFrozen(element.props)).toBe(true); } expect(element.props).toEqual({}); }); it('should warn when `key` is being accessed on composite elemen
; it('returns a complete element according to spec', () => { const element = React.createElement(ComponentClass); expect(element.type).toBe(ComponentClass); expect(element.key).toBe(null); expect(element.ref).t
{ "filepath": "packages/react/src/__tests__/ReactCreateElement-test.js", "language": "javascript", "file_size": 13755, "cut_index": 921, "middle_length": 229 }
nDev, } = require('internal-test-utils')); container = document.createElement('div'); root = ReactDOMClient.createRoot(container); attachedListener = null; renderedName = null; Inner = class extends React.Component { getName() { return this.props.name; } render() { ...
).toBe(expectedClassName); } it('preserves the name of the class for use in error messages', () => { class Foo extends React.Component {} expect(Foo.name).toBe('Foo'); }); it('throws if no render function is defined', () => { class Fo
dTag, expectedClassName) { ReactDOM.flushSync(() => root.render(element)); expect(container.firstChild).not.toBeNull(); expect(container.firstChild.tagName).toBe(expectedTag); expect(container.firstChild.className
{ "filepath": "packages/react/src/__tests__/ReactES6Class-test.js", "language": "javascript", "file_size": 19562, "cut_index": 1331, "middle_length": 229 }
ct-dom/client'); ({act, assertConsoleErrorDev} = require('internal-test-utils')); ComponentClass = class extends React.Component { render() { return React.createElement('div', null, this.props.children); } }; }); it('warns for keys for arrays of elements in rest args', async () => {...
`ComponentClass`. See https://react.dev/link/warning-keys for more information.\n' + ' in ComponentClass (at **)', ]); }); it('warns for keys for arrays of elements with owner info', async () => { class InnerClass extends React.Comp
ment(ComponentClass), React.createElement(ComponentClass), ]), ), ); assertConsoleErrorDev([ 'Each child in a list should have a unique "key" prop.\n\n' + 'Check the render method of
{ "filepath": "packages/react/src/__tests__/ReactElementValidator-test.internal.js", "language": "javascript", "file_size": 19504, "cut_index": 1331, "middle_length": 229 }
ct-core */ 'use strict'; // TODO: All these warnings should become static errors using Flow instead // of dynamic errors when using JSX with Flow. let act; let React; let ReactDOMClient; let assertConsoleErrorDev; describe('ReactJSXElementValidator', () => { let Component; let RequiredPropComponent; beforeEa...
props.prop}</span>; } }; RequiredPropComponent.displayName = 'RequiredPropComponent'; }); it('warns for keys for arrays of elements in children position', async () => { const container = document.createElement('div'); const root
omponent = class extends React.Component { render() { return <div>{this.props.children}</div>; } }; RequiredPropComponent = class extends React.Component { render() { return <span>{this.
{ "filepath": "packages/react/src/__tests__/ReactJSXElementValidator-test.js", "language": "javascript", "file_size": 9006, "cut_index": 716, "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 {Dispatcher} from 'react-reconciler/src/ReactInternalTypes'; import type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes'; import type {Tra...
ntDispatcher for Hooks A: null | AsyncDispatcher, // ReactCurrentCache for Cache T: null | Transition, // ReactCurrentBatchConfig for Transitions S: null | onStartTransitionFinish, G: null | onStartGestureTransitionFinish, // DEV-only // Reac
TransitionFinish = (Transition, mixed) => void; type onStartGestureTransitionFinish = ( Transition, GestureProvider, ?GestureOptions, ) => () => void; export type SharedStateClient = { H: null | Dispatcher, // ReactCurre
{ "filepath": "packages/react/src/ReactSharedInternalsClient.js", "language": "javascript", "file_size": 2518, "cut_index": 563, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {enableTaint} from 'shared/ReactFeatureFlags'; import getPrototypeOf from 'shared/getPrototypeOf'; import binaryToComparableString from 'shared/binaryToComparableString'; import ReactSharedInternals from './R...
nent or Action closure. ' + 'This would leak it to the client.'; function cleanup(entryValue: string | bigint): void { const entry = TaintRegistryValues.get(entryValue); if (entry !== undefined) { TaintRegistryPendingRequests.forEach(function (r
// This is the shared constructor of all typed arrays. const TypedArrayConstructor = getPrototypeOf(Uint32Array.prototype).constructor; const defaultMessage = 'A tainted value was attempted to be serialized to a Client Compo
{ "filepath": "packages/react/src/ReactTaint.js", "language": "javascript", "file_size": 4250, "cut_index": 614, "middle_length": 229 }
import type { Wakeable, Thenable, FulfilledThenable, RejectedThenable, ReactDebugInfo, ReactIOInfo, } from 'shared/ReactTypes'; import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags'; import {REACT_LAZY_TYPE} from 'shared/ReactSymbols'; import noop from 'shared/noop'; const Uninitialized = -1; co...
yload = { _status: 2, _result: mixed, _ioInfo?: ReactIOInfo, // DEV-only }; type Payload<T> = | UninitializedPayload<T> | PendingPayload | ResolvedPayload<T> | RejectedPayload; export type LazyComponent<T, P> = { $$typeof: symbol | number
type PendingPayload = { _status: 0, _result: Wakeable, _ioInfo?: ReactIOInfo, // DEV-only }; type ResolvedPayload<T> = { _status: 1, _result: {default: T, ...}, _ioInfo?: ReactIOInfo, // DEV-only }; type RejectedPa
{ "filepath": "packages/react/src/ReactLazy.js", "language": "javascript", "file_size": 8470, "cut_index": 716, "middle_length": 229 }
Client = require('react-dom/client'); ({act, assertConsoleErrorDev} = require('internal-test-utils')); }); // TODO: This behavior creates a runtime dependency on propTypes. We should // ensure that this is not required for ES6 classes with Flow. // @gate !disableLegacyContext it('should filter out conte...
er() { return <Component ref={this.childRef} />; } } ComponentInFooBarContext.childContextTypes = { foo: PropTypes.string, bar: PropTypes.number, }; let instance; const container = document.createElement('div'
string, }; class ComponentInFooBarContext extends React.Component { childRef = React.createRef(); getChildContext() { return { foo: 'abc', bar: 123, }; } rend
{ "filepath": "packages/react/src/__tests__/ReactContextValidator-test.js", "language": "javascript", "file_size": 21665, "cut_index": 1331, "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. * * @emails react-core */ 'use strict'; let React; let ReactDOM; let ReactDOMClient; let assertConsoleErrorDev; describe('ReactCreateRef', () => { bef...
render() { return null; } } const root = ReactDOMClient.createRoot(document.createElement('div')); ReactDOM.flushSync(() => { root.render( <Wrapper> <div ref={{}} /> </Wrapper>, ); }
quire('internal-test-utils')); }); it('should warn in dev if an invalid ref object is provided', () => { function Wrapper({children}) { return children; } class ExampleComponent extends React.Component {
{ "filepath": "packages/react/src/__tests__/ReactCreateRef-test.js", "language": "javascript", "file_size": 1579, "cut_index": 537, "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 */ export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer'; import {forEach, ma...
JSXElement'; import {createRef} from './ReactCreateRef'; import {use, useId, useCallback, useDebugValue, useMemo} from './ReactHooks'; import {forwardRef} from './ReactForwardRef'; import {lazy} from './ReactLazy'; import {memo} from './ReactMemo'; import
OFILER_TYPE, REACT_STRICT_MODE_TYPE, REACT_SUSPENSE_TYPE, REACT_SUSPENSE_LIST_TYPE, REACT_VIEW_TRANSITION_TYPE, } from 'shared/ReactSymbols'; import { cloneElement, createElement, isValidElement, } from './jsx/React
{ "filepath": "packages/react/src/ReactServer.fb.js", "language": "javascript", "file_size": 1892, "cut_index": 537, "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 */ export interface Reference {} export type TaintEntry = { message: string, count: number, }; export const TaintR...
emoved from any global caches. // No future requests can get a handle on it but any ongoing requests can still have // a handle on it. It's still tainted until that happens. export type RequestCleanupQueue = Array<string | bigint>; export const TaintRegist
. We don't both refcounting this. // We expect to see only a few lengths here such as the length of token. export const TaintRegistryByteLengths: Set<number> = new Set(); // When a value is finalized, it means that it has been r
{ "filepath": "packages/react/src/ReactTaintRegistry.js", "language": "javascript", "file_size": 1055, "cut_index": 513, "middle_length": 229 }
ortalContainer = document.createElement('div'); const simpleChild = <span key="simple" />; const reactPortal = ReactDOM.createPortal(simpleChild, portalContainer); const parentInstance = <div>{reactPortal}</div>; React.Children.forEach(parentInstance.props.children, callback, context); expect(call...
k = jest.fn().mockImplementation(function (kid, index) { expect(this).toBe(context); return kid; }); const simpleKid = <span />; const instance = <div>{simpleKid}</div>; React.Children.forEach(instance.props.children, callback,
expect(callback).toHaveBeenCalledWith(reactPortal, 0); expect(mappedChildren[0]).toEqual(reactPortal); }); it('should treat single arrayless child as being in array', () => { const context = {}; const callbac
{ "filepath": "packages/react/src/__tests__/ReactChildren-test.js", "language": "javascript", "file_size": 36901, "cut_index": 2151, "middle_length": 229 }
e // certain that we are testing the runtime behavior, as opposed to the Babel // transform that we use in our tests configuration. describe('ReactJSXRuntime', () => { beforeEach(() => { jest.resetModules(); React = require('react'); JSXRuntime = require('react/jsx-runtime'); JSXDEVRuntime = require(...
omeReturnValue'; const element = JSXRuntime.jsx(StaticMethodComponentClass, {}); expect(element.type.someStaticMethod()).toBe('someReturnValue'); }); it('is indistinguishable from a plain object', () => { const element = JSXRuntime.jsx('d
using the type property', () => { class StaticMethodComponentClass extends React.Component { render() { return JSXRuntime.jsx('div', {}); } } StaticMethodComponentClass.someStaticMethod = () => 's
{ "filepath": "packages/react/src/__tests__/ReactJSXRuntime-test.js", "language": "javascript", "file_size": 11658, "cut_index": 921, "middle_length": 229 }
({act, assertConsoleErrorDev} = require('internal-test-utils')); React = require('react'); ReactDOMClient = require('react-dom/client'); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. ComponentClass = class extends React.Component { rende...
return ( <div className="parent"> {React.cloneElement(this.props.child, {className: 'xyz'})} </div> ); } } const root = ReactDOMClient.createRoot(document.createElement('div')); await act((
ent { render() { return ( <Parent child={<div ref={node => (div = node)} className="child" />} /> ); } } class Parent extends React.Component { render() {
{ "filepath": "packages/react/src/__tests__/ReactElementClone-test.js", "language": "javascript", "file_size": 10749, "cut_index": 921, "middle_length": 229 }
ct-core */ 'use strict'; import {patchMessageChannel} from '../../../../scripts/jest/patchMessageChannel'; describe('ReactMismatchedVersions-test', () => { // Polyfills for test environment global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').ReadableStream; global.TextEncoder = require('u...
ReactVersion = React.__actualVersion; }); it('importing "react-dom/client" throws if version does not match React version', async () => { expect(() => require('react-dom/client')).toThrow( 'Incompatible React versions: The "react" and "react
jest.requireActual('react'); return { ...actualReact, version: '18.0.0-whoa-this-aint-the-right-react', __actualVersion: actualReact.version, }; }); React = require('react'); actual
{ "filepath": "packages/react/src/__tests__/ReactMismatchedVersions-test.js", "language": "javascript", "file_size": 5678, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; let React; let ReactDOMClient; let ReactFeatureFlags; let act; let container; let assertConsoleErrorDev; function loadModules({ enableProfilerTimer = true, enableProfilerCommitHooks = t...
; const InternalTestUtils = require('internal-test-utils'); act = InternalTestUtils.act; assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev; } describe('Profiler', () => { beforeEach(() => { container = document.createElement('div
reFlags.enableProfilerCommitHooks = enableProfilerCommitHooks; ReactFeatureFlags.enableProfilerNestedUpdatePhase = enableProfilerNestedUpdatePhase; React = require('react'); ReactDOMClient = require('react-dom/client')
{ "filepath": "packages/react/src/__tests__/ReactProfilerComponent-test.internal.js", "language": "javascript", "file_size": 4205, "cut_index": 614, "middle_length": 229 }
]); expect(callback).toHaveBeenCalledTimes(1); }); // @gate !__DEV__ it('does not record times for components outside of Profiler tree', async () => { // Mock the Scheduler module so we can track how many times the current // time is read jest.mock('scheduler', obj => { const ActualSchedule...
learLog(); await act(() => { ReactNoop.render( <div> <AdvanceTime /> <AdvanceTime /> <AdvanceTime /> <AdvanceTime /> <AdvanceTime /> </div>, ); }); // Restore origi
e'); return ActualScheduler.unstable_now(); }, }; }); jest.resetModules(); loadModules(); // Clear yields in case the current time is read during initialization. Scheduler.unstable_c
{ "filepath": "packages/react/src/__tests__/ReactProfiler-test.internal.js", "language": "javascript", "file_size": 68082, "cut_index": 3790, "middle_length": 229 }
mponent; 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 _interopRequireWildcard(obj) { i...
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) { cache.set(obj, ne
he && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) {
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ComponentUsingHooksIndirectly.js", "language": "javascript", "file_size": 5031, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; let act; let assertConsoleErrorDev; let React; let ReactDOMClient; describe('ReactPureComponent', () => { beforeEach(() => { ({act, assertConsoleErrorDev} = require('internal-test-uti...
createElement('div'); const root = ReactDOMClient.createRoot(container); let text; const componentRef = React.createRef(); text = ['porcini']; await act(() => { root.render(<Component ref={componentRef} text={text} />); });
mponent { constructor() { super(); this.state = {type: 'mushrooms'}; } render() { renders++; return <div>{this.props.text[0]}</div>; } } const container = document.
{ "filepath": "packages/react/src/__tests__/ReactPureComponent-test.js", "language": "javascript", "file_size": 4096, "cut_index": 614, "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. * * @emails react-core */ 'use strict'; let React; let ReactTestRenderer; let act; let assertConsoleWarnDev; let useState; let useTransition; const SUSPICIOUS_NUMBER_OF_FIBERS_UP...
() => { const subs = new Set(); const useUserSpaceSubscription = () => { const setState = useState(0)[1]; subs.add(setState); }; let triggerHookTransition; const Component = ({level}) => { useUserSpaceSubscription();
act, assertConsoleWarnDev} = require('internal-test-utils')); useState = React.useState; useTransition = React.useTransition; }); it('Warns if a suspicious number of fibers are updated inside startTransition', async
{ "filepath": "packages/react/src/__tests__/ReactStartTransition-test.js", "language": "javascript", "file_size": 2279, "cut_index": 563, "middle_length": 229 }
<React.StrictMode> <Foo /> </React.StrictMode>, ); assertConsoleErrorDev([ 'Invalid ARIA attribute `ariaTypo`. ' + 'ARIA attributes follow the pattern aria-* and must be lowercase.\n' + ' in div (at **)\n' + ' in Foo (at **)', ]); }); // @gate __DE...
log.push('constructor'); } componentDidMount() { log.push('componentDidMount'); } componentDidUpdate() { log.push('componentDidUpdate'); } componentWillUnmount() { log.push('componentWillUnmou
ClassComponent extends React.Component { state = {}; static getDerivedStateFromProps() { log.push('getDerivedStateFromProps'); return null; } constructor(props) { super(props);
{ "filepath": "packages/react/src/__tests__/ReactStrictMode-test.js", "language": "javascript", "file_size": 37243, "cut_index": 2151, "middle_length": 229 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * @jest-environment node */ 'use strict'; // NOTE: Intentionally using the dynamic version of the `gate` pragma to opt out // the negative test behavior. If this test happens...
for feature detection. Consider // some other way of handling that. test('ReactVersion matches package.json', () => { if (gate(flags => flags.build && flags.stable && !flags.www)) { const React = require('react'); const packageJSON = require('rea
e than // the package.json because DevTools uses it
{ "filepath": "packages/react/src/__tests__/ReactVersion-test.js", "language": "javascript", "file_size": 970, "cut_index": 582, "middle_length": 52 }
eact'); ReactNoop = require('react-noop-renderer'); const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev; }); it('should update refs when switching between children', async () => { f...
createRef(); ReactNoop.render(<RefForwardingComponent ref={ref} setRefOnDiv={true} />); await waitForAll([]); expect(ref.current.type).toBe('div'); ReactNoop.render(<RefForwardingComponent ref={ref} setRefOnDiv={false} />); await wait
null : forwardedRef}>Second</span> </section> ); } const RefForwardingComponent = React.forwardRef((props, ref) => ( <FunctionComponent {...props} forwardedRef={ref} /> )); const ref = React.
{ "filepath": "packages/react/src/__tests__/forwardRef-test.js", "language": "javascript", "file_size": 12097, "cut_index": 921, "middle_length": 229 }
(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 {REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols'; import { jsxProd, jsxProdSignatureRunningInDevWithDynamicChildren, jsxP...
tage of static children. // for now we can ship identical prod functions const jsxs: any = __DEV__ ? jsxProdSignatureRunningInDevWithStaticChildren : jsxProd; const jsxDEV: any = __DEV__ ? _jsxDEV : undefined; export {REACT_FRAGMENT_TYPE as Fragment,
y want to special case jsxs internally to take advan
{ "filepath": "packages/react/src/jsx/ReactJSX.js", "language": "javascript", "file_size": 858, "cut_index": 529, "middle_length": 52 }
(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 {REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols'; import { jsxProd, jsxProdSignatureRunningInDevWithDynamicChildren, jsxP...
tage of static children. // for now we can ship identical prod functions const jsxs: any = __DEV__ ? jsxProdSignatureRunningInDevWithStaticChildren : jsxProd; const jsxDEV: any = __DEV__ ? _jsxDEV : undefined; export {REACT_FRAGMENT_TYPE as Fragment,
y want to special case jsxs internally to take advan
{ "filepath": "packages/react/src/jsx/ReactJSXServer.js", "language": "javascript", "file_size": 858, "cut_index": 529, "middle_length": 52 }
ionString, } = require('react-devtools-extensions/utils'); const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils'); const NODE_ENV = process.env.NODE_ENV; if (!NODE_ENV) { console.error('NODE_ENV not set'); process.exit(1); } const builtModulesDir = resolve( __dirname, '..', '..', 'build...
l.config.js', ), }; module.exports = { mode: __DEV__ ? 'development' : 'production', devtool: __DEV__ ? 'eval-cheap-module-source-map' : 'source-map', target: 'electron-main', entry: { standalone: './src/standalone.js', }, output: {
rocess.env.LOGGING_URL || null; const featureFlagTarget = process.env.FEATURE_FLAG_TARGET || 'core/standalone-oss'; const babelOptions = { configFile: resolve( __dirname, '..', 'react-devtools-shared', 'babe
{ "filepath": "packages/react-devtools-core/webpack.standalone.js", "language": "javascript", "file_size": 4099, "cut_index": 614, "middle_length": 229 }
import {existsSync} from 'fs'; import {basename, join, isAbsolute} from 'path'; import {execSync, spawn} from 'child_process'; import {parse} from 'shell-quote'; function isTerminalEditor(editor: string): boolean { switch (editor) { case 'vim': case 'emacs': case 'nano': return true; default: ...
xt.app/Contents/MacOS/Sublime Text': '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', '/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '/Appli
me const COMMON_EDITORS = { '/Applications/Atom.app/Contents/MacOS/Atom': 'atom', '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', '/Applications/Sublime Te
{ "filepath": "packages/react-devtools-core/src/editor.js", "language": "javascript", "file_size": 5665, "cut_index": 716, "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. */ /** * The implementation of this plugin is based on similar webpack plugin in Angular CLI * https://github.com/angular/angular-cli/blob/16d8c552e99bfe65ded9e843e917dbb95eb8ec01/...
; class SourceMapIgnoreListPlugin { constructor({shouldIgnoreSource}) { this.shouldIgnoreSource = shouldIgnoreSource; } apply(compiler) { const {RawSource} = compiler.webpack.sources; compiler.hooks.compilation.tap(PLUGIN_NAME, compila
blob/d15274e4d2fdb74f73aa644f14773a5523823999/src/index.ts * which both are licensed under MIT */ const {Compilation} = require('webpack'); const IGNORE_LIST = 'ignoreList'; const PLUGIN_NAME = 'source-map-ignore-list-plugin'
{ "filepath": "packages/react-devtools-shared/SourceMapIgnoreListPlugin.js", "language": "javascript", "file_size": 2337, "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. * */ const {resolve} = require('path'); function resolveFeatureFlags(target) { let flagsPath; switch (target) { case 'inli...
tension-oss'; break; case 'extension-fb': flagsPath = 'DevToolsFeatureFlags.extension-fb'; break; default: console.error(`Invalid target "${target}"`); process.exit(1); } return resolve(__dirname, 'src/config/', f
lsFeatureFlags.core-oss'; break; case 'core/backend-fb': case 'core/standalone-fb': flagsPath = 'DevToolsFeatureFlags.core-fb'; break; case 'extension-oss': flagsPath = 'DevToolsFeatureFlags.ex
{ "filepath": "packages/react-devtools-shared/buildUtils.js", "language": "javascript", "file_size": 1057, "cut_index": 513, "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 strict-local */ import {__PERFORMANCE_PROFILE__} from './constants'; const supportsUserTiming = typeof performance !== 'undefined' && // $FlowFixMe[method-unbinding]...
ing): void { if (supportsUserTiming) { performance.mark(markName + '-end'); performance.measure(markName, markName + '-start', markName + '-end'); performance.clearMarks(markName + '-start'); performance.clearMarks(markName + '-end'); }
typeof performance !== 'undefined' && typeof performance.now === 'function'; function mark(markName: string): void { if (supportsUserTiming) { performance.mark(markName + '-start'); } } function measure(markName: str
{ "filepath": "packages/react-devtools-shared/src/PerformanceLoggingUtils.js", "language": "javascript", "file_size": 2521, "cut_index": 563, "middle_length": 229 }
import {hydrate, fillInPath} from 'react-devtools-shared/src/hydration'; import {backendToFrontendSerializedElementMapper} from 'react-devtools-shared/src/utils'; import Store from 'react-devtools-shared/src/devtools/store'; import TimeoutError from 'react-devtools-shared/src/errors/TimeoutError'; import ElementPolling...
ment as InspectedElementFrontend, SerializedAsyncInfo as SerializedAsyncInfoFrontend, } from 'react-devtools-shared/src/frontend/types'; import type {InspectedElementPath} from 'react-devtools-shared/src/frontend/types'; export function clearErrorsAndWa
AsyncInfo as SerializedAsyncInfoBackend, } from 'react-devtools-shared/src/backend/types'; import type { BackendEvents, FrontendBridge, } from 'react-devtools-shared/src/bridge'; import type { DehydratedData, InspectedEle
{ "filepath": "packages/react-devtools-shared/src/backendAPI.js", "language": "javascript", "file_size": 9042, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactStrictMode', () => { let React; let ReactDOMClient; let act; beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOMClient = require('r...
Effect mount`); return () => log.push(`${label}: useLayoutEffect unmount`); }); log.push(`${label}: render`); return null; } it('should default to not strict', async () => { await act(() => { const contain
l}) { React.useEffect(() => { log.push(`${label}: useEffect mount`); return () => log.push(`${label}: useEffect unmount`); }); React.useLayoutEffect(() => { log.push(`${label}: useLayout
{ "filepath": "packages/react/src/__tests__/ReactStrictMode-test.internal.js", "language": "javascript", "file_size": 4644, "cut_index": 614, "middle_length": 229 }
ct-core */ 'use strict'; describe('forwardRef', () => { let React; let ReactNoop; let Scheduler; let waitForAll; beforeEach(() => { jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); const InternalTestUtils = r...
t.forwardRef((props, ref) => ( <Wrapper {...props} forwardedRef={ref} /> )); ReactNoop.render(<RefForwardingComponent value={123} />); await waitForAll([123]); }); it('should forward a ref for a single child', async () => { clas
render() { Scheduler.log(this.props.value); return null; } } function Wrapper(props) { return <Child {...props} ref={props.forwardedRef} />; } const RefForwardingComponent = Reac
{ "filepath": "packages/react/src/__tests__/forwardRef-test.internal.js", "language": "javascript", "file_size": 5706, "cut_index": 716, "middle_length": 229 }
EV__ && console.createTask ? // eslint-disable-next-line react-internal/no-production-logging console.createTask : () => null; function getTaskName(type) { if (type === REACT_FRAGMENT_TYPE) { return '<>'; } if ( typeof type === 'object' && type !== null && type.$$typeof === REACT_LA...
nternals.A; if (dispatcher === null) { return null; } return dispatcher.getOwner(); } return null; } // v8 (Chromium, Node.js) defaults to 10 // SpiderMonkey (Firefox) does not support Error.stackTraceLimit // JSC (Safari) defaults t
.>'; } try { const name = getComponentNameFromType(type); return name ? '<' + name + '>' : '<...>'; } catch (x) { return '<...>'; } } function getOwner() { if (__DEV__) { const dispatcher = ReactSharedI
{ "filepath": "packages/react/src/jsx/ReactJSXElement.js", "language": "javascript", "file_size": 28664, "cut_index": 1331, "middle_length": 229 }
act-devtools-shared/src/backend'; import {__DEBUG__} from 'react-devtools-shared/src/constants'; import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor'; import { getDefaultComponentFilters, getIsReloadAndProfileSupported, } from 'react-devtools-shared/src/uti...
Options = { host?: string, nativeStyleEditorValidAttributes?: $ReadOnlyArray<string>, path?: string, port?: number, useHttps?: boolean, resolveRNStyle?: ResolveNativeStyle, retryConnectionDelay?: number, isAppActive?: () => boolean, webso
ook, DevToolsHookSettings, ProfilingSettings, } from 'react-devtools-shared/src/backend/types'; import type {ResolveNativeStyle} from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor'; type Connect
{ "filepath": "packages/react-devtools-core/src/backend.js", "language": "javascript", "file_size": 12636, "cut_index": 921, "middle_length": 229 }
quire('../react-devtools-extensions/chrome/manifest.json'); const firefoxManifest = require('../react-devtools-extensions/firefox/manifest.json'); const minChromeVersion = parseInt(chromeManifest.minimum_chrome_version, 10); const minFirefoxVersion = parseInt( firefoxManifest.browser_specific_settings.gecko.strict_m...
nChromeVersion.toString(); targets.firefox = minFirefoxVersion.toString(); let additionalTargets = process.env.BABEL_CONFIG_ADDITIONAL_TARGETS; if (additionalTargets) { additionalTargets = JSON.parse(additionalTargets); for (const
ew Error('Suspicious browser version in manifest: ' + version); } module.exports = api => { const isTest = api.env('test'); const targets = {}; if (isTest) { targets.node = 'current'; } else { targets.chrome = mi
{ "filepath": "packages/react-devtools-shared/babel.config.js", "language": "javascript", "file_size": 1573, "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 */ import type { ReactRenderer, RendererInterface, DevToolsHook, RendererID, ProfilingSettings, } from 'react-devtools-shared/src/backend/types'; import type {C...
the backend that is compatible with all older React versions function isMatchingRender(version: string): boolean { return !hasAssignedBackend(version); } export default function attachRenderer( hook: DevToolsHook, id: RendererID, renderer: ReactR
'react-devtools-shared/src/backend/fiber/renderer'; import {attach as attachLegacy} from 'react-devtools-shared/src/backend/legacy/renderer'; import {hasAssignedBackend} from 'react-devtools-shared/src/backend/utils'; // this is
{ "filepath": "packages/react-devtools-shared/src/attachRenderer.js", "language": "javascript", "file_size": 2470, "cut_index": 563, "middle_length": 229 }
ls-shared/src/devtools/store'; import {getSavedComponentFilters} from 'react-devtools-shared/src/utils'; import {registerDevToolsEventLogger} from 'react-devtools-shared/src/registerDevToolsEventLogger'; import {Server} from 'ws'; import {join} from 'path'; import {readFileSync} from 'fs'; import DevTools from 'react-d...
; export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error'; export type StatusListener = (message: string, status: StatusTypes) => void; export type OnDisconnectedCallback = () => void; let node: HTMLElement = ((null: any): HTMLEleme
constants'; import {localStorageSetItem} from 'react-devtools-shared/src/storage'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type {ReactFunctionLocation, ReactCallSite} from 'shared/ReactTypes'
{ "filepath": "packages/react-devtools-core/src/standalone.js", "language": "javascript", "file_size": 11893, "cut_index": 921, "middle_length": 229 }
ct-core * @jest-environment node */ 'use strict'; describe('ReactProfiler DevTools integration', () => { let React; let ReactFeatureFlags; let ReactTestRenderer; let Scheduler; let AdvanceTime; let hook; let waitForAll; let waitFor; let act; beforeEach(() => { global.__REACT_DEVTOOLS_GLOBAL...
est-renderer'); const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; waitFor = InternalTestUtils.waitFor; act = InternalTestUtils.act; AdvanceTime = class extends React.Component {
dules(); ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.enableProfilerTimer = true; Scheduler = require('scheduler'); React = require('react'); ReactTestRenderer = require('react-t
{ "filepath": "packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js", "language": "javascript", "file_size": 5916, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ export const CHROME_WEBSTORE_EXTENSION_ID = 'fmkadmapgofadopljbjfkapdkoienihi'; export const INTERNAL_EXTENSION_ID = 'dnjnjgbfilfphmojnmhliehogmojhclc'; export const LOCAL_EXTENSION_ID = 'ikiahnapldjmdmpkmfhjdjilojjhgc...
ON = 4; export const TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS = 5; // Removed `TREE_OPERATION_REMOVE_ROOT` export const TREE_OPERATION_SET_SUBTREE_MODE = 7; export const SUSPENSE_TREE_OPERATION_ADD = 8; export const SUSPENSE_TREE_OPERATION_REMOVE = 9; expo
gs. export const __PERFORMANCE_PROFILE__ = false; export const TREE_OPERATION_ADD = 1; export const TREE_OPERATION_REMOVE = 2; export const TREE_OPERATION_REORDER_CHILDREN = 3; export const TREE_OPERATION_UPDATE_TREE_BASE_DURATI
{ "filepath": "packages/react-devtools-shared/src/constants.js", "language": "javascript", "file_size": 3768, "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 */ export default class EventEmitter<Events: Object> { listenersMap: Map<string, Array<Function>> = new Map(); addListener<Event: $Keys<Eve...
id { const listeners = this.listenersMap.get(event); if (listeners !== undefined) { if (listeners.length === 1) { // No need to clone or try/catch const listener = listeners[0]; listener.apply(null, args); } else
(event, [listener]); } else { const index = listeners.indexOf(listener); if (index < 0) { listeners.push(listener); } } } emit<Event: $Keys<Events>>(event: Event, ...args: Events[Event]): vo
{ "filepath": "packages/react-devtools-shared/src/events.js", "language": "javascript", "file_size": 1908, "cut_index": 537, "middle_length": 229 }
import {__DEBUG__} from 'react-devtools-shared/src/constants'; import type {HooksTree} from 'react-debug-tools/src/ReactDebugHooks'; import type { Thenable, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import type { Element, HookNames, } from 'react-devtools-shared/src/frontend/types'; im...
-line react-hooks-published/rules-of-hooks return React.use(record); } catch (x) { if (record.status === 'rejected') { return null; } throw x; } } if (record.status === 'fulfilled') { return record.value; }
from './PerformanceLoggingUtils'; import {logEvent} from './Logger'; const TIMEOUT = 30000; function readRecord<T>(record: Thenable<T>): T | null { if (typeof React.use === 'function') { try { // eslint-disable-next
{ "filepath": "packages/react-devtools-shared/src/hookNamesCache.js", "language": "javascript", "file_size": 6672, "cut_index": 716, "middle_length": 229 }
short'): symbol), readonly: (Symbol('readonly'): symbol), size: (Symbol('size'): symbol), type: (Symbol('type'): symbol), unserializable: (Symbol('unserializable'): symbol), }; export type Dehydrated = { inspectable: boolean, name: string | null, preview_long: string | null, preview_short: string | nul...
e: string | null, preview_long: string | null, preview_short: string | null, readonly?: boolean, size?: number, type: string, unserializable: boolean, [string | number]: any, }; // This threshold determines the depth at which the bridge "deh
can't be serialized without losing type information, // so a "Unserializable" type wrapper is used (with meta-data keys) to send nested values- // while preserving the original type and name. export type Unserializable = { nam
{ "filepath": "packages/react-devtools-shared/src/hydration.js", "language": "javascript", "file_size": 23000, "cut_index": 1331, "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 strict-local */ import type {LoggerEvent} from 'react-devtools-shared/src/Logger'; import {registerEventLogger} from 'react-devtools-shared/src/Logger'; import {enableLo...
enableLogger) { if (currentLoggingIFrame != null && currentSessionId != null) { const {metadata, ...eventWithoutMetadata} = event; const additionalContext: LoggerContext | {} = fetchAdditionalContext != null ? await fetchAdd
, }; export function registerDevToolsEventLogger( surface: string, fetchAdditionalContext?: | (() => LoggerContext) | (() => Promise<LoggerContext>), ): void { async function logEvent(event: LoggerEvent) { if (
{ "filepath": "packages/react-devtools-shared/src/registerDevToolsEventLogger.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 SourceMapConsumer from 'react-devtools-shared/src/hooks/SourceMapConsumer'; import type {ReactFunctionLocation} from 'shared/ReactTypes'; import type {FetchFileWithCaching} from 'react-devtools-shared/src/devto...
umber, // 1-based column: number, // 1-based ): Promise<SourceMappedLocation | null> { const key = `${sourceURL}:${line}:${column}`; const cachedPromise = symbolicationCache.get(key); if (cachedPromise != null) { return cachedPromise; } co
tion: ReactFunctionLocation, ignored: boolean, // Whether the file for this location was ignore listed }; export function symbolicateSourceWithCache( fetchFileWithCaching: FetchFileWithCaching, sourceURL: string, line: n
{ "filepath": "packages/react-devtools-shared/src/symbolicateSource.js", "language": "javascript", "file_size": 4834, "cut_index": 614, "middle_length": 229 }
unction, ElementTypeMemo, ElementTypeVirtual, } from 'react-devtools-shared/src/frontend/types'; import { localStorageGetItem, localStorageSetItem, sessionStorageGetItem, sessionStorageRemoveItem, sessionStorageSetItem, } from 'react-devtools-shared/src/storage'; import {meta} from './hydration'; import i...
sOwnProperty = Object.prototype.hasOwnProperty; const cachedDisplayNames: WeakMap<Function, string> = new WeakMap(); // On large trees, encoding takes significant time. // Try to reuse the already encoded strings. const encodedStringCache: LRUCache<strin
t type { ProfilingSettings, SerializedElement as SerializedElementBackend, } from 'react-devtools-shared/src/backend/types'; import {isSynchronousXHRSupported} from './backend/utils'; // $FlowFixMe[method-unbinding] const ha
{ "filepath": "packages/react-devtools-shared/src/utils.js", "language": "javascript", "file_size": 39606, "cut_index": 2151, "middle_length": 229 }
require('webpack'); const { GITHUB_URL, getVersionString, } = require('react-devtools-extensions/utils'); const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils'); const NODE_ENV = process.env.NODE_ENV; if (!NODE_ENV) { console.error('NODE_ENV not set'); process.exit(1); } const builtModulesD...
ion', devtool: __DEV__ ? 'eval-cheap-module-source-map' : 'source-map', entry: { backend: './src/backend.js', }, output: { path: __dirname + '/dist', filename: '[name].js', // This name is important; standalone references it in ord
et = process.env.FEATURE_FLAG_TARGET || 'core/backend-oss'; // This targets RN/Hermes. process.env.BABEL_CONFIG_ADDITIONAL_TARGETS = JSON.stringify({ ie: '11', }); module.exports = { mode: __DEV__ ? 'development' : 'product
{ "filepath": "packages/react-devtools-core/webpack.backend.js", "language": "javascript", "file_size": 2492, "cut_index": 563, "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. * * */ const { useMemo, useState } = require('react'); function Component(props) { const InnerComponent = useMemo(() => () => { const [state] = useState(0...
ckNvbXBvbmVudCIsInN0YXRlIiwiY2FsbGJhY2siLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7OztBQVFBLE1BQU07QUFBQ0EsRUFBQUEsT0FBRDtBQUFVQyxFQUFBQTtBQUFWLElBQXNCQyxPQUFPLENBQUMsT0FBRCxDQUFuQzs7QUFFQSxTQUFTQyxTQUFULENBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixR
zLCJzZWN0aW9ucyI6W3sib2Zmc2V0Ijp7ImxpbmUiOjAsImNvbHVtbiI6MH0sIm1hcCI6eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhOZXN0ZWRIb29rcy5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlU3RhdGUiLCJyZXF1aXJlIiwiQ29tcG9uZW50IiwicHJvcHMiLCJJbm5l
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/react-sources-extended/index-map/ComponentWithNestedHooks.js", "language": "javascript", "file_size": 2188, "cut_index": 563, "middle_length": 229 }
/constants'; import attachRenderer from './attachRenderer'; import formatConsoleArguments from 'react-devtools-shared/src/backend/utils/formatConsoleArguments'; import formatWithStyles from 'react-devtools-shared/src/backend/utils/formatWithStyles'; // React's custom built component stack strings match "\s{4}in" // Ch...
rsions of React didn't do. // To compare if it's equivalent we strip out the suffix to see if they're // still equivalent. Similarly, we sometimes use [] and sometimes () so we // strip them to for the comparison. const frameDiffs = / \(\<anonymous\>\)$|\@
onst ROW_COLUMN_NUMBER_REGEX = /:\d+:\d+(\n|$)/; function isStringComponentStack(text: string): boolean { return PREFIX_REGEX.test(text) || ROW_COLUMN_NUMBER_REGEX.test(text); } // We add a suffix to some frames that older ve
{ "filepath": "packages/react-devtools-shared/src/hook.js", "language": "javascript", "file_size": 26144, "cut_index": 1331, "middle_length": 229 }
import LRU from 'lru-cache'; import { convertInspectedElementBackendToFrontend, hydrateHelper, inspectElement as inspectElementAPI, inspectScreen as inspectScreenAPI, } from 'react-devtools-shared/src/backendAPI'; import {fillInPath} from 'react-devtools-shared/src/hydration'; import type {LRUCache} from 'reac...
ment, InspectedElement as InspectedElementFrontend, InspectedElementResponseType, InspectedElementPath, } from 'react-devtools-shared/src/frontend/types'; // Maps element ID to inspected data. // We use an LRU for this rather than a WeakMap because
atedPath, } from 'react-devtools-shared/src/backend/types'; import UserError from 'react-devtools-shared/src/errors/UserError'; import UnknownHookError from 'react-devtools-shared/src/errors/UnknownHookError'; import type { Ele
{ "filepath": "packages/react-devtools-shared/src/inspectedElementMutableSource.js", "language": "javascript", "file_size": 6000, "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. * * @emails react-core */ 'use strict'; describe('onlyChild', () => { let React; let WrapComponent; beforeEach(() => { React = require('react'...
> ); React.Children.only(instance.props.children); }).toThrow(); }); it('should fail when passed nully values', () => { expect(function () { const instance = <WrapComponent>{null}</WrapComponent>; React.Children.only(in
</div> ); } }; }); it('should fail when passed two children', () => { expect(function () { const instance = ( <WrapComponent> <div /> <span /> </WrapComponent
{ "filepath": "packages/react/src/__tests__/onlyChild-test.js", "language": "javascript", "file_size": 1930, "cut_index": 537, "middle_length": 229 }
React.Component().updater, ); }); it('should throw when `render` is not specified', () => { expect(function () { createReactClass({}); }).toThrowError('Class specification must implement a `render` method.'); }); it('should copy prop types onto the Constructor', () => { const propValidat...
propTypes: { prop: null, }, render: function () { return <span>{this.props.prop}</span>; }, }); assertConsoleErrorDev([ 'Warning: Component: prop type `prop` is invalid; ' + 'it must be a function, us
expect(TestComponent.propTypes).toBeDefined(); expect(TestComponent.propTypes.value).toBe(propValidator); }); it('should warn on invalid prop types', () => { createReactClass({ displayName: 'Component',
{ "filepath": "packages/react/src/__tests__/createReactClassIntegration-test.js", "language": "javascript", "file_size": 30110, "cut_index": 1331, "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 */ import ErrorStackParser from 'error-stack-parser'; import testErrorStack, { SOURCE_STACK_FRAME_LINE_NUMBER, } from './ErrorTesterCompiled'; let sourceMapsAreAppliedToErrors: boolean |...
ToErrors = false; } catch (error) { const parsed = ErrorStackParser.parse(error); const topStackFrame = parsed[0]; const lineNumber = topStackFrame.lineNumber; if (lineNumber === SOURCE_STACK_FRAME_LINE_NUMBER) { sourceM
{ testErrorStack(); sourceMapsAreApplied
{ "filepath": "packages/react-devtools-shared/src/hooks/ErrorTester.js", "language": "javascript", "file_size": 989, "cut_index": 582, "middle_length": 52 }
ineProperty(exports, '__esModule', { value: true, }); exports.default = testErrorStack; exports.SOURCE_STACK_FRAME_LINE_NUMBER = void 0; /** * 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...
pbInRlc3RFcm9yclN0YWNrIiwiRXJyb3IiLCJTT1VSQ0VfU1RBQ0tfRlJBTUVfTElORV9OVU1CRVIiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBQUE7Ozs7Ozs7O0FBU2UsU0FBU0EsY0FBVCxHQUEwQjtBQUN2QztBQUNBLFFBQU1DLEtBQUssQ0FBQyxrQkFBRCxDQUFYO0FBQ0Q7O0FBRU0sTUFBTUMsOEJBQThCLEdBQUcsRUFBdkMiLCJzb3
AME_LINE_NUMBER = 12; exports.SOURCE_STACK_FRAME_LINE_NUMBER = SOURCE_STACK_FRAME_LINE_NUMBER; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3RFcm9yclN0YWNrLmpzIl0sIm5hbWVzIj
{ "filepath": "packages/react-devtools-shared/src/hooks/ErrorTesterCompiled.js", "language": "javascript", "file_size": 1653, "cut_index": 537, "middle_length": 229 }
ght (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 strict-local */ import type {EncodedHookMap} from './generateHookMap'; export type ReactSourceMetadata = [?EncodedHookMap]; export ...
ourcesArray, +x_react_sources?: ReactSourcesArray, +ignoreList?: Array<number>, }; export type IndexSourceMapSection = { map: BasicSourceMap, offset: { line: number, column: number, ... }, ... }; export type IndexSourceMap = { +
export type BasicSourceMap = { +file?: string, +mappings: string, +names: Array<string>, +sourceRoot?: string, +sources: Array<string>, +sourcesContent?: Array<?string>, +version: number, +x_facebook_sources?: FBS
{ "filepath": "packages/react-devtools-shared/src/hooks/SourceMapTypes.js", "language": "javascript", "file_size": 1322, "cut_index": 524, "middle_length": 229 }
ION: 'CallExpression', MEMBER_EXPRESSION: 'MemberExpression', ARRAY_PATTERN: 'ArrayPattern', IDENTIFIER: 'Identifier', NUMERIC_LITERAL: 'NumericLiteral', VARIABLE_DECLARATOR: 'VariableDeclarator', }); // Check if line number obtained from source map and the line number in hook node match function checkNodeLo...
r, // because this code matches the 1-based Error stack location for the hook Identifier (e.g. useState) // with the larger 0-based VariableDeclarator (e.g. [foo, setFoo] = useState()) // so the ranges should always overlap. // // For m
!== null) { // Column numbers are represented differently between tools/engines. // Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based. // // In practice this will probably never matte
{ "filepath": "packages/react-devtools-shared/src/hooks/astUtils.js", "language": "javascript", "file_size": 22947, "cut_index": 1331, "middle_length": 229 }
-local */ import type { HookMap, HookMapEntry, HookMapLine, HookMapMappings, } from './generateHookMap'; import type {Position} from './astUtils'; import {NO_HOOK_NAME} from './astUtils'; /** * Finds the Hook name assigned to a given location in the source code, * and a HookMap extracted from an extended s...
*/ export function getHookNameForLocation( location: Position, hookMap: HookMap, ): string | null { const {names, mappings} = hookMap; // The HookMap mappings are grouped by lines, so first we look up // which line of mappings covers the targe
d to map * to a name, including a sentinel value that represents a missing * Hook name: '<no-hook>'. * * For more details on the format of the HookMap, see generateHookMap * and the tests for that function and this function.
{ "filepath": "packages/react-devtools-shared/src/hooks/getHookNameForLocation.js", "language": "javascript", "file_size": 8615, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {parse} from '@babel/parser'; import {generateEncodedHookMap, generateHookMap} from '../generateHookMap'; function expectHookMapToEqual(actual, expected) { expect(actual.names).toEqual(expected.names); con...
p', () => { it('should parse names for built-in hooks', () => { const code = ` import {useState, useContext, useMemo, useReducer} from 'react'; export function Component() { const a = useMemo(() => A); const [b, setB] = useState(0); // pretti
xpected to find name at position ${segment[2]}`); } formattedMappings.push(`${name} from ${segment[0]}:${segment[1]}`); }); }); expect(formattedMappings).toEqual(expected.mappings); } describe('generateHookMa
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/generateHookMap-test.js", "language": "javascript", "file_size": 5067, "cut_index": 614, "middle_length": 229 }
sx = require('acorn-jsx'); const rollupResolve = require('@rollup/plugin-node-resolve').nodeResolve; const {encode, decode} = require('@jridgewell/sourcemap-codec'); const {generateEncodedHookMap} = require('../generateHookMap'); const {parse} = require('@babel/parser'); const sourceDir = resolve(__dirname, '__source_...
solve(inlineDir, 'fb-sources-extended'); const externalFbSourcesExtendedDir = resolve( externalDir, 'fb-sources-extended', ); const inlineFbSourcesIndexMapExtendedDir = resolve( inlineFbSourcesExtendedDir, 'index-map', ); const externalFbSourcesInd
ot, 'bundle'); const noColumnsDir = resolve(buildRoot, 'no-columns'); const inlineIndexMapDir = resolve(inlineDir, 'index-map'); const externalIndexMapDir = resolve(externalDir, 'index-map'); const inlineFbSourcesExtendedDir = re
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/updateMockSourceMaps.js", "language": "javascript", "file_size": 10722, "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 */ import React, {useEffect, useState} from 'react'; export function Component() { const countState = useState(0); const count = countState[0]; const setCount = countState[1]; con...
iv> <button onClick={handleClick}>Update count</button> </> ); } function useIsDarkMode() { const darkModeState = useState(false); const [isDarkMode] = darkModeState; useEffect(function useEffectCreate() { // Here is where we may li
ode? {isDarkMode}</div> <div>Count: {count}</d
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/ComponentUsingHooksIndirectly.js", "language": "javascript", "file_size": 963, "cut_index": 582, "middle_length": 52 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ export {Component as ComponentUsingHooksIndirectly} from './ComponentUsingHooksIndirectly'; export {Component as ComponentWithCustomHook} from './ComponentWithCustomHook'; export {Compon...
nentWithNestedHooks'; export {Component as ContainingStringSourceMappingURL} from './ContainingStringSourceMappingURL'; export {Component as Example} from './Example'; export {Component as InlineRequire} from './InlineRequire'; import * as ToDoList from '.
Component as ComponentWithNestedHooks} from './Compo
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/index.js", "language": "javascript", "file_size": 969, "cut_index": 582, "middle_length": 52 }
import * as React from 'react'; import { unstable_getCacheForType as getCacheForType, startTransition, } from 'react'; import Store from 'react-devtools-shared/src/devtools/store'; import {inspectElement as inspectElementMutableSource} from 'react-devtools-shared/src/inspectedElementMutableSource'; import ElementP...
d/src/frontend/types'; function readRecord<T>(record: Thenable<T>): T { if (typeof React.use === 'function') { // eslint-disable-next-line react-hooks-published/rules-of-hooks return React.use(record); } if (record.status === 'fulfilled') {
e, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import type { Element, InspectedElement as InspectedElementFrontend, InspectedElementResponseType, InspectedElementPath, } from 'react-devtools-share
{ "filepath": "packages/react-devtools-shared/src/inspectedElementCache.js", "language": "javascript", "file_size": 7981, "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 */ export function localStorageGetItem(key: string): any { try { return localStorage.getItem(key); } catch (erro...
or) { return null; } } export function sessionStorageRemoveItem(key: string): void { try { sessionStorage.removeItem(key); } catch (error) {} } export function sessionStorageSetItem(key: string, value: any): void { try { return sessio
ey: string, value: any): void { try { return localStorage.setItem(key, value); } catch (error) {} } export function sessionStorageGetItem(key: string): any { try { return sessionStorage.getItem(key); } catch (err
{ "filepath": "packages/react-devtools-shared/src/storage.js", "language": "javascript", "file_size": 1051, "cut_index": 513, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {__DEBUG__} from 'react-devtools-shared/src/constants'; import type { Thenable, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import * as React from 'react'; const TIMEOUT = 30000; t...
ct.use === 'function') { try { // eslint-disable-next-line react-hooks-published/rules-of-hooks return React.use(record); } catch (x) { if (x === null) { return null; } throw x; } } if (record.status ==
ent cache would also clear this cache. // Modules are static anyway. const moduleLoaderFunctionToModuleMap: Map<ModuleLoaderFunction, Module> = new Map(); function readRecord<T>(record: Thenable<T>): T | null { if (typeof Rea
{ "filepath": "packages/react-devtools-shared/src/dynamicImportCache.js", "language": "javascript", "file_size": 4340, "cut_index": 614, "middle_length": 229 }
-local */ import type {Position} from './astUtils'; import type { ReactSourceMetadata, IndexSourceMap, BasicSourceMap, MixedSourceMap, } from './SourceMapTypes'; import type {HookMap} from './generateHookMap'; import * as util from 'source-map-js/lib/util'; import {decodeHookMap} from './generateHookMap'; imp...
es are normalized using the same logic that the `source-map-js@0.6.2` package uses internally. * This is crucial for keeping the sources list in sync with a `SourceMapConsumer` instance. */ function normalizeSourcePath( sourceInput: string, map: {+so
FB_METADATA = 1; const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources'; const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources'; /** * Extracted from the logic in source-map-js@0.6.2's SourceMapConsumer. * By default, source nam
{ "filepath": "packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js", "language": "javascript", "file_size": 6974, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {getHookNamesMappingFromAST} from './astUtils'; import {encode, decode} from '@jridgewell/sourcemap-codec'; // Missing types in @babel/types type File = any; export type HookMap = { names: $ReadOnlyArray<stri...
TODO below) ]; export type HookMapLine = HookMapEntry[]; export type HookMapMappings = HookMapLine[]; /** * Given a parsed source code AST, returns a "Hook Map", which is a * mapping which maps locations in the source code to their to their * correspo
type HookMapEntry = [ number, // 1-indexed line number number, // 0-indexed column number number, // 0-indexed index into names array number, // TODO: filler number to support reusing encoding from `sourcemap-codec` (see
{ "filepath": "packages/react-devtools-shared/src/hooks/generateHookMap.js", "language": "javascript", "file_size": 3950, "cut_index": 614, "middle_length": 229 }
=> { console.trace('source-map-support'); }); fetchMock = initFetchMock(); inspectHooks = require('react-debug-tools/src/ReactDebugHooks').inspectHooks; // Jest can't run the workerized version of this module. const { flattenHooksList, loadSourceAndMetadata, } = requir...
// Runs in a Worker because it's CPU intensive: return parseSourceAndMetadata( hooksList, locationKeyToHookSourceAndMetadata, ); }; // Jest (jest-runner?) configures Errors to automatically account for source maps.
oksTree => { const hooksList = flattenHooksList(hooksTree); // Runs in the UI thread so it can share Network cache: const locationKeyToHookSourceAndMetadata = await loadSourceAndMetadata(hooksList);
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js", "language": "javascript", "file_size": 41989, "cut_index": 2151, "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 */ import React, {useDebugValue, useEffect, useState} from 'react'; export function Component() { const [count, setCount] = useState(0); const isDarkMode = useIsDarkMode(); const {fo...
lick={handleClick}>Update count</button> </> ); } function useIsDarkMode() { const [isDarkMode] = useState(false); useEffect(function useEffectCreate() { // Here is where we may listen to a "theme" event... }, []); return isDarkMode; }
</div> <div>Foo: {foo}</div> <button onC
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/ComponentWithCustomHook.js", "language": "javascript", "file_size": 960, "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 strict-local */ import {enableLogger} from 'react-devtools-feature-flags'; export type LoggerEvent = | { +event_name: 'loaded-dev-tools', } | { +even...
+duration_ms: number, +inspected_element_display_name: string | null, +inspected_element_number_of_hooks: number | null, } | { +event_name: 'select-element', +metadata: { +source: string, }, } | {
} | { +event_name: 'selected-profiler-tab', } | { +event_name: 'selected-suspense-tab', } | { +event_name: 'load-hook-names', +event_status: 'success' | 'error' | 'timeout' | 'unknown',
{ "filepath": "packages/react-devtools-shared/src/Logger.js", "language": "javascript", "file_size": 2420, "cut_index": 563, "middle_length": 229 }
mport {withSyncPerfMeasurements} from 'react-devtools-shared/src/PerformanceLoggingUtils'; import {decode} from '@jridgewell/sourcemap-codec'; import type { IndexSourceMap, IndexSourceMapSection, BasicSourceMap, MixedSourceMap, } from './SourceMapTypes'; type SearchPosition = { columnNumber: number, lineN...
sumerType { if (sourceMapJSON.sections != null) { return IndexedSourceMapConsumer(((sourceMapJSON: any): IndexSourceMap)); } else { return BasicSourceMapConsumer(((sourceMapJSON: any): BasicSourceMap)); } } function BasicSourceMapConsumer(so
pe = { originalPositionFor: SearchPosition => ResultPosition, }; type Mappings = Array<Array<Array<number>>>; export default function SourceMapConsumer( sourceMapJSON: MixedSourceMap | IndexSourceMapSection, ): SourceMapCon
{ "filepath": "packages/react-devtools-shared/src/hooks/SourceMapConsumer.js", "language": "javascript", "file_size": 6651, "cut_index": 716, "middle_length": 229 }
directly.js"; function Component() { const countState = React.useState(0); const count = countState[0]; const setCount = countState[1]; const darkMode = useIsDarkMode(); const [isDarkMode] = darkMode; React.useEffect(() => {// ... }, []); const handleClick = () => setCount(count + 1); return /*#__PU...
_PURE__*/React__default.createElement("button", { onClick: handleClick, __source: { fileName: _jsxFileName, lineNumber: 30, columnNumber: 7 } }, "Update count")); } function useIsDarkMode() { const darkModeState = React.u
olumnNumber: 7 } }, "Dark mode? ", isDarkMode), /*#__PURE__*/React__default.createElement("div", { __source: { fileName: _jsxFileName, lineNumber: 29, columnNumber: 7 } }, "Count: ", count), /*#_
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/bundle/index.js", "language": "javascript", "file_size": 11337, "cut_index": 921, "middle_length": 229 }
ineProperty(exports, "__esModule", { value: true }); exports.Component = Component; var _react = _interopRequireDefault(require("react")); var _useTheme = _interopRequireDefault(require("./useTheme")); var _jsxFileName = ""; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: ob...
XBvbmVudCIsInRoZW1lIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7O0FBQ0E7Ozs7OztBQUVPLFNBQVNBLFNBQVQsR0FBcUI7QUFDMUIsUUFBTUMsS0FBSyxHQUFHLHdCQUFkO0FBRUEsc0JBQU87QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsZ0JBQWFBLEtBQWIsQ0FBUDtBQUNEIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gK
ber: 16, columnNumber: 10 } }, "theme: ", theme); } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhFeHRlcm5hbEN1c3RvbUhvb2tzLmpzIl0sIm5hbWVzIjpbIkNvb
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ComponentWithExternalCustomHooks.js", "language": "javascript", "file_size": 1525, "cut_index": 537, "middle_length": 229 }
Module", { 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 source tree. * * */ const A = /*#__PURE__*/(0, _r...
VyY2VzIjpbIkNvbXBvbmVudFdpdGhNdWx0aXBsZUhvb2tzUGVyTGluZS5qcyJdLCJuYW1lcyI6WyJBIiwiQiIsIkNvbXBvbmVudCIsImEiLCJiIiwiYyIsImQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFTQTs7QUFUQTs7Ozs7Ozs7QUFXQSxNQUFNQSxDQUFDLGdCQUFHLDBCQUFjLENBQWQsQ0FBVjtBQUNBLE1BQU1DLENBQUMsZ0JBQUcsME
gnore const c = (0, _react.useContext)(A), d = (0, _react.useContext)(B); // eslint-disable-line one-var return a + b + c + d; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ComponentWithMultipleHooksPerLine.js", "language": "javascript", "file_size": 2170, "cut_index": 563, "middle_length": 229 }
mponent; 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 _interopRequireWildcard(obj) { i...
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) { cache.set(obj, ne
he && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) {
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ContainingStringSourceMappingURL.js", "language": "javascript", "file_size": 3149, "cut_index": 614, "middle_length": 229 }
trict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Component = Component; /** * 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. * * */ function Compone...
wQixDQUExQixDQUFoQjs7QUFFQSxTQUFPRixLQUFQO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgRmFjZWJvb2ssIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTEl
MiXSwibmFtZXMiOlsiQ29tcG9uZW50IiwiY291bnQiLCJyZXF1aXJlIiwidXNlU3RhdGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7Ozs7Ozs7QUFTTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxJQUFVQyxPQUFPLENBQUMsT0FBRCxDQUFQLENBQWlCQyxRQUFqQixDQUE
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/InlineRequire.js", "language": "javascript", "file_size": 1244, "cut_index": 518, "middle_length": 229 }
interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Obj...
on ListItem({ item, removeItem, toggleItem }) { const handleDelete = (0, React.useCallback)(() => { removeItem(item); }, [item, removeItem]); const handleToggle = (0, React.useCallback)(() => { toggleItem(item); }, [item, toggleItem])
riptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } functi
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ToDoList.js", "language": "javascript", "file_size": 13750, "cut_index": 921, "middle_length": 229 }
import {parse} from '@babel/parser'; import {generateHookMap} from '../generateHookMap'; import {getHookNameForLocation} from '../getHookNameForLocation'; function expectHookMapToEqual(actual, expected) { expect(actual.names).toEqual(expected.names); const formattedMappings = []; actual.mappings.forEach(lines =...
=> { const code = ` import {useState, useContext, useMemo, useReducer} from 'react'; export function Component() { const a = useMemo(() => A); const [b, setB] = useState(0); // prettier-ignore const c = useContext(A), d = useContext(B); // e
formattedMappings.push(`${name} from ${segment[0]}:${segment[1]}`); }); }); expect(formattedMappings).toEqual(expected.mappings); } describe('generateHookMap', () => { it('should parse names for built-in hooks', ()
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/getHookNameForLocation-test.js", "language": "javascript", "file_size": 7852, "cut_index": 716, "middle_length": 229 }
etRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !=...
.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function Component() { const [count, setCount] = (0, _react.useState)(0);
efineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ComponentWithCustomHook.js", "language": "javascript", "file_size": 5165, "cut_index": 716, "middle_length": 229 }
yright (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. * * */ const { useMemo, useState } = require('react'); function Component(props) { const InnerComponent = useMemo(() => () => { ...
BvcnRzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7OztBQVFBLE1BQU07QUFBQ0EsRUFBQUEsT0FBRDtBQUFVQyxFQUFBQTtBQUFWLElBQXNCQyxPQUFPLENBQUMsT0FBRCxDQUFuQzs7QUFFQSxTQUFTQyxTQUFULENBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixRQUFNQyxjQUFjLEdBQUdMLE9BQU8sQ0FBQyxNQUFNLE1BQU07QUFDekMsVU
f-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhOZXN0ZWRIb29rcy5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlU3RhdGUiLCJyZXF1aXJlIiwiQ29tcG9uZW50IiwicHJvcHMiLCJJbm5lckNvbXBvbmVudCIsInN0YXRlIiwiY2FsbGJhY2siLCJtb2R1bGUiLCJleH
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/ComponentWithNestedHooks.js", "language": "javascript", "file_size": 1948, "cut_index": 537, "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. * * */ const { useMemo, useState } = require('react'); function Component(props) { const InnerComponent = useMemo(() => () => { const [state] = useState(0...
ckNvbXBvbmVudCIsInN0YXRlIiwiY2FsbGJhY2siLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7OztBQVFBLE1BQU07QUFBQ0EsRUFBQUEsT0FBRDtBQUFVQyxFQUFBQTtBQUFWLElBQXNCQyxPQUFPLENBQUMsT0FBRCxDQUFuQzs7QUFFQSxTQUFTQyxTQUFULENBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixR
zLCJzZWN0aW9ucyI6W3sib2Zmc2V0Ijp7ImxpbmUiOjAsImNvbHVtbiI6MH0sIm1hcCI6eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhOZXN0ZWRIb29rcy5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlU3RhdGUiLCJyZXF1aXJlIiwiQ29tcG9uZW50IiwicHJvcHMiLCJJbm5l
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentWithNestedHooks.js", "language": "javascript", "file_size": 2200, "cut_index": 563, "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__/inline/Example.js", "language": "javascript", "file_size": 3018, "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 strict-local */ import type { BasicSourceMap, MixedSourceMap, IndexSourceMap, } from './SourceMapTypes'; export functi...
dexSourceMap.sections.some(section => { return sourceMapIncludesSource(section.map, source); }); } const basicMap: BasicSourceMap = sourcemap; return basicMap.sources.some( s => s === 'Inline Babel script' || source.endsWith(s), ); }
SourceMap: IndexSourceMap = sourcemap; return in
{ "filepath": "packages/react-devtools-shared/src/hooks/SourceMapUtils.js", "language": "javascript", "file_size": 826, "cut_index": 517, "middle_length": 52 }
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__/inline/index.js", "language": "javascript", "file_size": 4915, "cut_index": 614, "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, useCallback, useState} from 'react'; export function ListItem({item, removeItem, toggleItem}) { const handleDelete...
> ); } export function List(props) { const [newItemText, setNewItemText] = useState(''); const [items, setItems] = useState([ {id: 1, isComplete: true, text: 'First'}, {id: 2, isComplete: true, text: 'Second'}, {id: 3, isComplete: false,
utton onClick={handleDelete}>Delete</button> <label> <input checked={item.isComplete} onChange={handleToggle} type="checkbox" />{' '} {item.text} </label> </li
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/ToDoList.js", "language": "javascript", "file_size": 2924, "cut_index": 563, "middle_length": 229 }
ineProperty(exports, "__esModule", { value: true }); exports.default = useTheme; exports.ThemeContext = void 0; 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...
W1lIiwidGhlbWUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBU0E7O0FBVEE7Ozs7Ozs7O0FBV08sTUFBTUEsWUFBWSxnQkFBRywwQkFBYyxRQUFkLENBQXJCOzs7QUFFUSxTQUFTQyxRQUFULEdBQW9CO0FBQ2pDLFFBQU1DLEtBQUssR0FBRyx1QkFBV0YsWUFBWCxDQUFkO0FBQ0EsNEJBQWNFLEtBQWQ7QUFDQSxTQUFPQSxLQUFQO0FBQ0QiL
t)(ThemeContext); (0, _react.useDebugValue)(theme); return theme; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInVzZVRoZW1lLmpzIl0sIm5hbWVzIjpbIlRoZW1lQ29udGV4dCIsInVzZVRoZ
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/useTheme.js", "language": "javascript", "file_size": 1665, "cut_index": 537, "middle_length": 229 }
etRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !=...
.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function Component() { const [count, setCount] = (0, _react.useState)(0);
efineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/index-map/ComponentWithCustomHook.js", "language": "javascript", "file_size": 5253, "cut_index": 716, "middle_length": 229 }
ineProperty(exports, "__esModule", { value: true }); exports.Component = Component; var _react = _interopRequireDefault(require("react")); var _useTheme = _interopRequireDefault(require("./useTheme")); var _jsxFileName = ""; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: ob...
CJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhFeHRlcm5hbEN1c3RvbUhvb2tzLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsInRoZW1lIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7O0FBQ0E7Ozs7OztBQUVPLFNBQVNBLFNBQVQsR0FBcUI7QUFDMUIsUUFBTUMsS0FBSyxHQUFHLHdCQUFkO0FBRUEsc0JBQU87QUFBQTtBQUFBO0FBQUE7Q
ber: 16, columnNumber: 10 } }, "theme: ", theme); } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzZWN0aW9ucyI6W3sib2Zmc2V0Ijp7ImxpbmUiOjAsImNvbHVtbiI6MH0sIm1hcCI6eyJ2ZXJzaW9uIjozL
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/index-map/ComponentWithExternalCustomHooks.js", "language": "javascript", "file_size": 1613, "cut_index": 537, "middle_length": 229 }
mponent; 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 _interopRequireWildcard(obj) { i...
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) { cache.set(obj, ne
he && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) {
{ "filepath": "packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/inline/index-map/ContainingStringSourceMappingURL.js", "language": "javascript", "file_size": 3237, "cut_index": 614, "middle_length": 229 }