@capgo/capacitor-network-diagnostics 8.0.1
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/CapgoCapacitorNetworkDiagnostics.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +467 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/app/capgo/networkdiagnostics/NetworkDiagnostics.java +681 -0
- package/android/src/main/java/app/capgo/networkdiagnostics/NetworkDiagnosticsPlugin.java +141 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +961 -0
- package/dist/esm/definitions.d.ts +276 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +24 -0
- package/dist/esm/web.js +388 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +402 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +405 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnostics+Download.swift +71 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnostics+PacketLoss.swift +91 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnostics+Run.swift +163 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnostics+Utils.swift +202 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnostics.swift +151 -0
- package/ios/Sources/NetworkDiagnosticsPlugin/NetworkDiagnosticsPlugin.swift +139 -0
- package/ios/Tests/NetworkDiagnosticsPluginTests/NetworkDiagnosticsTests.swift +11 -0
- package/package.json +92 -0
package/README.md
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
# @capgo/capacitor-network-diagnostics
|
|
2
|
+
|
|
3
|
+
<a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-network-diagnostics" alt="Capgo - Instant updates for Capacitor" /></a>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h2><a href="https://capgo.app/?ref=plugin_network_diagnostics"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
7
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin_network_diagnostics"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
Capacitor plugin for native network diagnostics. It checks connection type, native HTTP reachability, TCP ports, WebSocket handshakes, download speed, and application-level packet loss from iOS and Android.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @capgo/capacitor-network-diagnostics
|
|
16
|
+
npx cap sync
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What It Tests
|
|
20
|
+
|
|
21
|
+
- Current native connection type: WiFi, cellular, ethernet, VPN, none, or unknown.
|
|
22
|
+
- OS network flags: validated internet on Android, captive portal on Android, expensive or constrained path where available.
|
|
23
|
+
- Native HTTP/HTTPS URL reachability with status code and latency.
|
|
24
|
+
- Native TCP host:port connectivity.
|
|
25
|
+
- Native WebSocket handshake for `ws://` and `wss://`.
|
|
26
|
+
- Download throughput against your own test file endpoint.
|
|
27
|
+
- Packet loss using repeated TCP connects or HTTP requests.
|
|
28
|
+
|
|
29
|
+
Raw ICMP ping is not consistently available to App Store and Play Store apps. `testPacketLoss` therefore measures application-level loss with TCP or HTTP probes.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { NetworkDiagnostics } from '@capgo/capacitor-network-diagnostics';
|
|
35
|
+
|
|
36
|
+
const status = await NetworkDiagnostics.getNetworkStatus();
|
|
37
|
+
|
|
38
|
+
const api = await NetworkDiagnostics.testUrl({
|
|
39
|
+
url: 'https://api.example.com/health',
|
|
40
|
+
method: 'HEAD',
|
|
41
|
+
timeoutMs: 5000,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const port = await NetworkDiagnostics.testPort({
|
|
45
|
+
host: 'api.example.com',
|
|
46
|
+
port: 443,
|
|
47
|
+
timeoutMs: 3000,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const ws = await NetworkDiagnostics.testWebSocket({
|
|
51
|
+
url: 'wss://ws.example.com/socket',
|
|
52
|
+
timeoutMs: 5000,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const packetLoss = await NetworkDiagnostics.testPacketLoss({
|
|
56
|
+
mode: 'tcp',
|
|
57
|
+
host: 'api.example.com',
|
|
58
|
+
port: 443,
|
|
59
|
+
count: 10,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log({ status, api, port, ws, packetLoss });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Combined Diagnostic Run
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const report = await NetworkDiagnostics.runDiagnostics({
|
|
69
|
+
urls: [{ url: 'https://api.example.com/health' }],
|
|
70
|
+
ports: [{ host: 'api.example.com', port: 443 }],
|
|
71
|
+
websockets: [{ url: 'wss://ws.example.com/socket' }],
|
|
72
|
+
download: {
|
|
73
|
+
url: 'https://speed.example.com/5mb.bin',
|
|
74
|
+
maxBytes: 5 * 1024 * 1024,
|
|
75
|
+
},
|
|
76
|
+
packetLoss: {
|
|
77
|
+
mode: 'tcp',
|
|
78
|
+
host: 'api.example.com',
|
|
79
|
+
port: 443,
|
|
80
|
+
count: 10,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
console.log(report.issues);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Platform Notes
|
|
88
|
+
|
|
89
|
+
- iOS: no extra permissions are required. Connection type comes from `Network.framework`.
|
|
90
|
+
- Android: the plugin declares `android.permission.INTERNET` and `android.permission.ACCESS_NETWORK_STATE`.
|
|
91
|
+
- Web: provided as a development fallback. Browsers cannot open raw TCP sockets, and URL checks are limited by CORS.
|
|
92
|
+
|
|
93
|
+
## API
|
|
94
|
+
|
|
95
|
+
<docgen-index>
|
|
96
|
+
|
|
97
|
+
* [`getNetworkStatus()`](#getnetworkstatus)
|
|
98
|
+
* [`testUrl(...)`](#testurl)
|
|
99
|
+
* [`testPort(...)`](#testport)
|
|
100
|
+
* [`testWebSocket(...)`](#testwebsocket)
|
|
101
|
+
* [`testDownloadSpeed(...)`](#testdownloadspeed)
|
|
102
|
+
* [`testPacketLoss(...)`](#testpacketloss)
|
|
103
|
+
* [`runDiagnostics(...)`](#rundiagnostics)
|
|
104
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
105
|
+
* [Interfaces](#interfaces)
|
|
106
|
+
* [Type Aliases](#type-aliases)
|
|
107
|
+
|
|
108
|
+
</docgen-index>
|
|
109
|
+
|
|
110
|
+
<docgen-api>
|
|
111
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
112
|
+
|
|
113
|
+
Native network diagnostics API.
|
|
114
|
+
|
|
115
|
+
### getNetworkStatus()
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
getNetworkStatus() => Promise<NetworkStatusResult>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Read the current native connection type and platform network flags.
|
|
122
|
+
|
|
123
|
+
**Returns:** <code>Promise<<a href="#networkstatusresult">NetworkStatusResult</a>></code>
|
|
124
|
+
|
|
125
|
+
--------------------
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### testUrl(...)
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
testUrl(options: UrlTestOptions) => Promise<UrlTestResult>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Test whether an HTTP or HTTPS URL can be reached from native networking.
|
|
135
|
+
|
|
136
|
+
| Param | Type |
|
|
137
|
+
| ------------- | --------------------------------------------------------- |
|
|
138
|
+
| **`options`** | <code><a href="#urltestoptions">UrlTestOptions</a></code> |
|
|
139
|
+
|
|
140
|
+
**Returns:** <code>Promise<<a href="#urltestresult">UrlTestResult</a>></code>
|
|
141
|
+
|
|
142
|
+
--------------------
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### testPort(...)
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
testPort(options: PortTestOptions) => Promise<PortTestResult>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Test whether a TCP host:port can be opened from native networking.
|
|
152
|
+
|
|
153
|
+
| Param | Type |
|
|
154
|
+
| ------------- | ----------------------------------------------------------- |
|
|
155
|
+
| **`options`** | <code><a href="#porttestoptions">PortTestOptions</a></code> |
|
|
156
|
+
|
|
157
|
+
**Returns:** <code>Promise<<a href="#porttestresult">PortTestResult</a>></code>
|
|
158
|
+
|
|
159
|
+
--------------------
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### testWebSocket(...)
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
testWebSocket(options: WebSocketTestOptions) => Promise<WebSocketTestResult>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Test whether a WebSocket URL can complete its native handshake.
|
|
169
|
+
|
|
170
|
+
| Param | Type |
|
|
171
|
+
| ------------- | --------------------------------------------------------------------- |
|
|
172
|
+
| **`options`** | <code><a href="#websockettestoptions">WebSocketTestOptions</a></code> |
|
|
173
|
+
|
|
174
|
+
**Returns:** <code>Promise<<a href="#websockettestresult">WebSocketTestResult</a>></code>
|
|
175
|
+
|
|
176
|
+
--------------------
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### testDownloadSpeed(...)
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
testDownloadSpeed(options: DownloadSpeedTestOptions) => Promise<DownloadSpeedTestResult>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Measure download throughput from a native HTTP request.
|
|
186
|
+
|
|
187
|
+
| Param | Type |
|
|
188
|
+
| ------------- | ----------------------------------------------------------------------------- |
|
|
189
|
+
| **`options`** | <code><a href="#downloadspeedtestoptions">DownloadSpeedTestOptions</a></code> |
|
|
190
|
+
|
|
191
|
+
**Returns:** <code>Promise<<a href="#downloadspeedtestresult">DownloadSpeedTestResult</a>></code>
|
|
192
|
+
|
|
193
|
+
--------------------
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
### testPacketLoss(...)
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
testPacketLoss(options: PacketLossTestOptions) => Promise<PacketLossTestResult>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Estimate application-level packet loss with repeated TCP or HTTP probes.
|
|
203
|
+
|
|
204
|
+
| Param | Type |
|
|
205
|
+
| ------------- | ----------------------------------------------------------------------- |
|
|
206
|
+
| **`options`** | <code><a href="#packetlosstestoptions">PacketLossTestOptions</a></code> |
|
|
207
|
+
|
|
208
|
+
**Returns:** <code>Promise<<a href="#packetlosstestresult">PacketLossTestResult</a>></code>
|
|
209
|
+
|
|
210
|
+
--------------------
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
### runDiagnostics(...)
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
runDiagnostics(options?: RunDiagnosticsOptions | undefined) => Promise<RunDiagnosticsResult>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Run several diagnostics and return a compact issue list.
|
|
220
|
+
|
|
221
|
+
| Param | Type |
|
|
222
|
+
| ------------- | ----------------------------------------------------------------------- |
|
|
223
|
+
| **`options`** | <code><a href="#rundiagnosticsoptions">RunDiagnosticsOptions</a></code> |
|
|
224
|
+
|
|
225
|
+
**Returns:** <code>Promise<<a href="#rundiagnosticsresult">RunDiagnosticsResult</a>></code>
|
|
226
|
+
|
|
227
|
+
--------------------
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
### getPluginVersion()
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
getPluginVersion() => Promise<PluginVersionResult>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Returns the platform implementation version marker.
|
|
237
|
+
|
|
238
|
+
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
239
|
+
|
|
240
|
+
--------------------
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Interfaces
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
#### NetworkStatusResult
|
|
247
|
+
|
|
248
|
+
Current native network state.
|
|
249
|
+
|
|
250
|
+
| Prop | Type | Description |
|
|
251
|
+
| ----------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
|
|
252
|
+
| **`connected`** | <code>boolean</code> | True when the platform reports an active network path. |
|
|
253
|
+
| **`connectionType`** | <code><a href="#connectiontype">ConnectionType</a></code> | Best-effort active transport type. |
|
|
254
|
+
| **`internetReachable`** | <code>boolean</code> | True when the OS marks the network as internet-capable or validated. |
|
|
255
|
+
| **`expensive`** | <code>boolean</code> | True for metered or expensive network paths. |
|
|
256
|
+
| **`constrained`** | <code>boolean</code> | True when the OS reports a low-data or constrained network path. |
|
|
257
|
+
| **`captivePortal`** | <code>boolean</code> | True when Android reports captive portal capability. |
|
|
258
|
+
| **`details`** | <code><a href="#record">Record</a><string, string \| number \| boolean></code> | Native platform details useful for debugging. |
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
#### UrlTestResult
|
|
262
|
+
|
|
263
|
+
Native HTTP URL reachability result.
|
|
264
|
+
|
|
265
|
+
| Prop | Type |
|
|
266
|
+
| ------------------ | ------------------------------------------------------- |
|
|
267
|
+
| **`url`** | <code>string</code> |
|
|
268
|
+
| **`method`** | <code><a href="#urltestmethod">UrlTestMethod</a></code> |
|
|
269
|
+
| **`ok`** | <code>boolean</code> |
|
|
270
|
+
| **`reachable`** | <code>boolean</code> |
|
|
271
|
+
| **`durationMs`** | <code>number</code> |
|
|
272
|
+
| **`statusCode`** | <code>number</code> |
|
|
273
|
+
| **`finalUrl`** | <code>string</code> |
|
|
274
|
+
| **`errorCode`** | <code>string</code> |
|
|
275
|
+
| **`errorMessage`** | <code>string</code> |
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
#### UrlTestOptions
|
|
279
|
+
|
|
280
|
+
Options for native HTTP URL reachability checks.
|
|
281
|
+
|
|
282
|
+
| Prop | Type | Description |
|
|
283
|
+
| --------------------- | ------------------------------------------------------- | ----------------------------------------------------- |
|
|
284
|
+
| **`url`** | <code>string</code> | HTTP or HTTPS URL to test. |
|
|
285
|
+
| **`method`** | <code><a href="#urltestmethod">UrlTestMethod</a></code> | HTTP method. Defaults to `HEAD`. |
|
|
286
|
+
| **`timeoutMs`** | <code>number</code> | Request timeout in milliseconds. Defaults to `10000`. |
|
|
287
|
+
| **`followRedirects`** | <code>boolean</code> | Follow redirects. Defaults to `true`. |
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
#### PortTestResult
|
|
291
|
+
|
|
292
|
+
Native TCP port check result.
|
|
293
|
+
|
|
294
|
+
| Prop | Type |
|
|
295
|
+
| ------------------ | -------------------- |
|
|
296
|
+
| **`host`** | <code>string</code> |
|
|
297
|
+
| **`port`** | <code>number</code> |
|
|
298
|
+
| **`open`** | <code>boolean</code> |
|
|
299
|
+
| **`durationMs`** | <code>number</code> |
|
|
300
|
+
| **`errorCode`** | <code>string</code> |
|
|
301
|
+
| **`errorMessage`** | <code>string</code> |
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
#### PortTestOptions
|
|
305
|
+
|
|
306
|
+
Options for native TCP port checks.
|
|
307
|
+
|
|
308
|
+
| Prop | Type | Description |
|
|
309
|
+
| --------------- | ------------------- | --------------------------------------------------- |
|
|
310
|
+
| **`host`** | <code>string</code> | Hostname or IP address. |
|
|
311
|
+
| **`port`** | <code>number</code> | TCP port to open. |
|
|
312
|
+
| **`timeoutMs`** | <code>number</code> | Socket timeout in milliseconds. Defaults to `5000`. |
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
#### WebSocketTestResult
|
|
316
|
+
|
|
317
|
+
Native WebSocket handshake result.
|
|
318
|
+
|
|
319
|
+
| Prop | Type |
|
|
320
|
+
| ------------------ | -------------------- |
|
|
321
|
+
| **`url`** | <code>string</code> |
|
|
322
|
+
| **`open`** | <code>boolean</code> |
|
|
323
|
+
| **`durationMs`** | <code>number</code> |
|
|
324
|
+
| **`protocol`** | <code>string</code> |
|
|
325
|
+
| **`statusCode`** | <code>number</code> |
|
|
326
|
+
| **`errorCode`** | <code>string</code> |
|
|
327
|
+
| **`errorMessage`** | <code>string</code> |
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
#### WebSocketTestOptions
|
|
331
|
+
|
|
332
|
+
Options for native WebSocket handshake checks.
|
|
333
|
+
|
|
334
|
+
| Prop | Type | Description |
|
|
335
|
+
| --------------- | ------------------- | ------------------------------------------------------- |
|
|
336
|
+
| **`url`** | <code>string</code> | `ws://` or `wss://` URL to test. |
|
|
337
|
+
| **`timeoutMs`** | <code>number</code> | Handshake timeout in milliseconds. Defaults to `10000`. |
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
#### DownloadSpeedTestResult
|
|
341
|
+
|
|
342
|
+
Native download speed measurement result.
|
|
343
|
+
|
|
344
|
+
| Prop | Type |
|
|
345
|
+
| --------------------- | -------------------- |
|
|
346
|
+
| **`url`** | <code>string</code> |
|
|
347
|
+
| **`ok`** | <code>boolean</code> |
|
|
348
|
+
| **`durationMs`** | <code>number</code> |
|
|
349
|
+
| **`bytesDownloaded`** | <code>number</code> |
|
|
350
|
+
| **`bytesPerSecond`** | <code>number</code> |
|
|
351
|
+
| **`mbps`** | <code>number</code> |
|
|
352
|
+
| **`statusCode`** | <code>number</code> |
|
|
353
|
+
| **`errorCode`** | <code>string</code> |
|
|
354
|
+
| **`errorMessage`** | <code>string</code> |
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
#### DownloadSpeedTestOptions
|
|
358
|
+
|
|
359
|
+
Options for native download speed measurement.
|
|
360
|
+
|
|
361
|
+
| Prop | Type | Description |
|
|
362
|
+
| --------------- | ------------------- | --------------------------------------------------------------------- |
|
|
363
|
+
| **`url`** | <code>string</code> | HTTP or HTTPS URL returning a downloadable body. |
|
|
364
|
+
| **`maxBytes`** | <code>number</code> | Maximum bytes to read before stopping. Defaults to `5242880` (5 MiB). |
|
|
365
|
+
| **`timeoutMs`** | <code>number</code> | Request timeout in milliseconds. Defaults to `30000`. |
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
#### PacketLossTestResult
|
|
369
|
+
|
|
370
|
+
Application-level packet loss result.
|
|
371
|
+
|
|
372
|
+
| Prop | Type |
|
|
373
|
+
| ---------------------- | --------------------------------------------------------- |
|
|
374
|
+
| **`mode`** | <code><a href="#packetlossmode">PacketLossMode</a></code> |
|
|
375
|
+
| **`target`** | <code>string</code> |
|
|
376
|
+
| **`sent`** | <code>number</code> |
|
|
377
|
+
| **`received`** | <code>number</code> |
|
|
378
|
+
| **`lost`** | <code>number</code> |
|
|
379
|
+
| **`lossPercent`** | <code>number</code> |
|
|
380
|
+
| **`averageLatencyMs`** | <code>number</code> |
|
|
381
|
+
| **`minLatencyMs`** | <code>number</code> |
|
|
382
|
+
| **`maxLatencyMs`** | <code>number</code> |
|
|
383
|
+
| **`errorCode`** | <code>string</code> |
|
|
384
|
+
| **`errorMessage`** | <code>string</code> |
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
#### PacketLossTestOptions
|
|
388
|
+
|
|
389
|
+
Options for packet loss measurement.
|
|
390
|
+
|
|
391
|
+
Native apps cannot rely on raw ICMP ping on both iOS and Android, so this
|
|
392
|
+
method measures application-level loss with repeated TCP connects or HTTP
|
|
393
|
+
requests.
|
|
394
|
+
|
|
395
|
+
| Prop | Type | Description |
|
|
396
|
+
| ---------------- | --------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
397
|
+
| **`mode`** | <code><a href="#packetlossmode">PacketLossMode</a></code> | Probe mode. Defaults to `tcp` when host/port is provided, otherwise `http`. |
|
|
398
|
+
| **`host`** | <code>string</code> | Hostname or IP address for TCP probes. |
|
|
399
|
+
| **`port`** | <code>number</code> | TCP port for TCP probes. |
|
|
400
|
+
| **`url`** | <code>string</code> | HTTP or HTTPS URL for HTTP probes. |
|
|
401
|
+
| **`count`** | <code>number</code> | Number of probes to send. Defaults to `10`. |
|
|
402
|
+
| **`timeoutMs`** | <code>number</code> | Per-probe timeout in milliseconds. Defaults to `3000`. |
|
|
403
|
+
| **`intervalMs`** | <code>number</code> | Delay between probes in milliseconds. Defaults to `250`. |
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
#### RunDiagnosticsResult
|
|
407
|
+
|
|
408
|
+
Combined native network diagnostic result.
|
|
409
|
+
|
|
410
|
+
| Prop | Type |
|
|
411
|
+
| ---------------- | --------------------------------------------------------------------------- |
|
|
412
|
+
| **`status`** | <code><a href="#networkstatusresult">NetworkStatusResult</a></code> |
|
|
413
|
+
| **`urls`** | <code>UrlTestResult[]</code> |
|
|
414
|
+
| **`ports`** | <code>PortTestResult[]</code> |
|
|
415
|
+
| **`websockets`** | <code>WebSocketTestResult[]</code> |
|
|
416
|
+
| **`issues`** | <code>string[]</code> |
|
|
417
|
+
| **`download`** | <code><a href="#downloadspeedtestresult">DownloadSpeedTestResult</a></code> |
|
|
418
|
+
| **`packetLoss`** | <code><a href="#packetlosstestresult">PacketLossTestResult</a></code> |
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
#### RunDiagnosticsOptions
|
|
422
|
+
|
|
423
|
+
Options for a combined native network diagnostic run.
|
|
424
|
+
|
|
425
|
+
| Prop | Type |
|
|
426
|
+
| ---------------- | ----------------------------------------------------------------------------- |
|
|
427
|
+
| **`urls`** | <code>UrlTestOptions[]</code> |
|
|
428
|
+
| **`ports`** | <code>PortTestOptions[]</code> |
|
|
429
|
+
| **`websockets`** | <code>WebSocketTestOptions[]</code> |
|
|
430
|
+
| **`download`** | <code><a href="#downloadspeedtestoptions">DownloadSpeedTestOptions</a></code> |
|
|
431
|
+
| **`packetLoss`** | <code><a href="#packetlosstestoptions">PacketLossTestOptions</a></code> |
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
#### PluginVersionResult
|
|
435
|
+
|
|
436
|
+
Plugin version payload.
|
|
437
|
+
|
|
438
|
+
| Prop | Type | Description |
|
|
439
|
+
| ------------- | ------------------- | ----------------------------------------------------------- |
|
|
440
|
+
| **`version`** | <code>string</code> | Version identifier returned by the platform implementation. |
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
### Type Aliases
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
#### ConnectionType
|
|
447
|
+
|
|
448
|
+
<code>'none' | 'wifi' | 'cellular' | 'ethernet' | 'vpn' | 'other' | 'unknown'</code>
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
#### Record
|
|
452
|
+
|
|
453
|
+
Construct a type with a set of properties K of type T
|
|
454
|
+
|
|
455
|
+
<code>{
|
|
456
|
[P in K]: T;
|
|
1
457
|
}</code>
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
#### UrlTestMethod
|
|
461
|
+
|
|
462
|
+
<code>'HEAD' | 'GET'</code>
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
#### PacketLossMode
|
|
466
|
+
|
|
467
|
+
<code>'tcp' | 'http'</code>
|
|
468
|
+
|
|
469
|
+
</docgen-api>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace = "app.capgo.networkdiagnostics"
|
|
22
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lint {
|
|
37
|
+
abortOnError = false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
annotationProcessor project(':capacitor-android')
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
+
testImplementation "junit:junit:$junitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
|
+
}
|