react-native-srschat 0.1.0

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.
Files changed (65) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +33 -0
  3. package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
  4. package/android/generated/android/app/build/generated/source/codegen/jni/RNSrschatSpec-generated.cpp +22 -0
  5. package/android/generated/android/app/build/generated/source/codegen/jni/RNSrschatSpec.h +24 -0
  6. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNSrschatSpec/RNSrschatSpecJSI-generated.cpp +17 -0
  7. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNSrschatSpec/RNSrschatSpecJSI.h +19 -0
  8. package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm +2321 -0
  9. package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h +2761 -0
  10. package/ios/generated/build/generated/ios/FBReactNativeSpecJSI-generated.cpp +2923 -0
  11. package/ios/generated/build/generated/ios/FBReactNativeSpecJSI.h +7718 -0
  12. package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.h +18 -0
  13. package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.mm +33 -0
  14. package/ios/generated/build/generated/ios/RNSrschatSpec/RNSrschatSpec-generated.mm +16 -0
  15. package/ios/generated/build/generated/ios/RNSrschatSpec/RNSrschatSpec.h +35 -0
  16. package/ios/generated/build/generated/ios/RNSrschatSpecJSI-generated.cpp +17 -0
  17. package/ios/generated/build/generated/ios/RNSrschatSpecJSI.h +19 -0
  18. package/lib/commonjs/components/Chat.js +43 -0
  19. package/lib/commonjs/components/Chat.js.map +1 -0
  20. package/lib/commonjs/components/ChatInput.js +64 -0
  21. package/lib/commonjs/components/ChatInput.js.map +1 -0
  22. package/lib/commonjs/components/ChatMessage.js +58 -0
  23. package/lib/commonjs/components/ChatMessage.js.map +1 -0
  24. package/lib/commonjs/index.js +37 -0
  25. package/lib/commonjs/index.js.map +1 -0
  26. package/lib/commonjs/types.js +2 -0
  27. package/lib/commonjs/types.js.map +1 -0
  28. package/lib/module/components/Chat.js +39 -0
  29. package/lib/module/components/Chat.js.map +1 -0
  30. package/lib/module/components/ChatInput.js +60 -0
  31. package/lib/module/components/ChatInput.js.map +1 -0
  32. package/lib/module/components/ChatMessage.js +54 -0
  33. package/lib/module/components/ChatMessage.js.map +1 -0
  34. package/lib/module/index.js +8 -0
  35. package/lib/module/index.js.map +1 -0
  36. package/lib/module/types.js +2 -0
  37. package/lib/module/types.js.map +1 -0
  38. package/lib/typescript/commonjs/package.json +1 -0
  39. package/lib/typescript/commonjs/src/components/Chat.d.ts +3 -0
  40. package/lib/typescript/commonjs/src/components/Chat.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/src/components/ChatInput.d.ts +6 -0
  42. package/lib/typescript/commonjs/src/components/ChatInput.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/src/components/ChatMessage.d.ts +8 -0
  44. package/lib/typescript/commonjs/src/components/ChatMessage.d.ts.map +1 -0
  45. package/lib/typescript/commonjs/src/index.d.ts +4 -0
  46. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  47. package/lib/typescript/commonjs/src/types.d.ts +12 -0
  48. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  49. package/lib/typescript/module/package.json +1 -0
  50. package/lib/typescript/module/src/components/Chat.d.ts +3 -0
  51. package/lib/typescript/module/src/components/Chat.d.ts.map +1 -0
  52. package/lib/typescript/module/src/components/ChatInput.d.ts +6 -0
  53. package/lib/typescript/module/src/components/ChatInput.d.ts.map +1 -0
  54. package/lib/typescript/module/src/components/ChatMessage.d.ts +8 -0
  55. package/lib/typescript/module/src/components/ChatMessage.d.ts.map +1 -0
  56. package/lib/typescript/module/src/index.d.ts +4 -0
  57. package/lib/typescript/module/src/index.d.ts.map +1 -0
  58. package/lib/typescript/module/src/types.d.ts +12 -0
  59. package/lib/typescript/module/src/types.d.ts.map +1 -0
  60. package/package.json +204 -0
  61. package/src/components/Chat.tsx +34 -0
  62. package/src/components/ChatInput.tsx +58 -0
  63. package/src/components/ChatMessage.tsx +51 -0
  64. package/src/index.tsx +6 -0
  65. package/src/types.ts +12 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../../../src/components/Chat.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,wBAAgB,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,SAAS,2CAkBlE"}
@@ -0,0 +1,6 @@
1
+ interface ChatInputProps {
2
+ onSend: (text: string) => void;
3
+ }
4
+ export declare function ChatInput({ onSend }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=ChatInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatInput.tsx"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACtB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,cAAc,2CAwBnD"}
@@ -0,0 +1,8 @@
1
+ import type { Message } from '../types';
2
+ interface ChatMessageProps {
3
+ message: Message;
4
+ isOwnMessage: boolean;
5
+ }
6
+ export declare function ChatMessage({ message, isOwnMessage }: ChatMessageProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ChatMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessage.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatMessage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,gBAAgB,2CAUtE"}
@@ -0,0 +1,4 @@
1
+ export declare function multiply(a: number, b: number): number;
2
+ export * from './components/Chat';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface Message {
2
+ id: string;
3
+ text: string;
4
+ sender: string;
5
+ timestamp: number;
6
+ }
7
+ export interface ChatProps {
8
+ userId: string;
9
+ messages: Message[];
10
+ onSendMessage: (text: string) => void;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC"}
package/package.json ADDED
@@ -0,0 +1,204 @@
1
+ {
2
+ "name": "react-native-srschat",
3
+ "version": "0.1.0",
4
+ "description": "srschat",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./lib/typescript/module/src/index.d.ts",
12
+ "default": "./lib/module/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
16
+ "default": "./lib/commonjs/index.js"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "src",
22
+ "lib",
23
+ "android",
24
+ "ios",
25
+ "cpp",
26
+ "*.podspec",
27
+ "react-native.config.js",
28
+ "!ios/build",
29
+ "!android/build",
30
+ "!android/gradle",
31
+ "!android/gradlew",
32
+ "!android/gradlew.bat",
33
+ "!android/local.properties",
34
+ "!**/__tests__",
35
+ "!**/__fixtures__",
36
+ "!**/__mocks__",
37
+ "!**/.*"
38
+ ],
39
+ "scripts": {
40
+ "example": "yarn workspace react-native-srschat-example",
41
+ "test": "jest",
42
+ "typecheck": "tsc",
43
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
44
+ "clean": "del-cli lib",
45
+ "prepare": "bob build",
46
+ "release": "release-it"
47
+ },
48
+ "keywords": [
49
+ "react-native",
50
+ "ios",
51
+ "android"
52
+ ],
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/alxkai/react-native-srschat.git"
56
+ },
57
+ "author": "alxkai <alex@instalily.ai> (https://github.com/alxkai)",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/alxkai/react-native-srschat/issues"
61
+ },
62
+ "homepage": "https://github.com/alxkai/react-native-srschat#readme",
63
+ "publishConfig": {
64
+ "registry": "https://registry.npmjs.org/"
65
+ },
66
+ "devDependencies": {
67
+ "@commitlint/config-conventional": "^17.0.2",
68
+ "@evilmartians/lefthook": "^1.5.0",
69
+ "@react-native/eslint-config": "^0.73.1",
70
+ "@release-it/conventional-changelog": "^9.0.2",
71
+ "@types/jest": "^29.5.5",
72
+ "@types/react": "^18.2.44",
73
+ "commitlint": "^17.0.2",
74
+ "del-cli": "^5.1.0",
75
+ "eslint": "^8.51.0",
76
+ "eslint-config-prettier": "^9.0.0",
77
+ "eslint-plugin-prettier": "^5.0.1",
78
+ "jest": "^29.7.0",
79
+ "prettier": "^3.0.3",
80
+ "react": "18.3.1",
81
+ "react-native": "0.76.6",
82
+ "react-native-builder-bob": "^0.35.2",
83
+ "release-it": "^17.10.0",
84
+ "typescript": "^5.2.2"
85
+ },
86
+ "resolutions": {
87
+ "@types/react": "^18.2.44"
88
+ },
89
+ "peerDependencies": {
90
+ "react": "*",
91
+ "react-native": "*"
92
+ },
93
+ "workspaces": [
94
+ "example"
95
+ ],
96
+ "packageManager": "yarn@3.6.1",
97
+ "jest": {
98
+ "preset": "react-native",
99
+ "modulePathIgnorePatterns": [
100
+ "<rootDir>/example/node_modules",
101
+ "<rootDir>/lib/"
102
+ ]
103
+ },
104
+ "commitlint": {
105
+ "extends": [
106
+ "@commitlint/config-conventional"
107
+ ]
108
+ },
109
+ "release-it": {
110
+ "git": {
111
+ "commitMessage": "chore: release ${version}",
112
+ "tagName": "v${version}"
113
+ },
114
+ "npm": {
115
+ "publish": true
116
+ },
117
+ "github": {
118
+ "release": true
119
+ },
120
+ "plugins": {
121
+ "@release-it/conventional-changelog": {
122
+ "preset": "angular"
123
+ }
124
+ }
125
+ },
126
+ "eslintConfig": {
127
+ "root": true,
128
+ "extends": [
129
+ "@react-native",
130
+ "prettier"
131
+ ],
132
+ "rules": {
133
+ "react/react-in-jsx-scope": "off",
134
+ "prettier/prettier": [
135
+ "error",
136
+ {
137
+ "quoteProps": "consistent",
138
+ "singleQuote": true,
139
+ "tabWidth": 2,
140
+ "trailingComma": "es5",
141
+ "useTabs": false
142
+ }
143
+ ]
144
+ }
145
+ },
146
+ "eslintIgnore": [
147
+ "node_modules/",
148
+ "lib/"
149
+ ],
150
+ "prettier": {
151
+ "quoteProps": "consistent",
152
+ "singleQuote": true,
153
+ "tabWidth": 2,
154
+ "trailingComma": "es5",
155
+ "useTabs": false
156
+ },
157
+ "react-native-builder-bob": {
158
+ "source": "src",
159
+ "output": "lib",
160
+ "targets": [
161
+ "codegen",
162
+ [
163
+ "commonjs",
164
+ {
165
+ "esm": true
166
+ }
167
+ ],
168
+ [
169
+ "module",
170
+ {
171
+ "esm": true
172
+ }
173
+ ],
174
+ [
175
+ "typescript",
176
+ {
177
+ "project": "tsconfig.build.json",
178
+ "esm": true
179
+ }
180
+ ]
181
+ ]
182
+ },
183
+ "codegenConfig": {
184
+ "name": "RNSrschatSpec",
185
+ "type": "modules",
186
+ "jsSrcsDir": "src",
187
+ "outputDir": {
188
+ "ios": "ios/generated",
189
+ "android": "android/generated"
190
+ },
191
+ "android": {
192
+ "javaPackageName": "com.srschat"
193
+ }
194
+ },
195
+ "create-react-native-library": {
196
+ "languages": "js",
197
+ "type": "library",
198
+ "version": "0.45.5"
199
+ },
200
+ "dependencies": {
201
+ "@expo/vector-icons": "^14.0.4",
202
+ "expo-font": "^13.0.3"
203
+ }
204
+ }
@@ -0,0 +1,34 @@
1
+ import { View, FlatList, StyleSheet } from 'react-native';
2
+ import type { ChatProps } from '../types';
3
+ import { ChatMessage } from './ChatMessage';
4
+ import { ChatInput } from './ChatInput';
5
+
6
+ export function Chat({ userId, messages, onSendMessage }: ChatProps) {
7
+ return (
8
+ <View style={styles.container}>
9
+ <FlatList
10
+ data={messages}
11
+ keyExtractor={(item) => item.id}
12
+ renderItem={({ item }) => (
13
+ <ChatMessage
14
+ message={item}
15
+ isOwnMessage={item.sender === userId}
16
+ />
17
+ )}
18
+ style={styles.messageList}
19
+ inverted
20
+ />
21
+ <ChatInput onSend={onSendMessage} />
22
+ </View>
23
+ );
24
+ }
25
+
26
+ const styles = StyleSheet.create({
27
+ container: {
28
+ flex: 1,
29
+ backgroundColor: '#F2F2F7',
30
+ },
31
+ messageList: {
32
+ flex: 1,
33
+ },
34
+ });
@@ -0,0 +1,58 @@
1
+ import { useState } from 'react';
2
+ import { View, TextInput, TouchableOpacity, StyleSheet } from 'react-native';
3
+ import { Ionicons } from '@expo/vector-icons';
4
+
5
+ interface ChatInputProps {
6
+ onSend: (text: string) => void;
7
+ }
8
+
9
+ export function ChatInput({ onSend }: ChatInputProps) {
10
+ const [message, setMessage] = useState('');
11
+
12
+ const handleSend = () => {
13
+ if (message.trim()) {
14
+ onSend(message.trim());
15
+ setMessage('');
16
+ }
17
+ };
18
+
19
+ return (
20
+ <View style={styles.container}>
21
+ <TextInput
22
+ style={styles.input}
23
+ value={message}
24
+ onChangeText={setMessage}
25
+ placeholder="Type a message..."
26
+ multiline
27
+ />
28
+ <TouchableOpacity onPress={handleSend} style={styles.sendButton}>
29
+ <Ionicons name="send" size={24} color="#007AFF" />
30
+ </TouchableOpacity>
31
+ </View>
32
+ );
33
+ }
34
+
35
+ const styles = StyleSheet.create({
36
+ container: {
37
+ flexDirection: 'row',
38
+ padding: 10,
39
+ borderTopWidth: 1,
40
+ borderTopColor: '#E5E5EA',
41
+ backgroundColor: 'white',
42
+ },
43
+ input: {
44
+ flex: 1,
45
+ borderWidth: 1,
46
+ borderColor: '#E5E5EA',
47
+ borderRadius: 20,
48
+ paddingHorizontal: 15,
49
+ paddingVertical: 8,
50
+ marginRight: 10,
51
+ maxHeight: 100,
52
+ },
53
+ sendButton: {
54
+ justifyContent: 'center',
55
+ alignItems: 'center',
56
+ width: 44,
57
+ },
58
+ });
@@ -0,0 +1,51 @@
1
+ import { View, Text, StyleSheet } from 'react-native';
2
+ import type { Message } from '../types';
3
+
4
+ interface ChatMessageProps {
5
+ message: Message;
6
+ isOwnMessage: boolean;
7
+ }
8
+
9
+ export function ChatMessage({ message, isOwnMessage }: ChatMessageProps) {
10
+ return (
11
+ <View style={[styles.messageContainer, isOwnMessage ? styles.ownMessage : styles.otherMessage]}>
12
+ <Text style={styles.sender}>{message.sender}</Text>
13
+ <Text style={styles.messageText}>{message.text}</Text>
14
+ <Text style={styles.timestamp}>
15
+ {new Date(message.timestamp).toLocaleTimeString()}
16
+ </Text>
17
+ </View>
18
+ );
19
+ }
20
+
21
+ const styles = StyleSheet.create({
22
+ messageContainer: {
23
+ padding: 10,
24
+ marginVertical: 5,
25
+ marginHorizontal: 10,
26
+ maxWidth: '80%',
27
+ borderRadius: 10,
28
+ },
29
+ ownMessage: {
30
+ alignSelf: 'flex-end',
31
+ backgroundColor: '#007AFF',
32
+ },
33
+ otherMessage: {
34
+ alignSelf: 'flex-start',
35
+ backgroundColor: '#E5E5EA',
36
+ },
37
+ sender: {
38
+ fontSize: 12,
39
+ color: '#666',
40
+ marginBottom: 2,
41
+ },
42
+ messageText: {
43
+ fontSize: 16,
44
+ },
45
+ timestamp: {
46
+ fontSize: 10,
47
+ color: '#666',
48
+ alignSelf: 'flex-end',
49
+ marginTop: 2,
50
+ },
51
+ });
package/src/index.tsx ADDED
@@ -0,0 +1,6 @@
1
+ export function multiply(a: number, b: number): number {
2
+ return a * b;
3
+ }
4
+
5
+ export * from './components/Chat';
6
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,12 @@
1
+ export interface Message {
2
+ id: string;
3
+ text: string;
4
+ sender: string;
5
+ timestamp: number;
6
+ }
7
+
8
+ export interface ChatProps {
9
+ userId: string;
10
+ messages: Message[];
11
+ onSendMessage: (text: string) => void;
12
+ }