react-native-debug-toolkit 3.2.3 → 3.2.4
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/android/src/main/java/com/reactnativedebugtoolkit/DebugToolkitDevConnectModule.java +43 -8
- package/ios/DebugToolkitDevConnect.mm +54 -1
- package/lib/commonjs/core/initialize.js +15 -3
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/features/devConnect/DevConnectTab.js +30 -47
- package/lib/commonjs/features/devConnect/DevConnectTab.js.map +1 -1
- package/lib/commonjs/features/devConnect/devConnectUtils.js +8 -0
- package/lib/commonjs/features/devConnect/devConnectUtils.js.map +1 -1
- package/lib/commonjs/features/devConnect/index.js +22 -3
- package/lib/commonjs/features/devConnect/index.js.map +1 -1
- package/lib/commonjs/features/devConnect/nativeDevConnect.js +26 -0
- package/lib/commonjs/features/devConnect/nativeDevConnect.js.map +1 -1
- package/lib/commonjs/ui/DebugView.js +10 -2
- package/lib/commonjs/ui/DebugView.js.map +1 -1
- package/lib/commonjs/utils/DaemonClient.js +5 -0
- package/lib/commonjs/utils/DaemonClient.js.map +1 -1
- package/lib/module/core/initialize.js +16 -4
- package/lib/module/core/initialize.js.map +1 -1
- package/lib/module/features/devConnect/DevConnectTab.js +30 -47
- package/lib/module/features/devConnect/DevConnectTab.js.map +1 -1
- package/lib/module/features/devConnect/devConnectUtils.js +7 -0
- package/lib/module/features/devConnect/devConnectUtils.js.map +1 -1
- package/lib/module/features/devConnect/index.js +19 -5
- package/lib/module/features/devConnect/index.js.map +1 -1
- package/lib/module/features/devConnect/nativeDevConnect.js +24 -0
- package/lib/module/features/devConnect/nativeDevConnect.js.map +1 -1
- package/lib/module/ui/DebugView.js +11 -3
- package/lib/module/ui/DebugView.js.map +1 -1
- package/lib/module/utils/DaemonClient.js +5 -0
- package/lib/module/utils/DaemonClient.js.map +1 -1
- package/lib/typescript/src/core/initialize.d.ts +4 -2
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts +1 -0
- package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/index.d.ts +1 -0
- package/lib/typescript/src/features/devConnect/index.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts +2 -0
- package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts.map +1 -1
- package/lib/typescript/src/features/devConnect/types.d.ts +1 -1
- package/lib/typescript/src/features/devConnect/types.d.ts.map +1 -1
- package/lib/typescript/src/ui/DebugView.d.ts.map +1 -1
- package/lib/typescript/src/utils/DaemonClient.d.ts +2 -0
- package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -1
- package/package.json +2 -10
- package/src/core/initialize.ts +17 -5
- package/src/features/devConnect/DevConnectTab.tsx +18 -34
- package/src/features/devConnect/devConnectUtils.ts +8 -0
- package/src/features/devConnect/index.ts +18 -5
- package/src/features/devConnect/nativeDevConnect.ts +28 -0
- package/src/features/devConnect/types.ts +1 -1
- package/src/ui/DebugView.tsx +12 -3
- package/src/utils/DaemonClient.ts +7 -0
- package/lib/commonjs/features/devConnect/DevConnectQrScanner.js +0 -248
- package/lib/commonjs/features/devConnect/DevConnectQrScanner.js.map +0 -1
- package/lib/commonjs/features/devConnect/cameraKit.js +0 -54
- package/lib/commonjs/features/devConnect/cameraKit.js.map +0 -1
- package/lib/module/features/devConnect/DevConnectQrScanner.js +0 -243
- package/lib/module/features/devConnect/DevConnectQrScanner.js.map +0 -1
- package/lib/module/features/devConnect/cameraKit.js +0 -49
- package/lib/module/features/devConnect/cameraKit.js.map +0 -1
- package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts +0 -10
- package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts.map +0 -1
- package/lib/typescript/src/features/devConnect/cameraKit.d.ts +0 -47
- package/lib/typescript/src/features/devConnect/cameraKit.d.ts.map +0 -1
- package/src/features/devConnect/DevConnectQrScanner.tsx +0 -214
- package/src/features/devConnect/cameraKit.ts +0 -93
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
normalizeComputerHost,
|
|
29
29
|
normalizePort,
|
|
30
30
|
parseComputerTarget,
|
|
31
|
-
type ParsedComputerTarget,
|
|
32
31
|
} from './devConnectUtils';
|
|
33
32
|
import {
|
|
34
33
|
saveComputerTarget,
|
|
@@ -37,7 +36,6 @@ import {
|
|
|
37
36
|
} from './devConnectPreferences';
|
|
38
37
|
import { applyMetroBundle, resetMetroBundle } from './nativeDevConnect';
|
|
39
38
|
import type { DevConnectState } from './types';
|
|
40
|
-
import { DevConnectQrScanner } from './DevConnectQrScanner';
|
|
41
39
|
|
|
42
40
|
const CONNECTION_TIMEOUT_MS = 2000;
|
|
43
41
|
|
|
@@ -73,7 +71,6 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
73
71
|
const [message, setMessage] = useState<string | null>(null);
|
|
74
72
|
const [sending, setSending] = useState(false);
|
|
75
73
|
const [metroBusy, setMetroBusy] = useState(false);
|
|
76
|
-
const [qrVisible, setQrVisible] = useState(false);
|
|
77
74
|
|
|
78
75
|
const isSim = snapshot.isSimulator;
|
|
79
76
|
|
|
@@ -124,13 +121,6 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
124
121
|
setMessage(null);
|
|
125
122
|
}, []);
|
|
126
123
|
|
|
127
|
-
const handleQrTarget = useCallback((target: ParsedComputerTarget) => {
|
|
128
|
-
setComputerHost(target.computerHost);
|
|
129
|
-
setMetroPort(target.metroPort);
|
|
130
|
-
saveComputerTarget(`${target.computerHost}:${target.metroPort}`).catch(() => {});
|
|
131
|
-
setMessage('Computer IP updated from QR code.');
|
|
132
|
-
}, []);
|
|
133
|
-
|
|
134
124
|
const validateSettings = useCallback((): boolean => {
|
|
135
125
|
if (!isSim && !normalizeComputerHost(computerHost)) {
|
|
136
126
|
setMessage('Enter your computer IP first.');
|
|
@@ -294,6 +284,8 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
294
284
|
const canConnect = isSim || (Boolean(normalizeComputerHost(computerHost)) && Boolean(normalizePort(daemonPort)));
|
|
295
285
|
const canUseMetro = Boolean(metroTarget) && snapshot.nativeMetroAvailable && !metroBusy;
|
|
296
286
|
const busy = sending || syncState === 'checking';
|
|
287
|
+
const subnetPrefix = snapshot.subnetPrefix;
|
|
288
|
+
const ipPlaceholder = subnetPrefix ? `${subnetPrefix}...` : '192.168.1.10';
|
|
297
289
|
|
|
298
290
|
return (
|
|
299
291
|
<KeyboardAvoidingView style={styles.container} behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
|
@@ -312,7 +304,7 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
312
304
|
style={styles.input}
|
|
313
305
|
value={computerHost}
|
|
314
306
|
onChangeText={handleHostChange}
|
|
315
|
-
placeholder=
|
|
307
|
+
placeholder={ipPlaceholder}
|
|
316
308
|
placeholderTextColor={Colors.textLight}
|
|
317
309
|
autoCapitalize="none"
|
|
318
310
|
autoCorrect={false}
|
|
@@ -321,12 +313,19 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
321
313
|
onSubmitEditing={() => inputRef.current?.blur()}
|
|
322
314
|
editable={!streaming}
|
|
323
315
|
/>
|
|
324
|
-
{snapshot.qrAvailable ? (
|
|
325
|
-
<TouchableOpacity style={styles.scanButton} onPress={() => setQrVisible(true)} disabled={streaming} activeOpacity={0.7}>
|
|
326
|
-
<Text style={styles.scanButtonText}>Scan</Text>
|
|
327
|
-
</TouchableOpacity>
|
|
328
|
-
) : null}
|
|
329
316
|
</View>
|
|
317
|
+
{subnetPrefix && !computerHost ? (
|
|
318
|
+
<TouchableOpacity
|
|
319
|
+
style={styles.subnetHint}
|
|
320
|
+
onPress={() => {
|
|
321
|
+
setComputerHost(subnetPrefix);
|
|
322
|
+
inputRef.current?.focus();
|
|
323
|
+
}}
|
|
324
|
+
activeOpacity={0.6}
|
|
325
|
+
>
|
|
326
|
+
<Text style={styles.subnetHintText}>Tap to fill: {subnetPrefix}</Text>
|
|
327
|
+
</TouchableOpacity>
|
|
328
|
+
) : null}
|
|
330
329
|
</View>
|
|
331
330
|
)}
|
|
332
331
|
|
|
@@ -438,11 +437,6 @@ export function DevConnectTab({ snapshot }: DebugFeatureRenderProps<DevConnectSt
|
|
|
438
437
|
) : null}
|
|
439
438
|
</View>
|
|
440
439
|
</ScrollView>
|
|
441
|
-
<DevConnectQrScanner
|
|
442
|
-
visible={qrVisible}
|
|
443
|
-
onClose={() => setQrVisible(false)}
|
|
444
|
-
onScanTarget={handleQrTarget}
|
|
445
|
-
/>
|
|
446
440
|
</KeyboardAvoidingView>
|
|
447
441
|
);
|
|
448
442
|
}
|
|
@@ -464,7 +458,9 @@ const styles = StyleSheet.create({
|
|
|
464
458
|
sectionTitle: { fontSize: 14, fontWeight: '600', color: Colors.text, marginBottom: 4 },
|
|
465
459
|
sectionDesc: { fontSize: 12, color: Colors.textSecondary, marginBottom: 10, lineHeight: 17 },
|
|
466
460
|
label: { fontSize: 13, fontWeight: '500', color: Colors.textSecondary, marginBottom: 6 },
|
|
467
|
-
inputRow: { flexDirection: 'row', alignItems: 'center'
|
|
461
|
+
inputRow: { flexDirection: 'row', alignItems: 'center' },
|
|
462
|
+
subnetHint: { marginTop: 6 },
|
|
463
|
+
subnetHintText: { fontSize: 12, color: Colors.primary, fontWeight: '500' },
|
|
468
464
|
input: {
|
|
469
465
|
flex: 1,
|
|
470
466
|
backgroundColor: Colors.surface,
|
|
@@ -477,18 +473,6 @@ const styles = StyleSheet.create({
|
|
|
477
473
|
color: Colors.text,
|
|
478
474
|
fontFamily: 'Courier',
|
|
479
475
|
},
|
|
480
|
-
scanButton: {
|
|
481
|
-
minWidth: 62,
|
|
482
|
-
alignItems: 'center',
|
|
483
|
-
justifyContent: 'center',
|
|
484
|
-
paddingHorizontal: 12,
|
|
485
|
-
paddingVertical: 10,
|
|
486
|
-
borderRadius: 8,
|
|
487
|
-
backgroundColor: Colors.surface,
|
|
488
|
-
borderWidth: 1,
|
|
489
|
-
borderColor: Colors.primary,
|
|
490
|
-
},
|
|
491
|
-
scanButtonText: { color: Colors.primary, fontSize: 13, fontWeight: '600' },
|
|
492
476
|
portRow: { flexDirection: 'row', gap: 10 },
|
|
493
477
|
portField: { flex: 1 },
|
|
494
478
|
portLabel: { fontSize: 11, color: Colors.textSecondary, marginBottom: 4 },
|
|
@@ -164,3 +164,11 @@ export function buildDaemonDeviceHost(computerHost: string, daemonPort: string):
|
|
|
164
164
|
const port = normalizePort(daemonPort) ?? DEFAULT_DAEMON_PORT;
|
|
165
165
|
return port === DEFAULT_DAEMON_PORT ? host : `${host}:${port}`;
|
|
166
166
|
}
|
|
167
|
+
|
|
168
|
+
export function extractSubnetPrefix(ip: string): string | null {
|
|
169
|
+
if (!isValidIpv4(ip)) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const parts = ip.split('.');
|
|
173
|
+
return `${parts[0]}.${parts[1]}.${parts[2]}.`;
|
|
174
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { DevConnectTab } from './DevConnectTab';
|
|
2
|
-
import { isCameraKitAvailable } from './cameraKit';
|
|
3
2
|
import { loadDevConnectPreferences } from './devConnectPreferences';
|
|
4
|
-
import { DEFAULT_DAEMON_PORT, DEFAULT_METRO_PORT } from './devConnectUtils';
|
|
5
|
-
import { isNativeDevConnectAvailable } from './nativeDevConnect';
|
|
3
|
+
import { DEFAULT_DAEMON_PORT, DEFAULT_METRO_PORT, extractSubnetPrefix } from './devConnectUtils';
|
|
4
|
+
import { getDeviceLocalIp, isNativeDevConnectAvailable } from './nativeDevConnect';
|
|
6
5
|
import { isSimulator } from './platformDetect';
|
|
7
6
|
import { daemonClient } from '../../utils/DaemonClient';
|
|
8
7
|
import type { DebugFeature, DebugFeatureListener } from '../../types';
|
|
@@ -24,6 +23,7 @@ export {
|
|
|
24
23
|
saveDaemonPort,
|
|
25
24
|
saveMetroPort,
|
|
26
25
|
} from './devConnectPreferences';
|
|
26
|
+
export { nativeIsDebugBuild } from './nativeDevConnect';
|
|
27
27
|
|
|
28
28
|
export const createDevConnectFeature = (): DebugFeature<DevConnectState> => {
|
|
29
29
|
const listeners = new Set<DebugFeatureListener>();
|
|
@@ -32,7 +32,6 @@ export const createDevConnectFeature = (): DebugFeature<DevConnectState> => {
|
|
|
32
32
|
computerHost: '',
|
|
33
33
|
metroPort: DEFAULT_METRO_PORT,
|
|
34
34
|
daemonPort: DEFAULT_DAEMON_PORT,
|
|
35
|
-
qrAvailable: isCameraKitAvailable(),
|
|
36
35
|
nativeMetroAvailable: isNativeDevConnectAvailable(),
|
|
37
36
|
streaming: daemonClient.isConnected(),
|
|
38
37
|
};
|
|
@@ -50,7 +49,8 @@ export const createDevConnectFeature = (): DebugFeature<DevConnectState> => {
|
|
|
50
49
|
label: 'DevConnect',
|
|
51
50
|
renderContent: DevConnectTab,
|
|
52
51
|
setup() {
|
|
53
|
-
|
|
52
|
+
daemonClient.setOnConnectionChange(() => notify());
|
|
53
|
+
loadDevConnectPreferences().then(async (preferences) => {
|
|
54
54
|
state = {
|
|
55
55
|
...state,
|
|
56
56
|
computerHost: preferences.computerHost,
|
|
@@ -58,6 +58,19 @@ export const createDevConnectFeature = (): DebugFeature<DevConnectState> => {
|
|
|
58
58
|
daemonPort: preferences.daemonPort,
|
|
59
59
|
nativeMetroAvailable: isNativeDevConnectAvailable(),
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
if (!state.isSimulator) {
|
|
63
|
+
try {
|
|
64
|
+
const localIp = await getDeviceLocalIp();
|
|
65
|
+
if (localIp) {
|
|
66
|
+
const prefix = extractSubnetPrefix(localIp);
|
|
67
|
+
if (prefix) {
|
|
68
|
+
state = { ...state, subnetPrefix: prefix };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch { /* subnetPrefix stays undefined */ }
|
|
72
|
+
}
|
|
73
|
+
|
|
61
74
|
notify();
|
|
62
75
|
}).catch(() => {
|
|
63
76
|
notify();
|
|
@@ -6,6 +6,8 @@ interface DebugToolkitDevConnectNativeModule {
|
|
|
6
6
|
applyMetroHost: (hostPort: string) => Promise<{ hostPort?: string } | void>;
|
|
7
7
|
resetMetroHost: () => Promise<void>;
|
|
8
8
|
getMetroHost?: () => Promise<string | null>;
|
|
9
|
+
getLocalIp?: () => Promise<string | null>;
|
|
10
|
+
isDebugBuild?: () => Promise<boolean>;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
type MetroBundleFailureReason =
|
|
@@ -124,3 +126,29 @@ export async function resetMetroBundle(): Promise<MetroBundleResult | { ok: true
|
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
}
|
|
129
|
+
|
|
130
|
+
export async function getDeviceLocalIp(): Promise<string | null> {
|
|
131
|
+
const nativeModule = getNativeModule();
|
|
132
|
+
if (!nativeModule?.getLocalIp) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const ip = await nativeModule.getLocalIp();
|
|
137
|
+
return typeof ip === 'string' ? ip : null;
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function nativeIsDebugBuild(): Promise<boolean | null> {
|
|
144
|
+
const nativeModule = getNativeModule();
|
|
145
|
+
if (!nativeModule?.isDebugBuild) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const result = await nativeModule.isDebugBuild();
|
|
150
|
+
return typeof result === 'boolean' ? result : null;
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
package/src/ui/DebugView.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { DebugToolkitProvider } from '../core/DebugToolkitProvider';
|
|
3
3
|
import { initializeDebugToolkit } from '../core/initialize';
|
|
4
4
|
import type { FeatureConfigs } from '../core/initialize';
|
|
@@ -42,6 +42,8 @@ export function DebugView({
|
|
|
42
42
|
environments,
|
|
43
43
|
enabled,
|
|
44
44
|
}: DebugViewProps) {
|
|
45
|
+
const destroyRef = useRef<(() => void) | null>(null);
|
|
46
|
+
|
|
45
47
|
useEffect(() => {
|
|
46
48
|
// Build feature config: all enabled by default, user overrides take precedence
|
|
47
49
|
const resolvedFeatures: FeatureConfigs = {
|
|
@@ -61,13 +63,20 @@ export function DebugView({
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
// Initialize toolkit
|
|
64
|
-
|
|
66
|
+
let cancelled = false;
|
|
67
|
+
initializeDebugToolkit({
|
|
65
68
|
features: resolvedFeatures,
|
|
66
69
|
enabled,
|
|
70
|
+
}).then((toolkit) => {
|
|
71
|
+
if (!cancelled) {
|
|
72
|
+
destroyRef.current = () => toolkit.destroy();
|
|
73
|
+
}
|
|
67
74
|
});
|
|
68
75
|
|
|
69
76
|
return () => {
|
|
70
|
-
|
|
77
|
+
cancelled = true;
|
|
78
|
+
destroyRef.current?.();
|
|
79
|
+
destroyRef.current = null;
|
|
71
80
|
};
|
|
72
81
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
82
|
}, []);
|
|
@@ -186,6 +186,7 @@ export class DaemonClient {
|
|
|
186
186
|
private _onEndpointDetected: ((url: string) => void) | undefined;
|
|
187
187
|
private _restorePromise: Promise<void> | null = null;
|
|
188
188
|
private _sessionId: SessionInfo | null = null;
|
|
189
|
+
private _onConnectionChange: (() => void) | undefined;
|
|
189
190
|
|
|
190
191
|
constructor(options: DaemonClientOptions) {
|
|
191
192
|
this._fetch = options.fetch;
|
|
@@ -315,6 +316,7 @@ export class DaemonClient {
|
|
|
315
316
|
).remove;
|
|
316
317
|
|
|
317
318
|
this._stream = state;
|
|
319
|
+
this._onConnectionChange?.();
|
|
318
320
|
this.emitStatus({ state: 'connecting' });
|
|
319
321
|
this.enqueueSendFullReport();
|
|
320
322
|
}
|
|
@@ -324,6 +326,7 @@ export class DaemonClient {
|
|
|
324
326
|
const state = this._stream;
|
|
325
327
|
this._stream = null;
|
|
326
328
|
this._sessionId = null;
|
|
329
|
+
this._onConnectionChange?.();
|
|
327
330
|
|
|
328
331
|
if (state.debounceTimer) clearTimeout(state.debounceTimer);
|
|
329
332
|
if (state.retryTimer) clearTimeout(state.retryTimer);
|
|
@@ -360,6 +363,10 @@ export class DaemonClient {
|
|
|
360
363
|
this._onEndpointDetected = callback;
|
|
361
364
|
}
|
|
362
365
|
|
|
366
|
+
setOnConnectionChange(callback: (() => void) | undefined): void {
|
|
367
|
+
this._onConnectionChange = callback;
|
|
368
|
+
}
|
|
369
|
+
|
|
363
370
|
// --- Restore (init-time reconnect) ---
|
|
364
371
|
|
|
365
372
|
async restore(): Promise<void> {
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DevConnectQrScanner = DevConnectQrScanner;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _colors = require("../../ui/theme/colors");
|
|
10
|
-
var _cameraKit = require("./cameraKit");
|
|
11
|
-
var _devConnectUtils = require("./devConnectUtils");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
-
// ─── Camera Error Boundary ─────────────────────────────────
|
|
15
|
-
|
|
16
|
-
class CameraErrorBoundary extends _react.Component {
|
|
17
|
-
state = {
|
|
18
|
-
hasError: false
|
|
19
|
-
};
|
|
20
|
-
static getDerivedStateFromError() {
|
|
21
|
-
return {
|
|
22
|
-
hasError: true
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
componentDidCatch(error) {
|
|
26
|
-
console.warn('[DevConnect] Camera error:', error.message);
|
|
27
|
-
this.props.onCameraError(error.message || 'Camera failed to initialize.');
|
|
28
|
-
}
|
|
29
|
-
render() {
|
|
30
|
-
if (this.state.hasError) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return this.props.children;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ─── QR Scanner ─────────────────────────────────────────────
|
|
38
|
-
|
|
39
|
-
function DevConnectQrScanner({
|
|
40
|
-
visible,
|
|
41
|
-
onClose,
|
|
42
|
-
onScanTarget
|
|
43
|
-
}) {
|
|
44
|
-
const scannedRef = (0, _react.useRef)(false);
|
|
45
|
-
const [error, setError] = (0, _react.useState)(null);
|
|
46
|
-
const [cameraFailed, setCameraFailed] = (0, _react.useState)(false);
|
|
47
|
-
const scanner = (0, _cameraKit.getScannerModule)();
|
|
48
|
-
(0, _react.useEffect)(() => {
|
|
49
|
-
if (visible) {
|
|
50
|
-
scannedRef.current = false;
|
|
51
|
-
setError(null);
|
|
52
|
-
setCameraFailed(false);
|
|
53
|
-
}
|
|
54
|
-
}, [visible]);
|
|
55
|
-
const handleScanned = (0, _react.useCallback)(rawValue => {
|
|
56
|
-
if (scannedRef.current) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (typeof rawValue !== 'string') {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const parsed = (0, _devConnectUtils.parseMetroQrPayload)(rawValue);
|
|
63
|
-
if (!parsed) {
|
|
64
|
-
setError('QR code does not contain a supported Metro URL.');
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
scannedRef.current = true;
|
|
68
|
-
setError(null);
|
|
69
|
-
onScanTarget({
|
|
70
|
-
computerHost: parsed.computerHost,
|
|
71
|
-
metroPort: parsed.metroPort
|
|
72
|
-
});
|
|
73
|
-
onClose();
|
|
74
|
-
}, [onClose, onScanTarget]);
|
|
75
|
-
const handleCameraKitRead = (0, _react.useCallback)(event => {
|
|
76
|
-
handleScanned(event.nativeEvent?.codeStringValue ?? '');
|
|
77
|
-
}, [handleScanned]);
|
|
78
|
-
const handleExpoScanned = (0, _react.useCallback)(result => {
|
|
79
|
-
handleScanned(result.value ?? '');
|
|
80
|
-
}, [handleScanned]);
|
|
81
|
-
const handleCameraError = (0, _react.useCallback)(_msg => {
|
|
82
|
-
setCameraFailed(true);
|
|
83
|
-
}, []);
|
|
84
|
-
if (!visible || !scanner) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
|
|
88
|
-
visible: visible,
|
|
89
|
-
animationType: "slide",
|
|
90
|
-
presentationStyle: "fullScreen",
|
|
91
|
-
onRequestClose: onClose,
|
|
92
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
93
|
-
style: styles.container,
|
|
94
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
95
|
-
style: styles.previewLayer,
|
|
96
|
-
children: [!cameraFailed && /*#__PURE__*/(0, _jsxRuntime.jsx)(CameraErrorBoundary, {
|
|
97
|
-
onCameraError: handleCameraError,
|
|
98
|
-
children: scanner.kind === 'camera-kit' && scanner.CameraKit ? /*#__PURE__*/(0, _jsxRuntime.jsx)(scanner.CameraKit.Camera, {
|
|
99
|
-
style: styles.camera,
|
|
100
|
-
cameraType: scanner.CameraKit.CameraType?.Back,
|
|
101
|
-
scanBarcode: true,
|
|
102
|
-
onReadCode: handleCameraKitRead,
|
|
103
|
-
showFrame: true,
|
|
104
|
-
laserColor: _colors.Colors.primary,
|
|
105
|
-
frameColor: _colors.Colors.primary,
|
|
106
|
-
allowedBarcodeTypes: ['qr']
|
|
107
|
-
}) : scanner.kind === 'expo-camera' && scanner.ExpoCamera ? /*#__PURE__*/(0, _jsxRuntime.jsx)(scanner.ExpoCamera.Camera, {
|
|
108
|
-
style: styles.camera,
|
|
109
|
-
onBarCodeScanned: handleExpoScanned,
|
|
110
|
-
barCodeScannerSettings: {
|
|
111
|
-
barCodeTypes: ['qr']
|
|
112
|
-
}
|
|
113
|
-
}) : null
|
|
114
|
-
}), cameraFailed && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
115
|
-
style: styles.cameraFallback,
|
|
116
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
117
|
-
style: styles.cameraFallbackText,
|
|
118
|
-
children: "Camera unavailable."
|
|
119
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
120
|
-
style: styles.cameraFallbackHint,
|
|
121
|
-
children: "Please enter computer IP manually."
|
|
122
|
-
})]
|
|
123
|
-
})]
|
|
124
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
125
|
-
style: styles.topBar,
|
|
126
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
127
|
-
style: styles.titleGroup,
|
|
128
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
129
|
-
style: styles.title,
|
|
130
|
-
children: "Scan Metro QR"
|
|
131
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
132
|
-
style: styles.subtitle,
|
|
133
|
-
children: "Expo or Metro URL"
|
|
134
|
-
})]
|
|
135
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
136
|
-
style: styles.closeButton,
|
|
137
|
-
onPress: onClose,
|
|
138
|
-
activeOpacity: 0.75,
|
|
139
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
140
|
-
style: styles.closeButtonText,
|
|
141
|
-
children: "Close"
|
|
142
|
-
})
|
|
143
|
-
})]
|
|
144
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
145
|
-
style: [styles.statusPill, error && styles.statusPillError],
|
|
146
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
147
|
-
style: [styles.statusText, error && styles.statusTextError],
|
|
148
|
-
children: error ?? 'Point the camera at exp:// or http:// Metro URL.'
|
|
149
|
-
})
|
|
150
|
-
})]
|
|
151
|
-
})
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
const styles = _reactNative.StyleSheet.create({
|
|
155
|
-
container: {
|
|
156
|
-
flex: 1,
|
|
157
|
-
backgroundColor: '#000'
|
|
158
|
-
},
|
|
159
|
-
previewLayer: {
|
|
160
|
-
..._reactNative.StyleSheet.absoluteFillObject
|
|
161
|
-
},
|
|
162
|
-
camera: {
|
|
163
|
-
..._reactNative.StyleSheet.absoluteFillObject
|
|
164
|
-
},
|
|
165
|
-
cameraFallback: {
|
|
166
|
-
..._reactNative.StyleSheet.absoluteFillObject,
|
|
167
|
-
justifyContent: 'center',
|
|
168
|
-
alignItems: 'center',
|
|
169
|
-
padding: 24
|
|
170
|
-
},
|
|
171
|
-
cameraFallbackText: {
|
|
172
|
-
fontSize: 16,
|
|
173
|
-
color: '#fff',
|
|
174
|
-
fontWeight: '600',
|
|
175
|
-
marginBottom: 8
|
|
176
|
-
},
|
|
177
|
-
cameraFallbackHint: {
|
|
178
|
-
fontSize: 13,
|
|
179
|
-
color: 'rgba(255,255,255,0.6)',
|
|
180
|
-
textAlign: 'center'
|
|
181
|
-
},
|
|
182
|
-
topBar: {
|
|
183
|
-
position: 'absolute',
|
|
184
|
-
top: 44,
|
|
185
|
-
left: 16,
|
|
186
|
-
right: 16,
|
|
187
|
-
flexDirection: 'row',
|
|
188
|
-
alignItems: 'center',
|
|
189
|
-
justifyContent: 'space-between',
|
|
190
|
-
paddingLeft: 14,
|
|
191
|
-
paddingRight: 8,
|
|
192
|
-
paddingVertical: 8,
|
|
193
|
-
borderRadius: 12,
|
|
194
|
-
backgroundColor: 'rgba(0,0,0,0.62)'
|
|
195
|
-
},
|
|
196
|
-
titleGroup: {
|
|
197
|
-
flex: 1,
|
|
198
|
-
paddingRight: 10
|
|
199
|
-
},
|
|
200
|
-
title: {
|
|
201
|
-
color: '#fff',
|
|
202
|
-
fontSize: 15,
|
|
203
|
-
fontWeight: '700'
|
|
204
|
-
},
|
|
205
|
-
subtitle: {
|
|
206
|
-
color: 'rgba(255,255,255,0.68)',
|
|
207
|
-
fontSize: 11,
|
|
208
|
-
marginTop: 2
|
|
209
|
-
},
|
|
210
|
-
closeButton: {
|
|
211
|
-
alignItems: 'center',
|
|
212
|
-
justifyContent: 'center',
|
|
213
|
-
paddingHorizontal: 12,
|
|
214
|
-
paddingVertical: 8,
|
|
215
|
-
borderRadius: 8,
|
|
216
|
-
backgroundColor: 'rgba(255,255,255,0.14)'
|
|
217
|
-
},
|
|
218
|
-
closeButtonText: {
|
|
219
|
-
color: '#fff',
|
|
220
|
-
fontSize: 14,
|
|
221
|
-
fontWeight: '600'
|
|
222
|
-
},
|
|
223
|
-
statusPill: {
|
|
224
|
-
position: 'absolute',
|
|
225
|
-
left: 16,
|
|
226
|
-
right: 16,
|
|
227
|
-
bottom: 30,
|
|
228
|
-
paddingHorizontal: 14,
|
|
229
|
-
paddingVertical: 11,
|
|
230
|
-
borderRadius: 12,
|
|
231
|
-
backgroundColor: 'rgba(0,0,0,0.62)'
|
|
232
|
-
},
|
|
233
|
-
statusPillError: {
|
|
234
|
-
backgroundColor: `${_colors.Colors.error}22`,
|
|
235
|
-
borderWidth: 1,
|
|
236
|
-
borderColor: `${_colors.Colors.error}66`
|
|
237
|
-
},
|
|
238
|
-
statusText: {
|
|
239
|
-
color: '#fff',
|
|
240
|
-
fontSize: 13,
|
|
241
|
-
textAlign: 'center',
|
|
242
|
-
lineHeight: 18
|
|
243
|
-
},
|
|
244
|
-
statusTextError: {
|
|
245
|
-
color: '#fff'
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
//# sourceMappingURL=DevConnectQrScanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_colors","_cameraKit","_devConnectUtils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","CameraErrorBoundary","Component","state","hasError","getDerivedStateFromError","componentDidCatch","error","console","warn","message","props","onCameraError","render","children","DevConnectQrScanner","visible","onClose","onScanTarget","scannedRef","useRef","setError","useState","cameraFailed","setCameraFailed","scanner","getScannerModule","useEffect","current","handleScanned","useCallback","rawValue","parsed","parseMetroQrPayload","computerHost","metroPort","handleCameraKitRead","event","nativeEvent","codeStringValue","handleExpoScanned","result","value","handleCameraError","_msg","jsx","Modal","animationType","presentationStyle","onRequestClose","jsxs","View","style","styles","container","previewLayer","kind","CameraKit","Camera","camera","cameraType","CameraType","Back","scanBarcode","onReadCode","showFrame","laserColor","Colors","primary","frameColor","allowedBarcodeTypes","ExpoCamera","onBarCodeScanned","barCodeScannerSettings","barCodeTypes","cameraFallback","Text","cameraFallbackText","cameraFallbackHint","topBar","titleGroup","title","subtitle","TouchableOpacity","closeButton","onPress","activeOpacity","closeButtonText","statusPill","statusPillError","statusText","statusTextError","StyleSheet","create","flex","backgroundColor","absoluteFillObject","justifyContent","alignItems","padding","fontSize","color","fontWeight","marginBottom","textAlign","position","top","left","right","flexDirection","paddingLeft","paddingRight","paddingVertical","borderRadius","marginTop","paddingHorizontal","bottom","borderWidth","borderColor","lineHeight"],"sourceRoot":"../../../../src","sources":["features/devConnect/DevConnectQrScanner.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAKA,IAAAI,gBAAA,GAAAJ,OAAA;AAAmF,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,G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MAAM;IAAED,QAAQ,EAAE,EAAE;IAAEI,SAAS,EAAE,QAAQ;IAAEe,UAAU,EAAE;EAAG,CAAC;EAChF5B,eAAe,EAAE;IAAEU,KAAK,EAAE;EAAO;AACnC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getScannerModule = getScannerModule;
|
|
7
|
-
exports.isCameraKitAvailable = isCameraKitAvailable;
|
|
8
|
-
// ---- react-native-camera-kit types ----
|
|
9
|
-
|
|
10
|
-
// ---- expo-camera types ----
|
|
11
|
-
|
|
12
|
-
// ---- Unified scanner ----
|
|
13
|
-
|
|
14
|
-
let cached = false;
|
|
15
|
-
function tryCameraKit() {
|
|
16
|
-
try {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
|
-
const mod = require('react-native-camera-kit');
|
|
19
|
-
if (mod.Camera) {
|
|
20
|
-
return {
|
|
21
|
-
kind: 'camera-kit',
|
|
22
|
-
CameraKit: {
|
|
23
|
-
Camera: mod.Camera,
|
|
24
|
-
CameraType: mod.CameraType
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
} catch {/* not installed */}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
function tryExpoCamera() {
|
|
32
|
-
try {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
|
-
const mod = require('expo-camera');
|
|
35
|
-
if (mod.Camera) {
|
|
36
|
-
return {
|
|
37
|
-
kind: 'expo-camera',
|
|
38
|
-
ExpoCamera: {
|
|
39
|
-
Camera: mod.Camera
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
} catch {/* not installed */}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
function getScannerModule() {
|
|
47
|
-
if (cached !== false) return cached;
|
|
48
|
-
cached = tryCameraKit() ?? tryExpoCamera();
|
|
49
|
-
return cached;
|
|
50
|
-
}
|
|
51
|
-
function isCameraKitAvailable() {
|
|
52
|
-
return getScannerModule() !== null;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=cameraKit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["cached","tryCameraKit","mod","require","Camera","kind","CameraKit","CameraType","tryExpoCamera","ExpoCamera","getScannerModule","isCameraKitAvailable"],"sourceRoot":"../../../../src","sources":["features/devConnect/cameraKit.ts"],"mappings":";;;;;;;AAGA;;AAwBA;;AAiBA;;AAUA,IAAIA,MAAoC,GAAG,KAAK;AAEhD,SAASC,YAAYA,CAAA,EAAyB;EAC5C,IAAI;IACF;IACA,MAAMC,GAAG,GAAGC,OAAO,CAAC,yBAAyB,CAA6B;IAC1E,IAAID,GAAG,CAACE,MAAM,EAAE;MACd,OAAO;QACLC,IAAI,EAAE,YAAY;QAClBC,SAAS,EAAE;UAAEF,MAAM,EAAEF,GAAG,CAACE,MAAM;UAAEG,UAAU,EAAEL,GAAG,CAACK;QAAW;MAC9D,CAAC;IACH;EACF,CAAC,CAAC,MAAM,CAAE;EACV,OAAO,IAAI;AACb;AAEA,SAASC,aAAaA,CAAA,EAAyB;EAC7C,IAAI;IACF;IACA,MAAMN,GAAG,GAAGC,OAAO,CAAC,aAAa,CAA8B;IAC/D,IAAID,GAAG,CAACE,MAAM,EAAE;MACd,OAAO;QACLC,IAAI,EAAE,aAAa;QACnBI,UAAU,EAAE;UAAEL,MAAM,EAAEF,GAAG,CAACE;QAAO;MACnC,CAAC;IACH;EACF,CAAC,CAAC,MAAM,CAAE;EACV,OAAO,IAAI;AACb;AAEO,SAASM,gBAAgBA,CAAA,EAAyB;EACvD,IAAIV,MAAM,KAAK,KAAK,EAAE,OAAOA,MAAM;EACnCA,MAAM,GAAGC,YAAY,CAAC,CAAC,IAAIO,aAAa,CAAC,CAAC;EAC1C,OAAOR,MAAM;AACf;AAEO,SAASW,oBAAoBA,CAAA,EAAY;EAC9C,OAAOD,gBAAgB,CAAC,CAAC,KAAK,IAAI;AACpC","ignoreList":[]}
|