@gaozh1024/photo-picker 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const MEDIA_PICKER_ROUTES: {
4
+ readonly PHOTO_ALBUM: "PhotoAlbum";
5
+ readonly PHOTO_CROP: "PhotoCrop";
6
+ };
7
+ declare const mediaPickerColors: {
8
+ readonly primary: {
9
+ readonly 500: "#3b82f6";
10
+ };
11
+ readonly slate: {
12
+ readonly 50: "#f8fafc";
13
+ readonly 100: "#f1f5f9";
14
+ readonly 200: "#e2e8f0";
15
+ readonly 700: "#334155";
16
+ readonly 800: "#1e293b";
17
+ readonly 900: "#0f172a";
18
+ readonly 950: "#020617";
19
+ };
20
+ };
21
+
22
+ type PhotoAlbumMediaType = 'photo' | 'video';
23
+ type PhotoAlbumOpenMediaType = PhotoAlbumMediaType | 'all';
24
+ type PickerSource = 'android-photo-picker' | 'android-open-document';
25
+ interface PickerBackend {
26
+ source: PickerSource;
27
+ action: string;
28
+ }
29
+ type PhotoPickerNativeErrorCode = 'PICKER_BUSY' | 'PICKER_LAUNCH_FAILED' | 'PICKER_SELECTION_LIMIT_UNSUPPORTED';
30
+ interface PhotoPickerNativeError extends Error {
31
+ code: PhotoPickerNativeErrorCode;
32
+ }
33
+ interface PhotoAlbumCropOptions {
34
+ aspect?: [number, number];
35
+ shape?: 'rect' | 'circle';
36
+ quality?: number;
37
+ }
38
+ interface PickerMetadata {
39
+ capturedAt?: string;
40
+ gpsLatitude?: number;
41
+ gpsLongitude?: number;
42
+ gpsAltitude?: number;
43
+ cameraMake?: string;
44
+ cameraModel?: string;
45
+ exifOrientation?: number;
46
+ }
47
+ /**
48
+ * A media descriptor owned by this package. It deliberately does not extend
49
+ * expo-media-library Asset so callers never need broad media-library access.
50
+ */
51
+ interface PhotoAlbumItem {
52
+ id: string;
53
+ uri: string;
54
+ originalUri?: string;
55
+ localUri?: string;
56
+ filename?: string;
57
+ fileName?: string;
58
+ mediaType: PhotoAlbumMediaType;
59
+ mimeType?: string | null;
60
+ fileSize?: number;
61
+ width: number;
62
+ height: number;
63
+ /** Seconds, retained for compatibility with the old package. */
64
+ duration?: number;
65
+ /** Milliseconds, preferred by new code. */
66
+ durationMs?: number;
67
+ source?: PickerSource;
68
+ metadata?: PickerMetadata;
69
+ selected?: boolean;
70
+ selectedIndex?: number;
71
+ edited?: boolean;
72
+ crop?: PhotoAlbumCropOptions & {
73
+ width: number;
74
+ height: number;
75
+ };
76
+ }
77
+ interface PhotoAlbumOpenOptions {
78
+ maxSelection?: number;
79
+ mediaType?: PhotoAlbumOpenMediaType;
80
+ allowsMultipleSelection?: boolean;
81
+ maxVideoDuration?: number;
82
+ quality?: number;
83
+ crop?: PhotoAlbumCropOptions;
84
+ uiConfig?: PhotoAlbumUiConfig;
85
+ }
86
+ interface PhotoPickerOptions {
87
+ mediaType?: PhotoAlbumOpenMediaType;
88
+ maxSelection?: number;
89
+ allowsMultipleSelection?: boolean;
90
+ cacheMode?: 'copy';
91
+ }
92
+ interface PhotoPickerResult {
93
+ cancelled: boolean;
94
+ assets: PhotoAlbumItem[];
95
+ source?: PickerSource;
96
+ action?: string;
97
+ }
98
+ interface PhotoAlbumUiTexts {
99
+ albumTitle?: string;
100
+ cropTitle?: string;
101
+ cropConfirmButton?: string;
102
+ cropSavingButton?: string;
103
+ cropCircleHint?: string;
104
+ cropRectHint?: string;
105
+ cropMissingPhoto?: string;
106
+ durationLimitAlertTitle?: string;
107
+ durationLimitAlertMessage?: string;
108
+ openAlbumError?: string;
109
+ permissionAllowButton?: string;
110
+ permissionOpenSettingsButton?: string;
111
+ permissionSettingsAlertTitle?: string;
112
+ permissionSettingsAlertMessage?: string;
113
+ permissionSettingsAlertCancelButton?: string;
114
+ permissionSettingsAlertConfirmButton?: string;
115
+ }
116
+ interface PhotoAlbumUiTheme {
117
+ permissionButtonBackgroundColor?: string;
118
+ permissionButtonTextColor?: string;
119
+ permissionSettingsButtonBackgroundColor?: string;
120
+ permissionSettingsButtonTextColor?: string;
121
+ }
122
+ interface PhotoAlbumUiConfig {
123
+ texts?: PhotoAlbumUiTexts;
124
+ theme?: PhotoAlbumUiTheme;
125
+ /** Retained as a no-op compatibility shape. The system picker requests no media permission. */
126
+ permission?: {
127
+ openSettingsMode?: 'confirm' | 'direct' | 'disabled';
128
+ };
129
+ }
130
+ interface MediaPickerRouteNames {
131
+ photoAlbum: string;
132
+ photoCrop: string;
133
+ }
134
+ interface PhotoAlbumRouteParams {
135
+ callbackId?: string;
136
+ options?: PhotoAlbumOpenOptions;
137
+ maxSelection?: number;
138
+ allowsMultipleSelection?: boolean;
139
+ mediaTypes?: PhotoAlbumMediaType[];
140
+ routeNames?: Partial<MediaPickerRouteNames>;
141
+ uiConfig?: PhotoAlbumUiConfig;
142
+ }
143
+ interface PhotoCropRouteParams {
144
+ photo?: PhotoAlbumItem;
145
+ crop?: PhotoAlbumCropOptions;
146
+ quality?: number;
147
+ callbackId?: string;
148
+ routeNames?: Partial<MediaPickerRouteNames>;
149
+ uiConfig?: PhotoAlbumUiConfig;
150
+ }
151
+ interface PhotoAlbumScreenProps {
152
+ route?: {
153
+ params?: PhotoAlbumRouteParams;
154
+ };
155
+ navigation?: {
156
+ goBack: () => void;
157
+ navigate?: (name: string, params?: Record<string, unknown>) => void;
158
+ pop?: (count?: number) => void;
159
+ };
160
+ }
161
+ interface PhotoCropScreenProps {
162
+ route?: {
163
+ params?: PhotoCropRouteParams;
164
+ };
165
+ navigation?: {
166
+ goBack: () => void;
167
+ pop?: (count?: number) => void;
168
+ };
169
+ }
170
+
171
+ /**
172
+ * Compatibility route for applications that previously navigated to PhotoAlbum.
173
+ * It immediately opens the system picker; the app never enumerates the device library.
174
+ */
175
+ declare function PhotoAlbumScreen({ route, navigation }: PhotoAlbumScreenProps): react_jsx_runtime.JSX.Element;
176
+
177
+ declare function PhotoCropScreen({ route, navigation }: PhotoCropScreenProps): react_jsx_runtime.JSX.Element;
178
+
179
+ declare function pickMedia(options?: PhotoPickerOptions): Promise<PhotoPickerResult>;
180
+ declare function isPhotoPickerNativeError(error: unknown, code?: PhotoPickerNativeErrorCode): error is PhotoPickerNativeError;
181
+ declare function releaseMedia(uris: string[]): Promise<void>;
182
+ declare function clearPickerCache(): Promise<void>;
183
+
184
+ type PhotoPickerCompleteCallback = (photos: PhotoAlbumItem[]) => void;
185
+ declare function registerPhotoAlbumCompleteCallback(callback: PhotoPickerCompleteCallback): string;
186
+ declare function getPhotoAlbumCompleteCallback(callbackId?: string | null): PhotoPickerCompleteCallback | undefined;
187
+ declare function clearPhotoAlbumCompleteCallback(callbackId?: string | null): void;
188
+
189
+ declare function normalizeOpenOptions(options?: PhotoAlbumOpenOptions): Required<Pick<PhotoAlbumOpenOptions, 'maxSelection' | 'mediaType' | 'allowsMultipleSelection'>> & PhotoAlbumOpenOptions;
190
+ declare function resolvePhotoPickerUiConfig(uiConfig?: PhotoAlbumUiConfig): {
191
+ texts: {
192
+ albumTitle: string;
193
+ cropTitle: string;
194
+ cropConfirmButton: string;
195
+ cropSavingButton: string;
196
+ cropCircleHint: string;
197
+ cropRectHint: string;
198
+ cropMissingPhoto: string;
199
+ durationLimitAlertTitle: string;
200
+ durationLimitAlertMessage: string;
201
+ openAlbumError: string;
202
+ permissionAllowButton?: string;
203
+ permissionOpenSettingsButton?: string;
204
+ permissionSettingsAlertTitle?: string;
205
+ permissionSettingsAlertMessage?: string;
206
+ permissionSettingsAlertCancelButton?: string;
207
+ permissionSettingsAlertConfirmButton?: string;
208
+ };
209
+ };
210
+ declare function formatPhotoPickerText(template: string, variables: Record<string, string | number>): string;
211
+ declare function createCroppedPhotoAlbumItem(photo: PhotoAlbumItem, manipulated: {
212
+ uri: string;
213
+ width: number;
214
+ height: number;
215
+ }, crop?: PhotoAlbumCropOptions): PhotoAlbumItem;
216
+ declare function normalizePickerMediaType(mediaType?: PhotoAlbumOpenMediaType): PhotoAlbumOpenMediaType;
217
+
218
+ export { MEDIA_PICKER_ROUTES, type MediaPickerRouteNames, type PhotoAlbumCropOptions, type PhotoAlbumItem, type PhotoAlbumOpenMediaType, type PhotoAlbumOpenOptions, PhotoAlbumScreen, type PhotoAlbumScreenProps, type PhotoAlbumUiConfig, type PhotoAlbumUiTexts, type PhotoAlbumUiTheme, PhotoCropScreen, type PhotoCropScreenProps, type PhotoPickerNativeError, type PhotoPickerNativeErrorCode, type PhotoPickerOptions, type PhotoPickerResult, type PickerBackend, type PickerMetadata, type PickerSource, clearPhotoAlbumCompleteCallback, clearPickerCache, createCroppedPhotoAlbumItem, formatPhotoPickerText, getPhotoAlbumCompleteCallback, isPhotoPickerNativeError, mediaPickerColors, normalizeOpenOptions, normalizePickerMediaType, pickMedia, registerPhotoAlbumCompleteCallback, releaseMedia, resolvePhotoPickerUiConfig };
@@ -0,0 +1,218 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const MEDIA_PICKER_ROUTES: {
4
+ readonly PHOTO_ALBUM: "PhotoAlbum";
5
+ readonly PHOTO_CROP: "PhotoCrop";
6
+ };
7
+ declare const mediaPickerColors: {
8
+ readonly primary: {
9
+ readonly 500: "#3b82f6";
10
+ };
11
+ readonly slate: {
12
+ readonly 50: "#f8fafc";
13
+ readonly 100: "#f1f5f9";
14
+ readonly 200: "#e2e8f0";
15
+ readonly 700: "#334155";
16
+ readonly 800: "#1e293b";
17
+ readonly 900: "#0f172a";
18
+ readonly 950: "#020617";
19
+ };
20
+ };
21
+
22
+ type PhotoAlbumMediaType = 'photo' | 'video';
23
+ type PhotoAlbumOpenMediaType = PhotoAlbumMediaType | 'all';
24
+ type PickerSource = 'android-photo-picker' | 'android-open-document';
25
+ interface PickerBackend {
26
+ source: PickerSource;
27
+ action: string;
28
+ }
29
+ type PhotoPickerNativeErrorCode = 'PICKER_BUSY' | 'PICKER_LAUNCH_FAILED' | 'PICKER_SELECTION_LIMIT_UNSUPPORTED';
30
+ interface PhotoPickerNativeError extends Error {
31
+ code: PhotoPickerNativeErrorCode;
32
+ }
33
+ interface PhotoAlbumCropOptions {
34
+ aspect?: [number, number];
35
+ shape?: 'rect' | 'circle';
36
+ quality?: number;
37
+ }
38
+ interface PickerMetadata {
39
+ capturedAt?: string;
40
+ gpsLatitude?: number;
41
+ gpsLongitude?: number;
42
+ gpsAltitude?: number;
43
+ cameraMake?: string;
44
+ cameraModel?: string;
45
+ exifOrientation?: number;
46
+ }
47
+ /**
48
+ * A media descriptor owned by this package. It deliberately does not extend
49
+ * expo-media-library Asset so callers never need broad media-library access.
50
+ */
51
+ interface PhotoAlbumItem {
52
+ id: string;
53
+ uri: string;
54
+ originalUri?: string;
55
+ localUri?: string;
56
+ filename?: string;
57
+ fileName?: string;
58
+ mediaType: PhotoAlbumMediaType;
59
+ mimeType?: string | null;
60
+ fileSize?: number;
61
+ width: number;
62
+ height: number;
63
+ /** Seconds, retained for compatibility with the old package. */
64
+ duration?: number;
65
+ /** Milliseconds, preferred by new code. */
66
+ durationMs?: number;
67
+ source?: PickerSource;
68
+ metadata?: PickerMetadata;
69
+ selected?: boolean;
70
+ selectedIndex?: number;
71
+ edited?: boolean;
72
+ crop?: PhotoAlbumCropOptions & {
73
+ width: number;
74
+ height: number;
75
+ };
76
+ }
77
+ interface PhotoAlbumOpenOptions {
78
+ maxSelection?: number;
79
+ mediaType?: PhotoAlbumOpenMediaType;
80
+ allowsMultipleSelection?: boolean;
81
+ maxVideoDuration?: number;
82
+ quality?: number;
83
+ crop?: PhotoAlbumCropOptions;
84
+ uiConfig?: PhotoAlbumUiConfig;
85
+ }
86
+ interface PhotoPickerOptions {
87
+ mediaType?: PhotoAlbumOpenMediaType;
88
+ maxSelection?: number;
89
+ allowsMultipleSelection?: boolean;
90
+ cacheMode?: 'copy';
91
+ }
92
+ interface PhotoPickerResult {
93
+ cancelled: boolean;
94
+ assets: PhotoAlbumItem[];
95
+ source?: PickerSource;
96
+ action?: string;
97
+ }
98
+ interface PhotoAlbumUiTexts {
99
+ albumTitle?: string;
100
+ cropTitle?: string;
101
+ cropConfirmButton?: string;
102
+ cropSavingButton?: string;
103
+ cropCircleHint?: string;
104
+ cropRectHint?: string;
105
+ cropMissingPhoto?: string;
106
+ durationLimitAlertTitle?: string;
107
+ durationLimitAlertMessage?: string;
108
+ openAlbumError?: string;
109
+ permissionAllowButton?: string;
110
+ permissionOpenSettingsButton?: string;
111
+ permissionSettingsAlertTitle?: string;
112
+ permissionSettingsAlertMessage?: string;
113
+ permissionSettingsAlertCancelButton?: string;
114
+ permissionSettingsAlertConfirmButton?: string;
115
+ }
116
+ interface PhotoAlbumUiTheme {
117
+ permissionButtonBackgroundColor?: string;
118
+ permissionButtonTextColor?: string;
119
+ permissionSettingsButtonBackgroundColor?: string;
120
+ permissionSettingsButtonTextColor?: string;
121
+ }
122
+ interface PhotoAlbumUiConfig {
123
+ texts?: PhotoAlbumUiTexts;
124
+ theme?: PhotoAlbumUiTheme;
125
+ /** Retained as a no-op compatibility shape. The system picker requests no media permission. */
126
+ permission?: {
127
+ openSettingsMode?: 'confirm' | 'direct' | 'disabled';
128
+ };
129
+ }
130
+ interface MediaPickerRouteNames {
131
+ photoAlbum: string;
132
+ photoCrop: string;
133
+ }
134
+ interface PhotoAlbumRouteParams {
135
+ callbackId?: string;
136
+ options?: PhotoAlbumOpenOptions;
137
+ maxSelection?: number;
138
+ allowsMultipleSelection?: boolean;
139
+ mediaTypes?: PhotoAlbumMediaType[];
140
+ routeNames?: Partial<MediaPickerRouteNames>;
141
+ uiConfig?: PhotoAlbumUiConfig;
142
+ }
143
+ interface PhotoCropRouteParams {
144
+ photo?: PhotoAlbumItem;
145
+ crop?: PhotoAlbumCropOptions;
146
+ quality?: number;
147
+ callbackId?: string;
148
+ routeNames?: Partial<MediaPickerRouteNames>;
149
+ uiConfig?: PhotoAlbumUiConfig;
150
+ }
151
+ interface PhotoAlbumScreenProps {
152
+ route?: {
153
+ params?: PhotoAlbumRouteParams;
154
+ };
155
+ navigation?: {
156
+ goBack: () => void;
157
+ navigate?: (name: string, params?: Record<string, unknown>) => void;
158
+ pop?: (count?: number) => void;
159
+ };
160
+ }
161
+ interface PhotoCropScreenProps {
162
+ route?: {
163
+ params?: PhotoCropRouteParams;
164
+ };
165
+ navigation?: {
166
+ goBack: () => void;
167
+ pop?: (count?: number) => void;
168
+ };
169
+ }
170
+
171
+ /**
172
+ * Compatibility route for applications that previously navigated to PhotoAlbum.
173
+ * It immediately opens the system picker; the app never enumerates the device library.
174
+ */
175
+ declare function PhotoAlbumScreen({ route, navigation }: PhotoAlbumScreenProps): react_jsx_runtime.JSX.Element;
176
+
177
+ declare function PhotoCropScreen({ route, navigation }: PhotoCropScreenProps): react_jsx_runtime.JSX.Element;
178
+
179
+ declare function pickMedia(options?: PhotoPickerOptions): Promise<PhotoPickerResult>;
180
+ declare function isPhotoPickerNativeError(error: unknown, code?: PhotoPickerNativeErrorCode): error is PhotoPickerNativeError;
181
+ declare function releaseMedia(uris: string[]): Promise<void>;
182
+ declare function clearPickerCache(): Promise<void>;
183
+
184
+ type PhotoPickerCompleteCallback = (photos: PhotoAlbumItem[]) => void;
185
+ declare function registerPhotoAlbumCompleteCallback(callback: PhotoPickerCompleteCallback): string;
186
+ declare function getPhotoAlbumCompleteCallback(callbackId?: string | null): PhotoPickerCompleteCallback | undefined;
187
+ declare function clearPhotoAlbumCompleteCallback(callbackId?: string | null): void;
188
+
189
+ declare function normalizeOpenOptions(options?: PhotoAlbumOpenOptions): Required<Pick<PhotoAlbumOpenOptions, 'maxSelection' | 'mediaType' | 'allowsMultipleSelection'>> & PhotoAlbumOpenOptions;
190
+ declare function resolvePhotoPickerUiConfig(uiConfig?: PhotoAlbumUiConfig): {
191
+ texts: {
192
+ albumTitle: string;
193
+ cropTitle: string;
194
+ cropConfirmButton: string;
195
+ cropSavingButton: string;
196
+ cropCircleHint: string;
197
+ cropRectHint: string;
198
+ cropMissingPhoto: string;
199
+ durationLimitAlertTitle: string;
200
+ durationLimitAlertMessage: string;
201
+ openAlbumError: string;
202
+ permissionAllowButton?: string;
203
+ permissionOpenSettingsButton?: string;
204
+ permissionSettingsAlertTitle?: string;
205
+ permissionSettingsAlertMessage?: string;
206
+ permissionSettingsAlertCancelButton?: string;
207
+ permissionSettingsAlertConfirmButton?: string;
208
+ };
209
+ };
210
+ declare function formatPhotoPickerText(template: string, variables: Record<string, string | number>): string;
211
+ declare function createCroppedPhotoAlbumItem(photo: PhotoAlbumItem, manipulated: {
212
+ uri: string;
213
+ width: number;
214
+ height: number;
215
+ }, crop?: PhotoAlbumCropOptions): PhotoAlbumItem;
216
+ declare function normalizePickerMediaType(mediaType?: PhotoAlbumOpenMediaType): PhotoAlbumOpenMediaType;
217
+
218
+ export { MEDIA_PICKER_ROUTES, type MediaPickerRouteNames, type PhotoAlbumCropOptions, type PhotoAlbumItem, type PhotoAlbumOpenMediaType, type PhotoAlbumOpenOptions, PhotoAlbumScreen, type PhotoAlbumScreenProps, type PhotoAlbumUiConfig, type PhotoAlbumUiTexts, type PhotoAlbumUiTheme, PhotoCropScreen, type PhotoCropScreenProps, type PhotoPickerNativeError, type PhotoPickerNativeErrorCode, type PhotoPickerOptions, type PhotoPickerResult, type PickerBackend, type PickerMetadata, type PickerSource, clearPhotoAlbumCompleteCallback, clearPickerCache, createCroppedPhotoAlbumItem, formatPhotoPickerText, getPhotoAlbumCompleteCallback, isPhotoPickerNativeError, mediaPickerColors, normalizeOpenOptions, normalizePickerMediaType, pickMedia, registerPhotoAlbumCompleteCallback, releaseMedia, resolvePhotoPickerUiConfig };