first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <ExpoModulesCore/Platform.h>
NS_ASSUME_NONNULL_BEGIN
@class EXReactDelegate;
/**
A wrapper of `ExpoReactDelegate` for Objective-C bindings.
*/
@interface EXReactDelegateWrapper : NSObject
- (instancetype)initWithExpoReactDelegate:(EXReactDelegate *)expoReactDelegate;
- (UIView *)createReactRootView:(NSString *)moduleName
initialProperties:(nullable NSDictionary *)initialProperties
launchOptions:(nullable NSDictionary *)launchOptions;
- (NSURL *)bundleURL;
- (UIViewController *)createRootViewController;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,41 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <ExpoModulesCore/EXReactDelegateWrapper.h>
#import <ExpoModulesCore/Swift.h>
@interface EXReactDelegateWrapper()
@property (nonatomic, weak) EXReactDelegate *expoReactDelegate;
@end
@implementation EXReactDelegateWrapper
- (instancetype)initWithExpoReactDelegate:(EXReactDelegate *)expoReactDelegate
{
if (self = [super init]) {
_expoReactDelegate = expoReactDelegate;
}
return self;
}
- (UIView *)createReactRootView:(NSString *)moduleName
initialProperties:(nullable NSDictionary *)initialProperties
launchOptions:(nullable NSDictionary *)launchOptions
{
return [_expoReactDelegate createReactRootViewWithModuleName:moduleName
initialProperties:initialProperties
launchOptions:launchOptions];
}
- (NSURL *)bundleURL
{
return [_expoReactDelegate bundleURL];
}
- (UIViewController *)createRootViewController
{
return [_expoReactDelegate createRootViewController];
}
@end

View File

@@ -0,0 +1,43 @@
// Copyright 2018-present 650 Industries. All rights reserved.
/**
An extensible react instance creation delegate. This class will loop through each `ExpoReactDelegateHandler` to determine the winner to create the instance.
*/
@objc(EXReactDelegate)
public class ExpoReactDelegate: NSObject {
private let handlers: [ExpoReactDelegateHandler]
public let reactNativeFactory: ExpoReactNativeFactoryProtocol
public init(handlers: [ExpoReactDelegateHandler], reactNativeFactory: ExpoReactNativeFactoryProtocol) {
self.handlers = handlers
self.reactNativeFactory = reactNativeFactory
}
@objc
public func createReactRootView(
moduleName: String,
initialProperties: [AnyHashable: Any]?,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> UIView {
return self.handlers
.compactMap { $0.createReactRootView(reactDelegate: self, moduleName: moduleName, initialProperties: initialProperties, launchOptions: launchOptions) }
.first(where: { _ in true })
?? {
return reactNativeFactory.recreateRootView(withBundleURL: nil, moduleName: moduleName, initialProps: initialProperties, launchOptions: launchOptions)
}()
}
@objc
public func bundleURL() -> URL? {
return self.handlers.lazy
.compactMap { $0.bundleURL(reactDelegate: self) }
.first(where: { _ in true })
}
@objc
public func createRootViewController() -> UIViewController {
return self.handlers.lazy
.compactMap { $0.createRootViewController() }
.first(where: { _ in true }) ?? UIViewController()
}
}

View File

@@ -0,0 +1,41 @@
// Copyright 2018-present 650 Industries. All rights reserved.
/**
The handler for `ExpoReactDelegate`. A module can implement a handler to process react instance creation.
*/
@objc(EXReactDelegateHandler)
open class ExpoReactDelegateHandler: NSObject {
public override required init() {}
/**
If this module wants to handle React instance and the root view creation, it can return the instance.
Otherwise return nil.
*/
@objc
open func createReactRootView(
reactDelegate: ExpoReactDelegate,
moduleName: String,
initialProperties: [AnyHashable: Any]?,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> UIView? {
return nil
}
/**
Clients could override this getter to serve the latest bundleURL for React instance.
For example, expo-updates uses this to serve the newer bundleURL from `Updates.reloadAsync()`.
*/
@objc
open func bundleURL(reactDelegate: ExpoReactDelegate) -> URL? {
return nil
}
/**
If this module wants to handle `UIViewController` creation for `RCTRootView`, it can return the instance.
Otherwise return nil.
*/
@objc
open func createRootViewController() -> UIViewController? {
return nil
}
}