81 lines
2.9 KiB
Objective-C
81 lines
2.9 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <React/RCTImageLoaderLoggable.h>
|
|
#import <React/RCTImageLoaderProtocol.h>
|
|
#import <React/RCTImageURLLoader.h>
|
|
|
|
// TODO (T61325135): Remove C++ checks
|
|
#ifdef __cplusplus
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
struct ImageURLLoaderAttribution {
|
|
int32_t nativeViewTag = 0;
|
|
int32_t surfaceId = 0;
|
|
std::string queryRootName;
|
|
NSString *analyticTag;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|
|
#endif
|
|
|
|
@interface RCTImageURLLoaderRequest : NSObject
|
|
|
|
@property (nonatomic, strong, readonly) NSString *requestId;
|
|
@property (nonatomic, strong, readonly) NSURL *imageURL;
|
|
@property (nonatomic, copy, readonly) RCTImageLoaderCancellationBlock cancellationBlock;
|
|
|
|
- (instancetype)initWithRequestId:(NSString *)requestId
|
|
imageURL:(NSURL *)imageURL
|
|
cancellationBlock:(RCTImageLoaderCancellationBlock)cancellationBlock;
|
|
- (void)cancel;
|
|
|
|
@end
|
|
|
|
/**
|
|
* Same as the RCTImageURLLoader interface, but allows passing in optional `attribution` information.
|
|
* This is useful for per-app logging and other instrumentation.
|
|
*/
|
|
@protocol RCTImageURLLoaderWithAttribution <RCTImageURLLoader, RCTImageLoaderLoggable>
|
|
|
|
// TODO (T61325135): Remove C++ checks
|
|
#ifdef __cplusplus
|
|
/**
|
|
* Same as the RCTImageURLLoader variant above, but allows optional `attribution` information.
|
|
* Caller may also specify a preferred requestId for tracking purpose.
|
|
*/
|
|
- (RCTImageURLLoaderRequest *)loadImageForURL:(NSURL *)imageURL
|
|
size:(CGSize)size
|
|
scale:(CGFloat)scale
|
|
resizeMode:(RCTResizeMode)resizeMode
|
|
requestId:(NSString *)requestId
|
|
priority:(RCTImageLoaderPriority)priority
|
|
attribution:(const facebook::react::ImageURLLoaderAttribution &)attribution
|
|
progressHandler:(RCTImageLoaderProgressBlock)progressHandler
|
|
partialLoadHandler:(RCTImageLoaderPartialLoadBlock)partialLoadHandler
|
|
completionHandler:(RCTImageLoaderCompletionBlockWithMetadata)completionHandler;
|
|
#endif
|
|
|
|
/**
|
|
* Image instrumentation - start tracking the on-screen visibility of the native image view.
|
|
*/
|
|
- (void)trackURLImageVisibilityForRequest:(RCTImageURLLoaderRequest *)loaderRequest imageView:(UIView *)imageView;
|
|
|
|
/**
|
|
* Image instrumentation - notify that the request was destroyed.
|
|
*/
|
|
- (void)trackURLImageRequestDidDestroy:(RCTImageURLLoaderRequest *)loaderRequest;
|
|
|
|
/**
|
|
* Image instrumentation - notify that the native image view was destroyed.
|
|
*/
|
|
- (void)trackURLImageDidDestroy:(RCTImageURLLoaderRequest *)loaderRequest;
|
|
|
|
@end
|