xref: /expo/ios/Exponent/Kernel/Core/EXKernel.h (revision 489c2041)
1 // Copyright 2015-present 650 Industries. All rights reserved.
2 
3 #import <UIKit/UIKit.h>
4 
5 #import "EXAppBrowserController.h"
6 #import "EXKernelAppRegistry.h"
7 #import "EXKernelServiceRegistry.h"
8 #import "EXKernelUtil.h"
9 #import "EXViewController.h"
10 
11 NS_ASSUME_NONNULL_BEGIN
12 
13 FOUNDATION_EXPORT NSString *kEXKernelErrorDomain;
14 
15 typedef NS_ENUM(NSInteger, EXKernelErrorCode) {
16   EXKernelErrorCodeModuleDeallocated,
17 };
18 
19 @interface EXKernel : NSObject <EXViewControllerDelegate>
20 
21 @property (nonatomic, strong, readonly) EXKernelAppRegistry *appRegistry;
22 @property (nonatomic, strong, readonly) EXKernelServiceRegistry *serviceRegistry;
23 @property (nonatomic, readonly) EXKernelAppRecord *visibleApp;
24 @property (nonatomic, assign) id<EXAppBrowserController> browserController;
25 
26 + (instancetype)sharedInstance;
27 
28 - (EXKernelAppRecord *)createNewAppWithUrl:(NSURL *)url initialProps:(nullable NSDictionary *)initialProps;
29 - (void)switchTasks;
30 - (void)reloadAppWithScopeKey:(NSString *)scopeKey; // called by Updates.reload
31 - (void)reloadAppFromCacheWithScopeKey:(NSString *)scopeKey; // called by Updates.reloadFromCache
32 - (void)reloadVisibleApp; // called in development whenever the app is reloaded
33 
34 /**
35  *  Initial props to pass to an app based on LaunchOptions from UIApplicationDelegate.
36  */
37 - (nullable NSDictionary *)initialAppPropsFromLaunchOptions:(NSDictionary *)launchOptions;
38 
39 /**
40  *  Find and return the (potentially versioned) native module instance belonging to the
41  *  specified app manager. Module name is the exported name such as @"AppState".
42  */
43 - (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName;
44 
45 /**
46  *  Send the given url to this app (via the RN Linking module) and foreground it.
47  */
48 - (void)sendUrl:(NSString *)url toAppRecord:(EXKernelAppRecord *)app;
49 
50 @end
51 
52 NS_ASSUME_NONNULL_END
53