@ansight/react-native 1.0.2-preview.7 → 1.1.0-preview.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/README.md +37 -37
- package/android/build.gradle +3 -1
- package/android/src/main/kotlin/ai/ansight/reactnative/AnsightReactNativeModule.kt +57 -13
- package/index.d.ts +11 -6
- package/index.js +21 -12
- package/ios/AnsightReactNative.swift +25 -13
- package/ios/AnsightReactNativeModule.m +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,39 +25,26 @@ npx react-native run-android
|
|
|
25
25
|
|
|
26
26
|
This package version expects matching native SDK packages:
|
|
27
27
|
|
|
28
|
-
- CocoaPods: `Ansight`, `AnsightObjC` version `1.0
|
|
29
|
-
- Maven: `ai.ansight:ansight-android:1.0
|
|
28
|
+
- CocoaPods: `Ansight`, `AnsightObjC` version `1.1.0-preview.1`
|
|
29
|
+
- Maven: `ai.ansight:ansight-android:1.1.0-preview.1`
|
|
30
30
|
|
|
31
31
|
## Quickstart
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
import Ansight from "@ansight/react-native";
|
|
35
35
|
|
|
36
|
-
const isDevelopmentOnly = __DEV__;
|
|
37
|
-
|
|
38
36
|
await Ansight.initializeAndActivate({
|
|
39
|
-
useNativeAllInOneDefaults:
|
|
37
|
+
useNativeAllInOneDefaults: __DEV__,
|
|
40
38
|
clientName: "My React Native App",
|
|
41
|
-
|
|
42
|
-
enabled: isDevelopmentOnly,
|
|
43
|
-
initialDelayMilliseconds: 1000,
|
|
44
|
-
probeIntervalMilliseconds: 5000,
|
|
45
|
-
reconnectDelayMilliseconds: 10000,
|
|
46
|
-
clientName: "My React Native App",
|
|
47
|
-
},
|
|
48
|
-
hostConnection: isDevelopmentOnly ? {
|
|
49
|
-
bundledDeveloperConfigJson: process.env.EXPO_PUBLIC_ANSIGHT_PAIRING_CONFIG_JSON,
|
|
50
|
-
} : undefined,
|
|
51
|
-
toolGuard: isDevelopmentOnly ? "readOnly" : "disabled",
|
|
39
|
+
toolGuard: __DEV__ ? "readOnly" : "disabled",
|
|
52
40
|
lifecycle: true,
|
|
53
41
|
});
|
|
54
|
-
|
|
55
|
-
await Ansight.connect(null, {
|
|
56
|
-
clientName: "My React Native App",
|
|
57
|
-
expectedAppId: "com.example.app",
|
|
58
|
-
});
|
|
59
42
|
```
|
|
60
43
|
|
|
44
|
+
The native iOS Simulator or Android emulator runtime registers automatically
|
|
45
|
+
with a running, signed-in Studio. No pairing file, environment variable, host
|
|
46
|
+
address, or build-time Studio probe is required.
|
|
47
|
+
|
|
61
48
|
`useNativeAllInOneDefaults` defaults to `false`. It only applies the native
|
|
62
49
|
iOS/Android all-in-one defaults: 400 ms sampling, 120 second retention, FPS,
|
|
63
50
|
touch capture, 2000 ms JPEG capture at quality 60 and max width 480, host
|
|
@@ -92,7 +79,6 @@ The TypeScript `AnsightOptions` surface mirrors Android `AnsightOptions`, iOS
|
|
|
92
79
|
| Option | Purpose |
|
|
93
80
|
| --- | --- |
|
|
94
81
|
| `useNativeAllInOneDefaults` | Applies native iOS/Android all-in-one defaults when true. Defaults to false. This enables the native visual-tree/screenshot tools required by Studio visual tree inspection unless `remoteTools.visualTree` is explicitly false. Configure `toolGuard`, capture options, and `hostConnection` separately. |
|
|
95
|
-
| `pairingConfigJson` | Legacy top-level pairing JSON. Prefer `hostConnection.*`. |
|
|
96
82
|
| `clientName` | Default client name for host auto-probe and connections. |
|
|
97
83
|
| `sampleFrequencyMilliseconds` | Built-in telemetry sampling interval. |
|
|
98
84
|
| `retentionPeriodSeconds` | Local metric/event retention window. |
|
|
@@ -107,11 +93,25 @@ The TypeScript `AnsightOptions` surface mirrors Android `AnsightOptions`, iOS
|
|
|
107
93
|
| `toolGuard` | `"disabled"`, `"readOnly"`, `"readWrite"`, or `"fullAccess"`. |
|
|
108
94
|
| `customProperties` | Grouped string properties sent with `session.open`. |
|
|
109
95
|
| `hostAutoProbe` | Remembered-host retry settings for reconnecting after the host disappears and later reappears. |
|
|
110
|
-
| `hostConnection` |
|
|
96
|
+
| `hostConnection` | Enrollment reconnect and network policy. |
|
|
111
97
|
| `secureStorage` | Compatibility alias for native secure-storage allow-list settings. |
|
|
112
98
|
| `remoteTools` | Native visual tree, file, database, preferences, reflection, and secure-storage tool options. |
|
|
113
99
|
| `lifecycle` | JS AppState tracking toggle. Defaults to true. |
|
|
114
100
|
|
|
101
|
+
Cellular host connections are disabled by default. The restriction applies to
|
|
102
|
+
enrollment and reconnect requests. Opt in only for a trusted development host
|
|
103
|
+
or personal hotspot:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const options = Ansight.createOptionsBuilder()
|
|
107
|
+
.withCellularHostConnections()
|
|
108
|
+
.build();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You can also set `hostConnection.allowCellularConnections: true` directly.
|
|
112
|
+
This may consume mobile data and permits connection attempts over a broader or
|
|
113
|
+
carrier-managed network; use it only with a trusted development host.
|
|
114
|
+
|
|
115
115
|
Example:
|
|
116
116
|
|
|
117
117
|
```ts
|
|
@@ -192,36 +192,36 @@ compatibility alias for `remoteTools.secureStorage`.
|
|
|
192
192
|
|
|
193
193
|
## Host Connection
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
No connection call is needed for a simulator or emulator. On a physical
|
|
196
|
+
device, scan the QR displayed by Studio once:
|
|
196
197
|
|
|
197
198
|
```ts
|
|
198
|
-
await Ansight.
|
|
199
|
+
await Ansight.enrollFromQrCode({
|
|
199
200
|
clientName: "My React Native App",
|
|
200
201
|
expectedAppId: "com.example.app",
|
|
201
202
|
});
|
|
202
203
|
```
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
After physical-device enrollment, `connect(null, options)` and the runtime
|
|
206
|
+
connection loop use the remembered registration:
|
|
205
207
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
```ts
|
|
209
|
+
await Ansight.connect(null, { clientName: "My React Native App" });
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
When Studio is closed or signed out, automatic attempts remain dormant and
|
|
213
|
+
retry later without failing the React Native app.
|
|
210
214
|
|
|
211
|
-
|
|
215
|
+
If the app already owns a scanner, pass its result through the explicit payload
|
|
216
|
+
API:
|
|
212
217
|
|
|
213
218
|
```ts
|
|
214
|
-
await Ansight.connect(
|
|
219
|
+
await Ansight.connect(enrollmentPayload, {
|
|
215
220
|
clientName: "My React Native App",
|
|
216
221
|
expectedAppId: "com.example.app",
|
|
217
222
|
hostAddressOverride: "192.168.1.20",
|
|
218
223
|
});
|
|
219
224
|
|
|
220
|
-
await Ansight.savePairingConfig(pairingJson, {
|
|
221
|
-
expectedAppId: "com.example.app",
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
await Ansight.clearSavedPairing();
|
|
225
225
|
await Ansight.clearCachedSession();
|
|
226
226
|
await Ansight.disconnect();
|
|
227
227
|
```
|
package/android/build.gradle
CHANGED
|
@@ -66,5 +66,7 @@ repositories {
|
|
|
66
66
|
|
|
67
67
|
dependencies {
|
|
68
68
|
implementation("com.facebook.react:react-android")
|
|
69
|
-
|
|
69
|
+
def ansightAndroidVersion =
|
|
70
|
+
findProperty("ansightAndroidVersion") ?: "1.1.0-preview.1"
|
|
71
|
+
implementation("ai.ansight:ansight-android:1.1.0-preview.1")
|
|
70
72
|
}
|
|
@@ -38,6 +38,7 @@ import ai.ansight.runtime.ToolScope
|
|
|
38
38
|
import ai.ansight.runtime.ToolSecurity
|
|
39
39
|
import ai.ansight.runtime.ToolSecurityLevel
|
|
40
40
|
import ai.ansight.runtime.sendBinaryTransfer
|
|
41
|
+
import ai.ansight.pairing.AnsightPairing
|
|
41
42
|
import ai.ansight.tools.database.AndroidDatabaseRoot
|
|
42
43
|
import ai.ansight.tools.database.AndroidDatabaseToolsOptions
|
|
43
44
|
import ai.ansight.tools.database.withDatabaseTools
|
|
@@ -74,6 +75,7 @@ import java.util.concurrent.CountDownLatch
|
|
|
74
75
|
import java.util.concurrent.Executors
|
|
75
76
|
import java.util.concurrent.TimeUnit
|
|
76
77
|
import java.util.concurrent.atomic.AtomicInteger
|
|
78
|
+
import java.util.concurrent.atomic.AtomicBoolean
|
|
77
79
|
import java.util.Locale
|
|
78
80
|
|
|
79
81
|
class AnsightReactNativeModule(
|
|
@@ -263,6 +265,56 @@ class AnsightReactNativeModule(
|
|
|
263
265
|
}
|
|
264
266
|
}
|
|
265
267
|
|
|
268
|
+
@ReactMethod
|
|
269
|
+
fun scanPairingQrCode(options: ReadableMap?, promise: Promise) {
|
|
270
|
+
val activity = currentActivity
|
|
271
|
+
if (activity == null) {
|
|
272
|
+
promise.reject("ansight_qr_unavailable", "QR pairing is unavailable because no Android activity is available.")
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
val completed = AtomicBoolean(false)
|
|
277
|
+
AnsightPairing.scanQrCode(
|
|
278
|
+
activity = activity,
|
|
279
|
+
onPayload = { payload ->
|
|
280
|
+
if (!completed.compareAndSet(false, true)) {
|
|
281
|
+
return@scanQrCode
|
|
282
|
+
}
|
|
283
|
+
if (payload.isNullOrBlank()) {
|
|
284
|
+
promise.resolve(
|
|
285
|
+
hostConnectionResultMap(
|
|
286
|
+
HostConnectionResult.failure(
|
|
287
|
+
message = "QR pairing canceled.",
|
|
288
|
+
reasonCode = "pairing_canceled",
|
|
289
|
+
),
|
|
290
|
+
),
|
|
291
|
+
)
|
|
292
|
+
return@scanQrCode
|
|
293
|
+
}
|
|
294
|
+
backgroundExecutor.execute {
|
|
295
|
+
runCatching {
|
|
296
|
+
hostConnectionResultMap(
|
|
297
|
+
AnsightRuntime.connect(
|
|
298
|
+
HostConnectionRequest(
|
|
299
|
+
kind = HostConnectionRequestKind.QrCode,
|
|
300
|
+
payload = payload,
|
|
301
|
+
clientName = options.stringValue("clientName"),
|
|
302
|
+
expectedAppId = options.stringValue("expectedAppId"),
|
|
303
|
+
hostAddressOverride = options.stringValue("hostAddressOverride"),
|
|
304
|
+
),
|
|
305
|
+
),
|
|
306
|
+
)
|
|
307
|
+
}.resolve(promise)
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
onError = { error ->
|
|
311
|
+
if (completed.compareAndSet(false, true)) {
|
|
312
|
+
promise.reject("ansight_qr_error", error.message, error)
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
266
318
|
@ReactMethod
|
|
267
319
|
fun openSession(pairingPayload: String?, options: ReadableMap?, promise: Promise) {
|
|
268
320
|
backgroundExecutor.execute {
|
|
@@ -616,23 +668,14 @@ class AnsightReactNativeModule(
|
|
|
616
668
|
|
|
617
669
|
private fun buildOptions(map: ReadableMap?): AnsightOptions {
|
|
618
670
|
val useNativeAllInOneDefaults = map.booleanValue("useNativeAllInOneDefaults", false)
|
|
619
|
-
val pairingConfigJson = map.stringValue("pairingConfigJson")
|
|
620
671
|
val clientName = map.stringValue("clientName")
|
|
621
672
|
var options = if (useNativeAllInOneDefaults) {
|
|
622
673
|
AnsightDeveloperMode.options(
|
|
623
|
-
bundledDeveloperConfigJson = pairingConfigJson,
|
|
624
674
|
clientName = clientName,
|
|
625
675
|
)
|
|
626
676
|
} else {
|
|
627
677
|
AnsightOptions()
|
|
628
678
|
}
|
|
629
|
-
if (!useNativeAllInOneDefaults && !pairingConfigJson.isNullOrBlank()) {
|
|
630
|
-
options = options.copy(
|
|
631
|
-
hostConnection = options.hostConnection.copy(
|
|
632
|
-
bundledConfigJson = pairingConfigJson,
|
|
633
|
-
),
|
|
634
|
-
)
|
|
635
|
-
}
|
|
636
679
|
if (useNativeAllInOneDefaults && !map.hasString("toolGuard")) {
|
|
637
680
|
options = options.copy(toolGuard = AnsightToolGuard.ReadOnly)
|
|
638
681
|
}
|
|
@@ -747,8 +790,11 @@ class AnsightReactNativeModule(
|
|
|
747
790
|
hostConnection = AnsightHostConnectionOptions(
|
|
748
791
|
savedConfigKey = host.stringValue("savedConfigKey") ?: options.hostConnection.savedConfigKey,
|
|
749
792
|
bundledConfigJson = host.stringValue("bundledConfigJson") ?: options.hostConnection.bundledConfigJson,
|
|
750
|
-
bundledDeveloperConfigJson = host.stringValue("bundledDeveloperConfigJson") ?: options.hostConnection.bundledDeveloperConfigJson,
|
|
751
793
|
discoveryPort = host.optionalInt("discoveryPort") ?: options.hostConnection.discoveryPort,
|
|
794
|
+
allowCellularConnections = host.booleanValue(
|
|
795
|
+
"allowCellularConnections",
|
|
796
|
+
options.hostConnection.allowCellularConnections,
|
|
797
|
+
),
|
|
752
798
|
connectionProfileRetentionSeconds = host.longValue(
|
|
753
799
|
"connectionProfileRetentionSeconds",
|
|
754
800
|
options.hostConnection.connectionProfileRetentionSeconds,
|
|
@@ -1014,7 +1060,6 @@ class AnsightReactNativeModule(
|
|
|
1014
1060
|
putString("configId", result.configId)
|
|
1015
1061
|
putString("appId", result.appId)
|
|
1016
1062
|
putString("resolvedHostAddress", result.resolvedHostAddress)
|
|
1017
|
-
putBoolean("usedEmbeddedDeveloperPairing", result.usedEmbeddedDeveloperPairing)
|
|
1018
1063
|
putString("discoverySource", result.discoverySource)
|
|
1019
1064
|
putString("reasonCode", result.reasonCode)
|
|
1020
1065
|
putString("hostId", result.hostId)
|
|
@@ -1034,7 +1079,6 @@ class AnsightReactNativeModule(
|
|
|
1034
1079
|
putString("hostId", session.hostId)
|
|
1035
1080
|
putString("hostName", session.hostName)
|
|
1036
1081
|
putBoolean("accepted", session.accepted)
|
|
1037
|
-
putBoolean("usedEmbeddedDeveloperPairing", session.usedEmbeddedDeveloperPairing)
|
|
1038
1082
|
putString("discoverySource", session.discoverySource)
|
|
1039
1083
|
}
|
|
1040
1084
|
}
|
|
@@ -1093,8 +1137,8 @@ class AnsightReactNativeModule(
|
|
|
1093
1137
|
putMap("hostConnection", mapOf(
|
|
1094
1138
|
"savedConfigKey" to options.hostConnection.savedConfigKey,
|
|
1095
1139
|
"hasBundledConfigJson" to (options.hostConnection.bundledConfigJson != null),
|
|
1096
|
-
"hasBundledDeveloperConfigJson" to (options.hostConnection.bundledDeveloperConfigJson != null),
|
|
1097
1140
|
"discoveryPort" to options.hostConnection.discoveryPort,
|
|
1141
|
+
"allowCellularConnections" to options.hostConnection.allowCellularConnections,
|
|
1098
1142
|
"connectionProfileRetentionSeconds" to options.hostConnection.connectionProfileRetentionSeconds,
|
|
1099
1143
|
).toWritableMap())
|
|
1100
1144
|
putMap("secureStorage", mapOf(
|
package/index.d.ts
CHANGED
|
@@ -104,9 +104,6 @@ export interface AnsightOptions {
|
|
|
104
104
|
* `hostAutoProbe`, and `hostConnection` explicitly for the workflow.
|
|
105
105
|
*/
|
|
106
106
|
useNativeAllInOneDefaults?: boolean;
|
|
107
|
-
pairingConfig?: string | object;
|
|
108
|
-
bundledPairingConfig?: string | object;
|
|
109
|
-
pairingConfigJson?: string;
|
|
110
107
|
clientName?: string;
|
|
111
108
|
sampleFrequencyMilliseconds?: number;
|
|
112
109
|
retentionPeriodSeconds?: number;
|
|
@@ -141,8 +138,8 @@ export interface AnsightOptions {
|
|
|
141
138
|
hostConnection?: {
|
|
142
139
|
savedConfigKey?: string;
|
|
143
140
|
bundledConfigJson?: string;
|
|
144
|
-
bundledDeveloperConfigJson?: string;
|
|
145
141
|
discoveryPort?: number;
|
|
142
|
+
allowCellularConnections?: boolean;
|
|
146
143
|
connectionProfileRetentionSeconds?: number;
|
|
147
144
|
};
|
|
148
145
|
secureStorage?: {
|
|
@@ -208,7 +205,6 @@ export interface AnsightHostConnectionResult extends AnsightOperationResult {
|
|
|
208
205
|
configId?: string;
|
|
209
206
|
appId?: string;
|
|
210
207
|
resolvedHostAddress?: string;
|
|
211
|
-
usedEmbeddedDeveloperPairing?: boolean;
|
|
212
208
|
discoverySource?: string;
|
|
213
209
|
hostId?: string;
|
|
214
210
|
hostName?: string;
|
|
@@ -289,10 +285,10 @@ export class AnsightOptionsBuilder {
|
|
|
289
285
|
) => NonNullable<AnsightOptions["hostConnection"]> | void
|
|
290
286
|
): this;
|
|
291
287
|
withBundledHostConnection(options?: {
|
|
292
|
-
bundledDeveloperConfigJson?: string;
|
|
293
288
|
bundledConfigJson?: string;
|
|
294
289
|
}): this;
|
|
295
290
|
withHostConnectionDiscoveryPort(discoveryPort: number): this;
|
|
291
|
+
withCellularHostConnections(allow?: boolean): this;
|
|
296
292
|
withHostConnectionProfileRetentionSeconds(connectionProfileRetentionSeconds: number): this;
|
|
297
293
|
withSecureStorage(secureStorage?: NonNullable<AnsightOptions["secureStorage"]>): this;
|
|
298
294
|
withRemoteTools(remoteTools?: AnsightRemoteToolsOptions): this;
|
|
@@ -473,6 +469,10 @@ export interface AnsightConnectOptions {
|
|
|
473
469
|
hostAddressOverride?: string;
|
|
474
470
|
}
|
|
475
471
|
|
|
472
|
+
export interface AnsightScanPairingOptions extends AnsightConnectOptions {
|
|
473
|
+
title?: string;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
476
|
export interface AnsightOpenSessionOptions extends AnsightConnectOptions {}
|
|
477
477
|
|
|
478
478
|
export interface AnsightSavePairingOptions {
|
|
@@ -514,6 +514,9 @@ export function screenViewed(name: string, details?: Record<string, string>): Pr
|
|
|
514
514
|
export function trackRoute(name: string, details?: Record<string, string>): Promise<AnsightDebugSnapshot>;
|
|
515
515
|
export function setAppLifecycleState(state: AnsightLifecycleState): Promise<AnsightDebugSnapshot>;
|
|
516
516
|
export function connect(pairingPayload?: string | object | null, options?: AnsightConnectOptions): Promise<AnsightHostConnectionResult>;
|
|
517
|
+
/** Scans a one-use Studio invite, registers this installation, and saves automatic reconnect state. */
|
|
518
|
+
export function enrollFromQrCode(options?: AnsightScanPairingOptions): Promise<AnsightHostConnectionResult>;
|
|
519
|
+
export function scanPairingQrCode(options?: AnsightScanPairingOptions): Promise<AnsightHostConnectionResult>;
|
|
517
520
|
export function openSession(pairingPayload: string | object, options?: AnsightOpenSessionOptions): Promise<AnsightHostConnectionResult>;
|
|
518
521
|
export function disconnect(): Promise<AnsightHostConnectionResult>;
|
|
519
522
|
export function completeSession(): Promise<AnsightOperationResult>;
|
|
@@ -584,6 +587,8 @@ declare const Ansight: {
|
|
|
584
587
|
trackRoute: typeof trackRoute;
|
|
585
588
|
setAppLifecycleState: typeof setAppLifecycleState;
|
|
586
589
|
connect: typeof connect;
|
|
590
|
+
enrollFromQrCode: typeof enrollFromQrCode;
|
|
591
|
+
scanPairingQrCode: typeof scanPairingQrCode;
|
|
587
592
|
openSession: typeof openSession;
|
|
588
593
|
disconnect: typeof disconnect;
|
|
589
594
|
completeSession: typeof completeSession;
|
package/index.js
CHANGED
|
@@ -35,16 +35,7 @@ function normalizePairingPayload(payload) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function normalizeOptions(options = {}) {
|
|
38
|
-
|
|
39
|
-
if (normalized.pairingConfig != null) {
|
|
40
|
-
normalized.pairingConfigJson = normalizePairingPayload(normalized.pairingConfig);
|
|
41
|
-
delete normalized.pairingConfig;
|
|
42
|
-
}
|
|
43
|
-
if (normalized.bundledPairingConfig != null) {
|
|
44
|
-
normalized.pairingConfigJson = normalizePairingPayload(normalized.bundledPairingConfig);
|
|
45
|
-
delete normalized.bundledPairingConfig;
|
|
46
|
-
}
|
|
47
|
-
return normalized;
|
|
38
|
+
return { ...options };
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
function cloneOptions(options = {}) {
|
|
@@ -383,10 +374,9 @@ class AnsightOptionsBuilder {
|
|
|
383
374
|
return this;
|
|
384
375
|
}
|
|
385
376
|
|
|
386
|
-
withBundledHostConnection({
|
|
377
|
+
withBundledHostConnection({ bundledConfigJson = undefined } = {}) {
|
|
387
378
|
return this.configureHostConnection((hostConnection) => ({
|
|
388
379
|
...hostConnection,
|
|
389
|
-
bundledDeveloperConfigJson,
|
|
390
380
|
bundledConfigJson,
|
|
391
381
|
}));
|
|
392
382
|
}
|
|
@@ -398,6 +388,13 @@ class AnsightOptionsBuilder {
|
|
|
398
388
|
}));
|
|
399
389
|
}
|
|
400
390
|
|
|
391
|
+
withCellularHostConnections(allow = true) {
|
|
392
|
+
return this.configureHostConnection((hostConnection) => ({
|
|
393
|
+
...hostConnection,
|
|
394
|
+
allowCellularConnections: allow,
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
|
|
401
398
|
withHostConnectionProfileRetentionSeconds(connectionProfileRetentionSeconds) {
|
|
402
399
|
return this.configureHostConnection((hostConnection) => ({
|
|
403
400
|
...hostConnection,
|
|
@@ -2174,6 +2171,14 @@ function connect(pairingPayload, options = {}) {
|
|
|
2174
2171
|
return notifyAfterHostConnectionChange(() => nativeModule.connect(normalizePairingPayload(pairingPayload), options));
|
|
2175
2172
|
}
|
|
2176
2173
|
|
|
2174
|
+
function scanPairingQrCode(options = {}) {
|
|
2175
|
+
return notifyAfterHostConnectionChange(() => nativeModule.scanPairingQrCode(options));
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
function enrollFromQrCode(options = {}) {
|
|
2179
|
+
return scanPairingQrCode(options);
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2177
2182
|
function openSession(pairingPayload, options = {}) {
|
|
2178
2183
|
return notifyAfterHostConnectionChange(() => nativeModule.openSession(normalizePairingPayload(pairingPayload), options));
|
|
2179
2184
|
}
|
|
@@ -2231,6 +2236,8 @@ const Ansight = {
|
|
|
2231
2236
|
trackRoute,
|
|
2232
2237
|
setAppLifecycleState: (state) => nativeModule.setAppLifecycleState(state),
|
|
2233
2238
|
connect,
|
|
2239
|
+
enrollFromQrCode,
|
|
2240
|
+
scanPairingQrCode,
|
|
2234
2241
|
openSession,
|
|
2235
2242
|
disconnect: () => notifyAfterHostConnectionChange(() => nativeModule.disconnect()),
|
|
2236
2243
|
completeSession: () => notifyAfterHostConnectionChange(() => nativeModule.completeSession()),
|
|
@@ -2295,6 +2302,8 @@ module.exports.default = Ansight;
|
|
|
2295
2302
|
module.exports.AnsightOptionsBuilder = AnsightOptionsBuilder;
|
|
2296
2303
|
module.exports.createOptionsBuilder = createOptionsBuilder;
|
|
2297
2304
|
module.exports.notifyHostConnectionConfigChanged = Ansight.notifyHostConnectionConfigChanged;
|
|
2305
|
+
module.exports.enrollFromQrCode = Ansight.enrollFromQrCode;
|
|
2306
|
+
module.exports.scanPairingQrCode = Ansight.scanPairingQrCode;
|
|
2298
2307
|
module.exports.addHostConnectionStatusListener = addHostConnectionStatusListener;
|
|
2299
2308
|
module.exports.addLogListener = addLogListener;
|
|
2300
2309
|
module.exports.registerArtifactProvider = registerArtifactProvider;
|
|
@@ -350,6 +350,24 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
@objc(scanPairingQrCode:resolver:rejecter:)
|
|
354
|
+
func scanPairingQrCode(
|
|
355
|
+
_ options: NSDictionary?,
|
|
356
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
357
|
+
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
358
|
+
) {
|
|
359
|
+
Task {
|
|
360
|
+
let request = HostConnectionRequest.qrCode(
|
|
361
|
+
title: stringValue(options, "title") ?? "Scan Ansight Enrollment QR",
|
|
362
|
+
clientName: stringValue(options, "clientName"),
|
|
363
|
+
expectedAppId: stringValue(options, "expectedAppId"),
|
|
364
|
+
hostAddressOverride: stringValue(options, "hostAddressOverride"),
|
|
365
|
+
sourceDescription: "React Native native QR scanner"
|
|
366
|
+
)
|
|
367
|
+
resolve(hostConnectionResultDictionary(await AnsightRuntime.shared.connect(request)))
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
353
371
|
@objc(openSession:options:resolver:rejecter:)
|
|
354
372
|
func openSession(
|
|
355
373
|
_ pairingPayload: NSString?,
|
|
@@ -411,7 +429,7 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
411
429
|
AnsightRuntime.shared.clearSavedPairing()
|
|
412
430
|
resolve(hostConnectionResultDictionary(HostConnectionResult(
|
|
413
431
|
success: true,
|
|
414
|
-
message: "Saved
|
|
432
|
+
message: "Saved registration cleared.",
|
|
415
433
|
kind: .savedConfig,
|
|
416
434
|
source: .savedConfig
|
|
417
435
|
)))
|
|
@@ -859,13 +877,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
859
877
|
let useNativeAllInOneDefaults = boolValue(dictionary, "useNativeAllInOneDefaults", defaultValue: false)
|
|
860
878
|
var options = useNativeAllInOneDefaults ? AnsightOptions.ansightDeveloperDefaults : AnsightOptions()
|
|
861
879
|
|
|
862
|
-
if let value = stringValue(dictionary, "pairingConfigJson") {
|
|
863
|
-
if useNativeAllInOneDefaults {
|
|
864
|
-
options.hostConnection.bundledDeveloperConfigJson = value
|
|
865
|
-
} else {
|
|
866
|
-
options.hostConnection.bundledConfigJson = value
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
880
|
if useNativeAllInOneDefaults && stringValue(dictionary, "toolGuard") == nil {
|
|
870
881
|
options.toolGuard = .readOnly
|
|
871
882
|
}
|
|
@@ -978,7 +989,11 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
978
989
|
savedConfigKey: stringValue(host, "savedConfigKey") ?? options.hostConnection.savedConfigKey,
|
|
979
990
|
connectionProfileRetentionSeconds: intValue(host, "connectionProfileRetentionSeconds", defaultValue: options.hostConnection.connectionProfileRetentionSeconds),
|
|
980
991
|
discoveryPort: optionalInt(host, "discoveryPort") ?? options.hostConnection.discoveryPort,
|
|
981
|
-
|
|
992
|
+
allowCellularConnections: boolValue(
|
|
993
|
+
host,
|
|
994
|
+
"allowCellularConnections",
|
|
995
|
+
defaultValue: options.hostConnection.allowCellularConnections
|
|
996
|
+
),
|
|
982
997
|
bundledConfigJson: stringValue(host, "bundledConfigJson") ?? options.hostConnection.bundledConfigJson
|
|
983
998
|
)
|
|
984
999
|
}
|
|
@@ -1087,7 +1102,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1087
1102
|
"executableTools": snapshot.executableTools,
|
|
1088
1103
|
"toolDiscoveryEnabled": snapshot.toolDiscoveryEnabled,
|
|
1089
1104
|
"toolExecutionEnabled": snapshot.toolExecutionEnabled,
|
|
1090
|
-
"embeddedDeveloperPairingAvailable": snapshot.embeddedDeveloperPairingAvailable,
|
|
1091
1105
|
"detectedBundledTools": snapshot.detectedBundledTools,
|
|
1092
1106
|
"touchesRecorded": snapshot.touchesCaptured,
|
|
1093
1107
|
"touchesCaptured": snapshot.touchesCaptured,
|
|
@@ -1172,7 +1186,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1172
1186
|
}
|
|
1173
1187
|
if let session = result.openSession {
|
|
1174
1188
|
dictionary["accepted"] = session.accepted
|
|
1175
|
-
dictionary["usedEmbeddedDeveloperPairing"] = session.usedEmbeddedDeveloperPairing
|
|
1176
1189
|
if let value = session.sessionId {
|
|
1177
1190
|
dictionary["sessionId"] = value
|
|
1178
1191
|
}
|
|
@@ -1203,7 +1216,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1203
1216
|
"success": result.success,
|
|
1204
1217
|
"message": result.message,
|
|
1205
1218
|
"accepted": result.accepted,
|
|
1206
|
-
"usedEmbeddedDeveloperPairing": result.usedEmbeddedDeveloperPairing,
|
|
1207
1219
|
]
|
|
1208
1220
|
if let value = result.sessionId {
|
|
1209
1221
|
dictionary["sessionId"] = value
|
|
@@ -1294,7 +1306,7 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1294
1306
|
"savedConfigKey": options.hostConnection.savedConfigKey,
|
|
1295
1307
|
"connectionProfileRetentionSeconds": options.hostConnection.connectionProfileRetentionSeconds,
|
|
1296
1308
|
"discoveryPort": options.hostConnection.discoveryPort as Any,
|
|
1297
|
-
"
|
|
1309
|
+
"allowCellularConnections": options.hostConnection.allowCellularConnections,
|
|
1298
1310
|
"hasBundledConfigJson": options.hostConnection.bundledConfigJson != nil,
|
|
1299
1311
|
],
|
|
1300
1312
|
]
|
|
@@ -47,6 +47,10 @@ RCT_EXTERN_METHOD(connect:(NSString *)pairingPayload
|
|
|
47
47
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
48
48
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
49
49
|
|
|
50
|
+
RCT_EXTERN_METHOD(scanPairingQrCode:(NSDictionary *)options
|
|
51
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
52
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
53
|
+
|
|
50
54
|
RCT_EXTERN_METHOD(openSession:(NSString *)pairingPayload
|
|
51
55
|
options:(NSDictionary *)options
|
|
52
56
|
resolver:(RCTPromiseResolveBlock)resolve
|