1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 #import <Foundation/Foundation.h> 4 5 #import "EXResourceLoader.h" 6 7 NS_ASSUME_NONNULL_BEGIN 8 9 @interface EXCachedResource : NSObject <EXResourceLoader> 10 11 @property (nonatomic, readonly) NSString *resourceName; 12 @property (nonatomic, strong) NSURL *remoteUrl; 13 @property (nonatomic, assign) BOOL shouldVersionCache; 14 @property (nonatomic, strong, nullable) NSString *abiVersion; 15 @property (nonatomic, strong) NSURLCache *urlCache; 16 @property (nonatomic, assign) NSTimeInterval requestTimeoutInterval; 17 @property (nonatomic, strong, nullable) NSString *releaseChannel; 18 19 - (instancetype)initWithResourceName:(NSString *)resourceName 20 resourceType:(NSString *)resourceType 21 remoteUrl:(NSURL *)url 22 cachePath:(NSString * _Nullable)cachePath; 23 24 /** 25 * Filesystem path to the downloaded and cached copy of this resource. 26 */ 27 - (NSString *)resourceCachePath; 28 /** 29 * NSBundle path to the embedded copy of this resource. 30 */ 31 - (NSString *)resourceBundlePath; 32 /** 33 * Indicates whether or not local copies of this resource are loaded from the NSBundle 34 * rather than the cache. 35 */ 36 - (BOOL)isUsingEmbeddedResource; 37 38 - (NSError *)_validateResponseData:(NSData *)data response:(NSURLResponse *)response; 39 - (NSError *)_validateErrorData:(NSError *)error response:(NSURLResponse *)response; 40 41 /** 42 * Returns whether a cache was removed. 43 */ 44 - (BOOL)removeCache; 45 46 /** 47 * Creates cache directory with the given name and returns path. 48 * In Expo Go this uses NSCachesDirectory, whereas in 49 * shell apps it uses NSApplicationSupportDirectory. 50 */ 51 + (NSString *)cachePathWithName:(NSString *)cacheName; 52 53 @end 54 55 NS_ASSUME_NONNULL_END 56