2015-04-19 19:55:46 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-04-02 14:33:21 +00:00
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTDefines.h>
|
2016-11-01 17:14:00 +00:00
|
|
|
|
2016-07-12 12:13:32 +00:00
|
|
|
extern NSString *const RCTJavaScriptLoaderErrorDomain;
|
|
|
|
|
|
|
|
NS_ENUM(NSInteger) {
|
|
|
|
RCTJavaScriptLoaderErrorNoScriptURL = 1,
|
|
|
|
RCTJavaScriptLoaderErrorFailedOpeningFile = 2,
|
|
|
|
RCTJavaScriptLoaderErrorFailedReadingFile = 3,
|
|
|
|
RCTJavaScriptLoaderErrorFailedStatingFile = 3,
|
|
|
|
RCTJavaScriptLoaderErrorURLLoadFailed = 3,
|
2016-11-11 13:21:37 +00:00
|
|
|
RCTJavaScriptLoaderErrorBCVersion = 4,
|
2017-01-12 06:28:07 +00:00
|
|
|
RCTJavaScriptLoaderErrorBCNotSupported = 4,
|
2016-07-12 12:13:32 +00:00
|
|
|
|
|
|
|
RCTJavaScriptLoaderErrorCannotBeLoadedSynchronously = 1000,
|
|
|
|
};
|
|
|
|
|
2016-10-13 18:42:30 +00:00
|
|
|
@interface RCTLoadingProgress : NSObject
|
|
|
|
|
|
|
|
@property (nonatomic, copy) NSString *status;
|
|
|
|
@property (strong, nonatomic) NSNumber *done;
|
|
|
|
@property (strong, nonatomic) NSNumber *total;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
typedef void (^RCTSourceLoadProgressBlock)(RCTLoadingProgress *progressData);
|
2016-07-12 12:13:34 +00:00
|
|
|
typedef void (^RCTSourceLoadBlock)(NSError *error, NSData *source, int64_t sourceLength);
|
2015-04-02 14:33:21 +00:00
|
|
|
|
|
|
|
@interface RCTJavaScriptLoader : NSObject
|
|
|
|
|
2016-10-13 18:42:30 +00:00
|
|
|
+ (void)loadBundleAtURL:(NSURL *)scriptURL onProgress:(RCTSourceLoadProgressBlock)onProgress onComplete:(RCTSourceLoadBlock)onComplete;
|
2016-07-12 12:13:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
* Attempts to synchronously load the script at the given URL. The following two conditions must be met:
|
2016-07-13 23:39:15 +00:00
|
|
|
* 1. It must be a file URL.
|
2016-11-01 17:14:00 +00:00
|
|
|
* 2. It must not point to a text/javascript file.
|
2016-07-12 12:13:32 +00:00
|
|
|
* If the URL does not meet those conditions, this method will return nil and supply an error with the domain
|
|
|
|
* RCTJavaScriptLoaderErrorDomain and the code RCTJavaScriptLoaderErrorCannotBeLoadedSynchronously.
|
|
|
|
*/
|
|
|
|
+ (NSData *)attemptSynchronousLoadOfBundleAtURL:(NSURL *)scriptURL
|
2016-11-11 13:21:37 +00:00
|
|
|
runtimeBCVersion:(int32_t)runtimeBCVersion
|
2016-07-12 12:13:32 +00:00
|
|
|
sourceLength:(int64_t *)sourceLength
|
|
|
|
error:(NSError **)error;
|
2015-04-02 14:33:21 +00:00
|
|
|
|
|
|
|
@end
|