react-native-kookit 0.3.1 → 0.3.2

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.
@@ -0,0 +1,175 @@
1
+ # SMB Client 静态方法使用示例
2
+
3
+ SmbClient新增了多个静态方法来管理多个客户端实例:
4
+
5
+ ## 新增的静态方法
6
+
7
+ ### 1. `SmbClient.disposeClient(clientId: string)`
8
+
9
+ 销毁指定客户端ID的客户端实例
10
+
11
+ ```typescript
12
+ // 销毁特定的客户端
13
+ const disposed = await SmbClient.disposeClient("my_client_id");
14
+ console.log("Client disposed:", disposed); // true/false
15
+ ```
16
+
17
+ ### 2. `SmbClient.getClientStatus(clientId: string)`
18
+
19
+ 获取指定客户端ID的状态信息
20
+
21
+ ```typescript
22
+ // 获取客户端状态
23
+ const status = SmbClient.getClientStatus("my_client_id");
24
+ console.log("Client status:", status);
25
+ // 返回: {
26
+ // exists: true,
27
+ // isConnected: true,
28
+ // currentShare: 'C$',
29
+ // isDisposed: false
30
+ // }
31
+ ```
32
+
33
+ ### 3. `SmbClient.getAllClientsStatus()`
34
+
35
+ 获取所有活跃客户端的状态
36
+
37
+ ```typescript
38
+ // 获取所有客户端状态
39
+ const allStatus = SmbClient.getAllClientsStatus();
40
+ allStatus.forEach((status, clientId) => {
41
+ console.log(`Client ${clientId}:`, status);
42
+ });
43
+ ```
44
+
45
+ ### 4. `SmbClient.getInstance(clientId: string)`
46
+
47
+ 获取指定客户端ID的实例对象
48
+
49
+ ```typescript
50
+ // 获取现有的客户端实例
51
+ const existingClient = SmbClient.getInstance("my_client_id");
52
+ if (existingClient) {
53
+ await existingClient.listFiles("/");
54
+ }
55
+ ```
56
+
57
+ ### 5. `SmbClient.disposeAllClients()`
58
+
59
+ 销毁所有客户端实例
60
+
61
+ ```typescript
62
+ // 清理所有客户端
63
+ const disposedCount = await SmbClient.disposeAllClients();
64
+ console.log(`Disposed ${disposedCount} clients`);
65
+ ```
66
+
67
+ ## 使用示例
68
+
69
+ ```typescript
70
+ import SmbClient from "react-native-kookit";
71
+
72
+ export class SmbManager {
73
+ private clients: Map<string, SmbClient> = new Map();
74
+
75
+ // 创建命名客户端
76
+ async createNamedClient(
77
+ name: string,
78
+ config: SmbConnectionConfig
79
+ ): Promise<SmbClient> {
80
+ const client = await SmbClient.create(name);
81
+ await client.connect(config);
82
+ this.clients.set(name, client);
83
+ return client;
84
+ }
85
+
86
+ // 检查客户端是否存在且连接
87
+ isClientReady(name: string): boolean {
88
+ const status = SmbClient.getClientStatus(name);
89
+ return status.exists && status.isConnected && !status.isDisposed;
90
+ }
91
+
92
+ // 安全获取客户端
93
+ getClient(name: string): SmbClient | null {
94
+ if (this.isClientReady(name)) {
95
+ return SmbClient.getInstance(name);
96
+ }
97
+ return null;
98
+ }
99
+
100
+ // 销毁指定客户端
101
+ async removeClient(name: string): Promise<boolean> {
102
+ this.clients.delete(name);
103
+ return await SmbClient.disposeClient(name);
104
+ }
105
+
106
+ // 获取所有客户端状态报告
107
+ getStatusReport(): Record<string, any> {
108
+ const report: Record<string, any> = {};
109
+ const allStatus = SmbClient.getAllClientsStatus();
110
+
111
+ allStatus.forEach((status, clientId) => {
112
+ report[clientId] = {
113
+ ...status,
114
+ managed: this.clients.has(clientId),
115
+ };
116
+ });
117
+
118
+ return report;
119
+ }
120
+
121
+ // 清理所有资源
122
+ async cleanup(): Promise<void> {
123
+ this.clients.clear();
124
+ await SmbClient.disposeAllClients();
125
+ }
126
+ }
127
+
128
+ // 使用示例
129
+ const smbManager = new SmbManager();
130
+
131
+ // 创建多个客户端
132
+ const client1 = await smbManager.createNamedClient("server1", {
133
+ host: "192.168.1.100",
134
+ username: "user1",
135
+ password: "pass1",
136
+ });
137
+
138
+ const client2 = await smbManager.createNamedClient("server2", {
139
+ host: "192.168.1.101",
140
+ username: "user2",
141
+ password: "pass2",
142
+ });
143
+
144
+ // 检查状态
145
+ console.log("Status report:", smbManager.getStatusReport());
146
+
147
+ // 使用特定客户端
148
+ const client = smbManager.getClient("server1");
149
+ if (client) {
150
+ const files = await client.listFiles("/");
151
+ console.log("Files:", files);
152
+ }
153
+
154
+ // 清理资源
155
+ await smbManager.cleanup();
156
+ ```
157
+
158
+ ## 类型定义
159
+
160
+ ```typescript
161
+ export interface SmbClientStatus {
162
+ exists: boolean;
163
+ isConnected: boolean;
164
+ currentShare: string | null;
165
+ isDisposed: boolean;
166
+ }
167
+
168
+ export interface SmbClientInfo {
169
+ isConnected: boolean;
170
+ currentShare: string | null;
171
+ isDisposed: boolean;
172
+ }
173
+ ```
174
+
175
+ 这些静态方法使得SmbClient的多实例管理变得更加简单和安全。
@@ -8,6 +8,17 @@ export interface SmbClientEventHandlers {
8
8
  onComplete?: () => void;
9
9
  onError?: (error: Error) => void;
10
10
  }
11
+ export interface SmbClientStatus {
12
+ exists: boolean;
13
+ isConnected: boolean;
14
+ currentShare: string | null;
15
+ isDisposed: boolean;
16
+ }
17
+ export interface SmbClientInfo {
18
+ isConnected: boolean;
19
+ currentShare: string | null;
20
+ isDisposed: boolean;
21
+ }
11
22
  export declare class SmbClient {
12
23
  private clientId;
13
24
  private isDisposed;
@@ -15,6 +26,7 @@ export declare class SmbClient {
15
26
  private eventSubscriptions;
16
27
  private _isConnected;
17
28
  private _currentShare;
29
+ private static instances;
18
30
  constructor(clientId?: string);
19
31
  private setupEventListeners;
20
32
  /**
@@ -121,6 +133,34 @@ export declare class SmbClient {
121
133
  * @returns New SMB client instance
122
134
  */
123
135
  static create(clientId?: string): Promise<SmbClient>;
136
+ /**
137
+ * Dispose a specific SMB client by client ID
138
+ * @param clientId Client ID to dispose
139
+ * @returns true if client was found and disposed, false otherwise
140
+ */
141
+ static disposeClient(clientId: string): Promise<boolean>;
142
+ /**
143
+ * Get the status of a specific SMB client by client ID
144
+ * @param clientId Client ID to check
145
+ * @returns Client status or null if not found
146
+ */
147
+ static getClientStatus(clientId: string): SmbClientStatus;
148
+ /**
149
+ * Get all active client IDs and their status
150
+ * @returns Map of client IDs to their status
151
+ */
152
+ static getAllClientsStatus(): Map<string, SmbClientInfo>;
153
+ /**
154
+ * Get a specific SMB client instance by client ID
155
+ * @param clientId Client ID to retrieve
156
+ * @returns SMB client instance or null if not found
157
+ */
158
+ static getInstance(clientId: string): SmbClient | null;
159
+ /**
160
+ * Dispose all SMB clients
161
+ * @returns Number of clients disposed
162
+ */
163
+ static disposeAllClients(): Promise<number>;
124
164
  }
125
165
  export default SmbClient;
126
166
  //# sourceMappingURL=SmbClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SmbClient.d.ts","sourceRoot":"","sources":["../src/SmbClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EAIZ,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,kBAAkB,CAAqC;IAC/D,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,aAAa,CAAuB;gBAEhC,QAAQ,CAAC,EAAE,MAAM;IAO7B,OAAO,CAAC,mBAAmB;IAmC3B;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAIxD;;OAEG;YACW,UAAU;IAKxB;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD;;;OAGG;IACG,YAAY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,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B;;OAEG;WACU,WAAW,IAAI,OAAO,CAAC;QAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,SAAS,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;QAChD,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IAIF;;;;OAIG;WACU,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAM1D;;;;OAIG;WACU,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9D;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe;IAkBzD;;;OAGG;IACH,MAAM,CAAC,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAYxD;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAItD;;;OAGG;WACU,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;CAkBlD;AAED,eAAe,SAAS,CAAC"}
@@ -6,10 +6,14 @@ export class SmbClient {
6
6
  eventSubscriptions = [];
7
7
  _isConnected = false;
8
8
  _currentShare = null;
9
+ // 静态实例管理
10
+ static instances = new Map();
9
11
  constructor(clientId) {
10
12
  this.clientId =
11
13
  clientId ||
12
14
  `smb_client_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
15
+ // 将实例添加到静态管理器
16
+ SmbClient.instances.set(this.clientId, this);
13
17
  this.setupEventListeners();
14
18
  }
15
19
  setupEventListeners() {
@@ -225,6 +229,8 @@ export class SmbClient {
225
229
  this.isDisposed = true;
226
230
  this._isConnected = false;
227
231
  this._currentShare = null;
232
+ // 从静态实例管理器中移除
233
+ SmbClient.instances.delete(this.clientId);
228
234
  }
229
235
  /**
230
236
  * List all SMB clients
@@ -242,6 +248,91 @@ export class SmbClient {
242
248
  await client.initialize();
243
249
  return client;
244
250
  }
251
+ /**
252
+ * Dispose a specific SMB client by client ID
253
+ * @param clientId Client ID to dispose
254
+ * @returns true if client was found and disposed, false otherwise
255
+ */
256
+ static async disposeClient(clientId) {
257
+ const client = SmbClient.instances.get(clientId);
258
+ if (client) {
259
+ await client.dispose();
260
+ return true;
261
+ }
262
+ // Try to dispose on native side even if not in our instances map
263
+ try {
264
+ await ReactNativeKookitModule.disposeSmbClient(clientId);
265
+ return true;
266
+ }
267
+ catch {
268
+ return false;
269
+ }
270
+ }
271
+ /**
272
+ * Get the status of a specific SMB client by client ID
273
+ * @param clientId Client ID to check
274
+ * @returns Client status or null if not found
275
+ */
276
+ static getClientStatus(clientId) {
277
+ const client = SmbClient.instances.get(clientId);
278
+ if (client) {
279
+ return {
280
+ exists: true,
281
+ isConnected: client._isConnected,
282
+ currentShare: client._currentShare,
283
+ isDisposed: client.isDisposed,
284
+ };
285
+ }
286
+ return {
287
+ exists: false,
288
+ isConnected: false,
289
+ currentShare: null,
290
+ isDisposed: true,
291
+ };
292
+ }
293
+ /**
294
+ * Get all active client IDs and their status
295
+ * @returns Map of client IDs to their status
296
+ */
297
+ static getAllClientsStatus() {
298
+ const statusMap = new Map();
299
+ SmbClient.instances.forEach((client, clientId) => {
300
+ statusMap.set(clientId, {
301
+ isConnected: client._isConnected,
302
+ currentShare: client._currentShare,
303
+ isDisposed: client.isDisposed,
304
+ });
305
+ });
306
+ return statusMap;
307
+ }
308
+ /**
309
+ * Get a specific SMB client instance by client ID
310
+ * @param clientId Client ID to retrieve
311
+ * @returns SMB client instance or null if not found
312
+ */
313
+ static getInstance(clientId) {
314
+ return SmbClient.instances.get(clientId) || null;
315
+ }
316
+ /**
317
+ * Dispose all SMB clients
318
+ * @returns Number of clients disposed
319
+ */
320
+ static async disposeAllClients() {
321
+ const clientIds = Array.from(SmbClient.instances.keys());
322
+ let disposedCount = 0;
323
+ for (const clientId of clientIds) {
324
+ try {
325
+ await SmbClient.disposeClient(clientId);
326
+ disposedCount++;
327
+ }
328
+ catch {
329
+ // Continue with next client even if disposal fails
330
+ }
331
+ }
332
+ // Clear the instances map
333
+ SmbClient.instances.clear();
334
+ return disposedCount;
335
+ }
245
336
  }
246
337
  export default SmbClient;
247
338
  //# sourceMappingURL=SmbClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SmbClient.js","sourceRoot":"","sources":["../src/SmbClient.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAmBhE,MAAM,OAAO,SAAS;IACZ,QAAQ,CAAS;IACjB,UAAU,GAAY,KAAK,CAAC;IAC5B,aAAa,GAA2B,EAAE,CAAC;IAC3C,kBAAkB,GAAkC,EAAE,CAAC;IACvD,YAAY,GAAY,KAAK,CAAC;IAC9B,aAAa,GAAkB,IAAI,CAAC;IAE5C,YAAY,QAAiB;QAC3B,IAAI,CAAC,QAAQ;YACX,QAAQ;gBACR,cAAc,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACxE,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAEO,mBAAmB;QACzB,MAAM,WAAW,GAAG,uBAAuB,CAAC,WAAW,CACrD,eAAe,EACf,CAAC,KAAuB,EAAE,EAAE;YAC1B,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBACtE,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;oBAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,UAAU,EAAE,KAAK,CAAC,UAAU;iBA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ConnectionConfig,\n SmbFileInfo,\n SmbProgressEvent,\n SmbCompleteEvent,\n SmbErrorEvent,\n} from \"./ReactNativeKookit.types\";\n\nexport interface SmbClientEventHandlers {\n onProgress?: (progress: {\n transferred: number;\n total: number;\n percentage: number;\n }) => void;\n onComplete?: () => void;\n onError?: (error: Error) => void;\n}\n\nexport class SmbClient {\n private clientId: string;\n private isDisposed: boolean = false;\n private eventHandlers: SmbClientEventHandlers = {};\n private eventSubscriptions: Array<{ remove: () => void }> = [];\n private _isConnected: boolean = false;\n private _currentShare: string | null = null;\n\n constructor(clientId?: string) {\n this.clientId =\n clientId ||\n `smb_client_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.setupEventListeners();\n }\n\n private setupEventListeners() {\n const progressSub = ReactNativeKookitModule.addListener(\n \"onSmbProgress\",\n (event: SmbProgressEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onProgress) {\n this.eventHandlers.onProgress({\n transferred: event.transferred,\n total: event.total,\n percentage: event.percentage,\n });\n }\n }\n );\n\n const completeSub = ReactNativeKookitModule.addListener(\n \"onSmbComplete\",\n (event: SmbCompleteEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onComplete) {\n this.eventHandlers.onComplete();\n }\n }\n );\n\n const errorSub = ReactNativeKookitModule.addListener(\n \"onSmbError\",\n (event: SmbErrorEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onError) {\n this.eventHandlers.onError(new Error(event.error));\n }\n }\n );\n\n this.eventSubscriptions = [progressSub, completeSub, errorSub];\n }\n\n /**\n * Set event handlers for SMB operations\n */\n setEventHandlers(handlers: SmbClientEventHandlers): void {\n this.eventHandlers = { ...handlers };\n }\n\n /**\n * Initialize the SMB client\n */\n private async initialize(): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.createSmbClient(this.clientId);\n }\n\n /**\n * Connect to SMB server\n * @param config Connection configuration\n */\n async connect(config: SmbConnectionConfig): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientConnect(this.clientId, config);\n this._isConnected = true;\n this._currentShare = config.share || null;\n }\n\n /**\n * Connect to a specific share\n * @param shareName Name of the share to connect to\n */\n async connectShare(shareName: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n\n await ReactNativeKookitModule.smbClientConnectShare(\n this.clientId,\n shareName\n );\n this._currentShare = shareName;\n }\n\n /**\n * List all available shares on the SMB server\n * @returns Array of share names\n */\n async listShares(): Promise<string[]> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n\n return ReactNativeKookitModule.smbClientListShares(this.clientId);\n }\n\n /**\n * Disconnect from SMB server\n */\n async disconnect(): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientDisconnect(this.clientId);\n this._isConnected = false;\n this._currentShare = null;\n }\n\n /**\n * List files and directories in the specified path\n * @param path Path to list (empty string for share root)\n * @returns Array of file information\n */\n async list(path?: string): Promise<SmbFileInfo[]> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n return ReactNativeKookitModule.smbClientList(this.clientId, path);\n }\n\n /**\n * Download a file from SMB server\n * @param remotePath Path to the remote file\n * @param localPath Local path to save the file\n */\n async download(remotePath: string, localPath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientDownload(\n this.clientId,\n remotePath,\n localPath\n );\n }\n\n /**\n * Upload a file to SMB server\n * @param localPath Local path of the file to upload\n * @param remotePath Remote path to save the file\n */\n async upload(localPath: string, remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientUpload(\n this.clientId,\n localPath,\n remotePath\n );\n }\n\n /**\n * Delete a file or directory from SMB server\n * @param remotePath Path to the file or directory to delete\n * @param isDirectory Whether the path is a directory\n */\n async delete(\n remotePath: string,\n isDirectory: boolean = false\n ): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientDelete(\n this.clientId,\n remotePath,\n isDirectory\n );\n }\n\n /**\n * Create a directory on SMB server\n * @param remotePath Path of the directory to create\n */\n async createDirectory(remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientCreateDirectory(\n this.clientId,\n remotePath\n );\n }\n\n /**\n * Get the current connection status\n */\n async getStatus(): Promise<{\n clientId: string;\n exists: boolean;\n connected: boolean;\n currentShare: string | null;\n }> {\n const status = await ReactNativeKookitModule.getSmbClientStatus(\n this.clientId\n );\n return {\n clientId: this.clientId,\n currentShare: this._currentShare,\n ...status,\n };\n }\n\n /**\n * Get the client ID\n */\n getClientId(): string {\n return this.clientId;\n }\n\n /**\n * Get the current share name\n */\n getCurrentShare(): string | null {\n return this._currentShare;\n }\n\n /**\n * Check if connected to SMB server\n */\n async isConnected(): Promise<boolean> {\n if (this.isDisposed) return false;\n try {\n const status = await this.getStatus();\n return status.exists && status.connected;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if connected to SMB server (synchronous)\n */\n isConnectedSync(): boolean {\n return this._isConnected;\n }\n\n /**\n * Check if connected to a share\n */\n hasShareConnected(): boolean {\n return this._isConnected && this._currentShare !== null;\n }\n\n /**\n * Dispose the SMB client and clean up resources\n */\n async dispose(): Promise<void> {\n if (this.isDisposed) return;\n try {\n await ReactNativeKookitModule.disposeSmbClient(this.clientId);\n } catch {}\n this.eventSubscriptions.forEach((s) => s.remove());\n this.eventSubscriptions = [];\n this.isDisposed = true;\n this._isConnected = false;\n this._currentShare = null;\n }\n\n /**\n * List all SMB clients\n */\n static async listClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }> {\n return ReactNativeKookitModule.listSmbClients();\n }\n\n /**\n * Create a new SMB client instance\n * @param clientId Optional client ID\n * @returns New SMB client instance\n */\n static async create(clientId?: string): Promise<SmbClient> {\n const client = new SmbClient(clientId);\n await client.initialize();\n return client;\n }\n}\n\nexport default SmbClient;\n"]}
1
+ {"version":3,"file":"SmbClient.js","sourceRoot":"","sources":["../src/SmbClient.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAgChE,MAAM,OAAO,SAAS;IACZ,QAAQ,CAAS;IACjB,UAAU,GAAY,KAAK,CAAC;IAC5B,aAAa,GAA2B,EAAE,CAAC;IAC3C,kBAAkB,GAAkC,EAAE,CAAC;IACvD,YAAY,GAAY,KAAK,CAAC;IAC9B,aAAa,GAAkB,IAAI,CAAC;IAE5C,SAAS;IACD,MAAM,CAAC,SAAS,GAA2B,IAAI,GAAG,EAAE,CAAC;IAE7D,YAAY,QAAiB;QAC3B,IAAI,CAAC,QAAQ;YACX,QAAQ;gBACR,cAAc,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAExE,cAAc;QACd,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,mBAAmB,EAAE,CAAC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AClB,UAAU,EAAE,IAAI;SACjB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,mBAAmB;QACxB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YAC/C,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACtB,WAAW,EAAE,MAAM,CAAC,YAAY;gBAChC,YAAY,EAAE,MAAM,CAAC,aAAa;gBAClC,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,QAAgB;QACjC,OAAO,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,iBAAiB;QAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,aAAa,GAAG,CAAC,CAAC;QAEtB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxC,aAAa,EAAE,CAAC;YAClB,CAAC;YAAC,MAAM,CAAC;gBACP,mDAAmD;YACrD,CAAC;QACH,CAAC;QAED,0BAA0B;QAC1B,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;;AAGH,eAAe,SAAS,CAAC","sourcesContent":["import ReactNativeKookitModule from \"./ReactNativeKookitModule\";\nimport type {\n SmbConnectionConfig,\n SmbFileInfo,\n SmbProgressEvent,\n SmbCompleteEvent,\n SmbErrorEvent,\n} from \"./ReactNativeKookit.types\";\n\nexport interface SmbClientEventHandlers {\n onProgress?: (progress: {\n transferred: number;\n total: number;\n percentage: number;\n }) => void;\n onComplete?: () => void;\n onError?: (error: Error) => void;\n}\n\nexport interface SmbClientStatus {\n exists: boolean;\n isConnected: boolean;\n currentShare: string | null;\n isDisposed: boolean;\n}\n\nexport interface SmbClientInfo {\n isConnected: boolean;\n currentShare: string | null;\n isDisposed: boolean;\n}\n\nexport class SmbClient {\n private clientId: string;\n private isDisposed: boolean = false;\n private eventHandlers: SmbClientEventHandlers = {};\n private eventSubscriptions: Array<{ remove: () => void }> = [];\n private _isConnected: boolean = false;\n private _currentShare: string | null = null;\n\n // 静态实例管理\n private static instances: Map<string, SmbClient> = new Map();\n\n constructor(clientId?: string) {\n this.clientId =\n clientId ||\n `smb_client_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n\n // 将实例添加到静态管理器\n SmbClient.instances.set(this.clientId, this);\n\n this.setupEventListeners();\n }\n\n private setupEventListeners() {\n const progressSub = ReactNativeKookitModule.addListener(\n \"onSmbProgress\",\n (event: SmbProgressEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onProgress) {\n this.eventHandlers.onProgress({\n transferred: event.transferred,\n total: event.total,\n percentage: event.percentage,\n });\n }\n }\n );\n\n const completeSub = ReactNativeKookitModule.addListener(\n \"onSmbComplete\",\n (event: SmbCompleteEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onComplete) {\n this.eventHandlers.onComplete();\n }\n }\n );\n\n const errorSub = ReactNativeKookitModule.addListener(\n \"onSmbError\",\n (event: SmbErrorEvent) => {\n if (event.clientId === this.clientId && this.eventHandlers.onError) {\n this.eventHandlers.onError(new Error(event.error));\n }\n }\n );\n\n this.eventSubscriptions = [progressSub, completeSub, errorSub];\n }\n\n /**\n * Set event handlers for SMB operations\n */\n setEventHandlers(handlers: SmbClientEventHandlers): void {\n this.eventHandlers = { ...handlers };\n }\n\n /**\n * Initialize the SMB client\n */\n private async initialize(): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.createSmbClient(this.clientId);\n }\n\n /**\n * Connect to SMB server\n * @param config Connection configuration\n */\n async connect(config: SmbConnectionConfig): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientConnect(this.clientId, config);\n this._isConnected = true;\n this._currentShare = config.share || null;\n }\n\n /**\n * Connect to a specific share\n * @param shareName Name of the share to connect to\n */\n async connectShare(shareName: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n\n await ReactNativeKookitModule.smbClientConnectShare(\n this.clientId,\n shareName\n );\n this._currentShare = shareName;\n }\n\n /**\n * List all available shares on the SMB server\n * @returns Array of share names\n */\n async listShares(): Promise<string[]> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n\n return ReactNativeKookitModule.smbClientListShares(this.clientId);\n }\n\n /**\n * Disconnect from SMB server\n */\n async disconnect(): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientDisconnect(this.clientId);\n this._isConnected = false;\n this._currentShare = null;\n }\n\n /**\n * List files and directories in the specified path\n * @param path Path to list (empty string for share root)\n * @returns Array of file information\n */\n async list(path?: string): Promise<SmbFileInfo[]> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n return ReactNativeKookitModule.smbClientList(this.clientId, path);\n }\n\n /**\n * Download a file from SMB server\n * @param remotePath Path to the remote file\n * @param localPath Local path to save the file\n */\n async download(remotePath: string, localPath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientDownload(\n this.clientId,\n remotePath,\n localPath\n );\n }\n\n /**\n * Upload a file to SMB server\n * @param localPath Local path of the file to upload\n * @param remotePath Remote path to save the file\n */\n async upload(localPath: string, remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientUpload(\n this.clientId,\n localPath,\n remotePath\n );\n }\n\n /**\n * Delete a file or directory from SMB server\n * @param remotePath Path to the file or directory to delete\n * @param isDirectory Whether the path is a directory\n */\n async delete(\n remotePath: string,\n isDirectory: boolean = false\n ): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientDelete(\n this.clientId,\n remotePath,\n isDirectory\n );\n }\n\n /**\n * Create a directory on SMB server\n * @param remotePath Path of the directory to create\n */\n async createDirectory(remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n if (!this._isConnected) throw new Error(\"Not connected to SMB server\");\n if (!this._currentShare) throw new Error(\"No share connected\");\n\n await ReactNativeKookitModule.smbClientCreateDirectory(\n this.clientId,\n remotePath\n );\n }\n\n /**\n * Get the current connection status\n */\n async getStatus(): Promise<{\n clientId: string;\n exists: boolean;\n connected: boolean;\n currentShare: string | null;\n }> {\n const status = await ReactNativeKookitModule.getSmbClientStatus(\n this.clientId\n );\n return {\n clientId: this.clientId,\n currentShare: this._currentShare,\n ...status,\n };\n }\n\n /**\n * Get the client ID\n */\n getClientId(): string {\n return this.clientId;\n }\n\n /**\n * Get the current share name\n */\n getCurrentShare(): string | null {\n return this._currentShare;\n }\n\n /**\n * Check if connected to SMB server\n */\n async isConnected(): Promise<boolean> {\n if (this.isDisposed) return false;\n try {\n const status = await this.getStatus();\n return status.exists && status.connected;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if connected to SMB server (synchronous)\n */\n isConnectedSync(): boolean {\n return this._isConnected;\n }\n\n /**\n * Check if connected to a share\n */\n hasShareConnected(): boolean {\n return this._isConnected && this._currentShare !== null;\n }\n\n /**\n * Dispose the SMB client and clean up resources\n */\n async dispose(): Promise<void> {\n if (this.isDisposed) return;\n try {\n await ReactNativeKookitModule.disposeSmbClient(this.clientId);\n } catch {}\n this.eventSubscriptions.forEach((s) => s.remove());\n this.eventSubscriptions = [];\n this.isDisposed = true;\n this._isConnected = false;\n this._currentShare = null;\n\n // 从静态实例管理器中移除\n SmbClient.instances.delete(this.clientId);\n }\n\n /**\n * List all SMB clients\n */\n static async listClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }> {\n return ReactNativeKookitModule.listSmbClients();\n }\n\n /**\n * Create a new SMB client instance\n * @param clientId Optional client ID\n * @returns New SMB client instance\n */\n static async create(clientId?: string): Promise<SmbClient> {\n const client = new SmbClient(clientId);\n await client.initialize();\n return client;\n }\n\n /**\n * Dispose a specific SMB client by client ID\n * @param clientId Client ID to dispose\n * @returns true if client was found and disposed, false otherwise\n */\n static async disposeClient(clientId: string): Promise<boolean> {\n const client = SmbClient.instances.get(clientId);\n if (client) {\n await client.dispose();\n return true;\n }\n\n // Try to dispose on native side even if not in our instances map\n try {\n await ReactNativeKookitModule.disposeSmbClient(clientId);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Get the status of a specific SMB client by client ID\n * @param clientId Client ID to check\n * @returns Client status or null if not found\n */\n static getClientStatus(clientId: string): SmbClientStatus {\n const client = SmbClient.instances.get(clientId);\n if (client) {\n return {\n exists: true,\n isConnected: client._isConnected,\n currentShare: client._currentShare,\n isDisposed: client.isDisposed,\n };\n }\n return {\n exists: false,\n isConnected: false,\n currentShare: null,\n isDisposed: true,\n };\n }\n\n /**\n * Get all active client IDs and their status\n * @returns Map of client IDs to their status\n */\n static getAllClientsStatus(): Map<string, SmbClientInfo> {\n const statusMap = new Map();\n SmbClient.instances.forEach((client, clientId) => {\n statusMap.set(clientId, {\n isConnected: client._isConnected,\n currentShare: client._currentShare,\n isDisposed: client.isDisposed,\n });\n });\n return statusMap;\n }\n\n /**\n * Get a specific SMB client instance by client ID\n * @param clientId Client ID to retrieve\n * @returns SMB client instance or null if not found\n */\n static getInstance(clientId: string): SmbClient | null {\n return SmbClient.instances.get(clientId) || null;\n }\n\n /**\n * Dispose all SMB clients\n * @returns Number of clients disposed\n */\n static async disposeAllClients(): Promise<number> {\n const clientIds = Array.from(SmbClient.instances.keys());\n let disposedCount = 0;\n\n for (const clientId of clientIds) {\n try {\n await SmbClient.disposeClient(clientId);\n disposedCount++;\n } catch {\n // Continue with next client even if disposal fails\n }\n }\n\n // Clear the instances map\n SmbClient.instances.clear();\n\n return disposedCount;\n }\n}\n\nexport default SmbClient;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-kookit",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "React Native module for intercepting volume button presses on iOS and Android, with FTP client functionality",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",