@ansight/react-native 1.0.2-preview.8 → 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 +26 -40
- package/android/build.gradle +3 -1
- package/android/src/main/kotlin/ai/ansight/reactnative/AnsightReactNativeModule.kt +52 -13
- package/index.d.ts +9 -6
- package/index.js +14 -12
- package/ios/AnsightReactNative.swift +19 -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,14 +93,14 @@ 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
|
|
|
115
101
|
Cellular host connections are disabled by default. The restriction applies to
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
enrollment and reconnect requests. Opt in only for a trusted development host
|
|
103
|
+
or personal hotspot:
|
|
118
104
|
|
|
119
105
|
```ts
|
|
120
106
|
const options = Ansight.createOptionsBuilder()
|
|
@@ -124,7 +110,7 @@ const options = Ansight.createOptionsBuilder()
|
|
|
124
110
|
|
|
125
111
|
You can also set `hostConnection.allowCellularConnections: true` directly.
|
|
126
112
|
This may consume mobile data and permits connection attempts over a broader or
|
|
127
|
-
carrier-managed network;
|
|
113
|
+
carrier-managed network; use it only with a trusted development host.
|
|
128
114
|
|
|
129
115
|
Example:
|
|
130
116
|
|
|
@@ -206,36 +192,36 @@ compatibility alias for `remoteTools.secureStorage`.
|
|
|
206
192
|
|
|
207
193
|
## Host Connection
|
|
208
194
|
|
|
209
|
-
|
|
195
|
+
No connection call is needed for a simulator or emulator. On a physical
|
|
196
|
+
device, scan the QR displayed by Studio once:
|
|
210
197
|
|
|
211
198
|
```ts
|
|
212
|
-
await Ansight.
|
|
199
|
+
await Ansight.enrollFromQrCode({
|
|
213
200
|
clientName: "My React Native App",
|
|
214
201
|
expectedAppId: "com.example.app",
|
|
215
202
|
});
|
|
216
203
|
```
|
|
217
204
|
|
|
218
|
-
|
|
205
|
+
After physical-device enrollment, `connect(null, options)` and the runtime
|
|
206
|
+
connection loop use the remembered registration:
|
|
219
207
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
4. `hostConnection.bundledConfigJson`
|
|
208
|
+
```ts
|
|
209
|
+
await Ansight.connect(null, { clientName: "My React Native App" });
|
|
210
|
+
```
|
|
224
211
|
|
|
225
|
-
|
|
212
|
+
When Studio is closed or signed out, automatic attempts remain dormant and
|
|
213
|
+
retry later without failing the React Native app.
|
|
214
|
+
|
|
215
|
+
If the app already owns a scanner, pass its result through the explicit payload
|
|
216
|
+
API:
|
|
226
217
|
|
|
227
218
|
```ts
|
|
228
|
-
await Ansight.connect(
|
|
219
|
+
await Ansight.connect(enrollmentPayload, {
|
|
229
220
|
clientName: "My React Native App",
|
|
230
221
|
expectedAppId: "com.example.app",
|
|
231
222
|
hostAddressOverride: "192.168.1.20",
|
|
232
223
|
});
|
|
233
224
|
|
|
234
|
-
await Ansight.savePairingConfig(pairingJson, {
|
|
235
|
-
expectedAppId: "com.example.app",
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
await Ansight.clearSavedPairing();
|
|
239
225
|
await Ansight.clearCachedSession();
|
|
240
226
|
await Ansight.disconnect();
|
|
241
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,7 +790,6 @@ 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,
|
|
752
794
|
allowCellularConnections = host.booleanValue(
|
|
753
795
|
"allowCellularConnections",
|
|
@@ -1018,7 +1060,6 @@ class AnsightReactNativeModule(
|
|
|
1018
1060
|
putString("configId", result.configId)
|
|
1019
1061
|
putString("appId", result.appId)
|
|
1020
1062
|
putString("resolvedHostAddress", result.resolvedHostAddress)
|
|
1021
|
-
putBoolean("usedEmbeddedDeveloperPairing", result.usedEmbeddedDeveloperPairing)
|
|
1022
1063
|
putString("discoverySource", result.discoverySource)
|
|
1023
1064
|
putString("reasonCode", result.reasonCode)
|
|
1024
1065
|
putString("hostId", result.hostId)
|
|
@@ -1038,7 +1079,6 @@ class AnsightReactNativeModule(
|
|
|
1038
1079
|
putString("hostId", session.hostId)
|
|
1039
1080
|
putString("hostName", session.hostName)
|
|
1040
1081
|
putBoolean("accepted", session.accepted)
|
|
1041
|
-
putBoolean("usedEmbeddedDeveloperPairing", session.usedEmbeddedDeveloperPairing)
|
|
1042
1082
|
putString("discoverySource", session.discoverySource)
|
|
1043
1083
|
}
|
|
1044
1084
|
}
|
|
@@ -1097,7 +1137,6 @@ class AnsightReactNativeModule(
|
|
|
1097
1137
|
putMap("hostConnection", mapOf(
|
|
1098
1138
|
"savedConfigKey" to options.hostConnection.savedConfigKey,
|
|
1099
1139
|
"hasBundledConfigJson" to (options.hostConnection.bundledConfigJson != null),
|
|
1100
|
-
"hasBundledDeveloperConfigJson" to (options.hostConnection.bundledDeveloperConfigJson != null),
|
|
1101
1140
|
"discoveryPort" to options.hostConnection.discoveryPort,
|
|
1102
1141
|
"allowCellularConnections" to options.hostConnection.allowCellularConnections,
|
|
1103
1142
|
"connectionProfileRetentionSeconds" to options.hostConnection.connectionProfileRetentionSeconds,
|
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,7 +138,6 @@ export interface AnsightOptions {
|
|
|
141
138
|
hostConnection?: {
|
|
142
139
|
savedConfigKey?: string;
|
|
143
140
|
bundledConfigJson?: string;
|
|
144
|
-
bundledDeveloperConfigJson?: string;
|
|
145
141
|
discoveryPort?: number;
|
|
146
142
|
allowCellularConnections?: boolean;
|
|
147
143
|
connectionProfileRetentionSeconds?: number;
|
|
@@ -209,7 +205,6 @@ export interface AnsightHostConnectionResult extends AnsightOperationResult {
|
|
|
209
205
|
configId?: string;
|
|
210
206
|
appId?: string;
|
|
211
207
|
resolvedHostAddress?: string;
|
|
212
|
-
usedEmbeddedDeveloperPairing?: boolean;
|
|
213
208
|
discoverySource?: string;
|
|
214
209
|
hostId?: string;
|
|
215
210
|
hostName?: string;
|
|
@@ -290,7 +285,6 @@ export class AnsightOptionsBuilder {
|
|
|
290
285
|
) => NonNullable<AnsightOptions["hostConnection"]> | void
|
|
291
286
|
): this;
|
|
292
287
|
withBundledHostConnection(options?: {
|
|
293
|
-
bundledDeveloperConfigJson?: string;
|
|
294
288
|
bundledConfigJson?: string;
|
|
295
289
|
}): this;
|
|
296
290
|
withHostConnectionDiscoveryPort(discoveryPort: number): this;
|
|
@@ -475,6 +469,10 @@ export interface AnsightConnectOptions {
|
|
|
475
469
|
hostAddressOverride?: string;
|
|
476
470
|
}
|
|
477
471
|
|
|
472
|
+
export interface AnsightScanPairingOptions extends AnsightConnectOptions {
|
|
473
|
+
title?: string;
|
|
474
|
+
}
|
|
475
|
+
|
|
478
476
|
export interface AnsightOpenSessionOptions extends AnsightConnectOptions {}
|
|
479
477
|
|
|
480
478
|
export interface AnsightSavePairingOptions {
|
|
@@ -516,6 +514,9 @@ export function screenViewed(name: string, details?: Record<string, string>): Pr
|
|
|
516
514
|
export function trackRoute(name: string, details?: Record<string, string>): Promise<AnsightDebugSnapshot>;
|
|
517
515
|
export function setAppLifecycleState(state: AnsightLifecycleState): Promise<AnsightDebugSnapshot>;
|
|
518
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>;
|
|
519
520
|
export function openSession(pairingPayload: string | object, options?: AnsightOpenSessionOptions): Promise<AnsightHostConnectionResult>;
|
|
520
521
|
export function disconnect(): Promise<AnsightHostConnectionResult>;
|
|
521
522
|
export function completeSession(): Promise<AnsightOperationResult>;
|
|
@@ -586,6 +587,8 @@ declare const Ansight: {
|
|
|
586
587
|
trackRoute: typeof trackRoute;
|
|
587
588
|
setAppLifecycleState: typeof setAppLifecycleState;
|
|
588
589
|
connect: typeof connect;
|
|
590
|
+
enrollFromQrCode: typeof enrollFromQrCode;
|
|
591
|
+
scanPairingQrCode: typeof scanPairingQrCode;
|
|
589
592
|
openSession: typeof openSession;
|
|
590
593
|
disconnect: typeof disconnect;
|
|
591
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
|
}
|
|
@@ -2181,6 +2171,14 @@ function connect(pairingPayload, options = {}) {
|
|
|
2181
2171
|
return notifyAfterHostConnectionChange(() => nativeModule.connect(normalizePairingPayload(pairingPayload), options));
|
|
2182
2172
|
}
|
|
2183
2173
|
|
|
2174
|
+
function scanPairingQrCode(options = {}) {
|
|
2175
|
+
return notifyAfterHostConnectionChange(() => nativeModule.scanPairingQrCode(options));
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
function enrollFromQrCode(options = {}) {
|
|
2179
|
+
return scanPairingQrCode(options);
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2184
2182
|
function openSession(pairingPayload, options = {}) {
|
|
2185
2183
|
return notifyAfterHostConnectionChange(() => nativeModule.openSession(normalizePairingPayload(pairingPayload), options));
|
|
2186
2184
|
}
|
|
@@ -2238,6 +2236,8 @@ const Ansight = {
|
|
|
2238
2236
|
trackRoute,
|
|
2239
2237
|
setAppLifecycleState: (state) => nativeModule.setAppLifecycleState(state),
|
|
2240
2238
|
connect,
|
|
2239
|
+
enrollFromQrCode,
|
|
2240
|
+
scanPairingQrCode,
|
|
2241
2241
|
openSession,
|
|
2242
2242
|
disconnect: () => notifyAfterHostConnectionChange(() => nativeModule.disconnect()),
|
|
2243
2243
|
completeSession: () => notifyAfterHostConnectionChange(() => nativeModule.completeSession()),
|
|
@@ -2302,6 +2302,8 @@ module.exports.default = Ansight;
|
|
|
2302
2302
|
module.exports.AnsightOptionsBuilder = AnsightOptionsBuilder;
|
|
2303
2303
|
module.exports.createOptionsBuilder = createOptionsBuilder;
|
|
2304
2304
|
module.exports.notifyHostConnectionConfigChanged = Ansight.notifyHostConnectionConfigChanged;
|
|
2305
|
+
module.exports.enrollFromQrCode = Ansight.enrollFromQrCode;
|
|
2306
|
+
module.exports.scanPairingQrCode = Ansight.scanPairingQrCode;
|
|
2305
2307
|
module.exports.addHostConnectionStatusListener = addHostConnectionStatusListener;
|
|
2306
2308
|
module.exports.addLogListener = addLogListener;
|
|
2307
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
|
}
|
|
@@ -983,7 +994,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
983
994
|
"allowCellularConnections",
|
|
984
995
|
defaultValue: options.hostConnection.allowCellularConnections
|
|
985
996
|
),
|
|
986
|
-
bundledDeveloperConfigJson: stringValue(host, "bundledDeveloperConfigJson") ?? options.hostConnection.bundledDeveloperConfigJson,
|
|
987
997
|
bundledConfigJson: stringValue(host, "bundledConfigJson") ?? options.hostConnection.bundledConfigJson
|
|
988
998
|
)
|
|
989
999
|
}
|
|
@@ -1092,7 +1102,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1092
1102
|
"executableTools": snapshot.executableTools,
|
|
1093
1103
|
"toolDiscoveryEnabled": snapshot.toolDiscoveryEnabled,
|
|
1094
1104
|
"toolExecutionEnabled": snapshot.toolExecutionEnabled,
|
|
1095
|
-
"embeddedDeveloperPairingAvailable": snapshot.embeddedDeveloperPairingAvailable,
|
|
1096
1105
|
"detectedBundledTools": snapshot.detectedBundledTools,
|
|
1097
1106
|
"touchesRecorded": snapshot.touchesCaptured,
|
|
1098
1107
|
"touchesCaptured": snapshot.touchesCaptured,
|
|
@@ -1177,7 +1186,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1177
1186
|
}
|
|
1178
1187
|
if let session = result.openSession {
|
|
1179
1188
|
dictionary["accepted"] = session.accepted
|
|
1180
|
-
dictionary["usedEmbeddedDeveloperPairing"] = session.usedEmbeddedDeveloperPairing
|
|
1181
1189
|
if let value = session.sessionId {
|
|
1182
1190
|
dictionary["sessionId"] = value
|
|
1183
1191
|
}
|
|
@@ -1208,7 +1216,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1208
1216
|
"success": result.success,
|
|
1209
1217
|
"message": result.message,
|
|
1210
1218
|
"accepted": result.accepted,
|
|
1211
|
-
"usedEmbeddedDeveloperPairing": result.usedEmbeddedDeveloperPairing,
|
|
1212
1219
|
]
|
|
1213
1220
|
if let value = result.sessionId {
|
|
1214
1221
|
dictionary["sessionId"] = value
|
|
@@ -1300,7 +1307,6 @@ final class AnsightReactNative: RCTEventEmitter {
|
|
|
1300
1307
|
"connectionProfileRetentionSeconds": options.hostConnection.connectionProfileRetentionSeconds,
|
|
1301
1308
|
"discoveryPort": options.hostConnection.discoveryPort as Any,
|
|
1302
1309
|
"allowCellularConnections": options.hostConnection.allowCellularConnections,
|
|
1303
|
-
"hasBundledDeveloperConfigJson": options.hostConnection.bundledDeveloperConfigJson != nil,
|
|
1304
1310
|
"hasBundledConfigJson": options.hostConnection.bundledConfigJson != nil,
|
|
1305
1311
|
],
|
|
1306
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
|