Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTBridge+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
@class RCTModuleData;
@protocol RCTJavaScriptExecutor;

#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
RCT_EXTERN void RCTRegisterModule(Class);
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

@interface RCTBridge ()

Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "RCTReloadCommand.h"
#import "RCTUtils.h"

#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
static NSMutableArray<Class> *RCTModuleClasses;
static dispatch_queue_t RCTModuleClassesSyncQueue;
NSArray<Class> *RCTGetModuleClasses(void)
Expand Down Expand Up @@ -115,6 +116,7 @@

return coreModuleClasses;
}
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

static NSMutableArray<NSString *> *modulesLoadedWithOldArch;
void addModuleLoadedWithOldArch(NSString * /*moduleName*/);
Expand All @@ -133,6 +135,7 @@ void addModuleLoadedWithOldArch(NSString *moduleName)
return modulesLoadedWithOldArch;
}

#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
/**
* Register the given class as a bridge module. All modules must be registered
* prior to the first bridge initialization.
Expand Down Expand Up @@ -161,6 +164,7 @@ void RCTRegisterModule(Class moduleClass)
[RCTModuleClasses addObject:moduleClass];
});
}
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

/**
* This function returns the module name for a given class.
Expand Down
14 changes: 14 additions & 0 deletions packages/react-native/React/Base/RCTBridgeModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ RCT_EXTERN_C_END
* will be used as the JS module name. If omitted, the JS module name will
* match the Objective-C class name.
*/
#if defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) && defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

// With both legacy interop layers removed, RCTRegisterModule is compiled out, so
// static module registration is a no-op: only the JS module name is emitted.
#define RCT_EXPORT_MODULE(js_name) \
+(NSString *)moduleName \
{ \
return @ #js_name; \
}

#else

#ifndef RCT_DISABLE_STATIC_MODULE_REGISTRATION
#define RCT_EXPORT_MODULE(js_name) \
RCT_EXTERN void RCTRegisterModule(Class); \
Expand Down Expand Up @@ -108,6 +120,8 @@ RCT_EXTERN_C_END
RCTRegisterModule([objc_name class]); \
}

#endif // defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) && defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

// Implemented by RCT_EXPORT_MODULE
+ (NSString *)moduleName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <jsi/jsi.h>

namespace facebook::react {
Expand All @@ -17,3 +19,5 @@ namespace facebook::react {
*/
void installLegacyUIManagerConstantsProviderBinding(jsi::Runtime &runtime);
} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "RCTLegacyUIManagerConstantsProvider.h"

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <React/RCTBridge+Private.h>
#import <React/RCTComponentData.h>
#import <React/RCTUIManager.h>
Expand Down Expand Up @@ -41,3 +43,5 @@ void installLegacyUIManagerConstantsProviderBinding(jsi::Runtime &runtime)
LegacyUIManagerConstantsProviderBinding::install(runtime, "getConstants", getConstants);
}
} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Loading