@sendbird/uikit-react-native 3.9.0 → 3.9.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.
- package/lib/commonjs/platform/createFileService.expo.js +16 -8
- package/lib/commonjs/platform/createFileService.expo.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/platform/createFileService.expo.js +16 -8
- package/lib/module/platform/createFileService.expo.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +10 -6
- package/src/platform/createFileService.expo.ts +23 -8
- package/src/version.ts +1 -1
|
@@ -24,12 +24,20 @@ const createExpoFileService = ({
|
|
|
24
24
|
const res = await imagePickerModule.requestCameraPermissionsAsync();
|
|
25
25
|
return (0, _expoPermissionGranted.default)([res]);
|
|
26
26
|
}
|
|
27
|
-
async
|
|
28
|
-
const perms = await imagePickerModule.getMediaLibraryPermissionsAsync(
|
|
27
|
+
async hasMediaLibraryReadPermission() {
|
|
28
|
+
const perms = await imagePickerModule.getMediaLibraryPermissionsAsync(false);
|
|
29
29
|
return (0, _expoPermissionGranted.default)([perms]);
|
|
30
30
|
}
|
|
31
|
-
async
|
|
32
|
-
const perms = await imagePickerModule.requestMediaLibraryPermissionsAsync(
|
|
31
|
+
async requestMediaLibraryReadPermission() {
|
|
32
|
+
const perms = await imagePickerModule.requestMediaLibraryPermissionsAsync(false);
|
|
33
|
+
return (0, _expoPermissionGranted.default)([perms]);
|
|
34
|
+
}
|
|
35
|
+
async hasMediaLibraryWritePermission() {
|
|
36
|
+
const perms = await mediaLibraryModule.getPermissionsAsync(true, []);
|
|
37
|
+
return (0, _expoPermissionGranted.default)([perms]);
|
|
38
|
+
}
|
|
39
|
+
async requestMediaLibraryWritePermission() {
|
|
40
|
+
const perms = await mediaLibraryModule.requestPermissionsAsync(true, []);
|
|
33
41
|
return (0, _expoPermissionGranted.default)([perms]);
|
|
34
42
|
}
|
|
35
43
|
async openCamera(options) {
|
|
@@ -61,9 +69,9 @@ const createExpoFileService = ({
|
|
|
61
69
|
return file;
|
|
62
70
|
}
|
|
63
71
|
async openMediaLibrary(options) {
|
|
64
|
-
const hasPermission = await this.
|
|
72
|
+
const hasPermission = await this.hasMediaLibraryReadPermission();
|
|
65
73
|
if (!hasPermission) {
|
|
66
|
-
const granted = await this.
|
|
74
|
+
const granted = await this.requestMediaLibraryReadPermission();
|
|
67
75
|
if (!granted) {
|
|
68
76
|
var _options$onOpenFailur2;
|
|
69
77
|
options === null || options === void 0 || (_options$onOpenFailur2 = options.onOpenFailure) === null || _options$onOpenFailur2 === void 0 || _options$onOpenFailur2.call(options, _SBUError.default.PERMISSIONS_DENIED);
|
|
@@ -104,9 +112,9 @@ const createExpoFileService = ({
|
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
async save(options) {
|
|
107
|
-
const hasPermission = await this.
|
|
115
|
+
const hasPermission = await this.hasMediaLibraryWritePermission();
|
|
108
116
|
if (!hasPermission) {
|
|
109
|
-
const granted = await this.
|
|
117
|
+
const granted = await this.requestMediaLibraryWritePermission();
|
|
110
118
|
if (!granted) throw new Error('Permission not granted');
|
|
111
119
|
}
|
|
112
120
|
const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_uikitUtils","require","_SBUError","_interopRequireDefault","_expoBackwardUtils","_expoPermissionGranted","e","__esModule","default","createExpoFileService","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","ExpoFileServiceInterface","hasCameraPermission","res","getCameraPermissionsAsync","expoPermissionGranted","requestCameraPermission","requestCameraPermissionsAsync","hasMediaLibraryPermission","type","perms","getMediaLibraryPermissionsAsync","requestMediaLibraryPermission","requestMediaLibraryPermissionsAsync","openCamera","options","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","SBUError","PERMISSIONS_DENIED","response","launchCameraAsync","mediaTypes","mediaType","MediaTypeOptions","Images","Videos","All","expoBackwardUtils","imagePicker","isCanceled","file","toFilePickerResponses","openMediaLibrary","_options$onOpenFailur2","selectionLimit","launchImageLibraryAsync","openDocument","getDocumentAsync","documentPicker","_options$onOpenFailur3","UNKNOWN","save","Error","basePath","documentDirectory","cacheDirectory","downloadPath","fileName","downloadAsync","fileUrl","getFileType","fileType","match","saveToLibraryAsync","uri","createRecordFilePath","customExtension","filename","Date","now","recordFilePath","_default","exports"],"sources":["createFileService.expo.ts"],"sourcesContent":["import type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\nimport type * as ExpoMediaLibrary from 'expo-media-library';\n\nimport { getFileType } from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport expoBackwardUtils from '../utils/expoBackwardUtils';\nimport type { ExpoMediaLibraryPermissionResponse, ExpoPermissionResponse } from '../utils/expoPermissionGranted';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nconst createExpoFileService = ({\n imagePickerModule,\n documentPickerModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ExpoImagePicker;\n documentPickerModule: typeof ExpoDocumentPicker;\n mediaLibraryModule: typeof ExpoMediaLibrary;\n fsModule: typeof ExpoFs;\n}): FileServiceInterface => {\n class ExpoFileServiceInterface implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n async requestCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n async hasMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {\n const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(\n type === 'write',\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n async requestMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {\n const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(\n type === 'write',\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCameraAsync({\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n return file;\n }\n async openMediaLibrary(options: OpenMediaLibraryOptions) {\n const hasPermission = await this.hasMediaLibraryPermission('read');\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission('read');\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const selectionLimit = options?.selectionLimit || 1;\n const response = await imagePickerModule.launchImageLibraryAsync({\n selectionLimit,\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n return expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n }\n\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const response = await documentPickerModule.getDocumentAsync({ type: '*/*' });\n if (expoBackwardUtils.documentPicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.documentPicker.toFilePickerResponses(response);\n return file;\n } catch (e) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n return null;\n }\n }\n\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryPermission('write');\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission('write');\n if (!granted) throw new Error('Permission not granted');\n }\n\n const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const downloadPath = `${basePath}/${options.fileName}`;\n\n const response = await fsModule.downloadAsync(options.fileUrl, downloadPath);\n if (getFileType(options.fileType || '').match(/video|image/)) {\n await mediaLibraryModule.saveToLibraryAsync(response.uri);\n }\n return response.uri;\n }\n createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {\n const basePath = fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const filename = `record-${Date.now()}.${customExtension}`;\n return {\n uri: `${basePath}/${filename}`,\n recordFilePath: `${basePath}/${filename}`,\n };\n }\n }\n\n return new ExpoFileServiceInterface();\n};\n\nexport default createExpoFileService;\n"],"mappings":";;;;;;AAKA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAmE,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAUnE,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C1D,OAAO;QACLF,GAAG,EAAE,GAAGX,QAAQ,IAAIc,QAAQ,EAAE;QAC9BG,cAAc,EAAE,GAAGjB,QAAQ,IAAIc,QAAQ;MACzC,CAAC;IACH;EACF;EAEA,OAAO,IAAI5D,wBAAwB,CAAC,CAAC;AACvC,CAAC;AAAC,IAAAgE,QAAA,GAAAC,OAAA,CAAAvE,OAAA,GAEaC,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_uikitUtils","require","_SBUError","_interopRequireDefault","_expoBackwardUtils","_expoPermissionGranted","e","__esModule","default","createExpoFileService","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","ExpoFileServiceInterface","hasCameraPermission","res","getCameraPermissionsAsync","expoPermissionGranted","requestCameraPermission","requestCameraPermissionsAsync","hasMediaLibraryReadPermission","perms","getMediaLibraryPermissionsAsync","requestMediaLibraryReadPermission","requestMediaLibraryPermissionsAsync","hasMediaLibraryWritePermission","getPermissionsAsync","requestMediaLibraryWritePermission","requestPermissionsAsync","openCamera","options","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","SBUError","PERMISSIONS_DENIED","response","launchCameraAsync","mediaTypes","mediaType","MediaTypeOptions","Images","Videos","All","expoBackwardUtils","imagePicker","isCanceled","file","toFilePickerResponses","openMediaLibrary","_options$onOpenFailur2","selectionLimit","launchImageLibraryAsync","openDocument","getDocumentAsync","type","documentPicker","_options$onOpenFailur3","UNKNOWN","save","Error","basePath","documentDirectory","cacheDirectory","downloadPath","fileName","downloadAsync","fileUrl","getFileType","fileType","match","saveToLibraryAsync","uri","createRecordFilePath","customExtension","filename","Date","now","recordFilePath","_default","exports"],"sources":["createFileService.expo.ts"],"sourcesContent":["import type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\nimport type * as ExpoMediaLibrary from 'expo-media-library';\n\nimport { getFileType } from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport expoBackwardUtils from '../utils/expoBackwardUtils';\nimport type { ExpoMediaLibraryPermissionResponse, ExpoPermissionResponse } from '../utils/expoPermissionGranted';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nconst createExpoFileService = ({\n imagePickerModule,\n documentPickerModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ExpoImagePicker;\n documentPickerModule: typeof ExpoDocumentPicker;\n mediaLibraryModule: typeof ExpoMediaLibrary;\n fsModule: typeof ExpoFs;\n}): FileServiceInterface => {\n class ExpoFileServiceInterface implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n\n async requestCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n\n async hasMediaLibraryReadPermission(): Promise<boolean> {\n const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(\n false,\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async requestMediaLibraryReadPermission(): Promise<boolean> {\n const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(\n false,\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async hasMediaLibraryWritePermission(): Promise<boolean> {\n const perms = (await mediaLibraryModule.getPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async requestMediaLibraryWritePermission(): Promise<boolean> {\n const perms = (await mediaLibraryModule.requestPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCameraAsync({\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n return file;\n }\n\n async openMediaLibrary(options: OpenMediaLibraryOptions) {\n const hasPermission = await this.hasMediaLibraryReadPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryReadPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const selectionLimit = options?.selectionLimit || 1;\n const response = await imagePickerModule.launchImageLibraryAsync({\n selectionLimit,\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n return expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n }\n\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const response = await documentPickerModule.getDocumentAsync({ type: '*/*' });\n if (expoBackwardUtils.documentPicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.documentPicker.toFilePickerResponses(response);\n return file;\n } catch (e) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n return null;\n }\n }\n\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryWritePermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryWritePermission();\n if (!granted) throw new Error('Permission not granted');\n }\n\n const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const downloadPath = `${basePath}/${options.fileName}`;\n\n const response = await fsModule.downloadAsync(options.fileUrl, downloadPath);\n if (getFileType(options.fileType || '').match(/video|image/)) {\n await mediaLibraryModule.saveToLibraryAsync(response.uri);\n }\n return response.uri;\n }\n\n createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {\n const basePath = fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const filename = `record-${Date.now()}.${customExtension}`;\n return {\n uri: `${basePath}/${filename}`,\n recordFilePath: `${basePath}/${filename}`,\n };\n }\n }\n\n return new ExpoFileServiceInterface();\n};\n\nexport default createExpoFileService;\n"],"mappings":";;;;;;AAKA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAmE,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAUnE,MAAMG,qBAAqB,GAAGA,CAAC;EAC7BC,iBAAiB;EACjBC,oBAAoB;EACpBC,kBAAkB;EAClBC;AAMF,CAAC,KAA2B;EAC1B,MAAMC,wBAAwB,CAAiC;IAC7D,MAAMC,mBAAmBA,CAAA,EAAqB;MAC5C,MAAMC,GAAG,GAAI,MAAMN,iBAAiB,CAACO,yBAAyB,CAAC,CAA4B;MAC3F,OAAO,IAAAC,8BAAqB,EAAC,CAACF,GAAG,CAAC,CAAC;IACrC;IAEA,MAAMG,uBAAuBA,CAAA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AE,GAAGX,QAAQ,IAAIc,QAAQ,EAAE;QAC9BG,cAAc,EAAE,GAAGjB,QAAQ,IAAIc,QAAQ;MACzC,CAAC;IACH;EACF;EAEA,OAAO,IAAIhE,wBAAwB,CAAC,CAAC;AACvC,CAAC;AAAC,IAAAoE,QAAA,GAAAC,OAAA,CAAA3E,OAAA,GAEaC,qBAAqB","ignoreList":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION","_default","exports","default"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.9.
|
|
1
|
+
{"version":3,"names":["VERSION","_default","exports","default"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.9.1';\nexport default VERSION;\n"],"mappings":";;;;;;AAAA,MAAMA,OAAO,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACTH,OAAO","ignoreList":[]}
|
|
@@ -17,12 +17,20 @@ const createExpoFileService = ({
|
|
|
17
17
|
const res = await imagePickerModule.requestCameraPermissionsAsync();
|
|
18
18
|
return expoPermissionGranted([res]);
|
|
19
19
|
}
|
|
20
|
-
async
|
|
21
|
-
const perms = await imagePickerModule.getMediaLibraryPermissionsAsync(
|
|
20
|
+
async hasMediaLibraryReadPermission() {
|
|
21
|
+
const perms = await imagePickerModule.getMediaLibraryPermissionsAsync(false);
|
|
22
22
|
return expoPermissionGranted([perms]);
|
|
23
23
|
}
|
|
24
|
-
async
|
|
25
|
-
const perms = await imagePickerModule.requestMediaLibraryPermissionsAsync(
|
|
24
|
+
async requestMediaLibraryReadPermission() {
|
|
25
|
+
const perms = await imagePickerModule.requestMediaLibraryPermissionsAsync(false);
|
|
26
|
+
return expoPermissionGranted([perms]);
|
|
27
|
+
}
|
|
28
|
+
async hasMediaLibraryWritePermission() {
|
|
29
|
+
const perms = await mediaLibraryModule.getPermissionsAsync(true, []);
|
|
30
|
+
return expoPermissionGranted([perms]);
|
|
31
|
+
}
|
|
32
|
+
async requestMediaLibraryWritePermission() {
|
|
33
|
+
const perms = await mediaLibraryModule.requestPermissionsAsync(true, []);
|
|
26
34
|
return expoPermissionGranted([perms]);
|
|
27
35
|
}
|
|
28
36
|
async openCamera(options) {
|
|
@@ -54,9 +62,9 @@ const createExpoFileService = ({
|
|
|
54
62
|
return file;
|
|
55
63
|
}
|
|
56
64
|
async openMediaLibrary(options) {
|
|
57
|
-
const hasPermission = await this.
|
|
65
|
+
const hasPermission = await this.hasMediaLibraryReadPermission();
|
|
58
66
|
if (!hasPermission) {
|
|
59
|
-
const granted = await this.
|
|
67
|
+
const granted = await this.requestMediaLibraryReadPermission();
|
|
60
68
|
if (!granted) {
|
|
61
69
|
var _options$onOpenFailur2;
|
|
62
70
|
options === null || options === void 0 || (_options$onOpenFailur2 = options.onOpenFailure) === null || _options$onOpenFailur2 === void 0 || _options$onOpenFailur2.call(options, SBUError.PERMISSIONS_DENIED);
|
|
@@ -97,9 +105,9 @@ const createExpoFileService = ({
|
|
|
97
105
|
}
|
|
98
106
|
}
|
|
99
107
|
async save(options) {
|
|
100
|
-
const hasPermission = await this.
|
|
108
|
+
const hasPermission = await this.hasMediaLibraryWritePermission();
|
|
101
109
|
if (!hasPermission) {
|
|
102
|
-
const granted = await this.
|
|
110
|
+
const granted = await this.requestMediaLibraryWritePermission();
|
|
103
111
|
if (!granted) throw new Error('Permission not granted');
|
|
104
112
|
}
|
|
105
113
|
const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFileType","SBUError","expoBackwardUtils","expoPermissionGranted","createExpoFileService","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","ExpoFileServiceInterface","hasCameraPermission","res","getCameraPermissionsAsync","requestCameraPermission","requestCameraPermissionsAsync","hasMediaLibraryPermission","type","perms","getMediaLibraryPermissionsAsync","requestMediaLibraryPermission","requestMediaLibraryPermissionsAsync","openCamera","options","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","PERMISSIONS_DENIED","response","launchCameraAsync","mediaTypes","mediaType","MediaTypeOptions","Images","Videos","All","imagePicker","isCanceled","file","toFilePickerResponses","openMediaLibrary","_options$onOpenFailur2","selectionLimit","launchImageLibraryAsync","openDocument","getDocumentAsync","documentPicker","e","_options$onOpenFailur3","UNKNOWN","save","Error","basePath","documentDirectory","cacheDirectory","downloadPath","fileName","downloadAsync","fileUrl","fileType","match","saveToLibraryAsync","uri","createRecordFilePath","customExtension","filename","Date","now","recordFilePath"],"sources":["createFileService.expo.ts"],"sourcesContent":["import type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\nimport type * as ExpoMediaLibrary from 'expo-media-library';\n\nimport { getFileType } from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport expoBackwardUtils from '../utils/expoBackwardUtils';\nimport type { ExpoMediaLibraryPermissionResponse, ExpoPermissionResponse } from '../utils/expoPermissionGranted';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nconst createExpoFileService = ({\n imagePickerModule,\n documentPickerModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ExpoImagePicker;\n documentPickerModule: typeof ExpoDocumentPicker;\n mediaLibraryModule: typeof ExpoMediaLibrary;\n fsModule: typeof ExpoFs;\n}): FileServiceInterface => {\n class ExpoFileServiceInterface implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n async requestCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n async hasMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {\n const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(\n type === 'write',\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n async requestMediaLibraryPermission(type: 'write' | 'read'): Promise<boolean> {\n const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(\n type === 'write',\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCameraAsync({\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n return file;\n }\n async openMediaLibrary(options: OpenMediaLibraryOptions) {\n const hasPermission = await this.hasMediaLibraryPermission('read');\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission('read');\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const selectionLimit = options?.selectionLimit || 1;\n const response = await imagePickerModule.launchImageLibraryAsync({\n selectionLimit,\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n return expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n }\n\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const response = await documentPickerModule.getDocumentAsync({ type: '*/*' });\n if (expoBackwardUtils.documentPicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.documentPicker.toFilePickerResponses(response);\n return file;\n } catch (e) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n return null;\n }\n }\n\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryPermission('write');\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission('write');\n if (!granted) throw new Error('Permission not granted');\n }\n\n const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const downloadPath = `${basePath}/${options.fileName}`;\n\n const response = await fsModule.downloadAsync(options.fileUrl, downloadPath);\n if (getFileType(options.fileType || '').match(/video|image/)) {\n await mediaLibraryModule.saveToLibraryAsync(response.uri);\n }\n return response.uri;\n }\n createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {\n const basePath = fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const filename = `record-${Date.now()}.${customExtension}`;\n return {\n uri: `${basePath}/${filename}`,\n recordFilePath: `${basePath}/${filename}`,\n };\n }\n }\n\n return new ExpoFileServiceInterface();\n};\n\nexport default createExpoFileService;\n"],"mappings":"AAKA,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,iBAAiB,MAAM,4BAA4B;AAE1D,OAAOC,qBAAqB,MAAM,gCAAgC;AAUlE,MAAMC,qBAAqB,GAAGA,CAAC;EAC7BC,iBAAiB;EACjBC,oBAAoB;EACpBC,kBAAkB;EAClBC;AAMF,CAAC,KAA2B;EAC1B,MAAMC,wBAAwB,CAAiC;IAC7D,MAAMC,mBAAmBA,CAAA,EAAqB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eL,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getFileType","SBUError","expoBackwardUtils","expoPermissionGranted","createExpoFileService","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","ExpoFileServiceInterface","hasCameraPermission","res","getCameraPermissionsAsync","requestCameraPermission","requestCameraPermissionsAsync","hasMediaLibraryReadPermission","perms","getMediaLibraryPermissionsAsync","requestMediaLibraryReadPermission","requestMediaLibraryPermissionsAsync","hasMediaLibraryWritePermission","getPermissionsAsync","requestMediaLibraryWritePermission","requestPermissionsAsync","openCamera","options","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","PERMISSIONS_DENIED","response","launchCameraAsync","mediaTypes","mediaType","MediaTypeOptions","Images","Videos","All","imagePicker","isCanceled","file","toFilePickerResponses","openMediaLibrary","_options$onOpenFailur2","selectionLimit","launchImageLibraryAsync","openDocument","getDocumentAsync","type","documentPicker","e","_options$onOpenFailur3","UNKNOWN","save","Error","basePath","documentDirectory","cacheDirectory","downloadPath","fileName","downloadAsync","fileUrl","fileType","match","saveToLibraryAsync","uri","createRecordFilePath","customExtension","filename","Date","now","recordFilePath"],"sources":["createFileService.expo.ts"],"sourcesContent":["import type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\nimport type * as ExpoMediaLibrary from 'expo-media-library';\n\nimport { getFileType } from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport expoBackwardUtils from '../utils/expoBackwardUtils';\nimport type { ExpoMediaLibraryPermissionResponse, ExpoPermissionResponse } from '../utils/expoPermissionGranted';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nconst createExpoFileService = ({\n imagePickerModule,\n documentPickerModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ExpoImagePicker;\n documentPickerModule: typeof ExpoDocumentPicker;\n mediaLibraryModule: typeof ExpoMediaLibrary;\n fsModule: typeof ExpoFs;\n}): FileServiceInterface => {\n class ExpoFileServiceInterface implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n\n async requestCameraPermission(): Promise<boolean> {\n const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;\n return expoPermissionGranted([res]);\n }\n\n async hasMediaLibraryReadPermission(): Promise<boolean> {\n const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(\n false,\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async requestMediaLibraryReadPermission(): Promise<boolean> {\n const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(\n false,\n )) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async hasMediaLibraryWritePermission(): Promise<boolean> {\n const perms = (await mediaLibraryModule.getPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async requestMediaLibraryWritePermission(): Promise<boolean> {\n const perms = (await mediaLibraryModule.requestPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;\n return expoPermissionGranted([perms]);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCameraAsync({\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n return file;\n }\n\n async openMediaLibrary(options: OpenMediaLibraryOptions) {\n const hasPermission = await this.hasMediaLibraryReadPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryReadPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const selectionLimit = options?.selectionLimit || 1;\n const response = await imagePickerModule.launchImageLibraryAsync({\n selectionLimit,\n mediaTypes: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return imagePickerModule.MediaTypeOptions.Images;\n case 'video':\n return imagePickerModule.MediaTypeOptions.Videos;\n case 'all':\n return imagePickerModule.MediaTypeOptions.All;\n default:\n return imagePickerModule.MediaTypeOptions.Images;\n }\n })(),\n });\n if (expoBackwardUtils.imagePicker.isCanceled(response)) return null;\n return expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);\n }\n\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const response = await documentPickerModule.getDocumentAsync({ type: '*/*' });\n if (expoBackwardUtils.documentPicker.isCanceled(response)) return null;\n\n const [file] = await expoBackwardUtils.documentPicker.toFilePickerResponses(response);\n return file;\n } catch (e) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n return null;\n }\n }\n\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryWritePermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryWritePermission();\n if (!granted) throw new Error('Permission not granted');\n }\n\n const basePath = fsModule.documentDirectory || fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const downloadPath = `${basePath}/${options.fileName}`;\n\n const response = await fsModule.downloadAsync(options.fileUrl, downloadPath);\n if (getFileType(options.fileType || '').match(/video|image/)) {\n await mediaLibraryModule.saveToLibraryAsync(response.uri);\n }\n return response.uri;\n }\n\n createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {\n const basePath = fsModule.cacheDirectory;\n if (!basePath) throw new Error('Cannot determine directory');\n\n const filename = `record-${Date.now()}.${customExtension}`;\n return {\n uri: `${basePath}/${filename}`,\n recordFilePath: `${basePath}/${filename}`,\n };\n }\n }\n\n return new ExpoFileServiceInterface();\n};\n\nexport default createExpoFileService;\n"],"mappings":"AAKA,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,iBAAiB,MAAM,4BAA4B;AAE1D,OAAOC,qBAAqB,MAAM,gCAAgC;AAUlE,MAAMC,qBAAqB,GAAGA,CAAC;EAC7BC,iBAAiB;EACjBC,oBAAoB;EACpBC,kBAAkB;EAClBC;AAMF,CAAC,KAA2B;EAC1B,MAAMC,wBAAwB,CAAiC;IAC7D,MAAMC,mBAAmBA,CAAA,EAAqB;MAC5C,MAAMC,GAAG,GAAI,MAAMN,iBAAiB,CAACO,yBAAyB,CAAC,CAA4B;MAC3F,OAAOT,qBAAqB,CAAC,CAACQ,GAAG,CAAC,CAAC;IACrC;IAEA,MAAME,uBAAuBA,CAAA,EAAqB;MAChD,MAAMF,GAAG,GAAI,MAAMN,iBAAiB,CAACS,6BAA6B,CAAC,CAA4B;MAC/F,OAAOX,qBAAqB,CAAC,CAACQ,GAAG,CAAC,CAAC;IACrC;IAEA,MAAMI,6BAA6BA,CAAA,EAAqB;MACtD,MAAMC,KAAK,GAAI,MAAMX,iBAAiB,CAACY,+BAA+B,CACpE,KACF,CAAwC;MACxC,OAAOd,qBAAqB,CAAC,CAACa,KAAK,CAAC,CAAC;IACvC;IAEA,MAAME,iCAAiCA,CAAA,EAAqB;MAC1D,MAAMF,KAAK,GAAI,MAAMX,iBAAiB,CAACc,mCAAmC,CACxE,KACF,CAAwC;MACxC,OAAOhB,qBAAqB,CAAC,CAACa,KAAK,CAAC,CAAC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I,CAACF,QAAQ,EAAE,MAAM,IAAID,KAAK,CAAC,4BAA4B,CAAC;MAE5D,MAAMI,YAAY,GAAG,GAAGH,QAAQ,IAAIhC,OAAO,CAACoC,QAAQ,EAAE;MAEtD,MAAM7B,QAAQ,GAAG,MAAMxB,QAAQ,CAACsD,aAAa,CAACrC,OAAO,CAACsC,OAAO,EAAEH,YAAY,CAAC;MAC5E,IAAI5D,WAAW,CAACyB,OAAO,CAACuC,QAAQ,IAAI,EAAE,CAAC,CAACC,KAAK,CAAC,aAAa,CAAC,EAAE;QAC5D,MAAM1D,kBAAkB,CAAC2D,kBAAkB,CAAClC,QAAQ,CAACmC,GAAG,CAAC;MAC3D;MACA,OAAOnC,QAAQ,CAACmC,GAAG;IACrB;IAEAC,oBAAoBA,CAACC,eAAe,GAAG,KAAK,EAA2C;MACrF,MAAMZ,QAAQ,GAAGjD,QAAQ,CAACmD,cAAc;MACxC,IAAI,CAACF,QAAQ,EAAE,MAAM,IAAID,KAAK,CAAC,4BAA4B,CAAC;MAE5D,MAAMc,QAAQ,GAAG,UAAUC,IAAI,CAACC,GAAG,CAAC,CAAC,IAAIH,eAAe,EAAE;MAC1D,OAAO;QACLF,GAAG,EAAE,GAAGV,QAAQ,IAAIa,QAAQ,EAAE;QAC9BG,cAAc,EAAE,GAAGhB,QAAQ,IAAIa,QAAQ;MACzC,CAAC;IACH;EACF;EAEA,OAAO,IAAI7D,wBAAwB,CAAC,CAAC;AACvC,CAAC;AAED,eAAeL,qBAAqB","ignoreList":[]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.9.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.9.1';\nexport default VERSION;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,OAAO;AACvB,eAAeA,OAAO","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ import type { StringSet } from '../localization/StringSet.type';
|
|
|
14
14
|
import type { ClipboardServiceInterface, FileServiceInterface, MediaServiceInterface, NotificationServiceInterface, PlayerServiceInterface, RecorderServiceInterface } from '../platform/types';
|
|
15
15
|
import { ErrorBoundaryProps, LocalCacheStorage } from '../types';
|
|
16
16
|
export declare const SendbirdUIKit: Readonly<{
|
|
17
|
-
VERSION: "3.9.
|
|
17
|
+
VERSION: "3.9.1";
|
|
18
18
|
PLATFORM: string;
|
|
19
19
|
DEFAULT: {
|
|
20
20
|
AUTO_PUSH_TOKEN_REGISTRATION: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const VERSION = "3.9.
|
|
1
|
+
declare const VERSION = "3.9.1";
|
|
2
2
|
export default VERSION;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-react-native",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sendbird",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@openspacelabs/react-native-zoomable-view": "^2.1.5",
|
|
63
|
-
"@sendbird/uikit-chat-hooks": "3.9.
|
|
64
|
-
"@sendbird/uikit-react-native-foundation": "3.9.
|
|
63
|
+
"@sendbird/uikit-chat-hooks": "3.9.1",
|
|
64
|
+
"@sendbird/uikit-react-native-foundation": "3.9.1",
|
|
65
65
|
"@sendbird/uikit-tools": "0.0.1-alpha.77",
|
|
66
|
-
"@sendbird/uikit-utils": "3.9.
|
|
66
|
+
"@sendbird/uikit-utils": "3.9.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"expo-file-system": "^15.2.2",
|
|
84
84
|
"expo-image-manipulator": "^11.1.1",
|
|
85
85
|
"expo-image-picker": "^14.1.1",
|
|
86
|
-
"expo-media-library": "^
|
|
86
|
+
"expo-media-library": "^16.0.0",
|
|
87
87
|
"expo-notifications": "^0.18.1",
|
|
88
88
|
"expo-video-thumbnails": "^7.2.1",
|
|
89
89
|
"glob": "^7.2.0",
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"expo-file-system": ">=13.1.4",
|
|
121
121
|
"expo-image-manipulator": ">=11.0.0",
|
|
122
122
|
"expo-image-picker": ">=12.0.2",
|
|
123
|
+
"expo-media-library": ">=16.0.0",
|
|
123
124
|
"expo-notifications": ">=0.14.1",
|
|
124
125
|
"expo-video-thumbnails": ">=6.4.0",
|
|
125
126
|
"react": ">=17.0.2",
|
|
@@ -177,6 +178,9 @@
|
|
|
177
178
|
"expo-notifications": {
|
|
178
179
|
"optional": true
|
|
179
180
|
},
|
|
181
|
+
"expo-media-library": {
|
|
182
|
+
"optional": true
|
|
183
|
+
},
|
|
180
184
|
"expo-video-thumbnails": {
|
|
181
185
|
"optional": true
|
|
182
186
|
},
|
|
@@ -213,5 +217,5 @@
|
|
|
213
217
|
]
|
|
214
218
|
]
|
|
215
219
|
},
|
|
216
|
-
"gitHead": "
|
|
220
|
+
"gitHead": "83e3acf677236ee37a3608fdd32e283b62d87bbf"
|
|
217
221
|
}
|
|
@@ -34,23 +34,36 @@ const createExpoFileService = ({
|
|
|
34
34
|
const res = (await imagePickerModule.getCameraPermissionsAsync()) as ExpoPermissionResponse;
|
|
35
35
|
return expoPermissionGranted([res]);
|
|
36
36
|
}
|
|
37
|
+
|
|
37
38
|
async requestCameraPermission(): Promise<boolean> {
|
|
38
39
|
const res = (await imagePickerModule.requestCameraPermissionsAsync()) as ExpoPermissionResponse;
|
|
39
40
|
return expoPermissionGranted([res]);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
async hasMediaLibraryReadPermission(): Promise<boolean> {
|
|
42
44
|
const perms = (await imagePickerModule.getMediaLibraryPermissionsAsync(
|
|
43
|
-
|
|
45
|
+
false,
|
|
44
46
|
)) as ExpoMediaLibraryPermissionResponse;
|
|
45
47
|
return expoPermissionGranted([perms]);
|
|
46
48
|
}
|
|
47
|
-
|
|
49
|
+
|
|
50
|
+
async requestMediaLibraryReadPermission(): Promise<boolean> {
|
|
48
51
|
const perms = (await imagePickerModule.requestMediaLibraryPermissionsAsync(
|
|
49
|
-
|
|
52
|
+
false,
|
|
50
53
|
)) as ExpoMediaLibraryPermissionResponse;
|
|
51
54
|
return expoPermissionGranted([perms]);
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
async hasMediaLibraryWritePermission(): Promise<boolean> {
|
|
58
|
+
const perms = (await mediaLibraryModule.getPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;
|
|
59
|
+
return expoPermissionGranted([perms]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async requestMediaLibraryWritePermission(): Promise<boolean> {
|
|
63
|
+
const perms = (await mediaLibraryModule.requestPermissionsAsync(true, [])) as ExpoMediaLibraryPermissionResponse;
|
|
64
|
+
return expoPermissionGranted([perms]);
|
|
65
|
+
}
|
|
66
|
+
|
|
54
67
|
async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {
|
|
55
68
|
const hasPermission = await this.hasCameraPermission();
|
|
56
69
|
if (!hasPermission) {
|
|
@@ -81,10 +94,11 @@ const createExpoFileService = ({
|
|
|
81
94
|
const [file] = await expoBackwardUtils.imagePicker.toFilePickerResponses(response, fsModule);
|
|
82
95
|
return file;
|
|
83
96
|
}
|
|
97
|
+
|
|
84
98
|
async openMediaLibrary(options: OpenMediaLibraryOptions) {
|
|
85
|
-
const hasPermission = await this.
|
|
99
|
+
const hasPermission = await this.hasMediaLibraryReadPermission();
|
|
86
100
|
if (!hasPermission) {
|
|
87
|
-
const granted = await this.
|
|
101
|
+
const granted = await this.requestMediaLibraryReadPermission();
|
|
88
102
|
if (!granted) {
|
|
89
103
|
options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);
|
|
90
104
|
return null;
|
|
@@ -125,9 +139,9 @@ const createExpoFileService = ({
|
|
|
125
139
|
}
|
|
126
140
|
|
|
127
141
|
async save(options: SaveOptions): Promise<string> {
|
|
128
|
-
const hasPermission = await this.
|
|
142
|
+
const hasPermission = await this.hasMediaLibraryWritePermission();
|
|
129
143
|
if (!hasPermission) {
|
|
130
|
-
const granted = await this.
|
|
144
|
+
const granted = await this.requestMediaLibraryWritePermission();
|
|
131
145
|
if (!granted) throw new Error('Permission not granted');
|
|
132
146
|
}
|
|
133
147
|
|
|
@@ -142,6 +156,7 @@ const createExpoFileService = ({
|
|
|
142
156
|
}
|
|
143
157
|
return response.uri;
|
|
144
158
|
}
|
|
159
|
+
|
|
145
160
|
createRecordFilePath(customExtension = 'm4a'): { recordFilePath: string; uri: string } {
|
|
146
161
|
const basePath = fsModule.cacheDirectory;
|
|
147
162
|
if (!basePath) throw new Error('Cannot determine directory');
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const VERSION = '3.9.
|
|
1
|
+
const VERSION = '3.9.1';
|
|
2
2
|
export default VERSION;
|