Skip to content

Commit de667ff

Browse files
fkgozalifacebook-github-bot
authored andcommitted
Moved some NativeModule JS specs to OSS
Summary: For some reason the specs were internal, but the native impl is still in github. So let's move these to github for consistency. Changelog: [Internal] Reviewed By: hramos Differential Revision: D21419934 fbshipit-source-id: f2c4486edca43c4348f3a3c6ce98f76a322bab0b
1 parent 41f0d9b commit de667ff

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
3+
*
4+
* @flow strict-local
5+
* @format
6+
*/
7+
8+
'use strict';
9+
10+
import type {TurboModule} from '../TurboModule/RCTExport';
11+
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
12+
13+
export type PhotoIdentifier = {|
14+
node: {|
15+
image: PhotoIdentifierImage,
16+
type: string,
17+
group_name: string,
18+
timestamp: number,
19+
location: {|
20+
longitude: number,
21+
latitude: number,
22+
23+
// iOS Only
24+
altitude: ?number,
25+
heading: ?number,
26+
speed: ?number,
27+
|},
28+
|},
29+
|};
30+
31+
export type PhotoIdentifierImage = {|
32+
uri: string,
33+
playableDuration: number,
34+
width: number,
35+
height: number,
36+
isStored: ?boolean,
37+
filename: ?string,
38+
|};
39+
40+
export type PhotoIdentifiersPage = {|
41+
edges: Array<PhotoIdentifier>,
42+
page_info: {|
43+
has_next_page: boolean,
44+
start_cursor?: ?string,
45+
end_cursor?: ?string,
46+
|},
47+
|};
48+
49+
export type GetPhotosParams = {|
50+
first: number,
51+
after?: ?string,
52+
groupName?: ?string,
53+
groupTypes?: ?string,
54+
assetType?: ?string,
55+
maxSize?: ?number,
56+
mimeTypes?: ?Array<string>,
57+
|};
58+
59+
export interface Spec extends TurboModule {
60+
+getConstants: () => {||};
61+
// eslint-disable-next-line lint/react-native-modules
62+
+getPhotos: (params: GetPhotosParams) => Promise<PhotoIdentifiersPage>;
63+
+saveToCameraRoll: (uri: string, type: string) => Promise<string>;
64+
65+
// iOS Only
66+
+deletePhotos: (assets: Array<string>) => Promise<boolean>;
67+
}
68+
69+
export default (TurboModuleRegistry.getEnforcing<Spec>(
70+
'CameraRollManager',
71+
): Spec);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
3+
*
4+
* @flow strict-local
5+
* @format
6+
*/
7+
8+
'use strict';
9+
10+
import type {TurboModule} from '../TurboModule/RCTExport';
11+
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
12+
13+
type Options = {|
14+
+offset: {|
15+
+x: number,
16+
+y: number,
17+
|},
18+
+size: {|
19+
+width: number,
20+
+height: number,
21+
|},
22+
+displaySize?: ?{|
23+
+width: number,
24+
+height: number,
25+
|},
26+
/**
27+
* Enum with potential values:
28+
* - cover
29+
* - contain
30+
* - stretch
31+
* - center
32+
* - repeat
33+
*/
34+
+resizeMode?: ?string,
35+
+allowExternalStorage?: boolean,
36+
|};
37+
38+
export interface Spec extends TurboModule {
39+
+getConstants: () => {||};
40+
+cropImage: (
41+
uri: string,
42+
// eslint-disable-next-line lint/react-native-modules
43+
cropData: Options,
44+
successCallback: (uri: string) => void,
45+
errorCallback: (error: string) => void,
46+
) => void;
47+
}
48+
49+
export default (TurboModuleRegistry.getEnforcing<Spec>(
50+
'ImageEditingManager',
51+
): Spec);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
3+
*
4+
* @flow strict-local
5+
* @format
6+
*/
7+
8+
'use strict';
9+
10+
import type {TurboModule} from '../TurboModule/RCTExport';
11+
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
12+
13+
export interface Spec extends TurboModule {
14+
+getConstants: () => {||};
15+
// Common
16+
+getBase64ForTag: (
17+
uri: string,
18+
successCallback: (base64ImageData: string) => void,
19+
20+
/**
21+
* On Android, the failure callback is called with a string.
22+
* On iOS, the failure callback is called with an error object.
23+
*
24+
* TODO(T47527939) Unify this inconsistency
25+
*/
26+
errorCallback: (error: {|message: string|} | string) => void,
27+
) => void;
28+
29+
// iOS-only
30+
+hasImageForTag: (uri: string, callback: (hasImage: boolean) => void) => void;
31+
+removeImageForTag: (uri: string) => void;
32+
+addImageFromBase64: (
33+
base64ImageData: string,
34+
successCallback: (uri: string) => void,
35+
errorCallback: (error: {|message: string|}) => void,
36+
) => void;
37+
}
38+
39+
export default (TurboModuleRegistry.getEnforcing<Spec>(
40+
'ImageStoreManager',
41+
): Spec);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
3+
*
4+
* @flow strict-local
5+
* @format
6+
*/
7+
8+
'use strict';
9+
10+
import type {TurboModule} from '../TurboModule/RCTExport';
11+
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
12+
13+
export type TimePickerOptions = {|
14+
hour?: number,
15+
minute?: number,
16+
is24Hour?: boolean,
17+
mode?: string,
18+
|};
19+
20+
export type TimePickerResult = {|
21+
action: string,
22+
hour: number,
23+
minute: number,
24+
|};
25+
26+
export interface Spec extends TurboModule {
27+
// eslint-disable-next-line lint/react-native-modules
28+
+open: (options: TimePickerOptions) => Promise<TimePickerResult>;
29+
}
30+
31+
export default (TurboModuleRegistry.get<Spec>('TimePickerAndroid'): ?Spec);

0 commit comments

Comments
 (0)