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. * * @flow */ import type {ReactNodeList} from 'shared/ReactTypes'; import type {Request} from 'react-server/src/ReactFizzServer'; import type {Destination} from 'react-server/src/ReactServerStreamConfig'; import type {BootstrapSc...
: Array<string>, bootstrapModules: Array<string>, progressiveChunkSize?: number, onError: (error: mixed) => void, unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor, }; opaque type Stream = { destination: Destination, request: Re
r'; import { createResumableState, createRenderState, createRootFormatContext, } from 'react-server/src/ReactFizzConfig'; type Options = { identifierPrefix?: string, bootstrapScriptContent?: string, bootstrapScripts
{ "filepath": "packages/react-server-dom-fb/src/ReactDOMServerFB.js", "language": "javascript", "file_size": 3135, "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 * as React from 'react'; import {useContext} from 'react'; import {createPortal} from 'react-dom'; import SearchInput fro...
ntext, ); if (searchInputContainerRef.current === null) { return null; } const search = (text: string) => dispatch({type: 'SET_SEARCH_TEXT', payload: text}); const goToNextResult = () => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}); c
xport default function TimelineSearchInput(props: Props): React.Node { const {searchInputContainerRef} = useContext(TimelineContext); const {dispatch, searchIndex, searchResults, searchText} = useContext( TimelineSearchCo
{ "filepath": "packages/react-devtools-timeline/src/TimelineSearchInput.js", "language": "javascript", "file_size": 1450, "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 */ import {createResource} from 'react-devtools-shared/src/devtools/cache'; import {importFile} from './import-worker'; import typ...
(resolve, reject) => { const promise = ((importFile( file, ): any): Promise<ImportWorkerOutputData>); promise.then(data => { switch (data.status) { case 'SUCCESS': resolve(data.processed
ource = Resource<void, File, TimelineData | Error>; export default function createDataResourceFromImportedFile( file: File, ): DataResource { return createResource( () => { return new Promise<TimelineData | Error>(
{ "filepath": "packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js", "language": "javascript", "file_size": 1315, "cut_index": 524, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type { Thenable, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import type {TimelineData} from './types'; import * as React from 'react'; import {importFile as importFileWorker} from '...
// eslint-disable-next-line react-hooks-published/rules-of-hooks return React.use(record); } catch (x) { if (record.status === 'rejected') { return (record.reason: any); } throw x; } } if (record.status ==
ile contents are static anyway. const fileNameToProfilerDataMap: Map< string, Thenable<TimelineData>, > = new Map(); function readRecord<T>(record: Thenable<T>): T | Error { if (typeof React.use === 'function') { try {
{ "filepath": "packages/react-devtools-timeline/src/timelineCache.js", "language": "javascript", "file_size": 3132, "cut_index": 614, "middle_length": 229 }
mport type {StackFrame as ErrorStackFrame} from 'error-stack-parser'; import type {ScrollState} from './view-base/utils/scrollState'; // Source: https://github.com/facebook/flow/issues/4002#issuecomment-323612798 // eslint-disable-next-line no-unused-vars type Return_<R, F: (...args: Array<any>) => R> = R; /** Get ret...
ning: string | null, }; type BaseReactScheduleEvent = { ...BaseReactEvent, +lanes: ReactLane[], }; export type ReactScheduleRenderEvent = { ...BaseReactScheduleEvent, +type: 'schedule-render', }; export type ReactScheduleStateUpdateEvent = { ...
ort type NativeEvent = { +depth: number, +duration: Milliseconds, +timestamp: Milliseconds, +type: string, warning: string | null, }; type BaseReactEvent = { +componentName?: string, +timestamp: Milliseconds, war
{ "filepath": "packages/react-devtools-timeline/src/types.js", "language": "javascript", "file_size": 6773, "cut_index": 716, "middle_length": 229 }
import type {ReactComponentMeasure, TimelineData, ViewState} from '../types'; import type { Interaction, IntrinsicSize, MouseMoveInteraction, Rect, ViewRefs, } from '../view-base'; import { durationToWidth, positioningScaleFactor, positionToTimestamp, timestampToPosition, } from './utils/positioning'...
Map<string, boolean>; _cachedSearchRegExp: RegExp | null = null; _hoveredComponentMeasure: ReactComponentMeasure | null = null; _intrinsicSize: IntrinsicSize; _profilerData: TimelineData; _viewState: ViewState; onHover: ((event: ReactComponen
m '../view-base'; import {BORDER_SIZE, COLORS, NATIVE_EVENT_HEIGHT} from './constants'; const ROW_WITH_BORDER_HEIGHT = NATIVE_EVENT_HEIGHT + BORDER_SIZE; export class ComponentMeasuresView extends View { _cachedSearchMatches:
{ "filepath": "packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js", "language": "javascript", "file_size": 8548, "cut_index": 716, "middle_length": 229 }
s, } from '../view-base'; import { BackgroundColorView, Surface, View, layeredLayout, rectContainsPoint, intersectionOfRects, rectIntersectsRect, verticallyStackedLayout, } from '../view-base'; import {isInternalModule} from './utils/moduleFilters'; import { durationToWidth, positioningScaleFactor,...
d79707a693351b806b8710b2f6b7d399 const colorGenerator = new ColorGenerator( {min: 30, max: 330}, {min: 50, max: 80, count: 3}, 85, ); colorGenerator.setColorForID('', {h: 43.6, s: 45.8, l: 90.6, a: 100}); function defaultHslaColorForStackFrame({scri
stants'; import {ColorGenerator, dimmedColor, hslaColorToString} from './utils/colors'; // Source: https://source.chromium.org/chromium/chromium/src/+/master:out/Debug/gen/devtools/timeline/TimelineUIUtils.js;l=2109;drc=fb32e928
{ "filepath": "packages/react-devtools-timeline/src/content-views/FlamechartView.js", "language": "javascript", "file_size": 10895, "cut_index": 921, "middle_length": 229 }
import type {NativeEvent, TimelineData} from '../types'; import type { Interaction, IntrinsicSize, MouseMoveInteraction, Rect, ViewRefs, } from '../view-base'; import { durationToWidth, positioningScaleFactor, positionToTimestamp, timestampToPosition, } from './utils/positioning'; import {drawText} f...
; _hoveredEvent: NativeEvent | null = null; _intrinsicSize: IntrinsicSize; _maxDepth: number = 0; _profilerData: TimelineData; onHover: ((event: NativeEvent | null) => void) | null = null; constructor(surface: Surface, frame: Rect, profilerDa
ort {COLORS, NATIVE_EVENT_HEIGHT, BORDER_SIZE} from './constants'; const ROW_WITH_BORDER_HEIGHT = NATIVE_EVENT_HEIGHT + BORDER_SIZE; export class NativeEventsView extends View { _depthToNativeEvent: Map<number, NativeEvent[]>
{ "filepath": "packages/react-devtools-timeline/src/content-views/NativeEventsView.js", "language": "javascript", "file_size": 6790, "cut_index": 716, "middle_length": 229 }
import type {NetworkMeasure, TimelineData} from '../types'; import type { Interaction, IntrinsicSize, MouseMoveInteraction, Rect, ViewRefs, } from '../view-base'; import { durationToWidth, positioningScaleFactor, positionToTimestamp, timestampToPosition, } from './utils/positioning'; import {drawText...
/; export class NetworkMeasuresView extends View { _depthToNetworkMeasure: Map<number, NetworkMeasure[]>; _hoveredNetworkMeasure: NetworkMeasure | null = null; _intrinsicSize: IntrinsicSize; _maxDepth: number = 0; _profilerData: TimelineData;
import {BORDER_SIZE, COLORS, SUSPENSE_EVENT_HEIGHT} from './constants'; const HEIGHT = SUSPENSE_EVENT_HEIGHT; // TODO Constant name const ROW_WITH_BORDER_HEIGHT = HEIGHT + BORDER_SIZE; const BASE_URL_REGEX = /([^:]+:\/\/[^\/]+)
{ "filepath": "packages/react-devtools-timeline/src/content-views/NetworkMeasuresView.js", "language": "javascript", "file_size": 9139, "cut_index": 716, "middle_length": 229 }
} from '../utils/formatting'; import {drawText} from './utils/text'; import { durationToWidth, positioningScaleFactor, positionToTimestamp, timestampToPosition, } from './utils/positioning'; import { View, Surface, rectContainsPoint, rectIntersectsRect, intersectionOfRects, } from '../view-base'; imp...
ull; constructor(surface: Surface, frame: Rect, profilerData: TimelineData) { super(surface, frame); this._profilerData = profilerData; this._performPreflightComputations(); } _performPreflightComputations() { this._lanesToRender =
uresView extends View { _intrinsicSize: IntrinsicSize; _lanesToRender: ReactLane[]; _profilerData: TimelineData; _hoveredMeasure: ReactMeasure | null = null; onHover: ((measure: ReactMeasure | null) => void) | null = n
{ "filepath": "packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js", "language": "javascript", "file_size": 11131, "cut_index": 921, "middle_length": 229 }
import type {SchedulingEvent, TimelineData} from '../types'; import type { ClickInteraction, Interaction, MouseMoveInteraction, Rect, Size, ViewRefs, } from '../view-base'; import { positioningScaleFactor, timestampToPosition, positionToTimestamp, widthToDuration, } from './utils/positioning'; impo...
vent: SchedulingEvent | null = null; onHover: ((event: SchedulingEvent | null) => void) | null = null; onClick: | ((event: SchedulingEvent | null, eventIndex: number | null) => void) | null = null; constructor(surface: Surface, frame: Rect,
from './constants'; const EVENT_ROW_HEIGHT_FIXED = TOP_ROW_PADDING + REACT_EVENT_DIAMETER + TOP_ROW_PADDING; export class SchedulingEventsView extends View { _profilerData: TimelineData; _intrinsicSize: Size; _hoveredE
{ "filepath": "packages/react-devtools-timeline/src/content-views/SchedulingEventsView.js", "language": "javascript", "file_size": 7297, "cut_index": 716, "middle_length": 229 }
import type {Snapshot, TimelineData} from '../types'; import type { Interaction, Point, Rect, Size, Surface, ViewRefs, } from '../view-base'; import {positioningScaleFactor, timestampToPosition} from './utils/positioning'; import { intersectionOfRects, rectContainsPoint, rectEqualToRect, View, } fr...
this._intrinsicSize = { width: profilerData.duration, height: profilerData.snapshotHeight, }; this._profilerData = profilerData; } desiredSize(): Size { return this._intrinsicSize; } draw(context: CanvasRenderingContext2D)
Location: Point | null = null; _intrinsicSize: Size; _profilerData: TimelineData; onHover: OnHover | null = null; constructor(surface: Surface, frame: Rect, profilerData: TimelineData) { super(surface, frame);
{ "filepath": "packages/react-devtools-timeline/src/content-views/SnapshotsView.js", "language": "javascript", "file_size": 6730, "cut_index": 716, "middle_length": 229 }
sitioningScaleFactor, positionToTimestamp, timestampToPosition, widthToDuration, } from './utils/positioning'; import {drawText} from './utils/text'; import {formatDuration} from '../utils/formatting'; import { View, Surface, rectContainsPoint, rectIntersectsRect, intersectionOfRects, } from '../view-ba...
mber = 0; _profilerData: TimelineData; onHover: ((event: SuspenseEvent | null) => void) | null = null; constructor(surface: Surface, frame: Rect, profilerData: TimelineData) { super(surface, frame); this._profilerData = profilerData;
MAX_ROWS_TO_SHOW_INITIALLY = 3; export class SuspenseEventsView extends View { _depthToSuspenseEvent: Map<number, SuspenseEvent[]>; _hoveredEvent: SuspenseEvent | null = null; _intrinsicSize: IntrinsicSize; _maxDepth: nu
{ "filepath": "packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js", "language": "javascript", "file_size": 9540, "cut_index": 921, "middle_length": 229 }
import type {ThrownError, TimelineData} from '../types'; import type { Interaction, MouseMoveInteraction, Rect, Size, ViewRefs, } from '../view-base'; import { positioningScaleFactor, timestampToPosition, positionToTimestamp, widthToDuration, } from './utils/positioning'; import { View, Surface, ...
ll; onHover: ((event: ThrownError | null) => void) | null = null; constructor(surface: Surface, frame: Rect, profilerData: TimelineData) { super(surface, frame); this._profilerData = profilerData; this._intrinsicSize = { width: this
st EVENT_ROW_HEIGHT_FIXED = TOP_ROW_PADDING + REACT_EVENT_DIAMETER + TOP_ROW_PADDING; export class ThrownErrorsView extends View { _profilerData: TimelineData; _intrinsicSize: Size; _hoveredEvent: ThrownError | null = nu
{ "filepath": "packages/react-devtools-timeline/src/content-views/ThrownErrorsView.js", "language": "javascript", "file_size": 6016, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {Rect, Size} from '../view-base'; import { durationToWidth, positioningScaleFactor, positionToTimestamp, timestampToPosition, } from './utils/positioning'; import { View, Surface, rectInterse...
mber; _intrinsicSize: Size; constructor(surface: Surface, frame: Rect, totalDuration: number) { super(surface, frame); this._totalDuration = totalDuration; this._intrinsicSize = { width: this._totalDuration, height: HEADER_HEIG
VAL_SIZE_PX, BORDER_SIZE, } from './constants'; const HEADER_HEIGHT_FIXED = MARKER_HEIGHT + BORDER_SIZE; const LABEL_FIXED_WIDTH = LABEL_SIZE + BORDER_SIZE; export class TimeAxisMarkersView extends View { _totalDuration: nu
{ "filepath": "packages/react-devtools-timeline/src/content-views/TimeAxisMarkersView.js", "language": "javascript", "file_size": 4540, "cut_index": 614, "middle_length": 229 }
import type {UserTimingMark} from '../types'; import type { Interaction, MouseMoveInteraction, Rect, Size, ViewRefs, } from '../view-base'; import { positioningScaleFactor, timestampToPosition, positionToTimestamp, widthToDuration, } from './utils/positioning'; import { View, Surface, rectConta...
r: ((mark: UserTimingMark | null) => void) | null = null; constructor( surface: Surface, frame: Rect, marks: UserTimingMark[], duration: number, ) { super(surface, frame); this._marks = marks; this._intrinsicSize = {
GHT_FIXED = TOP_ROW_PADDING + USER_TIMING_MARK_SIZE + TOP_ROW_PADDING; export class UserTimingMarksView extends View { _marks: UserTimingMark[]; _intrinsicSize: Size; _hoveredMark: UserTimingMark | null = null; onHove
{ "filepath": "packages/react-devtools-timeline/src/content-views/UserTimingMarksView.js", "language": "javascript", "file_size": 5793, "cut_index": 716, "middle_length": 229 }
_TEXT_PADDING = 8; export const COLOR_HOVER_DIM_DELTA = 5; export const TOP_ROW_PADDING = 4; export const NATIVE_EVENT_HEIGHT = 14; export const SUSPENSE_EVENT_HEIGHT: number = 14; export const PENDING_SUSPENSE_EVENT_SIZE = 8; export const REACT_EVENT_DIAMETER = 6; export const USER_TIMING_MARK_SIZE = 8; export const R...
string, INTERNAL_MODULE_FRAME_HOVER: string, INTERNAL_MODULE_FRAME_TEXT: string, NATIVE_EVENT: string, NATIVE_EVENT_HOVER: string, NETWORK_PRIMARY: string, NETWORK_PRIMARY_HOVER: string, NETWORK_SECONDARY: string, NETWORK_SECONDARY_HOVER:
NTERVAL_TIMES = [ 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, ]; export const MIN_INTERVAL_SIZE_PX = 70; // TODO Replace this with "export let" vars export let COLORS: { BACKGROUND: string, INTERNAL_MODULE_FRAME:
{ "filepath": "packages/react-devtools-timeline/src/content-views/constants.js", "language": "javascript", "file_size": 10481, "cut_index": 921, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ type ColorSpace = number | {min: number, max: number, count?: number}; // Docstrings from https://www.w3schools.com/css/css_colors_hsl.asp type HslaColor = $ReadOnly<{ /** Hue is a degree on the color wheel from 0 t...
ing({h, s, l, a}: HslaColor): string { return `hsl(${h}deg ${s}% ${l}% / ${a})`; } export function dimmedColor(color: HslaColor, dimDelta: number): HslaColor { return { ...color, l: color.l - dimDelta, }; } // Source: https://source.chromiu
a percentage, 0% is black, 50% is neither light or dark, 100% is white. */ l: number, /** Alpha is a percentage, 0% is fully transparent, and 100 is not transparent at all. */ a: number, }>; export function hslaColorToStr
{ "filepath": "packages/react-devtools-timeline/src/content-views/utils/colors.js", "language": "javascript", "file_size": 3522, "cut_index": 614, "middle_length": 229 }
import type { DevToolsHook, ReactRenderer, } from 'react-devtools-shared/src/backend/types'; import {hasAssignedBackend} from 'react-devtools-shared/src/backend/utils'; import {COMPACT_VERSION_NAME} from 'react-devtools-extensions/src/utils'; import {getIsReloadAndProfileSupported} from 'react-devtools-shared/src/u...
called more than once for a single welcome message. // The exact circumstances of this are unclear, though it seems related to 3rd party event batching code. // // Regardless, call this method multiple times can cause DevTools to add duplicate eleme
ackends = new Set<string>(); function welcome(event: $FlowFixMe) { if ( event.source !== window || event.data.source !== 'react-devtools-content-script' ) { return; } // In some circumstances, this method is
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/backendManager.js", "language": "javascript", "file_size": 6527, "cut_index": 716, "middle_length": 229 }
global chrome */ function fetchResource(url) { const reject = value => { chrome.runtime.sendMessage({ source: 'react-devtools-fetch-resource-content-script', payload: { type: 'fetch-file-with-cache-error', url, value, }, }); }; const resolve = value => { chr...
r => reject(null)); } else { reject(null); } }, error => reject(null), ); } chrome.runtime.onMessage.addListener(message => { if ( message?.source === 'devtools-page' && message?.payload?.type === 'fetch-file-with-c
}); }; fetch(url, {cache: 'force-cache', signal: AbortSignal.timeout(60000)}).then( response => { if (response.ok) { response .text() .then(text => resolve(text)) .catch(erro
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/fileFetcher.js", "language": "javascript", "file_size": 1060, "cut_index": 515, "middle_length": 229 }
m './messages'; import type {DevToolsHookSettings} from 'react-devtools-shared/src/backend/types'; import type {ComponentFilter} from 'react-devtools-shared/src/frontend/types'; import {installHook} from 'react-devtools-shared/src/hook'; import { getIfReloadedAndProfiling, getProfilingSettings, } from 'react-devto...
ct-devtools-settings-injector') { const payload = event.data.payload; // In case handshake message was sent prior to hookSettingsInjector execution // We can't guarantee order if (payload.handshake) { postMessage({ source: 're
=> void; let resolveComponentFiltersInjection: (filters: Array<ComponentFilter>) => void; function messageListener(event: UnknownMessageEvent) { if (event.source !== window) { return; } if (event.data.source === 'rea
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/installHook.js", "language": "javascript", "file_size": 2318, "cut_index": 563, "middle_length": 229 }
rome */ let lastSentDevToolsHookMessage; // We want to detect when a renderer attaches, and notify the "background page" // (which is shared between tabs and can highlight the React icon). // Currently we are in "content script" context, so we can't listen to the hook directly // (it will be injected directly into th...
'react-devtools-hook') { const {source: messageSource, payload} = data; const message = {source: messageSource, payload}; lastSentDevToolsHookMessage = message; chrome.runtime.sendMessage(message); } }); // NOTE: Firefox WebExtensions c
function onMessage({data, source}) { if (source !== window || !data) { return; } // We keep this logic here and not in `proxy.js`, because proxy content script is injected later at `document_end` if (data.source ===
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/prepareInjection.js", "language": "javascript", "file_size": 1466, "cut_index": 524, "middle_length": 229 }
* global chrome */ 'use strict'; function injectProxy() { // Firefox's behaviour for injecting this content script can be unpredictable // While navigating the history, some content scripts might not be re-injected and still be alive if (!window.__REACT_DEVTOOLS_PROXY_INJECTED__) { window.__REACT_DEVTOOLS_P...
> { if (backendInitialized) { clearInterval(intervalID); } else { sayHelloToBackendManager(); } }, 500); } } function handlePageShow() { if (document.prerendering) { // React DevTools can't handle multiple doc
page reload, the content script might be loaded before the backend manager is injected. // Because of this we need to poll the backend manager until it has been initialized. const intervalID: IntervalID = setInterval(() =
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/proxy.js", "language": "javascript", "file_size": 5094, "cut_index": 716, "middle_length": 229 }
* An array that contains all the object results that have been * returned by this mock function call */ results: Array<{isThrow: boolean, value: TReturn}>, }, /** * Resets all information stored in the mockFn.mock.calls and * mockFn.mock.instances arrays. Often this is useful when you want ...
* original implementation in others. Beware that mockFn.mockRestore only * works when mock was created with jest.spyOn. Thus you have to take care of * restoration yourself when manually assigning jest.fn(). */ mockRestore(): void, /** * Ac
store a mock back to its initial state. */ mockReset(): void, /** * Removes the mock and restores the initial implementation. This is useful * when you want to mock functions in certain test cases and restore the
{ "filepath": "packages/react-devtools-extensions/flow-typed/jest.js", "language": "javascript", "file_size": 33754, "cut_index": 1331, "middle_length": 229 }
strict'; const {exec} = require('child-process-promise'); const {Finder} = require('firefox-profile'); const {resolve} = require('path'); const {argv} = require('yargs'); const EXTENSION_PATH = resolve('./firefox/build/unpacked'); const START_URL = argv.url || 'https://react.dev/'; const firefoxVersion = process.en...
htly': return 'default-nightly'; case 'firefoxdeveloperedition': return 'dev-edition-default'; default: // Fall back to using the default Firefox profile for testing purposes. // This prevents users from having to re-login-t
mes from https://searchfox.org/mozilla-central/source/toolkit/profile/xpcshell/head.js#96 switch (firefoxVersion) { case 'firefox': return 'default-release'; case 'beta': return 'default-beta'; case 'nig
{ "filepath": "packages/react-devtools-extensions/firefox/test.js", "language": "javascript", "file_size": 1933, "cut_index": 537, "middle_length": 229 }
ct-core */ 'use strict'; let React; let ReactDOMServer; let Suspense; describe('ReactDOMServerFB', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOMServer = require('../ReactDOMServerFB'); Suspense = React.Suspense; }); const theError = new Error('This is an e...
const stream = ReactDOMServer.renderToStream(<div>hello world</div>, { onError(x) { console.error(x); }, }); const result = readResult(stream); expect(result).toMatchInlineSnapshot(`"<div>hello world</div>"`); }); it('
(stream) { let result = ''; while (!ReactDOMServer.hasFinished(stream)) { result += ReactDOMServer.renderNextChunk(stream); } return result; } it('should be able to render basic HTML', async () => {
{ "filepath": "packages/react-server-dom-fb/src/__tests__/ReactDOMServerFB-test.internal.js", "language": "javascript", "file_size": 5535, "cut_index": 716, "middle_length": 229 }
ent(props) { useCustomEffect(() => { console.log(props.foo); }, []); } `, options: [{additionalHooks: 'useAnotherEffect'}], }, { code: normalizeIndent` function MyComponent(props) { useWithoutEffectSuffix(() => { console.log...
> { console.log(local); }, []); `, }, { // Valid because we don't care about hooks outside of components. code: normalizeIndent` const local1 = {}; { const local2 = {}; useEffe
console.log(props.foo); }, []); } `, }, { // Valid because we don't care about hooks outside of components. code: normalizeIndent` const local = {}; useEffect(() =
{ "filepath": "packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js", "language": "javascript", "file_size": 265793, "cut_index": 13624, "middle_length": 229 }
---------------------------------------------------------------------- // Helpers //------------------------------------------------------------------------------ /** * Checks whether or not a given segment is reachable. * @param {CodePathSegment} segment A segment to check. * @returns {boolean} `true` if the segme...
ray of the previous segments. * This array includes unreachable segments. * @param {boolean} reachable A flag which shows this is reachable. */ constructor(id, allPrevSegments, reachable) { /** * The identifier of this code path.
------------------------------------------------------------------------- /** * A code path segment. */ class CodePathSegment { /** * @param {string} id An identifier. * @param {CodePathSegment[]} allPrevSegments An ar
{ "filepath": "packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-segment.js", "language": "javascript", "file_size": 6372, "cut_index": 716, "middle_length": 229 }
disable-next-line const CodePathState = require('./code-path-state'); // eslint-disable-next-line const IdGenerator = require('./id-generator'); //------------------------------------------------------------------------------ // Public Interface //-----------------------------------------------------------------------...
ooping. */ constructor({id, origin, upper, onLooped}) { /** * The identifier of this code path. * Rules use it to store additional information of each rule. * @type {string} */ this.id = id; /** * The reason that
ifier. * @param {string} options.origin The type of code path origin. * @param {CodePath|null} options.upper The code path of the upper function scope. * @param {Function} options.onLooped A callback function to notify l
{ "filepath": "packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path.js", "language": "javascript", "file_size": 6506, "cut_index": 716, "middle_length": 229 }
opyright (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. */ 'use strict'; // TODO: this doesn't make sense for an ESLint rule. // We need to fix our build process to not create bundles for "raw" ...
ode’s cjs-module-lexer to make named imports work // https://github.com/facebook/react/issues/34801#issuecomment-3433478810 // eslint-disable-next-line ft-flow/no-unused-expressions 0 && (module.exports = { meta: true, rules: true, configs: t
plugin-react-hooks.development.js'); } // Hint to N
{ "filepath": "packages/eslint-plugin-react-hooks/npm/index.js", "language": "javascript", "file_size": 841, "cut_index": 520, "middle_length": 52 }
NetworkMeasuresView, ReactMeasuresView, SchedulingEventsView, SnapshotsView, SuspenseEventsView, ThrownErrorsView, TimeAxisMarkersView, UserTimingMarksView, } from './content-views'; import {COLORS} from './content-views/constants'; import {clampState, moveStateToRange} from './view-base/utils/scrollStat...
; type Props = { profilerData: TimelineData, viewState: ViewState, }; function CanvasPage({profilerData, viewState}: Props): React.Node { return ( <div className={styles.CanvasPage} style={{backgroundColor: COLORS.BACKGROUND}}>
lineContext} from './TimelineContext'; import CanvasPageContextMenu from './CanvasPageContextMenu'; import type {ContextMenuRef} from 'react-devtools-shared/src/devtools/ContextMenu/types'; import styles from './CanvasPage.css'
{ "filepath": "packages/react-devtools-timeline/src/CanvasPage.js", "language": "javascript", "file_size": 21069, "cut_index": 1331, "middle_length": 229 }
import type {ViewState} from './types'; import * as React from 'react'; import { Suspense, useContext, useDeferredValue, useLayoutEffect, useRef, useState, } from 'react'; import {SettingsContext} from 'react-devtools-shared/src/devtools/views/Settings/SettingsContext'; import {ProfilerContext} from 'react...
; import {importFile} from './timelineCache'; import TimelineSearchInput from './TimelineSearchInput'; import TimelineNotSupported from './TimelineNotSupported'; import {TimelineSearchContextController} from './TimelineSearchContext'; import styles from '
'react-devtools-shared/src/devtools/views/Profiler/RecordingInProgress'; import {updateColorsToMatchTheme} from './content-views/constants'; import {TimelineContext} from './TimelineContext'; import CanvasPage from './CanvasPage'
{ "filepath": "packages/react-devtools-timeline/src/Timeline.js", "language": "javascript", "file_size": 5262, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactContext, RefObject} from 'shared/ReactTypes'; import * as React from 'react'; import { createContext, useContext, useMemo, useRef, useState, useSyncExternalStore, } from 'react'; import {...
: RefObject, setFile: (file: File | null) => void, viewState: ViewState, selectEvent: ReactEventInfo => void, selectedEvent: ReactEventInfo, }; const TimelineContext: ReactContext<Context> = createContext<Context>( ((null: any): Context), ); Tim
eactEventInfo, } from './types'; export type Context = { file: File | null, inMemoryTimelineData: Array<TimelineData> | null, isPerformanceTracksSupported: boolean, isTimelineSupported: boolean, searchInputContainerRef
{ "filepath": "packages/react-devtools-timeline/src/TimelineContext.js", "language": "javascript", "file_size": 4929, "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 */ /* global chrome */ 'use strict'; import type {ReactBuildType} from 'react-devtools-shared/src/backend/types'; function setExtensionIconAndPopup( re...
'48': chrome.runtime.getURL(`icons/48-${reactBuildType}.png`), '128': chrome.runtime.getURL(`icons/128-${reactBuildType}.png`), }, }); chrome.action.setPopup({ tabId, popup: chrome.runtime.getURL(`popups/${reactBuildType}.html`), }
ime.getURL(`icons/32-${reactBuildType}.png`),
{ "filepath": "packages/react-devtools-extensions/src/background/setExtensionIconAndPopup.js", "language": "javascript", "file_size": 902, "cut_index": 547, "middle_length": 52 }
nder the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {evalScripts} from '../evalScripts'; window.addEventListener('message', event => { if (event.data?.source === 'react-devtools-content-script-eval') { const {scriptId, args, requestId} = event.data...
ll, args); } catch (err) { response.error = err.message; } window.postMessage( { source: 'react-devtools-content-script-eval-response', payload: { requestId, response, }, }, '*
response.result = evalScripts[scriptId].fn.apply(nu
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/fallbackEvalContext.js", "language": "javascript", "file_size": 932, "cut_index": 606, "middle_length": 52 }
hrome.storage domain from scripts which are injected in ExecutionWorld.MAIN // This is the only purpose of this script - to send persisted settings to installHook.js content script import type {UnknownMessageEvent} from './messages'; import type { DevToolsHookSettings, DevToolsSettings, } from 'react-devtools-shar...
handshake) { const settings: Partial<DevToolsSettings> = await chrome.storage.local.get(); // If storage was empty (first installation), define default settings const hookSettings: DevToolsHookSettings = { appendComponentS
evtools-shared/src/utils'; async function messageListener(event: UnknownMessageEvent) { if (event.source !== window) { return; } if (event.data.source === 'react-devtools-hook-installer') { if (event.data.payload.
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/hookSettingsInjector.js", "language": "javascript", "file_size": 2475, "cut_index": 563, "middle_length": 229 }
818d1b // flow-typed version: 9c71eca8ef/react-test-renderer_v16.x.x/flow_>=v0.47.x // Type definitions for react-test-renderer 16.x.x // Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer 'use strict'; /* eslint-disable no-unused-vars */ type ReactComponentInstanc...
propName: string]: any}, parent: null | ReactTestInstance, children: Array<ReactTestInstance | string>, find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance, findByType(type: React$ElementType): ReactTestInstance, findByProps
TestRendererJSON & { nodeType: 'component' | 'host', instance: ?ReactComponentInstance, rendered: null | ReactTestRendererTree, }; type ReactTestInstance = { instance: ?ReactComponentInstance, type: string, props: {[
{ "filepath": "packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js", "language": "javascript", "file_size": 2488, "cut_index": 563, "middle_length": 229 }
usr/bin/env node 'use strict'; const chalk = require('chalk'); const build = require('../build'); const main = async () => { await build('firefox'); console.log(chalk.green('\nThe Firefox extension has been built!')); console.log(chalk.green('You can test this build by running:')); console.log(chalk.gray('\...
redition, nightly, beta):' ) ); console.log('WEB_EXT_FIREFOX=nightly yarn run test:firefox'); console.log(chalk.gray('\n# You can test against older versions too:')); console.log( 'WEB_EXT_FIREFOX=/Applications/Firefox Developer Edition.app
log( chalk.gray( '# First download a release from https://www.mozilla.org/en-US/firefox/channel/desktop/' ) ); console.log( chalk.gray( '# And then tell web-ext which release to use (eg firefoxdevelope
{ "filepath": "packages/react-devtools-extensions/firefox/build.js", "language": "javascript", "file_size": 1094, "cut_index": 515, "middle_length": 229 }
cks whether or not a given node is a `case` node (not `default` node). * @param {ASTNode} node A `SwitchCase` node to check. * @returns {boolean} `true` if the node is a `case` node (not `default` node). */ function isCaseNode(node) { return Boolean(node.test); } /** * Checks if a given node appears as the value...
code * path analysis. * @param {string} operator The operator found in the LogicalExpression node * @returns {boolean} `true` if the operator is "&&" or "||" or "??" */ function isHandledLogicalOperator(operator) { return operator === '&&' || operato
DefinitionValue(node) { const parent = node.parent; return ( parent && parent.type === 'PropertyDefinition' && parent.value === node ); } /** * Checks whether the given logical operator is taken into account for the
{ "filepath": "packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js", "language": "javascript", "file_size": 21724, "cut_index": 1331, "middle_length": 229 }
disable-next-line const assert = require('./assert'); // eslint-disable-next-line const CodePathSegment = require('./code-path-segment'); //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ /** * ...
es `[g, h]`. This `g` is from `a`, `c`, and `e`. * This `h` is from `b`, `d`, and `f`. * @param {ForkContext} context An instance. * @param {number} begin The first index of the previous segments. * @param {number} end The last index of the previous se
nt) { return segment.reachable; } /** * Creates new segments from the specific range of `context.segmentsList`. * * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and * `end` is `-1`, this creat
{ "filepath": "packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js", "language": "javascript", "file_size": 7172, "cut_index": 716, "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 {useMemo} from 'react'; import {copy} from 'clipboard-js'; import prettyMilliseconds from 'pretty-ms'; import ContextMenuContainer from 'react-devtools-shared/src/devtools/Contex...
nu/types'; import type { ReactEventInfo, ReactMeasure, TimelineData, ViewState, } from './types'; function zoomToBatch( data: TimelineData, measure: ReactMeasure, viewState: ViewState, width: number, ) { const {batchUID} = measure; con
oveStateToRange} from './view-base/utils/scrollState'; import {MAX_ZOOM_LEVEL, MIN_ZOOM_LEVEL} from './view-base/constants'; import type { ContextMenuItem, ContextMenuRef, } from 'react-devtools-shared/src/devtools/ContextMe
{ "filepath": "packages/react-devtools-timeline/src/CanvasPageContextMenu.js", "language": "javascript", "file_size": 4594, "cut_index": 614, "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, useMemo, useReducer} from 'react'; import type {ReactComponentMeasure, TimelineData, ViewState} from './type...
, }; type Action = | ACTION_GO_TO_NEXT_SEARCH_RESULT | ACTION_GO_TO_PREVIOUS_SEARCH_RESULT | ACTION_SET_SEARCH_TEXT; type Dispatch = (action: Action) => void; const EMPTY_ARRAY: Array<ReactComponentMeasure> = []; function reducer(state: State, ac
TO_NEXT_SEARCH_RESULT = { type: 'GO_TO_NEXT_SEARCH_RESULT', }; type ACTION_GO_TO_PREVIOUS_SEARCH_RESULT = { type: 'GO_TO_PREVIOUS_SEARCH_RESULT', }; type ACTION_SET_SEARCH_TEXT = { type: 'SET_SEARCH_TEXT', payload: string
{ "filepath": "packages/react-devtools-timeline/src/TimelineSearchContext.js", "language": "javascript", "file_size": 4236, "cut_index": 614, "middle_length": 229 }
low */ import type {DevToolsHookSettings} from 'react-devtools-shared/src/backend/types'; import type {ComponentFilter} from 'react-devtools-shared/src/frontend/types'; export function postMessage(event: UnknownMessageEventData): void { window.postMessage(event); } export interface UnknownMessageEvent extends Me...
pe SettingsInjectorEventData = { source: 'react-devtools-settings-injector', payload: SettingsInjectorEventPayload, }; export type SettingsInjectorEventPayload = | SettingsInjectorEventPayloadHandshake | SettingsInjectorEventPayloadSettings; expo
-devtools-hook-installer', payload: HookInstallerEventPayload, }; export type HookInstallerEventPayload = HookInstallerEventPayloadHandshake; export type HookInstallerEventPayloadHandshake = { handshake: true, }; export ty
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/messages.js", "language": "javascript", "file_size": 1214, "cut_index": 518, "middle_length": 229 }
} `, }, { code: normalizeIndent` // Valid because components can use hooks. function createComponentWithHook() { return function ComponentWithHook() { useHook(); }; } `, }, { code: normalizeIndent` // Valid ...
s. function ComponentWithNormalFunction() { doSomething(); } `, }, { code: normalizeIndent` // Valid because functions can call functions. function normalFunctionWithNormalFunction() {
. function createHook() { return function useHookWithHook() { useHook(); } } `, }, { code: normalizeIndent` // Valid because components can call function
{ "filepath": "packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js", "language": "javascript", "file_size": 65193, "cut_index": 2151, "middle_length": 229 }
n state.loopContext; } let context = state.loopContext; while (context) { if (context.label === label) { return context; } context = context.upper; } /* c8 ignore next */ return null; } /** * Gets a context for a `break` statement. * @param {CodePathState} state A state to get. * @p...
r a `return` statement. * @param {CodePathState} state A state to get. * @returns {TryContext|CodePathState} A context for a `return` statement. */ function getReturnContext(state) { let context = state.tryContext; while (context) { if (context
ate.breakContext; while (context) { if (label ? context.label === label : context.breakable) { return context; } context = context.upper; } /* c8 ignore next */ return null; } /** * Gets a context fo
{ "filepath": "packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js", "language": "javascript", "file_size": 42231, "cut_index": 2151, "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 {isInternalFacebookBuild} from 'react-devtools-feature-flags'; import styles from './TimelineNotSupported.css'; type Props = {...
</a>{' '} instead of the Timeline profiler. </span> </p> </> ); } function UnknownUnsupportedReason() { return ( <> <p className={styles.Paragraph}> Timeline profiler requires a development or prof
<a className={styles.Link} href="https://react.dev/reference/dev-tools/react-performance-tracks" rel="noopener noreferrer" target="_blank"> React Performance tracks
{ "filepath": "packages/react-devtools-timeline/src/TimelineNotSupported.js", "language": "javascript", "file_size": 2636, "cut_index": 563, "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 {hslaColorToString, dimmedColor, ColorGenerator} from '../colors'; describe('hslaColorToString', () => { it('should transform colors to strings', () => { ...
4, }); expect(dimmedColor({h: 1, s: 2, l: 3, a: 4}, -3)).toEqual({ h: 1, s: 2, l: 6, a: 4, }); }); }); describe('ColorGenerator', () => { describe('colorForID', () => { it('should generate a color for an ID', (
6.28% 1.68% / 100)', ); }); }); describe('dimmedColor', () => { it('should dim luminosity using delta', () => { expect(dimmedColor({h: 1, s: 2, l: 3, a: 4}, 3)).toEqual({ h: 1, s: 2, l: 0, a:
{ "filepath": "packages/react-devtools-timeline/src/content-views/utils/__tests__/colors-test.js", "language": "javascript", "file_size": 2808, "cut_index": 563, "middle_length": 229 }
import type {Size, IntrinsicSize, Rect} from './geometry'; import type { Interaction, MouseDownInteraction, MouseMoveInteraction, MouseUpInteraction, WheelPlainInteraction, WheelWithShiftInteraction, } from './useCanvasInteraction'; import type {ScrollState} from './utils/scrollState'; import type {ViewRefs...
PanAndZoomView extends View { _contentView: View; _intrinsicContentWidth: number; _isPanning: boolean = false; _viewState: ViewState; constructor( surface: Surface, frame: Rect, contentView: View, intrinsicContentWidth: number,
e, moveStateToRange, areScrollStatesEqual, translateState, zoomState, } from './utils/scrollState'; import { MAX_ZOOM_LEVEL, MIN_ZOOM_LEVEL, MOVE_WHEEL_DELTA_THRESHOLD, } from './constants'; export class Horizontal
{ "filepath": "packages/react-devtools-timeline/src/view-base/HorizontalPanAndZoomView.js", "language": "javascript", "file_size": 6768, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {Interaction} from './useCanvasInteraction'; import type {Size} from './geometry'; import memoize from 'memoize-one'; import {View} from './View'; import {zeroPoint} from './geometry'; import {DPR} from '...
anvasContext = memoize( ( canvas: HTMLCanvasElement, height: number, width: number, scaleCanvas: boolean = true, ): CanvasRenderingContext2D => { const context = canvas.getContext('2d', {alpha: false}); if (scaleCanvas) {
naCanvas( canvas: HTMLCanvasElement, height: number, width: number, ) { canvas.width = width * DPR; canvas.height = height * DPR; canvas.style.width = `${width}px`; canvas.style.height = `${height}px`; } const getC
{ "filepath": "packages/react-devtools-timeline/src/view-base/Surface.js", "language": "javascript", "file_size": 3870, "cut_index": 614, "middle_length": 229 }
import type {Rect} from './geometry'; import type {View} from './View'; export type LayoutInfo = {view: View, frame: Rect}; export type Layout = LayoutInfo[]; /** * A function that takes a list of subviews, currently laid out in * `existingLayout`, and lays them out into `containingFrame`. */ export type Layouter ...
w.setFrame(frame)); } /** * A no-operation layout; does not modify the layout. */ export const noopLayout: Layouter = layout => layout; /** * Layer views on top of each other. All views' frames will be set to `containerFrame`. * * Equivalent to comp
ews: View[]): Layout { return views.map(viewToLayoutInfo); } /** * Applies `layout`'s `frame`s to its corresponding `view`. */ export function collapseLayoutIntoViews(layout: Layout) { layout.forEach(({view, frame}) => vie
{ "filepath": "packages/react-devtools-timeline/src/view-base/layouter.js", "language": "javascript", "file_size": 5880, "cut_index": 716, "middle_length": 229 }
import type {NormalizedWheelDelta} from './utils/normalizeWheel'; import type {Point} from './geometry'; import {useEffect, useRef} from 'react'; import {normalizeWheel} from './utils/normalizeWheel'; export type ClickInteraction = { type: 'click', payload: { event: MouseEvent, location: Point, }, }; ex...
up', payload: { event: MouseEvent, location: Point, }, }; export type WheelPlainInteraction = { type: 'wheel-plain', payload: { event: WheelEvent, location: Point, delta: NormalizedWheelDelta, }, }; export type WheelWithShiftI
d: { event: MouseEvent, location: Point, }, }; export type MouseMoveInteraction = { type: 'mousemove', payload: { event: MouseEvent, location: Point, }, }; export type MouseUpInteraction = { type: 'mouse
{ "filepath": "packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js", "language": "javascript", "file_size": 6367, "cut_index": 716, "middle_length": 229 }
import type {Rect} from '../geometry'; import type {Surface, ViewRefs} from '../Surface'; import type { Interaction, ClickInteraction, MouseDownInteraction, MouseMoveInteraction, MouseUpInteraction, } from '../useCanvasInteraction'; import {VerticalScrollOverflowView} from './VerticalScrollOverflowView'; imp...
ect: Rect = HIDDEN_RECT; _scrollThumbRect: Rect = HIDDEN_RECT; _verticalScrollOverflowView: VerticalScrollOverflowView; constructor( surface: Surface, frame: Rect, verticalScrollOverflowView: VerticalScrollOverflowView, ) { super(s
t HIDDEN_RECT = { origin: { x: 0, y: 0, }, size: { width: 0, height: 0, }, }; export class VerticalScrollBarView extends View { _contentHeight: number = 0; _isScrolling: boolean = false; _scrollBarR
{ "filepath": "packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/VerticalScrollBarView.js", "language": "javascript", "file_size": 5756, "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 {Rect} from '../geometry'; import type {ScrollState} from '../utils/scrollState'; import type {Surface} from '../Surface'; import type {ViewState} from '.....
_scrollBarView: VerticalScrollBarView; _verticalScrollView: VerticalScrollView; constructor( surface: Surface, frame: Rect, contentView: View, viewState: ViewState, ) { super(surface, frame, withVerticalScrollbarLayout); t
ticalScrollView} from '../VerticalScrollView'; export class VerticalScrollOverflowView extends View { _contentView: View; _isProcessingOnChange: boolean = false; _isScrolling: boolean = false; _scrollOffset: number = 0;
{ "filepath": "packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/VerticalScrollOverflowView.js", "language": "javascript", "file_size": 2724, "cut_index": 563, "middle_length": 229 }
nt, Snapshot, SuspenseEvent, ThrownError, TimelineData, UserTimingMark, } from './types'; import * as React from 'react'; import { formatDuration, formatTimestamp, trimString, getSchedulingEventLabel, } from './utils/formatting'; import {getBatchRange} from './utils/getBatchRange'; import useSmartToo...
eact commit'; case 'render-idle': return 'react idle'; case 'render': return 'react render'; case 'layout-effects': return 'react layout effects'; case 'passive-effects': return 'react passive effects'; default:
elineData, height: number, hoveredEvent: ReactEventInfo | null, origin: Point, width: number, }; function getReactMeasureLabel(type: ReactMeasureType): string | null { switch (type) { case 'commit': return 'r
{ "filepath": "packages/react-devtools-timeline/src/EventTooltip.js", "language": "javascript", "file_size": 13773, "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 { FlamechartStackFrame, InternalModuleSourceToRanges, } from '../../types'; import { CHROME_WEBSTORE_EXTENSION_ID, INTERNAL_EXTENSION_ID, LOCAL_...
e performance.mark(). return false; } // Internal modules are only registered if DevTools was running when the profile was captured, // but DevTools should also hide its own frames to avoid over-emphasizing them. if ( // Handle webpack-int
tackFrame, ): boolean { const {locationColumn, locationLine, scriptUrl} = flamechartStackFrame; if (scriptUrl == null || locationColumn == null || locationLine == null) { // This could indicate a browser-internal API lik
{ "filepath": "packages/react-devtools-timeline/src/content-views/utils/moduleFilters.js", "language": "javascript", "file_size": 2407, "cut_index": 563, "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 {isInternalModule} from '../moduleFilters'; describe('isInternalModule', () => { let map; function createFlamechartStackFrame(scriptUrl, locationLine, loc...
er})`, }; } beforeEach(() => { map = new Map(); map.set('foo', [ [createStackFrame('foo', 10, 0), createStackFrame('foo', 15, 100)], ]); map.set('bar', [ [createStackFrame('bar', 10, 0), createStackFrame('bar', 15, 100)
me, lineNumber, columnNumber) { return { columnNumber: columnNumber, lineNumber: lineNumber, fileName: fileName, functionName: 'test', source: ` at test (${fileName}:${lineNumber}:${columnNumb
{ "filepath": "packages/react-devtools-timeline/src/content-views/utils/__tests__/moduleFilters-test.js", "language": "javascript", "file_size": 2256, "cut_index": 563, "middle_length": 229 }
import type {Interaction} from './useCanvasInteraction'; import type {IntrinsicSize, Rect, Size} from './geometry'; import type {Layouter} from './layouter'; import type {ViewRefs} from './Surface'; import {Surface} from './Surface'; import { rectEqualToRect, intersectionOfRects, rectIntersectsRect, sizeIsEmpt...
subviews: View[] = []; /** * An injected function that lays out our subviews. * @private */ _layouter: Layouter; /** * Whether this view needs to be drawn. * * NOTE: Do not set directly! Use `setNeedsDisplay`. * * @see setNe
to draw custom content or manage * subclasses. */ export class View { _backgroundColor: string | null; currentCursor: string | null = null; surface: Surface; frame: Rect; visibleArea: Rect; superview: ?View;
{ "filepath": "packages/react-devtools-timeline/src/view-base/View.js", "language": "javascript", "file_size": 9073, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ export type Point = $ReadOnly<{x: number, y: number}>; export type Size = $ReadOnly<{width: number, height: number}>; export type IntrinsicSize = { ...Size, // If content is this height or less, hide the scrollbar...
ft`) coordinates. */ type Box = [number, number, number, number]; export const zeroPoint: Point = Object.freeze({x: 0, y: 0}); export const zeroSize: Size = Object.freeze({width: 0, height: 0}); export const zeroRect: Rect = Object.freeze({ origin: zer
ght of the content, or this, whichever is less. maxInitialHeight?: number, }; export type Rect = $ReadOnly<{origin: Point, size: Size}>; /** * Alternative representation of `Rect`. * A tuple of (`top`, `right`, `bottom`, `le
{ "filepath": "packages/react-devtools-timeline/src/view-base/geometry.js", "language": "javascript", "file_size": 4146, "cut_index": 614, "middle_length": 229 }
om './setExtensionIconAndPopup'; function isRestrictedBrowserPage(url) { if (!url) { return true; } const urlProtocol = new URL(url).protocol; return urlProtocol === 'chrome:' || urlProtocol === 'about:'; } function checkAndHandleRestrictedPageIfSo(tab) { if (tab && isRestrictedBrowserPage(tab.url)) { ...
.addListener(tab => checkAndHandleRestrictedPageIfSo(tab)); // Listen to URL changes on the active tab and update the DevTools icon. chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { if (changeInfo.url && isRestrictedBrowserPage(changeInfo
AndHandleRestrictedPageIfSo)); chrome.tabs.onCreated
{ "filepath": "packages/react-devtools-extensions/src/background/tabsManager.js", "language": "javascript", "file_size": 958, "cut_index": 582, "middle_length": 52 }
nder the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {Rect} from '../../view-base'; export function positioningScaleFactor( intrinsicWidth: number, frame: Rect, ): number { return frame.size.width / intrinsicWidth; } export function timestampT...
return (position - frame.origin.x) / scaleFactor; } export function durationToWidth(duration: number, scaleFactor: number): number { return duration * scaleFactor; } export function widthToDuration(width: number, scaleFactor: number): number { retur
scaleFactor: number, frame: Rect, ): number {
{ "filepath": "packages/react-devtools-timeline/src/content-views/utils/positioning.js", "language": "javascript", "file_size": 939, "cut_index": 606, "middle_length": 52 }
import { pointEqualToPoint, sizeEqualToSize, rectEqualToRect, sizeIsValid, sizeIsEmpty, rectIntersectsRect, intersectionOfRects, rectContainsPoint, unionOfRects, } from '../geometry'; describe('pointEqualToPoint', () => { it('should return true when 2 points have the same values', () => { expec...
: -1, y: 2}, {x: 0, y: 1})).toBe(false); expect( pointEqualToPoint({x: 3.1416, y: 0.26534}, {x: 3.14159, y: 0.26535}), ).toBe(false); }); }); describe('sizeEqualToSize', () => { it('should return true when 2 sizes have the same values',
}, {x: 3.14159, y: 0.26535}), ).toBe(true); }); it('should return false when 2 points have different values', () => { expect(pointEqualToPoint({x: 1, y: 1}, {x: 1, y: 0})).toBe(false); expect(pointEqualToPoint({x
{ "filepath": "packages/react-devtools-timeline/src/view-base/__tests__/geometry-test.js", "language": "javascript", "file_size": 8117, "cut_index": 716, "middle_length": 229 }
require('@playwright/test'); const config = require('../../playwright.config'); const semver = require('semver'); test.use(config); test.describe('Components', () => { let page; test.beforeEach(async ({browser}) => { page = await browser.newPage(); await page.goto(config.use.url, { waitUntil: 'domc...
t rows = findAllNodes(container, [ createTestNameSelector('ListItem'), ]); return rows.length; }); expect(appRowCount).toBe(3); const devToolsRowCount = await devToolsUtils.getElementCount( page, 'ListItem'
', async () => { const appRowCount = await page.evaluate(() => { const {createTestNameSelector, findAllNodes} = window.REACT_DOM_APP; const container = document.getElementById('iframe').contentDocument; cons
{ "filepath": "packages/react-devtools-inline/__tests__/__e2e__/components.test.js", "language": "javascript", "file_size": 8890, "cut_index": 716, "middle_length": 229 }
testName => { const {createTestNameSelector, findAllNodes} = window.REACT_DOM_DEVTOOLS; const container = document.getElementById('devtools'); const button = findAllNodes(container, [ createTestNameSelector(testName), ])[0]; button.click(); }, buttonTestName); } async function getElementCo...
); } async function selectElement( page, displayName, waitForOwnersText, waitForSourceLoaded = false ) { await page.evaluate(listItemText => { const {createTestNameSelector, createTextSelector, findAllNodes} = window.REACT_DOM_DEVTOOLS
ner = document.getElementById('devtools'); const rows = findAllNodes(container, [ createTestNameSelector('ComponentTreeListItem'), createTextSelector(listItemText), ]); return rows.length; }, displayName
{ "filepath": "packages/react-devtools-inline/__tests__/__e2e__/devtools-utils.js", "language": "javascript", "file_size": 3075, "cut_index": 614, "middle_length": 229 }
equire('./list-app-utils'); const devToolsUtils = require('./devtools-utils'); const {test, expect} = require('@playwright/test'); const config = require('../../playwright.config'); test.use(config); test.describe('Profiler', () => { let page; test.beforeEach(async ({browser}) => { page = await browser.newPage...
urn await page.evaluate(() => { const {createTestNameSelector, findAllNodes} = window.REACT_DOM_DEVTOOLS; const container = document.getElementById('devtools'); const input = findAllNodes(container, [ createTest
iler'); }); test('should record renders and commits when active', async () => { // Profiling is only available in 16.5 and over runOnlyForReactRange('>=16.5'); async function getSnapshotSelectorText() { ret
{ "filepath": "packages/react-devtools-inline/__tests__/__e2e__/profiler.test.js", "language": "javascript", "file_size": 3103, "cut_index": 614, "middle_length": 229 }
evtools-shared/src/bridge'; import {initBackend} from 'react-devtools-shared/src/backend'; import {installHook} from 'react-devtools-shared/src/hook'; import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor'; import type { BackendBridge, SavedPreferencesParams...
w Promise<Array<ComponentFilter>>(resolve => { resolveComponentFiltersInjection = resolve; }); function startActivation(contentWindow: any, bridge: BackendBridge) { const onSavedPreferences = (data: SavedPreferencesParams) => { // This is the only
rofileSupported, onReloadAndProfile, onReloadAndProfileFlagsReset, } from 'react-devtools-shared/src/utils'; let resolveComponentFiltersInjection: (filters: Array<ComponentFilter>) => void; const componentFiltersPromise = ne
{ "filepath": "packages/react-devtools-inline/src/backend.js", "language": "javascript", "file_size": 3500, "cut_index": 614, "middle_length": 229 }
t {forwardRef} from 'react'; import Bridge from 'react-devtools-shared/src/bridge'; import Store from 'react-devtools-shared/src/devtools/store'; import DevTools from 'react-devtools-shared/src/devtools/views/DevTools'; import {getSavedComponentFilters} from 'react-devtools-shared/src/utils'; import type {Wall} from '...
ortsTraceUpdates: true, supportsTimeline: true, ...config, }); } export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge { if (wall == null) { wall = { listen(fn) { // $FlowFixMe[missing-local-annot]
mport type {Config} from 'react-devtools-shared/src/devtools/store'; export function createStore(bridge: FrontendBridge, config?: Config): Store { return new Store(bridge, { checkBridgeProtocolCompatibility: true, supp
{ "filepath": "packages/react-devtools-inline/src/frontend.js", "language": "javascript", "file_size": 2749, "cut_index": 563, "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 */ /* globals Event$Init */ /** * A bridge event class that extends the W3C Event interface and carries * the native event payload. This is u...
this._propagationStopped = false; } get nativeEvent(): {[string]: mixed} { return this._nativeEvent; } stopPropagation(): void { super.stopPropagation(); this._propagationStopped = true; } stopImmediatePropagation(): void {
_nativeEvent: {[string]: mixed}; _propagationStopped: boolean; constructor( type: string, options: Event$Init, nativeEvent: {[string]: mixed}, ) { super(type, options); this._nativeEvent = nativeEvent;
{ "filepath": "packages/react-native-renderer/src/LegacySyntheticEvent.js", "language": "javascript", "file_size": 1682, "cut_index": 537, "middle_length": 229 }
import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes'; import type {ElementRef, Element, ElementType} from 'react'; import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; import type {RenderRootOptions} from './ReactNativeTypes'; import './ReactFabricInjection'; import { batchedUpdates ...
import {LegacyRoot, ConcurrentRoot} from 'react-reconciler/src/ReactRootTags'; import { findHostInstance_DEPRECATED, findNodeHandle, dispatchCommand, sendAccessibilityEvent, getNodeFromInternalInstanceHandle, isChildPublicInstance, } from './
verableError, } from 'react-reconciler/src/ReactFiberReconciler'; import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal'; import {setBatchingImplementation} from './legacy-events/ReactGenericBatching';
{ "filepath": "packages/react-native-renderer/src/ReactFabric.js", "language": "javascript", "file_size": 7338, "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 strict-local */ import type { PublicInstance, Instance, Props, TextInstance, } from './ReactFiberConfigFabric'; import type {Fiber} from...
ative, node is never a text instance if ( instance.canonical != null && instance.canonical.internalInstanceHandle != null ) { return instance.canonical.internalInstanceHandle; } // $FlowFixMe[incompatible-return] DevTools incorrectly
s is ok in DOM because they types are interchangeable, but in React Native // they aren't. function getInstanceFromNode(node: Instance | TextInstance): Fiber | null { const instance: Instance = (node: $FlowFixMe); // In React N
{ "filepath": "packages/react-native-renderer/src/ReactFabricComponentTree.js", "language": "javascript", "file_size": 1579, "cut_index": 537, "middle_length": 229 }
import type { AnyNativeEvent, LegacyPluginModule, } from './legacy-events/PluginModuleType'; import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import type {ReactSyntheticEvent} from './legacy-events/ReactSyntheticEventType'; import type { RNTopLevelEventType, TopLevelType, } from './legacy-eve...
rom 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; import {getPublicInstance} from './ReactFiberConfigFabric'; import {enableNativeEventTargetEventDispatching} from './ReactNativeFeatureFlags'; export {getListener, registrationNameModu
rt accumulateInto from './legacy-events/accumulateInto'; import getListener from './ReactNativeGetListener'; import {runEventsInBatch} from './legacy-events/EventBatching'; import { RawEventEmitter, dispatchNativeEvent, } f
{ "filepath": "packages/react-native-renderer/src/ReactFabricEventEmitter.js", "language": "javascript", "file_size": 5269, "cut_index": 716, "middle_length": 229 }
a 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 */ const ReactFabricGlobalResponderHandler = { onChange: function (from: any, to: any, blockNativeResponder: boolean) { if (from && from....
to && to.stateNode) { // equivalent to setJSResponder nativeFabricUIManager.setIsJSResponder( to.stateNode.node, true, blockNativeResponder || false, ); } }, }; export default ReactFabricGlobalResponderHandl
} if (
{ "filepath": "packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js", "language": "javascript", "file_size": 810, "cut_index": 536, "middle_length": 14 }
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 './ReactNativeInjectionShared'; import { getFiberCurrentPropsFromNode, getInstanceFromNode, getNodeFromInstance, }...
entPlugin from './legacy-events/ResponderEventPlugin'; setComponentTree( getFiberCurrentPropsFromNode, getInstanceFromNode, getNodeFromInstance, ); ResponderEventPlugin.injection.injectGlobalResponderHandler( ReactFabricGlobalResponderHandler, );
rt ResponderEv
{ "filepath": "packages/react-native-renderer/src/ReactFabricInjection.js", "language": "javascript", "file_size": 795, "cut_index": 524, "middle_length": 14 }
ules provided by RN: import { ReactNativeViewConfigRegistry, deepFreezeAndThrowOnMutationInDev, createPublicInstance, createPublicTextInstance, createAttributePayload, diffAttributePayloads, type PublicInstance as ReactNativePublicInstance, type PublicTextInstance, type PublicRootInstance, } from 'rea...
sterEventHandler, unstable_DefaultEventPriority: FabricDefaultPriority, unstable_DiscreteEventPriority: FabricDiscretePriority, unstable_ContinuousEventPriority: FabricContinuousPriority, unstable_IdleEventPriority: FabricIdlePriority, unstable_g
Node, cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps, cloneNodeWithNewProps, createChildSet: createChildNodeSet, appendChild: appendChildNode, appendChildToSet: appendChildNodeToSet, completeRoot, regi
{ "filepath": "packages/react-native-renderer/src/ReactFiberConfigFabric.js", "language": "javascript", "file_size": 27281, "cut_index": 1331, "middle_length": 229 }
import type {TransitionTypes} from 'react/src/ReactTransitionType'; import type { Instance, Props, Container, SuspendedState, GestureTimeline, } from './ReactFiberConfigFabric'; import {allocateTag} from './ReactFiberConfigFabric'; const { applyViewTransitionName: fabricApplyViewTransitionName, createVi...
e<void>, ready: Promise<void>, ... }; interface ViewTransitionPseudoElementType extends mixin$Animatable { _pseudo: string; _name: string; } function ViewTransitionPseudoElement( this: ViewTransitionPseudoElementType, pseudo: string, name:
veFabricUIManager; export type InstanceMeasurement = { rect: {x: number, y: number, width: number, height: number}, abs: boolean, clip: boolean, view: boolean, }; export type RunningViewTransition = { finished: Promis
{ "filepath": "packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js", "language": "javascript", "file_size": 6567, "cut_index": 716, "middle_length": 229 }
import type { AnyNativeEvent, EventTypes, LegacyPluginModule, } from './legacy-events/PluginModuleType'; import type {TopLevelType} from './legacy-events/TopLevelEventTypes'; import SyntheticEvent from './legacy-events/SyntheticEvent'; // Module provided by RN: import {ReactNativeViewConfigRegistry} from 'react-...
the below functions were inlined from // EventPropagator.js, as they deviated from ReactDOM's newer // implementations. // $FlowFixMe[missing-local-annot] function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) { const registrationNam
ulated from './legacy-events/forEachAccumulated'; import {HostComponent} from 'react-reconciler/src/ReactWorkTags'; const {customBubblingEventTypes, customDirectEventTypes} = ReactNativeViewConfigRegistry; // Start of inline:
{ "filepath": "packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js", "language": "javascript", "file_size": 6363, "cut_index": 716, "middle_length": 229 }
nder the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // These globals are set by React Native (e.g. in setUpDOM.js, setUpTimers.js) // and provide access to RN's feature flags. We use global functions because we // don't have another mechanism to pass feature fla...
eEventTargetEventDispatching == null) { _enableNativeEventTargetEventDispatching = typeof RN$isNativeEventTargetEventDispatchingEnabled === 'function' && RN$isNativeEventTargetEventDispatchingEnabled(); } return _enableNativeEventTarget
rgetEventDispatching(): boolean { if (_enableNativ
{ "filepath": "packages/react-native-renderer/src/ReactNativeFeatureFlags.js", "language": "javascript", "file_size": 934, "cut_index": 606, "middle_length": 52 }
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import type {TouchedViewDataAtPoint, InspectorData} from './ReactNativeTypes'; import { findCurrentHostFiber, findCurrentFiberUsingSlowPath, } from 'react-reconciler/src/ReactFiberTreeReflection'; import getComponentNameFromType from 'shared/getCo...
: ( closestInstance: Fiber | null, ) => InspectorData; if (__DEV__) { const emptyObject = Object.freeze({}); // $FlowFixMe[missing-local-annot] const createHierarchy = function (fiberHierarchy) { return fiberHierarchy.map(fiber => ({ na
eactNativePrivateInterface'; import {getNodeFromInternalInstanceHandle} from './ReactNativePublicCompat'; import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactFiberComponentStack'; let getInspectorDataForInstance
{ "filepath": "packages/react-native-renderer/src/ReactNativeFiberInspector.js", "language": "javascript", "file_size": 6099, "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 type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import {getFiberCurrentPropsFromNode} from './l...
stener = props[registrationName]; if (listener && typeof listener !== 'function') { throw new Error( `Expected \`${registrationName}\` listener to be a function, instead got a value of \`${typeof listener}\` type.`, ); } return listen
ll) { // Work in progress (ex: onload events in incremental mode). return null; } const props = getFiberCurrentPropsFromNode(stateNode); if (props === null) { // Work in progress. return null; } const li
{ "filepath": "packages/react-native-renderer/src/ReactNativeGetListener.js", "language": "javascript", "file_size": 1003, "cut_index": 512, "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 */ /** * Make sure essential globals are available and are patched correctly. Please don't remove this * line. Bundles created by...
jectEventPluginsByName, } from './legacy-events/EventPluginRegistry'; import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin'; import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder'; /** * Inject module for resolving D
932517 */ // Module provided by RN: import 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore'; import ResponderEventPlugin from './legacy-events/ResponderEventPlugin'; import { injectEventPluginOrder, in
{ "filepath": "packages/react-native-renderer/src/ReactNativeInjectionShared.js", "language": "javascript", "file_size": 1337, "cut_index": 524, "middle_length": 229 }
t {hasPointerEvent, platform} from './domEnvironment'; import * as touchStore from './touchStore'; /** * Converts a PointerEvent payload to a Touch */ function createTouch(target, payload) { const { height = defaultPointerSize, pageX, pageY, pointerId, pressure = 1, twist = 0, width = d...
entPayload(target, touch, payload) { const { altKey = false, ctrlKey = false, metaKey = false, preventDefault, shiftKey = false, timeStamp, } = payload; return { altKey, changedTouches: [touch], ctrlKey, metaK
, radiusX: width / 2, radiusY: height / 2, rotationAngle: twist, target, screenX: x, screenY: y + defaultBrowserChromeSize, }; } /** * Converts a PointerEvent to a TouchEvent */ function createTouchEv
{ "filepath": "packages/dom-event-testing-library/domEventSequences.js", "language": "javascript", "file_size": 9971, "cut_index": 921, "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'; import {hasPointerEvent, setPointerEvent} from './domEnvironment'; export function describeWithPointerEvent(message, describeFn) { const pointerEvent = 'PointerEvent'; const fal...
describeFn(hasPointerEvents); }); } export function testWithPointerType(message, testFn) { const table = hasPointerEvent() ? ['mouse', 'touch', 'pen'] : ['mouse', 'touch']; test.each(table)(`${message}: %s`, pointerType => { testFn(
entry.value; setPointerEvent(hasPointerEvents);
{ "filepath": "packages/dom-event-testing-library/testHelpers.js", "language": "javascript", "file_size": 936, "cut_index": 606, "middle_length": 52 }
; /** * Unit test helpers */ describeWithPointerEvent('describeWithPointerEvent', pointerEvent => { test('provides boolean to tests', () => { expect(pointerEvent).toMatchSnapshot(); }); testWithPointerType('testWithPointerType', pointerType => { expect(pointerType).toMatchSnapshot(); }); }); /** *...
"blur", "click", "focus", "keydown", "keyup", "scroll", "virtualclick", "contextmenu", "pointercancel", "pointerdown", "pointerhover", "pointermove", "pointere
ivePointers(); }); it('returns expected API', () => { const target = createEventTarget(node); expect(target.node).toEqual(node); expect(Object.keys(target)).toMatchInlineSnapshot(` [ "node",
{ "filepath": "packages/dom-event-testing-library/__tests__/index-test.internal.js", "language": "javascript", "file_size": 9919, "cut_index": 921, "middle_length": 229 }
ct-core */ 'use strict'; let React; let ReactDOM; let ReactIs; let SuspenseList; describe('ReactIs', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactIs = require('react-is'); if (gate(flags => flags.enableSuspenseList)) { ...
ed); expect(ReactIs.typeOf(NaN)).toBe(undefined); expect(ReactIs.typeOf(Symbol('def'))).toBe(undefined); }); it('identifies valid element types', () => { class Component extends React.Component { render() { return React.creat
.typeOf(true)).toBe(undefined); expect(ReactIs.typeOf(123)).toBe(undefined); expect(ReactIs.typeOf({})).toBe(undefined); expect(ReactIs.typeOf(null)).toBe(undefined); expect(ReactIs.typeOf(undefined)).toBe(undefin
{ "filepath": "packages/react-is/src/__tests__/ReactIs-test.js", "language": "javascript", "file_size": 8651, "cut_index": 716, "middle_length": 229 }
iliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const electron = require('electron'); const spawn = require('cross-spawn'); const argv = process.argv.slice(2); const pkg = require('./package.json'); const updateNo...
ble ${notifier.update.current} -> ${notifier.update.latest}` + '\nTo update:' + '\n"npm i [-g] react-devtools" or "yarn add react-devtools"'; notifier.notify({defer: false, message: updateMsg}); } const result = spawn.sync(electron, [require.res
ier.update) { const updateMsg = `Update availa
{ "filepath": "packages/react-devtools/bin.js", "language": "javascript", "file_size": 974, "cut_index": 582, "middle_length": 52 }
contextBridge} = require('electron'); const fs = require('fs'); const internalIP = require('internal-ip'); // Expose protected methods so that render process does not need unsafe node integration contextBridge.exposeInMainWorld('api', { electron: {clipboard, shell}, ip: {address: internalIP.v4.sync}, getDevTools...
= { key: fs.readFileSync(process.env.KEY), cert: fs.readFileSync(process.env.CERT), }; useHttps = true; } } catch (err) { console.error('Failed to process SSL options - ', err); options = undefined
and `yarn run build` in packages/react-devtools-core?', ); } return devtools; }, readEnv() { let options; let useHttps = false; try { if (process.env.KEY && process.env.CERT) { options
{ "filepath": "packages/react-devtools/preload.js", "language": "javascript", "file_size": 1756, "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 type {ReactBuildType} from 'react-devtools-shared/src/backend/types'; function reduceReactBuild( currentReactBuildType:...
f them is a non-production build, we'll display that instead of "production". return nextReactBuildType === 'production' ? currentReactBuildType : nextReactBuildType; } export function createReactRendererListener(target: { postMessage: Functio
eactBuildType; } // We only display the "worst" build type, so if we've already detected a non-production build, // we ignore any future production builds. This way if a page has multiple renderers, // and at least one o
{ "filepath": "packages/react-devtools-extensions/src/contentScripts/reactBuildType.js", "language": "javascript", "file_size": 1471, "cut_index": 524, "middle_length": 229 }
import type {Size, IntrinsicSize, Rect} from './geometry'; import type { Interaction, MouseDownInteraction, MouseMoveInteraction, MouseUpInteraction, WheelWithShiftInteraction, } from './useCanvasInteraction'; import type {ScrollState} from './utils/scrollState'; import type {ViewRefs} from './Surface'; impor...
type OnChangeCallback = ( scrollState: ScrollState, containerLength: number, ) => void; export class VerticalScrollView extends View { _contentView: View; _isPanning: boolean; _mutableViewStateKey: string; _onChangeCallback: OnChangeCallback
, translateState, } from './utils/scrollState'; import {MOVE_WHEEL_DELTA_THRESHOLD} from './constants'; import {COLORS} from '../content-views/constants'; const CARET_MARGIN = 3; const CARET_WIDTH = 5; const CARET_HEIGHT = 3;
{ "filepath": "packages/react-devtools-timeline/src/view-base/VerticalScrollView.js", "language": "javascript", "file_size": 8477, "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 type {LayoutInfo, Layouter} from '../layouter'; /** * Assumes {@param layout} will only contain 2 views. */ export con...
tentLayoutInfo: LayoutInfo = { ...contentLayoutInfo, frame: { origin: contentLayoutInfo.view.frame.origin, size: { width: containerFrame.size.width - scrollbarWidth, height: containerFrame.size.height, }, },
desiredSize(); const shouldShowScrollbar = desiredContentSize.height > containerFrame.size.height; const scrollbarWidth = shouldShowScrollbar ? scrollbarLayoutInfo.view.desiredSize().width : 0; const laidOutCon
{ "filepath": "packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/withVerticalScrollbarLayout.js", "language": "javascript", "file_size": 1460, "cut_index": 524, "middle_length": 229 }
import type { Interaction, MouseDownInteraction, MouseMoveInteraction, MouseUpInteraction, } from '../useCanvasInteraction'; import type {Rect, Size} from '../geometry'; import type {ViewRefs} from '../Surface'; import {BORDER_SIZE, COLORS} from '../../content-views/constants'; import {drawText} from '../../co...
nteractionState: ResizeBarState = 'normal'; _label: string; showLabel: boolean = false; constructor(surface: Surface, frame: Rect, label: string) { super(surface, frame, noopLayout); this._label = label; } desiredSize(): Size { re
rState = 'normal' | 'hovered' | 'dragging'; const RESIZE_BAR_DOT_RADIUS = 1; const RESIZE_BAR_DOT_SPACING = 4; const RESIZE_BAR_HEIGHT = 8; const RESIZE_BAR_WITH_LABEL_HEIGHT = 16; export class ResizeBarView extends View { _i
{ "filepath": "packages/react-devtools-timeline/src/view-base/resizable/ResizeBarView.js", "language": "javascript", "file_size": 5287, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ // Adapted from: https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js export type NormalizedWheelDelta = { deltaX: number, deltaY: number, }; // Reasonable def...
of the * deltas. This code will return an object with properties: * * - deltaX -- normalized distance (to pixels) - x plane * - deltaY -- " - y plane * * Wheel values are provided by the browser assuming you are using the wheel to * scroll a
ed enough to answer * your questions. * * If you need to react to the mouse wheel in a predictable way, this code is * like your bestest friend. * hugs * * * In your event callback, use this code to get sane interpretation
{ "filepath": "packages/react-devtools-timeline/src/view-base/utils/normalizeWheel.js", "language": "javascript", "file_size": 3090, "cut_index": 614, "middle_length": 229 }
import { clampState, moveStateToRange, areScrollStatesEqual, translateState, zoomState, } from '../scrollState'; describe('clampState', () => { it('should passthrough offset if state fits within container', () => { expect( clampState({ state: {offset: 0, length: 50}, minContentLen...
clampState({ state: {offset: -1, length: 50}, minContentLength: 0, maxContentLength: 100, containerLength: 50, }).offset, ).toBeCloseTo(0, 10); expect( clampState({ state: {offset: 1, lengt
minContentLength: 0, maxContentLength: 100, containerLength: 50, }).offset, ).toBeCloseTo(-20, 10); }); it('should clamp offset if offset causes content to go out of container', () => { expect(
{ "filepath": "packages/react-devtools-timeline/src/view-base/utils/__tests__/scrollState-test.js", "language": "javascript", "file_size": 6438, "cut_index": 716, "middle_length": 229 }
potentialSuspenseEventsOutsideOfTransition: Array< [SuspenseEvent, ReactLane[]], >, requestIdToNetworkMeasureMap: Map<string, NetworkMeasure>, uidCounter: BatchUID, unresolvedSuspenseEvents: Map<string, SuspenseEvent>, }; const NATIVE_EVENT_DURATION_THRESHOLD = 20; const NESTED_UPDATE_DURATION_THRESHOLD ...
ect).', SUSPEND_DURING_UPDATE: 'A component suspended during an update which caused a fallback to be shown. ' + "Consider using the Transition API to avoid hiding components after they've been mounted.", }; // Exported for tests export function
'A big nested update was scheduled during layout. ' + 'Nested updates require React to re-render synchronously before the browser can paint. ' + 'Consider delaying this update by moving it to a passive effect (useEff
{ "filepath": "packages/react-devtools-timeline/src/import-worker/preprocessData.js", "language": "javascript", "file_size": 38639, "cut_index": 2151, "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 {SchedulingEvent} from '../types'; import prettyMilliseconds from 'pretty-ms'; export function formatTimesta...
…`; } return string; } export function getSchedulingEventLabel(event: SchedulingEvent): string | null { switch (event.type) { case 'schedule-render': return 'render scheduled'; case 'schedule-state-update': return 'state update s
number): string { return prettyMilliseconds(ms, {millisecondsDecimalDigits: 1}); } export function trimString(string: string, length: number): string { if (string.length > length) { return `${string.slice(0, length - 1)}
{ "filepath": "packages/react-devtools-timeline/src/utils/formatting.js", "language": "javascript", "file_size": 1127, "cut_index": 518, "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 memoize from 'memoize-one'; import type { BatchUID, Milliseconds, ReactMeasure, TimelineData, } from '../types';...
Time = lastMeasure.timestamp + lastMeasure.duration; if (stopTime < minStartTime) { return [0, 0]; } let startTime = minStartTime; for (let index = 0; index < measures.length; index++) { const measure = measures[index]; if (measure.ti
(batchUID); if (measures == null || measures.length === 0) { throw Error(`Could not find measures with batch UID "${batchUID}"`); } const lastMeasure = ((measures[measures.length - 1]: any): ReactMeasure); const stop
{ "filepath": "packages/react-devtools-timeline/src/utils/getBatchRange.js", "language": "javascript", "file_size": 1301, "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. * * @emails react-core */ 'use strict'; export const defaultPointerId = 1; export const defaultPointerSize = 23; export const defaultBrowser...
rt const buttonType = { // no change since last event none: -1, // left-mouse // touch contact // pen contact primary: 0, // right-mouse // pen barrel button secondary: 2, // middle mouse auxiliary: 1, // back mouse back: 3, //
h, it is not reliable for events such as 'mouseenter', 'mouseleave', * 'mouseover', 'mouseout' or 'mousemove'. Furthermore, the semantics differ for PointerEvent, where the value * for 'pointermove' will always be -1. */ expo
{ "filepath": "packages/dom-event-testing-library/constants.js", "language": "javascript", "file_size": 1388, "cut_index": 524, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; import {buttonType, buttonsType} from './constants'; import * as domEvents from './domEvents'; import * as domEventSequences from './domEventSequences'; import {hasPointerEvent, setPointerEv...
) { node.dispatchEvent(domEvents.focus(payload)); node.dispatchEvent(domEvents.focusIn(payload)); node.focus(); }, keydown(payload) { node.dispatchEvent(domEvents.keydown(payload)); }, keyup(payload) { node.dispatchEvent(domEven
raction. */ blur(payload) { node.dispatchEvent(domEvents.blur(payload)); node.dispatchEvent(domEvents.focusOut(payload)); }, click(payload) { node.dispatchEvent(domEvents.click(payload)); }, focus(payload
{ "filepath": "packages/dom-event-testing-library/index.js", "language": "javascript", "file_size": 3193, "cut_index": 614, "middle_length": 229 }
'use strict'; import { REACT_CONTEXT_TYPE, REACT_ELEMENT_TYPE, REACT_FORWARD_REF_TYPE, REACT_FRAGMENT_TYPE, REACT_LAZY_TYPE, REACT_MEMO_TYPE, REACT_PORTAL_TYPE, REACT_PROFILER_TYPE, REACT_CONSUMER_TYPE, REACT_STRICT_MODE_TYPE, REACT_SUSPENSE_TYPE, REACT_SUSPENSE_LIST_TYPE, REACT_VIEW_TRANSITI...
= null) { const $$typeof = object.$$typeof; switch ($$typeof) { case REACT_ELEMENT_TYPE: const type = object.type; switch (type) { case REACT_FRAGMENT_TYPE: case REACT_PROFILER_TYPE: case REACT_S
enableViewTransition, } from 'shared/ReactFeatureFlags'; const REACT_CLIENT_REFERENCE: symbol = Symbol.for('react.client.reference'); export function typeOf(object: any): mixed { if (typeof object === 'object' && object !=
{ "filepath": "packages/react-is/src/ReactIs.js", "language": "javascript", "file_size": 5174, "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. */ const {app, BrowserWindow, shell} = require('electron'); // Module to create native browser window. const {join} = require('path'); const os = require('o...
webPreferences: { contextIsolation: true, // protect against prototype pollution enableRemoteModule: false, // turn off remote sandbox: false, // allow preload script to access file system preload: join(__dirname, 'preload.js'), /
, function () { // Create the browser window. mainWindow = new BrowserWindow({ width: 800, height: 600, icon: join(__dirname, 'icons/icon128.png'), frame: false, //titleBarStyle: 'customButtonsOnHover',
{ "filepath": "packages/react-devtools/app.js", "language": "javascript", "file_size": 1969, "cut_index": 537, "middle_length": 229 }
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 __DEV__ = NODE_ENV === 'development'; const EDITOR_URL = proces...
ames: './src/hookNames.js', }, output: { path: __dirname + '/dist', publicPath: '/dist/', filename: '[name].js', chunkFilename: '[name].chunk.js', library: { type: 'commonjs2', }, }, externals: { react: 'react',
s', ), }; module.exports = { mode: __DEV__ ? 'development' : 'production', devtool: __DEV__ ? 'eval-cheap-source-map' : 'source-map', entry: { backend: './src/backend.js', frontend: './src/frontend.js', hookN
{ "filepath": "packages/react-devtools-inline/webpack.config.js", "language": "javascript", "file_size": 3068, "cut_index": 614, "middle_length": 229 }
import type { ClickInteraction, DoubleClickInteraction, Interaction, MouseDownInteraction, MouseMoveInteraction, MouseUpInteraction, } from '../useCanvasInteraction'; import type {Rect} from '../geometry'; import type {ViewRefs} from '../Surface'; import type {ViewState} from '../../types'; import {ResizeB...
}>; type LayoutState = { /** Resize bar's vertical position relative to resize view's frame.origin.y */ barOffsetY: number, }; const RESIZE_BAR_HEIGHT = 8; const RESIZE_BAR_WITH_LABEL_HEIGHT = 16; const HIDDEN_RECT = { origin: {x: 0, y: 0}, size
{clamp} from '../utils/clamp'; type ResizingState = $ReadOnly<{ /** Distance between top of resize bar and mouseY */ cursorOffsetInBarFrame: number, /** Mouse's vertical coordinates relative to canvas */ mouseY: number,
{ "filepath": "packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js", "language": "javascript", "file_size": 8044, "cut_index": 716, "middle_length": 229 }