prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
Suspense = React.Suspense;
startTransition = React.startTransition;
const InternalTestUtils = require('internal-test-utils');
assertLog = InternalTestUtils.assertLog;
getCacheForType = React.unstable_getCacheForType;
caches = [];
seededCache = null;
});
function createTextCache() {
... | resolve(text) {
const record = data.get(text);
if (record === undefined) {
const newRecord = {
status: 'resolved',
value: text,
};
data.set(text, newRecord);
} else if (record | nothing has mounted yet).
const cache = seededCache;
seededCache = null;
return cache;
}
const data = new Map();
const version = caches.length + 1;
const cache = {
version,
data,
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js",
"language": "javascript",
"file_size": 12532,
"cut_index": 921,
"middle_length": 229
} |
';
import getComponentNameFromFiber from './getComponentNameFromFiber';
import {isAlreadyRendering} from './ReactFiberWorkLoop';
// Intentionally not named imports because Rollup would use dynamic dispatch for
// CommonJS interop named imports.
import * as Scheduler from 'scheduler';
const {unstable_now: now} = Sche... | | 1 | 2;
export let renderStartTime: number = -0;
export let commitStartTime: number = -0;
export let commitEndTime: number = -0;
export let commitErrors: null | Array<CapturedValue<mixed>> = null;
export let profilerStartTime: number = -1.1;
export let p | ging
console.createTask
: (name: string) => null;
export const REGULAR_UPDATE: UpdateType = 0;
export const SPAWNED_UPDATE: UpdateType = 1;
export const PINGED_UPDATE: UpdateType = 2;
export opaque type UpdateType = 0 | {
"filepath": "packages/react-reconciler/src/ReactProfilerTimer.js",
"language": "javascript",
"file_size": 23333,
"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.
*
* @flow
*/
// This module only exists as an ESM wrapper around the external CommonJS
// Scheduler dependency. Notice that we're intentionally not using ... | nstable_requestPaint;
export const now = Scheduler.unstable_now;
export const getCurrentPriorityLevel =
Scheduler.unstable_getCurrentPriorityLevel;
export const ImmediatePriority = Scheduler.unstable_ImmediatePriority;
export const UserBlockingPriority = | ort const scheduleCallback = Scheduler.unstable_scheduleCallback;
export const cancelCallback = Scheduler.unstable_cancelCallback;
export const shouldYield = Scheduler.unstable_shouldYield;
export const requestPaint = Scheduler.u | {
"filepath": "packages/react-reconciler/src/Scheduler.js",
"language": "javascript",
"file_size": 1583,
"cut_index": 537,
"middle_length": 229
} |
et BrokenRender;
let DidCatchErrorBoundary;
let GetDerivedErrorBoundary;
let React;
let ReactTestRenderer;
let span;
let act;
beforeEach(() => {
jest.resetModules();
ReactTestRenderer = require('react-test-renderer');
React = require('react');
act = require('internal-test-utils').act;
... | .Component {
state = {error: null};
static getDerivedStateFromError(error) {
return {error};
}
render() {
return this.state.error
? React.createElement(this.props.fallbackTagName, {
prop: 'Err | this.state.error
? React.createElement(this.props.fallbackTagName, {
prop: 'ErrorBoundary',
})
: this.props.children;
}
};
GetDerivedErrorBoundary = class extends React | {
"filepath": "packages/react-reconciler/src/__tests__/ErrorBoundaryReconciliation-test.internal.js",
"language": "javascript",
"file_size": 2528,
"cut_index": 563,
"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 ReactNoop;
let Scheduler;
let act;
let assertLog;
describe('ReactClassComponentPropResolution', () => {
beforeEach(() => {
jest.resetModules();
React = require('re... | PropKeys(props) {
return Object.keys(props).join(', ');
}
class Component extends React.Component {
constructor(props) {
super(props);
Scheduler.log('constructor: ' + getPropKeys(props));
}
shouldComponentUp | Log;
});
function Text({text}) {
Scheduler.log(text);
return text;
}
it('resolves ref and default props before calling lifecycle methods', async () => {
const root = ReactNoop.createRoot();
function get | {
"filepath": "packages/react-reconciler/src/__tests__/ReactClassComponentPropResolution-test.js",
"language": "javascript",
"file_size": 3852,
"cut_index": 614,
"middle_length": 229
} |
rLayoutEffects,
disconnectPassiveEffect,
invokeLayoutEffectMountInDEV,
invokePassiveEffectMountInDEV,
invokeLayoutEffectUnmountInDEV,
invokePassiveEffectUnmountInDEV,
accumulateSuspenseyCommit,
} from './ReactFiberCommitWork';
import {resetShouldStartViewTransition} from './ReactFiberCommitViewTransitions';... | actFiberHooks';
import {DefaultAsyncDispatcher} from './ReactFiberAsyncDispatcher';
import {
createCapturedValueAtFiber,
type CapturedValue,
} from './ReactCapturedValue';
import {
enqueueConcurrentRenderForLane,
finishQueueingConcurrentUpdates,
| lyGesture';
import {enqueueUpdate} from './ReactFiberClassUpdateQueue';
import {resetContextDependencies} from './ReactFiberNewContext';
import {
resetHooksAfterThrow,
resetHooksOnUnwind,
ContextOnlyDispatcher,
} from './Re | {
"filepath": "packages/react-reconciler/src/ReactFiberWorkLoop.js",
"language": "javascript",
"file_size": 202678,
"cut_index": 7068,
"middle_length": 229
} |
act = require('internal-test-utils').act;
LegacyHidden = React.unstable_LegacyHidden;
Activity = React.Activity;
Suspense = React.Suspense;
useState = React.useState;
useEffect = React.useEffect;
startTransition = React.startTransition;
const InternalTestUtils = require('internal-test-u... | ecord.status === 'pending') {
const thenable = record.value;
record.status = 'resolved';
record.value = text;
thenable.pings.forEach(t => t());
}
}
function readText(text) {
const record = textCache.get(text);
if (r | esolveText(text) {
const record = textCache.get(text);
if (record === undefined) {
const newRecord = {
status: 'resolved',
value: text,
};
textCache.set(text, newRecord);
} else if (r | {
"filepath": "packages/react-reconciler/src/__tests__/ActivityLegacySuspense-test.js",
"language": "javascript",
"file_size": 15950,
"cut_index": 921,
"middle_length": 229
} |
xport function getNearestMountedFiber(fiber: Fiber): null | Fiber {
let node = fiber;
let nearestMounted: null | Fiber = fiber;
// If there is no alternate, this might be a new tree that isn't inserted
// yet. If it is, then it will have a pending insertion effect on it.
let nextNode: Fiber = node;
while (n... | nextNode = node.return;
}
// After we've reached an alternate, go the rest of the way to see if the
// tree is still mounted. If it's not, its return pointer will be disconnected.
while (node.return) {
node = node.return;
}
if (node.tag == | e
// mounted fiber is the parent but we need to continue to figure out
// if that one is still mounted.
nearestMounted = node.return;
}
// $FlowFixMe[incompatible-type] we bail out when we get a null
| {
"filepath": "packages/react-reconciler/src/ReactFiberTreeReflection.js",
"language": "javascript",
"file_size": 18043,
"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
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let assertConsoleErrorDev;
let waitForAll;
let waitForThrow;
... | d fail gracefully on error in the host environment', async () => {
ReactNoop.render(<errorInBeginPhase />);
await waitForThrow('Error in host config.');
});
it("should ignore error if it doesn't throw on retry", async () => {
let didInit = | TestUtils = require('internal-test-utils');
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
waitForAll = InternalTestUtils.waitForAll;
waitForThrow = InternalTestUtils.waitForThrow;
});
it('shoul | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js",
"language": "javascript",
"file_size": 1580,
"cut_index": 537,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoopPersistent;
let act;
describe('ReactPersistentUpdatesMinimalism', () => {
beforeEach(() => {
jest.resetModules();
React = require... | );
expect(ReactNoopPersistent.stopTrackingHostCounters()).toEqual({
hostCloneCounter: 0,
});
ReactNoopPersistent.startTrackingHostCounters();
await act(() => ReactNoopPersistent.render(<Parent />));
expect(ReactNoopPersistent.sto | function Child() {
return <div>Hello World</div>;
}
function Parent() {
return <Child />;
}
ReactNoopPersistent.startTrackingHostCounters();
await act(() => ReactNoopPersistent.render(<Parent />) | {
"filepath": "packages/react-reconciler/src/__tests__/ReactPersistentUpdatesMinimalism-test.js",
"language": "javascript",
"file_size": 4021,
"cut_index": 614,
"middle_length": 229
} |
() => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.wait... | rk on other roots once the current root completes', async () => {
ReactNoop.renderToRootWithID(<span prop="a:1" />, 'a');
ReactNoop.renderToRootWithID(<span prop="b:1" />, 'b');
ReactNoop.renderToRootWithID(<span prop="c:1" />, 'c');
await | k', async () => {
ReactNoop.render(<span prop="1" />);
expect(ReactNoop).toMatchRenderedOutput(null);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(<span prop="1" />);
});
it('searches for wo | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js",
"language": "javascript",
"file_size": 10122,
"cut_index": 921,
"middle_length": 229
} |
s');
waitForAll = InternalTestUtils.waitForAll;
waitFor = InternalTestUtils.waitFor;
assertLog = InternalTestUtils.assertLog;
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
function Text({text}) {
Scheduler.log(text);
return text;
}
it('applies updates in order of... | te;
return <div />;
}
}
ReactNoop.render(<Foo />);
await waitFor(['commit']);
expect(state).toEqual({a: 'a'});
await waitForAll([]);
expect(state).toEqual({a: 'a', b: 'b', c: 'c'});
});
it('applies updates with | => {
// Has low priority
this.setState({b: 'b'});
this.setState({c: 'c'});
});
// Has Task priority
this.setState({a: 'a'});
}
render() {
state = this.sta | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js",
"language": "javascript",
"file_size": 19172,
"cut_index": 1331,
"middle_length": 229
} |
t assertLog;
let waitFor;
let waitForPaint;
describe('ReactInterleavedUpdates', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
startTransition = ... | sed during the current render', async () => {
const updaters = [];
function Child() {
const [state, setState] = useState(0);
useEffect(() => {
updaters.push(setState);
}, []);
return <Text text={state} />;
}
| g;
waitFor = InternalTestUtils.waitFor;
waitForPaint = InternalTestUtils.waitForPaint;
});
function Text({text}) {
Scheduler.log(text);
return text;
}
it('update during an interleaved event is not proces | {
"filepath": "packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js",
"language": "javascript",
"file_size": 3593,
"cut_index": 614,
"middle_length": 229
} |
escribe('isomorphic act()', () => {
beforeEach(() => {
React = require('react');
Scheduler = require('scheduler');
ReactNoop = require('react-noop-renderer');
DiscreteEventPriority =
require('react-reconciler/constants').DiscreteEventPriority;
act = React.act;
use = React.use;
Suspe... | in production', () => {
if (!__DEV__) {
if (gate('fb')) {
expect(() => act(() => {})).toThrow(
'act(...) is not supported in production builds of React',
);
} else {
expect(React).not.toHaveProperty('act') | ertLog;
});
beforeEach(() => {
global.IS_REACT_ACT_ENVIRONMENT = true;
});
afterEach(() => {
jest.restoreAllMocks();
});
function Text({text}) {
Scheduler.log(text);
return text;
}
it('behavior | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js",
"language": "javascript",
"file_size": 10216,
"cut_index": 921,
"middle_length": 229
} |
</div>
);
}
// We have several ways of reading from context. sharedContextTests runs
// a suite of tests for a given context consumer implementation.
sharedContextTests('Context.Consumer', Context => Context.Consumer);
sharedContextTests(
'useContext inside function component',
Context =>
... | ,
);
sharedContextTests('useContext inside memoized function component', Context =>
React.memo(function Consumer(props) {
const contextValue = useContext(Context);
const render = props.children;
return render(contextValue);
}) | eContext inside forwardRef component', Context =>
React.forwardRef(function Consumer(props, ref) {
const contextValue = useContext(Context);
const render = props.children;
return render(contextValue);
}) | {
"filepath": "packages/react-reconciler/src/__tests__/ReactNewContext-test.js",
"language": "javascript",
"file_size": 50218,
"cut_index": 2151,
"middle_length": 229
} |
actOwnerStacks', () => {
beforeEach(function () {
let time = 10;
advanceTimersByTime = timeMS => {
jest.advanceTimersByTime(timeMS);
time += timeMS;
};
const now = jest.fn().mockImplementation(() => {
return time++;
});
Object.defineProperty(performance, 'timeOrigin', {
... | ('internal-test-utils').assertLog;
serverAct = require('internal-test-utils').serverAct;
waitFor = require('internal-test-utils').waitFor;
});
function normalizeCodeLocInfo(str) {
return (
str &&
str.replace(/\n +(?:at|in) ([\S | re('react');
ReactNoop = require('react-noop-renderer');
ReactNoopServer = require('react-noop-renderer/server');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
assertLog = require | {
"filepath": "packages/react-reconciler/src/__tests__/ReactOwnerStacks-test.js",
"language": "javascript",
"file_size": 11301,
"cut_index": 921,
"middle_length": 229
} |
ed': {
throw newRecord.value;
}
}
},
};
fakeModuleCache.set(Component, newRecord);
return newRecord;
}
return record;
}
function resolveFakeImport(moduleName) {
const record = fakeModuleCache.get(moduleName);
if (record === undefined) {
... | ="Loading..." />}>
<LazyText text="Hi" />
</Suspense>,
{
unstable_isConcurrent: true,
},
);
await waitForAll(['Loading...']);
expect(root).not.toMatchRenderedOutput('Hi');
await act(() => resolveFakeImpor | .forEach(ping => ping(record.value));
}
it('suspends until module has loaded', async () => {
const LazyText = lazy(() => fakeImport(Text));
const root = ReactTestRenderer.create(
<Suspense fallback={<Text text | {
"filepath": "packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js",
"language": "javascript",
"file_size": 49130,
"cut_index": 2151,
"middle_length": 229
} |
function Counter({incrementBy}) {
const [count, updateCount] = useState(0);
const onClick = useEffectEvent(() => updateCount(c => c + incrementBy));
return (
<>
<IncrementButton onClick={() => onClick()} ref={button} />
<Text text={'Count: ' + count} />
</>
... | edOutput(
<>
<span prop="Increment" />
<span prop="Count: 1" />
</>,
);
await act(() => button.current.increment());
assertLog([
'Increment',
// Event should use the updated callback function closed over | Output(
<>
<span prop="Increment" />
<span prop="Count: 0" />
</>,
);
await act(() => button.current.increment());
assertLog(['Increment', 'Count: 1']);
expect(ReactNoop).toMatchRender | {
"filepath": "packages/react-reconciler/src/__tests__/useEffectEvent-test.js",
"language": "javascript",
"file_size": 36901,
"cut_index": 2151,
"middle_length": 229
} |
assertLog;
useMemo = React.useMemo;
useMemoCache = require('react/compiler-runtime').c;
useState = React.useState;
MemoCacheSentinel = Symbol.for('react.memo_cache_sentinel');
class _ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = {hasEr... | ren;
}
}
ErrorBoundary = _ErrorBoundary;
});
it('render component using cache', async () => {
function Component(props) {
const cache = useMemoCache(1);
expect(Array.isArray(cache)).toBe(true);
expect(cache.length). | nentDidCatch(error, errorInfo) {}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>;
}
return this.props.child | {
"filepath": "packages/react-reconciler/src/__tests__/useMemoCache-test.js",
"language": "javascript",
"file_size": 18405,
"cut_index": 1331,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
describe('useRef', () => {
let React;
let ReactNoop;
let Scheduler;
let act;
let useCallback;
let useEffect;
let useLayoutEffect;
let useRef;
let useState;
let waitForAll;
let assertLog;
beforeEach(() => {
React = require('react');
R... | Log = InternalTestUtils.assertLog;
});
function Text(props) {
Scheduler.log(props.text);
return <span prop={props.text} />;
}
it('creates a ref object initialized with the provided value', async () => {
jest.useFakeTimers();
func | fect;
useLayoutEffect = React.useLayoutEffect;
useRef = React.useRef;
useState = React.useState;
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
assert | {
"filepath": "packages/react-reconciler/src/__tests__/useRef-test.internal.js",
"language": "javascript",
"file_size": 5638,
"cut_index": 716,
"middle_length": 229
} |
startTransition;
let waitFor;
let waitForAll;
let assertLog;
let Suspense;
let useMemo;
let textCache;
// This tests the native useSyncExternalStore implementation, not the shim.
// Tests that apply to both the native implementation and the shim should go
// into useSyncExternalStoreShared-test.js. The reason they are... | dle = React.useImperativeHandle;
forwardRef = React.forwardRef;
useRef = React.useRef;
useState = React.useState;
use = React.use;
useSyncExternalStore = React.useSyncExternalStore;
startTransition = React.startTransition;
Suspe |
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
useLayoutEffect = React.useLayoutEffect;
useImperativeHan | {
"filepath": "packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js",
"language": "javascript",
"file_size": 12222,
"cut_index": 921,
"middle_length": 229
} |
he `react-reconciler` we treat host config as a module.
// This file is a shim between two worlds.
//
// It works because the `react-reconciler` bundle is wrapped in something like:
//
// module.exports = function ($$$config) {
// /* reconciler code */
// }
//
// So `$$$config` looks like a global variable, but it's
... | type PublicInstance = mixed;
export opaque type HostContext = mixed;
export opaque type UpdatePayload = mixed;
export opaque type ChildSet = mixed;
export opaque type TimeoutHandle = mixed;
export opaque type NoTimeout = mixed;
export opaque type RendererI | export opaque type Instance = mixed;
export opaque type TextInstance = mixed;
export opaque type ActivityInstance = mixed;
export opaque type SuspenseInstance = mixed;
export opaque type HydratableInstance = mixed;
export opaque | {
"filepath": "packages/react-reconciler/src/forks/ReactFiberConfig.custom.js",
"language": "javascript",
"file_size": 14474,
"cut_index": 921,
"middle_length": 229
} |
module.
// This file is a shim between two worlds.
//
// It works because the `react-reconciler` bundle is wrapped in something like:
//
// module.exports = function ($$$config) {
// /* reconciler code */
// }
//
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping fu... | dle = mixed;
export opaque type NoTimeout = mixed;
export opaque type RendererInspectionConfig = mixed;
export opaque type FormInstance = mixed;
export opaque type SuspendedState = mixed;
export type RunningViewTransition = mixed;
export type ViewTransitio | pe ActivityInstance = mixed;
export opaque type SuspenseInstance = mixed;
export opaque type HydratableInstance = mixed;
export opaque type UpdatePayload = mixed;
export opaque type ChildSet = mixed;
export opaque type TimeoutHan | {
"filepath": "packages/react-reconciler/src/forks/ReactFiberConfig.noop.js",
"language": "javascript",
"file_size": 14252,
"cut_index": 921,
"middle_length": 229
} |
/simulateBrowserEventDispatch';
import {
clearLogs,
clearWarnings,
clearErrors,
createLogAssertion,
} from './consoleMock';
export {getDebugInfo} from './debugInfo';
export {act, serverAct} from './internalAct';
const {assertConsoleLogsCleared} = require('internal-test-utils/consoleMock');
import {thrownErrors... | {
return new Promise(resolve => {
enqueueTask(() => resolve());
});
}
export async function waitFor(expectedLog, options) {
assertYieldsWereCleared(waitFor);
// Create the error object before doing any async work, to get a better
// stack | nst error = Error(
'The event log is not empty. Call assertLog(...) first.',
);
Error.captureStackTrace(error, caller);
throw error;
}
assertConsoleLogsCleared();
}
export async function waitForMicrotasks() | {
"filepath": "packages/internal-test-utils/ReactInternalTestUtils.js",
"language": "javascript",
"file_size": 10911,
"cut_index": 921,
"middle_length": 229
} |
export function setupDocumentReadyState(
document: Document,
Event: typeof Event,
) {
let readyState: 0 | 1 | 2 = 0;
Object.defineProperty(document, 'readyState', {
get() {
switch (readyState) {
case 0:
return 'loading';
case 1:
return 'interactive';
case 2:... | else if (value === 'loading') {
// We allow resetting the readyState to loading mostly for pragamtism.
// tests that use this environment don't reset the document between tests.
readyState = 0;
}
},
configurable: true, | echange'));
} else if (value === 'complete' && readyState < 2) {
readyState = 2;
document.dispatchEvent(new Event('readystatechange'));
document.dispatchEvent(new Event('DOMContentLoaded'));
} | {
"filepath": "packages/internal-test-utils/ReactJSDOMUtils.js",
"language": "javascript",
"file_size": 1006,
"cut_index": 512,
"middle_length": 229
} |
]);
const loggedLogs = (global.__loggedLogs = global.__loggedLogs || []);
const patchConsoleMethod = (methodName, logged) => {
const newMethod = function (format, ...args) {
// Ignore uncaught errors reported by jsdom
// and React addendums because they're too noisy.
if (shouldIgnoreConsoleError(format, ... | lly we could remove this check, but we have some tests like
// useSyncExternalStoreShared-test that tests against React 17,
// which doesn't have the captureOwnerStack method.
if (React.captureOwnerStack) {
const stack = React.cap | Component Stacks. Simulates a framework or DevTools appending them.
if (
typeof format === 'string' &&
(methodName === 'error' || methodName === 'warn')
) {
const React = require('react');
// Idea | {
"filepath": "packages/internal-test-utils/consoleMock.js",
"language": "javascript",
"file_size": 19987,
"cut_index": 1331,
"middle_length": 229
} |
eFixedTime?: boolean,
useV8Stack?: boolean,
};
function formatV8Stack(stack) {
let v8StyleStack = '';
if (stack) {
for (let i = 0; i < stack.length; i++) {
const [name] = stack[i];
if (v8StyleStack !== '') {
v8StyleStack += '\n';
}
v8StyleStack += ' in ' + name + ' (at **)'... | ction normalizeIOInfo(config: DebugInfoConfig, ioInfo) {
const {debugTask, debugStack, debugLocation, ...copy} = ioInfo;
if (ioInfo.stack) {
copy.stack = config.useV8Stack
? formatV8Stack(ioInfo.stack)
: normalizeStack(ioInfo.stack);
| , line, col, enclosingLine, enclosingCol] = stack[i];
copy.push([
name,
file.replace(__REACT_ROOT_PATH_TEST__, ''),
line,
col,
enclosingLine,
enclosingCol,
]);
}
return copy;
}
fun | {
"filepath": "packages/internal-test-utils/debugInfo.js",
"language": "javascript",
"file_size": 3662,
"cut_index": 614,
"middle_length": 229
} |
avior from the public
// version, too, since our constraints in our test suite are not the same as
// those of developers using React — we're testing React itself, as opposed to
// building an app with React.
import type {Thenable} from 'shared/ReactTypes';
import * as Scheduler from 'scheduler/unstable_mock';
impor... | eof AggregateError === 'function') {
return new AggregateError(errors);
}
return errors[0];
}
export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
if (Scheduler.unstable_flushUntilNextPaint === undefined) {
throw Error(
| nErrors: Array<mixed> = [];
async function waitForMicrotasks() {
return new Promise(resolve => {
enqueueTask(() => resolve());
});
}
function aggregateErrors(errors: Array<mixed>): mixed {
if (errors.length > 1 && typ | {
"filepath": "packages/internal-test-utils/internalAct.js",
"language": "javascript",
"file_size": 10600,
"cut_index": 921,
"middle_length": 229
} |
orts = function shouldIgnoreConsoleError(format, args) {
if (__DEV__) {
if (typeof format === 'string') {
if (format.startsWith('%c%s')) {
// Looks like a badged error message
args.splice(0, 3);
}
if (
args[0] != null &&
((typeof args[0] === 'object' &&
... | error with addendum from ReactFiberErrorLogger.
// They are noisy too so we'll try to ignore them.
return true;
}
if (
format.indexOf('ReactDOM.render was removed in React 19') !== -1 ||
format.indexOf('ReactDOM | es('Failed to serialize an action') &&
typeof args[0].stack === 'string') ||
(typeof args[0] === 'string' &&
args[0].indexOf('An error occurred in ') === 0))
) {
// This looks like an | {
"filepath": "packages/internal-test-utils/shouldIgnoreConsoleError.js",
"language": "javascript",
"file_size": 1832,
"cut_index": 537,
"middle_length": 229
} |
rotasks} = require('./ReactInternalTestUtils');
const EVENT_PHASE = {
NONE: 0,
CAPTURING_PHASE: 1,
AT_TARGET: 2,
BUBBLING_PHASE: 3,
};
// Hack to get Symbol(wrapper) for target nodes.
let wrapperSymbol;
function wrapperForImpl(impl) {
if (impl == null) {
return null;
}
return impl[wrapperSymbol];
}... | r of real user interactions, so we simulate it.
//
// It's async because we need to wait for microtasks between event handlers.
//
// Taken from:
// https://github.com/jsdom/jsdom/blob/2f8a7302a43fff92f244d5f3426367a8eb2b8896/lib/jsdom/living/events/EventT | icrotasks in-between event handlers, which is
// different from programmatically calling dispatchEvent (which does not yield).
// JSDOM correctly implements programmatic dispatchEvent, but sometimes we need
// to test the behavio | {
"filepath": "packages/internal-test-utils/simulateBrowserEventDispatch.js",
"language": "javascript",
"file_size": 10244,
"cut_index": 921,
"middle_length": 229
} |
A');
// Deferred paint
await waitForPaint(['Urgent: B, Deferred: B']);
expect(root).toMatchRenderedOutput('Urgent: B, Deferred: B');
});
it('assertLog', async () => {
const Yield = ({id}) => {
Scheduler.log(id);
React.useEffect(() => {
Scheduler.log(`create effect ${id}`);
... | trictMode>
);
});
assertLog([
'A',
'B',
'C',
'create effect A',
'create effect B',
'create effect C',
]);
await act(() => {
root.render(null);
});
assertLog(['cleanup effect A', 'cle | <Yield id="B" />
<Yield id="C" />
</div>
);
}
const root = ReactNoop.createRoot();
await act(() => {
root.render(
<React.StrictMode>
<App />
</React.S | {
"filepath": "packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js",
"language": "javascript",
"file_size": 67214,
"cut_index": 3790,
"middle_length": 229
} |
etModules();
act = require('internal-test-utils').act;
simulateEventDispatch =
require('internal-test-utils').simulateEventDispatch;
Scheduler = require('scheduler/unstable_mock');
ReactDOMClient = require('react-dom/client');
React = require('react');
assertLog = require('internal-test-ut... | task');
});
setState(1);
Scheduler.log('onClickCapture parent');
}}>
<button
ref={ref => (childRef = ref)}
onClickCapture={() => {
queueMicrotask( | [state, setState] = React.useState(0);
Scheduler.log(`Render ${state}`);
return (
<div
onClickCapture={() => {
queueMicrotask(() => {
Scheduler.log('Parent micro | {
"filepath": "packages/internal-test-utils/__tests__/ReactInternalTestUtilsDOM-test.js",
"language": "javascript",
"file_size": 16375,
"cut_index": 921,
"middle_length": 229
} |
, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
import type {ComponentStackNode} from './ReactFizzComponentStack';
impor... | const DefaultAsyncDispatcher: AsyncDispatcher = ({
getCacheForType,
cacheSignal,
}: any);
if (__DEV__) {
DefaultAsyncDispatcher.getOwner = (): ComponentStackNode | null => {
if (currentTaskInDEV === null) {
return null;
}
return c | l {
throw new Error('Not implemented.');
}
export | {
"filepath": "packages/react-server/src/ReactFizzAsyncDispatcher.js",
"language": "javascript",
"file_size": 894,
"cut_index": 547,
"middle_length": 52
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {LazyComponent} from 'react/src/ReactLazy';
// These indirections exists so we can exclude its stack frame in DEV (and anything ... | g,
) => R = __DEV__
? // We use this technique to trick minifiers to preserve the function name.
(callComponent.react_stack_bottom_frame.bind(callComponent): any)
: (null: any);
interface ClassInstance<R> {
render(): R;
}
const callRender = {
| Arg) => R,
props: Props,
secondArg: Arg,
): R {
return Component(props, secondArg);
},
};
export const callComponentInDEV: <Props, Arg, R>(
Component: (p: Props, arg: Arg) => R,
props: Props,
secondArg: Ar | {
"filepath": "packages/react-server/src/ReactFizzCallUserSpace.js",
"language": "javascript",
"file_size": 1828,
"cut_index": 537,
"middle_length": 229
} |
et didWarnAboutUninitializedState;
let didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
let didWarnAboutLegacyLifecyclesAndDerivedState;
let didWarnAboutUndefinedDerivedState;
let didWarnAboutDirectlyAssigningPropsToState;
let didWarnAboutContextTypeAndContextTypes;
let didWarnAboutContextTypes;
let didWarnAboutChi... | idWarnAboutContextTypeAndContextTypes = new Set<mixed>();
didWarnAboutContextTypes = new Set<mixed>();
didWarnAboutChildContextTypes = new Set<mixed>();
didWarnAboutInvalidateContextType = new Set<mixed>();
didWarnOnInvalidCallback = new Set<string | WithoutDidUpdate = new Set<mixed>();
didWarnAboutLegacyLifecyclesAndDerivedState = new Set<string>();
didWarnAboutDirectlyAssigningPropsToState = new Set<string>();
didWarnAboutUndefinedDerivedState = new Set<string>();
d | {
"filepath": "packages/react-server/src/ReactFizzClassComponent.js",
"language": "javascript",
"file_size": 24696,
"cut_index": 1331,
"middle_length": 229
} |
import type {ReactComponentInfo, ReactAsyncInfo} from 'shared/ReactTypes';
import type {LazyComponent} from 'react/src/ReactLazy';
import {
describeBuiltInComponentFrame,
describeFunctionComponentFrame,
describeClassComponentFrame,
describeDebugInfoFrame,
} from 'shared/ReactComponentStackFrame';
import {
R... |
| LazyComponent<any, any>
| ReactComponentInfo
| ReactAsyncInfo,
owner?: null | ReactComponentInfo | ComponentStackNode, // DEV only
stack?: null | string | Error, // DEV only
};
function shouldConstruct(Component: any) {
return Compone | ransition} from 'shared/ReactFeatureFlags';
import {formatOwnerStack} from 'shared/ReactOwnerStackFrames';
export type ComponentStackNode = {
parent: null | ComponentStackNode,
type:
| symbol
| string
| Function | {
"filepath": "packages/react-server/src/ReactFizzComponentStack.js",
"language": "javascript",
"file_size": 6620,
"cut_index": 716,
"middle_length": 229
} |
nable,
readPreviousThenable,
} from './ReactFizzThenable';
import {
makeId,
NotPendingTransition,
supportsClientAPIs,
} from './ReactFizzConfig';
import {createFastHash} from './ReactServerStreamConfig';
import is from 'shared/objectIs';
import {
REACT_CONTEXT_TYPE,
REACT_MEMO_CACHE_SENTINEL,
} from 'shar... | : UpdateQueue<any> | null,
next: Hook | null,
};
let currentlyRenderingComponent: Object | null = null;
let currentlyRenderingTask: Task | null = null;
let currentlyRenderingRequest: Request | null = null;
let currentlyRenderingKeyPath: KeyNode | null = | on<S> = (S => S) | S;
type Dispatch<A> = A => void;
type Update<A> = {
action: A,
next: Update<A> | null,
};
type UpdateQueue<A> = {
last: Update<A> | null,
dispatch: any,
};
type Hook = {
memoizedState: any,
queue | {
"filepath": "packages/react-server/src/ReactFizzHooks.js",
"language": "javascript",
"file_size": 27332,
"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
*/
import {disableLegacyContext} from 'shared/ReactFeatureFlags';
import getComponentNameFromType from 'shared/getComponentNameFromType';
let warnedAboutMissingGetChildC... | emptyContextObject;
}
const context: {[string]: $FlowFixMe} = {};
for (const key in contextTypes) {
context[key] = unmaskedContext[key];
}
return context;
}
}
export function processChildContext(
instance: any,
type: any | ort function getMaskedContext(type: any, unmaskedContext: Object): Object {
if (disableLegacyContext) {
return emptyContextObject;
} else {
const contextTypes = type.contextTypes;
if (!contextTypes) {
return | {
"filepath": "packages/react-server/src/ReactFizzLegacyContext.js",
"language": "javascript",
"file_size": 2419,
"cut_index": 563,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let waitForAll;
// This is a new feature in Fiber so I put it in its own test file. It could
// probably move to one of the other test fi... | agment() {
return [<div key="a">Hello</div>, <div key="b">World</div>];
}
ReactNoop.render(<Fragment />);
await waitForAll([]);
});
it('should preserve state when switching from a single child', async function () {
let instance = | enderer');
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
});
it('should render a simple fragment at the top of a component', async function () {
function Fr | {
"filepath": "packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js",
"language": "javascript",
"file_size": 4055,
"cut_index": 614,
"middle_length": 229
} |
import type {ReactContext} from 'shared/ReactTypes';
import {isPrimaryRenderer} from './ReactFizzConfig';
let rendererSigil;
if (__DEV__) {
// Use this to detect multiple renderers using the same context
rendererSigil = {};
}
// Used to store the parent path of all context overrides in a shared linked list.
// F... | ny>;
export const rootContextSnapshot: ContextSnapshot = null;
// We assume that this runtime owns the "current" field on all ReactContext instances.
// This global (actually thread local) state represents what state all those "current",
// fields are cu | rentValue: T,
value: T,
};
// The structure of a context snapshot is an implementation of this file.
// Currently, it's implemented as tracking the current active node.
export opaque type ContextSnapshot = null | ContextNode<a | {
"filepath": "packages/react-server/src/ReactFizzNewContext.js",
"language": "javascript",
"file_size": 8935,
"cut_index": 716,
"middle_length": 229
} |
this row is not blocked)
hoistables: HoistableState, // Any dependencies that this row depends on. Future rows need to also depend on it.
inheritedHoistables: null | HoistableState, // Any dependencies that previous row depend on, that new boundaries of this row needs.
together: boolean, // All the boundaries wit... | ndary blocks from completing.
completedSegments: Array<Segment>, // completed but not yet flushed segments.
byteSize: number, // used to determine whether to inline children boundaries.
defer: boolean, // never inline deferred boundaries
fallbackAb | eBoundary = {
status: 0 | 1 | 4 | 5,
rootSegmentID: number,
parentFlushed: boolean,
pendingTasks: number, // when it reaches zero we can show this boundary's content
row: null | SuspenseListRow, // the row that this bou | {
"filepath": "packages/react-server/src/ReactFizzServer.js",
"language": "javascript",
"file_size": 212044,
"cut_index": 7068,
"middle_length": 229
} |
e,
RejectedThenable,
} from 'shared/ReactTypes';
import type {ComponentStackNode} from './ReactFizzComponentStack';
import noop from 'shared/noop';
import {currentTaskInDEV} from './ReactFizzCurrentTask';
export opaque type ThenableState = Array<Thenable<any>>;
// An error that is thrown (e.g. by `use`) to trigger... | lead to ' +
'unexpected behavior.\n\n' +
'To handle async errors, wrap your component in an error boundary, or ' +
"call the promise's `.catch` method and pass the result to `use`.",
);
export function createThenableState(): ThenableState {
| It's an implementation " +
'detail of `use` to interrupt the current render. You must either ' +
'rethrow it immediately, or move the `use` call outside of the ' +
'`try/catch` block. Capturing without rethrowing will | {
"filepath": "packages/react-server/src/ReactFizzThenable.js",
"language": "javascript",
"file_size": 12745,
"cut_index": 921,
"middle_length": 229
} |
e;
let useEffect;
let act;
let waitFor;
let waitForPaint;
let assertLog;
describe('ReactUpdatePriority', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').ac... | unction Text({text}) {
Scheduler.log(text);
return text;
}
it('setState inside passive effect triggered by sync update should have default priority', async () => {
const root = ReactNoop.createRoot();
function App() {
const [sta | = React.useEffect;
const InternalTestUtils = require('internal-test-utils');
waitFor = InternalTestUtils.waitFor;
waitForPaint = InternalTestUtils.waitForPaint;
assertLog = InternalTestUtils.assertLog;
});
f | {
"filepath": "packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js",
"language": "javascript",
"file_size": 4333,
"cut_index": 614,
"middle_length": 229
} |
, retry immediately without unwinding the stack', async () => {
let fulfilled = false;
function Async() {
if (fulfilled) {
return <Text text="Async" />;
}
Scheduler.log('Suspend!');
throw Promise.resolve().then(() => {
Scheduler.log('Resolve in microtask');
fulfil... | 'Resolve in microtask',
// Finished rendering without unwinding the stack or preparing a fallback.
'Async',
]);
expect(root).toMatchRenderedOutput('Async');
});
it('if suspended fiber is pinged in a microtask, it does not block a | = ReactNoop.createRoot();
await act(() => {
startTransition(() => {
root.render(<App />);
});
});
assertLog([
// React will yield when the async component suspends.
'Suspend!',
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactUse-test.js",
"language": "javascript",
"file_size": 74736,
"cut_index": 3790,
"middle_length": 229
} |
yMode
it('should not double invoke effects in legacy mode', async () => {
const log = [];
function App({text}) {
React.useEffect(() => {
log.push('useEffect mount');
return () => log.push('useEffect unmount');
});
React.useLayoutEffect(() => {
log.push('useLayoutEffe... | fecycles in legacy mode', async () => {
const log = [];
class App extends React.PureComponent {
componentDidMount() {
log.push('componentDidMount');
}
componentDidUpdate() {
log.push('componentDidUpdate');
} | >
<App text={'mount'} />
</React.StrictMode>,
);
});
expect(log).toEqual(['useLayoutEffect mount', 'useEffect mount']);
});
// @gate !disableLegacyMode
it('should not double invoke class li | {
"filepath": "packages/react-reconciler/src/__tests__/StrictEffectsModeDefaults-test.internal.js",
"language": "javascript",
"file_size": 20223,
"cut_index": 1331,
"middle_length": 229
} |
ls.assertLog;
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
function Text(props) {
Scheduler.log(props.text);
return <span prop={props.text} />;
}
async function fakeImport(result) {
return {default: result};
}
// Tests should run against both the lazy and non-lazy ... | return React.lazy(() => fakeImport(Memo));
});
function sharedTests(label, memo) {
describe(`${label}`, () => {
it('bails out on props equality', async () => {
function Counter({count}) {
return <Text text={count} />;
| .memo(...args);
function Indirection(props) {
return <Memo {...props} />;
}
return React.lazy(() => fakeImport(Indirection));
});
sharedTests('lazy', (...args) => {
const Memo = React.memo(...args);
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactMemo-test.js",
"language": "javascript",
"file_size": 18013,
"cut_index": 1331,
"middle_length": 229
} |
{
performanceMeasureCalls.length = 0;
Object.defineProperty(performance, 'measure', {
value: jest.fn((measureName, reusableOptions) => {
performanceMeasureCalls.push([
measureName,
{
// React will mutate the options it passes to performance.measure.
...... | ction getConsoleTimestampEntries() {
try {
return console.timeStamp.mock.calls.filter(call => {
const [, startTime, endTime] = call;
const isRegisterTrackCall = startTime !== 0.003 && endTime !== 0.003;
return isRegisterT | jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
useEffect = React.useEffect;
});
fun | {
"filepath": "packages/react-reconciler/src/__tests__/ReactPerformanceTrack-test.js",
"language": "javascript",
"file_size": 17254,
"cut_index": 921,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoopPersistent;
let act;
let waitForAll;
describe('ReactPersistent', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoopPersistent = require('react-noop-renderer/persistent');
({act, waitForAll... | ment);
}
function div(...children) {
children = children.map(c =>
typeof c === 'string' ? {text: c, hidden: false} : c,
);
return {type: 'div', children, prop: undefined, hidden: false};
}
function span(prop) {
return {type: | urn {
$$typeof: Symbol.for('react.portal'),
key: key == null ? null : String(key),
children,
containerInfo,
implementation,
};
}
function render(element) {
ReactNoopPersistent.render(ele | {
"filepath": "packages/react-reconciler/src/__tests__/ReactPersistent-test.js",
"language": "javascript",
"file_size": 6471,
"cut_index": 716,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let act;
describe('ReactIncrementalUpdatesMinimalism', () => {
beforeEach(() => {
jest.resetModules();
React = require('react')... | )).toEqual({
hostUpdateCounter: 0,
});
ReactNoop.startTrackingHostCounters();
await act(() => ReactNoop.render(<Parent />));
expect(ReactNoop.stopTrackingHostCounters()).toEqual({
hostUpdateCounter: 1,
});
});
it('shou | rn <div>Hello World</div>;
}
function Parent() {
return <Child />;
}
ReactNoop.startTrackingHostCounters();
await act(() => ReactNoop.render(<Parent />));
expect(ReactNoop.stopTrackingHostCounters( | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalUpdatesMinimalism-test.js",
"language": "javascript",
"file_size": 3748,
"cut_index": 614,
"middle_length": 229
} |
container = document.createElement('div');
document.body.appendChild(container);
});
afterEach(() => {
document.body.removeChild(container);
container = null;
});
// @gate enableScopeAPI
it('DO_NOT_USE_queryAllNodes() works as intended', async () => {
const testScopeQuery ... | <a ref={aRef}>A</a>
</TestScope>
) : (
<TestScope ref={scopeRef}>
<a ref={aRef}>A</a>
<div ref={divRef}>DIV</div>
<span ref={spanRef}>SPAN</span>
</TestScope>
);
}
| ;
const aRef = React.createRef();
function Test({toggle}) {
return toggle ? (
<TestScope ref={scopeRef}>
<div ref={divRef}>DIV</div>
<span ref={spanRef}>SPAN</span>
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactScope-test.internal.js",
"language": "javascript",
"file_size": 17734,
"cut_index": 1331,
"middle_length": 229
} |
et caches;
let seededCache;
let assertLog;
describe('ReactSuspenseWithNoopRenderer', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
Suspense = Re... | fore the initial render (i.e.
// not a refresh because nothing has mounted yet).
const cache = seededCache;
seededCache = null;
return cache;
}
const data = new Map();
const version = caches.length + 1;
const cache | tUtils.assertLog;
caches = [];
seededCache = null;
});
function createTextCache() {
if (seededCache !== null) {
// Trick to seed a cache before it exists.
// TODO: Need a built-in API to seed data be | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js",
"language": "javascript",
"file_size": 4711,
"cut_index": 614,
"middle_length": 229
} |
t}]`);
const thenable = {
pings: [],
then(resolve) {
if (newRecord.status === 'pending') {
thenable.pings.push(resolve);
} else {
Promise.resolve().then(() => resolve(newRecord.value));
}
},
};
const newRecord = {
s... | n props.children;
}
function Foo({renderBar}) {
Scheduler.log('Foo');
return (
<Suspense fallback={<Text text="Loading..." />}>
{renderBar ? (
<Bar>
<AsyncText text="A" />
<Text | }
function AsyncText({text}) {
readText(text);
Scheduler.log(text);
return text;
}
it('suspends rendering and continues later', async () => {
function Bar(props) {
Scheduler.log('Bar');
retur | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js",
"language": "javascript",
"file_size": 40956,
"cut_index": 2151,
"middle_length": 229
} |
OM', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
const InternalTestUtils = require('internal-test-utils... | const newRecord = {
status: 'pending',
value: {default: Component},
pings: [],
then(ping) {
switch (newRecord.status) {
case 'pending': {
newRecord.pings.push(ping);
ret | akeModuleCache = new Map();
});
afterEach(() => {
document.body.removeChild(container);
});
async function fakeImport(Component) {
const record = fakeModuleCache.get(Component);
if (record === undefined) {
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js",
"language": "javascript",
"file_size": 15490,
"cut_index": 921,
"middle_length": 229
} |
e('ReactSuspenseFuzz', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
Suspense = React.Suspense;
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
Random = require('random-seed');
ReactFeat... | dates}) {
const [step, setStep] = useState(0);
useLayoutEffect(() => {
if (updates !== undefined) {
const cleanUps = new Set();
updates.forEach(({remountAfter}, i) => {
const task = {
label | dContext = React.createContext(true);
let pendingTasks = new Set();
let cache = new Map();
function resetCache() {
pendingTasks = new Set();
cache = new Map();
}
function Container({children, up | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js",
"language": "javascript",
"file_size": 12903,
"cut_index": 921,
"middle_length": 229
} |
uses the -s suffix in the spelling. ' +
'Use "forwards" instead.' +
'\n in SuspenseList (at **)' +
'\n in Foo (at **)',
]);
});
// @gate enableSuspenseList
it('warns if a single element is passed to a "forwards" list', async () => {
function Foo({children}) {
return (
... | <Foo>
<Suspense fallback="Loading">Child</Suspense>
</Foo>,
);
});
assertConsoleErrorDev([
'A single row was passed to a <SuspenseList revealOrder="forwards" />. ' +
'This is not useful since it needs multi | []);
ReactNoop.render(<Foo>{null}</Foo>);
// No warning
await waitForAll([]);
ReactNoop.render(<Foo>{false}</Foo>);
// No warning
await waitForAll([]);
await act(() => {
ReactNoop.render(
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js",
"language": "javascript",
"file_size": 91658,
"cut_index": 3790,
"middle_length": 229
} |
stUtils = require('internal-test-utils');
act = InternalTestUtils.act;
assertLog = InternalTestUtils.assertLog;
waitForPaint = InternalTestUtils.waitForPaint;
});
function Text({text}) {
Scheduler.log(text);
return text;
}
function SuspenseyImage({src}) {
return (
<suspensey-thin... | nseyImage src="A" />
</Suspense>,
);
});
});
assertLog(['Image requested [A]', 'Loading...']);
expect(getSuspenseyThingStatus('A')).toBe('pending');
expect(root).toMatchRenderedOutput('Loading...');
// This shou | g initial mount', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
startTransition(() => {
root.render(
<Suspense fallback={<Text text="Loading..." />}>
<Suspe | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js",
"language": "javascript",
"file_size": 17780,
"cut_index": 1331,
"middle_length": 229
} |
nst data = new Map();
const version = caches.length + 1;
const cache = {
version,
data,
resolve(text) {
const record = data.get(text);
if (record === undefined) {
const newRecord = {
status: 'resolved',
value: text,
};
data.... | value: error,
};
data.set(text, newRecord);
} else if (record.status === 'pending') {
const thenable = record.value;
record.status = 'rejected';
record.value = error;
thenable.pings.forEa | thenable.pings.forEach(t => t());
}
},
reject(text, error) {
const record = data.get(text);
if (record === undefined) {
const newRecord = {
status: 'rejected',
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactTransition-test.js",
"language": "javascript",
"file_size": 34938,
"cut_index": 2151,
"middle_length": 229
} |
;
let act;
let waitFor;
let waitForAll;
let assertLog;
describe('updaters', () => {
beforeEach(() => {
jest.resetModules();
allSchedulerTags = [];
allSchedulerTypes = [];
onCommitRootShouldYield = true;
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactFeatureFlags.enableUpdate... | schedulerTypes.push(fiber.elementType);
});
allSchedulerTags.push(schedulerTags);
allSchedulerTypes.push(schedulerTypes);
}),
onCommitUnmount: jest.fn(() => {}),
onPostCommitRoot: jest.fn(() => {}),
onSche | eld) {
Scheduler.log('onCommitRoot');
}
const schedulerTags = [];
const schedulerTypes = [];
fiberRoot.memoizedUpdaters.forEach(fiber => {
schedulerTags.push(fiber.tag);
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactUpdaters-test.internal.js",
"language": "javascript",
"file_size": 13972,
"cut_index": 921,
"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
* @jest-environment node
*/
'use strict';
let act;
let ViewTransition;
let React;
let ReactServer;
let ReactNoop;
let ReactNoopFl... | ire('react');
ReactNoopFlightClient = require('react-noop-renderer/flight-client');
ReactNoop = require('react-noop-renderer');
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils.act;
});
afterEach(() => | er'));
ReactServer = require('react');
ViewTransition = ReactServer.ViewTransition;
ReactNoopFlightServer = require('react-noop-renderer/flight-server');
jest.resetModules();
__unmockReact();
React = requ | {
"filepath": "packages/react-reconciler/src/__tests__/ViewTransitionReactServer-test.js",
"language": "javascript",
"file_size": 1636,
"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.
*
* @jest-environment node
*/
// sanity tests for act()
const React = require('react');
const ReactNoop = require('react-noop-renderer');
const Scheduler... | eEffect(props.callback);
return null;
}
const calledLog = [];
await act(() => {
ReactNoop.render(
<App
callback={() => {
calledLog.push(calledLog.length);
}}
/>,
);
});
| p renderer
// implementation. They test the internal implementation we use in the React
// test suite.
describe('internal act()', () => {
it('can use act to flush effects', async () => {
function App(props) {
React.us | {
"filepath": "packages/react-reconciler/src/__tests__/ReactNoopRendererAct-test.js",
"language": "javascript",
"file_size": 1669,
"cut_index": 537,
"middle_length": 229
} |
t(
<div>
<span>Hello</span>
</div>,
);
ReactNoop.render(<Foo text="World" />);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(
<div>
<span>World</span>
<span>World</span>
</div>,
);
});
it('can update child nodes of a fragment', as... | an prop="test" />
</div>
);
}
ReactNoop.render(<Foo text="Hello" />);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(
<div>
<span>Hello</span>
<span prop="test" />
</div>,
);
| {props.text === 'World'
? [<Bar key="a" text={props.text} />, <div key="b" />]
: props.text === 'Hi'
? [<div key="b" />, <Bar key="a" text={props.text} />]
: null}
<sp | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js",
"language": "javascript",
"file_size": 34632,
"cut_index": 2151,
"middle_length": 229
} |
nal-test-utils').act;
assertLog = require('internal-test-utils').assertLog;
waitFor = require('internal-test-utils').waitFor;
waitForPaint = require('internal-test-utils').waitForPaint;
waitForAll = require('internal-test-utils').waitForAll;
startTransition = React.startTransition;
Suspense = Re... |
record.value = text;
thenable.pings.forEach(t => t());
}
}
function readText(text) {
const record = textCache.get(text);
if (record !== undefined) {
switch (record.status) {
case 'pending':
Scheduler.lo | st newRecord = {
status: 'resolved',
value: text,
};
textCache.set(text, newRecord);
} else if (record.status === 'pending') {
const thenable = record.value;
record.status = 'resolved'; | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSiblingPrerendering-test.js",
"language": "javascript",
"file_size": 16284,
"cut_index": 921,
"middle_length": 229
} |
case 'resolved':
return textCache.version;
}
} else {
Scheduler.log(`Suspend:${text}`);
const thenable = {
pings: [],
then(resolve) {
if (newRecord.status === 'pending') {
thenable.pings.push(resolve);
} else {
Promise.resolve... | eturn () => {
Scheduler.log(`Text:${text} destroy insertion`);
};
}, []);
React.useLayoutEffect(() => {
Scheduler.log(`Text:${text} create layout`);
return () => {
Scheduler.log(`Text:${text} destroy layout`);
| newRecord);
throw thenable;
}
}
function Text({children = null, text}) {
Scheduler.log(`Text:${text} render`);
React.useInsertionEffect(() => {
Scheduler.log(`Text:${text} create insertion`);
r | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js",
"language": "javascript",
"file_size": 111526,
"cut_index": 3790,
"middle_length": 229
} |
t.Profiler;
Suspense = React.Suspense;
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
assertLog = InternalTestUtils.assertLog;
act = InternalTestUtils.act;
TextResource = ReactCache.unstable_createResource(
([text, ms = 0]) => {
... | rejected [${text}]`);
status = 'rejected';
value = new Error('Failed to load: ' + text);
listeners.forEach(listener => listener.reject(value));
} else {
| : {
if (listeners === null) {
listeners = [{resolve, reject}];
setTimeout(() => {
if (textResourceShouldFail) {
Scheduler.log(`Promise | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspensePlaceholder-test.internal.js",
"language": "javascript",
"file_size": 19534,
"cut_index": 1331,
"middle_length": 229
} |
pending',
value: thenable,
};
textCache.data.set(text, newRecord);
throw thenable;
}
}
function Text({text}) {
Scheduler.log(text);
return <span prop={text} />;
}
function AsyncText({text, showVersion}) {
const version = readText(text);
const fullText = showVersi... | ently created cache. An older cache can by
// resolved with `caches[index].resolve(text)`.
caches[caches.length - 1].resolve(text);
}
}
const resolveText = resolveMostRecentTextCache;
function rejectMostRecentTextCache(text, error) | he = createTextCache();
}
seededCache.resolve(text);
}
function resolveMostRecentTextCache(text) {
if (caches.length === 0) {
throw Error('Cache does not exist.');
} else {
// Resolve the most rec | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js",
"language": "javascript",
"file_size": 115674,
"cut_index": 3790,
"middle_length": 229
} |
} else {
Promise.resolve().then(() => resolve(newRecord.value));
}
},
};
const newRecord = {
status: 'pending',
value: thenable,
};
textCache.data.set(text, newRecord);
throw thenable;
}
}
function AsyncText({text}) {
const fu... | hes[caches.length - 1].resolve(text);
}
}
const resolveText = resolveMostRecentTextCache;
function advanceTimers(ms) {
// Note: This advances Jest's virtual time but not React's. Use
// ReactNoop.expire for that.
if (typeof ms !== ' | ext) {
if (caches.length === 0) {
throw Error('Cache does not exist');
} else {
// Resolve the most recently created cache. An older cache can by
// resolved with `caches[index].resolve(text)`.
cac | {
"filepath": "packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js",
"language": "javascript",
"file_size": 79844,
"cut_index": 3790,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let Scheduler;
let waitFor;
let waitForAll;
describe('ReactIncrementalReflection', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require... | an', children: [], prop, hidden: false};
}
it('finds no node before insertion and correct node before deletion', async () => {
let classInstance = null;
function findInstance(inst) {
// We ignore warnings fired by findInstance because w | hildren) {
children = children.map(c =>
typeof c === 'string' ? {text: c, hidden: false} : c,
);
return {type: 'div', children, prop: undefined, hidden: false};
}
function span(prop) {
return {type: 'sp | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js",
"language": "javascript",
"file_size": 5481,
"cut_index": 716,
"middle_length": 229
} |
aitForPaint;
let assertLog;
let waitFor;
describe('ReactSchedulerIntegration', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
NormalPriority = Sc... | tils.waitFor;
});
// Note: This is based on a similar component we use in www. We can delete
// once the extra div wrapper is no longer necessary.
function LegacyHiddenDiv({children, mode}) {
return (
<div hidden={mode === 'hidden'}>
| const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
waitForPaint = InternalTestUtils.waitForPaint;
assertLog = InternalTestUtils.assertLog;
waitFor = InternalTestU | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js",
"language": "javascript",
"file_size": 11915,
"cut_index": 921,
"middle_length": 229
} |
ight (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let waitForAll;
// This is a new feature in Fib... | nent returning strings directly from render', async () => {
const Text = ({value}) => value;
ReactNoop.render(<Text value="foo" />);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput('foo');
});
it('should render a componen | les();
React = require('react');
ReactNoop = require('react-noop-renderer');
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
});
it('should render a compo | {
"filepath": "packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js",
"language": "javascript",
"file_size": 1485,
"cut_index": 524,
"middle_length": 229
} |
ayoutEffect mount');
return () => log.push('useLayoutEffect unmount');
});
return text;
}
const root = ReactNoop.createLegacyRoot();
await act(() => {
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
);
});
expec... | useLayoutEffect unmount');
});
return text;
}
await act(() => {
ReactNoop.renderToRootWithID(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
'root',
);
});
if (__D | .useEffect(() => {
log.push('useEffect mount');
return () => log.push('useEffect unmount');
});
React.useLayoutEffect(() => {
log.push('useLayoutEffect mount');
return () => log.push(' | {
"filepath": "packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js",
"language": "javascript",
"file_size": 22320,
"cut_index": 1331,
"middle_length": 229
} |
et React;
let ReactNoop;
let Scheduler;
let Suspense;
let getCacheForType;
let caches;
let seededCache;
let waitForAll;
describe('ReactSuspenseFallback', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('schedul... | nitial render (i.e.
// not a refresh because nothing has mounted yet).
const cache = seededCache;
seededCache = null;
return cache;
}
const data = new Map();
const version = caches.length + 1;
const cache = {
| );
waitForAll = InternalTestUtils.waitForAll;
});
function createTextCache() {
if (seededCache !== null) {
// Trick to seed a cache before it exists.
// TODO: Need a built-in API to seed data before the i | {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js",
"language": "javascript",
"file_size": 6006,
"cut_index": 716,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let waitForAll;
let act;
let assertConsoleErrorDev;
describe('ReactSuspense', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
const InternalTestUtils ... | if (!completed) {
throw promise;
}
return 'Done';
};
return {promise, resolve, PromiseComp};
}
// Warning don't fire in production, so this test passes in prod even if
// the suspenseCallback feature is not enabled
| function createThenable() {
let completed = false;
let resolve;
const promise = new Promise(res => {
resolve = () => {
completed = true;
res();
};
});
const PromiseComp = () => {
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactSuspenseCallback-test.js",
"language": "javascript",
"file_size": 6693,
"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 {ViewTransitionProps, ViewTransitionClass} from 'shared/ReactTypes';
import type {TreeContext} from './ReactFizzTreeContext';
import type {ResumableState} ... | d, 0);
}
function getClassNameByType(classByType: ?ViewTransitionClass): ?string {
if (classByType == null || typeof classByType === 'string') {
return classByType;
}
let className: ?string = null;
const activeTypes = null; // TODO: Support pa | reeContext: TreeContext,
resumableState: ResumableState,
): string {
if (props.name != null && props.name !== 'auto') {
return props.name;
}
const treeId = getTreeId(treeContext);
return makeId(resumableState, treeI | {
"filepath": "packages/react-server/src/ReactFizzViewTransitionComponent.js",
"language": "javascript",
"file_size": 2140,
"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.
*
* @flow
*/
import type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
export * from 'react-serve... | > = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export * from '../ReactFlightServerConfigDebugNoop';
export * from '../ReactFlightStackConfigV8' | nst requestStorage: AsyncLocalStorage<Request | void | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-parcel.js",
"language": "javascript",
"file_size": 909,
"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 type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
export * from 'react-server-dom-turbopack/src/server/ReactFlightServerConfigTurbopack... | ge = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export * from '../ReactFlightServerConfigDebugNoop';
export * from '../ReactFlightStackConfigV8';
export * from '../ReactServerConsoleConfigBrowser'; | = (null: any);
export const supportsComponentStora | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-turbopack.js",
"language": "javascript",
"file_size": 915,
"cut_index": 606,
"middle_length": 52
} |
, 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 {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
export * from 'react-serve... | id> = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export * from '../ReactFlightServerConfigDebugNoop';
export * from '../ReactFlightStackConfigV | const requestStorage: AsyncLocalStorage<Request | vo | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js",
"language": "javascript",
"file_size": 911,
"cut_index": 547,
"middle_length": 52
} |
ffiliates.
*
* 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 {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
export * from '../ReactFlightServerCon... | nentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export * from '../ReactFlightServerConfigDebugNoop';
export * from '../ReactFlightStackConfigV8';
export * from '../ReactServerConsoleConfig | t | void> = (null: any);
export const supportsCompo | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js",
"language": "javascript",
"file_size": 875,
"cut_index": 559,
"middle_length": 52
} |
Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';... | ? new AsyncLocalStorage() : (null: any);
export const supportsComponentStorage: boolean =
__DEV__ && supportsRequestStorage;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage | om the global scope, but this will likely move to a module.
export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
export const requestStorage: AsyncLocalStorage<Request | void> =
supportsRequestStorage | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-parcel.js",
"language": "javascript",
"file_size": 1172,
"cut_index": 518,
"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 {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';... | orage ? new AsyncLocalStorage() : (null: any);
export const supportsComponentStorage: boolean =
__DEV__ && supportsRequestStorage;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalS | his from the global scope, but this will likely move to a module.
export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
export const requestStorage: AsyncLocalStorage<Request | void> =
supportsRequestSt | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js",
"language": "javascript",
"file_size": 1178,
"cut_index": 518,
"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 {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes'... | ge ? new AsyncLocalStorage() : (null: any);
export const supportsComponentStorage: boolean =
__DEV__ && supportsRequestStorage;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStor | from the global scope, but this will likely move to a module.
export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
export const requestStorage: AsyncLocalStorage<Request | void> =
supportsRequestStora | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js",
"language": "javascript",
"file_size": 1175,
"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 type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
exp... | calStorage<Request | void> = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export function createHints(): any {
return null;
}
export type Forma | nfigServer';
export type Hints = any;
export type HintCode = any;
// eslint-disable-next-line no-unused-vars
export type HintModel<T: any> = any;
export const supportsRequestStorage = false;
export const requestStorage: AsyncLo | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js",
"language": "javascript",
"file_size": 1253,
"cut_index": 524,
"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 {AsyncLocalStorage} from 'async_hooks';
import type {Request} from 'react-server/src/ReactFlightServer';
imp... | ntStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
export * from '../ReactFlightServerConfigDebugNode';
export * from '../ReactFlightStackConfigV8';
export * from '../ReactServerC | ightServerConfigDOM';
export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
export const supportsComponentStorage = __DEV__;
export const compone | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js",
"language": "javascript",
"file_size": 1018,
"cut_index": 512,
"middle_length": 229
} |
, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
export * from 'react-fligh... | d> = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export * from '../ReactFlightServerConfigDebugNoop';
export * from '../ReactFlightStackConfigV8 | onst requestStorage: AsyncLocalStorage<Request | voi | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node-fb.js",
"language": "javascript",
"file_size": 909,
"cut_index": 547,
"middle_length": 52
} |
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {AsyncLocalStorage} from 'async_hooks';
import type {Request} from 'react-server/src/ReactFlightServer';
imp... | omponentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
export * from '../ReactFlightServerConfigDebugNode';
export * from '../ReactFlightStackConfigV8';
export * from '../ReactS | eactFlightServerConfigDOM';
export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
export const supportsComponentStorage = __DEV__;
export const c | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node-parcel.js",
"language": "javascript",
"file_size": 1024,
"cut_index": 512,
"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 {AsyncLocalStorage} from 'async_hooks';
import type {Request} from 'react-server/src/ReactFlightServer';
impo... | nst componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
export * from '../ReactFlightServerConfigDebugNode';
export * from '../ReactFlightStackConfigV8';
export * from '../R | ver/ReactFlightServerConfigDOM';
export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
export const supportsComponentStorage = __DEV__;
export co | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js",
"language": "javascript",
"file_size": 1030,
"cut_index": 513,
"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 {AsyncLocalStorage} from 'async_hooks';
import type {Request} from 'react-server/src/ReactFlightServer';
impo... | nst componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
export * from '../ReactFlightServerConfigDebugNode';
export * from '../ReactFlightStackConfigV8';
export * from '../R | ver/ReactFlightServerConfigDOM';
export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
export const supportsComponentStorage = __DEV__;
export co | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node-unbundled.js",
"language": "javascript",
"file_size": 1030,
"cut_index": 513,
"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 {AsyncLocalStorage} from 'async_hooks';
import type {Request} from 'react-server/src/ReactFlightServer';
imp... | componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
export * from '../ReactFlightServerConfigDebugNode';
export * from '../ReactFlightStackConfigV8';
export * from '../Reac | /ReactFlightServerConfigDOM';
export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
export const supportsComponentStorage = __DEV__;
export const | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js",
"language": "javascript",
"file_size": 1026,
"cut_index": 512,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
export type HintCod... | parentContext;
}
export const supportsRequestStorage = false;
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | matContext = null;
export function createRootFormatContext(): FormatContext {
return null;
}
export function getChildFormatContext(
parentContext: FormatContext,
type: string,
props: Object,
): FormatContext {
return | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.markup.js",
"language": "javascript",
"file_size": 3541,
"cut_index": 614,
"middle_length": 229
} |
ight (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Request} from 'react-server/src/ReactFlightServer';
import type {ReactComponentInfo} from 'shared/ReactTypes';
exp... | ncLocalStorage<Request | void> = (null: any);
export const supportsComponentStorage = false;
export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
(null: any);
export function createHints(): Hints {
return null;
}
export type | nfigPlain';
export type Hints = null;
export type HintCode = string;
export type HintModel<T: HintCode> = null; // eslint-disable-line no-unused-vars
export const supportsRequestStorage = false;
export const requestStorage: Asy | {
"filepath": "packages/react-server/src/forks/ReactFlightServerConfig.noop.js",
"language": "javascript",
"file_size": 1259,
"cut_index": 524,
"middle_length": 229
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// This is a host config that's used for the `react-server` package on npm.
// It is only used by third-party renderers.
//
// Its API lets y... | ion.
declare const $$$config: any;
export opaque type Destination = mixed;
export opaque type PrecomputedChunk = mixed;
export opaque type Chunk = mixed;
export opaque type BinaryChunk = mixed;
export const scheduleWork = $$$config.scheduleWork;
export | ver` bundle is wrapped in something like:
//
// module.exports = function ($$$config) {
// /* renderer code */
// }
//
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping funct | {
"filepath": "packages/react-server/src/forks/ReactServerStreamConfig.custom.js",
"language": "javascript",
"file_size": 1899,
"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
*/
// This is a host config that's used for the `react-server` package on npm.
// It is only used by third-party renderers.
//
// Its API lets y... | ion.
declare const $$$config: $FlowFixMe;
export opaque type Destination = mixed;
export opaque type PrecomputedChunk = mixed;
export opaque type Chunk = mixed;
export opaque type BinaryChunk = mixed;
export const scheduleWork = $$$config.scheduleWork;
| ver` bundle is wrapped in something like:
//
// module.exports = function ($$$config) {
// /* renderer code */
// }
//
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping funct | {
"filepath": "packages/react-server/src/forks/ReactServerStreamConfig.noop.js",
"language": "javascript",
"file_size": 1906,
"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
*/
import type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
import {resolveRequest, getCache} from '../... | Type): any);
if (entry === undefined) {
entry = resourceType();
// TODO: Warn if undefined?
cache.set(resourceType, entry);
}
return entry;
},
cacheSignal(): null | AbortSignal {
const request = resolveRequest();
i | Cache(request);
}
return new Map();
}
export const DefaultAsyncDispatcher: AsyncDispatcher = ({
getCacheForType<T>(resourceType: () => T): T {
const cache = resolveCache();
let entry: T | void = (cache.get(resource | {
"filepath": "packages/react-server/src/flight/ReactFlightAsyncDispatcher.js",
"language": "javascript",
"file_size": 1167,
"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 type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
import ReactSharedInternals from 'shared/ReactShar... |
}
return entry;
},
cacheSignal(): null {
return null;
},
getOwner(): null {
return null;
},
};
// Not using async/await because we don't compile it.
return new Promise((resolve, reject) => {
function r | (resourceType: () => R): R {
let entry: R | void = (cache.get(resourceType): any);
if (entry === undefined) {
entry = resourceType();
// TODO: Warn if undefined?
cache.set(resourceType, entry); | {
"filepath": "packages/react-suspense-test-utils/src/ReactSuspenseTestUtils.js",
"language": "javascript",
"file_size": 1470,
"cut_index": 524,
"middle_length": 229
} |
ing,
url: string,
};
type TransformSourceFunction = (
Source,
TransformSourceContext,
TransformSourceFunction,
) => Promise<{source: Source}>;
type LoadContext = {
conditions: Array<string>,
format: string | null | void,
importAssertions: Object,
};
type LoadFunction = (
string,
LoadContext,
Load... |
// We stash this in case we end up needing to resolve export * statements later.
stashedResolve = defaultResolve;
if (!context.conditions.includes('react-server')) {
context = {
...context,
conditions: [...context.conditions, 'react | e: null | GetSourceFunction = null;
let stashedResolve: null | ResolveFunction = null;
export async function resolve(
specifier: string,
context: ResolveContext,
defaultResolve: ResolveFunction,
): Promise<{url: string}> { | {
"filepath": "packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeLoader.js",
"language": "javascript",
"file_size": 23844,
"cut_index": 1331,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
const acorn = require('acorn-loose');
const url = require('url');
const Module = require('module');
module.exports = function register() {
const Server: any = require('react-server-dom-unbundled/server');
const ... | heck for the exact string. If it doesn't exist, don't
// bother parsing.
if (
content.indexOf('use client') === -1 &&
content.indexOf('use server') === -1
) {
return originalCompile.apply(this, arguments);
}
let body; | ginalCompile = Module.prototype._compile;
// $FlowFixMe[prop-missing] found when upgrading Flow
Module.prototype._compile = function (
this: any,
content: string,
filename: string,
): void {
// Do a quick c | {
"filepath": "packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeRegister.js",
"language": "javascript",
"file_size": 3097,
"cut_index": 614,
"middle_length": 229
} |
$$location?: Error,
};
// eslint-disable-next-line no-unused-vars
export type ClientReference<T> = {
$$typeof: symbol,
$$id: string,
$$async: boolean,
};
const CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
const SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
export function isClien... | + '#' + exportName,
false,
);
}
function registerClientReferenceImpl<T>(
proxyImplementation: any,
id: string,
async: boolean,
): ClientReference<T> {
return Object.defineProperties(proxyImplementation, {
$$typeof: {value: CLIENT_REFEREN | = SERVER_REFERENCE_TAG;
}
export function registerClientReference<T>(
proxyImplementation: any,
id: string,
exportName: string,
): ClientReference<T> {
return registerClientReferenceImpl(
proxyImplementation,
id | {
"filepath": "packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js",
"language": "javascript",
"file_size": 11353,
"cut_index": 921,
"middle_length": 229
} |
ight (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export type ImportManifestEntry = {
id: string,
// chunks is a double indexed array of chunkId / chunkFilename pairs
chunk... | ndexed */ Array<string>,
/* name */ string,
];
export const ID = 0;
export const CHUNKS = 1;
export const NAME = 2;
// export const ASYNC = 3;
// This logic is correct because currently only include the 4th tuple member
// when the module is as | adata =
| [
/* id */ string,
/* chunks id/filename pairs, double indexed */ Array<string>,
/* name */ string,
/* async */ 1,
]
| [
/* id */ string,
/* chunks id/filename pairs, double i | {
"filepath": "packages/react-server-dom-unbundled/src/shared/ReactFlightImportMetadata.js",
"language": "javascript",
"file_size": 1283,
"cut_index": 524,
"middle_length": 229
} |
erRequest,
startWork,
startFlowing,
startFlowingDebug,
stopFlowing,
abort,
resolveDebugMessage,
closeDebugChannel,
} from 'react-server/src/ReactFlightServer';
import {
createResponse,
reportGlobalError,
close,
resolveField,
resolveFile,
resolveFileInfo,
resolveFileChunk,
resolveFileCompl... | tStreamConfigNode';
import {textEncoder} from 'react-server/src/ReactServerStreamConfigNode';
import type {TemporaryReferenceSet} from 'react-server/src/ReactFlightServerTemporaryReferences';
import type {FileHandle} from 'react-server/src/ReactFlightRep | rence,
registerClientReference,
createClientModuleProxy,
} from '../ReactFlightUnbundledReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClien | {
"filepath": "packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js",
"language": "javascript",
"file_size": 22463,
"cut_index": 1331,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {
ImportMetadata,
ImportManifestEntry,
} from '../shared/ReactFlightImportMetadata';
import type {
ClientReference,
ServerR... | e,
isServerReference,
} from '../ReactFlightUnbundledReferences';
export function getClientReferenceKey(
reference: ClientReference<any>,
): ClientReferenceKey {
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
}
export functi | type ServerReferenceId = string;
export type ClientReferenceMetadata = ImportMetadata;
export opaque type ClientReferenceManifestEntry = ImportManifestEntry;
export type ClientReferenceKey = string;
export {
isClientReferenc | {
"filepath": "packages/react-server-dom-unbundled/src/server/ReactFlightServerConfigUnbundledBundler.js",
"language": "javascript",
"file_size": 3237,
"cut_index": 614,
"middle_length": 229
} |
import type {
Thenable,
FulfilledThenable,
RejectedThenable,
} from 'shared/ReactTypes';
import type {ImportMetadata} from '../shared/ReactFlightImportMetadata';
import type {ModuleLoading} from 'react-client/src/ReactFlightClientConfig';
import {
ID,
CHUNKS,
NAME,
isAsyncImport,
} from '../shared/React... | tadata;
// eslint-disable-next-line no-unused-vars
export opaque type ClientReference<T> = {
specifier: string,
name: string,
async?: boolean,
};
// The reason this function needs to defined here in this file instead of just
// being exported direc | duleMap = {
[clientId: string]: {
[clientExportName: string]: ClientReference<any>,
},
};
export type ServerManifest = void;
export type ServerReferenceId = string;
export opaque type ClientReferenceMetadata = ImportMe | {
"filepath": "packages/react-server-dom-unbundled/src/client/ReactFlightClientConfigBundlerNode.js",
"language": "javascript",
"file_size": 5457,
"cut_index": 716,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.