@@ -50,6 +50,7 @@ @implementation RCTModuleData {
50
50
BOOL _setupComplete;
51
51
RCTModuleRegistry *_moduleRegistry;
52
52
RCTViewRegistry *_viewRegistry_DEPRECATED;
53
+ RCTBundleManager *_bundleManager;
53
54
}
54
55
55
56
@synthesize methods = _methods;
@@ -103,28 +104,32 @@ - (instancetype)initWithModuleClass:(Class)moduleClass
103
104
bridge : (RCTBridge *)bridge
104
105
moduleRegistry : (RCTModuleRegistry *)moduleRegistry
105
106
viewRegistry_DEPRECATED : (RCTViewRegistry *)viewRegistry_DEPRECATED
107
+ bundleManager : (RCTBundleManager *)bundleManager
106
108
{
107
109
return [self initWithModuleClass: moduleClass
108
110
moduleProvider: ^id <RCTBridgeModule> {
109
111
return [moduleClass new ];
110
112
}
111
113
bridge: bridge
112
114
moduleRegistry: moduleRegistry
113
- viewRegistry_DEPRECATED: viewRegistry_DEPRECATED];
115
+ viewRegistry_DEPRECATED: viewRegistry_DEPRECATED
116
+ bundleManager: bundleManager];
114
117
}
115
118
116
119
- (instancetype )initWithModuleClass : (Class )moduleClass
117
120
moduleProvider : (RCTBridgeModuleProvider)moduleProvider
118
121
bridge : (RCTBridge *)bridge
119
122
moduleRegistry : (RCTModuleRegistry *)moduleRegistry
120
123
viewRegistry_DEPRECATED : (RCTViewRegistry *)viewRegistry_DEPRECATED
124
+ bundleManager : (RCTBundleManager *)bundleManager
121
125
{
122
126
if (self = [super init ]) {
123
127
_bridge = bridge;
124
128
_moduleClass = moduleClass;
125
129
_moduleProvider = [moduleProvider copy ];
126
130
_moduleRegistry = moduleRegistry;
127
131
_viewRegistry_DEPRECATED = viewRegistry_DEPRECATED;
132
+ _bundleManager = bundleManager;
128
133
[self setUp ];
129
134
}
130
135
return self;
@@ -134,13 +139,15 @@ - (instancetype)initWithModuleInstance:(id<RCTBridgeModule>)instance
134
139
bridge : (RCTBridge *)bridge
135
140
moduleRegistry : (RCTModuleRegistry *)moduleRegistry
136
141
viewRegistry_DEPRECATED : (RCTViewRegistry *)viewRegistry_DEPRECATED
142
+ bundleManager : (RCTBundleManager *)bundleManager
137
143
{
138
144
if (self = [super init ]) {
139
145
_bridge = bridge;
140
146
_instance = instance;
141
147
_moduleClass = [instance class ];
142
148
_moduleRegistry = moduleRegistry;
143
149
_viewRegistry_DEPRECATED = viewRegistry_DEPRECATED;
150
+ _bundleManager = bundleManager;
144
151
[self setUp ];
145
152
}
146
153
return self;
@@ -203,6 +210,7 @@ - (void)setUpInstanceAndBridge:(int32_t)requestId
203
210
[self setBridgeForInstance ];
204
211
[self setModuleRegistryForInstance ];
205
212
[self setViewRegistryForInstance ];
213
+ [self setBundleManagerForInstance ];
206
214
}
207
215
208
216
[self setUpMethodQueue ];
@@ -284,6 +292,23 @@ - (void)setViewRegistryForInstance
284
292
}
285
293
}
286
294
295
+ - (void )setBundleManagerForInstance
296
+ {
297
+ if ([_instance respondsToSelector: @selector (bundleManager )] && _instance.bundleManager != _bundleManager) {
298
+ RCT_PROFILE_BEGIN_EVENT (RCTProfileTagAlways, @" [RCTModuleData setBundleManagerForInstance]" , nil );
299
+ @try {
300
+ [(id )_instance setValue: _bundleManager forKey: @" bundleManager" ];
301
+ } @catch (NSException *exception ) {
302
+ RCTLogError (
303
+ @" %@ has no setter or ivar for its module registry, which is not "
304
+ " permitted. You must either @synthesize the bundleManager property, "
305
+ " or provide your own setter method." ,
306
+ self.name );
307
+ }
308
+ RCT_PROFILE_END_EVENT (RCTProfileTagAlways, @" " );
309
+ }
310
+ }
311
+
287
312
- (void )finishSetupForInstance
288
313
{
289
314
if (!_setupComplete && _instance) {
0 commit comments