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 8 #import <Foundation/Foundation.h> 9 10 #import <ABI47_0_0React/ABI47_0_0RCTInvalidating.h> 11 #import "ABI47_0_0RCTDefines.h" 12 13 @protocol ABI47_0_0RCTBridgeMethod; 14 @protocol ABI47_0_0RCTBridgeModule; 15 @class ABI47_0_0RCTBridge; 16 @class ABI47_0_0RCTModuleRegistry; 17 @class ABI47_0_0RCTViewRegistry; 18 @class ABI47_0_0RCTBundleManager; 19 @class ABI47_0_0RCTCallableJSModules; 20 21 typedef id<ABI47_0_0RCTBridgeModule> (^ABI47_0_0RCTBridgeModuleProvider)(void); 22 23 @interface ABI47_0_0RCTModuleData : NSObject <ABI47_0_0RCTInvalidating> 24 25 - (instancetype)initWithModuleClass:(Class)moduleClass 26 bridge:(ABI47_0_0RCTBridge *)bridge 27 moduleRegistry:(ABI47_0_0RCTModuleRegistry *)moduleRegistry 28 viewRegistry_DEPRECATED:(ABI47_0_0RCTViewRegistry *)viewRegistry_DEPRECATED 29 bundleManager:(ABI47_0_0RCTBundleManager *)bundleManager 30 callableJSModules:(ABI47_0_0RCTCallableJSModules *)callableJSModules; 31 32 - (instancetype)initWithModuleClass:(Class)moduleClass 33 moduleProvider:(ABI47_0_0RCTBridgeModuleProvider)moduleProvider 34 bridge:(ABI47_0_0RCTBridge *)bridge 35 moduleRegistry:(ABI47_0_0RCTModuleRegistry *)moduleRegistry 36 viewRegistry_DEPRECATED:(ABI47_0_0RCTViewRegistry *)viewRegistry_DEPRECATED 37 bundleManager:(ABI47_0_0RCTBundleManager *)bundleManager 38 callableJSModules:(ABI47_0_0RCTCallableJSModules *)callableJSModules NS_DESIGNATED_INITIALIZER; 39 40 - (instancetype)initWithModuleInstance:(id<ABI47_0_0RCTBridgeModule>)instance 41 bridge:(ABI47_0_0RCTBridge *)bridge 42 moduleRegistry:(ABI47_0_0RCTModuleRegistry *)moduleRegistry 43 viewRegistry_DEPRECATED:(ABI47_0_0RCTViewRegistry *)viewRegistry_DEPRECATED 44 bundleManager:(ABI47_0_0RCTBundleManager *)bundleManager 45 callableJSModules:(ABI47_0_0RCTCallableJSModules *)callableJSModules NS_DESIGNATED_INITIALIZER; 46 47 /** 48 * Calls `constantsToExport` on the module and stores the result. Note that 49 * this will init the module if it has not already been created. This method 50 * can be called on any thread, but may block the main thread briefly if the 51 * module implements `constantsToExport`. 52 */ 53 - (void)gatherConstants; 54 55 @property (nonatomic, strong, readonly) Class moduleClass; 56 @property (nonatomic, copy, readonly) NSString *name; 57 58 /** 59 * Returns the module methods. Note that this will gather the methods the first 60 * time it is called and then memoize the results. 61 */ 62 @property (nonatomic, copy, readonly) NSArray<id<ABI47_0_0RCTBridgeMethod>> *methods; 63 64 /** 65 * Returns a map of the module methods. Note that this will gather the methods the first 66 * time it is called and then memoize the results. 67 */ 68 @property (nonatomic, copy, readonly) NSDictionary<NSString *, id<ABI47_0_0RCTBridgeMethod>> *methodsByName; 69 70 /** 71 * Returns the module's constants, if it exports any 72 */ 73 @property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *exportedConstants; 74 75 /** 76 * Returns YES if module instance has already been initialized; NO otherwise. 77 */ 78 @property (nonatomic, assign, readonly) BOOL hasInstance; 79 80 /** 81 * Returns YES if module instance must be created on the main thread. 82 */ 83 @property (nonatomic, assign) BOOL requiresMainQueueSetup; 84 85 /** 86 * Returns YES if module has constants to export. 87 */ 88 @property (nonatomic, assign, readonly) BOOL hasConstantsToExport; 89 90 /** 91 * Returns the current module instance. Note that this will init the instance 92 * if it has not already been created. To check if the module instance exists 93 * without causing it to be created, use `hasInstance` instead. 94 */ 95 @property (nonatomic, strong, readwrite) id<ABI47_0_0RCTBridgeModule> instance; 96 97 /** 98 * Returns the module method dispatch queue. Note that this will init both the 99 * queue and the module itself if they have not already been created. 100 */ 101 @property (nonatomic, strong, readonly) dispatch_queue_t methodQueue; 102 103 /** 104 * Whether the receiver has a valid `instance` which implements -batchDidComplete. 105 */ 106 @property (nonatomic, assign, readonly) BOOL implementsBatchDidComplete; 107 108 /** 109 * Whether the receiver has a valid `instance` which implements 110 * -partialBatchDidFlush. 111 */ 112 @property (nonatomic, assign, readonly) BOOL implementsPartialBatchDidFlush; 113 114 @end 115 116 ABI47_0_0RCT_EXTERN void ABI47_0_0RCTSetIsMainQueueExecutionOfConstantsToExportDisabled(BOOL val); 117 ABI47_0_0RCT_EXTERN BOOL ABI47_0_0RCTIsMainQueueExecutionOfConstantsToExportDisabled(void); 118