stream-chat-react-native 5.39.5 → 5.40.0-rc.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/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  > The official React Native and Expo components for Stream Chat, a service for
8
8
  > building chat applications.
9
9
 
10
-
11
10
  [![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native)
12
11
  [![Build Status](https://github.com/GetStream/stream-chat-react-native/actions/workflows/release.yml/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions)
13
12
  [![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native",
3
3
  "description": "The official React Native SDK for Stream Chat, a service for building chat applications",
4
- "version": "5.39.5",
4
+ "version": "5.40.0-rc.1",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -11,22 +11,20 @@
11
11
  "types": "types/index.d.ts",
12
12
  "dependencies": {
13
13
  "es6-symbol": "^3.1.3",
14
- "stream-chat-react-native-core": "5.39.5"
14
+ "stream-chat-react-native-core": "5.40.0-rc.1"
15
15
  },
16
16
  "peerDependencies": {
17
- "@react-native-camera-roll/camera-roll": ">=5.0.0",
18
- "@react-native-clipboard/clipboard": "^1.11.1",
19
- "@react-native-community/netinfo": ">=2.0.7",
20
- "@stream-io/flat-list-mvcp": "^0.10.3",
21
- "react-native": ">=0.60.0",
17
+ "@bam.tech/react-native-image-resizer": ">=3.0.10",
18
+ "@react-native-camera-roll/camera-roll": ">=7.8.0",
19
+ "@react-native-clipboard/clipboard": ">=1.14.1",
20
+ "@stream-io/flat-list-mvcp": ">=0.10.3",
21
+ "react-native": ">=0.67.0",
22
22
  "react-native-audio-recorder-player": ">=3.6.4",
23
- "react-native-document-picker": ">=9.0.1",
24
- "react-native-fs": ">=2.16.6",
25
- "react-native-haptic-feedback": ">=1.11.0",
23
+ "react-native-blob-util": ">=0.19.9",
24
+ "react-native-document-picker": ">=9.3.0",
25
+ "react-native-haptic-feedback": ">=2.2.0",
26
26
  "react-native-image-picker": ">=7.1.2",
27
- "react-native-image-crop-picker": ">=0.33.2",
28
- "react-native-image-resizer": ">=1.4.2",
29
- "react-native-share": ">=4.1.0",
27
+ "react-native-share": ">=10.2.1",
30
28
  "react-native-video": ">=6.4.2"
31
29
  },
32
30
  "peerDependenciesMeta": {
@@ -36,6 +34,9 @@
36
34
  "@react-native-clipboard/clipboard": {
37
35
  "optional": true
38
36
  },
37
+ "@stream-io/flat-list-mvcp": {
38
+ "optional": true
39
+ },
39
40
  "react-native-share": {
40
41
  "optional": true
41
42
  },
@@ -48,14 +49,14 @@
48
49
  "react-native-image-picker": {
49
50
  "optional": true
50
51
  },
51
- "react-native-image-crop-picker": {
52
- "optional": true
53
- },
54
52
  "react-native-audio-recorder-player": {
55
53
  "optional": true
56
54
  },
57
55
  "react-native-video": {
58
56
  "optional": true
57
+ },
58
+ "react-native-blob-util": {
59
+ "optional": true
59
60
  }
60
61
  },
61
62
  "scripts": {
@@ -63,10 +64,7 @@
63
64
  "postpack": "rm README.md"
64
65
  },
65
66
  "devDependencies": {
66
- "@react-native-community/netinfo": ">=2.0.7",
67
- "@stream-io/flat-list-mvcp": "0.10.3",
68
- "react-native": ">=0.60.0",
69
- "react-native-fs": ">=2.16.6",
70
- "react-native-image-resizer": ">=1.4.2"
67
+ "@bam.tech/react-native-image-resizer": ">=3.0.10",
68
+ "react-native": ">=0.67.0"
71
69
  }
72
70
  }
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore this module does not have a type declaration
2
- import ImageResizer from 'react-native-image-resizer';
2
+ import ImageResizer from '@bam.tech/react-native-image-resizer';
3
3
 
4
4
  type CompressImageParams = {
5
5
  compressImageQuality: number;
@@ -1,6 +1 @@
1
- export * from './deleteFile';
2
1
  export * from './compressImage';
3
- export * from './NetInfo';
4
- export * from './saveFile';
5
- export * from './Sound';
6
- export * from './Video';
package/src/index.js CHANGED
@@ -1,22 +1,26 @@
1
1
  import { Platform } from 'react-native';
2
2
 
3
- import { FlatList } from '@stream-io/flat-list-mvcp';
4
3
  import { registerNativeHandlers } from 'stream-chat-react-native-core';
5
4
 
6
- import { compressImage, deleteFile, NetInfo, saveFile, Sound, Video } from './handlers';
5
+ import { compressImage } from './handlers';
7
6
 
8
7
  import {
9
8
  Audio,
9
+ deleteFile,
10
+ FlatList,
10
11
  getLocalAssetUri,
11
12
  getPhotos,
12
13
  iOS14RefreshGallerySelection,
13
14
  oniOS14GalleryLibrarySelectionChange,
14
15
  pickDocument,
15
16
  pickImage,
17
+ saveFile,
16
18
  setClipboardString,
17
19
  shareImage,
20
+ Sound,
18
21
  takePhoto,
19
22
  triggerHaptic,
23
+ Video,
20
24
  } from './optionalDependencies';
21
25
 
22
26
  registerNativeHandlers({
@@ -27,7 +31,6 @@ registerNativeHandlers({
27
31
  getLocalAssetUri,
28
32
  getPhotos,
29
33
  iOS14RefreshGallerySelection,
30
- NetInfo,
31
34
  oniOS14GalleryLibrarySelectionChange,
32
35
  pickDocument,
33
36
  pickImage,
@@ -1,8 +1,15 @@
1
1
  import { PermissionsAndroid, Platform } from 'react-native';
2
- import RNFS from 'react-native-fs';
3
2
  let AudioRecorderPackage;
4
3
  let audioRecorderPlayer;
5
4
 
5
+ let RNBlobUtil;
6
+
7
+ try {
8
+ RNBlobUtil = require('react-native-blob-util').default;
9
+ } catch (e) {
10
+ console.log('react-native-blob-util is not installed');
11
+ }
12
+
6
13
  try {
7
14
  AudioRecorderPackage = require('react-native-audio-recorder-player').default;
8
15
  audioRecorderPlayer = new AudioRecorderPackage();
@@ -197,7 +204,7 @@ class _Audio {
197
204
  }
198
205
  try {
199
206
  const path = Platform.select({
200
- android: `${RNFS.CachesDirectoryPath}/sound.aac`,
207
+ android: `${RNBlobUtil.fs.dirs.CacheDir}/sound.aac`,
201
208
  ios: 'sound.aac',
202
209
  });
203
210
  const audioSet = {
@@ -249,4 +256,4 @@ class _Audio {
249
256
  };
250
257
  }
251
258
 
252
- export const Audio = AudioRecorderPackage ? new _Audio() : null;
259
+ export const Audio = AudioRecorderPackage && RNBlobUtil ? new _Audio() : null;
@@ -0,0 +1,21 @@
1
+ import { FlatList as DefaultFlatList, Platform } from 'react-native';
2
+ let FlatList;
3
+
4
+
5
+ if (Platform.constants.reactNativeVersion.minor < 72) {
6
+ const upgradeLog =
7
+ "'@stream-io/flat-list-mvcp' is deprecated, please upgrade your react-native version to >0.71 to get same the benefits on the default FlatList and uninstall the package.";
8
+ try {
9
+ FlatList = require('@stream-io/flat-list-mvcp').FlatList;
10
+ console.log(upgradeLog);
11
+ } catch (error) {
12
+ console.log(
13
+ `@stream-io/flat-list-mvcp not found, using react-native's FlatList. This library is used to achieve bi-directional infinite scrolling on lower react native versions. ${upgradeLog}`,
14
+ );
15
+ FlatList = require('react-native').FlatList;
16
+ }
17
+ } else {
18
+ FlatList = DefaultFlatList;
19
+ }
20
+
21
+ export { FlatList };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import AudioVideoPlayer from '../optionalDependencies/Video';
3
+ import AudioVideoPlayer from './AudioVideo';
4
4
 
5
5
  export const Sound = {
6
6
  initializeSound: null,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
+ import AudioVideoPlayer from './AudioVideo';
2
3
 
3
- import AudioVideoPlayer from '../optionalDependencies/Video';
4
4
  export const Video = AudioVideoPlayer
5
5
  ? ({ onBuffer, onEnd, onLoad, onProgress, paused, repeat, resizeMode, style, uri, videoRef }) => (
6
6
  <AudioVideoPlayer
@@ -0,0 +1,19 @@
1
+ let RNBlobUtil;
2
+
3
+ try {
4
+ RNBlobUtil = require('react-native-blob-util').default;
5
+ } catch (e) {
6
+ console.log('react-native-blob-util is not installed');
7
+ }
8
+
9
+ export const deleteFile = RNBlobUtil
10
+ ? async ({ uri }) => {
11
+ try {
12
+ await RNBlobUtil.fs.unlink(uri);
13
+ return true;
14
+ } catch (error) {
15
+ console.log('File deletion failed...', error);
16
+ return false;
17
+ }
18
+ }
19
+ : null;
@@ -5,7 +5,7 @@ try {
5
5
  } catch (e) {
6
6
  // do nothing
7
7
  console.log(
8
- '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
8
+ '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-picker for native image picker.',
9
9
  );
10
10
  }
11
11
 
@@ -7,7 +7,7 @@ try {
7
7
  } catch (e) {
8
8
  // do nothing
9
9
  console.log(
10
- '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
10
+ '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-picker for native image picker.',
11
11
  );
12
12
  }
13
13
 
@@ -7,7 +7,7 @@ try {
7
7
  } catch (e) {
8
8
  // do nothing
9
9
  console.log(
10
- '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
10
+ '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-picker for native image picker.',
11
11
  );
12
12
  }
13
13
 
@@ -1,12 +1,16 @@
1
1
  export * from './Audio';
2
- export * from './shareImage';
3
- export * from './Video';
4
- export * from './triggerHaptic';
5
- export * from './setClipboardString';
6
- export * from './pickDocument';
2
+ export * from './deleteFile';
3
+ export * from './FlatList';
7
4
  export * from './getLocalAssetUri';
5
+ export * from './getPhotos';
8
6
  export * from './iOS14RefreshGallerySelection';
9
7
  export * from './oniOS14GalleryLibrarySelectionChange';
10
- export * from './getPhotos';
8
+ export * from './pickDocument';
11
9
  export * from './pickImage';
10
+ export * from './saveFile';
11
+ export * from './setClipboardString';
12
+ export * from './shareImage';
13
+ export * from './Sound';
12
14
  export * from './takePhoto';
15
+ export * from './triggerHaptic';
16
+ export * from './Video';
@@ -7,7 +7,7 @@ try {
7
7
  } catch (e) {
8
8
  // do nothing
9
9
  console.log(
10
- '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
10
+ '@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-picker for native image picker.',
11
11
  );
12
12
  }
13
13
 
@@ -0,0 +1,24 @@
1
+ let RNBlobUtil;
2
+
3
+ try {
4
+ RNBlobUtil = require('react-native-blob-util').default;
5
+ } catch (e) {
6
+ console.log('react-native-blob-util is not installed');
7
+ }
8
+
9
+ export const saveFile = RNBlobUtil
10
+ ? async ({ fileName, fromUrl }) => {
11
+ try {
12
+ const path = RNBlobUtil.fs.dirs.CacheDir + '/' + encodeURIComponent(fileName);
13
+ await RNBlobUtil.config({
14
+ fileCache: true,
15
+ path,
16
+ }).fetch('GET', fromUrl);
17
+
18
+ return path;
19
+ } catch (error) {
20
+ console.log('Downloading image failed...', error);
21
+ throw new Error('Downloading image failed...');
22
+ }
23
+ }
24
+ : null;
@@ -1,5 +1,4 @@
1
1
  import { Platform } from 'react-native';
2
- import RNFS from 'react-native-fs';
3
2
 
4
3
  let RNShare;
5
4
 
@@ -9,10 +8,18 @@ try {
9
8
  console.log('react-native-share is not installed');
10
9
  }
11
10
 
11
+ let RNBlobUtil;
12
+
13
+ try {
14
+ RNBlobUtil = require('react-native-blob-util').default;
15
+ } catch (e) {
16
+ console.log('react-native-blob-util is not installed');
17
+ }
18
+
12
19
  export const shareImage = RNShare
13
20
  ? async ({ type, url }) => {
14
21
  try {
15
- const base64Image = await RNFS.readFile(url, 'base64');
22
+ const base64Image = await RNBlobUtil.fs.readFile(url, 'base64');
16
23
  const base64Url = `data:${type};base64,${base64Image}`;
17
24
  await RNShare.open({
18
25
  activityItemSources:
@@ -35,9 +42,6 @@ export const shareImage = RNShare
35
42
  },
36
43
  ]
37
44
  : undefined,
38
- // react-native-share has a typing issue, where their docs confirm that
39
- // this property should be an array of strings, but the type is a string
40
- // in the @types/react-native-share package.
41
45
  excludedActivityTypes: [] as unknown as string,
42
46
  failOnCancel: false,
43
47
  type,
@@ -45,7 +49,7 @@ export const shareImage = RNShare
45
49
  });
46
50
  return true;
47
51
  } catch (error) {
48
- console.warn('Sharing failed...');
52
+ console.warn('Sharing failed...', error);
49
53
  }
50
54
  }
51
55
  : null;
@@ -3,9 +3,11 @@ import { AppState, Image, PermissionsAndroid, Platform } from 'react-native';
3
3
  let ImagePicker;
4
4
 
5
5
  try {
6
- ImagePicker = require('react-native-image-crop-picker').default;
6
+ ImagePicker = require('react-native-image-picker');
7
7
  } catch (e) {
8
- console.log('react-native-image-crop-picker is not installed');
8
+ console.log(
9
+ 'The package react-native-image-picker is not installed. Please install the same so as to take photo through camera and upload it.',
10
+ );
9
11
  }
10
12
 
11
13
  export const takePhoto = ImagePicker
@@ -26,20 +28,22 @@ export const takePhoto = ImagePicker
26
28
  }
27
29
  }
28
30
  try {
29
- const photo = await ImagePicker.openCamera({
30
- compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
31
+ const result = await ImagePicker.launchCamera({
32
+ quality: Math.min(Math.max(0, compressImageQuality), 1),
31
33
  });
32
- if (photo.height && photo.width && photo.path) {
34
+ if (!result.assets.length) {
35
+ return {
36
+ cancelled: true,
37
+ };
38
+ }
39
+ const photo = result.assets[0];
40
+ if (photo.height && photo.width && photo.uri) {
33
41
  let size: { height?: number; width?: number } = {};
34
42
  if (Platform.OS === 'android') {
35
43
  // Height and width returned by ImagePicker are incorrect on Android.
36
- // The issue is described in following github issue:
37
- // https://github.com/ivpusic/react-native-image-crop-picker/issues/901
38
- // This we can't rely on them as it is, and we need to use Image.getSize
39
- // to get accurate size.
40
44
  const getSize = (): Promise<{ height: number; width: number }> =>
41
45
  new Promise((resolve) => {
42
- Image.getSize(photo.path, (width, height) => {
46
+ Image.getSize(photo.uri, (width, height) => {
43
47
  resolve({ height, width });
44
48
  });
45
49
  });
@@ -62,7 +66,7 @@ export const takePhoto = ImagePicker
62
66
  cancelled: false,
63
67
  size: photo.size,
64
68
  source: 'camera',
65
- uri: photo.path,
69
+ uri: photo.uri,
66
70
  ...size,
67
71
  };
68
72
  }
@@ -1,43 +0,0 @@
1
- import { NetInfoState, default as OriginalNetInfo } from '@react-native-community/netinfo';
2
-
3
- export const NetInfo = {
4
- addEventListener(listener) {
5
- let unsubscribe;
6
- // For NetInfo >= 3.x.x
7
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
8
- unsubscribe = OriginalNetInfo.addEventListener(({ isConnected, isInternetReachable }) => {
9
- // Initialize with truthy value when internetReachable is still loading
10
- // if it resolves to false, listener is triggered with false value and network
11
- // status is updated
12
- listener(isInternetReachable === null ? isConnected : isConnected && isInternetReachable);
13
- });
14
- return unsubscribe;
15
- } else {
16
- // For NetInfo < 3.x.x
17
- unsubscribe = OriginalNetInfo.addEventListener('connectionChange', () => {
18
- // @ts-ignore
19
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
20
- listener(isConnected);
21
- });
22
- });
23
-
24
- return unsubscribe.remove;
25
- }
26
- },
27
- fetch() {
28
- return new Promise((resolve, reject) => {
29
- // For NetInfo >= 3.x.x
30
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
31
- OriginalNetInfo.fetch().then(({ isConnected }) => {
32
- resolve(isConnected);
33
- }, reject);
34
- } else {
35
- // For NetInfo < 3.x.x
36
- // @ts-ignore
37
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
38
- resolve(isConnected);
39
- }, reject);
40
- }
41
- });
42
- },
43
- };
@@ -1,11 +0,0 @@
1
- import RNFS from 'react-native-fs';
2
-
3
- export const deleteFile = async ({ uri }: { uri: string }) => {
4
- try {
5
- await RNFS.unlink(uri);
6
- return true;
7
- } catch (error) {
8
- console.log('File deletion failed...');
9
- return false;
10
- }
11
- };
@@ -1,11 +0,0 @@
1
- import RNFS from 'react-native-fs';
2
-
3
- export const saveFile = async ({ fileName, fromUrl }: { fileName: string; fromUrl: string }) => {
4
- try {
5
- const path = RNFS.CachesDirectoryPath + '/' + encodeURIComponent(fileName);
6
- await RNFS.downloadFile({ fromUrl, toFile: path }).promise;
7
- return 'file://' + path;
8
- } catch (error) {
9
- throw new Error('Downloading image failed...');
10
- }
11
- };