File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow strict-local
8+ * @format
9+ */
10+
11+ 'use strict' ;
12+
13+ type Module = { ...} ;
14+ type RegisterCallableModule = (
15+ name : string ,
16+ moduleOrFactory : Module | ( void => Module ) ,
17+ ) => void ;
18+
19+ const registerCallableModule : RegisterCallableModule = ( function ( ) {
20+ if ( global . RN$Bridgeless === true ) {
21+ return ( name , moduleOrFactory ) => {
22+ if ( typeof moduleOrFactory === 'function' ) {
23+ global . RN$registerCallableModule ( name , moduleOrFactory ) ;
24+ return ;
25+ }
26+
27+ global . RN$registerCallableModule ( name , ( ) => moduleOrFactory ) ;
28+ } ;
29+ }
30+
31+ const BatchedBridge = require ( '../BatchedBridge/BatchedBridge' ) ;
32+ return ( name , moduleOrFactory ) => {
33+ if ( typeof moduleOrFactory === 'function' ) {
34+ BatchedBridge . registerLazyCallableModule ( name , moduleOrFactory ) ;
35+ return ;
36+ }
37+
38+ BatchedBridge . registerCallableModule ( name , moduleOrFactory ) ;
39+ } ;
40+ } ) ( ) ;
41+
42+ export default registerCallableModule ;
Original file line number Diff line number Diff line change @@ -3929,6 +3929,17 @@ exports[`public API should not change unintentionally Libraries/Core/checkNative
39293929
39303930exports[`public API should not change unintentionally Libraries/Core/polyfillPromise.js 1`] = `""`;
39313931
3932+ exports[`public API should not change unintentionally Libraries/Core/registerCallableModule.js 1`] = `
3933+ "type Module = { ... };
3934+ type RegisterCallableModule = (
3935+ name: string,
3936+ moduleOrFactory: Module | ((void) => Module)
3937+ ) => void;
3938+ declare const registerCallableModule: RegisterCallableModule;
3939+ declare export default typeof registerCallableModule;
3940+ "
3941+ `;
3942+
39323943exports[`public API should not change unintentionally Libraries/Core/setUpAlert.js 1`] = `""`;
39333944
39343945exports[`public API should not change unintentionally Libraries/Core/setUpBatchedBridge.js 1`] = `""`;
@@ -9164,6 +9175,7 @@ declare export default class EventEmitter<TEventToArgsMap: { ... }>
91649175exports[`public API should not change unintentionally index.js 1`] = `
91659176"export type HostComponent<T> = _HostComponentInternal<T>;
91669177declare module.exports: {
9178+ get registerCallableModule(): RegisterCallableModule,
91679179 get AccessibilityInfo(): AccessibilityInfo,
91689180 get ActivityIndicator(): ActivityIndicator,
91699181 get Button(): Button,
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import typeof TouchableNativeFeedback from './Libraries/Components/Touchable/Tou
4343import typeof TouchableOpacity from './Libraries/Components/Touchable/TouchableOpacity' ;
4444import typeof TouchableWithoutFeedback from './Libraries/Components/Touchable/TouchableWithoutFeedback' ;
4545import typeof View from './Libraries/Components/View/View' ;
46+ import typeof RegisterCallableModule from './Libraries/Core/registerCallableModule' ;
4647import typeof NativeEventEmitter from './Libraries/EventEmitter/NativeEventEmitter' ;
4748import typeof RCTDeviceEventEmitter from './Libraries/EventEmitter/RCTDeviceEventEmitter' ;
4849import typeof RCTNativeAppEventEmitter from './Libraries/EventEmitter/RCTNativeAppEventEmitter' ;
@@ -97,6 +98,9 @@ const invariant = require('invariant');
9798export type HostComponent < T > = _HostComponentInternal < T > ;
9899
99100module . exports = {
101+ get registerCallableModule ( ) : RegisterCallableModule {
102+ return require ( './Libraries/Core/registerCallableModule' ) . default ;
103+ } ,
100104 // Components
101105 get AccessibilityInfo ( ) : AccessibilityInfo {
102106 return require ( './Libraries/Components/AccessibilityInfo/AccessibilityInfo' )
You can’t perform that action at this time.
0 commit comments