prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
StringValue} from './ToStringValue';
import escapeSelectorAttributeValueInsideDoubleQuotes from './escapeSelectorAttributeValueInsideDoubleQuotes';
import {queueChangeEvent} from '../events/ReactDOMEventReplaying';
let didWarnValueDefaultValue = false;
let didWarnCheckedDefaultChecked = false;
/**
* Implements an <i... | must change in order for
* the rendered element to be updated.
*
* The rendered element will be initialized as unchecked (or `defaultChecked`)
* with an empty value (or `defaultValue`).
*
* See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-el | user actions
* that affect the checked state or value will trigger updates to the element.
*
* If they are supplied (and not null/undefined), the rendered element will not
* trigger updates to the element. Instead, the props | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMInput.js",
"language": "javascript",
"file_size": 17395,
"cut_index": 1331,
"middle_length": 229
} |
// TODO: direct imports like some-package/src/* are bad. Fix me.
import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCurrentFiber';
import {getToStringValue, toString} from './ToStringValue';
import isArray from 'shared/isArray';
import {queueChangeEvent} from '../events/ReactDOMEventReplaying... | kSelectPropTypes(props: any) {
if (__DEV__) {
for (let i = 0; i < valuePropNames.length; i++) {
const propName = valuePropNames[i];
if (props[propName] == null) {
continue;
}
const propNameIsArray = isArray(props[propN | f (ownerName) {
return '\n\nCheck the render method of `' + ownerName + '`.';
}
return '';
}
const valuePropNames = ['value', 'defaultValue'];
/**
* Validation function for `value` and `defaultValue`.
*/
function chec | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMSelect.js",
"language": "javascript",
"file_size": 7479,
"cut_index": 716,
"middle_length": 229
} |
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export function setSrcObject(domElement: Element, tag: string, value: any) {
// We optimistically create the URL r... | RL.revokeObjectURL(url);
domElement.removeEventListener(loadEvent, cleanUp);
domElement.removeEventListener('error', cleanUp);
};
domElement.addEventListener(loadEvent, cleanUp);
domElement.addEventListener('error', cleanUp);
domElement.set | === 'img' ? 'load' : 'loadstart';
const cleanUp = () => {
// Once the object has started loading, then it's already collected by the
// browser and it won't refer to it by the URL anymore so we can now revoke it.
U | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMSrcObject.js",
"language": "javascript",
"file_size": 1022,
"cut_index": 512,
"middle_length": 229
} |
(c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// When passing user input into querySelector(All) the embedded string must not alter
// the semantics of the query. This escape func... | ubleQuotesRegex = /[\n\"\\]/g;
export default function escapeSelectorAttributeValueInsideDoubleQuotes(
value: string,
): string {
return value.replace(
escapeSelectorAttributeValueInsideDoubleQuotesRegex,
ch => '\\' + ch.charCodeAt(0).toString( | ckslashes
const escapeSelectorAttributeValueInsideDo | {
"filepath": "packages/react-dom-bindings/src/client/escapeSelectorAttributeValueInsideDoubleQuotes.js",
"language": "javascript",
"file_size": 855,
"cut_index": 529,
"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 {TEXT_NODE} from './HTMLNodeType';
/**
* Given any node return the first leaf node without children.
*
* @param {DOMElement|DOMTex... | Node | Element)) {
while (node) {
if (node.nextSibling) {
return node.nextSibling;
}
node = node.parentNode;
}
}
/**
* Get object describing the nodes which contain characters at offset.
*
* @param {DOMElement|DOMTextNode} root
* | Get the next sibling within a container. This will walk up the
* DOM if a node's siblings have been exhausted.
*
* @param {DOMElement|DOMTextNode} node
* @return {?DOMElement|DOMTextNode}
*/
function getSiblingNode(node: ?( | {
"filepath": "packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js",
"language": "javascript",
"file_size": 1611,
"cut_index": 537,
"middle_length": 229
} |
, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {TEXT_NODE} from './HTMLNodeType';
/**
* Set the textContent property of a node. For text updates, it's faster
* to set the `nodeValue` of th... | {
if (text) {
const firstChild = node.firstChild;
if (
firstChild &&
firstChild === node.lastChild &&
firstChild.nodeType === TEXT_NODE
) {
firstChild.nodeValue = text;
return;
}
}
node.textContent = te | on setTextContent(node: Element, text: string): void | {
"filepath": "packages/react-dom-bindings/src/client/setTextContent.js",
"language": "javascript",
"file_size": 893,
"cut_index": 547,
"middle_length": 52
} |
};
declare class ActivityInterface extends Comment {}
declare class SuspenseInterface extends Comment {
_reactRetry: void | (() => void);
}
export type ActivityInstance = ActivityInterface;
export type SuspenseInstance = SuspenseInterface;
type FormStateMarkerInstance = Comment;
export type HydratableInstance =
... | sed
export type TimeoutHandle = TimeoutID;
export type NoTimeout = -1;
export type RendererInspectionConfig = $ReadOnly<{}>;
export type TransitionStatus = FormStatus;
export type ViewTransitionInstance = {
name: string,
group: mixin$Animatable,
im | ntextProd,
ancestorInfo: AncestorInfoDev,
};
type HostContextProd = HostContextNamespace;
export type HostContext = HostContextDev | HostContextProd;
export type UpdatePayload = Array<mixed>;
export type ChildSet = void; // Unu | {
"filepath": "packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js",
"language": "javascript",
"file_size": 227317,
"cut_index": 7068,
"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 {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';
export opaque type ToStringValue =
| bool... | next-line react-internal/safe-string-coercion
return '' + (value: any);
}
export function getToStringValue(value: mixed): ToStringValue {
switch (typeof value) {
case 'bigint':
case 'boolean':
case 'number':
case 'string':
case 'un | pe that can only be obtained by
// passing the value through getToStringValue first.
export function toString(value: ToStringValue): string {
// The coercion safety check is performed in getToStringValue().
// eslint-disable- | {
"filepath": "packages/react-dom-bindings/src/client/ToStringValue.js",
"language": "javascript",
"file_size": 1243,
"cut_index": 518,
"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-turbopack/src/ReactFlightTurbopackReferences.js",
"language": "javascript",
"file_size": 11326,
"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.
*
* @flow
*/
import {Children} from 'react';
let didWarnSelectedSetOnOption = false;
let didWarnInvalidChild = false;
let didWarnInvalidInnerHTML = false... | if (child == null) {
return;
}
if (
typeof child === 'string' ||
typeof child === 'number' ||
typeof child === 'bigint'
) {
return;
}
if (!didWarn | e is not provided, then the children must be simple.
if (props.value == null) {
if (typeof props.children === 'object' && props.children !== null) {
Children.forEach(props.children, function (child) {
| {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMOption.js",
"language": "javascript",
"file_size": 1961,
"cut_index": 537,
"middle_length": 229
} |
deForCharacterOffset from './getNodeForCharacterOffset';
import {TEXT_NODE} from './HTMLNodeType';
/**
* @param {DOMElement} outerNode
* @return {?object}
*/
export function getOffsets(outerNode) {
const {ownerDocument} = outerNode;
const win = (ownerDocument && ownerDocument.defaultView) || window;
const sel... | of its
// properties are accessed. The only seemingly possible way to avoid erroring
// is to access a property that typically works for non-anonymous divs and
// catch any error that may otherwise arise. See
// https://bugzilla.mozilla.org/show_bu | ;
// In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
// up/down buttons on an <input type="number">. Anonymous divs do not seem to
// expose properties, triggering a "Permission denied error" if any | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMSelection.js",
"language": "javascript",
"file_size": 5908,
"cut_index": 716,
"middle_length": 229
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
import {getEventPriority} from '../events/ReactDOMEventListene... | seems to inline it even when the internal length of the function
// is much longer. I hope this is consistent enough to rely on across builds
IntentionallyUnusedArgument?: empty,
): void {
ReactDOMSharedInternals.p /* currentUpdatePriority */ = newPr | ion setCurrentUpdatePriority(
newPriority: EventPriority,
// Closure will consistently not inline this function when it has arity 1
// however when it has arity 2 even if the second arg is omitted at every
// callsite it | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMUpdatePriority.js",
"language": "javascript",
"file_size": 1797,
"cut_index": 537,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
function isLikelyStaticResource(initiatorType: string) {
switch (initiatorType) {
case 'css':
case 'script':
case 'font':
case 'img':
case 'image':
case 'input':
case 'link':
return ... | = 0; i < resourceEntries.length; i++) {
const entry = resourceEntries[i];
// $FlowFixMe[prop-missing]
const transferSize: number = entry.transferSize;
// $FlowFixMe[prop-missing]
const initiatorType: string = entry.initiatorT |
// loaded.
// $FlowFixMe[method-unbinding]
if (typeof performance.getEntriesByType === 'function') {
let count = 0;
let bits = 0;
const resourceEntries = performance.getEntriesByType('resource');
for (let i | {
"filepath": "packages/react-dom-bindings/src/client/estimateBandwidth.js",
"language": "javascript",
"file_size": 3641,
"cut_index": 614,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';
type ValueTracker = {
getValue(): string,
setValue(value: string): void,
stopTracking(): void,
};
interface ElementWithValueTracker e... | eTracker) {
node._valueTracker = null;
}
function getValueFromNode(node: HTMLInputElement): string {
let value = '';
if (!node) {
return value;
}
if (isCheckable(node)) {
value = node.checked ? 'true' : 'false';
} else {
value = n | &&
nodeName.toLowerCase() === 'input' &&
(type === 'checkbox' || type === 'radio')
);
}
function getTracker(node: ElementWithValueTracker) {
return node._valueTracker;
}
function detachTracker(node: ElementWithValu | {
"filepath": "packages/react-dom-bindings/src/client/inputValueTracking.js",
"language": "javascript",
"file_size": 4902,
"cut_index": 614,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {DOMEventName} from '../events/DOMEventNames';
import type {ReactScopeInstance} from 'shared/ReactTypes';
import type {
ReactDOMEventHandle,
ReactDOMEventHandleListener,
} from './ReactDOMEventHandleTyp... | hared/ReactFeatureFlags';
import typeof {SyntheticEvent} from '../events/SyntheticEvent';
type EventHandleOptions = {
capture?: boolean,
};
function isValidEventTarget(target: EventTarget | ReactScopeInstance): boolean {
return typeof (target: Object | /ReactDOMComponentTree';
import {ELEMENT_NODE} from './HTMLNodeType';
import {listenToNativeEventForNonManagedEventTarget} from '../events/DOMPluginEventSystem';
import {
enableScopeAPI,
enableCreateEventHandleAPI,
} from 's | {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMEventHandle.js",
"language": "javascript",
"file_size": 4845,
"cut_index": 614,
"middle_length": 229
} |
import isArray from 'shared/isArray';
import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCurrentFiber';
import {getToStringValue, toString} from './ToStringValue';
import {disableTextareaChildren} from 'shared/ReactFeatureFlags';
import {track, trackHydrated} from './inputValueTracking';
imp... | *
* If `value` is supplied (and not null/undefined), the rendered element will
* not trigger updates to the element. Instead, the `value` prop must change in
* order for the rendered element to be updated.
*
* The rendered element will be initialized | lue`. This differs from the traditional DOM API because value is
* usually set as PCDATA children.
*
* If `value` is not supplied (or null/undefined), user actions that affect the
* value will trigger updates to the element.
| {
"filepath": "packages/react-dom-bindings/src/client/ReactDOMTextarea.js",
"language": "javascript",
"file_size": 5783,
"cut_index": 716,
"middle_length": 229
} |
fNode = null;
let distanceFromLeaf = 0;
while (fiber) {
if (fiber === ancestor) {
distanceFromLeaf = 0;
}
node = {
fiber: fiber,
children: node !== null ? [node] : [],
serverProps:
fiber === child ? props : fiber === ancestor ? null : undefined,
serverTail: [],
... | ?Info,
aTagInScope: ?Info,
buttonTagInScope: ?Info,
nobrTagInScope: ?Info,
pTagInButtonScope: ?Info,
listItemTagAutoclosing: ?Info,
dlItemTagAutoclosing: ?Info,
// <head> or <body>
containerTagInScope: ?Info,
implicitRootScope: boolean | e + with - to mark ancestor and child. It's kind of arbitrary.
return describeDiff(node).replaceAll(/^[+-]/gm, '>');
}
return '';
}
type Info = {tag: string};
export type AncestorInfoDev = {
current: ?Info,
formTag: | {
"filepath": "packages/react-dom-bindings/src/client/validateDOMNesting.js",
"language": "javascript",
"file_size": 17722,
"cut_index": 1331,
"middle_length": 229
} |
tiveElement from './getActiveElement';
import {getOffsets, setOffsets} from './ReactDOMSelection';
import {ELEMENT_NODE, TEXT_NODE} from './HTMLNodeType';
function isTextNode(node) {
return node && node.nodeType === TEXT_NODE;
}
function containsNode(outerNode, innerNode) {
if (!outerNode || !innerNode) {
re... | } else {
return false;
}
}
function isInDocument(node) {
return (
node &&
node.ownerDocument &&
containsNode(node.ownerDocument.documentElement, node)
);
}
function isSameOriginFrame(iframe) {
try {
// Accessing the contentDoc | Node, innerNode.parentNode);
} else if ('contains' in outerNode) {
return outerNode.contains(innerNode);
} else if (outerNode.compareDocumentPosition) {
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
| {
"filepath": "packages/react-dom-bindings/src/client/ReactInputSelection.js",
"language": "javascript",
"file_size": 6064,
"cut_index": 716,
"middle_length": 229
} |
ct-core
*/
'use strict';
import {patchSetImmediate} from '../../../../scripts/jest/patchSetImmediate';
// Polyfills for test environment
global.ReadableStream =
require('web-streams-polyfill/ponyfill/es6').ReadableStream;
global.TextEncoder = require('util').TextEncoder;
global.TextDecoder = require('util').TextD... | thought of as essentially being the React Server Components scope with react-server
// condition
jest.resetModules();
patchSetImmediate();
serverAct = require('internal-test-utils').serverAct;
// Simulate the condition resolution
| nt;
let Suspense;
let ErrorBoundary;
describe('ReactFlightTurbopackDOM', () => {
beforeEach(() => {
// For this first reset we are going to load the dom-node version of react-server-dom-turbopack/server
// This can be | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOM-test.js",
"language": "javascript",
"file_size": 9157,
"cut_index": 716,
"middle_length": 229
} |
let ReactDOMServer;
let ReactServer;
let ReactServerDOMServer;
let ReactServerDOMClient;
let Stream;
let use;
let serverAct;
const streamOptions = {
objectMode: true,
};
describe('ReactFlightTurbopackDOMNode', () => {
beforeEach(() => {
jest.resetModules();
patchSetImmediate();
serverAct = require('i... | ackMock');
clientExports = TurbopackMock.clientExports;
turbopackMap = TurbopackMock.turbopackMap;
turbopackModules = TurbopackMock.turbopackModules;
turbopackModuleLoading = TurbopackMock.moduleLoading;
jest.resetModules();
__unmo | () =>
require('react-server-dom-turbopack/server.node'),
);
ReactServer = require('react');
ReactServerDOMServer = require('react-server-dom-turbopack/server');
const TurbopackMock = require('./utils/Turbop | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMNode-test.js",
"language": "javascript",
"file_size": 9676,
"cut_index": 921,
"middle_length": 229
} |
;
const url = require('url');
let turbopackModuleIdx = 0;
const turbopackServerModules = {};
const turbopackClientModules = {};
const turbopackErroredModules = {};
const turbopackServerMap = {};
const turbopackClientMap = {};
global.__turbopack_require__ = function (id) {
if (turbopackErroredModules[id]) {
thro... | odules = turbopackClientModules;
exports.turbopackServerMap = turbopackServerMap;
exports.moduleLoading = {
prefix: '/prefix/',
};
exports.clientExports = function clientExports(moduleExports, chunkUrl) {
const chunks = [];
if (chunkUrl !== undefine | ence = Server.registerClientReference;
const registerServerReference = Server.registerServerReference;
const createClientModuleProxy = Server.createClientModuleProxy;
exports.turbopackMap = turbopackClientMap;
exports.turbopackM | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/utils/TurbopackMock.js",
"language": "javascript",
"file_size": 5236,
"cut_index": 716,
"middle_length": 229
} |
ight (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment
*/
'use strict';
let turbopackServerMap;
let... | opackMock');
turbopackServerMap = TurbopackMock.turbopackServerMap;
ReactServerDOMServer = require('react-server-dom-turbopack/server.edge');
jest.resetModules();
ReactServerDOMClient = require('react-server-dom-turbopack/client.edge');
} | st.mock('react', () => require('react/react.react-server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.edge'),
);
const TurbopackMock = require('./utils/Turb | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReplyEdge-test.js",
"language": "javascript",
"file_size": 1292,
"cut_index": 524,
"middle_length": 229
} |
import type {
Request,
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {Thenable} from 'shared/ReactTypes';
import type {ClientManifest} from './ReactFlightServerConfigTurbopackBundler';
import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';
import {
createReques... | ,
registerClientReference,
createClientModuleProxy,
} from '../ReactFlightTurbopackReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClientStreamConfigWeb';
import type |
import {
createResponse,
close,
getRoot,
} from 'react-server/src/ReactFlightReplyServer';
import {
decodeAction,
decodeFormState,
} from 'react-server/src/ReactFlightActionServer';
export {
registerServerReference | {
"filepath": "packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js",
"language": "javascript",
"file_size": 7453,
"cut_index": 716,
"middle_length": 229
} |
import type {
Request,
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {Thenable} from 'shared/ReactTypes';
import type {ClientManifest} from './ReactFlightServerConfigTurbopackBundler';
import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';
import {ASYNC_ITERATOR}... | decodeFormState,
} from 'react-server/src/ReactFlightActionServer';
export {
registerServerReference,
registerClientReference,
createClientModuleProxy,
} from '../ReactFlightTurbopackReferences';
import {
createStringDecoder,
readPartialStrin | hannel,
} from 'react-server/src/ReactFlightServer';
import {
createResponse,
close,
getRoot,
reportGlobalError,
resolveField,
resolveFile,
} from 'react-server/src/ReactFlightReplyServer';
import {
decodeAction,
| {
"filepath": "packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js",
"language": "javascript",
"file_size": 8949,
"cut_index": 716,
"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 '../ReactFlightTurbopackReferences';
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-turbopack/src/server/ReactFlightServerConfigTurbopackBundler.js",
"language": "javascript",
"file_size": 3237,
"cut_index": 614,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {
ReactDebugInfo,
ReactIOInfo,
ReactAsyncInfo,
} from 'shared/ReactTypes';
export function loadChunk(filename: string): Promise<mixed> {
return __turbopack_load_by_url__(filename);
}
// We cache R... | = new URL(filename, document.baseURI).href;
} catch (_) {
href = filename;
}
let start = -1;
let end = -1;
let byteSize = 0;
// $FlowFixMe[method-unbinding]
if (typeof performance.getEntriesByType === 'function') {
| ugInfo(
target: ReactDebugInfo,
filename: string,
): void {
if (!__DEV__) {
return;
}
let ioInfo = chunkIOInfoCache.get(filename);
if (ioInfo === undefined) {
let href;
try {
// $FlowFixMe
href | {
"filepath": "packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js",
"language": "javascript",
"file_size": 3239,
"cut_index": 614,
"middle_length": 229
} |
import type {Thenable} from 'shared/ReactTypes.js';
import type {
DebugChannel,
DebugChannelCallback,
FindSourceMapURLCallback,
Response as FlightResponse,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import {
createResponse,
... | ightTemporaryReferences';
export {createTemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export type {TemporaryReferenceSet};
type CallServerCallback = <A, T>(string, args: A) => Promise<T>;
export type Options = {
callS | } from 'react-client/src/ReactFlightReplyClient';
export {
createServerReference,
registerServerReference,
} from 'react-client/src/ReactFlightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/ReactFl | {
"filepath": "packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientBrowser.js",
"language": "javascript",
"file_size": 8133,
"cut_index": 716,
"middle_length": 229
} |
r s;
if (process.env.NODE_ENV === 'production') {
s = require('./cjs/react-server-dom-turbopack-server.node.production.js');
} else {
s = require('./cjs/react-server-dom-turbopack-server.node.development.js');
}
exports.renderToReadableStream = s.renderToReadableStream;
exports.renderToPipeableStream = s.renderToP... | s.decodeFormState;
exports.registerServerReference = s.registerServerReference;
exports.registerClientReference = s.registerClientReference;
exports.createClientModuleProxy = s.createClientModuleProxy;
exports.createTemporaryReferenceSet = s.createTempora | deAction = s.decodeAction;
exports.decodeFormState = | {
"filepath": "packages/react-server-dom-turbopack/npm/server.node.js",
"language": "javascript",
"file_size": 853,
"cut_index": 529,
"middle_length": 52
} |
import type {
Request,
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {ReactFormState, Thenable} from 'shared/ReactTypes';
import {
preloadModule,
requireModule,
resolveServerReference,
type ServerManifest,
type ServerReferenceId,
} from '../client/ReactFlightClientConfigBundl... | react-server/src/ReactFlightActionServer';
export {
createClientReference,
registerServerReference,
} from '../ReactFlightParcelReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/Re | act-server/src/ReactFlightServer';
import {
createResponse,
close,
getRoot,
} from 'react-server/src/ReactFlightReplyServer';
import {
decodeAction as decodeActionImpl,
decodeFormState as decodeFormStateImpl,
} from ' | {
"filepath": "packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js",
"language": "javascript",
"file_size": 8267,
"cut_index": 716,
"middle_length": 229
} |
r;
let ReactServerDOMServer;
let ReactServerDOMClient;
let use;
let serverAct;
describe('ReactFlightTurbopackDOMEdge', () => {
beforeEach(() => {
jest.resetModules();
serverAct = require('internal-test-utils').serverAct;
// Simulate the condition resolution
jest.mock('react', () => require('react/r... | quire('react-server-dom-turbopack/server.edge');
jest.resetModules();
__unmockReact();
React = require('react');
ReactDOMServer = require('react-dom/server.edge');
ReactServerDOMClient = require('react-server-dom-turbopack/client.edge | packMock');
clientExports = TurbopackMock.clientExports;
turbopackMap = TurbopackMock.turbopackMap;
turbopackModules = TurbopackMock.turbopackModules;
ReactServer = require('react');
ReactServerDOMServer = re | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js",
"language": "javascript",
"file_size": 9189,
"cut_index": 921,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
import {patchMessageChannel} from '../../../../scripts/jest/patchMessageChannel';
// Polyfills for test environment
global.ReadableStream ... | ctServerScheduler = require('scheduler');
patchMessageChannel(ReactServerScheduler);
// Simulate the condition resolution
jest.mock('react', () => require('react/react.react-server'));
jest.mock('react-server-dom-turbopack/server', () =>
| assertConsoleErrorDev;
let turbopackServerMap;
let ReactServerDOMServer;
let ReactServerDOMClient;
let ReactServerScheduler;
describe('ReactFlightTurbopackDOMReply', () => {
beforeEach(() => {
jest.resetModules();
Rea | {
"filepath": "packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js",
"language": "javascript",
"file_size": 2949,
"cut_index": 563,
"middle_length": 229
} |
Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export type ImportManifestEntry = {
id: string,
// chunks is an array of filenames
chunks: Array<string>,
name: st... |
export const NAME = 2;
// export const ASYNC = 3;
// This logic is correct because currently only include the 4th tuple member
// when the module is async. If that changes we will need to actually assert
// the value is true. We don't index into the 4th | string,
/* chunk filenames */ Array<string>,
/* name */ string,
/* async */ 1,
]
| [/* id */ string, /* chunk filenames */ Array<string>, /* name */ string];
export const ID = 0;
export const CHUNKS = 1; | {
"filepath": "packages/react-server-dom-turbopack/src/shared/ReactFlightImportMetadata.js",
"language": "javascript",
"file_size": 1174,
"cut_index": 518,
"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 '../ReactFlightTurbopackReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClien | {
"filepath": "packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js",
"language": "javascript",
"file_size": 22491,
"cut_index": 1331,
"middle_length": 229
} |
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {
DebugChannel,
Response as FlightResponse,
FindSourceMapURLCallback,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import type {
ServerConsumer... | Reply,
createServerReference as createServerReferenceImpl,
} from 'react-client/src/ReactFlightReplyClient';
export {registerServerReference} from 'react-client/src/ReactFlightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/Rea | oading,
serverModuleMap: null | ServerManifest,
};
import {
createResponse,
createStreamState,
getRoot,
reportGlobalError,
processBinaryChunk,
close,
} from 'react-client/src/ReactFlightClient';
import {
process | {
"filepath": "packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientEdge.js",
"language": "javascript",
"file_size": 6967,
"cut_index": 716,
"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';
export type ServerReference<T: Function> = T & {
$$typeof: symbol,
$$id: string,
$$bound: null | Array<ReactClientValue>,
$$location?: ... | eference.$$typeof === CLIENT_REFERENCE_TAG;
}
export function isServerReference(reference: Object): boolean {
return reference.$$typeof === SERVER_REFERENCE_TAG;
}
export function createClientReference<T>(
id: string,
exportName: string,
bundles: | ring]: string},
};
const CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
const SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
export function isClientReference(reference: Object): boolean {
return r | {
"filepath": "packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js",
"language": "javascript",
"file_size": 3643,
"cut_index": 614,
"middle_length": 229
} |
import type {
Thenable,
FulfilledThenable,
RejectedThenable,
ReactDebugInfo,
} from 'shared/ReactTypes';
import type {
ImportMetadata,
ImportManifestEntry,
} from '../shared/ReactFlightImportMetadata';
import type {ModuleLoading} from 'react-client/src/ReactFlightClientConfig';
import {
ID,
CHUNKS,
... | nceManifestEntry,
},
};
export type ServerManifest = {
[id: string]: ImportManifestEntry,
};
export type ServerReferenceId = string;
export opaque type ClientReferenceManifestEntry = ImportManifestEntry;
export opaque type ClientReferenceMetadata = | bugInfo,
} from 'react-client/src/ReactFlightClientConfig';
import hasOwnProperty from 'shared/hasOwnProperty';
export type ServerConsumerModuleMap = null | {
[clientId: string]: {
[clientExportName: string]: ClientRefere | {
"filepath": "packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js",
"language": "javascript",
"file_size": 8655,
"cut_index": 716,
"middle_length": 229
} |
lveServerReference,
type ServerManifest,
type ServerReferenceId,
} from '../client/ReactFlightClientConfigBundlerParcel';
import {ASYNC_ITERATOR} from 'shared/ReactSymbols';
import {
createRequest,
createPrerenderRequest,
startWork,
startFlowing,
startFlowingDebug,
stopFlowing,
abort,
resolveDebug... | nce,
} from '../ReactFlightParcelReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClientStreamConfigWeb';
import type {TemporaryReferenceSet} from 'react-server/src/ReactFl | ver/src/ReactFlightReplyServer';
import {
decodeAction as decodeActionImpl,
decodeFormState as decodeFormStateImpl,
} from 'react-server/src/ReactFlightActionServer';
export {
createClientReference,
registerServerRefere | {
"filepath": "packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js",
"language": "javascript",
"file_size": 9605,
"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.
*
* @flow
*/
import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {ImportMetadata} from '../shared/ReactFlightImportMetad... | function getClientReferenceKey(
reference: ClientReference<any>,
): ClientReferenceKey {
return reference.$$id + '#' + reference.$$name;
}
export function resolveClientReferenceMetadata<T>(
config: ClientManifest,
clientReference: ClientReference< | type ServerReferenceId = string;
export type ClientReferenceMetadata = ImportMetadata;
export type ClientReferenceKey = string;
export {
isClientReference,
isServerReference,
} from '../ReactFlightParcelReferences';
export | {
"filepath": "packages/react-server-dom-parcel/src/server/ReactFlightServerConfigParcelBundler.js",
"language": "javascript",
"file_size": 1870,
"cut_index": 537,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Thenable, ReactDebugInfo} from 'shared/ReactTypes';
import type {ImportMetadata} from '../shared/ReactFlightImportMetadata';
import {
ID,
NAME,
BU... | export opaque type ClientReferenceMetadata = ImportMetadata;
// eslint-disable-next-line no-unused-vars
export opaque type ClientReference<T> = ImportMetadata;
export function prepareDestinationForModule(
moduleLoading: ModuleLoading,
nonce: ?string, | sOwnProperty';
export type ServerManifest = {
[string]: Array<string>,
};
export type SSRModuleMap = null;
export type ModuleLoading = null;
export type ServerConsumerModuleMap = null;
export type ServerReferenceId = string;
| {
"filepath": "packages/react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel.js",
"language": "javascript",
"file_size": 2451,
"cut_index": 563,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {DebugChannel, Response} from 'react-client/src/ReactFlightClient';
import type {Readable} from 'stream';
import {
createRespons... | qs.set('env', environmentName);
return devServer + '/__parcel_source_map?' + qs.toString();
}
return null;
}
function noServerCall() {
throw new Error(
'Server Functions cannot be called during initial render. ' +
'This would create | Edge';
function findSourceMapURL(filename: string, environmentName: string) {
const devServer = parcelRequire.meta.devServer;
if (devServer != null) {
const qs = new URLSearchParams();
qs.set('filename', filename);
| {
"filepath": "packages/react-server-dom-parcel/src/client/ReactFlightDOMClientNode.js",
"language": "javascript",
"file_size": 3759,
"cut_index": 614,
"middle_length": 229
} |
nv.NODE_ENV === 'production') {
s = require('./cjs/react-server-dom-parcel-server.node.production.js');
} else {
s = require('./cjs/react-server-dom-parcel-server.node.development.js');
}
exports.renderToReadableStream = s.renderToReadableStream;
exports.renderToPipeableStream = s.renderToPipeableStream;
exports.d... | rts.createClientReference = s.createClientReference;
exports.registerServerReference = s.registerServerReference;
exports.createTemporaryReferenceSet = s.createTemporaryReferenceSet;
exports.registerServerActions = s.registerServerActions;
exports.loadServ | n;
exports.decodeFormState = s.decodeFormState;
expo | {
"filepath": "packages/react-server-dom-parcel/npm/server.node.js",
"language": "javascript",
"file_size": 886,
"cut_index": 547,
"middle_length": 52
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import * as React from 'react';
import {createRoot} from 'react-dom/client';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-s... | pe {FetchFileWithCaching} from 'react-devtools-shared/src/devtools/views/Components/FetchFileWithCachingContext';
import type {Config} from 'react-devtools-shared/src/devtools/store';
export function createBridge(wall?: Wall): FrontendBridge {
if (wall | mport type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {
CanViewElementSource,
TabID,
ViewAttributeSource,
ViewElementSource,
} from 'react-devtools-shared/src/devtools/views/DevTools';
import ty | {
"filepath": "packages/react-devtools-fusebox/src/frontend.js",
"language": "javascript",
"file_size": 2889,
"cut_index": 563,
"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-webpack/server');
const re... | ck 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;
| nalCompile = Module.prototype._compile;
// $FlowFixMe[prop-missing] found when upgrading Flow
Module.prototype._compile = function (
this: any,
content: string,
filename: string,
): void {
// Do a quick che | {
"filepath": "packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js",
"language": "javascript",
"file_size": 3095,
"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-webpack/src/ReactFlightWebpackReferences.js",
"language": "javascript",
"file_size": 11353,
"cut_index": 921,
"middle_length": 229
} |
InfiniteSuspend() {
throw theInfinitePromise;
}
function requireServerRef(ref) {
let name = '';
let resolvedModuleData = webpackServerMap[ref];
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
// We didn't find this specific ... | }
if (!resolvedModuleData) {
throw new Error(
'Could not find the module "' +
ref +
'" in the React Client Manifest. ' +
'This is probably a bug in the React Server Components bundler.',
| to encoding path and name separately on the client reference.
const idx = ref.lastIndexOf('#');
if (idx !== -1) {
name = ref.slice(idx + 1);
resolvedModuleData = webpackServerMap[ref.slice(0, idx)];
| {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js",
"language": "javascript",
"file_size": 85310,
"cut_index": 3790,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {
DebugChannel,
FindSourceMapURLCallback,
Response,
} from 'react-client/src/ReactFlightClient';
import type {
ServerCons... |
} from 'react-client/src/ReactFlightClient';
export * from './ReactFlightDOMClientEdge';
function noServerCall() {
throw new Error(
'Server Functions cannot be called during initial render. ' +
'This would create a fetch waterfall. Try to us | uleLoading,
serverModuleMap: null | ServerManifest,
};
import type {Readable} from 'stream';
import {
createResponse,
createStreamState,
getRoot,
reportGlobalError,
processStringChunk,
processBinaryChunk,
close, | {
"filepath": "packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientNode.js",
"language": "javascript",
"file_size": 3946,
"cut_index": 614,
"middle_length": 229
} |
import type {Thenable} from 'shared/ReactTypes.js';
import type {
DebugChannel,
DebugChannelCallback,
Response as FlightResponse,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import type {ServerReferenceId} from '../client/ReactFlightC... | lightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export {createTemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export type {TemporaryReferenceSet};
function fin | eact-client/src/ReactFlightClient';
import {
processReply,
createServerReference as createServerReferenceImpl,
} from 'react-client/src/ReactFlightReplyClient';
export {registerServerReference} from 'react-client/src/ReactF | {
"filepath": "packages/react-server-dom-parcel/src/client/ReactFlightDOMClientBrowser.js",
"language": "javascript",
"file_size": 9098,
"cut_index": 716,
"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-webpack/src/ReactFlightWebpackNodeLoader.js",
"language": "javascript",
"file_size": 23844,
"cut_index": 1331,
"middle_length": 229
} |
on readInto(
container: Document | HTMLElement,
stream: ReadableStream,
) {
const reader = stream.getReader();
const decoder = new TextDecoder();
let content = '';
while (true) {
const {done, value} = await reader.read();
if (done) {
content += decoder.decode();
bre... | me,
);
}
const attrs = doc.documentElement.attributes;
for (let i = 0; i < attrs.length; i++) {
container.documentElement.setAttribute(attrs[i].name, attrs[i].value);
}
} else {
container.innerHTML = conten | er.documentElement.innerHTML = doc.documentElement.innerHTML;
while (container.documentElement.attributes.length > 0) {
container.documentElement.removeAttribute(
container.documentElement.attributes[0].na | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js",
"language": "javascript",
"file_size": 93556,
"cut_index": 3790,
"middle_length": 229
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
Children,
Component,
Fragment,
Prof... | seContext,
useDebugValue,
useDeferredValue,
useEffect,
useEffectEvent,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useOptimistic,
useReducer,
useRef,
useState,
useSyncExternalStore,
useTransition,
useAct | startTransition,
optimisticKey,
Activity,
unstable_getCacheForType,
unstable_SuspenseList,
ViewTransition,
unstable_startGestureTransition,
addTransitionType,
unstable_useCacheRefresh,
useId,
useCallback,
u | {
"filepath": "packages/react/index.experimental.development.js",
"language": "javascript",
"file_size": 1530,
"cut_index": 537,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';
import {forEach, map, count, toArray, only} f... | ,
useCallback,
useDebugValue,
useMemo,
getCacheForType,
} from './ReactHooks';
import {forwardRef} from './ReactForwardRef';
import {lazy} from './ReactLazy';
import {memo} from './ReactMemo';
import {cache, cacheSignal} from './ReactCacheServer';
| _ACTIVITY_TYPE,
REACT_OPTIMISTIC_KEY,
} from 'shared/ReactSymbols';
import {
cloneElement,
createElement,
isValidElement,
} from './jsx/ReactJSXElement';
import {createRef} from './ReactCreateRef';
import {
use,
useId | {
"filepath": "packages/react/src/ReactServer.experimental.js",
"language": "javascript",
"file_size": 2032,
"cut_index": 563,
"middle_length": 229
} |
st: mixed) {
super(request);
}
get type(): string {
return 'client-reference';
}
}
// This is the module that will be used to anchor all client references to.
// I.e. it will have all the client files as async deps from this point on.
// We use the Flight client implementation because you can't get to t... | Options = {
isServer: boolean,
clientReferences?: ClientReferencePath | $ReadOnlyArray<ClientReferencePath>,
chunkName?: string,
clientManifestFilename?: string,
serverConsumerManifestFilename?: string,
};
const PLUGIN_NAME = 'React Server Plug | uire.resolve('../client.browser.js');
type ClientReferenceSearchPath = {
directory: string,
recursive?: boolean,
include: RegExp,
exclude?: RegExp,
};
type ClientReferencePath = string | ClientReferenceSearchPath;
type | {
"filepath": "packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js",
"language": "javascript",
"file_size": 17700,
"cut_index": 1331,
"middle_length": 229
} |
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {
DebugChannel,
Response as FlightResponse,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import {
createResponse,
createStreamState,
getRoot,
... | oraryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export type {TemporaryReferenceSet};
function findSourceMapURL(filename: string, environmentName: string) {
const devServer = parcelRequire.meta.devServer;
if (devServer != nul | lient/src/ReactFlightReplyClient';
export {registerServerReference} from 'react-client/src/ReactFlightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export {createTemp | {
"filepath": "packages/react-server-dom-parcel/src/client/ReactFlightDOMClientEdge.js",
"language": "javascript",
"file_size": 6870,
"cut_index": 716,
"middle_length": 229
} |
);
patchMessageChannel(ReactServerScheduler);
serverAct = require('internal-test-utils').serverAct;
// Simulate the condition resolution
jest.mock('react', () => require('react/react.react-server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.b... | thod should exist on File but is not implemented in JSDOM
async function arrayBuffer(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = function () {
return resolve(reader.result);
| ire('react');
ReactServerDOMServer = require('react-server-dom-webpack/server.browser');
jest.resetModules();
__unmockReact();
ReactServerDOMClient = require('react-server-dom-webpack/client');
});
// This me | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js",
"language": "javascript",
"file_size": 23222,
"cut_index": 1331,
"middle_length": 229
} |
;
const url = require('url');
const Module = require('module');
let webpackModuleIdx = 0;
let webpackChunkIdx = 0;
const webpackServerModules = {};
const webpackClientModules = {};
const webpackErroredModules = {};
const webpackServerMap = {};
const webpackClientMap = {};
const webpackChunkMap = {};
global.__webpack_... | ebpack/node-register');
// Register node compile
register();
const nodeCompile = Module.prototype._compile;
if (previousCompile === nodeCompile) {
throw new Error(
'Expected the Node loader to register the _compile extension',
);
}
Module.protot | n webpackClientModules[id] || webpackServerModules[id];
};
global.__webpack_get_script_filename__ = function (id) {
return id;
};
const previousCompile = Module.prototype._compile;
const register = require('react-server-dom-w | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js",
"language": "javascript",
"file_size": 6023,
"cut_index": 716,
"middle_length": 229
} |
ight (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
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-webpack/src/shared/ReactFlightImportMetadata.js",
"language": "javascript",
"file_size": 1283,
"cut_index": 524,
"middle_length": 229
} |
ionString,
} = require('react-devtools-extensions/utils');
const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
console.error('NODE_ENV not set');
process.exit(1);
}
const... | 'production',
entry: {
frontend: './src/frontend.js',
},
experiments: {
outputModule: true,
},
output: {
path: __dirname + '/dist',
publicPath: '/dist/',
filename: '[name].js',
chunkFilename: '[name].chunk.js',
librar | onst DEVTOOLS_VERSION = getVersionString();
const babelOptions = {
configFile: resolve(
__dirname,
'..',
'react-devtools-shared',
'babel.config.js',
),
};
module.exports = {
mode: __DEV__ ? 'development' : | {
"filepath": "packages/react-devtools-fusebox/webpack.config.frontend.js",
"language": "javascript",
"file_size": 3209,
"cut_index": 614,
"middle_length": 229
} |
Request,
startWork,
startFlowing,
startFlowingDebug,
stopFlowing,
abort,
resolveDebugMessage,
closeDebugChannel,
} from 'react-server/src/ReactFlightServer';
import {
createResponse,
reportGlobalError,
close,
resolveField,
resolveFile,
resolveFileInfo,
resolveFileChunk,
resolveFileComplet... | eamConfigNode';
import {textEncoder} from 'react-server/src/ReactServerStreamConfigNode';
import type {TemporaryReferenceSet} from 'react-server/src/ReactFlightServerTemporaryReferences';
import type {FileHandle} from 'react-server/src/ReactFlightReplySe | nce,
registerClientReference,
createClientModuleProxy,
} from '../ReactFlightWebpackReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClientStr | {
"filepath": "packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js",
"language": "javascript",
"file_size": 22459,
"cut_index": 1331,
"middle_length": 229
} |
er = stream.getReader();
let prevChunk = new Uint8Array(0);
function push() {
reader.read().then(({done, value}) => {
if (done) {
controller.enqueue(prevChunk);
prevChunk = new Uint8Array(0);
controller.close();
return;
... | nt) may detach
// the underlying buffer. Since prevChunk would share the same
// buffer, we copy it first so it has its own independent buffer.
// TODO: Should we just use {type: 'bytes'} for this stream to
| ngth > 50) {
// Copy the part we're keeping (prevChunk) to avoid buffer
// transfer. When we enqueue the partial chunk below, downstream
// consumers (like byte streams in the Flight Clie | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js",
"language": "javascript",
"file_size": 69226,
"cut_index": 3790,
"middle_length": 229
} |
Mock.clientExports;
webpackMap = WebpackMock.webpackMap;
webpackModules = WebpackMock.webpackModules;
webpackModuleLoading = WebpackMock.moduleLoading;
jest.resetModules();
__unmockReact();
jest.unmock('react-server-dom-webpack/server');
jest.mock('react-server-dom-webpack/client', () =>
... | ev = InternalTestUtils.assertConsoleErrorDev;
});
function filterStackFrame(filename, functionName) {
return (
filename !== '' &&
!filename.startsWith('node:') &&
!filename.includes('node_modules') &&
// Filter out our own | eact-dom/static');
ReactServerDOMClient = require('react-server-dom-webpack/client');
Stream = require('stream');
use = React.use;
const InternalTestUtils = require('internal-test-utils');
assertConsoleErrorD | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js",
"language": "javascript",
"file_size": 64804,
"cut_index": 2151,
"middle_length": 229
} |
erverDOMClient;
describe('ReactFlightDOMReplyEdge', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.react-server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.edg... | soleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
it('can encode a reply', async () => {
const body = await ReactServerDOMClient.encodeReply({some: 'object'});
const decoded = await ReactServerDOMServer.decodeReply(
body,
| = require('react-server-dom-webpack/server.edge');
jest.resetModules();
ReactServerDOMClient = require('react-server-dom-webpack/client.edge');
const InternalTestUtils = require('internal-test-utils');
assertCon | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js",
"language": "javascript",
"file_size": 12683,
"cut_index": 921,
"middle_length": 229
} |
import type {
Request,
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {Thenable} from 'shared/ReactTypes';
import type {ClientManifest} from './ReactFlightServerConfigWebpackBundler';
import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';
import {
createRequest,... | registerClientReference,
createClientModuleProxy,
} from '../ReactFlightWebpackReferences';
import {
createStringDecoder,
readPartialStringChunk,
readFinalStringChunk,
} from 'react-client/src/ReactFlightClientStreamConfigWeb';
import type {Tem | mport {
createResponse,
close,
getRoot,
} from 'react-server/src/ReactFlightReplyServer';
import {
decodeAction,
decodeFormState,
} from 'react-server/src/ReactFlightActionServer';
export {
registerServerReference,
| {
"filepath": "packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js",
"language": "javascript",
"file_size": 7437,
"cut_index": 716,
"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... |
isServerReference,
} from '../ReactFlightWebpackReferences';
export function getClientReferenceKey(
reference: ClientReference<any>,
): ClientReferenceKey {
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
}
export function r | pe ServerReferenceId = string;
export type ClientReferenceMetadata = ImportMetadata;
export opaque type ClientReferenceManifestEntry = ImportManifestEntry;
export type ClientReferenceKey = string;
export {
isClientReference, | {
"filepath": "packages/react-server-dom-webpack/src/server/ReactFlightServerConfigWebpackBundler.js",
"language": "javascript",
"file_size": 3233,
"cut_index": 614,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
let webpackServerMap;
let busboy;
let ReactServerDOMServer;
let ReactServerDOMClient;
describe('ReactFlightDOMReplyNode', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/reac... |
busboy = require('busboy');
});
// Writes the body to busboy as a multipart stream. Blob entries become
// `filename`-bearing parts so busboy emits them as 'file' events (with
// streamed data) rather than 'field' events.
async function pi | webpackServerMap = WebpackMock.webpackServerMap;
ReactServerDOMServer = require('react-server-dom-webpack/server.node');
jest.resetModules();
ReactServerDOMClient = require('react-server-dom-webpack/client.node'); | {
"filepath": "packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyNode-test.js",
"language": "javascript",
"file_size": 5308,
"cut_index": 716,
"middle_length": 229
} |
import type {
Request,
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {Thenable} from 'shared/ReactTypes';
import type {ClientManifest} from './ReactFlightServerConfigWebpackBundler';
import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';
import {ASYNC_ITERATOR} f... | decodeFormState,
} from 'react-server/src/ReactFlightActionServer';
export {
registerServerReference,
registerClientReference,
createClientModuleProxy,
} from '../ReactFlightWebpackReferences';
import {
createStringDecoder,
readPartialStringChu | nnel,
} from 'react-server/src/ReactFlightServer';
import {
createResponse,
close,
getRoot,
reportGlobalError,
resolveField,
resolveFile,
} from 'react-server/src/ReactFlightReplyServer';
import {
decodeAction,
| {
"filepath": "packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js",
"language": "javascript",
"file_size": 8929,
"cut_index": 716,
"middle_length": 229
} |
ct-core
*/
'use strict';
let React;
let ReactDOMClient;
let act;
let assertConsoleErrorDev;
// TODO: Historically this module was used to confirm that the JSX transform
// produces the correct output. However, most users (and indeed our own test
// suite) use a tool like Babel or TypeScript to transform JSX; unlike... | beforeEach(() => {
jest.resetModules();
React = require('react');
ReactDOMClient = require('react-dom/client');
({act, assertConsoleErrorDev} = require('internal-test-utils'));
Component = class extends React.Component {
render | he JSX runtime directly, in ReactCreateElement-test
// and ReactJsxRuntime-test. In the meantime, there's lots of overlap between
// those modules and this one.
describe('ReactJSXTransformIntegration', () => {
let Component;
| {
"filepath": "packages/react/src/__tests__/ReactJSXTransformIntegration-test.js",
"language": "javascript",
"file_size": 8044,
"cut_index": 716,
"middle_length": 229
} |
etadata';
import type {ModuleLoading} from 'react-client/src/ReactFlightClientConfig';
import {
ID,
CHUNKS,
NAME,
isAsyncImport,
} from '../shared/ReactFlightImportMetadata';
import {prepareDestinationWithChunks} from 'react-client/src/ReactFlightClientConfig';
import {
loadChunk,
addChunkDebugInfo,
} fr... | ntry;
export opaque type ClientReferenceMetadata = ImportMetadata;
// eslint-disable-next-line no-unused-vars
export opaque type ClientReference<T> = ClientReferenceMetadata;
// The reason this function needs to defined here in this file instead of just
| e: string]: ClientReferenceManifestEntry,
},
};
export type ServerManifest = {
[id: string]: ImportManifestEntry,
};
export type ServerReferenceId = string;
export opaque type ClientReferenceManifestEntry = ImportManifestE | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpack.js",
"language": "javascript",
"file_size": 9271,
"cut_index": 921,
"middle_length": 229
} |
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {preinitScriptForSSR} from 'react-client/src/ReactFlightClientConfig';
export type ModuleLoading = null | {
pre... | .]
chunks: Array<string>,
nonce: ?string,
) {
if (moduleLoading !== null) {
for (let i = 1; i < chunks.length; i += 2) {
preinitScriptForSSR(
moduleLoading.prefix + chunks[i],
nonce,
moduleLoading.crossOrigin,
| filenamey, .. | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackServer.js",
"language": "javascript",
"file_size": 802,
"cut_index": 517,
"middle_length": 14
} |
import type {Thenable} from 'shared/ReactTypes.js';
import type {
DebugChannel,
DebugChannelCallback,
FindSourceMapURLCallback,
Response as FlightResponse,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import {
createResponse,
... | ightTemporaryReferences';
export {createTemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences';
export type {TemporaryReferenceSet};
type CallServerCallback = <A, T>(string, args: A) => Promise<T>;
export type Options = {
callS | } from 'react-client/src/ReactFlightReplyClient';
export {
createServerReference,
registerServerReference,
} from 'react-client/src/ReactFlightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/ReactFl | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightDOMClientBrowser.js",
"language": "javascript",
"file_size": 8133,
"cut_index": 716,
"middle_length": 229
} |
f (process.env.NODE_ENV === 'production') {
s = require('./cjs/react-server-dom-webpack-server.node.production.js');
} else {
s = require('./cjs/react-server-dom-webpack-server.node.development.js');
}
exports.renderToReadableStream = s.renderToReadableStream;
exports.renderToPipeableStream = s.renderToPipeableStr... | ormState;
exports.registerServerReference = s.registerServerReference;
exports.registerClientReference = s.registerClientReference;
exports.createClientModuleProxy = s.createClientModuleProxy;
exports.createTemporaryReferenceSet = s.createTemporaryReferenc | s.decodeAction;
exports.decodeFormState = s.decodeF | {
"filepath": "packages/react-server-dom-webpack/npm/server.node.js",
"language": "javascript",
"file_size": 849,
"cut_index": 535,
"middle_length": 52
} |
Sig = t.identifier(opts.refreshSig || '$RefreshSig$');
const registrationsByProgramPath = new Map();
function createRegistration(programPath, persistentID) {
const handle = programPath.scope.generateUidIdentifier('c');
if (!registrationsByProgramPath.has(programPath)) {
registrationsByProgramPath.set... | case 'Identifier': {
if (!isComponentishName(node.name)) {
return false;
}
// export default hoc(Foo)
// const X = hoc(Foo)
callback(inferredName, node, null);
return true;
}
case 'F | ction isComponentishName(name) {
return typeof name === 'string' && name[0] >= 'A' && name[0] <= 'Z';
}
function findInnerComponents(inferredName, path, callback) {
const node = path.node;
switch (node.type) {
| {
"filepath": "packages/react-refresh/src/ReactFreshBabelPlugin.js",
"language": "javascript",
"file_size": 28468,
"cut_index": 1331,
"middle_length": 229
} |
).toBe('blue');
await act(() => {
el.dispatchEvent(new MouseEvent('click', {bubbles: true}));
});
expect(el.textContent).toBe('1');
// Perform a hot update.
const HelloV2 = await patch(() => {
function Hello() {
const [val, setVal] = React.useState(0);
... | again.
await act(() => {
el.dispatchEvent(new MouseEvent('click', {bubbles: true}));
});
expect(container.firstChild).toBe(el);
expect(el.textContent).toBe('2');
expect(el.style.color).toBe('red');
// Perform t | Hello;
});
// Assert the state was preserved but color changed.
expect(container.firstChild).toBe(el);
expect(el.textContent).toBe('1');
expect(el.style.color).toBe('red');
// Bump the state | {
"filepath": "packages/react-refresh/src/__tests__/ReactFresh-test.js",
"language": "javascript",
"file_size": 117288,
"cut_index": 3790,
"middle_length": 229
} |
],
[
'JavaScript syntax with destructuring disabled',
source => executeJavaScript(source, false),
testJavaScript,
],
['TypeScript syntax', executeTypescript, testTypeScript],
])('%s', (language, execute, runTest) => {
async function render(source) {
const Component = execute(... | real module system we'd do this for *all* exports.)
// For example, this can happen if you convert a class to a function.
// Or if you wrap something in a HOC.
const didExportsChange =
ReactFreshRuntime.getFamilyByType(prevExports | efresh()).toBe(null);
}
async function patch(source) {
const prevExports = exportsObj;
execute(source);
const nextExports = exportsObj;
// Check if exported families have changed.
// (In a | {
"filepath": "packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js",
"language": "javascript",
"file_size": 66549,
"cut_index": 3790,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
jest.resetModules();
const React = require('react');
let ReactFreshRuntime;
if (__DEV__) {
ReactFreshRuntime = require('react-refresh/run... | () => {
if (__DEV__) {
container = document.createElement('div');
document.body.appendChild(container);
}
});
afterEach(() => {
if (__DEV__) {
document.body.removeChild(container);
container = null;
}
});
i | tART = require('react-art');
const ARTSVGMode = require('art/modes/svg');
const ARTCurrentMode = require('art/modes/current');
ARTCurrentMode.setCurrent(ARTSVGMode);
describe('ReactFresh', () => {
let container;
beforeEach( | {
"filepath": "packages/react-refresh/src/__tests__/ReactFreshMultipleRenderer-test.internal.js",
"language": "javascript",
"file_size": 2976,
"cut_index": 563,
"middle_length": 229
} |
ct from 'react';
import * as Scheduler from 'scheduler/unstable_mock';
import {
getPublicRootInstance,
createContainer,
updateContainer,
flushSyncFromReconciler,
injectIntoDevTools,
batchedUpdates,
defaultOnUncaughtError,
defaultOnCaughtError,
defaultOnRecoverableError,
} from 'react-reconciler/src/Re... | } from 'react-reconciler/src/ReactWorkTags';
import isArray from 'shared/isArray';
import getComponentNameFromType from 'shared/getComponentNameFromType';
import ReactVersion from 'shared/ReactVersion';
import {checkPropStringCoercion} from 'shared/CheckSt | HostHoistable,
HostSingleton,
HostPortal,
HostText,
HostRoot,
ContextConsumer,
ContextProvider,
Mode,
ForwardRef,
Profiler,
MemoComponent,
SimpleMemoComponent,
IncompleteClassComponent,
ScopeComponent,
| {
"filepath": "packages/react-test-renderer/src/ReactTestRenderer.js",
"language": "javascript",
"file_size": 17373,
"cut_index": 921,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
let ReactDOM;
let React;
let ReactCache;
let ReactTestRenderer;
let act;
let assertConsoleErrorDev;
describe('ReactTestRenderer', () => {
beforeEach(() => {
jest.resetModules();
R... | a ReactDOM portal', async () => {
const container = document.createElement('div');
let error;
await act(() => {
ReactTestRenderer.create(ReactDOM.createPortal('foo', container));
}).catch(e => (error = e));
assertConsoleErrorDev | react-test-renderer');
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils.act;
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
it('should warn if used to render | {
"filepath": "packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js",
"language": "javascript",
"file_size": 4521,
"cut_index": 614,
"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 ReactTestRenderer;
let Scheduler;
let waitForAll;
let waitFor;
describe('ReactTestRendererAsync', () => {
beforeEach(() => {
jest.resetModules... | tTestRenderer.create(<Foo>Hi</Foo>, {
unstable_isConcurrent: true,
});
// Before flushing, nothing has mounted.
expect(renderer.toJSON()).toEqual(null);
// Flush initial mount.
await waitForAll([]);
expect(renderer.toJSON()) | waitForAll = InternalTestUtils.waitForAll;
waitFor = InternalTestUtils.waitFor;
});
it('flushAll flushes all work', async () => {
function Foo(props) {
return props.children;
}
const renderer = Reac | {
"filepath": "packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js",
"language": "javascript",
"file_size": 4068,
"cut_index": 614,
"middle_length": 229
} |
erer;
let Scheduler;
let act;
let assertLog;
describe('ReactTestRenderer.act()', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactTestRenderer = require('react-test-renderer');
Scheduler = require('scheduler');
act = ReactTestRenderer.act;
const InternalTestUtil... | ot;
act(() => {
root = ReactTestRenderer.create(
<App
callback={() => {
calledLog.push(calledLog.length);
}}
/>,
);
});
expect(calledLog).toEqual([0]);
expect(root.toJSON()).toEqu | ) => {
function App(props) {
const [ctr, setCtr] = React.useState(0);
React.useEffect(() => {
props.callback();
setCtr(1);
}, []);
return ctr;
}
const calledLog = [];
let ro | {
"filepath": "packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js",
"language": "javascript",
"file_size": 2913,
"cut_index": 563,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {
ReactDebugInfo,
ReactIOInfo,
ReactAsyncInfo,
} from 'shared/ReactTypes';
const chunkMap: Map<string, string> = new Map();
/**
* We patch the chunk filename function in webpack to insert our own r... | mise<mixed> {
chunkMap.set(chunkId, filename);
return __webpack_chunk_load__(chunkId);
}
// We cache ReactIOInfo across requests so that inner refreshes can dedupe with outer.
const chunkIOInfoCache: Map<string, ReactIOInfo> = __DEV__
? new Map()
| tring) {
const flightChunk = chunkMap.get(chunkId);
if (flightChunk !== undefined) {
return flightChunk;
}
return webpackGetChunkFilename(chunkId);
};
export function loadChunk(chunkId: string, filename: string): Pro | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js",
"language": "javascript",
"file_size": 3912,
"cut_index": 614,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {
DebugChannel,
FindSourceMapURLCallback,
Response,
} from 'react-client/src/ReactFlightClient';
import type {
ServerCons... |
} from 'react-client/src/ReactFlightClient';
export * from './ReactFlightDOMClientEdge';
function noServerCall() {
throw new Error(
'Server Functions cannot be called during initial render. ' +
'This would create a fetch waterfall. Try to us | uleLoading,
serverModuleMap: null | ServerManifest,
};
import type {Readable} from 'stream';
import {
createResponse,
createStreamState,
getRoot,
reportGlobalError,
processStringChunk,
processBinaryChunk,
close, | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightDOMClientNode.js",
"language": "javascript",
"file_size": 3946,
"cut_index": 614,
"middle_length": 229
} |
ScheduleRoot,
setRefreshHandler: SetRefreshHandler,
};
if (!__DEV__) {
throw new Error(
'React Refresh runtime should not be included in the production bundle.',
);
}
// In old environments, we'll leak previous types after every edit.
const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
/... | actually been edited here. This keeps checks fast.
const updatedFamiliesByType: WeakMap<any, Family> | Map<any, Family> =
new PossiblyWeakMap();
// This is cleared on every performReactRefresh() call.
// It is an array of [Family, NextType] tuples.
let | any, Family> | Map<any, Family> =
new PossiblyWeakMap();
const allSignaturesByType: WeakMap<any, Signature> | Map<any, Signature> =
new PossiblyWeakMap();
// This WeakMap is read by React, so we only put families
// that have | {
"filepath": "packages/react-refresh/src/ReactFreshRuntime.js",
"language": "javascript",
"file_size": 22400,
"cut_index": 1331,
"middle_length": 229
} |
tSymbols';
import {
DefaultEventPriority,
NoEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
export {default as rendererVersion} from 'shared/ReactVersion'; // TODO: Consider exporting the react-native version.
ex... | : Object,
rootContainerInstance: Container,
tag: 'INSTANCE',
};
export type TextInstance = {
text: string,
isHidden: boolean,
tag: 'TEXT',
};
export type HydratableInstance = Instance | TextInstance;
export type PublicInstance = Instance | TextIn | rray<Instance | TextInstance>,
createNodeMock: Function,
tag: 'CONTAINER',
};
export type Instance = {
type: string,
props: Object,
isHidden: boolean,
children: Array<Instance | TextInstance>,
internalInstanceHandle | {
"filepath": "packages/react-test-renderer/src/ReactFiberConfigTestHost.js",
"language": "javascript",
"file_size": 14797,
"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.
*
* @flow
*/
// Keep in sync with https://github.com/facebook/flow/blob/main/lib/react.js
export type ElementType = React$ElementType;
export type Element... | they're available in tests.
// We can't use export * from in Flow for some reason.
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
Children,
Component,
Fragment,
Profiler,
PureComponent,
StrictM | React$ElementProps<C>;
export type ElementConfig<C> = React$ElementConfig<C>;
export type ElementRef<C> = React$ElementRef<C>;
export type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
// Export all exports so that | {
"filepath": "packages/react/index.development.js",
"language": "javascript",
"file_size": 1785,
"cut_index": 537,
"middle_length": 229
} |
describe('ReactTestRendererTraversal', () => {
beforeEach(() => {
jest.resetModules();
ReactTestRenderer = require('react-test-renderer');
act = require('internal-test-utils').act;
Context = React.createContext(null);
});
class Example extends React.Component {
render() {
return (
... | React.Profiler id="test" onRender={() => {}}>
<ExampleForwardRef qux="qux" />
</React.Profiler>
<>
<>
<Context.Provider value={null}>
<Context.Consumer>
| <ExampleFn bar="bar" bing="bing" />
<ExampleNull bar="bar" />
<ExampleNull null="null">
<View void="void" />
<View void="void" />
</ExampleNull>
< | {
"filepath": "packages/react-test-renderer/src/__tests__/ReactTestRendererTraversal-test.js",
"language": "javascript",
"file_size": 10065,
"cut_index": 921,
"middle_length": 229
} |
(
babel.transform(input, {
babelrc: false,
configFile: false,
envName: options.envName,
plugins: [
'@babel/syntax-jsx',
'@babel/syntax-dynamic-import',
[
freshPlugin,
{
skipEnvCheck:
options.skipEnvCheck === undefined ? tr... | ransform(`
function Hello() {
function handleClick() {}
return <h1 onClick={handleClick}>Hi</h1>;
}
function Bar() {
return <Hello />;
}
`),
).toMatchSnapshot();
});
it('registers | ugins || []),
],
}).code,
);
}
describe('ReactFreshBabelPlugin', () => {
it('registers top-level function declarations', () => {
// Hello and Bar should be registered, handleClick shouldn't.
expect(
t | {
"filepath": "packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js",
"language": "javascript",
"file_size": 15356,
"cut_index": 921,
"middle_length": 229
} |
import type {Thenable, ReactCustomFormAction} from 'shared/ReactTypes.js';
import type {
DebugChannel,
FindSourceMapURLCallback,
Response as FlightResponse,
} from 'react-client/src/ReactFlightClient';
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
import type {
ServerConsumer... | Reply,
createServerReference as createServerReferenceImpl,
} from 'react-client/src/ReactFlightReplyClient';
export {registerServerReference} from 'react-client/src/ReactFlightReplyClient';
import type {TemporaryReferenceSet} from 'react-client/src/Rea | oading,
serverModuleMap: null | ServerManifest,
};
import {
createResponse,
createStreamState,
getRoot,
reportGlobalError,
processBinaryChunk,
close,
} from 'react-client/src/ReactFlightClient';
import {
process | {
"filepath": "packages/react-server-dom-webpack/src/client/ReactFlightDOMClientEdge.js",
"language": "javascript",
"file_size": 6967,
"cut_index": 716,
"middle_length": 229
} |
=== 'production') {
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.production.js');
} else {
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.development.js');
}
exports.renderToReadableStream = s.renderToReadableStream;
exports.renderToPipeableStream = s.renderToPipeableStream;... | tate;
exports.registerServerReference = s.registerServerReference;
exports.registerClientReference = s.registerClientReference;
exports.createClientModuleProxy = s.createClientModuleProxy;
exports.createTemporaryReferenceSet = s.createTemporaryReferenceSet | ecodeAction;
exports.decodeFormState = s.decodeFormS | {
"filepath": "packages/react-server-dom-webpack/npm/server.node.unbundled.js",
"language": "javascript",
"file_size": 869,
"cut_index": 559,
"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
*/
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
Children,
Component,
Fragment,
Prof... | resh,
useId,
useCallback,
useContext,
useDebugValue,
useDeferredValue,
useEffect,
useEffectEvent,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useOptimistic,
useReducer,
useRef,
useState,
useSyncExterna | startTransition,
optimisticKey,
Activity,
Activity as unstable_Activity,
unstable_getCacheForType,
unstable_SuspenseList,
ViewTransition,
unstable_startGestureTransition,
addTransitionType,
unstable_useCacheRef | {
"filepath": "packages/react/index.experimental.js",
"language": "javascript",
"file_size": 1511,
"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
*/
// Keep in sync with https://github.com/facebook/flow/blob/main/lib/react.js
export type ElementType = React$ElementType;
export type Element... | ;
export type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
Children,
Component,
Fragment,
Profiler,
PureComponent,
StrictMode,
Sus | pe Portal = React$Portal;
export type RefSetter<-I> = React$RefSetter<I>;
export type ElementProps<C> = React$ElementProps<C>;
export type ElementConfig<C> = React$ElementConfig<C>;
export type ElementRef<C> = React$ElementRef<C> | {
"filepath": "packages/react/index.js",
"language": "javascript",
"file_size": 1723,
"cut_index": 537,
"middle_length": 229
} |
'shared/enqueueTask';
import {disableLegacyMode} from 'shared/ReactFeatureFlags';
// `act` calls can be nested, so we track the depth. This represents the
// number of `act` scopes on the stack.
let actScopeDepth = 0;
// We only warn the first time you neglect to await an async `act` scope.
let didWarnNoAwaitAct = f... | push all its tasks to
// this queue instead of scheduling them with platform APIs.
//
// We set this to an empty array when we first enter an `act` scope, and
// only unset it once we've left the outermost `act` scope — remember that
// |
}
export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
if (__DEV__) {
// When ReactSharedInternals.actQueue is not null, it signals to React that
// we're currently inside an `act` scope. React will | {
"filepath": "packages/react/src/ReactAct.js",
"language": "javascript",
"file_size": 14113,
"cut_index": 921,
"middle_length": 229
} |
Platforms, Inc. and its 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 {disableClientCache} from 'shared/ReactFeatureFlags';
import {
cache as cacheImpl,
cacheSignal as cacheSignalImpl,
} from './R... | er without breaking on the client. But it
// does mean they need to be aware of the behavioral difference.
//
// The rest of the behavior is the same as the server implementation — it
// returns a new reference, extra properties like `displayName` | e just return the function as-is.
//
// We intend to implement client caching in a future major release. In the
// meantime, it's only exposed as an API so that Shared Components can use
// per-request caching on the serv | {
"filepath": "packages/react/src/ReactCacheClient.js",
"language": "javascript",
"file_size": 1593,
"cut_index": 537,
"middle_length": 229
} |
ort {
getIteratorFn,
REACT_ELEMENT_TYPE,
REACT_LAZY_TYPE,
REACT_PORTAL_TYPE,
REACT_OPTIMISTIC_KEY,
} from 'shared/ReactSymbols';
import {enableOptimisticKey} from 'shared/ReactFeatureFlags';
import {checkKeyStringCoercion} from 'shared/CheckStringCoercion';
import {isValidElement, cloneAndReplaceKey} from '.... | / $FlowFixMe[invalid-computed-prop]
return escaperLookup[match];
});
return '$' + escapedString;
}
/**
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/
let didWarnAboutMaps = false;
const userProvid | ng} the escaped key.
*/
function escape(key: string): string {
const escapeRegex = /[=:]/g;
const escaperLookup = {
'=': '=0',
':': '=2',
};
const escapedString = key.replace(escapeRegex, function (match) {
/ | {
"filepath": "packages/react/src/ReactChildren.js",
"language": "javascript",
"file_size": 14380,
"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.
*
* @flow
*/
import {REACT_CONSUMER_TYPE, REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
import type {ReactContext} from 'shared/ReactTypes';
export fu... | e two concurrent renderers at most: React Native (primary) and
// Fabric (secondary); React DOM (primary) and React ART (secondary).
// Secondary renderers store their context values on separate fields.
_currentValue: defaultValue,
_current | text: ReactContext<T> = {
$$typeof: REACT_CONTEXT_TYPE,
// As a workaround to support multiple concurrent renderers, we categorize
// some renderers as primary and others as secondary. We only expect
// there to b | {
"filepath": "packages/react/src/ReactContext.js",
"language": "javascript",
"file_size": 1538,
"cut_index": 537,
"middle_length": 229
} |
import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
import type {
ReactContext,
StartTransitionOptions,
Usable,
Awaited,
} from 'shared/ReactTypes';
import {REACT_CONSUMER_TYPE} from 'shared/ReactSymbols';
import ReactSharedInternals from 'shared/ReactSharedInternals';
type BasicStateActi... | eact and the renderer (such as React DOM)\n' +
'2. You might be breaking the Rules of Hooks\n' +
'3. You might have more than one copy of React in the same app\n' +
'See https://react.dev/link/invalid-hook-call for tips about | rror(
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
' one of the following reasons:\n' +
'1. You might have mismatching versions of R | {
"filepath": "packages/react/src/ReactHooks.js",
"language": "javascript",
"file_size": 6864,
"cut_index": 716,
"middle_length": 229
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
import {REACT_MEMO_TYPE} from 'shared/ReactSymbols';
export function memo<Props>(
type: React$ElementType,
compare?: (oldProps: Props,... | .defineProperty(elementType, 'displayName', {
enumerable: false,
configurable: true,
get: function () {
return ownName;
},
set: function (name) {
ownName = name;
// The inner component shouldn't inheri | type === null ? 'null' : typeof type,
);
}
}
const elementType = {
$$typeof: REACT_MEMO_TYPE,
type,
compare: compare === undefined ? null : compare,
};
if (__DEV__) {
let ownName;
Object | {
"filepath": "packages/react/src/ReactMemo.js",
"language": "javascript",
"file_size": 1690,
"cut_index": 537,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';
import {forEach, map, count, toArray, only} f... | ,
useCallback,
useDebugValue,
useMemo,
getCacheForType,
} from './ReactHooks';
import {forwardRef} from './ReactForwardRef';
import {lazy} from './ReactLazy';
import {memo} from './ReactMemo';
import {cache, cacheSignal} from './ReactCacheServer';
| _ACTIVITY_TYPE,
REACT_OPTIMISTIC_KEY,
} from 'shared/ReactSymbols';
import {
cloneElement,
createElement,
isValidElement,
} from './jsx/ReactJSXElement';
import {createRef} from './ReactCreateRef';
import {
use,
useId | {
"filepath": "packages/react/src/ReactServer.experimental.development.js",
"language": "javascript",
"file_size": 2118,
"cut_index": 563,
"middle_length": 229
} |
Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {captureOwnerStack as captureOwnerStackImpl} from './src/ReactClient';
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CA... | orType,
unstable_LegacyHidden,
unstable_Scope,
unstable_SuspenseList,
ViewTransition,
ViewTransition as unstable_ViewTransition,
unstable_TracingMarker,
addTransitionType,
addTransitionType as unstable_addTransitionType,
unstable_useCache | ffectEvent,
useEffectEvent,
forwardRef,
Fragment,
isValidElement,
lazy,
memo,
Profiler,
PureComponent,
startTransition,
StrictMode,
Suspense,
Activity,
Activity as unstable_Activity,
unstable_getCacheF | {
"filepath": "packages/react/index.fb.js",
"language": "javascript",
"file_size": 1870,
"cut_index": 537,
"middle_length": 229
} |
ource code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export {
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
__COMPILER_RUNTIME,
Activity,
Children,
Component,
Fragment,
Profiler,
PureComponent,
StrictMo... | useId,
useCallback,
useContext,
useDebugValue,
useDeferredValue,
useEffect,
useEffectEvent,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useReducer,
useOptimistic,
useRef,
useState,
useSyncExternalStore | nal,
unstable_useCacheRefresh,
startTransition,
| {
"filepath": "packages/react/index.stable.js",
"language": "javascript",
"file_size": 966,
"cut_index": 582,
"middle_length": 52
} |
the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import ReactSharedInternals from 'shared/ReactSharedInternals';
const UNTERMINATED = 0;
const TERMINATED = 1;
const ERRORED = 2;
type UnterminatedCacheNode<T> = {
s: 0,
v: void,
o: null | WeakMap<Function |... | | number | null | void | symbol | boolean, CacheNode<T>>,
};
type CacheNode<T> =
| TerminatedCacheNode<T>
| UnterminatedCacheNode<T>
| ErroredCacheNode<T>;
function createCacheRoot<T>(): WeakMap<Function | Object, CacheNode<T>> {
return new Weak | ct, CacheNode<T>>,
p: null | Map<string | number | null | void | symbol | boolean, CacheNode<T>>,
};
type ErroredCacheNode<T> = {
s: 2,
v: mixed,
o: null | WeakMap<Function | Object, CacheNode<T>>,
p: null | Map<string | {
"filepath": "packages/react/src/ReactCacheImpl.js",
"language": "javascript",
"file_size": 4465,
"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.
*
* @noflow
*/
import {REACT_FORWARD_REF_TYPE, REACT_MEMO_TYPE} from 'shared/ReactSymbols';
export function forwardRef<Props, ElementType: React$ElementType>(
render: (
prop... |
console.error(
'forwardRef requires a render function but was given %s.',
render === null ? 'null' : typeof render,
);
} else {
if (render.length !== 0 && render.length !== 2) {
console.error(
'forwa |
'forwardRef requires a render function but received a `memo` ' +
'component. Instead of forwardRef(memo(...)), use ' +
'memo(forwardRef(...)).',
);
} else if (typeof render !== 'function') { | {
"filepath": "packages/react/src/ReactForwardRef.js",
"language": "javascript",
"file_size": 2614,
"cut_index": 563,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.