prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
extends React.Component {
render() {
return <div />;
}
};
let RequiredPropComponent = class extends React.Component {
render() {
return <span>{this.props.prop}</span>;
}
};
RequiredPropComponent.displayName = 'RequiredPropComponent';
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired}... | tion);
expect(element.props).toEqual(expectation);
});
it('allows a lower-case to be passed as the string type', () => {
const element = <div />;
expect(element.type).toBe('div');
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
| te element according to spec', () => {
const element = <Component />;
expect(element.type).toBe(Component);
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
const expectation = {};
Object.freeze(expecta | {
"filepath": "fixtures/legacy-jsx-runtimes/react-17/react-17.test.js",
"language": "javascript",
"file_size": 21950,
"cut_index": 1331,
"middle_length": 229
} |
RICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
... | REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
}
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbo | ck');
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
REACT_SCOPE_TYPE = symbolFor('react.scope');
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
| {
"filepath": "fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-dev-runtime.development.js",
"language": "javascript",
"file_size": 37760,
"cut_index": 2151,
"middle_length": 229
} |
_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
REAC... | CT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
}
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.it | ;
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
REACT_SCOPE_TYPE = symbolFor('react.scope');
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
REA | {
"filepath": "fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-runtime.development.js",
"language": "javascript",
"file_size": 38359,
"cut_index": 2151,
"middle_length": 229
} |
extends React.Component {
render() {
return <div />;
}
};
let RequiredPropComponent = class extends React.Component {
render() {
return <span>{this.props.prop}</span>;
}
};
RequiredPropComponent.displayName = 'RequiredPropComponent';
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired}... | tion);
expect(element.props).toEqual(expectation);
});
it('allows a lower-case to be passed as the string type', () => {
const element = <div />;
expect(element.type).toBe('div');
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
| te element according to spec', () => {
const element = <Component />;
expect(element.type).toBe(Component);
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
const expectation = {};
Object.freeze(expecta | {
"filepath": "fixtures/legacy-jsx-runtimes/react-15/react-15.test.js",
"language": "javascript",
"file_size": 21547,
"cut_index": 1331,
"middle_length": 229
} |
= 0xeacb;
var REACT_STRICT_MODE_TYPE = 0xeacc;
var REACT_PROFILER_TYPE = 0xead2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
va... | REACT_PORTAL_TYPE = symbolFor('react.portal');
exports.Fragment = symbolFor('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provi | G_MODE_TYPE = 0xeae1;
var REACT_OFFSCREEN_TYPE = 0xeae2;
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
| {
"filepath": "fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js",
"language": "javascript",
"file_size": 27326,
"cut_index": 1331,
"middle_length": 229
} |
eacb;
var REACT_STRICT_MODE_TYPE = 0xeacc;
var REACT_PROFILER_TYPE = 0xead2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
var RE... | CT_PORTAL_TYPE = symbolFor('react.portal');
exports.Fragment = symbolFor('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider' | DE_TYPE = 0xeae1;
var REACT_OFFSCREEN_TYPE = 0xeae2;
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
REA | {
"filepath": "fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-runtime.development.js",
"language": "javascript",
"file_size": 27937,
"cut_index": 1331,
"middle_length": 229
} |
ds React.Component {
render() {
return <div />;
}
};
let RequiredPropComponent = class extends React.Component {
render() {
return <span>{this.props.prop}</span>;
}
};
RequiredPropComponent.displayName = 'RequiredPropComponent';
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
it(... |
expect(element.props).toEqual(expectation);
});
it('allows a lower-case to be passed as the string type', () => {
const element = <div />;
expect(element.type).toBe('div');
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
const | ment according to spec', () => {
const element = <Component />;
expect(element.type).toBe(Component);
expect(element.key).toBe(null);
expect(element.ref).toBe(null);
const expectation = {};
Object.freeze(expectation); | {
"filepath": "fixtures/legacy-jsx-runtimes/react-14/react-14.test.js",
"language": "javascript",
"file_size": 21531,
"cut_index": 1331,
"middle_length": 229
} |
read: getSVGAttribute('additive'),
},
{
name: 'alignment-baseline',
containerTagName: 'svg',
tagName: 'textPath',
read: getSVGAttribute('alignment-baseline'),
},
{
name: 'alignmentBaseline',
containerTagName: 'svg',
tagName: 'textPath',
read: getSVGAttribute('alignment-basel... | ',
containerTagName: 'svg',
tagName: 'font-face',
read: getSVGAttribute('alphabetic'),
},
{name: 'alt', tagName: 'img'},
{
name: 'amplitude',
containerTagName: 'svg',
tagName: 'feFuncA',
read: getSVGProperty('amplitude'),
| ('allowFullscreen'),
},
{name: 'allowFullscreen', tagName: 'iframe'},
{
name: 'allowReorder',
containerTagName: 'svg',
tagName: 'switch',
read: getSVGAttribute('allowReorder'),
},
{
name: 'alphabetic | {
"filepath": "fixtures/attribute-behavior/src/attributes.js",
"language": "javascript",
"file_size": 59027,
"cut_index": 2151,
"middle_length": 229
} |
equire('fs');
const path = require('path');
const child_process = require('child_process');
const fixtureDirs = fs.readdirSync(__dirname).filter(file => {
return fs.statSync(path.join(__dirname, file)).isDirectory();
});
const cmdArgs = [
{cmd: 'yarn', args: ['install']},
{cmd: 'yarn', args: ['build']},
];
fun... | to be built
const devPath = path.join(__dirname, dir, 'dev');
if (fs.existsSync(devPath)) {
buildFixture(cmdArg, devPath);
}
const prodPath = path.join(__dirname, dir, 'prod');
if (fs.existsSync(prodPath)) {
buildFixture(c | ) {
throw new Error(`Failed to build fixtures!`);
}
}
fixtureDirs.forEach(dir => {
cmdArgs.forEach(cmdArg => {
// we only care about directories that have DEV and PROD directories in
// otherwise they don't need | {
"filepath": "fixtures/packaging/build-all.js",
"language": "javascript",
"file_size": 1368,
"cut_index": 524,
"middle_length": 229
} |
bore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ... | .
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad min | im ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua | {
"filepath": "fixtures/owner-stacks/src/App.js",
"language": "javascript",
"file_size": 7217,
"cut_index": 716,
"middle_length": 229
} |
from 'react';
import {renderToPipeableStream} from 'react-dom/server';
import App from '../src/components/App.js';
let assets;
if (process.env.NODE_ENV === 'development') {
// Use the bundle from create-react-app's server in development mode.
assets = {
'main.js': '/static/js/bundle.js',
// 'main.css': '... | // If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
pipe(res);
},
onShellError(x) {
// Som | .error('Fatal', error);
});
let didError = false;
const {pipe, abort} = renderToPipeableStream(
<App assets={assets} initialURL={url} />,
{
bootstrapScripts: [assets['main.js']],
onShellReady() {
| {
"filepath": "fixtures/view-transition/server/render.js",
"language": "javascript",
"file_size": 1405,
"cut_index": 524,
"middle_length": 229
} |
or nisi in leo congue rutrum. Morbi sed ante posuere,
aliquam lorem ac, imperdiet orci. Duis malesuada gravida pharetra.
Cras facilisis arcu diam, id dictum lorem imperdiet a. Suspendisse
aliquet tempus tortor et ultricies. Aliquam libero velit, posuere
tempus ante sed, pellentes... | ta risus vitae
pretium posuere. Fusce facilisis eros in lacus tincidunt congue.
</p>
</Suspense>
<Suspense fallback={null}>
<p>
Pellentesque habitant morbi tristique senectus et netus et malesuada
f | eget
blandit neque. Pellentesque a massa in turpis ullamcorper volutpat vel
at massa. Sed ante est, auctor non diam non, vulputate ultrices metus.
Maecenas dictum fermentum quam id aliquam. Donec por | {
"filepath": "fixtures/ssr/src/components/LargeContent.js",
"language": "javascript",
"file_size": 16873,
"cut_index": 921,
"middle_length": 229
} |
const babelRegister = require('babel-register');
const proxy = require('http-proxy-middleware');
babelRegister({
ignore: /\/(build|node_modules)\//,
presets: ['react-app'],
});
const express = require('express');
const path = require('path');
const app = express();
// Application
if (process.env.NODE_ENV === '... | der(req.url, res);
});
}
// Static resources
app.use(express.static(path.resolve(__dirname, '..', 'build')));
// Proxy everything else to create-react-app's webpack development server
if (process.env.NODE_ENV === 'development') {
app.use(
'/',
| e.cache) {
delete require.cache[key];
}
const render = require('./render').default;
render(req.url, res);
});
} else {
const render = require('./render').default;
app.get('/', function (req, res) {
ren | {
"filepath": "fixtures/ssr/server/index.js",
"language": "javascript",
"file_size": 1632,
"cut_index": 537,
"middle_length": 229
} |
ent, commentSource}) {
const currentUserID = comment.viewer.id;
const environment = RelayEnvironment.forUser(currentUserID);
const commentID = nullthrows(comment.id);
useEffect(() => {
const subscription = SubscriptionCounter.subscribeOnce(
`StoreSubscription_${commentID}`,
() =>
StoreSu... | }
function UseEffectWithEmptyDependencies() {
useEffect(() => {
const local = {};
console.log(local);
}, []);
}
// OK because `props` wasn't defined.
function ComponentWithNoPropsDefined() {
useEffect(() => {
console.log(props.foo);
}, | cription.dispose();
}, [commentID, commentSource, currentUserID, environment]);
}
// Valid because no dependencies
function UseEffectWithNoDependencies() {
const local = {};
useEffect(() => {
console.log(local);
});
| {
"filepath": "fixtures/eslint-v6/index.js",
"language": "javascript",
"file_size": 4191,
"cut_index": 614,
"middle_length": 229
} |
ct, {Component} from 'react';
class Editor extends Component {
constructor(props) {
super(props);
this.state = {
code: props.code,
};
}
render() {
return (
<div
style={{
height: '100%',
width: '100%',
}}>
<textarea
value={this.sta... | <div style={{height: '20%', textAlign: 'center'}}>
<button
onClick={() => this.props.onClose(this.state.code)}
style={{fontSize: 'large'}}>
Run
</button>
</div>
</div>
);
}
}
ex | />
| {
"filepath": "fixtures/fiber-debugger/src/Editor.js",
"language": "javascript",
"file_size": 813,
"cut_index": 522,
"middle_length": 14
} |
();
function getFiberUniqueID(fiber) {
if (!fiberIDMap.has(fiber)) {
fiberIDMap.set(fiber, nextFiberID++);
}
return fiberIDMap.get(fiber);
}
function getFriendlyTag(tag) {
switch (tag) {
case 0:
return '[indeterminate]';
case 1:
return '[fn]';
case 2:
return '[class]';
ca... | rk',
2: 'Placement',
4: 'Update',
8: 'Deletion',
16: 'Content reset',
32: 'Callback',
64: 'Err',
128: 'Ref',
};
return Object.keys(effects)
.filter(flag => flag & flags)
.map(flag => effects[flag])
.join(' & ');
| return '[handler]';
case 9:
return '[yield]';
case 10:
return '[frag]';
default:
throw new Error('Unknown tag.');
}
}
function getFriendlyEffect(flags) {
const effects = {
1: 'Performed Wo | {
"filepath": "fixtures/fiber-debugger/src/describeFibers.js",
"language": "javascript",
"file_size": 2562,
"cut_index": 563,
"middle_length": 229
} |
ion, useOptimistic} from 'react';
import {deleteTodo, setTodoComplete, type Todo as ITodo} from './actions';
export function TodoItem({
todo,
isSelected,
}: {
todo: ITodo;
isSelected: boolean;
}) {
let [isOptimisticComplete, setOptimisticComplete] = useOptimistic(
todo.isComplete,
);
return (
<l... | await setTodoComplete(todo.id, e.target.checked);
});
}}
/>
<a
href={`/todos/${todo.id}`}
aria-current={isSelected ? 'page' : undefined}>
{todo.title}
</a>
<button onClick={() => delete | setOptimisticComplete(e.target.checked);
| {
"filepath": "fixtures/flight-parcel/src/TodoItem.tsx",
"language": "tsx",
"file_size": 898,
"cut_index": 547,
"middle_length": 52
} |
Response,
} from 'express';
import {Readable} from 'node:stream';
import type {ReadableStream as NodeReadableStream} from 'stream/web';
import {
renderToReadableStream,
loadServerAction,
decodeReply,
decodeAction,
} from 'react-server-dom-parcel/server.edge';
import {injectRSCPayload} from 'rsc-html-stream/serv... | 'react-client'};
// Page components. These must have "use server-entry" so they are treated as code splitting entry points.
import {Todos} from './Todos';
const app = express();
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-M | om-parcel/client.edge' with {env: 'react-client'};
import {renderToReadableStream as renderHTMLToReadableStream} from 'react-dom/server.edge' with {env: 'react-client'};
import ReactClient, {ReactElement} from 'react' with {env: | {
"filepath": "fixtures/flight-parcel/src/server.tsx",
"language": "tsx",
"file_size": 4067,
"cut_index": 614,
"middle_length": 229
} |
var Circle = require('react-art/Circle');
var React = require('react');
var ReactART = require('react-art');
var Group = ReactART.Group;
var Shape = ReactART.Shape;
var Surface = ReactART.Surface;
var Transform = ReactART.Transform;
var MOUSE_UP_DRAG = 0.978;
var MOUSE_DOWN_DRAG = 0.9;
var MAX_VEL = 11;
var CLICK_AC... | ation loop that invokes our
* method. Binding of `this.onTick` is not needed because all React methods
* are automatically bound before being mounted.
*/
componentDidMount() {
this._interval = window.setInterval(this.onTick, 20);
}
comp | drag: MOUSE_UP_DRAG};
/**
* When the component is mounted into the document - this is similar to a
* constructor, but invoked when the instance is actually mounted into the
* document. Here, we'll just set up an anim | {
"filepath": "fixtures/art/VectorWidget.js",
"language": "javascript",
"file_size": 5716,
"cut_index": 716,
"middle_length": 229
} |
nder the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
export default function Html({assets, children, title}) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
... | `<b>Enable JavaScript to run this app.</b>`,
}}
/>
{children}
<script
dangerouslySetInnerHTML={{
__html: `assetManifest = ${JSON.stringify(assets)};`,
}}
/>
</body>
</html | dangerouslySetInnerHTML={{
__html: | {
"filepath": "fixtures/ssr2/src/Html.js",
"language": "javascript",
"file_size": 923,
"cut_index": 606,
"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.
*
*/
import {createContext, useContext} from 'react';
// Note: this file does not demonstrate a real data fetching strategy.
// We only... | streamed with the HTML.
// We haven't integrated this part yet, so we'll just use fake data.
const fakeData = [
"Wait, it doesn't wait for React to load?",
'How does this even work?',
'I like marshmallows',
];
export function useData() {
const ct | for this.
const DataContext = createContext(null);
export function DataProvider({children, data}) {
return <DataContext.Provider value={data}>{children}</DataContext.Provider>;
}
// In a real implementation the data would be | {
"filepath": "fixtures/ssr2/src/data.js",
"language": "javascript",
"file_size": 1202,
"cut_index": 518,
"middle_length": 229
} |
ent, commentSource}) {
const currentUserID = comment.viewer.id;
const environment = RelayEnvironment.forUser(currentUserID);
const commentID = nullthrows(comment.id);
useEffect(() => {
const subscription = SubscriptionCounter.subscribeOnce(
`StoreSubscription_${commentID}`,
() =>
StoreSu... | }
function UseEffectWithEmptyDependencies() {
useEffect(() => {
const local = {};
console.log(local);
}, []);
}
// OK because `props` wasn't defined.
function ComponentWithNoPropsDefined() {
useEffect(() => {
console.log(props.foo);
}, | cription.dispose();
}, [commentID, commentSource, currentUserID, environment]);
}
// Valid because no dependencies
function UseEffectWithNoDependencies() {
const local = {};
useEffect(() => {
console.log(local);
});
| {
"filepath": "fixtures/eslint-v7/index.js",
"language": "javascript",
"file_size": 4191,
"cut_index": 614,
"middle_length": 229
} |
alue: {
toString() {
return 'result of toString()';
},
},
testDisplayValue: "{ toString() { return 'result of toString()'; } }",
},
{
name: 'numeric string',
testValue: '42',
displayValue: "'42'",
},
{
name: '-1',
testValue: -1,
},
{
name: '0',
testVal... | e'",
},
{
name: "string 'on'",
testValue: 'on',
displayValue: "'on'",
},
{
name: "string 'off'",
testValue: 'off',
displayValue: "'off'",
},
{
name: 'symbol',
testValue: Symbol('foo'),
testDisplayValue: "Symb | true,
},
{
name: 'false',
testValue: false,
},
{
name: "string 'true'",
testValue: 'true',
displayValue: "'true'",
},
{
name: "string 'false'",
testValue: 'false',
displayValue: "'fals | {
"filepath": "fixtures/attribute-behavior/src/App.js",
"language": "javascript",
"file_size": 26518,
"cut_index": 1331,
"middle_length": 229
} |
ent, commentSource}) {
const currentUserID = comment.viewer.id;
const environment = RelayEnvironment.forUser(currentUserID);
const commentID = nullthrows(comment.id);
useEffect(() => {
const subscription = SubscriptionCounter.subscribeOnce(
`StoreSubscription_${commentID}`,
() =>
StoreSu... | }
function UseEffectWithEmptyDependencies() {
useEffect(() => {
const local = {};
console.log(local);
}, []);
}
// OK because `props` wasn't defined.
function ComponentWithNoPropsDefined() {
useEffect(() => {
console.log(props.foo);
}, | cription.dispose();
}, [commentID, commentSource, currentUserID, environment]);
}
// Valid because no dependencies
function UseEffectWithNoDependencies() {
const local = {};
useEffect(() => {
console.log(local);
});
| {
"filepath": "fixtures/eslint-v10/index.js",
"language": "javascript",
"file_size": 4633,
"cut_index": 614,
"middle_length": 229
} |
const babelRegister = require('@babel/register');
const proxy = require('http-proxy-middleware');
babelRegister({
ignore: [/\/(build|node_modules)\//],
presets: ['react-app'],
});
const express = require('express');
const path = require('path');
const app = express();
// Application
if (process.env.NODE_ENV ==... | , function (req, res) {
render(req.url, res);
});
});
}
// Static resources
app.use(express.static(path.resolve(__dirname, '..', 'build')));
// Proxy everything else to create-react-app's webpack development server
if (process.env.NODE_ENV == | uire.cache) {
delete require.cache[key];
}
import('./render.js').then(({default: render}) => {
render(req.url, res);
});
});
} else {
import('./render.js').then(({default: render}) => {
app.get('/' | {
"filepath": "fixtures/view-transition/server/index.js",
"language": "javascript",
"file_size": 1721,
"cut_index": 537,
"middle_length": 229
} |
, {Component} from 'react';
import Theme from './Theme';
import Suspend from './Suspend';
import './Page.css';
const autofocusedInputs = [
<input key="0" autoFocus placeholder="Has auto focus" />,
<input key="1" autoFocus placeholder="Has auto focus" />,
];
export default class Page extends Component {
state ... | text + '-box'}>
<Suspend>
<p suppressHydrationWarning={true}>
A random number: {Math.random()}
</p>
<p>Autofocus on page load: {autofocusedInputs}</p>
<p>{!this.state.active ? link : 'Thanks!'}</p | // Rerender on mount
this.setState({mounted: true});
}
render() {
const link = (
<a className="link" onClick={this.handleClick}>
Click Here
</a>
);
return (
<div className={this.con | {
"filepath": "fixtures/ssr/src/components/Page.js",
"language": "javascript",
"file_size": 1303,
"cut_index": 524,
"middle_length": 229
} |
ibers from './describeFibers';
// The only place where we use it.
const ReactFiberInstrumentation =
ReactNoop.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.ReactFiberInstrumentation;
function getFiberState(root, workInProgress) {
if (!root) {
return null;
}
return describeFibers(root.current, wo... | ],
currentStep: 0,
show: {
alt: false,
child: true,
sibling: true,
return: false,
fx: false,
},
graphSettings: {
rankdir: 'TB',
trackActive: true,
},
};
}
compon | >);
ReactNoop.flush();
`;
class App extends Component {
constructor(props) {
super(props);
this.state = {
code: localStorage.getItem('fiber-debugger-code') || defaultCode,
isEditing: false,
history: [ | {
"filepath": "fixtures/fiber-debugger/src/App.js",
"language": "javascript",
"file_size": 6966,
"cut_index": 716,
"middle_length": 229
} |
}
function Graph(props) {
const {rankdir, trackActive} = props.settings;
var g = new dagre.graphlib.Graph();
g.setGraph({
width: 1000,
height: 1000,
nodesep: 50,
edgesep: 150,
ranksep: 100,
marginx: 100,
marginy: 100,
rankdir,
});
var edgeLabels = {};
React.Children.forEac... | ipKey] = [];
}
edgeLabels[relationshipKey].push(child);
}
});
Object.keys(edgeLabels).forEach(key => {
const children = edgeLabels[key];
const child = children[0];
g.setEdge(child.props.source, child.props.target, {
l | height: child.props.height,
});
} else if (child.type.isEdge) {
const relationshipKey = child.props.source + ':' + child.props.target;
if (!edgeLabels[relationshipKey]) {
edgeLabels[relationsh | {
"filepath": "fixtures/fiber-debugger/src/Fibers.js",
"language": "javascript",
"file_size": 10605,
"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.
*
*/
'use strict';
const path = require('path');
const rimraf = require('rimraf');
const webpack = require('webpack');
const isProduction = ... | test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
],
},
},
(err, stats) => {
if (err) {
console.error(err.stack || err);
if (err.details) {
console.error(err.details); | -map' : 'cheap-module-source-map',
entry: [path.resolve(__dirname, '../src/index.js')],
output: {
path: path.resolve(__dirname, '../build'),
filename: 'main.js',
},
module: {
rules: [
{
| {
"filepath": "fixtures/ssr2/scripts/build.js",
"language": "javascript",
"file_size": 1316,
"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.
*
*/
import {Suspense, lazy} from 'react';
import {ErrorBoundary} from 'react-error-boundary';
import Html from './Html';
import Spinner from './Spinner';
... | >
<ErrorBoundary FallbackComponent={Error}>
<Content />
</ErrorBoundary>
</Suspense>
</Html>
);
}
function Content() {
return (
<Layout>
<NavBar />
<aside className="sidebar">
<Suspense fallb | ebpackPrefetch: true */));
const Post = lazy(() => import('./Post' /* webpackPrefetch: true */));
export default function App({assets}) {
return (
<Html assets={assets} title="Hello">
<Suspense fallback={<Spinner />} | {
"filepath": "fixtures/ssr2/src/App.js",
"language": "javascript",
"file_size": 1627,
"cut_index": 537,
"middle_length": 229
} |
React from 'react';
import Button from './Button.js';
import Form from './Form.js';
import {like, greet} from './actions.js';
import {getServerState} from './ServerState.js';
const h = React.createElement;
export default async function App() {
const res = await fetch('http://localhost:3001/todos');
const todos... | })
),
h(
'body',
null,
h(
'div',
null,
h('h1', null, getServerState()),
h(
'ul',
null,
todos.map(todo =>
h(
'li',
{
| e: 'viewport',
content: 'width=device-width, initial-scale=1',
}),
h('title', null, 'Flight'),
h('link', {
rel: 'stylesheet',
href: '/src/style.css',
precedence: 'default',
| {
"filepath": "fixtures/flight-esm/src/App.js",
"language": "javascript",
"file_size": 1356,
"cut_index": 524,
"middle_length": 229
} |
from 'react';
import Chrome from './Chrome';
import Page from './Page';
import Page2 from './Page2';
import Theme from './Theme';
function LoadingIndicator() {
let theme = useContext(Theme);
return <div className={theme + '-loading'}>Loading...</div>;
}
function Content() {
let [CurrentPage, switchPage] = useS... | Page 2
</a>
<Suspense fallback={<LoadingIndicator />}>
<CurrentPage />
</Suspense>
</div>
);
}
export default function App({assets}) {
return (
<Chrome title="Hello World" assets={assets}>
<Content />
</C | link" onClick={() => switchPage(() => Page2)}>
| {
"filepath": "fixtures/ssr/src/components/App.js",
"language": "javascript",
"file_size": 881,
"cut_index": 559,
"middle_length": 52
} |
Stream} from 'react-dom/server';
import {Writable} from 'stream';
import App from '../src/components/App';
let assets;
if (process.env.NODE_ENV === 'development') {
// Use the bundle from create-react-app's server in development mode.
assets = {
'main.js': '/static/js/bundle.js',
'main.css': '',
};
} el... | imeout(write, this.delay);
} else {
callback(x);
}
});
};
setTimeout(write, this.delay);
}
_final(callback) {
setTimeout(() => {
this.destination.end(callback);
}, this.delay);
}
}
export defaul | lay = 10;
}
_write(chunk, encoding, callback) {
let o = 0;
const write = () => {
this.destination.write(chunk.slice(o, o + 100), encoding, x => {
o += 100;
if (o < chunk.length) {
setT | {
"filepath": "fixtures/ssr/server/render.js",
"language": "javascript",
"file_size": 2185,
"cut_index": 563,
"middle_length": 229
} |
nt,
} from 'react';
import ReactDOM from 'react-dom/client';
import {
createFromReadableStream,
createFromFetch,
encodeReply,
setServerCallback,
} from 'react-server-dom-parcel/client';
import {rscStream} from 'rsc-html-stream/client';
// Stream in initial RSC payload embedded in the HTML.
let initialRSCPayloa... | t, cb) => setRoot([root, cb ?? null]);
useInsertionEffect(() => cb?.());
return root;
}
// Hydrate initial page content.
startTransition(() => {
ReactDOM.hydrateRoot(document, <Content />);
});
// A very simple router. When we navigate, we'll fetch | t root element in state, along with a callback
// to call once rendering is complete.
let [[root, cb], setRoot] = useState<[ReactElement, (() => void) | null]>([
use(initialRSCPayload),
null,
]);
updateRoot = (roo | {
"filepath": "fixtures/flight-parcel/src/client.tsx",
"language": "tsx",
"file_size": 3165,
"cut_index": 614,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
const babelRegister = require('@babel/register');
babelRegister({
ignore: [/[\\\/](build|server\/server|node_modules)[\\\/]/],
presets: [['react-app', {runti... | .js')) {
// Artificially delay serving JS
// to demonstrate streaming HTML.
setTimeout(next, JS_BUNDLE_DELAY);
} else {
next();
}
});
app.use(compress());
app.get(
'/',
handleErrors(async function (req, res) {
await waitForWebp | nst path = require('path');
const render = require('./render');
const {JS_BUNDLE_DELAY} = require('./delays');
const PORT = process.env.PORT || 4000;
const app = express();
app.use((req, res, next) => {
if (req.url.endsWith(' | {
"filepath": "fixtures/ssr2/server/server.js",
"language": "javascript",
"file_size": 2270,
"cut_index": 563,
"middle_length": 229
} |
entry';
import './client';
import './Todos.css';
import {Dialog} from './Dialog';
import {TodoDetail} from './TodoDetail';
import {TodoCreate} from './TodoCreate';
import {TodoList} from './TodoList';
export async function Todos({id}: {id?: number}) {
return (
<html style={{colorScheme: 'dark light'}}>
<h... | log>
</header>
<main>
<div className="todo-column">
<TodoList id={id} />
</div>
{id != null ? <TodoDetail key={id} id={id} /> : <p>Select a todo</p>}
</main>
</body>
</html>
);
} | </Dia | {
"filepath": "fixtures/flight-parcel/src/Todos.tsx",
"language": "tsx",
"file_size": 795,
"cut_index": 524,
"middle_length": 14
} |
Suspense, startTransition} from 'react';
import Theme, {ThemeToggleButton} from './Theme';
import './Chrome.css';
import LargeContent from './LargeContent';
export default class Chrome extends Component {
state = {theme: 'light'};
render() {
const assets = this.props.assets;
return (
<html lang="... | __html: `<b>Enable JavaScript to run this app.</b>`,
}}
/>
<Suspense fallback="Loading...">
<Theme.Provider value={this.state.theme}>
<div>
<ThemeToggleButton
| >
<link rel="stylesheet" href={assets['main.css']} />
<title>{this.props.title}</title>
</head>
<body className={this.state.theme}>
<noscript
dangerouslySetInnerHTML={{
| {
"filepath": "fixtures/ssr/src/components/Chrome.js",
"language": "javascript",
"file_size": 1536,
"cut_index": 537,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import * as React from 'react';
// import {renderToString} from 'react-dom/server';
import {renderToPipeableStream} from 'react-dom/server';
import App from '../src/App';
impor... | / <DataProvider data={data}>
// <App assets={assets} />
// </DataProvider>,
// )
// );
// The new wiring is a bit more involved.
res.socket.on('error', error => {
console.error('Fatal', error);
});
let didError = false; | in.css': '/main.css',
};
module.exports = function render(url, res) {
const data = createServerData();
// This is how you would wire it up previously:
//
// res.send(
// '<!DOCTYPE html>' +
// renderToString(
/ | {
"filepath": "fixtures/ssr2/server/render.js",
"language": "javascript",
"file_size": 2588,
"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.
*
*/
import * as React from 'react';
import {renderToString} from 'react-dom/server';
import App from '../src/App';
import {API_DELAY, ABORT_DELAY} from './delays';
... | rl, res) {
let payload =
'<!DOCTYPE html>' +
renderToString(<App assets={assets} />) +
'<script src="/main.js" async=""></script>';
let arr = textEncoder.encode(payload);
let buf = Buffer.from(arr);
res.statusCode = 200;
res.setHeade | w TextEncoder();
module.exports = function render(u | {
"filepath": "fixtures/fizz/server/render-to-string.js",
"language": "javascript",
"file_size": 907,
"cut_index": 547,
"middle_length": 52
} |
ct = window.React;
class Header extends React.Component {
constructor(props, context) {
super(props, context);
const query = parse(window.location.search);
const version = query.version || 'local';
const production = query.production || false;
const versions = [version];
this.state = {versio... | delete query.production;
}
window.location.search = stringify(query);
}
handleFixtureChange(event) {
window.location.pathname = event.target.value;
}
render() {
return (
<header className="header">
<div className= | uery.version;
}
window.location.search = stringify(query);
}
handleProductionChange(event) {
const query = parse(window.location.search);
query.production = event.target.checked;
if (!query.production) {
| {
"filepath": "fixtures/dom/src/components/Header.js",
"language": "javascript",
"file_size": 4211,
"cut_index": 614,
"middle_length": 229
} |
= window.React;
const ReactDOM = window.ReactDOM;
class IframePortal extends React.Component {
iframeRef = null;
handleRef = ref => {
if (ref !== this.iframeRef) {
this.iframeRef = ref;
if (ref) {
if (ref.contentDocument && this.props.head) {
ref.contentDocument.head.innerHTML = ... | <div>
<iframe
title="Iframe portal"
style={{border: 'none', height: this.props.height}}
ref={this.handleRef}
/>
{portal}
</div>
);
}
}
class IframeSubtree extends React.Component {
warned |
const ref = this.iframeRef;
let portal = null;
if (ref && ref.contentDocument) {
portal = ReactDOM.createPortal(
this.props.children,
ref.contentDocument.body
);
}
return (
| {
"filepath": "fixtures/dom/src/components/Iframe.js",
"language": "javascript",
"file_size": 1313,
"cut_index": 524,
"middle_length": 229
} |
ssueList from './IssueList';
import {parse} from 'query-string';
import {semverString} from './propTypes';
const React = window.React;
const propTypes = {
children: PropTypes.node.isRequired,
title: PropTypes.node.isRequired,
resolvedIn: semverString,
introducedIn: semverString,
resolvedBy: PropTypes.string... | dren,
} = this.props;
let {complete} = this.state;
const {version} = parse(window.location.search);
const isTestFixed =
!version || !resolvedIn || semver.gte(version, resolvedIn);
complete = !isTestFixed || complete;
retur | s.setState({
complete: e.target.checked,
});
};
render() {
const {
title,
description,
introducedIn,
resolvedIn,
resolvedBy,
affectedBrowsers,
relatedIssues,
chil | {
"filepath": "fixtures/dom/src/components/TestCase.js",
"language": "javascript",
"file_size": 3748,
"cut_index": 614,
"middle_length": 229
} |
s React.Component {
constructor(props, context) {
super(props, context);
const version = props.version || 'local';
const versions = [version];
this.state = {versions};
}
componentWillMount() {
getVersionTags().then(tags => {
let versions = tags.map(tag => tag.name.slice(1));
versi... | return (
<select id={id} name={name} value={version} onChange={this.onChange}>
{versions.map(version => (
<option key={version} value={version}>
{version}
</option>
))}
</select>
);
}
}
| } = this.props;
const {versions} = this.state;
| {
"filepath": "fixtures/dom/src/components/VersionPicker.js",
"language": "javascript",
"file_size": 945,
"cut_index": 606,
"middle_length": 52
} |
r">
<h1>DOM Test Fixtures</h1>
<p>
Use this site to test browser quirks and other behavior that can not be
captured through unit tests.
</p>
<section>
<h2>Tested Browsers</h2>
<table>
<thead>
<tr>
<th>Browser</th>
... | <a href="https://www.mozilla.org/en-US/firefox/organizations/">
ESR<sup>β </sup>
</a>
, Latest
</td>
</tr>
<tr>
<td>Internet Explorer</td>
< | </td>
</tr>
<tr>
<td>Chrome - Android</td>
<td>Latest</td>
</tr>
<tr>
<td>Firefox Desktop</td>
<td>
| {
"filepath": "fixtures/dom/src/components/fixtures/home.js",
"language": "javascript",
"file_size": 3722,
"cut_index": 614,
"middle_length": 229
} |
React = window.React;
const fixturePath = window.location.pathname;
/**
* A simple routing component that renders the appropriate
* fixture based on the location pathname.
*/
class FixturesPage extends React.Component {
static defaultProps = {
fixturePath: fixturePath === '/' ? '/home' : fixturePath,
};
... | Loading: false});
}
}
render() {
const {Fixture, error, isLoading} = this.state;
if (isLoading) {
return null;
}
if (error) {
return <FixtureError error={error} />;
}
return <Fixture />;
}
}
function Fixtu | try {
const module = await import(`.${fixturePath}`);
this.setState({Fixture: module.default});
} catch (error) {
console.error(error);
this.setState({error});
} finally {
this.setState({is | {
"filepath": "fixtures/dom/src/components/fixtures/index.js",
"language": "javascript",
"file_size": 1165,
"cut_index": 518,
"middle_length": 229
} |
../TestCase';
import Fixture from '../../Fixture';
import CompareDocumentPositionFragmentContainer from './CompareDocumentPositionFragmentContainer';
const React = window.React;
export default function CompareDocumentPositionCase() {
return (
<TestCase title="compareDocumentPosition">
<TestCase.Steps>
... | ase.ExpectedResult>
<Fixture>
<Fixture.Controls>
<CompareDocumentPositionFragmentContainer>
<div
style={{
padding: '10px',
backgroundColor: 'lightblue',
borde | relative to other elements in the DOM. The "Before Element" should be
PRECEDING the fragment, and the "After Element" should be FOLLOWING.
Elements inside the fragment should be CONTAINED_BY.
</TestC | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/CompareDocumentPositionCase.js",
"language": "javascript",
"file_size": 1761,
"cut_index": 537,
"middle_length": 229
} |
EMENTATION_SPECIFIC: 0x20,
};
function getPositionDescription(bitmask) {
const flags = [];
if (bitmask & POSITION_FLAGS.DISCONNECTED) flags.push('DISCONNECTED');
if (bitmask & POSITION_FLAGS.PRECEDING) flags.push('PRECEDING');
if (bitmask & POSITION_FLAGS.FOLLOWING) flags.push('FOLLOWING');
if (bitmask & POS... | marginBottom: '8px',
backgroundColor: '#f8f9fa',
borderLeft: `4px solid ${color}`,
borderRadius: '4px',
}}>
<div
style={{
fontWeight: 'bold',
marginBottom: '6px',
color: '#333',
| MPLEMENTATION_SPECIFIC');
return flags.length > 0 ? flags.join(' | ') : 'SAME';
}
function ResultRow({label, result, color}) {
if (!result) return null;
return (
<div
style={{
padding: '10px 14px',
| {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/CompareDocumentPositionFragmentContainer.js",
"language": "javascript",
"file_size": 7185,
"cut_index": 716,
"middle_length": 229
} |
t;
const {Fragment, useRef, useState} = React;
function WrapperComponent(props) {
return props.children;
}
const initialState = {
child: false,
parent: false,
grandparent: false,
};
export default function EventListenerCase() {
const fragmentRef = useRef(null);
const [clickedState, setClickedState] = use... | as regular click handlers, you can click each one to observe
the status changing through standard bubbling.
</li>
<li>Clear the clicked state</li>
<li>
Click the "Dispatch click event" button to dispatch a click | ckedState(prev => ({...prev, [id]: true}));
}
function fragmentClickHandler(e) {
setFragmentEventFired(true);
}
return (
<TestCase title="Event Dispatch">
<TestCase.Steps>
<li>
Each box h | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/EventDispatchCase.js",
"language": "javascript",
"file_size": 4955,
"cut_index": 614,
"middle_length": 229
} |
FragmentContainer({children}) {
const fragmentRef = useRef(null);
const [eventLog, setEventLog] = useState([]);
const [listenerAdded, setListenerAdded] = useState(false);
const [bubblesState, setBubblesState] = useState(true);
const logEvent = message => {
setEventLog(prev => [...prev, message]);
};
... | ogEvent('Removed click listener from fragment');
};
const dispatchClick = () => {
fragmentRef.current.dispatchEvent(
new MouseEvent('click', {bubbles: bubblesState})
);
logEvent(`Dispatched click event (bubbles: ${bubblesState})`);
| ;
setListenerAdded(true);
logEvent('Added click listener to fragment');
};
const removeListener = () => {
fragmentRef.current.removeEventListener('click', fragmentClickHandler);
setListenerAdded(false);
l | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/EventFragmentContainer.js",
"language": "javascript",
"file_size": 3187,
"cut_index": 614,
"middle_length": 229
} |
re from '../../Fixture';
import EventFragmentContainer from './EventFragmentContainer';
const React = window.React;
const {useState} = React;
function WrapperComponent(props) {
return props.children;
}
export default function EventListenerCase() {
const [extraChildCount, setExtraChildCount] = useState(0);
ret... | vent listener" and dispatch again to see no event fires
</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
<p>
Fragment refs can manage event listeners on the first level of host
children. The event log shows | ck "Dispatch click event" to dispatch a click event</li>
<li>Observe the event log showing the event fired</li>
<li>Add a new child, dispatch again to see it still works</li>
<li>
Click "Remove e | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/EventListenerCase.js",
"language": "javascript",
"file_size": 2362,
"cut_index": 563,
"middle_length": 229
} |
re from '../../Fixture';
const React = window.React;
const {Fragment, useRef} = React;
export default function FocusCase() {
const fragmentRef = useRef(null);
return (
<TestCase title="Focus Management">
<TestCase.Steps>
<li>Click to focus the first child</li>
<li>Click to focus the la... | Blur will call blur on the document, only if one of the children
within the fragment is the active element.
</p>
</TestCase.ExpectedResult>
<Fixture>
<Fixture.Controls>
<button onClick={() => fragmentRe | focusable child within the
fragment, skipping any unfocusable children.
</p>
<p>
The focusLast method is the reverse, focusing the last focusable
child.
</p>
<p>
| {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/FocusCase.js",
"language": "javascript",
"file_size": 2032,
"cut_index": 563,
"middle_length": 229
} |
../TestCase';
import Fixture from '../../Fixture';
import PrintRectsFragmentContainer from './PrintRectsFragmentContainer';
const React = window.React;
export default function GetClientRectsCase() {
return (
<TestCase title="getClientRects">
<TestCase.Steps>
<li>
Click the "Print Rects" ... | width: '300px',
height: '250px',
backgroundColor: 'lightblue',
fontSize: 20,
border: '1px solid black',
marginBottom: '10px',
}}>
Lorem ipsum dolor | urn a list of a
DOMRectList for each child node.
</TestCase.ExpectedResult>
<Fixture>
<Fixture.Controls>
<PrintRectsFragmentContainer>
<span
style={{
| {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/GetClientRectsCase.js",
"language": "javascript",
"file_size": 1708,
"cut_index": 537,
"middle_length": 229
} |
, useState} = React;
export default function GetRootNodeFragmentContainer({children}) {
const fragmentRef = useRef(null);
const [rootNodeInfo, setRootNodeInfo] = useState(null);
const getRootNodeInfo = () => {
const rootNode = fragmentRef.current.getRootNode();
setRootNodeInfo({
nodeName: rootNode... | >
<div style={{marginBottom: '16px'}}>
<button
onClick={getRootNodeInfo}
style={{
padding: '8px 16px',
fontSize: '14px',
fontWeight: 'bold',
cursor: 'pointer',
}}>
| pe => {
const types = {
1: 'ELEMENT_NODE',
3: 'TEXT_NODE',
9: 'DOCUMENT_NODE',
11: 'DOCUMENT_FRAGMENT_NODE',
};
return types[nodeType] || `UNKNOWN (${nodeType})`;
};
return (
<Fragment | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/GetRootNodeFragmentContainer.js",
"language": "javascript",
"file_size": 2136,
"cut_index": 563,
"middle_length": 229
} |
t;
const {Fragment, useEffect, useRef, useState} = React;
function WrapperComponent(props) {
return props.children;
}
function ObservedChild({id}) {
return (
<div id={id} className="observable-card">
{id}
</div>
);
}
const initialItems = [
['A', false],
['B', false],
['C', false],
];
expor... | tems(prev => {
const newItems = [...prev];
entries.forEach(entry => {
const index = newItems.findIndex(
([id]) => id === entry.target.id
);
newItems[index] = [entry.target.id | = items.some(([, onScreen]) => onScreen);
const observerRef = useRef(null);
useEffect(() => {
if (observerRef.current === null) {
observerRef.current = new IntersectionObserver(
entries => {
setI | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/IntersectionObserverCase.js",
"language": "javascript",
"file_size": 4410,
"cut_index": 614,
"middle_length": 229
} |
'#3498db',
'#2ecc71',
'#9b59b6',
'#f39c12',
'#1abc9c',
];
export default function PrintRectsFragmentContainer({children}) {
const fragmentRef = useRef(null);
const [rects, setRects] = useState([]);
const getRects = () => {
const rectsResult = fragmentRef.current.getClientRects();
setRects(Arr... | th > 0 && (
<span style={{marginLeft: '12px', color: '#666'}}>
Found {rects.length} rect{rects.length !== 1 ? 's' : ''}
</span>
)}
</div>
<div style={{display: 'flex', gap: '20px', marginBottom: '16px'}} | {getRects}
style={{
padding: '8px 16px',
fontSize: '14px',
fontWeight: 'bold',
cursor: 'pointer',
}}>
Print Rects
</button>
{rects.leng | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/PrintRectsFragmentContainer.js",
"language": "javascript",
"file_size": 3547,
"cut_index": 614,
"middle_length": 229
} |
../TestCase';
import Fixture from '../../Fixture';
const React = window.React;
const {Fragment, useEffect, useRef, useState} = React;
export default function ResizeObserverCase() {
const fragmentRef = useRef(null);
const [width, setWidth] = useState([0, 0, 0]);
useEffect(() => {
const resizeObserver = new ... | const lastFragmentRefValue = fragmentRef.current;
return () => {
lastFragmentRefValue.unobserveUsing(resizeObserver);
};
}, []);
return (
<TestCase title="Resize Observer">
<TestCase.Steps>
<li>Resize the viewport width | = parseInt(entry.target.id, 10);
newWidth[index] = Math.round(entry.contentRect.width);
});
return newWidth;
});
}
});
fragmentRef.current.observeUsing(resizeObserver);
| {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/ResizeObserverCase.js",
"language": "javascript",
"file_size": 1923,
"cut_index": 537,
"middle_length": 229
} |
imple';
import ScrollIntoViewTargetElement from './ScrollIntoViewTargetElement';
const React = window.React;
const {Fragment, useRef, useState, useEffect} = React;
const ReactDOM = window.ReactDOM;
function Controls({
alignToTop,
setAlignToTop,
scrollVertical,
exampleType,
setExampleType,
}) {
return (
... | div>
<label>
Align to Top:
<input
type="checkbox"
checked={alignToTop}
onChange={e => setAlignToTop(e.target.checked)}
/>
</label>
</div>
<div>
<button on | ion>
<option value="multiple">Multiple Scroll Containers</option>
<option value="horizontal">Horizontal</option>
<option value="empty">Empty Fragment</option>
</select>
</label>
< | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/ScrollIntoViewCase.js",
"language": "javascript",
"file_size": 5768,
"cut_index": 716,
"middle_length": 229
} |
lIntoViewTargetElement from './ScrollIntoViewTargetElement';
const React = window.React;
const {Fragment, useRef, useState, useEffect} = React;
const ReactDOM = window.ReactDOM;
export default function ScrollIntoViewCaseComplex({
caseInViewport,
scrollContainerRef,
}) {
const [didMount, setDidMount] = useState(... | Fixed header
</div>
)}
{didMount &&
ReactDOM.createPortal(
<ScrollIntoViewTargetElement color="red" id="FROM_PORTAL" />,
scrollContainerRef.current
)}
<ScrollIntoViewTargetElement color= | => {
if (!didMount) {
setDidMount(true);
}
}, []);
return (
<Fragment>
{caseInViewport && (
<div
style={{position: 'fixed', top: 0, backgroundColor: 'red'}}
id="header">
| {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/ScrollIntoViewCaseComplex.js",
"language": "javascript",
"file_size": 1417,
"cut_index": 524,
"middle_length": 229
} |
eact;
const {Fragment, useRef, useState} = React;
function GetClientRectsTextOnly() {
return (
<TestCase title="getClientRects - Text Only">
<TestCase.Steps>
<li>Click the "Print Rects" button</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The fragment contains only text nodes... | tRectsMixed() {
return (
<TestCase title="getClientRects - Mixed Content">
<TestCase.Steps>
<li>Click the "Print Rects" button</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The fragment contains both text nodes an | tRectsFragmentContainer>
This is text content inside a fragment with no element children.
</PrintRectsFragmentContainer>
</Fixture.Controls>
</Fixture>
</TestCase>
);
}
function GetClien | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/TextNodesCase.js",
"language": "javascript",
"file_size": 15660,
"cut_index": 921,
"middle_length": 229
} |
;
import EventDispatchCase from './EventDispatchCase';
import IntersectionObserverCase from './IntersectionObserverCase';
import ResizeObserverCase from './ResizeObserverCase';
import FocusCase from './FocusCase';
import GetClientRectsCase from './GetClientRectsCase';
import CompareDocumentPositionCase from './CompareD... | ">
<EventListenerCase />
<EventDispatchCase />
<IntersectionObserverCase />
<ResizeObserverCase />
<FocusCase />
<GetClientRectsCase />
<CompareDocumentPositionCase />
<ScrollIntoViewCase />
<TextNodesC | () {
return (
<FixtureSet title="Fragment Refs | {
"filepath": "fixtures/dom/src/components/fixtures/fragment-refs/index.js",
"language": "javascript",
"file_size": 946,
"cut_index": 606,
"middle_length": 52
} |
re from '../../Fixture';
const React = window.React;
class InputPlaceholderFixture extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
placeholder: 'A placeholder',
changeCount: 0,
};
}
handleChange = () => {
this.setState(({changeCount}) =>... | (
<Fixture>
<input
type="text"
placeholder={placeholder}
onChange={this.handleChange}
/>{' '}
<button onClick={this.handleGeneratePlaceholder}>
Change placeholder
</button>
| }`,
});
};
handleReset = () => {
this.setState({
changeCount: 0,
});
};
render() {
const {placeholder, changeCount} = this.state;
const color = changeCount === 0 ? 'green' : 'red';
return | {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/InputPlaceholderFixture.js",
"language": "javascript",
"file_size": 1276,
"cut_index": 524,
"middle_length": 229
} |
import Fixture from '../../Fixture';
const React = window.React;
class RadioClickFixture extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
changeCount: 0,
};
}
handleChange = () => {
this.setState(({changeCount}) => {
return {
chan... | p style={{color}}>
<code>onChange</code>
{' calls: '}
<strong>{changeCount}</strong>
</p>
<button onClick={this.handleReset}>Reset count</button>
</Fixture>
);
}
}
export default RadioClickFixture; | lor = changeCount === 0 ? 'green' : 'red';
return (
<Fixture>
<label>
<input defaultChecked type="radio" onChange={this.handleChange} />
Test case radio input
</label>{' '}
< | {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/RadioClickFixture.js",
"language": "javascript",
"file_size": 998,
"cut_index": 512,
"middle_length": 229
} |
Fixture from '../../Fixture';
const React = window.React;
class RadioGroupFixture extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
changeCount: 0,
};
}
handleChange = () => {
this.setState(({changeCount}) => {
return {
changeCoun... | Radio 1
</label>
<label>
<input name="foo" type="radio" onChange={this.handleChange} />
Radio 2
</label>{' '}
<p style={{color}}>
<code>onChange</code>
{' calls: '}
| changeCount >= 3 ? 'green' : 'red';
return (
<Fixture>
<label>
<input
defaultChecked
name="foo"
type="radio"
onChange={this.handleChange}
/>
| {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/RadioGroupFixture.js",
"language": "javascript",
"file_size": 1176,
"cut_index": 518,
"middle_length": 229
} |
eFixture extends React.Component {
state = {
updated: false,
};
onClick = () => {
this.setState(state => {
return {updated: !state.updated};
});
};
render() {
const {updated} = this.state;
const radioName = updated ? 'firstName' : 'secondName';
return (
<div>
<label... | radio"
name={radioName}
onChange={noop}
checked={updated === false}
/>
Second Radio
</label>
<div>
<button type="button" onClick={this.onClick}>
Toggle
|
<label>
<input
type=" | {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/RadioNameChangeFixture.js",
"language": "javascript",
"file_size": 982,
"cut_index": 582,
"middle_length": 52
} |
./Fixture';
const React = window.React;
class RangeKeyboardFixture extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
keydownCount: 0,
changeCount: 0,
};
}
componentDidMount() {
this.input.addEventListener('keydown', this.handleKeydown, fal... | ownCount}) => {
return {
keydownCount: keydownCount + 1,
};
});
};
handleReset = () => {
this.setState({
keydownCount: 0,
changeCount: 0,
});
};
render() {
const {keydownCount, changeCount} = this.s | {
changeCount: changeCount + 1,
};
});
};
handleKeydown = e => {
// only interesting in arrow key events
if ([37, 38, 39, 40].indexOf(e.keyCode) < 0) {
return;
}
this.setState(({keyd | {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/RangeKeyboardFixture.js",
"language": "javascript",
"file_size": 1754,
"cut_index": 537,
"middle_length": 229
} |
Fixture from './RangeKeyboardFixture';
import RadioClickFixture from './RadioClickFixture';
import RadioGroupFixture from './RadioGroupFixture';
import RadioNameChangeFixture from './RadioNameChangeFixture';
import InputPlaceholderFixture from './InputPlaceholderFixture';
const React = window.React;
class InputChangeE... | </li>
<li>change value via the keyboard arrow keys</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The <code>onKeyDown</code> call count should be equal to the{' '}
<code>onChange</code> call count. | <TestCase
title="Range keyboard changes"
description={`
Range inputs should fire onChange events for keyboard events
`}>
<TestCase.Steps>
<li>Focus range input | {
"filepath": "fixtures/dom/src/components/fixtures/input-change-events/index.js",
"language": "javascript",
"file_size": 3746,
"cut_index": 614,
"middle_length": 229
} |
, ms)
);
}
return null;
}
let suspendyTreeIdCounter = 0;
class SuspendyTreeChild extends React.Component {
id = suspendyTreeIdCounter++;
state = {
step: 1,
isHidden: false,
};
increment = () => this.setState(s => ({step: s.step + 1}));
componentDidMount() {
document.addEventListener('key... | {this.props.children}
</div>
</Suspense>
<button onClick={this.increment}>Hide</button>
</>
);
}
}
class SuspendyTree extends React.Component {
parentContainer = React.createRef(null);
container = React.cr | ') {
this.increment();
}
};
render() {
return (
<>
<Suspense fallback={<div>(display: none)</div>}>
<div>
<AsyncStep text={`${this.state.step} + ${this.id}`} ms={500} />
| {
"filepath": "fixtures/dom/src/components/fixtures/suspense/index.js",
"language": "javascript",
"file_size": 10351,
"cut_index": 921,
"middle_length": 229
} |
Set from '../../FixtureSet';
import TestCase from '../../TestCase';
const React = window.React;
export default class TextAreaFixtures extends React.Component {
state = {value: ''};
onChange = event => {
this.setState({value: event.target.value});
};
render() {
return (
<FixtureSet title="Textare... | /fieldset>
<fieldset>
<legend>Uncontrolled</legend>
<textarea defaultValue="" />
</fieldset>
</form>
<div className="container">
<h4>Controlled Output:</h4>
| ped in">
<div>
<form className="container">
<fieldset>
<legend>Controlled</legend>
<textarea value={this.state.value} onChange={this.onChange} />
< | {
"filepath": "fixtures/dom/src/components/fixtures/textareas/index.js",
"language": "javascript",
"file_size": 2762,
"cut_index": 563,
"middle_length": 229
} |
esTestCase extends React.Component {
state = {value: 'a@fb.com'};
onChange = event => {
this.setState({value: event.target.value});
};
render() {
return (
<Fixture>
<div>{this.props.children}</div>
<div className="control-box">
<fieldset>
<legend>Controlled</... | .state.value)}
</span>
</fieldset>
<fieldset>
<legend>Uncontrolled</legend>
<input type="email" defaultValue="" />
</fieldset>
</div>
</Fixture>
);
}
}
export default E | {' '}
Value: {JSON.stringify(this | {
"filepath": "fixtures/dom/src/components/fixtures/email-inputs/EmailDisabledAttributesTestCase.js",
"language": "javascript",
"file_size": 946,
"cut_index": 606,
"middle_length": 52
} |
Fixture from '../../Fixture';
const React = window.React;
class EmailAttributesTestCase extends React.Component {
state = {value: 'a@fb.com'};
onChange = event => {
this.setState({value: event.target.value});
};
render() {
return (
<Fixture>
<div>{this.props.children}</div>
<di... | te.value)}
</span>
</fieldset>
<fieldset>
<legend>Uncontrolled</legend>
<input
type="email"
defaultValue=""
pattern=".+@fb.com"
maxlength={17}
| {17}
multiple={true}
value={this.state.value}
onChange={this.onChange}
/>
<span className="hint">
{' '}
Value: {JSON.stringify(this.sta | {
"filepath": "fixtures/dom/src/components/fixtures/email-inputs/EmailEnabledAttributesTestCase.js",
"language": "javascript",
"file_size": 1156,
"cut_index": 518,
"middle_length": 229
} |
extends React.Component {
state = {value: ''};
onChange = event => {
this.setState({value: event.target.value});
};
render() {
return (
<Fixture>
<div>{this.props.children}</div>
<div className="control-box">
<fieldset>
<legend>Controlled</legend>
... | </span>
</fieldset>
<fieldset>
<legend>Uncontrolled</legend>
<input type="email" defaultValue="" />
</fieldset>
</div>
</Fixture>
);
}
}
export default JumpingCursorTestCa | Value: {JSON.stringify(this.state.value)}
| {
"filepath": "fixtures/dom/src/components/fixtures/email-inputs/JumpingCursorTestCase.js",
"language": "javascript",
"file_size": 918,
"cut_index": 606,
"middle_length": 52
} |
ent, commentSource}) {
const currentUserID = comment.viewer.id;
const environment = RelayEnvironment.forUser(currentUserID);
const commentID = nullthrows(comment.id);
useEffect(() => {
const subscription = SubscriptionCounter.subscribeOnce(
`StoreSubscription_${commentID}`,
() =>
StoreSu... | }
function UseEffectWithEmptyDependencies() {
useEffect(() => {
const local = {};
console.log(local);
}, []);
}
// OK because `props` wasn't defined.
function ComponentWithNoPropsDefined() {
useEffect(() => {
console.log(props.foo);
}, | cription.dispose();
}, [commentID, commentSource, currentUserID, environment]);
}
// Valid because no dependencies
function UseEffectWithNoDependencies() {
const local = {};
useEffect(() => {
console.log(local);
});
| {
"filepath": "fixtures/eslint-v9/index.js",
"language": "javascript",
"file_size": 4633,
"cut_index": 614,
"middle_length": 229
} |
ileSync,
existsSync,
mkdirSync,
readFileSync,
rmdirSync,
} = require('fs');
const {join} = require('path');
const http = require('http');
const DEPENDENCIES = [
['scheduler/umd/scheduler.development.js', 'scheduler.js'],
['react/umd/react.development.js', 'react.js'],
['react-dom/umd/react-dom.developmen... | toPath = join(__dirname, DEPENDENCIES_DIRECTORY, to);
console.log(`Copying ${fromPath} => ${toPath}`);
copyFileSync(fromPath, toPath);
});
}
function initServer() {
const host = 'localhost';
const port = 8000;
const requestListener = fun | IES_DIRECTORY)) {
rmdirSync(DEPENDENCIES_DIRECTORY, {recursive: true});
}
mkdirSync(DEPENDENCIES_DIRECTORY);
DEPENDENCIES.forEach(([from, to]) => {
const fromPath = join(__dirname, BUILD_DIRECTORY, from);
const | {
"filepath": "fixtures/devtools/scheduling-profiler/run.js",
"language": "javascript",
"file_size": 2126,
"cut_index": 563,
"middle_length": 229
} |
dled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
// Ensure environment variables are read.
require('../config/env');
const path = requ... | tils/printHostingInstructions');
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
const printBuildError = require('react-dev-utils/printBuildError');
const measureFileSizesBeforeBuild =
FileSizeReporter.measureFileSizesBeforeBuild;
| e('../config/paths');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
const printHostingInstructions = require('react-dev-u | {
"filepath": "fixtures/flight/scripts/build.js",
"language": "javascript",
"file_size": 6606,
"cut_index": 716,
"middle_length": 229
} |
dable} from 'stream';
import {ClientContext, ClientReadContext} from './ClientContext.js';
import Container from './Container.js';
import {Counter} from './Counter.js';
import {Counter as Counter2} from './Counter2.js';
import AsyncModule from './cjs/Counter3.js';
const Counter3 = await(AsyncModule);
import ShowMore ... | /ServerState.js';
import {sdkMethod} from './library.js';
const promisedText = new Promise(resolve =>
setTimeout(() => resolve('deferred text'), 50)
);
function Foo({children}) {
return <div>{children}</div>;
}
async function delayedError(text, ms) | te.js';
import {Note} from './cjs/Note.js';
import {GenerateImage} from './GenerateImage.js';
import LargeContent from './LargeContent.js';
import {like, greet, increment} from './actions.js';
import {getServerState} from '. | {
"filepath": "fixtures/flight/src/App.js",
"language": "javascript",
"file_size": 6437,
"cut_index": 716,
"middle_length": 229
} |
'use client';
import * as React from 'react';
import Container from './Container.js';
export function Navigate() {
/** Repro for https://issues.chromium.org/u/1/issues/419746417 */
function provokeChromeCrash() {
React.startTransition(async () => {
console.log('Default transition triggered');
awa... | console.log('Default transition completed');
resolve();
}, 1000);
});
});
}
return (
<Container>
<h2>Navigation fixture</h2>
<button onClick={provokeChromeCrash}>Provoke Chrome Crash (fixed)</button>
</C | `
);
},
// This needs to happen before React's default transition indicator
// is displayed but after it's scheduled.
100 + -50
);
setTimeout(() => {
| {
"filepath": "fixtures/flight/src/Navigate.js",
"language": "javascript",
"file_size": 1014,
"cut_index": 512,
"middle_length": 229
} |
/core';
const babelOptions = {
babelrc: false,
ignore: [/\/(build|node_modules)\//],
plugins: [
'@babel/plugin-syntax-import-meta',
['@babel/plugin-transform-react-jsx', {runtime: 'automatic'}],
],
};
export async function load(url, context, defaultLoad) {
const {format} = context;
const result = ... | };
}
return {source: newResult.code, format: 'module'};
}
return defaultLoad(url, context, defaultLoad);
}
async function babelTransformSource(source, context, defaultTransformSource) {
const {format} = context;
if (format === 'module') { | (result.source, opt);
if (!newResult) {
if (typeof result.source === 'string') {
return result;
}
return {
source: Buffer.from(result.source).toString('utf8'),
format: 'module',
| {
"filepath": "fixtures/flight/loader/global.js",
"language": "javascript",
"file_size": 1546,
"cut_index": 537,
"middle_length": 229
} |
env.
process.env.BABEL_ENV = process.env.NODE_ENV;
const babelRegister = require('@babel/register');
babelRegister({
babelrc: false,
ignore: [
/\/(build|node_modules)\//,
function (file) {
if ((path.dirname(file) + '/').startsWith(__dirname + '/')) {
// Ignore everything in this folder
... | e('http');
const React = require('react');
const {renderToPipeableStream} = require('react-dom/server');
const {createFromNodeStream} = require('react-server-dom-unbundled/client');
const {PassThrough} = require('stream');
const app = express();
app.use | Ensure environment variables are read.
require('../config/env');
const fs = require('fs').promises;
const compress = require('compression');
const chalk = require('chalk');
const express = require('express');
const http = requir | {
"filepath": "fixtures/flight/server/global.js",
"language": "javascript",
"file_size": 8609,
"cut_index": 716,
"middle_length": 229
} |
);
// Make sure that including paths.js after env.js will read .env variables.
delete require.cache[require.resolve('./paths')];
const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
throw new Error(
'The NODE_ENV environment variable is required but was not specified.'
);
}
// https://github.com/bkeepers/... | using silent
// if this file is missing. dotenv will never modify any environment variables
// that have already been set. Variable expansion is supported in .env files.
// https://github.com/motdotla/dotenv
// https://github.com/motdotla/dotenv-expand
d | o produce the same
// results for everyone
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
`${paths.dotenv}.${NODE_ENV}`,
paths.dotenv,
].filter(Boolean);
// Load environment variables from .env* files. Suppress warnings | {
"filepath": "fixtures/flight/config/env.js",
"language": "javascript",
"file_size": 4205,
"cut_index": 614,
"middle_length": 229
} |
fs = require('fs');
const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(app... | .js. We have to know the root.
const publicUrlOrPath = getPublicUrlOrPath(
process.env.NODE_ENV === 'development',
require(resolveApp('package.json')).homepage,
process.env.PUBLIC_URL
);
const buildPath = process.env.BUILD_PATH || 'build';
const mo | cript> hrefs into HTML even in
// single-page apps that may serve index.html for nested URLs like /todos/42.
// We can't use a relative path in HTML because we don't want to load something
// like /todos/42/static/js/bundle.7289d | {
"filepath": "fixtures/flight/config/paths.js",
"language": "javascript",
"file_size": 2354,
"cut_index": 563,
"middle_length": 229
} |
lyfills';
import loadReact, {isLocal} from './react-loader';
if (isLocal()) {
Promise.all([
import('react'),
import('react-dom'),
import('react-dom/client'),
])
.then(([React, ReactDOM, ReactDOMClient]) => {
if (
React === undefined ||
ReactDOM === undefined ||
ReactDO... | window.React.createElement(App.default)
);
});
} else {
loadReact()
.then(() => import('./components/App'))
.then(App => {
const {React, ReactDOM} = window;
if (
typeof window.ReactDOMClient !== 'undefined' &&
| window.ReactDOM = ReactDOM;
window.ReactDOMClient = ReactDOMClient;
})
.then(() => import('./components/App'))
.then(App => {
window.ReactDOMClient.createRoot(document.getElementById('root')).render(
| {
"filepath": "fixtures/dom/src/index.js",
"language": "javascript",
"file_size": 1434,
"cut_index": 524,
"middle_length": 229
} |
function parseQuery(qstr) {
var query = {};
var a = qstr.slice(1).split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
return query;
}
function loadScript(src) {
let firstScript = document.getElementsByTagNa... | firstScript = document.getElementsByTagName('script')[0];
let imports = '';
SymbolSrcPairs.map(([symbol, src]) => {
imports += `import ${symbol} from "${src}";\n`;
imports += `window.${symbol} = ${symbol};\n`;
});
return new Promise((res | ptNode.onload = () => resolve();
scriptNode.onerror = () => reject(new Error(`failed to load: ${src}`));
firstScript.parentNode.insertBefore(scriptNode, firstScript);
});
}
function loadModules(SymbolSrcPairs) {
let | {
"filepath": "fixtures/dom/src/react-loader.js",
"language": "javascript",
"file_size": 5292,
"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.
*
* @emails react-core
*/
let React;
let DOMAct;
let TestRenderer;
let TestAct;
global.__DEV__ = process.env.NODE_ENV !== 'production';
describe('unmocked scheduler', () => {
b... | }
// in legacy mode, this tests whether an act only flushes its own effects
TestAct(() => {
DOMAct(() => {
TestRenderer.create(<Effecty />);
});
expect(log).toEqual([]);
});
expect(log).toEqual(['called']);
lo | 'flushes work only outside the outermost act() corresponding to its own renderer', () => {
let log = [];
function Effecty() {
React.useEffect(() => {
log.push('called');
}, []);
return null;
| {
"filepath": "fixtures/dom/src/__tests__/nested-act-test.js",
"language": "javascript",
"file_size": 2433,
"cut_index": 563,
"middle_length": 229
} |
d2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
var REACT_BLOCK_TYPE = 0xead9;
var REACT_SERVER_BLOCK_TYPE = 0xeada;
var REACT_... | r('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD_REF | DEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
REACT_PORTAL_TYPE = symbolFor('react.portal');
exports.Fragment = symbolFo | {
"filepath": "fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js",
"language": "javascript",
"file_size": 27729,
"cut_index": 1331,
"middle_length": 229
} |
ion</h2>
<p>
This page has repeating sections purposefully to create very large
trees that stress the rendering and streaming capabilities of Fizz
</p>
</section>
<section>
<h2>Another Section</h2>
<p>this section has a list</p>
<ul>
<li>... |
<li>π
</li>
<li>π</li>
<li>π€£</li>
<li>π₯²</li>
<li>βΊοΈ</li>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li>
| </section>
<section>
<h2>Smiley Section</h2>
<p>here is a list of smiley emojis</p>
<ol>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li>
<li>π</li> | {
"filepath": "fixtures/fizz/src/BigComponent.js",
"language": "javascript",
"file_size": 4762,
"cut_index": 614,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import {Writable} from 'stream';
import * as React from 'react';
import {renderToPipeableStream} from 'react-dom/server';
import App from '../src/App';
import {ABORT_DELAY} fro... | function _write(chunk, encoding, callback) {
this.chunks.push(chunk);
callback();
};
HtmlWritable.prototype._final = function _final(callback) {
this.html = Buffer.concat(this.chunks).toString();
callback();
};
module.exports = function render(url | ll(this, options);
this.chunks = [];
this.html = '';
}
HtmlWritable.prototype = Object.create(Writable.prototype);
HtmlWritable.prototype.getHtml = function getHtml() {
return this.html;
};
HtmlWritable.prototype._write = | {
"filepath": "fixtures/fizz/server/render-to-buffer.js",
"language": "javascript",
"file_size": 2339,
"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.
*
*/
import * as React from 'react';
import {renderToPipeableStream} from 'react-dom/server';
import App from '../src/App';
import {ABORT_DELAY} from './de... | />, {
bootstrapScripts: [assets['main.js']],
onAllReady() {
// Full completion.
// You can use this for SSG or crawlers.
didFinish = true;
},
onShellReady() {
// If something errored before we started streaming, we | new wiring is a bit more involved.
res.socket.on('error', error => {
console.error('Fatal', error);
});
let didError = false;
let didFinish = false;
const {pipe, abort} = renderToPipeableStream(<App assets={assets} | {
"filepath": "fixtures/fizz/server/render-to-stream.js",
"language": "javascript",
"file_size": 1669,
"cut_index": 537,
"middle_length": 229
} |
API features in DevTools.
function Feature({children, label, version}) {
return (
<div className="Feature">
<div className="FeatureHeader">
<code className="FeatureCode">{label}</code>
<small>{version}</small>
</div>
{children}
</div>
);
}
// Simplify interaction tracing f... | .useState === 'function') {
// Hooks
function Hooks() {
const [count, setCount] = React.useState(0);
const incrementCount = React.useCallback(
() => setCount(count + 1),
[count]
| uleTracing.unstable_trace;
} else {
trace = (_, __, callback) => callback();
}
// https://github.com/facebook/react/blob/main/CHANGELOG.md
switch (major) {
case 16:
switch (minor) {
case 7:
if (typeof React | {
"filepath": "fixtures/devtools/regression/shared.js",
"language": "javascript",
"file_size": 9864,
"cut_index": 921,
"middle_length": 229
} |
ight/test';
test('smoke test', async ({page}) => {
const consoleErrors = [];
page.on('console', msg => {
const type = msg.type();
if (type === 'warn' || type === 'error') {
consoleErrors.push({type: type, text: msg.text()});
}
});
const pageErrors = [];
page.on('pageerror', error => {
p... | ')).not.toBeAttached();
await expect(consoleErrors).toEqual([]);
await expect(pageErrors).toEqual([]);
await page.goto('/prerender');
await expect(page.getByTestId('prerendered')).toBeAttached();
await expect(consoleErrors).toEqual([]);
awai | t'
);
await expect(page.getByTestId('prerendered | {
"filepath": "fixtures/flight/__tests__/__e2e__/smoke.test.js",
"language": "javascript",
"file_size": 893,
"cut_index": 547,
"middle_length": 52
} |
dom/client';
import {createFromFetch, encodeReply} from 'react-server-dom-webpack/client';
// TODO: This should be a dependency of the App but we haven't implemented CSS in Node yet.
import './style.css';
function findSourceMapURL(fileName) {
return (
document.location.origin +
'/source-maps?name=' +
en... | ose();
},
abort(reason) {
ws.close(1000, reason && String(reason));
},
});
const readable = new ReadableStream({
start(controller) {
ws.addEventListener('message', event => {
controller.enqueue(event.data);
}) | ws.addEventListener('open', resolve, {once: true});
ws.addEventListener('error', reject, {once: true});
});
const writable = new WritableStream({
write(chunk) {
ws.send(chunk);
},
close() {
ws.cl | {
"filepath": "fixtures/flight/src/index.js",
"language": "javascript",
"file_size": 3889,
"cut_index": 614,
"middle_length": 229
} |
//,
function (file) {
if ((path.dirname(file) + '/').startsWith(__dirname + '/')) {
// Ignore everything in this folder
// because it's a mix of CJS and ESM
// and working with raw code is easier.
return true;
}
return false;
},
],
presets: ['@babel/preset-r... | ('compression');
const {Readable} = require('node:stream');
const nodeModule = require('node:module');
app.use(compress());
// Application
const {readFile} = require('fs').promises;
const React = require('react');
const activeDebugChannels =
proces | earlier Node versions.
global.fetch = require('undici').fetch;
}
const express = require('express');
const bodyParser = require('body-parser');
const busboy = require('busboy');
const app = express();
const compress = require | {
"filepath": "fixtures/flight/server/region.js",
"language": "javascript",
"file_size": 12745,
"cut_index": 921,
"middle_length": 229
} |
);
const paths = require('./paths');
const modules = require('./modules');
const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const ForkTsCheckerWebpackPlugin =
process.env.TSC_COMPILE_ON_ERROR === 'true'
? require('react-dev-utils/ForkTsCh... | an cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
const reactRefreshWebpackPluginRuntimeEntry = require.re | stPlugin} = require('webpack-manifest-plugin');
function createEnvironmentHash(env) {
const hash = createHash('md5');
hash.update(JSON.stringify(env));
return hash.digest('hex');
}
// Source maps are resource heavy and c | {
"filepath": "fixtures/flight/config/webpack.config.js",
"language": "javascript",
"file_size": 27666,
"cut_index": 1331,
"middle_length": 229
} |
Since the GitHub API is rate-limited
* we attempt to save and load the tags in sessionStorage when possible. Since its unlikely
* that versions will change during a single session this should be safe.
*/
const TAGS_CACHE_KEY = '@react-dom-fixtures/tags';
/**
* Its possible that users will be testing changes freq... |
'15.1.0',
'15.0.2',
'0.14.8',
'0.13.0',
].map(version => ({
name: `v${version}`,
}));
let canUseSessionStorage = true;
try {
sessionStorage.setItem('foo', '');
} catch (err) {
canUseSessionStorage = false;
}
/**
* Attempts to load tags f | e versions while testing.
* If there's a specific version they need to test that is not here, they
* can manually load it by editing the URL (`?version={whatever}`)
*/
const fallbackTags = [
'15.4.2',
'15.3.2',
'15.2.1', | {
"filepath": "fixtures/dom/src/tags.js",
"language": "javascript",
"file_size": 2196,
"cut_index": 563,
"middle_length": 229
} |
0xead2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
var REACT_BLOCK_TYPE = 0xead9;
var REACT_SERVER_BLOCK_TYPE = 0xeada;
var RE... | olFor('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD | _HIDDEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
REACT_PORTAL_TYPE = symbolFor('react.portal');
exports.Fragment = symb | {
"filepath": "fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js",
"language": "javascript",
"file_size": 27118,
"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.
*
*/
'use strict';
const babelRegister = require('@babel/register');
babelRegister({
ignore: [/[\\\/](build|server\/server|node_modules)[\\\/]/],
presets: [['react-app', {runti... | lays');
const PORT = process.env.PORT || 4000;
const app = express();
app.use(compress());
app.get(
'/',
handleErrors(async function (req, res) {
await waitForWebpack();
renderToStream(req.url, res);
})
);
app.get(
'/string',
handleErro | nst path = require('path');
const renderToString = require('./render-to-string');
const renderToStream = require('./render-to-stream');
const renderToBuffer = require('./render-to-buffer');
const {JS_BUNDLE_DELAY} = require('./de | {
"filepath": "fixtures/fizz/server/server.js",
"language": "javascript",
"file_size": 2600,
"cut_index": 563,
"middle_length": 229
} |
;
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'test';
process.env.NODE_ENV = 'test';
process.env.PUBLIC_URL = '';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled wi... | return true;
} catch (e) {
return false;
}
}
function isInMercurialRepository() {
try {
execSync('hg --cwd . root', {stdio: 'ignore'});
return true;
} catch (e) {
return false;
}
}
// Watch unless on CI or explicitly running | const jest = require('jest');
const execSync = require('child_process').execSync;
let argv = process.argv.slice(2);
function isInGitRepository() {
try {
execSync('git rev-parse --is-inside-work-tree', {stdio: 'ignore'});
| {
"filepath": "fixtures/flight/scripts/test.js",
"language": "javascript",
"file_size": 1346,
"cut_index": 524,
"middle_length": 229
} |
e as getSourceImpl,
transformSource as reactTransformSource,
} from 'react-server-dom-unbundled/node-loader';
export {resolve};
import babel from '@babel/core';
const babelOptions = {
babelrc: false,
ignore: [/\/(build|node_modules)\//],
plugins: [
'@babel/plugin-syntax-import-meta',
['@babel/plugin-... | result.source, opt);
if (!newResult) {
if (typeof result.source === 'string') {
return result;
}
return {
source: Buffer.from(result.source).toString('utf8'),
format: 'module',
};
}
return {source | format} = context;
const result = await defaultLoad(url, context, defaultLoad);
if (result.format === 'module') {
const opt = Object.assign({filename: url}, babelOptions);
const newResult = await babel.transformAsync( | {
"filepath": "fixtures/flight/loader/region.js",
"language": "javascript",
"file_size": 2249,
"cut_index": 563,
"middle_length": 229
} |
);
const chalk = require('chalk');
const resolve = require('resolve');
/**
* Get additional module paths based on the baseUrl of a compilerOptions object.
*
* @param {Object} options
*/
function getAdditionalModulePaths(options = {}) {
const baseUrl = options.baseUrl;
if (!baseUrl) {
return '';
}
con... | s equal to the root directory we ignore it here.
// We don't want to allow importing from the root directly as source files are
// not transpiled outside of `src`. We do allow importing them with the
// absolute path (e.g. `src/Components/Button.js`) | s.appNodeModules, baseUrlResolved) === '') {
return null;
}
// Allow the user set the `baseUrl` to `appSrc`.
if (path.relative(paths.appSrc, baseUrlResolved) === '') {
return [paths.appSrc];
}
// If the path i | {
"filepath": "fixtures/flight/config/modules.js",
"language": "javascript",
"file_size": 3492,
"cut_index": 614,
"middle_length": 229
} |
nder the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
export default function Html({assets, children, title}) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
... | `<b>Enable JavaScript to run this app.</b>`,
}}
/>
{children}
<script
dangerouslySetInnerHTML={{
__html: `assetManifest = ${JSON.stringify(assets)};`,
}}
/>
</body>
</html | dangerouslySetInnerHTML={{
__html: | {
"filepath": "fixtures/fizz/src/Html.js",
"language": "javascript",
"file_size": 923,
"cut_index": 606,
"middle_length": 52
} |
sed. Aliquam et
vestibulum eros. Pellentesque mattis efficitur erat. Quisque scelerisque
sem venenatis eros bibendum porta. Fusce a elit et ante rutrum gravida.
Sed ex orci, venenatis non elementum id, faucibus et diam. Nullam
posuere viverra tempus. Duis faucibus metus urna, sit amet b... | sed hendrerit sem. Nulla facilisi. Sed tempor odio eu
nisl facilisis, vel porttitor augue auctor. Fusce in ex euismod,
dignissim diam quis, lacinia purus. Interdum et malesuada fames ac ante
ipsum primis in faucibus. Integer non nib | aoreet pulvinar. Interdum et malesuada fames ac ante
ipsum primis in faucibus. Sed libero velit, porttitor vitae lectus sit
amet, accumsan rhoncus mi. Donec tincidunt purus odio. Aliquam ac
molestie nisi, | {
"filepath": "fixtures/flight/src/LargeContent.js",
"language": "javascript",
"file_size": 69583,
"cut_index": 3790,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.