react-native-kookit 0.3.5 → 0.3.7

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/FTP_README.md DELETED
@@ -1,322 +0,0 @@
1
- # React Native Kookit - FTP Client
2
-
3
- A React Native Expo module that provides volume key interception and FTP client functionality for iOS and Android.
4
-
5
- ## Features
6
-
7
- ### Volume Key Interception
8
-
9
- - Intercept volume up/down button presses
10
- - Works on both iOS and Android
11
- - Prevent default volume behavior (optional)
12
-
13
- ### FTP Client
14
-
15
- - Connect to FTP servers
16
- - List files and directories
17
- - Download files from FTP server
18
- - Upload files to FTP server
19
- - Delete files and directories
20
- - Create directories
21
- - Navigate directories
22
- - Progress monitoring for uploads/downloads
23
-
24
- ## Installation
25
-
26
- ```bash
27
- npm install react-native-kookit
28
- ```
29
-
30
- ### iOS Setup
31
-
32
- For iOS, no additional setup is required. The module works out of the box.
33
-
34
- ### Android Setup
35
-
36
- For Android, your MainActivity must implement the `VolumeKeyInterceptActivity` interface:
37
-
38
- ```kotlin
39
- import expo.modules.kookit.VolumeKeyInterceptActivity
40
-
41
- class MainActivity : ReactActivity(), VolumeKeyInterceptActivity {
42
- // ... existing code ...
43
- }
44
- ```
45
-
46
- ## Usage
47
-
48
- ### Basic Import
49
-
50
- ```typescript
51
- import ReactNativeKookitModule, {
52
- FtpConnectionConfig,
53
- FtpFileInfo,
54
- FtpProgressInfo,
55
- } from "react-native-kookit";
56
- ```
57
-
58
- ### Volume Key Interception
59
-
60
- ```typescript
61
- import { useEffect } from "react";
62
-
63
- useEffect(() => {
64
- // Set up volume key listener
65
- const subscription = ReactNativeKookitModule.addListener(
66
- "onVolumeButtonPressed",
67
- (event) => {
68
- console.log("Volume button pressed:", event.key); // 'up' or 'down'
69
- }
70
- );
71
-
72
- // Enable volume key interception
73
- ReactNativeKookitModule.enableVolumeKeyInterception();
74
-
75
- return () => {
76
- // Clean up
77
- ReactNativeKookitModule.disableVolumeKeyInterception();
78
- subscription.remove();
79
- };
80
- }, []);
81
- ```
82
-
83
- ### FTP Client Usage
84
-
85
- #### 1. Connect to FTP Server
86
-
87
- ```typescript
88
- const config: FtpConnectionConfig = {
89
- host: "ftp.example.com",
90
- port: 21, // optional, defaults to 21
91
- username: "your-username",
92
- password: "your-password",
93
- passive: true, // optional, defaults to true
94
- timeout: 30000, // optional, defaults to 30000ms
95
- };
96
-
97
- try {
98
- await ReactNativeKookitModule.ftpConnect(config);
99
- console.log("Connected to FTP server");
100
- } catch (error) {
101
- console.error("Failed to connect:", error);
102
- }
103
- ```
104
-
105
- #### 2. List Files and Directories
106
-
107
- ```typescript
108
- try {
109
- const files: FtpFileInfo[] = await ReactNativeKookitModule.ftpList();
110
- files.forEach((file) => {
111
- console.log(
112
- `${file.isDirectory ? "DIR" : "FILE"}: ${file.name} (${file.size} bytes)`
113
- );
114
- });
115
- } catch (error) {
116
- console.error("Failed to list files:", error);
117
- }
118
- ```
119
-
120
- #### 3. Download Files
121
-
122
- ```typescript
123
- try {
124
- const remotePath = "remote-file.txt";
125
- const localPath = "/path/to/local/file.txt";
126
-
127
- await ReactNativeKookitModule.ftpDownload(remotePath, localPath);
128
- console.log("File downloaded successfully");
129
- } catch (error) {
130
- console.error("Download failed:", error);
131
- }
132
- ```
133
-
134
- #### 4. Upload Files
135
-
136
- ```typescript
137
- try {
138
- const localPath = "/path/to/local/file.txt";
139
- const remotePath = "remote-file.txt";
140
-
141
- await ReactNativeKookitModule.ftpUpload(localPath, remotePath);
142
- console.log("File uploaded successfully");
143
- } catch (error) {
144
- console.error("Upload failed:", error);
145
- }
146
- ```
147
-
148
- #### 5. Progress Monitoring
149
-
150
- ```typescript
151
- useEffect(() => {
152
- const progressListener = ReactNativeKookitModule.addListener(
153
- "onFtpProgress",
154
- (progress: FtpProgressInfo) => {
155
- console.log(
156
- `Progress: ${progress.percentage}% (${progress.transferred}/${progress.total} bytes)`
157
- );
158
- }
159
- );
160
-
161
- const completeListener = ReactNativeKookitModule.addListener(
162
- "onFtpComplete",
163
- () => {
164
- console.log("Operation completed");
165
- }
166
- );
167
-
168
- const errorListener = ReactNativeKookitModule.addListener(
169
- "onFtpError",
170
- (error) => {
171
- console.error("FTP Error:", error.error);
172
- }
173
- );
174
-
175
- return () => {
176
- progressListener.remove();
177
- completeListener.remove();
178
- errorListener.remove();
179
- };
180
- }, []);
181
- ```
182
-
183
- #### 6. Directory Operations
184
-
185
- ```typescript
186
- // Create directory
187
- await ReactNativeKookitModule.ftpCreateDirectory("new-directory");
188
-
189
- // Change directory
190
- await ReactNativeKookitModule.ftpChangeDirectory("some-directory");
191
-
192
- // Get current directory
193
- const currentDir = await ReactNativeKookitModule.ftpGetCurrentDirectory();
194
- console.log("Current directory:", currentDir);
195
-
196
- // Delete file or directory
197
- await ReactNativeKookitModule.ftpDelete("file.txt", false); // false for file
198
- await ReactNativeKookitModule.ftpDelete("directory", true); // true for directory
199
- ```
200
-
201
- #### 7. Disconnect
202
-
203
- ```typescript
204
- try {
205
- await ReactNativeKookitModule.ftpDisconnect();
206
- console.log("Disconnected from FTP server");
207
- } catch (error) {
208
- console.error("Failed to disconnect:", error);
209
- }
210
- ```
211
-
212
- ## API Reference
213
-
214
- ### Types
215
-
216
- ```typescript
217
- interface FtpConnectionConfig {
218
- host: string;
219
- port?: number;
220
- username: string;
221
- password: string;
222
- passive?: boolean;
223
- timeout?: number;
224
- }
225
-
226
- interface FtpFileInfo {
227
- name: string;
228
- isDirectory: boolean;
229
- size: number;
230
- lastModified: string;
231
- permissions?: string;
232
- }
233
-
234
- interface FtpProgressInfo {
235
- transferred: number;
236
- total: number;
237
- percentage: number;
238
- }
239
- ```
240
-
241
- ### Methods
242
-
243
- #### Volume Key Methods
244
-
245
- - `enableVolumeKeyInterception()`: Enable volume key interception
246
- - `disableVolumeKeyInterception()`: Disable volume key interception
247
-
248
- #### FTP Methods
249
-
250
- - `ftpConnect(config: FtpConnectionConfig): Promise<void>`
251
- - `ftpDisconnect(): Promise<void>`
252
- - `ftpList(path?: string): Promise<FtpFileInfo[]>`
253
- - `ftpDownload(remotePath: string, localPath: string): Promise<void>`
254
- - `ftpUpload(localPath: string, remotePath: string): Promise<void>`
255
- - `ftpDelete(remotePath: string, isDirectory?: boolean): Promise<void>`
256
- - `ftpCreateDirectory(remotePath: string): Promise<void>`
257
- - `ftpChangeDirectory(remotePath: string): Promise<void>`
258
- - `ftpGetCurrentDirectory(): Promise<string>`
259
-
260
- ### Events
261
-
262
- #### Volume Key Events
263
-
264
- - `onVolumeButtonPressed`: Fired when volume button is pressed
265
- ```typescript
266
- {
267
- key: "up" | "down";
268
- }
269
- ```
270
-
271
- #### FTP Events
272
-
273
- - `onFtpProgress`: Fired during file transfer operations
274
-
275
- ```typescript
276
- { transferred: number, total: number, percentage: number }
277
- ```
278
-
279
- - `onFtpComplete`: Fired when an operation completes successfully
280
-
281
- - `onFtpError`: Fired when an error occurs
282
- ```typescript
283
- {
284
- error: string;
285
- }
286
- ```
287
-
288
- ## Platform Support
289
-
290
- - ✅ iOS 15.1+
291
- - ✅ Android API 21+
292
- - ❌ Web (FTP operations are not supported due to browser security restrictions)
293
-
294
- ## Example
295
-
296
- See the [FtpExample.tsx](./example/FtpExample.tsx) file for a complete working example.
297
-
298
- ## Security Considerations
299
-
300
- - FTP credentials are transmitted in plain text. Use FTPS or SFTP for secure file transfers when possible.
301
- - Ensure proper file path validation to prevent directory traversal attacks.
302
- - Consider implementing connection pooling and timeout handling for production use.
303
-
304
- ## Troubleshooting
305
-
306
- ### Android
307
-
308
- - Make sure your MainActivity implements `VolumeKeyInterceptActivity`
309
- - Check that you have INTERNET permission in your AndroidManifest.xml
310
-
311
- ### iOS
312
-
313
- - Ensure your app has network permissions
314
- - For file operations, make sure your app has appropriate file system permissions
315
-
316
- ## Contributing
317
-
318
- Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
319
-
320
- ## License
321
-
322
- MIT
package/README_NEW.md DELETED
@@ -1,143 +0,0 @@
1
- # React Native Kookit - 零配置音量键拦截
2
-
3
- 🎉 **现在支持零配置安装!** 使用 Expo 插件自动处理所有原生代码修改。
4
-
5
- ## 快速开始
6
-
7
- ### 方法一:自动安装(推荐 - Expo 项目)
8
-
9
- ```bash
10
- # 1. 安装
11
- npm install react-native-kookit
12
-
13
- # 2. 添加到 app.json
14
- {
15
- "expo": {
16
- "plugins": ["react-native-kookit"]
17
- }
18
- }
19
-
20
- # 3. 预构建
21
- npx expo prebuild --clean
22
-
23
- # 4. 运行
24
- npx expo run:android
25
- ```
26
-
27
- ### 方法二:手动安装(React Native CLI 项目)
28
-
29
- 如果不使用 Expo,请按照 [ANDROID_SETUP.md](./ANDROID_SETUP.md) 手动修改 MainActivity。
30
-
31
- ## 使用示例
32
-
33
- ```javascript
34
- import React, { useEffect } from "react";
35
- import { View, Text, Alert } from "react-native";
36
- import ReactNativeKookit from "react-native-kookit";
37
-
38
- export default function App() {
39
- useEffect(() => {
40
- // 添加音量键监听器
41
- const subscription = ReactNativeKookit.addListener(
42
- "onVolumeButtonPressed",
43
- (event) => {
44
- Alert.alert(
45
- "音量键按下",
46
- `按下了${event.key === "up" ? "音量+" : "音量-"}键`,
47
- [{ text: "确定" }]
48
- );
49
- }
50
- );
51
-
52
- // 启用音量键拦截
53
- ReactNativeKookit.enableVolumeKeyInterception();
54
-
55
- // 清理函数
56
- return () => {
57
- subscription.remove();
58
- ReactNativeKookit.disableVolumeKeyInterception();
59
- };
60
- }, []);
61
-
62
- return (
63
- <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
64
- <Text style={{ fontSize: 18, textAlign: "center", margin: 20 }}>
65
- 音量键拦截已启用{"\n"}
66
- 请按音量键测试功能
67
- </Text>
68
- </View>
69
- );
70
- }
71
- ```
72
-
73
- ## API 文档
74
-
75
- ### `enableVolumeKeyInterception()`
76
-
77
- 启用音量键拦截功能。
78
-
79
- ### `disableVolumeKeyInterception()`
80
-
81
- 禁用音量键拦截功能。
82
-
83
- ### `addListener(eventName, callback)`
84
-
85
- 添加事件监听器。
86
-
87
- **参数:**
88
-
89
- - `eventName`: `'onVolumeButtonPressed'`
90
- - `callback`: `(event: {key: 'up' | 'down'}) => void`
91
-
92
- **返回:** 订阅对象,调用 `.remove()` 方法可取消监听。
93
-
94
- ## 功能特性
95
-
96
- - ✅ **零配置**:Expo 插件自动修改原生代码
97
- - ✅ **跨平台**:支持 iOS 和 Android
98
- - ✅ **高性能**:原生实现,无性能损耗
99
- - ✅ **类型安全**:完整 TypeScript 支持
100
- - ✅ **兼容性强**:支持新架构和旧架构
101
-
102
- ## 支持的平台
103
-
104
- - iOS 9.0+
105
- - Android API 21+
106
- - Expo SDK 49+
107
- - React Native 0.70+
108
-
109
- ## 常见问题
110
-
111
- ### Q: 为什么需要 `npx expo prebuild --clean`?
112
-
113
- A: 插件需要修改原生 Android 代码,prebuild 会应用所有插件修改。
114
-
115
- ### Q: 遇到 "Plugin is an unexpected type: undefined" 错误怎么办?
116
-
117
- A:
118
-
119
- 1. 确保已正确安装:`npm install react-native-kookit`
120
- 2. 清理重装:`rm -rf node_modules && npm install`
121
- 3. 重新预构建:`npx expo prebuild --clean`
122
-
123
- 详细故障排除请查看 [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
124
-
125
- ### Q: 音量键无响应怎么办?
126
-
127
- A:
128
-
129
- 1. 确认已调用 `enableVolumeKeyInterception()`
130
- 2. 检查是否正确添加了事件监听器
131
- 3. 在 Android 上确认 MainActivity 已被正确修改
132
-
133
- ### Q: 支持 React Native CLI 项目吗?
134
-
135
- A: 支持,但需要手动修改 MainActivity,请参考 [ANDROID_SETUP.md](./ANDROID_SETUP.md)。
136
-
137
- ### Q: 会影响系统音量调节吗?
138
-
139
- A: 当启用拦截时,会阻止系统音量调节。禁用拦截后恢复正常。
140
-
141
- ## License
142
-
143
- MIT © [troyeguo](https://github.com/troyeguo)
@@ -1,115 +0,0 @@
1
- # React Native Kookit - 发布前检查
2
-
3
- ## 修复的主要问题
4
-
5
- ✅ **Plugin undefined 错误**
6
-
7
- - 修复了 package.json 中插件配置位置
8
- - 添加了 @expo/config-plugins 依赖
9
- - 改进了 app.plugin.js 的错误处理
10
-
11
- ✅ **插件导出问题**
12
-
13
- - 确保插件正确导出为 ConfigPlugin 函数
14
- - 添加了fallback处理
15
-
16
- ## 当前文件结构
17
-
18
- ```
19
- react-native-kookit/
20
- ├── package.json # 主包配置,包含插件配置
21
- ├── app.plugin.js # 插件入口文件
22
- ├── plugin/ # 插件源码目录
23
- │ ├── package.json # 插件依赖
24
- │ ├── tsconfig.json # TypeScript 配置
25
- │ ├── src/
26
- │ │ └── withVolumeKeyIntercept.ts # 插件实现
27
- │ └── build/ # 编译后的插件
28
- │ └── withVolumeKeyIntercept.js
29
- ├── README_NEW.md # 更新的文档
30
- ├── TROUBLESHOOTING.md # 故障排除指南
31
- └── EXPO_PLUGIN_README.md # 插件详细说明
32
- ```
33
-
34
- ## 测试步骤
35
-
36
- ### 1. 本地测试插件加载
37
-
38
- ```bash
39
- cd /path/to/react-native-kookit
40
- node -e "
41
- const plugin = require('./app.plugin.js');
42
- console.log('Plugin type:', typeof plugin);
43
- console.log('Plugin loaded:', typeof plugin === 'function' ? '✅ Success' : '❌ Failed');
44
- "
45
- ```
46
-
47
- ### 2. 在测试项目中验证
48
-
49
- 1. 创建新的 Expo 项目:
50
-
51
- ```bash
52
- npx create-expo-app TestKookit
53
- cd TestKookit
54
- ```
55
-
56
- 2. 添加本地模块:
57
-
58
- ```bash
59
- npm install ../react-native-kookit
60
- ```
61
-
62
- 3. 配置 app.json:
63
-
64
- ```json
65
- {
66
- "expo": {
67
- "plugins": ["react-native-kookit"]
68
- }
69
- }
70
- ```
71
-
72
- 4. 预构建:
73
-
74
- ```bash
75
- npx expo prebuild --clean
76
- ```
77
-
78
- 5. 检查生成的 MainActivity 是否包含必要代码
79
-
80
- ### 3. 发布验证
81
-
82
- ```bash
83
- # 构建插件
84
- npm run build-plugin
85
-
86
- # 检查文件
87
- ls -la plugin/build/
88
-
89
- # 发布(测试版本)
90
- npm publish --tag beta
91
- ```
92
-
93
- ## 用户使用流程验证
94
-
95
- ### 正确的用户步骤:
96
-
97
- 1. ✅ `npm install react-native-kookit`
98
- 2. ✅ 在 app.json 添加 `"plugins": ["react-native-kookit"]`
99
- 3. ✅ `npx expo prebuild --clean`
100
- 4. ✅ `npx expo run:android`
101
-
102
- ### 预期结果:
103
-
104
- - MainActivity 自动包含 VolumeKeyInterceptActivity 接口
105
- - 音量键监听功能正常工作
106
- - 无需手动修改原生代码
107
-
108
- ## 发布清单
109
-
110
- - [ ] 插件本地测试通过
111
- - [ ] 在新项目中端到端测试
112
- - [ ] 文档更新完成
113
- - [ ] 版本号更新
114
- - [ ] README 更新为 README_NEW.md
115
- - [ ] 发布到 npm