1a5a9f97fSStanisław Chmiela// Copyright © 2018 650 Industries. All rights reserved. 2a5a9f97fSStanisław Chmiela 3a5a9f97fSStanisław Chmiela#import "EXScopedModuleRegistry.h" 4a5a9f97fSStanisław Chmiela 5a5a9f97fSStanisław Chmiela#import "EXScopedModuleRegistryAdapter.h" 6a5a9f97fSStanisław Chmiela#import "EXSensorsManagerBinding.h" 7b33148adSTomasz Sapeta#import "EXConstantsBinding.h" 8712e5c6cSSzymon20000#import "EXScopedFileSystemModule.h" 9a5a9f97fSStanisław Chmiela#import "EXUnversioned.h" 10d1fb9868SSzymon20000#import "EXScopedFilePermissionModule.h" 117327b9ddSBrent Vatne#import "EXScopedFontLoader.h" 12c9802ebaSStanisław Chmiela#import "EXScopedSecureStore.h" 13c9802ebaSStanisław Chmiela#import "EXScopedPermissions.h" 1404f8f9ecSTomasz Sapeta#import "EXScopedSegment.h" 15631604b1STomasz Sapeta#import "EXScopedLocalAuthentication.h" 16636b55abSStanisław Chmiela#import "EXScopedBranch.h" 170f064ba0SŁukasz Kosmaty#import "EXScopedErrorRecoveryModule.h" 180ff9a3f7SStanisław Chmiela#import "EXScopedFacebook.h" 19776d46faSHein Rutjes#import "EXScopedFirebaseCore.h" 2092e817a0SEric Samelson#import "EXUpdatesBinding.h" 21a5a9f97fSStanisław Chmiela 22e9ab9323SStanisław Chmiela#import "EXScopedReactNativeAdapter.h" 237100de8cSSzymon20000#import "EXExpoUserNotificationCenterProxy.h" 24a5a9f97fSStanisław Chmiela 25e62fb1d4SŁukasz Kosmaty#import "EXScopedNotificationsEmitter.h" 2644bbe92dSŁukasz Kosmaty#import "EXScopedNotificationsHandlerModule.h" 2744bbe92dSŁukasz Kosmaty#import "EXScopedNotificationBuilder.h" 280f9680e4SŁukasz Kosmaty#import "EXScopedNotificationSchedulerModule.h" 29bfb365deSŁukasz Kosmaty#import "EXScopedNotificationPresentationModule.h" 30f6562485SCharlie Cruzan#import "EXScopedNotificationCategoriesModule.h" 3198629a0cSStanisław Chmiela#import "EXScopedServerRegistrationModule.h" 32e62fb1d4SŁukasz Kosmaty 33631604b1STomasz Sapeta#if __has_include(<EXTaskManager/EXTaskManager.h>) 34631604b1STomasz Sapeta#import <EXTaskManager/EXTaskManager.h> 35631604b1STomasz Sapeta#endif 36631604b1STomasz Sapeta 37a5a9f97fSStanisław Chmiela@implementation EXScopedModuleRegistryAdapter 38a5a9f97fSStanisław Chmiela 39efd75decSTomasz Sapeta- (EXModuleRegistry *)moduleRegistryForParams:(NSDictionary *)params 40167fd314SWill Schurman forExperienceStableLegacyId:(NSString *)experienceStableLegacyId 41167fd314SWill Schurman scopeKey:(NSString *)scopeKey 4250661f5cSWill Schurman manifest:(EXManifestsManifest *)manifest 43167fd314SWill Schurman withKernelServices:(NSDictionary *)kernelServices 44a5a9f97fSStanisław Chmiela{ 45efd75decSTomasz Sapeta EXModuleRegistry *moduleRegistry = [self.moduleRegistryProvider moduleRegistry]; 46a5a9f97fSStanisław Chmiela 4792e817a0SEric Samelson#if __has_include(<EXUpdates/EXUpdatesService.h>) 48167fd314SWill Schurman EXUpdatesBinding *updatesBinding = [[EXUpdatesBinding alloc] initWithScopeKey:scopeKey 49167fd314SWill Schurman updatesKernelService:kernelServices[EX_UNVERSIONED(@"EXUpdatesManager")] 50167fd314SWill Schurman databaseKernelService:kernelServices[EX_UNVERSIONED(@"EXUpdatesDatabaseManager")]]; 5192e817a0SEric Samelson [moduleRegistry registerInternalModule:updatesBinding]; 5292e817a0SEric Samelson#endif 5392e817a0SEric Samelson 54631604b1STomasz Sapeta#if __has_include(<EXConstants/EXConstantsService.h>) 55167fd314SWill Schurman EXConstantsBinding *constantsBinding = [[EXConstantsBinding alloc] initWithParams:params]; 56712e5c6cSSzymon20000 [moduleRegistry registerInternalModule:constantsBinding]; 57631604b1STomasz Sapeta#endif 58712e5c6cSSzymon20000 590ff9a3f7SStanisław Chmiela#if __has_include(<EXFacebook/EXFacebook.h>) 60dc898499SJames Ide // only override in Expo Go 610ff9a3f7SStanisław Chmiela if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 622615299dSWill Schurman EXScopedFacebook *scopedFacebook = [[EXScopedFacebook alloc] initWithScopeKey:scopeKey manifest:manifest]; 630ff9a3f7SStanisław Chmiela [moduleRegistry registerExportedModule:scopedFacebook]; 640ff9a3f7SStanisław Chmiela } 650ff9a3f7SStanisław Chmiela#endif 660ff9a3f7SStanisław Chmiela 67*51e273e0STomasz Sapeta#if __has_include(<ExpoFileSystem/EXFileSystem.h>) 68e61ddc0cSStanisław Chmiela EXScopedFileSystemModule *fileSystemModule; 69e61ddc0cSStanisław Chmiela if (params[@"fileSystemDirectories"]) { 70e61ddc0cSStanisław Chmiela NSString *documentDirectory = params[@"fileSystemDirectories"][@"documentDirectory"]; 71e61ddc0cSStanisław Chmiela NSString *cachesDirectory = params[@"fileSystemDirectories"][@"cachesDirectory"]; 72e61ddc0cSStanisław Chmiela fileSystemModule = [[EXScopedFileSystemModule alloc] initWithDocumentDirectory:documentDirectory 73e61ddc0cSStanisław Chmiela cachesDirectory:cachesDirectory 74e61ddc0cSStanisław Chmiela bundleDirectory:nil]; 75e61ddc0cSStanisław Chmiela } else { 76e61ddc0cSStanisław Chmiela fileSystemModule = [EXScopedFileSystemModule new]; 77e61ddc0cSStanisław Chmiela } 78712e5c6cSSzymon20000 [moduleRegistry registerExportedModule:fileSystemModule]; 79da9af05cSTomasz Sapeta [moduleRegistry registerInternalModule:fileSystemModule]; 80631604b1STomasz Sapeta#endif 81712e5c6cSSzymon20000 827327b9ddSBrent Vatne#if __has_include(<EXFont/EXFontLoader.h>) 837327b9ddSBrent Vatne EXScopedFontLoader *fontModule = [[EXScopedFontLoader alloc] init]; 847327b9ddSBrent Vatne [moduleRegistry registerExportedModule:fontModule]; 857327b9ddSBrent Vatne#endif 867327b9ddSBrent Vatne 87631604b1STomasz Sapeta#if __has_include(<EXSensors/EXSensorsManager.h>) 88167fd314SWill Schurman EXSensorsManagerBinding *sensorsManagerBinding = [[EXSensorsManagerBinding alloc] initWithScopeKey:scopeKey andKernelService:kernelServices[EX_UNVERSIONED(@"EXSensorManager")]]; 89a5a9f97fSStanisław Chmiela [moduleRegistry registerInternalModule:sensorsManagerBinding]; 90631604b1STomasz Sapeta#endif 91a5a9f97fSStanisław Chmiela 92e9ab9323SStanisław Chmiela EXScopedReactNativeAdapter *reactNativeAdapter = [[EXScopedReactNativeAdapter alloc] init]; 93e9ab9323SStanisław Chmiela [moduleRegistry registerInternalModule:reactNativeAdapter]; 94e9ab9323SStanisław Chmiela 95c6e11a07SStanisław Chmiela EXExpoUserNotificationCenterProxy *userNotificationCenter = [[EXExpoUserNotificationCenterProxy alloc] initWithUserNotificationCenter:kernelServices[EX_UNVERSIONED(@"EXUserNotificationCenter")]]; 967100de8cSSzymon20000 [moduleRegistry registerInternalModule:userNotificationCenter]; 977100de8cSSzymon20000 98*51e273e0STomasz Sapeta#if __has_include(<ExpoFileSystem/EXFilePermissionModule.h>) 99d1fb9868SSzymon20000 EXScopedFilePermissionModule *filePermissionModule = [[EXScopedFilePermissionModule alloc] init]; 100d1fb9868SSzymon20000 [moduleRegistry registerInternalModule:filePermissionModule]; 101631604b1STomasz Sapeta#endif 102d1fb9868SSzymon20000 103631604b1STomasz Sapeta#if __has_include(<EXSecureStore/EXSecureStore.h>) 104167fd314SWill Schurman EXScopedSecureStore *secureStoreModule = [[EXScopedSecureStore alloc] initWithScopeKey:scopeKey andConstantsBinding:constantsBinding]; 105c9802ebaSStanisław Chmiela [moduleRegistry registerExportedModule:secureStoreModule]; 106631604b1STomasz Sapeta#endif 107c9802ebaSStanisław Chmiela 108efd75decSTomasz Sapeta#if __has_include(<ExpoModulesCore/EXPermissionsService.h>) 109167fd314SWill Schurman EXScopedPermissions *permissionsModule = [[EXScopedPermissions alloc] initWithScopeKey:scopeKey andConstantsBinding:constantsBinding]; 110c9802ebaSStanisław Chmiela [moduleRegistry registerExportedModule:permissionsModule]; 111c9802ebaSStanisław Chmiela [moduleRegistry registerInternalModule:permissionsModule]; 112631604b1STomasz Sapeta#endif 113c9802ebaSStanisław Chmiela 114631604b1STomasz Sapeta#if __has_include(<EXSegment/EXSegment.h>) 11504f8f9ecSTomasz Sapeta EXScopedSegment *segmentModule = [[EXScopedSegment alloc] init]; 11604f8f9ecSTomasz Sapeta [moduleRegistry registerExportedModule:segmentModule]; 117631604b1STomasz Sapeta#endif 11804f8f9ecSTomasz Sapeta 119636b55abSStanisław Chmiela#if __has_include(<EXBranch/RNBranch.h>) 120167fd314SWill Schurman EXScopedBranch *branchModule = [[EXScopedBranch alloc] initWithScopeKey:scopeKey]; 121636b55abSStanisław Chmiela [moduleRegistry registerInternalModule:branchModule]; 122636b55abSStanisław Chmiela#endif 123636b55abSStanisław Chmiela 124631604b1STomasz Sapeta#if __has_include(<EXLocalAuthentication/EXLocalAuthentication.h>) 125631604b1STomasz Sapeta EXScopedLocalAuthentication *localAuthenticationModule = [[EXScopedLocalAuthentication alloc] init]; 126631604b1STomasz Sapeta [moduleRegistry registerExportedModule:localAuthenticationModule]; 127631604b1STomasz Sapeta#endif 128631604b1STomasz Sapeta 129631604b1STomasz Sapeta#if __has_include(<EXTaskManager/EXTaskManager.h>) 130515bbe1aSTomasz Sapeta // TODO: Make scoped task manager when adding support for bare React Native 131167fd314SWill Schurman EXTaskManager *taskManagerModule = [[EXTaskManager alloc] initWithScopeKey:scopeKey]; 132515bbe1aSTomasz Sapeta [moduleRegistry registerInternalModule:taskManagerModule]; 133515bbe1aSTomasz Sapeta [moduleRegistry registerExportedModule:taskManagerModule]; 134631604b1STomasz Sapeta#endif 135515bbe1aSTomasz Sapeta 1360f064ba0SŁukasz Kosmaty#if __has_include(<EXErrorRecovery/EXErrorRecoveryModule.h>) 137167fd314SWill Schurman EXScopedErrorRecoveryModule *errorRecovery = [[EXScopedErrorRecoveryModule alloc] initWithScopeKey:scopeKey]; 1380f064ba0SŁukasz Kosmaty [moduleRegistry registerExportedModule:errorRecovery]; 1390f064ba0SŁukasz Kosmaty#endif 1400f064ba0SŁukasz Kosmaty 141776d46faSHein Rutjes#if __has_include(<EXFirebaseCore/EXFirebaseCore.h>) 14245f3e3b4SWill Schurman EXScopedFirebaseCore *firebaseCoreModule = [[EXScopedFirebaseCore alloc] initWithScopeKey:scopeKey manifest:manifest constantsBinding:constantsBinding]; 143776d46faSHein Rutjes [moduleRegistry registerExportedModule:firebaseCoreModule]; 144776d46faSHein Rutjes [moduleRegistry registerInternalModule:firebaseCoreModule]; 145776d46faSHein Rutjes#endif 146776d46faSHein Rutjes 147e62fb1d4SŁukasz Kosmaty#if __has_include(<EXNotifications/EXNotificationsEmitter.h>) 148d044143fSCharlie Cruzan // only override in Expo Go 149d044143fSCharlie Cruzan if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 150167fd314SWill Schurman EXScopedNotificationsEmitter *notificationsEmmitter = [[EXScopedNotificationsEmitter alloc] initWithScopeKey:scopeKey]; 151e62fb1d4SŁukasz Kosmaty [moduleRegistry registerExportedModule:notificationsEmmitter]; 152d044143fSCharlie Cruzan } 153e62fb1d4SŁukasz Kosmaty#endif 15444bbe92dSŁukasz Kosmaty 15544bbe92dSŁukasz Kosmaty#if __has_include(<EXNotifications/EXNotificationsHandlerModule.h>) 156d044143fSCharlie Cruzan // only override in Expo Go 157d044143fSCharlie Cruzan if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 158167fd314SWill Schurman EXScopedNotificationsHandlerModule *notificationsHandler = [[EXScopedNotificationsHandlerModule alloc] initWithScopeKey:scopeKey]; 15944bbe92dSŁukasz Kosmaty [moduleRegistry registerExportedModule:notificationsHandler]; 160d044143fSCharlie Cruzan } 16144bbe92dSŁukasz Kosmaty#endif 16244bbe92dSŁukasz Kosmaty 16344bbe92dSŁukasz Kosmaty#if __has_include(<EXNotifications/EXNotificationsHandlerModule.h>) 164167fd314SWill Schurman EXScopedNotificationBuilder *notificationsBuilder = [[EXScopedNotificationBuilder alloc] initWithScopeKey:scopeKey 165167fd314SWill Schurman andConstantsBinding:constantsBinding]; 16644bbe92dSŁukasz Kosmaty [moduleRegistry registerInternalModule:notificationsBuilder]; 16744bbe92dSŁukasz Kosmaty#endif 1680f9680e4SŁukasz Kosmaty 1690f9680e4SŁukasz Kosmaty#if __has_include(<EXNotifications/EXNotificationSchedulerModule.h>) 1707228d0b7SCharlie Cruzan // only override in Expo Go 1717228d0b7SCharlie Cruzan if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 172167fd314SWill Schurman EXScopedNotificationSchedulerModule *schedulerModule = [[EXScopedNotificationSchedulerModule alloc] initWithScopeKey:scopeKey]; 1730f9680e4SŁukasz Kosmaty [moduleRegistry registerExportedModule:schedulerModule]; 1747228d0b7SCharlie Cruzan } 1750f9680e4SŁukasz Kosmaty#endif 176bfb365deSŁukasz Kosmaty 177bfb365deSŁukasz Kosmaty#if __has_include(<EXNotifications/EXNotificationPresentationModule.h>) 178d044143fSCharlie Cruzan // only override in Expo Go 179d044143fSCharlie Cruzan if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 180167fd314SWill Schurman EXScopedNotificationPresentationModule *notificationPresentationModule = [[EXScopedNotificationPresentationModule alloc] initWithScopeKey:scopeKey]; 181bfb365deSŁukasz Kosmaty [moduleRegistry registerExportedModule:notificationPresentationModule]; 182d044143fSCharlie Cruzan } 183bfb365deSŁukasz Kosmaty#endif 184f6562485SCharlie Cruzan 185f6562485SCharlie Cruzan#if __has_include(<EXNotifications/EXNotificationCategoriesModule.h>) 1867228d0b7SCharlie Cruzan // only override in Expo Go 1877228d0b7SCharlie Cruzan if ([params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]) { 188f7824892SWill Schurman EXScopedNotificationCategoriesModule *scopedCategoriesModule = [[EXScopedNotificationCategoriesModule alloc] initWithScopeKey:scopeKey]; 1897228d0b7SCharlie Cruzan [moduleRegistry registerExportedModule:scopedCategoriesModule]; 1907228d0b7SCharlie Cruzan } 191167fd314SWill Schurman [EXScopedNotificationCategoriesModule maybeMigrateLegacyCategoryIdentifiersForProjectWithExperienceStableLegacyId:experienceStableLegacyId 192167fd314SWill Schurman scopeKey:scopeKey 1937228d0b7SCharlie Cruzan isInExpoGo:[params[@"constants"][@"appOwnership"] isEqualToString:@"expo"]]; 194f6562485SCharlie Cruzan#endif 19542300cfbSStanisław Chmiela 19698629a0cSStanisław Chmiela#if __has_include(<EXNotifications/EXServerRegistrationModule.h>) 197167fd314SWill Schurman EXScopedServerRegistrationModule *serverRegistrationModule = [[EXScopedServerRegistrationModule alloc] initWithScopeKey:scopeKey]; 19898629a0cSStanisław Chmiela [moduleRegistry registerExportedModule:serverRegistrationModule]; 19998629a0cSStanisław Chmiela#endif 20098629a0cSStanisław Chmiela 201c9802ebaSStanisław Chmiela return moduleRegistry; 202a5a9f97fSStanisław Chmiela} 203a5a9f97fSStanisław Chmiela 204a5a9f97fSStanisław Chmiela@end 205