|
5 | 5 |
|
6 | 6 | @interface ReactNativeFs : RCTEventEmitter <NativeReactNativeFsSpec>
|
7 | 7 | #else
|
8 |
| -#import <React/RCTBridgeModule.h> |
| 8 | +#import <optional> |
| 9 | +#import <React/RCTCxxConvert.h> |
| 10 | +#import <React/RCTManagedPointer.h> |
| 11 | + |
| 12 | +// These are automatically generated by RN Codegen when using the New Arch, |
| 13 | +// however for the backward compatibility to the Old Arch we need to provide |
| 14 | +// these ourselves. |
| 15 | +namespace JS { |
| 16 | + namespace NativeReactNativeFs { |
| 17 | + struct FileOptions { |
| 18 | + NSString *NSFileProtectionKey() const { |
| 19 | + return _v[@"NSFileProtectionKey"]; |
| 20 | + }; |
| 21 | + FileOptions(NSDictionary *const v) : _v(v) {} |
| 22 | + private: |
| 23 | + NSDictionary *_v; |
| 24 | + }; |
| 25 | + |
| 26 | + struct MkdirOptions { |
| 27 | + std::optional<bool> NSURLIsExcludedFromBackupKey() const { |
| 28 | + return _v[@"NSURLIsExcludedFromBackupKey"]; |
| 29 | + } |
| 30 | + NSString *NSFileProtectionKey() const { |
| 31 | + return _v[@"NSFileProtectionKey"]; |
| 32 | + } |
| 33 | + |
| 34 | + MkdirOptions(NSDictionary *const v) : _v(v) {} |
| 35 | + private: |
| 36 | + NSDictionary *_v; |
| 37 | + }; |
| 38 | + |
| 39 | + struct NativeDownloadFileOptions { |
| 40 | + double jobId() const { return [_v[@"jobId"] doubleValue]; } |
| 41 | + NSString *fromUrl() const { return _v[@"fromUrl"]; } |
| 42 | + NSString *toFile() const { return _v[@"toFile"]; } |
| 43 | + bool background() const { return _v[@"background"]; } |
| 44 | + double backgroundTimeout() const { return [_v[@"backgroundTimeout"] doubleValue]; } |
| 45 | + bool cacheable() const { return _v[@"cacheable"]; } |
| 46 | + double connectionTimeout() const { return [_v[@"connectionTimeout"] doubleValue]; } |
| 47 | + bool discretionary() const { return _v[@"discretionary"]; } |
| 48 | + id<NSObject> headers() const { return _v[@"headers"]; } |
| 49 | + double progressDivider() const { return [_v[@"progressDivider"] doubleValue]; } |
| 50 | + double progressInterval() const { return [_v[@"progressInterval"] doubleValue]; } |
| 51 | + double readTimeout() const { return [_v[@"readTimeout"] doubleValue]; } |
| 52 | + bool hasBeginCallback() const { return _v[@"hasBeginCallback"]; } |
| 53 | + bool hasProgressCallback() const { return _v[@"hasProgressCallback"]; } |
| 54 | + bool hasResumableCallback() const { return _v[@"hasResumableCallback"]; } |
| 55 | + |
| 56 | + NativeDownloadFileOptions(NSDictionary *const v) : _v(v) {} |
| 57 | + private: |
| 58 | + NSDictionary *_v; |
| 59 | + }; |
| 60 | + |
| 61 | + typedef NSDictionary NativeUploadFileOptions; |
| 62 | + typedef NSDictionary TouchOptions; |
| 63 | + |
| 64 | + /* |
| 65 | + struct UploadFileItem { |
| 66 | + NSString *name() const; |
| 67 | + NSString *filename() const; |
| 68 | + NSString *filepath() const; |
| 69 | + NSString *filetype() const; |
| 70 | +
|
| 71 | + UploadFileItem(NSDictionary *const v) : _v(v) {} |
| 72 | + private: |
| 73 | + NSDictionary *_v; |
| 74 | + }; |
| 75 | +
|
| 76 | + template <typename T> |
| 77 | + using LazyVector = FB::LazyVector<T,id>; |
| 78 | +
|
| 79 | + struct NativeUploadFileOptions { |
| 80 | + NSString *toUrl() const; |
| 81 | + std::optional<bool> binaryStreamOnly() const; |
| 82 | + LazyVector<UploadFileItem> files() const; |
| 83 | + id<NSObject> _Nullable headers() const; |
| 84 | + id<NSObject> _Nullable fields() const; |
| 85 | + NSString *method() const; |
| 86 | +
|
| 87 | + NativeUploadFileOptions(NSDictionary *const v) : _v(v) {} |
| 88 | + private: |
| 89 | + NSDictionary *_v; |
| 90 | + }; |
| 91 | +
|
| 92 | + struct TouchOptions { |
| 93 | + std::optional<double> ctime() const; |
| 94 | + std::optional<double> mtime() const; |
| 95 | +
|
| 96 | + TouchOptions(NSDictionary *const v) : _v(v) {} |
| 97 | + private: |
| 98 | + NSDictionary *_v; |
| 99 | + }; |
| 100 | + */ |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +@implementation RCTCxxConvert (NativeReactNativeFs_FileOptions) |
| 105 | ++ (RCTManagedPointer *)JS_NativeReactNativeFs_FileOptions:(id)json |
| 106 | +{ |
| 107 | + return facebook::react::managedPointer<JS::NativeReactNativeFs::FileOptions>(json); |
| 108 | +} |
| 109 | +@end |
| 110 | +@implementation RCTCxxConvert (NativeReactNativeFs_MkdirOptions) |
| 111 | ++ (RCTManagedPointer *)JS_NativeReactNativeFs_MkdirOptions:(id)json |
| 112 | +{ |
| 113 | + return facebook::react::managedPointer<JS::NativeReactNativeFs::MkdirOptions>(json); |
| 114 | +} |
| 115 | +@end |
9 | 116 |
|
10 | 117 | @interface ReactNativeFs : RCTEventEmitter <RCTBridgeModule>
|
11 | 118 | #endif
|
|
0 commit comments