react-native-kookit 0.2.7 → 0.2.9

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,198 @@
1
+ package expo.modules.kookit
2
+
3
+ import com.hierynomus.msdtyp.AccessMask
4
+ import com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation
5
+ import com.hierynomus.msfscc.FileAttributes
6
+ import com.hierynomus.mssmb2.SMB2CreateDisposition
7
+ import com.hierynomus.mssmb2.SMB2ShareAccess
8
+ import com.hierynomus.smbj.SMBClient
9
+ import com.hierynomus.smbj.auth.AuthenticationContext
10
+ import com.hierynomus.smbj.connection.Connection
11
+ import com.hierynomus.smbj.session.Session
12
+ import com.hierynomus.smbj.share.DiskShare
13
+ import com.hierynomus.smbj.share.File
14
+ import kotlinx.coroutines.Dispatchers
15
+ import kotlinx.coroutines.withContext
16
+ import java.io.FileOutputStream
17
+ import java.io.FileInputStream
18
+ import java.io.IOException
19
+
20
+ data class SmbConnectionConfig(
21
+ val host: String,
22
+ val port: Int = 445,
23
+ val username: String,
24
+ val password: String,
25
+ val domain: String? = null,
26
+ val share: String? = null,
27
+ val timeoutMs: Int = 10000
28
+ )
29
+
30
+ data class SmbFileInfo(
31
+ val name: String,
32
+ val isDirectory: Boolean,
33
+ val size: Long,
34
+ val lastModified: Long,
35
+ val attributes: String? = null
36
+ )
37
+
38
+ class SmbClient {
39
+ private val smb = SMBClient()
40
+ private var connection: Connection? = null
41
+ private var session: Session? = null
42
+ private var share: DiskShare? = null
43
+ private var connected = false
44
+
45
+ @Synchronized
46
+ @Throws(IOException::class)
47
+ fun connect(config: SmbConnectionConfig) {
48
+ disconnect()
49
+ val conn = smb.connect(config.host)
50
+ connection = conn
51
+ val auth = AuthenticationContext(
52
+ config.username,
53
+ config.password.toCharArray(),
54
+ config.domain
55
+ )
56
+ session = conn.authenticate(auth)
57
+ connected = true
58
+ if (!config.share.isNullOrBlank()) {
59
+ share = session!!.connectShare(config.share) as DiskShare
60
+ }
61
+ }
62
+
63
+ @Synchronized
64
+ fun openShare(shareName: String) {
65
+ val s = session ?: throw IOException("Not authenticated")
66
+ share?.close()
67
+ share = s.connectShare(shareName) as DiskShare
68
+ }
69
+
70
+ @Synchronized
71
+ fun disconnect() {
72
+ try { share?.close() } catch (_: Exception) {}
73
+ try { session?.logoff() } catch (_: Exception) {}
74
+ try { connection?.close() } catch (_: Exception) {}
75
+ share = null
76
+ session = null
77
+ connection = null
78
+ connected = false
79
+ }
80
+
81
+ @Synchronized
82
+ fun isConnected(): Boolean = connected
83
+
84
+ private fun requireShare(): DiskShare {
85
+ return share ?: throw IOException("No share is opened. Call connect with share or openShare().")
86
+ }
87
+
88
+ suspend fun list(path: String?): List<SmbFileInfo> = withContext(Dispatchers.IO) {
89
+ val disk = requireShare()
90
+ val dirPath = (path?.trim()?.ifEmpty { null } ?: "").replace('\\', '/').removePrefix("./")
91
+ val results = mutableListOf<SmbFileInfo>()
92
+ for (info in disk.list(dirPath)) {
93
+ val name = info.fileName
94
+ if (name == "." || name == "..") continue
95
+ val isDir = info.fileAttributes and FileAttributes.FILE_ATTRIBUTE_DIRECTORY.value != 0L
96
+ val size = if (isDir) 0L else (info as? FileIdBothDirectoryInformation)?.endOfFile ?: 0L
97
+ val lastModified = (info as? FileIdBothDirectoryInformation)?.lastWriteTime?.toEpochMillis() ?: 0L
98
+ val attrs = info.fileAttributes.toString()
99
+ results.add(SmbFileInfo(name, isDir, size, lastModified, attrs))
100
+ }
101
+ results
102
+ }
103
+
104
+ suspend fun download(remotePath: String, localPath: String, onProgress: ((Long, Long) -> Unit)? = null) = withContext(Dispatchers.IO) {
105
+ val disk = requireShare()
106
+ val normRemote = remotePath.replace('\\', '/').removePrefix("./")
107
+ java.io.File(localPath).parentFile?.mkdirs()
108
+ // Request read data + attributes to allow QueryInfo; some servers require READ_ATTRIBUTES for size query
109
+ val readAccess = setOf(
110
+ AccessMask.FILE_READ_DATA,
111
+ AccessMask.FILE_READ_ATTRIBUTES,
112
+ AccessMask.FILE_READ_EA,
113
+ AccessMask.READ_CONTROL,
114
+ AccessMask.SYNCHRONIZE
115
+ )
116
+ disk.openFile(
117
+ normRemote,
118
+ readAccess,
119
+ setOf(FileAttributes.FILE_ATTRIBUTE_NORMAL),
120
+ SMB2ShareAccess.ALL,
121
+ SMB2CreateDisposition.FILE_OPEN,
122
+ null
123
+ ).use { f: File ->
124
+ FileOutputStream(localPath).use { out ->
125
+ val buffer = ByteArray(8192)
126
+ var total = 0L
127
+ var read: Int
128
+ // Some servers deny QueryInfo on the handle unless READ_ATTRIBUTES is requested.
129
+ // Guard this to allow download to proceed even when size is unavailable.
130
+ val fileSize = try {
131
+ f.fileInformation.standardInformation.endOfFile
132
+ } catch (_: Exception) {
133
+ -1L
134
+ }
135
+ while (true) {
136
+ read = f.read(buffer, total)
137
+ if (read <= 0) break
138
+ out.write(buffer, 0, read)
139
+ total += read
140
+ onProgress?.invoke(total, if (fileSize > 0) fileSize else 0L)
141
+ }
142
+ out.flush()
143
+ }
144
+ }
145
+ }
146
+
147
+ suspend fun upload(localPath: String, remotePath: String, onProgress: ((Long, Long) -> Unit)? = null) = withContext(Dispatchers.IO) {
148
+ val disk = requireShare()
149
+ val normRemote = remotePath.replace('\\', '/').removePrefix("./")
150
+ val file = java.io.File(localPath)
151
+ val size = file.length()
152
+ file.inputStream().use { input ->
153
+ val writeAccess = setOf(
154
+ AccessMask.FILE_WRITE_DATA,
155
+ AccessMask.FILE_WRITE_ATTRIBUTES,
156
+ AccessMask.FILE_WRITE_EA,
157
+ AccessMask.READ_CONTROL,
158
+ AccessMask.SYNCHRONIZE
159
+ )
160
+ disk.openFile(
161
+ normRemote,
162
+ writeAccess,
163
+ setOf(FileAttributes.FILE_ATTRIBUTE_NORMAL),
164
+ SMB2ShareAccess.ALL,
165
+ SMB2CreateDisposition.FILE_OVERWRITE_IF,
166
+ null
167
+ ).use { f: File ->
168
+ val buffer = ByteArray(8192)
169
+ var offset = 0L
170
+ var read: Int
171
+ while (input.read(buffer).also { read = it } > 0) {
172
+ f.write(buffer, offset, 0, read)
173
+ offset += read
174
+ onProgress?.invoke(offset, size)
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ suspend fun delete(path: String, isDirectory: Boolean = false) = withContext(Dispatchers.IO) {
181
+ val disk = requireShare()
182
+ val norm = path.replace('\\', '/').removePrefix("./")
183
+ if (isDirectory) {
184
+ disk.rmdir(norm, false)
185
+ } else {
186
+ disk.rm(norm)
187
+ }
188
+ }
189
+
190
+ suspend fun mkdir(path: String) = withContext(Dispatchers.IO) {
191
+ val disk = requireShare()
192
+ val norm = path.replace('\\', '/').removePrefix("./")
193
+ if (!disk.folderExists(norm)) {
194
+ disk.mkdir(norm)
195
+ }
196
+ }
197
+ }
198
+
@@ -46,6 +46,9 @@ export type ReactNativeKookitModuleEvents = {
46
46
  onFtpProgress: (params: FtpProgressEvent) => void;
47
47
  onFtpComplete: (params: FtpCompleteEvent) => void;
48
48
  onFtpError: (params: FtpErrorEvent) => void;
49
+ onSmbProgress: (params: SmbProgressEvent) => void;
50
+ onSmbComplete: (params: SmbCompleteEvent) => void;
51
+ onSmbError: (params: SmbErrorEvent) => void;
49
52
  };
50
53
  export type ChangeEventPayload = {
51
54
  value: string;
@@ -57,4 +60,40 @@ export type ReactNativeKookitViewProps = {
57
60
  }) => void;
58
61
  style?: StyleProp<ViewStyle>;
59
62
  };
63
+ export type SmbConnectionConfig = {
64
+ host: string;
65
+ port?: number;
66
+ username: string;
67
+ password: string;
68
+ domain?: string;
69
+ share?: string;
70
+ timeout?: number;
71
+ };
72
+ export type SmbFileInfo = {
73
+ name: string;
74
+ isDirectory: boolean;
75
+ size: number;
76
+ lastModified?: string;
77
+ attributes?: string;
78
+ };
79
+ export type SmbProgressInfo = {
80
+ transferred: number;
81
+ total: number;
82
+ percentage: number;
83
+ };
84
+ export type SmbProgressEvent = SmbProgressInfo & {
85
+ clientId: string;
86
+ };
87
+ export type SmbCompleteEvent = {
88
+ clientId: string;
89
+ };
90
+ export type SmbErrorEvent = {
91
+ clientId: string;
92
+ error: string;
93
+ };
94
+ export type SmbEventPayload = {
95
+ onProgress?: (progress: SmbProgressInfo) => void;
96
+ onComplete?: () => void;
97
+ onError?: (error: string) => void;
98
+ };
60
99
  //# sourceMappingURL=ReactNativeKookit.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeKookit.types.d.ts","sourceRoot":"","sources":["../src/ReactNativeKookit.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAA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C;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeKookit.types.js","sourceRoot":"","sources":["../src/ReactNativeKookit.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from \"react-native\";\n\nexport type OnLoadEventPayload = {\n url: string;\n};\n\nexport type VolumeKeyEventPayload = {\n key: \"up\" | \"down\";\n};\n\nexport type FtpConnectionConfig = {\n host: string;\n port?: number;\n username: string;\n password: string;\n passive?: boolean;\n timeout?: number;\n};\n\nexport type FtpFileInfo = {\n name: string;\n isDirectory: boolean;\n size: number;\n lastModified: string;\n permissions?: string;\n};\n\nexport type FtpProgressInfo = {\n transferred: number;\n total: number;\n percentage: number;\n};\n\nexport type FtpProgressEvent = FtpProgressInfo & {\n clientId: string;\n};\n\nexport type FtpCompleteEvent = {\n clientId: string;\n};\n\nexport type FtpErrorEvent = {\n clientId: string;\n error: string;\n};\n\nexport type FtpEventPayload = {\n onProgress?: (progress: FtpProgressInfo) => void;\n onComplete?: () => void;\n onError?: (error: string) => void;\n};\n\nexport type ReactNativeKookitModuleEvents = {\n onChange: (params: ChangeEventPayload) => void;\n onVolumeButtonPressed: (params: VolumeKeyEventPayload) => void;\n onFtpProgress: (params: FtpProgressEvent) => void;\n onFtpComplete: (params: FtpCompleteEvent) => void;\n onFtpError: (params: FtpErrorEvent) => void;\n};\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ReactNativeKookitViewProps = {\n url: string;\n onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;\n style?: StyleProp<ViewStyle>;\n};\n"]}
1
+ {"version":3,"file":"ReactNativeKookit.types.js","sourceRoot":"","sources":["../src/ReactNativeKookit.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from \"react-native\";\n\nexport type OnLoadEventPayload = {\n url: string;\n};\n\nexport type VolumeKeyEventPayload = {\n key: \"up\" | \"down\";\n};\n\nexport type FtpConnectionConfig = {\n host: string;\n port?: number;\n username: string;\n password: string;\n passive?: boolean;\n timeout?: number;\n};\n\nexport type FtpFileInfo = {\n name: string;\n isDirectory: boolean;\n size: number;\n lastModified: string;\n permissions?: string;\n};\n\nexport type FtpProgressInfo = {\n transferred: number;\n total: number;\n percentage: number;\n};\n\nexport type FtpProgressEvent = FtpProgressInfo & {\n clientId: string;\n};\n\nexport type FtpCompleteEvent = {\n clientId: string;\n};\n\nexport type FtpErrorEvent = {\n clientId: string;\n error: string;\n};\n\nexport type FtpEventPayload = {\n onProgress?: (progress: FtpProgressInfo) => void;\n onComplete?: () => void;\n onError?: (error: string) => void;\n};\n\nexport type ReactNativeKookitModuleEvents = {\n onChange: (params: ChangeEventPayload) => void;\n onVolumeButtonPressed: (params: VolumeKeyEventPayload) => void;\n onFtpProgress: (params: FtpProgressEvent) => void;\n onFtpComplete: (params: FtpCompleteEvent) => void;\n onFtpError: (params: FtpErrorEvent) => void;\n // SMB events (reserved for future file operations parity)\n onSmbProgress: (params: SmbProgressEvent) => void;\n onSmbComplete: (params: SmbCompleteEvent) => void;\n onSmbError: (params: SmbErrorEvent) => void;\n};\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ReactNativeKookitViewProps = {\n url: string;\n onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;\n style?: StyleProp<ViewStyle>;\n};\n\n// SMB API parity with FTP (OOP new-client style)\nexport type SmbConnectionConfig = {\n host: string;\n port?: number; // default 445\n username: string;\n password: string;\n domain?: string; // optional Windows domain or workgroup\n share?: string; // optional default share to open\n timeout?: number; // ms\n};\n\nexport type SmbFileInfo = {\n name: string;\n isDirectory: boolean;\n size: number;\n lastModified?: string;\n attributes?: string;\n};\n\nexport type SmbProgressInfo = {\n transferred: number;\n total: number;\n percentage: number;\n};\n\nexport type SmbProgressEvent = SmbProgressInfo & {\n clientId: string;\n};\n\nexport type SmbCompleteEvent = {\n clientId: string;\n};\n\nexport type SmbErrorEvent = {\n clientId: string;\n error: string;\n};\n\nexport type SmbEventPayload = {\n onProgress?: (progress: SmbProgressInfo) => void;\n onComplete?: () => void;\n onError?: (error: string) => void;\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { NativeModule } from "expo";
2
- import { ReactNativeKookitModuleEvents, FtpConnectionConfig, FtpFileInfo } from "./ReactNativeKookit.types";
2
+ import { ReactNativeKookitModuleEvents, FtpConnectionConfig, FtpFileInfo, SmbConnectionConfig, SmbFileInfo } from "./ReactNativeKookit.types";
3
3
  declare class ReactNativeKookitModule extends NativeModule<ReactNativeKookitModuleEvents> {
4
4
  PI: number;
5
5
  /**
@@ -119,6 +119,28 @@ declare class ReactNativeKookitModule extends NativeModule<ReactNativeKookitModu
119
119
  }>;
120
120
  count: number;
121
121
  }>;
122
+ createSmbClient(clientId: string): Promise<{
123
+ clientId: string;
124
+ }>;
125
+ smbClientConnect(clientId: string, config: SmbConnectionConfig): Promise<void>;
126
+ smbClientConnectShare(clientId: string, shareName: string): Promise<void>;
127
+ smbClientDisconnect(clientId: string): Promise<void>;
128
+ disposeSmbClient(clientId: string): Promise<void>;
129
+ smbClientList(clientId: string, path?: string): Promise<SmbFileInfo[]>;
130
+ smbClientDownload(clientId: string, remotePath: string, localPath: string): Promise<void>;
131
+ smbClientUpload(clientId: string, localPath: string, remotePath: string): Promise<void>;
132
+ smbClientDelete(clientId: string, remotePath: string, isDirectory?: boolean): Promise<void>;
133
+ smbClientCreateDirectory(clientId: string, remotePath: string): Promise<void>;
134
+ getSmbClientStatus(clientId: string): Promise<{
135
+ exists: boolean;
136
+ connected: boolean;
137
+ }>;
138
+ listSmbClients(): Promise<{
139
+ clients: Record<string, {
140
+ connected: boolean;
141
+ }>;
142
+ count: number;
143
+ }>;
122
144
  }
123
145
  declare const _default: ReactNativeKookitModule;
124
146
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeKookitModule.d.ts","sourceRoot":"","sources":["../src/ReactNativeKookitModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,OAAO,uBAAwB,SAAQ,YAAY,CAAC,6BAA6B,CAAC;IACvF,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,IAAI,MAAM;IAEf;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;;;;;OAMG;IACH,2BAA2B,IAAI,IAAI;IAEnC;;OAEG;IACH,4BAA4B,IAAI,IAAI;IAIpC;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAEhE;;;;;OAKG;IACH,gBAAgB,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,mBAAmB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Ae,mBAAmB,CAChC,mBAAmB,CACpB,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nimport {\n ReactNativeKookitModuleEvents,\n FtpConnectionConfig,\n FtpFileInfo,\n} from \"./ReactNativeKookit.types\";\n\ndeclare class ReactNativeKookitModule extends NativeModule<ReactNativeKookitModuleEvents> {\n PI: number;\n\n /**\n * Returns a hello world string\n */\n hello(): string;\n\n /**\n * Test async function that sends a change event\n */\n setValueAsync(value: string): Promise<void>;\n\n /**\n * Enables volume key interception.\n * On Android, your MainActivity must implement VolumeKeyInterceptActivity interface.\n * On iOS, this works automatically.\n *\n * @throws Error if MainActivity doesn't implement VolumeKeyInterceptActivity on Android\n */\n enableVolumeKeyInterception(): void;\n\n /**\n * Disables volume key interception\n */\n disableVolumeKeyInterception(): void;\n\n // New FTP Client API Methods\n\n /**\n * Create a new FTP client instance\n * @param clientId Unique identifier for the FTP client\n * @returns Promise that resolves with client creation result\n */\n createFtpClient(clientId: string): Promise<{ clientId: string }>;\n\n /**\n * Connect FTP client to server\n * @param clientId FTP client identifier\n * @param config FTP connection configuration\n * @returns Promise that resolves when connected\n */\n ftpClientConnect(\n clientId: string,\n config: FtpConnectionConfig\n ): Promise<void>;\n\n /**\n * Disconnect FTP client from server\n * @param clientId FTP client identifier\n * @returns Promise that resolves when disconnected\n */\n ftpClientDisconnect(clientId: string): Promise<void>;\n\n /**\n * Dispose FTP client and clean up resources\n * @param clientId FTP client identifier\n * @returns Promise that resolves when disposed\n */\n disposeFtpClient(clientId: string): Promise<void>;\n\n /**\n * List files and directories\n * @param clientId FTP client identifier\n * @param path Optional path to list (defaults to current directory)\n * @returns Promise that resolves with array of file information\n */\n ftpClientList(clientId: string, path?: string): Promise<FtpFileInfo[]>;\n\n /**\n * Download a file from FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote file path on FTP server\n * @param localPath Local file path to save the downloaded file\n * @returns Promise that resolves when download is complete\n */\n ftpClientDownload(\n clientId: string,\n remotePath: string,\n localPath: string\n ): Promise<void>;\n\n /**\n * Upload a file to FTP server\n * @param clientId FTP client identifier\n * @param localPath Local file path to upload\n * @param remotePath Remote file path on FTP server\n * @returns Promise that resolves when upload is complete\n */\n ftpClientUpload(\n clientId: string,\n localPath: string,\n remotePath: string\n ): Promise<void>;\n\n /**\n * Delete a file or directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote file or directory path to delete\n * @param isDirectory Whether the path is a directory (default: false)\n * @returns Promise that resolves when deletion is complete\n */\n ftpClientDelete(\n clientId: string,\n remotePath: string,\n isDirectory?: boolean\n ): Promise<void>;\n\n /**\n * Create a directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote directory path to create\n * @returns Promise that resolves when directory is created\n */\n ftpClientCreateDirectory(clientId: string, remotePath: string): Promise<void>;\n\n /**\n * Change current working directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote directory path to change to\n * @returns Promise that resolves when directory is changed\n */\n ftpClientChangeDirectory(clientId: string, remotePath: string): Promise<void>;\n\n /**\n * Get current working directory on FTP server\n * @param clientId FTP client identifier\n * @returns Promise that resolves with current directory path\n */\n ftpClientGetCurrentDirectory(clientId: string): Promise<string>;\n\n /**\n * Get FTP client status\n * @param clientId FTP client identifier\n * @returns Client status information\n */\n getFtpClientStatus(\n clientId: string\n ): Promise<{ exists: boolean; connected: boolean }>;\n\n /**\n * List all FTP clients\n * @returns Object containing all clients and their status\n */\n listFtpClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }>;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ReactNativeKookitModule>(\n \"ReactNativeKookit\"\n);\n"]}
1
+ {"version":3,"file":"ReactNativeKookitModule.js","sourceRoot":"","sources":["../src/ReactNativeKookitModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAmMzD,yDAAyD;AACzD,eAAe,mBAAmB,CAChC,mBAAmB,CACpB,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nimport {\n ReactNativeKookitModuleEvents,\n FtpConnectionConfig,\n FtpFileInfo,\n SmbConnectionConfig,\n SmbFileInfo,\n} from \"./ReactNativeKookit.types\";\n\ndeclare class ReactNativeKookitModule extends NativeModule<ReactNativeKookitModuleEvents> {\n PI: number;\n\n /**\n * Returns a hello world string\n */\n hello(): string;\n\n /**\n * Test async function that sends a change event\n */\n setValueAsync(value: string): Promise<void>;\n\n /**\n * Enables volume key interception.\n * On Android, your MainActivity must implement VolumeKeyInterceptActivity interface.\n * On iOS, this works automatically.\n *\n * @throws Error if MainActivity doesn't implement VolumeKeyInterceptActivity on Android\n */\n enableVolumeKeyInterception(): void;\n\n /**\n * Disables volume key interception\n */\n disableVolumeKeyInterception(): void;\n\n // New FTP Client API Methods\n\n /**\n * Create a new FTP client instance\n * @param clientId Unique identifier for the FTP client\n * @returns Promise that resolves with client creation result\n */\n createFtpClient(clientId: string): Promise<{ clientId: string }>;\n\n /**\n * Connect FTP client to server\n * @param clientId FTP client identifier\n * @param config FTP connection configuration\n * @returns Promise that resolves when connected\n */\n ftpClientConnect(\n clientId: string,\n config: FtpConnectionConfig\n ): Promise<void>;\n\n /**\n * Disconnect FTP client from server\n * @param clientId FTP client identifier\n * @returns Promise that resolves when disconnected\n */\n ftpClientDisconnect(clientId: string): Promise<void>;\n\n /**\n * Dispose FTP client and clean up resources\n * @param clientId FTP client identifier\n * @returns Promise that resolves when disposed\n */\n disposeFtpClient(clientId: string): Promise<void>;\n\n /**\n * List files and directories\n * @param clientId FTP client identifier\n * @param path Optional path to list (defaults to current directory)\n * @returns Promise that resolves with array of file information\n */\n ftpClientList(clientId: string, path?: string): Promise<FtpFileInfo[]>;\n\n /**\n * Download a file from FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote file path on FTP server\n * @param localPath Local file path to save the downloaded file\n * @returns Promise that resolves when download is complete\n */\n ftpClientDownload(\n clientId: string,\n remotePath: string,\n localPath: string\n ): Promise<void>;\n\n /**\n * Upload a file to FTP server\n * @param clientId FTP client identifier\n * @param localPath Local file path to upload\n * @param remotePath Remote file path on FTP server\n * @returns Promise that resolves when upload is complete\n */\n ftpClientUpload(\n clientId: string,\n localPath: string,\n remotePath: string\n ): Promise<void>;\n\n /**\n * Delete a file or directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote file or directory path to delete\n * @param isDirectory Whether the path is a directory (default: false)\n * @returns Promise that resolves when deletion is complete\n */\n ftpClientDelete(\n clientId: string,\n remotePath: string,\n isDirectory?: boolean\n ): Promise<void>;\n\n /**\n * Create a directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote directory path to create\n * @returns Promise that resolves when directory is created\n */\n ftpClientCreateDirectory(clientId: string, remotePath: string): Promise<void>;\n\n /**\n * Change current working directory on FTP server\n * @param clientId FTP client identifier\n * @param remotePath Remote directory path to change to\n * @returns Promise that resolves when directory is changed\n */\n ftpClientChangeDirectory(clientId: string, remotePath: string): Promise<void>;\n\n /**\n * Get current working directory on FTP server\n * @param clientId FTP client identifier\n * @returns Promise that resolves with current directory path\n */\n ftpClientGetCurrentDirectory(clientId: string): Promise<string>;\n\n /**\n * Get FTP client status\n * @param clientId FTP client identifier\n * @returns Client status information\n */\n getFtpClientStatus(\n clientId: string\n ): Promise<{ exists: boolean; connected: boolean }>;\n\n /**\n * List all FTP clients\n * @returns Object containing all clients and their status\n */\n listFtpClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }>;\n\n // SMB Client API\n\n createSmbClient(clientId: string): Promise<{ clientId: string }>;\n smbClientConnect(\n clientId: string,\n config: SmbConnectionConfig\n ): Promise<void>;\n smbClientConnectShare(clientId: string, shareName: string): Promise<void>;\n smbClientDisconnect(clientId: string): Promise<void>;\n disposeSmbClient(clientId: string): Promise<void>;\n smbClientList(clientId: string, path?: string): Promise<SmbFileInfo[]>;\n smbClientDownload(\n clientId: string,\n remotePath: string,\n localPath: string\n ): Promise<void>;\n smbClientUpload(\n clientId: string,\n localPath: string,\n remotePath: string\n ): Promise<void>;\n smbClientDelete(\n clientId: string,\n remotePath: string,\n isDirectory?: boolean\n ): Promise<void>;\n smbClientCreateDirectory(clientId: string, remotePath: string): Promise<void>;\n getSmbClientStatus(\n clientId: string\n ): Promise<{ exists: boolean; connected: boolean }>;\n listSmbClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }>;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ReactNativeKookitModule>(\n \"ReactNativeKookit\"\n);\n"]}
@@ -0,0 +1,45 @@
1
+ import type { SmbConnectionConfig, SmbFileInfo } from "./ReactNativeKookit.types";
2
+ export interface SmbClientEventHandlers {
3
+ onProgress?: (progress: {
4
+ transferred: number;
5
+ total: number;
6
+ percentage: number;
7
+ }) => void;
8
+ onComplete?: () => void;
9
+ onError?: (error: Error) => void;
10
+ }
11
+ export declare class SmbClient {
12
+ private clientId;
13
+ private isDisposed;
14
+ private eventHandlers;
15
+ private eventSubscriptions;
16
+ constructor(clientId?: string);
17
+ private setupEventListeners;
18
+ setEventHandlers(handlers: SmbClientEventHandlers): void;
19
+ initialize(): Promise<void>;
20
+ connect(config: SmbConnectionConfig): Promise<void>;
21
+ connectShare(shareName: string): Promise<void>;
22
+ disconnect(): Promise<void>;
23
+ list(path?: string): Promise<SmbFileInfo[]>;
24
+ download(remotePath: string, localPath: string): Promise<void>;
25
+ upload(localPath: string, remotePath: string): Promise<void>;
26
+ delete(remotePath: string, isDirectory?: boolean): Promise<void>;
27
+ createDirectory(remotePath: string): Promise<void>;
28
+ getStatus(): Promise<{
29
+ clientId: string;
30
+ exists: boolean;
31
+ connected: boolean;
32
+ }>;
33
+ getClientId(): string;
34
+ isConnected(): Promise<boolean>;
35
+ dispose(): Promise<void>;
36
+ static listClients(): Promise<{
37
+ clients: Record<string, {
38
+ connected: boolean;
39
+ }>;
40
+ count: number;
41
+ }>;
42
+ static create(clientId?: string): Promise<SmbClient>;
43
+ }
44
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,OAAO,CAAC,IAAI,CAAC;IAS5D,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,IAAI,CAAC;IASV,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlD,SAAS,IAAI,OAAO,CAAC;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IAOF,WAAW,IAAI,MAAM;IAIf,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;WAUjB,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;WAIW,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAK3D;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,122 @@
1
+ import ReactNativeKookitModule from "./ReactNativeKookitModule";
2
+ export class SmbClient {
3
+ clientId;
4
+ isDisposed = false;
5
+ eventHandlers = {};
6
+ eventSubscriptions = [];
7
+ constructor(clientId) {
8
+ this.clientId =
9
+ clientId ||
10
+ `smb_client_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
11
+ this.setupEventListeners();
12
+ }
13
+ setupEventListeners() {
14
+ const progressSub = ReactNativeKookitModule.addListener("onSmbProgress", (event) => {
15
+ if (event.clientId === this.clientId && this.eventHandlers.onProgress) {
16
+ this.eventHandlers.onProgress({
17
+ transferred: event.transferred,
18
+ total: event.total,
19
+ percentage: event.percentage,
20
+ });
21
+ }
22
+ });
23
+ const completeSub = ReactNativeKookitModule.addListener("onSmbComplete", (event) => {
24
+ if (event.clientId === this.clientId && this.eventHandlers.onComplete) {
25
+ this.eventHandlers.onComplete();
26
+ }
27
+ });
28
+ const errorSub = ReactNativeKookitModule.addListener("onSmbError", (event) => {
29
+ if (event.clientId === this.clientId && this.eventHandlers.onError) {
30
+ this.eventHandlers.onError(new Error(event.error));
31
+ }
32
+ });
33
+ this.eventSubscriptions = [progressSub, completeSub, errorSub];
34
+ }
35
+ setEventHandlers(handlers) {
36
+ this.eventHandlers = { ...handlers };
37
+ }
38
+ async initialize() {
39
+ if (this.isDisposed)
40
+ throw new Error("SMB client has been disposed");
41
+ await ReactNativeKookitModule.createSmbClient(this.clientId);
42
+ }
43
+ async connect(config) {
44
+ if (this.isDisposed)
45
+ throw new Error("SMB client has been disposed");
46
+ await ReactNativeKookitModule.smbClientConnect(this.clientId, config);
47
+ }
48
+ async connectShare(shareName) {
49
+ if (this.isDisposed)
50
+ throw new Error("SMB client has been disposed");
51
+ await ReactNativeKookitModule.smbClientConnectShare(this.clientId, shareName);
52
+ }
53
+ async disconnect() {
54
+ if (this.isDisposed)
55
+ throw new Error("SMB client has been disposed");
56
+ await ReactNativeKookitModule.smbClientDisconnect(this.clientId);
57
+ }
58
+ async list(path) {
59
+ if (this.isDisposed)
60
+ throw new Error("SMB client has been disposed");
61
+ return ReactNativeKookitModule.smbClientList(this.clientId, path);
62
+ }
63
+ async download(remotePath, localPath) {
64
+ if (this.isDisposed)
65
+ throw new Error("SMB client has been disposed");
66
+ await ReactNativeKookitModule.smbClientDownload(this.clientId, remotePath, localPath);
67
+ }
68
+ async upload(localPath, remotePath) {
69
+ if (this.isDisposed)
70
+ throw new Error("SMB client has been disposed");
71
+ await ReactNativeKookitModule.smbClientUpload(this.clientId, localPath, remotePath);
72
+ }
73
+ async delete(remotePath, isDirectory = false) {
74
+ if (this.isDisposed)
75
+ throw new Error("SMB client has been disposed");
76
+ await ReactNativeKookitModule.smbClientDelete(this.clientId, remotePath, isDirectory);
77
+ }
78
+ async createDirectory(remotePath) {
79
+ if (this.isDisposed)
80
+ throw new Error("SMB client has been disposed");
81
+ await ReactNativeKookitModule.smbClientCreateDirectory(this.clientId, remotePath);
82
+ }
83
+ async getStatus() {
84
+ const status = await ReactNativeKookitModule.getSmbClientStatus(this.clientId);
85
+ return { clientId: this.clientId, ...status };
86
+ }
87
+ getClientId() {
88
+ return this.clientId;
89
+ }
90
+ async isConnected() {
91
+ if (this.isDisposed)
92
+ return false;
93
+ try {
94
+ const status = await this.getStatus();
95
+ return status.exists && status.connected;
96
+ }
97
+ catch {
98
+ return false;
99
+ }
100
+ }
101
+ async dispose() {
102
+ if (this.isDisposed)
103
+ return;
104
+ try {
105
+ await ReactNativeKookitModule.disposeSmbClient(this.clientId);
106
+ }
107
+ catch { }
108
+ this.eventSubscriptions.forEach((s) => s.remove());
109
+ this.eventSubscriptions = [];
110
+ this.isDisposed = true;
111
+ }
112
+ static async listClients() {
113
+ return ReactNativeKookitModule.listSmbClients();
114
+ }
115
+ static async create(clientId) {
116
+ const client = new SmbClient(clientId);
117
+ await client.initialize();
118
+ return client;
119
+ }
120
+ }
121
+ export default SmbClient;
122
+ //# sourceMappingURL=SmbClient.js.map
@@ -0,0 +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;IAE/D,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;Q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O;QACX,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAC5B,IAAI,CAAC;YACH,MAAM,uBAAuB,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,WAAW;QAItB,OAAO,uBAAuB,CAAC,cAAc,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAiB;QACnC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,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 class SmbClient {\n private clientId: string;\n private isDisposed: boolean = false;\n private eventHandlers: SmbClientEventHandlers = {};\n private eventSubscriptions: Array<{ remove: () => void }> = [];\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 setEventHandlers(handlers: SmbClientEventHandlers): void {\n this.eventHandlers = { ...handlers };\n }\n\n 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 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 }\n\n async connectShare(shareName: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientConnectShare(\n this.clientId,\n shareName\n );\n }\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 }\n\n async list(path?: string): Promise<SmbFileInfo[]> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n return ReactNativeKookitModule.smbClientList(this.clientId, path);\n }\n\n async download(remotePath: string, localPath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientDownload(\n this.clientId,\n remotePath,\n localPath\n );\n }\n\n async upload(localPath: string, remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientUpload(\n this.clientId,\n localPath,\n remotePath\n );\n }\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 await ReactNativeKookitModule.smbClientDelete(\n this.clientId,\n remotePath,\n isDirectory\n );\n }\n\n async createDirectory(remotePath: string): Promise<void> {\n if (this.isDisposed) throw new Error(\"SMB client has been disposed\");\n await ReactNativeKookitModule.smbClientCreateDirectory(\n this.clientId,\n remotePath\n );\n }\n\n async getStatus(): Promise<{\n clientId: string;\n exists: boolean;\n connected: boolean;\n }> {\n const status = await ReactNativeKookitModule.getSmbClientStatus(\n this.clientId\n );\n return { clientId: this.clientId, ...status };\n }\n\n getClientId(): string {\n return this.clientId;\n }\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 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 }\n\n static async listClients(): Promise<{\n clients: Record<string, { connected: boolean }>;\n count: number;\n }> {\n return ReactNativeKookitModule.listSmbClients();\n }\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"]}
package/build/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { default } from "./ReactNativeKookitModule";
2
2
  export { default as ReactNativeKookitView } from "./ReactNativeKookitView";
3
3
  export * from "./ReactNativeKookit.types";
4
4
  export { FtpClient } from "./FtpClient";
5
+ export { SmbClient } from "./SmbClient";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/build/index.js CHANGED
@@ -4,4 +4,5 @@ export { default } from "./ReactNativeKookitModule";
4
4
  export { default as ReactNativeKookitView } from "./ReactNativeKookitView";
5
5
  export * from "./ReactNativeKookit.types";
6
6
  export { FtpClient } from "./FtpClient";
7
+ export { SmbClient } from "./SmbClient";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wDAAwD;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Reexport the native module. On web, it will be resolved to ReactNativeKookitModule.web.ts\n// and on native platforms to ReactNativeKookitModule.ts\nexport { default } from \"./ReactNativeKookitModule\";\nexport { default as ReactNativeKookitView } from \"./ReactNativeKookitView\";\nexport * from \"./ReactNativeKookit.types\";\nexport { FtpClient } from \"./FtpClient\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wDAAwD;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Reexport the native module. On web, it will be resolved to ReactNativeKookitModule.web.ts\n// and on native platforms to ReactNativeKookitModule.ts\nexport { default } from \"./ReactNativeKookitModule\";\nexport { default as ReactNativeKookitView } from \"./ReactNativeKookitView\";\nexport * from \"./ReactNativeKookit.types\";\nexport { FtpClient } from \"./FtpClient\";\nexport { SmbClient } from \"./SmbClient\";\n"]}
@@ -19,6 +19,7 @@ Pod::Spec.new do |s|
19
19
  s.static_framework = true
20
20
 
21
21
  s.dependency 'ExpoModulesCore'
22
+ s.dependency 'SMBClient'
22
23
 
23
24
  # Add Network framework for FTP functionality
24
25
  s.frameworks = 'Network'