Skip to content

Commit f936780

Browse files
zhongwuzwfacebook-github-bot
authored andcommitted
Expose NativeComponentRegistry API as JavaScript root export (facebook#52999)
Summary: Resolves react-native-community/discussions-and-proposals#893 (comment) Expose NativeComponentRegistry as a root export on index.js. ## Changelog: [General][Added] - Expose NativeComponentRegistry API as JavaScript root export Pull Request resolved: facebook#52999 Test Plan: Can import NativeComponentRegistry from root exort Reviewed By: cortinico, cipolleschi Differential Revision: D79721243 Pulled By: huntie fbshipit-source-id: 77d94fb22255de020009ffe0e54d5030213519e2
1 parent e89df64 commit f936780

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

packages/react-native/ReactNativeApi.d.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9e1f5e0432c20ddc070ec9dced982591>>
7+
* @generated SignedSource<<2945ef6895f3b6ab1da15ac08a6ef3e7>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -2454,14 +2454,24 @@ declare type GestureResponderHandlers = {
24542454
e: GestureResponderEvent,
24552455
) => boolean
24562456
}
2457-
declare function get<T extends TurboModule>(name: string): null | T | undefined
2457+
declare function get<Config extends {}>(
2458+
name: string,
2459+
viewConfigProvider: () => PartialViewConfig,
2460+
): HostComponent<Config>
2461+
declare function get_2<T extends TurboModule>(
2462+
name: string,
2463+
): null | T | undefined
24582464
declare function getAppKeys(): ReadonlyArray<string>
24592465
declare function getColorScheme(): ColorSchemeName | null | undefined
24602466
declare function getEnforcing<T extends TurboModule>(name: string): T
24612467
declare function getRegistry(): Registry
24622468
declare function getRunnable(appKey: string): null | Runnable | undefined
24632469
declare function getSectionKeys(): ReadonlyArray<string>
24642470
declare function getSections(): Runnables
2471+
declare function getWithFallback_DEPRECATED<Config extends {}>(
2472+
name: string,
2473+
viewConfigProvider: () => PartialViewConfig,
2474+
): React.ComponentType<Config>
24652475
declare type hairlineWidth = typeof hairlineWidth
24662476
declare type Handle = number
24672477
declare type Headers = {
@@ -3215,6 +3225,9 @@ declare type NativeComponentOptions = {
32153225
readonly paperComponentName?: string
32163226
readonly paperComponentNameDeprecated?: string
32173227
}
3228+
declare namespace NativeComponentRegistry {
3229+
export { setRuntimeConfigProvider, get, getWithFallback_DEPRECATED }
3230+
}
32183231
declare type NativeComponentType<T extends {}> = HostComponent<T>
32193232
declare type NativeDialogManagerAndroid = typeof NativeDialogManagerAndroid
32203233
declare class NativeEventEmitter<
@@ -3570,6 +3583,13 @@ declare type parallel = typeof parallel
35703583
declare type ParallelConfig = {
35713584
stopTogether?: boolean
35723585
}
3586+
declare type PartialViewConfig = {
3587+
readonly bubblingEventTypes?: ViewConfig["bubblingEventTypes"]
3588+
readonly directEventTypes?: ViewConfig["directEventTypes"]
3589+
readonly supportsRawText?: boolean
3590+
readonly uiViewClassName: string
3591+
readonly validAttributes?: AttributeConfiguration
3592+
}
35733593
declare type PassiveCallback = (
35743594
event: GestureResponderEvent,
35753595
gestureState: PanResponderGestureState,
@@ -4623,6 +4643,15 @@ declare function setComponentProviderInstrumentationHook(
46234643
declare function setEnabled(_doEnable: boolean): void
46244644
declare function setLayoutAnimationEnabled(value: boolean): void
46254645
declare function setRootViewStyleProvider(provider: RootViewStyleProvider): void
4646+
declare function setRuntimeConfigProvider(
4647+
runtimeConfigProvider: (name: string) =>
4648+
| null
4649+
| undefined
4650+
| {
4651+
native: boolean
4652+
verify: boolean
4653+
},
4654+
): void
46264655
declare type setStyleAttributePreprocessor =
46274656
typeof setStyleAttributePreprocessor
46284657
declare function setSurfaceProps(
@@ -5586,7 +5615,7 @@ declare type TouchEventProps = {
55865615
declare type TransformsStyle = ____TransformStyle_Internal
55875616
declare interface TurboModule extends DEPRECATED_RCTExport<void> {}
55885617
declare namespace TurboModuleRegistry {
5589-
export { get, getEnforcing }
5618+
export { get_2 as get, getEnforcing }
55905619
}
55915620
declare type TVViewPropsIOS = {
55925621
readonly hasTVPreferredFocus?: boolean
@@ -6049,6 +6078,7 @@ export {
60496078
MouseEvent, // d432147f
60506079
NativeAppEventEmitter, // b4d20c1d
60516080
NativeColorValue, // d2094c29
6081+
NativeComponentRegistry, // b4954306
60526082
NativeDialogManagerAndroid, // 6254873e
60536083
NativeEventEmitter, // d72906cc
60546084
NativeEventSubscription, // de3942e7
@@ -6173,7 +6203,7 @@ export {
61736203
TouchableWithoutFeedbackProps, // 26d3cf4e
61746204
TransformsStyle, // 65e70f18
61756205
TurboModule, // dfe29706
6176-
TurboModuleRegistry, // badfcca2
6206+
TurboModuleRegistry, // 4ace6db2
61776207
UIManager, // 8d2c8281
61786208
UTFSequence, // baacd11b
61796209
Vibration, // 315e131d

packages/react-native/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ module.exports = {
241241
get NativeAppEventEmitter() {
242242
return require('./Libraries/EventEmitter/RCTNativeAppEventEmitter').default;
243243
},
244+
get NativeComponentRegistry() {
245+
return require('./Libraries/NativeComponent/NativeComponentRegistry');
246+
},
244247
get NativeDialogManagerAndroid() {
245248
return require('./Libraries/NativeModules/specs/NativeDialogManagerAndroid')
246249
.default;

packages/react-native/index.js.flow

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ export {default as LogBox} from './Libraries/LogBox/LogBox';
311311

312312
export {default as NativeAppEventEmitter} from './Libraries/EventEmitter/RCTNativeAppEventEmitter';
313313

314+
export * as NativeComponentRegistry from './Libraries/NativeComponent/NativeComponentRegistry';
315+
314316
export {default as NativeDialogManagerAndroid} from './Libraries/NativeModules/specs/NativeDialogManagerAndroid';
315317

316318
export type {

packages/rn-tester/js/RNTesterAppShared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ import {
3333
BackHandler,
3434
Button,
3535
Linking,
36+
NativeComponentRegistry,
3637
Platform,
3738
StatusBar,
3839
StyleSheet,
3940
View,
4041
useColorScheme,
4142
useWindowDimensions,
4243
} from 'react-native';
43-
import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
4444

4545
// In Bridgeless mode, in dev, enable static view config validator
4646
if (global.RN$Bridgeless === true && __DEV__) {

0 commit comments

Comments
 (0)