stream-chat-react-native 6.0.0-rc.2 → 6.0.0-rc.20

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/package.json CHANGED
@@ -1,20 +1,28 @@
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": "6.0.0-rc.2",
4
+ "version": "6.0.0-rc.20",
5
+ "homepage": "https://www.npmjs.com/package/stream-chat-react-native",
5
6
  "author": {
6
7
  "company": "Stream.io Inc",
7
8
  "name": "Stream.io Inc"
8
9
  },
10
+ "files": [
11
+ "src",
12
+ "types",
13
+ "android",
14
+ "ios",
15
+ "*.podspec",
16
+ "package.json"
17
+ ],
9
18
  "license": "SEE LICENSE IN LICENSE",
10
19
  "main": "src/index.js",
11
20
  "types": "types/index.d.ts",
12
21
  "dependencies": {
13
22
  "es6-symbol": "^3.1.3",
14
- "stream-chat-react-native-core": "6.0.0-rc.2"
23
+ "stream-chat-react-native-core": "6.0.0-rc.20"
15
24
  },
16
25
  "peerDependencies": {
17
- "@bam.tech/react-native-image-resizer": ">=3.0.10",
18
26
  "@react-native-camera-roll/camera-roll": ">=7.8.0",
19
27
  "@react-native-clipboard/clipboard": ">=1.14.1",
20
28
  "@stream-io/flat-list-mvcp": ">=0.10.3",
@@ -64,7 +72,11 @@
64
72
  "postpack": "rm README.md"
65
73
  },
66
74
  "devDependencies": {
67
- "@bam.tech/react-native-image-resizer": ">=3.0.10",
68
75
  "react-native": ">=0.67.0"
76
+ },
77
+ "codegenConfig": {
78
+ "name": "StreamChatReactNativeSpec",
79
+ "type": "modules",
80
+ "jsSrcsDir": "src/native"
69
81
  }
70
82
  }
@@ -1,5 +1,4 @@
1
- // @ts-ignore this module does not have a type declaration
2
- import ImageResizer from '@bam.tech/react-native-image-resizer';
1
+ import StreamChatReactNative from '../native';
3
2
 
4
3
  type CompressImageParams = {
5
4
  compressImageQuality: number;
@@ -15,7 +14,7 @@ export const compressImage = async ({
15
14
  width,
16
15
  }: CompressImageParams) => {
17
16
  try {
18
- const { uri: compressedUri } = await ImageResizer.createResizedImage(
17
+ const { uri: compressedUri } = await StreamChatReactNative.createResizedImage(
19
18
  uri,
20
19
  width,
21
20
  height,
@@ -28,7 +27,7 @@ export const compressImage = async ({
28
27
  );
29
28
  return compressedUri;
30
29
  } catch (error) {
31
- console.log(error);
30
+ console.log('Error resizing image:', error);
32
31
  return uri;
33
32
  }
34
33
  };
@@ -0,0 +1,24 @@
1
+ import type { TurboModule } from 'react-native';
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+
5
+ export interface Spec extends TurboModule {
6
+ createResizedImage(
7
+ uri: string,
8
+ width: number,
9
+ height: number,
10
+ format: string,
11
+ quality: number,
12
+ mode: string,
13
+ onlyScaleDown: boolean,
14
+ rotation?: number,
15
+ outputPath?: string | null,
16
+ keepMeta?: boolean,
17
+ ): Promise<{
18
+ base64: string;
19
+ height: number;
20
+ name: string;
21
+ }>;
22
+ }
23
+
24
+ export default TurboModuleRegistry.getEnforcing<Spec>('StreamChatReactNative');
@@ -0,0 +1,48 @@
1
+ import { NativeModules } from 'react-native';
2
+
3
+ import type { Options, ResizeFormat, Response } from './types';
4
+ export type { ResizeFormat, ResizeMode, Response } from './types';
5
+
6
+ // @ts-ignore
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
9
+
10
+ const ImageResizer = isTurboModuleEnabled
11
+ ? require('./NativeStreamChatReactNative').default
12
+ : NativeModules.StreamChatReactNative;
13
+
14
+ const defaultOptions: Options = {
15
+ mode: 'contain',
16
+ onlyScaleDown: false,
17
+ };
18
+
19
+ async function createResizedImage(
20
+ uri: string,
21
+ width: number,
22
+ height: number,
23
+ format: ResizeFormat,
24
+ quality: number,
25
+ rotation: number = 0,
26
+ outputPath?: string | null,
27
+ keepMeta = false,
28
+ options: Options = defaultOptions,
29
+ ): Promise<Response> {
30
+ const { mode, onlyScaleDown } = { ...defaultOptions, ...options };
31
+
32
+ return await ImageResizer.createResizedImage(
33
+ uri,
34
+ width,
35
+ height,
36
+ format,
37
+ quality,
38
+ mode,
39
+ onlyScaleDown,
40
+ rotation,
41
+ outputPath,
42
+ keepMeta,
43
+ );
44
+ }
45
+
46
+ export default {
47
+ createResizedImage,
48
+ };
@@ -0,0 +1,32 @@
1
+ export interface Response {
2
+ height: number;
3
+ name: string;
4
+ path: string;
5
+ size: number;
6
+ uri: string;
7
+ width: number;
8
+ }
9
+
10
+ export type ResizeFormat = 'PNG' | 'JPEG' | 'WEBP';
11
+ export type ResizeMode = 'contain' | 'cover' | 'stretch';
12
+
13
+ export type Options = {
14
+ /**
15
+ * Either `contain` (the default), `cover`, or `stretch`. Similar to
16
+ * [react-native <Image>'s resizeMode](https://reactnative.dev/docs/image#resizemode)
17
+ *
18
+ * - `contain` will fit the image within `width` and `height`,
19
+ * preserving its ratio
20
+ * - `cover` will make sure at least one dimension fits `width` or
21
+ * `height`, and the other is larger, also preserving its ratio.
22
+ * - `stretch` will resize the image to exactly `width` and `height`.
23
+ *
24
+ * (Default: 'contain')
25
+ */
26
+ mode?: ResizeMode;
27
+ /**
28
+ * Whether to avoid resizing the image to be larger than the original.
29
+ * (Default: false)
30
+ */
31
+ onlyScaleDown?: boolean;
32
+ };
@@ -16,7 +16,6 @@ try {
16
16
  audioRecorderPlayer.setSubscriptionDuration(Platform.OS === 'android' ? 0.1 : 0.06);
17
17
  } catch (e) {
18
18
  console.log('react-native-audio-recorder-player is not installed.');
19
- console.log(e);
20
19
  }
21
20
 
22
21
  export enum AudioSourceAndroidType {
@@ -35,6 +35,7 @@ export const pickImage = ImagePicker
35
35
  }
36
36
  } catch (error) {
37
37
  console.log('Error picking image: ', error);
38
+ return { cancelled: true };
38
39
  }
39
40
  }
40
41
  : null;
@@ -0,0 +1,38 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "stream-chat-react-native"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "10.0" }
15
+ s.source = { :git => "./ios", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ s.dependency "React-Core"
20
+ s.ios.framework = 'AssetsLibrary', 'MobileCoreServices'
21
+
22
+ # Don't install the dependencies when we run `pod install` in the old architecture.
23
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25
+ s.pod_target_xcconfig = {
26
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
27
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
28
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
29
+ }
30
+ s.dependency "React-Codegen"
31
+ s.dependency "RCT-Folly"
32
+ s.dependency "RCTRequired"
33
+ s.dependency "RCTTypeSafety"
34
+ s.dependency "ReactCommon/turbomodule/core"
35
+ install_modules_dependencies(s)
36
+ end
37
+ end
38
+