Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nullable annotations to RCTBundleURLProvider #42293

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTBridgeDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* When running from a locally bundled JS file, this should be a `file://` url
* pointing to a path inside the app resources, e.g. `file://.../main.jsbundle`.
*/
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge;
- (NSURL *__nullable)sourceURLForBridge:(RCTBridge *)bridge;

@optional

Expand Down
32 changes: 18 additions & 14 deletions packages/react-native/React/Base/RCTBundleURLProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import "RCTDefines.h"

RCT_EXTERN NSString *const RCTBundleURLProviderUpdatedNotification;
RCT_EXTERN NSString *_Nonnull const RCTBundleURLProviderUpdatedNotification;
RCT_EXTERN const NSUInteger kRCTBundleURLProviderDefaultPort;

#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
Expand All @@ -22,6 +22,8 @@ RCT_EXTERN const NSUInteger kRCTBundleURLProviderDefaultPort;
RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed);
#endif

NS_ASSUME_NONNULL_BEGIN

@interface RCTBundleURLProvider : NSObject

/**
Expand Down Expand Up @@ -52,44 +54,44 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed);
* The port is optional, if not specified, kRCTBundleURLProviderDefaultPort will be used
* The scheme is also optional, if not specified, a default http protocol will be used
*/
+ (BOOL)isPackagerRunning:(NSString *)hostPort scheme:(NSString *)scheme;
+ (BOOL)isPackagerRunning:(NSString *)hostPort scheme:(NSString *__nullable)scheme;

/**
* Returns the jsBundleURL for a given bundle entrypoint and
* the fallback offline JS bundle if the packager is not running.
*/
- (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackURLProvider:(NSURL * (^)(void))fallbackURLProvider;
- (NSURL *__nullable)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackURLProvider:(NSURL *__nullable (^)(void))fallbackURLProvider;

/**
* Returns the jsBundleURL for a given split bundle entrypoint in development
*/
- (NSURL *)jsBundleURLForSplitBundleRoot:(NSString *)bundleRoot;
- (NSURL *__nullable)jsBundleURLForSplitBundleRoot:(NSString *)bundleRoot;

/**
* Returns the jsBundleURL for a given bundle entrypoint and
* the fallback offline JS bundle if the packager is not running.
* if extension is nil, "jsbundle" will be used.
*/
- (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackExtension:(NSString *)extension;
- (NSURL *__nullable)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackExtension:(NSString *__nullable)extension;

/**
* Returns the jsBundleURL for a given bundle entrypoint and
* the fallback offline JS bundle if the packager is not running.
*/
- (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot;
- (NSURL *__nullable)jsBundleURLForBundleRoot:(NSString *)bundleRoot;

/**
* Returns the jsBundleURL for a given bundle entrypoint and
* the fallback offline JS bundle. If extension is nil,
* "jsbundle" will be used.
*/
- (NSURL *)jsBundleURLForFallbackExtension:(NSString *)extension;
- (NSURL *__nullable)jsBundleURLForFallbackExtension:(NSString *)extension;

/**
* Returns the resourceURL for a given bundle entrypoint and
* the fallback offline resource file if the packager is not running.
*/
- (NSURL *)resourceURLForResourceRoot:(NSString *)root
- (NSURL *__nullable)resourceURLForResourceRoot:(NSString *)root
resourceName:(NSString *)name
resourceExtension:(NSString *)extension
offlineBundle:(NSBundle *)offlineBundle;
Expand Down Expand Up @@ -124,15 +126,15 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed);
* - runModule: When true, will run the main module after defining all modules. This is used in the main bundle but not
* in split bundles.
*/
+ (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
+ (NSURL *__nullable)jsBundleURLForBundleRoot:(NSString *)bundleRoot
packagerHost:(NSString *)packagerHost
enableDev:(BOOL)enableDev
enableMinification:(BOOL)enableMinification
inlineSourceMap:(BOOL)inlineSourceMap;

+ (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
+ (NSURL *__nullable)jsBundleURLForBundleRoot:(NSString *)bundleRoot
packagerHost:(NSString *)packagerHost
packagerScheme:(NSString *)scheme
packagerScheme:(NSString *__nullable)scheme
enableDev:(BOOL)enableDev
enableMinification:(BOOL)enableMinification
inlineSourceMap:(BOOL)inlineSourceMap
Expand All @@ -145,8 +147,8 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed);
*/
+ (NSURL *)resourceURLForResourcePath:(NSString *)path
packagerHost:(NSString *)packagerHost
scheme:(NSString *)scheme
query:(NSString *)query
scheme:(NSString *__nullable)scheme
query:(NSString *__nullable)query
__deprecated_msg("Use version with queryItems parameter instead");

/**
Expand All @@ -157,6 +159,8 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed);
+ (NSURL *)resourceURLForResourcePath:(NSString *)path
packagerHost:(NSString *)packagerHost
scheme:(NSString *)scheme
queryItems:(NSArray<NSURLQueryItem *> *)queryItems;
queryItems:(NSArray<NSURLQueryItem *> *__nullable)queryItems;

@end

NS_ASSUME_NONNULL_END
Loading