Skip to content

Commit a9e2e03

Browse files
committed
dep types: Use TsFlower for @react-native-camera-roll/camera-roll
1 parent 122315f commit a9e2e03

13 files changed

+241
-2
lines changed

src/lightbox/download.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* @flow strict-local */
22
import { Platform, PermissionsAndroid } from 'react-native';
33
import type { Rationale } from 'react-native/Libraries/PermissionsAndroid/PermissionsAndroid';
4-
// $FlowFixMe[untyped-import] - TODO type this
5-
import CameraRoll from '@react-native-camera-roll/camera-roll';
4+
import { CameraRoll } from '@react-native-camera-roll/camera-roll';
65
import RNFetchBlob from 'rn-fetch-blob';
76
import invariant from 'invariant';
87

tools/tsflower

+4
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ run_only()
170170
run_on_package "${package}"
171171
format_dir "${rootdir}"/types/"${package}"
172172

173+
package=@react-native-camera-roll/camera-roll
174+
run_on_package "${package}"
175+
format_dir "${rootdir}"/types/"${package}"
176+
173177
for package in @react-navigation/{routers,core,native,stack,bottom-tabs,material-top-tabs}; do
174178
run_on_package "${package}"
175179
# TODO(tsflower): skip node_modules when acting on package,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* @flow
2+
* @generated
3+
*/
4+
export * from './lib/typescript/index.js.flow';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
export type GroupTypes =
5+
| 'Album'
6+
| 'All'
7+
| 'Event'
8+
| 'Faces'
9+
| 'Library'
10+
| 'PhotoStream'
11+
| 'SavedPhotos';
12+
export type Include = 'filename' | 'fileSize' | 'location' | 'imageSize' | 'playableDuration';
13+
export type AssetType = 'All' | 'Videos' | 'Photos';
14+
15+
export type GetPhotosParams = {
16+
first: number,
17+
after?: string,
18+
groupTypes?: GroupTypes,
19+
groupName?: string,
20+
assetType?: AssetType,
21+
fromTime?: number,
22+
toTime?: number,
23+
mimeTypes?: Array<string>,
24+
include?: Include[],
25+
...
26+
};
27+
28+
export type PhotoIdentifier = {
29+
node: {
30+
type: string,
31+
group_name: string,
32+
image: {
33+
filename: string | null,
34+
uri: string,
35+
height: number,
36+
width: number,
37+
fileSize: number | null,
38+
playableDuration: number,
39+
...
40+
},
41+
timestamp: number,
42+
location: {
43+
latitude?: number,
44+
longitude?: number,
45+
altitude?: number,
46+
heading?: number,
47+
speed?: number,
48+
...
49+
} | null,
50+
...
51+
},
52+
...
53+
};
54+
55+
export type PhotoConvertionOptions = { convertHeicImages: boolean, ... };
56+
57+
export type PhotoIdentifiersPage = {
58+
edges: Array<PhotoIdentifier>,
59+
page_info: {
60+
has_next_page: boolean,
61+
start_cursor?: string,
62+
end_cursor?: string,
63+
...
64+
},
65+
limited?: boolean,
66+
...
67+
};
68+
69+
export type SaveToCameraRollOptions = {
70+
type?: 'photo' | 'video' | 'auto',
71+
album?: string,
72+
...
73+
};
74+
75+
export type GetAlbumsParams = { assetType?: AssetType, ... };
76+
77+
export type Album = {
78+
title: string,
79+
count: number,
80+
...
81+
};
82+
83+
declare export class CameraRoll {
84+
static GroupTypesOptions: {
85+
Album: string,
86+
All: string,
87+
Event: string,
88+
Faces: string,
89+
Library: string,
90+
PhotoStream: string,
91+
SavedPhotos: string,
92+
...
93+
};
94+
static AssetTypeOptions: {
95+
All: string,
96+
Videos: string,
97+
Photos: string,
98+
...
99+
};
100+
static deletePhotos(photoUris: Array<string>): void;
101+
static save(tag: string, options?: SaveToCameraRollOptions): Promise<string>;
102+
static saveToCameraRoll(tag: string, type?: 'photo' | 'video' | 'auto'): Promise<string>;
103+
static getAlbums(params?: GetAlbumsParams): Promise<Album[]>;
104+
static getParamsWithDefaults(params: GetPhotosParams): GetPhotosParams;
105+
static getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage>;
106+
static iosGetImageDataById(internalID: string, convertHeicImages?: boolean): Promise<PhotoIdentifier>;
107+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
import { NativeEventEmitter } from 'react-native';
5+
export type AccessLevel = 'addOnly' | 'readWrite';
6+
export type CameraRollAuthorizationStatus =
7+
| 'granted'
8+
| 'limited'
9+
| 'denied'
10+
| 'unavailable'
11+
| 'blocked'
12+
| 'not-determined';
13+
declare export var cameraRollEventEmitter: NativeEventEmitter<{| +[string]: mixed |}>;
14+
declare export var iosReadGalleryPermission: (
15+
accessLevel: AccessLevel,
16+
) => Promise<CameraRollAuthorizationStatus>;
17+
declare export var iosRequestReadWriteGalleryPermission: () => Promise<CameraRollAuthorizationStatus>;
18+
declare export var iosRequestAddOnlyGalleryPermission: () => Promise<CameraRollAuthorizationStatus>;
19+
declare export var iosRefreshGallerySelection: () => Promise<boolean>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
declare var _default: any;
5+
export default _default;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
export * from './CameraRoll';
5+
export * from './CameraRollIOSPermission';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* @flow
2+
* @generated by TsFlower
3+
*/
4+
declare var _default: any;
5+
export default _default;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Greg Price <[email protected]>
3+
Date: Tue, 8 Nov 2022 13:00:28 -0800
4+
Subject: [tsflower] camera-roll: Fill in RN's NativeEventEmitter
5+
6+
---
7+
.../camera-roll/lib/typescript/CameraRollIOSPermission.js.flow | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRollIOSPermission.js.flow types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRollIOSPermission.js.flow
11+
index 92bf2a28f..ca282678f 100644
12+
--- types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRollIOSPermission.js.flow
13+
+++ types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRollIOSPermission.js.flow
14+
@@ -10,7 +10,7 @@ export type CameraRollAuthorizationStatus =
15+
| 'unavailable'
16+
| 'blocked'
17+
| 'not-determined';
18+
-declare export var cameraRollEventEmitter: NativeEventEmitter;
19+
+declare export var cameraRollEventEmitter: NativeEventEmitter<{| +[string]: mixed |}>;
20+
declare export var iosReadGalleryPermission: (
21+
accessLevel: AccessLevel,
22+
) => Promise<CameraRollAuthorizationStatus>;
23+
--
24+
2.32.0
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Greg Price <[email protected]>
3+
Date: Tue, 8 Nov 2022 13:02:55 -0800
4+
Subject: [tsflower] camera-roll: Mark statics as static
5+
6+
Seems like TsFlower is just not propagating the `static` modifier.
7+
Should be easy to fix, then.
8+
---
9+
.../lib/typescript/CameraRoll.js.flow | 18 +++++++++---------
10+
1 file changed, 9 insertions(+), 9 deletions(-)
11+
12+
diff --git types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRoll.js.flow types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRoll.js.flow
13+
index 525cabed3..6f6ab12f5 100644
14+
--- types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRoll.js.flow
15+
+++ types/@react-native-camera-roll/camera-roll/lib/typescript/CameraRoll.js.flow
16+
@@ -81,27 +81,27 @@ export type Album = {
17+
};
18+
19+
declare export class CameraRoll {
20+
- GroupTypesOptions: {
21+
+ static GroupTypesOptions: {
22+
Album: string,
23+
All: string,
24+
Event: string,
25+
Faces: string,
26+
Library: string,
27+
PhotoStream: string,
28+
SavedPhotos: string,
29+
...
30+
};
31+
- AssetTypeOptions: {
32+
+ static AssetTypeOptions: {
33+
All: string,
34+
Videos: string,
35+
Photos: string,
36+
...
37+
};
38+
- deletePhotos(photoUris: Array<string>): void;
39+
- save(tag: string, options?: SaveToCameraRollOptions): Promise<string>;
40+
- saveToCameraRoll(tag: string, type?: 'photo' | 'video' | 'auto'): Promise<string>;
41+
- getAlbums(params?: GetAlbumsParams): Promise<Album[]>;
42+
- getParamsWithDefaults(params: GetPhotosParams): GetPhotosParams;
43+
- getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage>;
44+
- iosGetImageDataById(internalID: string, convertHeicImages?: boolean): Promise<PhotoIdentifier>;
45+
+ static deletePhotos(photoUris: Array<string>): void;
46+
+ static save(tag: string, options?: SaveToCameraRollOptions): Promise<string>;
47+
+ static saveToCameraRoll(tag: string, type?: 'photo' | 'video' | 'auto'): Promise<string>;
48+
+ static getAlbums(params?: GetAlbumsParams): Promise<Album[]>;
49+
+ static getParamsWithDefaults(params: GetPhotosParams): GetPhotosParams;
50+
+ static getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage>;
51+
+ static iosGetImageDataById(internalID: string, convertHeicImages?: boolean): Promise<PhotoIdentifier>;
52+
}
53+
--
54+
2.32.0
55+

0 commit comments

Comments
 (0)