Expose NativeComponentRegistry API as JavaScript root export (#52999)

Summary:
Resolves https://github.com/react-native-community/discussions-and-proposals/discussions/893#discussioncomment-13449739

Expose NativeComponentRegistry as a root export on index.js.

## Changelog:

[General][Added] - Expose NativeComponentRegistry API as JavaScript root export

Pull Request resolved: https://github.com/facebook/react-native/pull/52999

Test Plan: Can import NativeComponentRegistry from root exort

Reviewed By: cortinico, cipolleschi

Differential Revision: D79721243

Pulled By: huntie

fbshipit-source-id: 77d94fb22255de020009ffe0e54d5030213519e2
This commit is contained in:
zhongwuzw
2025-08-15 04:02:26 -07:00
committed by Facebook GitHub Bot
parent e89df6410f
commit f936780cd5
4 changed files with 40 additions and 5 deletions
+34 -4
View File
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9e1f5e0432c20ddc070ec9dced982591>>
* @generated SignedSource<<2945ef6895f3b6ab1da15ac08a6ef3e7>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
@@ -2454,7 +2454,13 @@ declare type GestureResponderHandlers = {
e: GestureResponderEvent,
) => boolean
}
declare function get<T extends TurboModule>(name: string): null | T | undefined
declare function get<Config extends {}>(
name: string,
viewConfigProvider: () => PartialViewConfig,
): HostComponent<Config>
declare function get_2<T extends TurboModule>(
name: string,
): null | T | undefined
declare function getAppKeys(): ReadonlyArray<string>
declare function getColorScheme(): ColorSchemeName | null | undefined
declare function getEnforcing<T extends TurboModule>(name: string): T
@@ -2462,6 +2468,10 @@ declare function getRegistry(): Registry
declare function getRunnable(appKey: string): null | Runnable | undefined
declare function getSectionKeys(): ReadonlyArray<string>
declare function getSections(): Runnables
declare function getWithFallback_DEPRECATED<Config extends {}>(
name: string,
viewConfigProvider: () => PartialViewConfig,
): React.ComponentType<Config>
declare type hairlineWidth = typeof hairlineWidth
declare type Handle = number
declare type Headers = {
@@ -3215,6 +3225,9 @@ declare type NativeComponentOptions = {
readonly paperComponentName?: string
readonly paperComponentNameDeprecated?: string
}
declare namespace NativeComponentRegistry {
export { setRuntimeConfigProvider, get, getWithFallback_DEPRECATED }
}
declare type NativeComponentType<T extends {}> = HostComponent<T>
declare type NativeDialogManagerAndroid = typeof NativeDialogManagerAndroid
declare class NativeEventEmitter<
@@ -3570,6 +3583,13 @@ declare type parallel = typeof parallel
declare type ParallelConfig = {
stopTogether?: boolean
}
declare type PartialViewConfig = {
readonly bubblingEventTypes?: ViewConfig["bubblingEventTypes"]
readonly directEventTypes?: ViewConfig["directEventTypes"]
readonly supportsRawText?: boolean
readonly uiViewClassName: string
readonly validAttributes?: AttributeConfiguration
}
declare type PassiveCallback = (
event: GestureResponderEvent,
gestureState: PanResponderGestureState,
@@ -4623,6 +4643,15 @@ declare function setComponentProviderInstrumentationHook(
declare function setEnabled(_doEnable: boolean): void
declare function setLayoutAnimationEnabled(value: boolean): void
declare function setRootViewStyleProvider(provider: RootViewStyleProvider): void
declare function setRuntimeConfigProvider(
runtimeConfigProvider: (name: string) =>
| null
| undefined
| {
native: boolean
verify: boolean
},
): void
declare type setStyleAttributePreprocessor =
typeof setStyleAttributePreprocessor
declare function setSurfaceProps(
@@ -5586,7 +5615,7 @@ declare type TouchEventProps = {
declare type TransformsStyle = ____TransformStyle_Internal
declare interface TurboModule extends DEPRECATED_RCTExport<void> {}
declare namespace TurboModuleRegistry {
export { get, getEnforcing }
export { get_2 as get, getEnforcing }
}
declare type TVViewPropsIOS = {
readonly hasTVPreferredFocus?: boolean
@@ -6049,6 +6078,7 @@ export {
MouseEvent, // d432147f
NativeAppEventEmitter, // b4d20c1d
NativeColorValue, // d2094c29
NativeComponentRegistry, // b4954306
NativeDialogManagerAndroid, // 6254873e
NativeEventEmitter, // d72906cc
NativeEventSubscription, // de3942e7
@@ -6173,7 +6203,7 @@ export {
TouchableWithoutFeedbackProps, // 26d3cf4e
TransformsStyle, // 65e70f18
TurboModule, // dfe29706
TurboModuleRegistry, // badfcca2
TurboModuleRegistry, // 4ace6db2
UIManager, // 8d2c8281
UTFSequence, // baacd11b
Vibration, // 315e131d
+3
View File
@@ -241,6 +241,9 @@ module.exports = {
get NativeAppEventEmitter() {
return require('./Libraries/EventEmitter/RCTNativeAppEventEmitter').default;
},
get NativeComponentRegistry() {
return require('./Libraries/NativeComponent/NativeComponentRegistry');
},
get NativeDialogManagerAndroid() {
return require('./Libraries/NativeModules/specs/NativeDialogManagerAndroid')
.default;
+2
View File
@@ -311,6 +311,8 @@ export {default as LogBox} from './Libraries/LogBox/LogBox';
export {default as NativeAppEventEmitter} from './Libraries/EventEmitter/RCTNativeAppEventEmitter';
export * as NativeComponentRegistry from './Libraries/NativeComponent/NativeComponentRegistry';
export {default as NativeDialogManagerAndroid} from './Libraries/NativeModules/specs/NativeDialogManagerAndroid';
export type {
+1 -1
View File
@@ -33,6 +33,7 @@ import {
BackHandler,
Button,
Linking,
NativeComponentRegistry,
Platform,
StatusBar,
StyleSheet,
@@ -40,7 +41,6 @@ import {
useColorScheme,
useWindowDimensions,
} from 'react-native';
import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
// In Bridgeless mode, in dev, enable static view config validator
if (global.RN$Bridgeless === true && __DEV__) {