react-native-vconsole 0.3.0 → 0.4.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.
- package/README.md +17 -2
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/vconsole/VconsoleModule.kt +36 -23
- package/ios/Vconsole.mm +0 -12
- package/lib/module/VConsole.js +333 -60
- package/lib/module/VConsole.js.map +1 -1
- package/lib/module/core/xhrProxy.js +146 -8
- package/lib/module/core/xhrProxy.js.map +1 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/VConsole.d.ts +7 -2
- package/lib/typescript/src/VConsole.d.ts.map +1 -1
- package/lib/typescript/src/core/xhrProxy.d.ts +2 -1
- package/lib/typescript/src/core/xhrProxy.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +3 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/VConsole.tsx +410 -67
- package/src/core/xhrProxy.ts +179 -10
- package/src/index.tsx +0 -4
- package/src/types.ts +3 -1
package/README.md
CHANGED
|
@@ -18,16 +18,31 @@ export default function App() {
|
|
|
18
18
|
return (
|
|
19
19
|
<>
|
|
20
20
|
{/* your app content */}
|
|
21
|
-
<VConsole
|
|
21
|
+
<VConsole
|
|
22
|
+
enable={true}
|
|
23
|
+
exclude={{
|
|
24
|
+
domains: ['localhost:8081'],
|
|
25
|
+
ip: true,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
22
28
|
</>
|
|
23
29
|
);
|
|
24
30
|
}
|
|
25
31
|
```
|
|
26
32
|
|
|
33
|
+
## VConsole Props
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| `enable` | `boolean` | `true` | Whether to enable and render vConsole. |
|
|
38
|
+
| `exclude` | `{ domains?: string[]; ip?: boolean }` | `{}` | Network capture exclusion rules. |
|
|
39
|
+
| `exclude.domains` | `string[]` | `[]` | Hosts to exclude from Network tab capture, keeping previous host-based matching behavior (e.g. `localhost:8081`). |
|
|
40
|
+
| `exclude.ip` | `boolean` | `false` | When `true`, requests whose hostname is an IP address (IPv4/IPv6) will be skipped in Network tab capture. |
|
|
41
|
+
|
|
27
42
|
## Features
|
|
28
43
|
|
|
29
44
|
- Draggable floating button (`vConsole`) with screen-boundary constraints.
|
|
30
|
-
- Bottom sheet panel (
|
|
45
|
+
- Bottom sheet panel (7/9 screen height) with `Log / Network / System / App` tabs.
|
|
31
46
|
- Log tab captures `console.log/info/warn/error` without breaking original console behavior.
|
|
32
47
|
- Network tab captures `XMLHttpRequest` requests/responses without breaking original request behavior.
|
|
33
48
|
- System/App tabs read info from native module bridges (`NativeModules.Vconsole`).
|
|
@@ -5,6 +5,7 @@ import android.content.Context
|
|
|
5
5
|
import android.net.ConnectivityManager
|
|
6
6
|
import android.net.NetworkCapabilities
|
|
7
7
|
import android.os.Build
|
|
8
|
+
import android.util.Log
|
|
8
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
10
|
import com.facebook.react.bridge.Arguments
|
|
10
11
|
import com.facebook.react.bridge.Promise
|
|
@@ -18,13 +19,6 @@ class VconsoleModule(reactContext: ReactApplicationContext) :
|
|
|
18
19
|
return NAME
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
// Example method
|
|
22
|
-
// See https://reactnative.dev/docs/native-modules-android
|
|
23
|
-
@ReactMethod
|
|
24
|
-
fun multiply(a: Double, b: Double, promise: Promise) {
|
|
25
|
-
promise.resolve(a * b)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
22
|
@ReactMethod
|
|
29
23
|
fun getSystemInfo(promise: Promise) {
|
|
30
24
|
try {
|
|
@@ -33,29 +27,41 @@ class VconsoleModule(reactContext: ReactApplicationContext) :
|
|
|
33
27
|
val memoryInfo = ActivityManager.MemoryInfo()
|
|
34
28
|
activityManager.getMemoryInfo(memoryInfo)
|
|
35
29
|
|
|
36
|
-
val connectivityManager =
|
|
37
|
-
reactApplicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
38
|
-
val network = connectivityManager.activeNetwork
|
|
39
|
-
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
|
40
|
-
|
|
41
|
-
val networkType = when {
|
|
42
|
-
capabilities == null -> "none"
|
|
43
|
-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> "wifi"
|
|
44
|
-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> "cellular"
|
|
45
|
-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> "ethernet"
|
|
46
|
-
else -> "unknown"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
30
|
val map = Arguments.createMap()
|
|
50
31
|
map.putString("manufacturer", Build.MANUFACTURER ?: "")
|
|
51
32
|
map.putString("model", Build.MODEL ?: "")
|
|
52
33
|
map.putString("osVersion", Build.VERSION.RELEASE ?: "")
|
|
53
|
-
map.putString("networkType", networkType)
|
|
54
|
-
map.putBoolean("isNetworkReachable", capabilities != null)
|
|
55
34
|
map.putDouble("totalMemory", memoryInfo.totalMem.toDouble())
|
|
56
35
|
map.putDouble("availableMemory", memoryInfo.availMem.toDouble())
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
val connectivityManager =
|
|
39
|
+
reactApplicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
40
|
+
val network = connectivityManager.activeNetwork
|
|
41
|
+
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
|
42
|
+
|
|
43
|
+
val networkType = when {
|
|
44
|
+
capabilities == null -> "none"
|
|
45
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> "wifi"
|
|
46
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> "cellular"
|
|
47
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> "ethernet"
|
|
48
|
+
else -> "unknown"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
map.putString("networkType", networkType)
|
|
52
|
+
map.putString("isNetworkReachable", "${capabilities != null}")
|
|
53
|
+
} catch (e: SecurityException) {
|
|
54
|
+
Log.w(NAME, "[getSystemInfo] Missing ACCESS_NETWORK_STATE permission")
|
|
55
|
+
map.putString("networkType", "unknown")
|
|
56
|
+
map.putString("isNetworkReachable", "unknown")
|
|
57
|
+
} catch (e: Exception) {
|
|
58
|
+
map.putString("networkType", "unknown")
|
|
59
|
+
map.putString("isNetworkReachable", "unknown")
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
promise.resolve(map)
|
|
58
63
|
} catch (error: Exception) {
|
|
64
|
+
Log.e(NAME, "[getSystemInfo] ${error.stackTraceToString()}")
|
|
59
65
|
promise.reject("SYSTEM_INFO_ERROR", error)
|
|
60
66
|
}
|
|
61
67
|
}
|
|
@@ -65,11 +71,18 @@ class VconsoleModule(reactContext: ReactApplicationContext) :
|
|
|
65
71
|
try {
|
|
66
72
|
val packageInfo =
|
|
67
73
|
reactApplicationContext.packageManager.getPackageInfo(reactApplicationContext.packageName, 0)
|
|
74
|
+
@Suppress("DEPRECATION")
|
|
75
|
+
val buildNumber = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
76
|
+
packageInfo.longVersionCode.toString()
|
|
77
|
+
} else {
|
|
78
|
+
packageInfo.versionCode.toString()
|
|
79
|
+
}
|
|
68
80
|
val map = Arguments.createMap()
|
|
69
81
|
map.putString("appVersion", packageInfo.versionName ?: "")
|
|
70
|
-
map.putString("buildNumber",
|
|
82
|
+
map.putString("buildNumber", buildNumber)
|
|
71
83
|
promise.resolve(map)
|
|
72
84
|
} catch (error: Exception) {
|
|
85
|
+
Log.e(NAME, "[getAppInfo] ${error.stackTraceToString()}")
|
|
73
86
|
promise.reject("APP_INFO_ERROR", error)
|
|
74
87
|
}
|
|
75
88
|
}
|
package/ios/Vconsole.mm
CHANGED
|
@@ -4,18 +4,6 @@
|
|
|
4
4
|
@implementation Vconsole
|
|
5
5
|
RCT_EXPORT_MODULE()
|
|
6
6
|
|
|
7
|
-
// Example method
|
|
8
|
-
// See // https://reactnative.dev/docs/native-modules-ios
|
|
9
|
-
RCT_EXPORT_METHOD(multiply:(double)a
|
|
10
|
-
b:(double)b
|
|
11
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
12
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
13
|
-
{
|
|
14
|
-
NSNumber *result = @(a * b);
|
|
15
|
-
|
|
16
|
-
resolve(result);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
7
|
RCT_EXPORT_METHOD(getSystemInfo:(RCTPromiseResolveBlock)resolve
|
|
20
8
|
reject:(RCTPromiseRejectBlock)reject)
|
|
21
9
|
{
|