first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow
* @generated SignedSource<<cf323fc5ca893bab5669c7d321660412>>
*/
'use strict';
import {BatchedBridge} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
import type {ReactFabricType} from './ReactNativeTypes';
let ReactFabric: ReactFabricType;
if (__DEV__) {
ReactFabric = require('../implementations/ReactFabric-dev');
} else {
ReactFabric = require('../implementations/ReactFabric-prod');
}
global.RN$stopSurface = ReactFabric.stopSurface;
if (global.RN$Bridgeless !== true) {
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);
}
export default ReactFabric;

View File

@@ -0,0 +1,19 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow strict-local
* @generated SignedSource<<908f5fb85384725318e261f40e49d9a6>>
*/
'use strict';
const ReactFeatureFlags = {
debugRenderPhaseSideEffects: false,
};
export default ReactFeatureFlags;

View File

@@ -0,0 +1,26 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow
*
* This file is no longer sync'd from the facebook/react repository.
* The version compatability check is removed. Use at your own risk.
*/
'use strict';
import type {ReactNativeType} from './ReactNativeTypes';
let ReactNative: ReactNativeType;
if (__DEV__) {
ReactNative = require('../implementations/ReactNativeRenderer-dev');
} else {
ReactNative = require('../implementations/ReactNativeRenderer-prod');
}
export default ReactNative;

View File

@@ -0,0 +1,258 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow strict
* @generated SignedSource<<c0e57723772ea5f1aa8c3c897ac3c216>>
*/
import type {
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
HostInstance as PublicInstance,
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
MeasureOnSuccessCallback,
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
PublicRootInstance,
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
PublicTextInstance,
} from 'react-native';
import * as React from 'react';
export type AttributeType<T, V> =
| true
| $ReadOnly<{
diff?: (arg1: T, arg2: T) => boolean,
process?: (arg1: V) => T,
}>;
// We either force that `diff` and `process` always use mixed,
// or we allow them to define specific types and use this hack
export type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>;
export type AttributeConfiguration = $ReadOnly<{
[propName: string]: AnyAttributeType | void,
style?: $ReadOnly<{
[propName: string]: AnyAttributeType,
...
}>,
...
}>;
export type ViewConfig = $ReadOnly<{
Commands?: $ReadOnly<{[commandName: string]: number, ...}>,
Constants?: $ReadOnly<{[name: string]: mixed, ...}>,
Manager?: string,
NativeProps?: $ReadOnly<{[propName: string]: string, ...}>,
baseModuleName?: ?string,
bubblingEventTypes?: $ReadOnly<{
[eventName: string]: $ReadOnly<{
phasedRegistrationNames: $ReadOnly<{
captured: string,
bubbled: string,
skipBubbling?: ?boolean,
}>,
}>,
...
}>,
directEventTypes?: $ReadOnly<{
[eventName: string]: $ReadOnly<{
registrationName: string,
}>,
...
}>,
supportsRawText?: boolean,
uiViewClassName: string,
validAttributes: AttributeConfiguration,
}>;
export type PartialViewConfig = $ReadOnly<{
bubblingEventTypes?: ViewConfig['bubblingEventTypes'],
directEventTypes?: ViewConfig['directEventTypes'],
supportsRawText?: boolean,
uiViewClassName: string,
validAttributes?: AttributeConfiguration,
}>;
type InspectorDataProps = $ReadOnly<{
[propName: string]: string,
...
}>;
type InspectorDataGetter = (
<TElementType: React.ElementType>(
componentOrHandle: React.ElementRef<TElementType> | number,
) => ?number,
) => $ReadOnly<{
measure: (callback: MeasureOnSuccessCallback) => void,
props: InspectorDataProps,
}>;
export type InspectorData = $ReadOnly<{
closestInstance?: mixed,
hierarchy: Array<{
name: ?string,
getInspectorData: InspectorDataGetter,
}>,
selectedIndex: ?number,
props: InspectorDataProps,
componentStack: string,
}>;
export type TouchedViewDataAtPoint = $ReadOnly<
{
pointerY: number,
touchedViewTag?: number,
frame: $ReadOnly<{
top: number,
left: number,
width: number,
height: number,
}>,
closestPublicInstance?: PublicInstance,
} & InspectorData,
>;
export type RenderRootOptions = {
onUncaughtError?: (
error: mixed,
errorInfo: {+componentStack?: ?string},
) => void,
onCaughtError?: (
error: mixed,
errorInfo: {
+componentStack?: ?string,
// $FlowFixMe[unclear-type] unknown props and state.
// $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
+errorBoundary?: ?React.Component<any, any>,
},
) => void,
onRecoverableError?: (
error: mixed,
errorInfo: {+componentStack?: ?string},
) => void,
onDefaultTransitionIndicator?: () => void | (() => void),
};
/**
* Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
* Provide minimal Flow typing for the high-level RN API and call it a day.
*/
export type ReactNativeType = {
findHostInstance_DEPRECATED<TElementType: React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?PublicInstance,
findNodeHandle<TElementType: React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?number,
isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
dispatchCommand(
handle: PublicInstance,
command: string,
args: Array<mixed>,
): void,
sendAccessibilityEvent(handle: PublicInstance, eventType: string): void,
render(
element: React.MixedElement,
containerTag: number,
callback: ?() => void,
options: ?RenderRootOptions,
): ?React.ElementRef<React.ElementType>,
unmountComponentAtNode(containerTag: number): void,
unmountComponentAtNodeAndRemoveContainer(containerTag: number): void,
+unstable_batchedUpdates: <T>(fn: (T) => void, bookkeeping: T) => void,
...
};
export opaque type Node = mixed;
export opaque type InternalInstanceHandle = mixed;
export type ReactFabricType = {
findHostInstance_DEPRECATED<TElementType: React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?PublicInstance,
findNodeHandle<TElementType: React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?number,
dispatchCommand(
handle: PublicInstance,
command: string,
args: Array<mixed>,
): void,
isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
sendAccessibilityEvent(handle: PublicInstance, eventType: string): void,
render(
element: React.MixedElement,
containerTag: number,
callback: ?() => void,
concurrentRoot: ?boolean,
options: ?RenderRootOptions,
): ?React.ElementRef<React.ElementType>,
unmountComponentAtNode(containerTag: number): void,
getNodeFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle,
): ?Node,
getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle,
): PublicInstance | PublicTextInstance | null,
getPublicInstanceFromRootTag(rootTag: number): PublicRootInstance | null,
...
};
export type ReactFabricEventTouch = {
identifier: number,
locationX: number,
locationY: number,
pageX: number,
pageY: number,
screenX: number,
screenY: number,
target: number,
timestamp: number,
force: number,
...
};
export type ReactFabricEvent = {
touches: Array<ReactFabricEventTouch>,
changedTouches: Array<ReactFabricEventTouch>,
targetTouches: Array<ReactFabricEventTouch>,
target: number,
...
};
// Imperative LayoutAnimation API types
//
export type LayoutAnimationType =
| 'spring'
| 'linear'
| 'easeInEaseOut'
| 'easeIn'
| 'easeOut'
| 'keyboard';
export type LayoutAnimationProperty =
| 'opacity'
| 'scaleX'
| 'scaleY'
| 'scaleXY';
export type LayoutAnimationAnimationConfig = $ReadOnly<{
duration?: number,
delay?: number,
springDamping?: number,
initialVelocity?: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty,
}>;
export type LayoutAnimationConfig = $ReadOnly<{
duration: number,
create?: LayoutAnimationAnimationConfig,
update?: LayoutAnimationAnimationConfig,
delete?: LayoutAnimationAnimationConfig,
}>;

View File

@@ -0,0 +1,125 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow strict-local
* @generated SignedSource<<1f7876c0dc0b05685a730513dc410236>>
*/
'use strict';
import {type ViewConfig} from './ReactNativeTypes';
import invariant from 'invariant';
// Event configs
export const customBubblingEventTypes: {
[eventName: string]: $ReadOnly<{
phasedRegistrationNames: $ReadOnly<{
captured: string,
bubbled: string,
skipBubbling?: ?boolean,
}>,
}>,
} = {};
export const customDirectEventTypes: {
[eventName: string]: $ReadOnly<{
registrationName: string,
}>,
} = {};
const viewConfigCallbacks = new Map<string, ?() => ViewConfig>();
const viewConfigs = new Map<string, ViewConfig>();
function processEventTypes(viewConfig: ViewConfig): void {
const {bubblingEventTypes, directEventTypes} = viewConfig;
if (__DEV__) {
if (bubblingEventTypes != null && directEventTypes != null) {
for (const topLevelType in directEventTypes) {
invariant(
bubblingEventTypes[topLevelType] == null,
'Event cannot be both direct and bubbling: %s',
topLevelType,
);
}
}
}
if (bubblingEventTypes != null) {
for (const topLevelType in bubblingEventTypes) {
if (customBubblingEventTypes[topLevelType] == null) {
customBubblingEventTypes[topLevelType] =
bubblingEventTypes[topLevelType];
}
}
}
if (directEventTypes != null) {
for (const topLevelType in directEventTypes) {
if (customDirectEventTypes[topLevelType] == null) {
customDirectEventTypes[topLevelType] = directEventTypes[topLevelType];
}
}
}
}
/**
* Registers a native view/component by name.
* A callback is provided to load the view config from UIManager.
* The callback is deferred until the view is actually rendered.
*/
export function register(name: string, callback: () => ViewConfig): string {
invariant(
!viewConfigCallbacks.has(name),
'Tried to register two views with the same name %s',
name,
);
invariant(
typeof callback === 'function',
'View config getter callback for component `%s` must be a function (received `%s`)',
name,
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
callback === null ? 'null' : typeof callback,
);
viewConfigCallbacks.set(name, callback);
return name;
}
/**
* Retrieves a config for the specified view.
* If this is the first time the view has been used,
* This configuration will be lazy-loaded from UIManager.
*/
export function get(name: string): ViewConfig {
let viewConfig = viewConfigs.get(name);
if (viewConfig == null) {
const callback = viewConfigCallbacks.get(name);
if (typeof callback !== 'function') {
invariant(
false,
'View config getter callback for component `%s` must be a function (received `%s`).%s',
name,
callback === null ? 'null' : typeof callback,
// $FlowFixMe[recursive-definition]
typeof name[0] === 'string' && /[a-z]/.test(name[0])
? ' Make sure to start component names with a capital letter.'
: '',
);
}
viewConfig = callback();
invariant(viewConfig, 'View config not found for component `%s`', name);
processEventTypes(viewConfig);
viewConfigs.set(name, viewConfig);
// Clear the callback after the config is set so that
// we don't mask any errors during registration.
viewConfigCallbacks.set(name, null);
}
return viewConfig;
}

View File

@@ -0,0 +1,35 @@
/**
* 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.
*
* @noformat
* @nolint
* @flow strict-local
* @generated SignedSource<<52163887de05f1cff05388145cf85b3b>>
*/
'use strict';
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
import {type ViewConfig} from './ReactNativeTypes';
const {register} = ReactNativeViewConfigRegistry;
/**
* Creates a renderable ReactNative host component.
* Use this method for view configs that are loaded from UIManager.
* Use createReactNativeComponentClass() for view configs defined within JavaScript.
*
* @param {string} config iOS View configuration.
* @private
*/
const createReactNativeComponentClass = function (
name: string,
callback: () => ViewConfig,
): string {
return register(name, callback);
};
export default createReactNativeComponentClass;