react-native-debug-toolkit 3.2.3 → 3.2.5

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.
Files changed (74) hide show
  1. package/android/src/main/java/com/reactnativedebugtoolkit/DebugToolkitDevConnectModule.java +80 -10
  2. package/ios/DebugToolkitDevConnect.mm +84 -19
  3. package/lib/commonjs/core/initialize.js +15 -3
  4. package/lib/commonjs/core/initialize.js.map +1 -1
  5. package/lib/commonjs/features/devConnect/DevConnectTab.js +121 -58
  6. package/lib/commonjs/features/devConnect/DevConnectTab.js.map +1 -1
  7. package/lib/commonjs/features/devConnect/devConnectPreferences.js +6 -2
  8. package/lib/commonjs/features/devConnect/devConnectPreferences.js.map +1 -1
  9. package/lib/commonjs/features/devConnect/devConnectUtils.js +8 -0
  10. package/lib/commonjs/features/devConnect/devConnectUtils.js.map +1 -1
  11. package/lib/commonjs/features/devConnect/index.js +33 -5
  12. package/lib/commonjs/features/devConnect/index.js.map +1 -1
  13. package/lib/commonjs/features/devConnect/nativeDevConnect.js +26 -0
  14. package/lib/commonjs/features/devConnect/nativeDevConnect.js.map +1 -1
  15. package/lib/commonjs/ui/DebugView.js +10 -2
  16. package/lib/commonjs/ui/DebugView.js.map +1 -1
  17. package/lib/commonjs/utils/DaemonClient.js +5 -0
  18. package/lib/commonjs/utils/DaemonClient.js.map +1 -1
  19. package/lib/module/core/initialize.js +16 -4
  20. package/lib/module/core/initialize.js.map +1 -1
  21. package/lib/module/features/devConnect/DevConnectTab.js +122 -59
  22. package/lib/module/features/devConnect/DevConnectTab.js.map +1 -1
  23. package/lib/module/features/devConnect/devConnectPreferences.js +6 -2
  24. package/lib/module/features/devConnect/devConnectPreferences.js.map +1 -1
  25. package/lib/module/features/devConnect/devConnectUtils.js +7 -0
  26. package/lib/module/features/devConnect/devConnectUtils.js.map +1 -1
  27. package/lib/module/features/devConnect/index.js +30 -7
  28. package/lib/module/features/devConnect/index.js.map +1 -1
  29. package/lib/module/features/devConnect/nativeDevConnect.js +24 -0
  30. package/lib/module/features/devConnect/nativeDevConnect.js.map +1 -1
  31. package/lib/module/ui/DebugView.js +11 -3
  32. package/lib/module/ui/DebugView.js.map +1 -1
  33. package/lib/module/utils/DaemonClient.js +5 -0
  34. package/lib/module/utils/DaemonClient.js.map +1 -1
  35. package/lib/typescript/src/core/initialize.d.ts +4 -2
  36. package/lib/typescript/src/core/initialize.d.ts.map +1 -1
  37. package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts +1 -1
  38. package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts.map +1 -1
  39. package/lib/typescript/src/features/devConnect/devConnectPreferences.d.ts.map +1 -1
  40. package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts +1 -0
  41. package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts.map +1 -1
  42. package/lib/typescript/src/features/devConnect/index.d.ts +1 -0
  43. package/lib/typescript/src/features/devConnect/index.d.ts.map +1 -1
  44. package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts +2 -0
  45. package/lib/typescript/src/features/devConnect/nativeDevConnect.d.ts.map +1 -1
  46. package/lib/typescript/src/features/devConnect/types.d.ts +5 -1
  47. package/lib/typescript/src/features/devConnect/types.d.ts.map +1 -1
  48. package/lib/typescript/src/ui/DebugView.d.ts.map +1 -1
  49. package/lib/typescript/src/utils/DaemonClient.d.ts +2 -0
  50. package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -1
  51. package/package.json +2 -10
  52. package/src/core/initialize.ts +17 -5
  53. package/src/features/devConnect/DevConnectTab.tsx +120 -45
  54. package/src/features/devConnect/devConnectPreferences.ts +7 -2
  55. package/src/features/devConnect/devConnectUtils.ts +8 -0
  56. package/src/features/devConnect/index.ts +31 -7
  57. package/src/features/devConnect/nativeDevConnect.ts +28 -0
  58. package/src/features/devConnect/types.ts +9 -1
  59. package/src/ui/DebugView.tsx +12 -3
  60. package/src/utils/DaemonClient.ts +7 -0
  61. package/lib/commonjs/features/devConnect/DevConnectQrScanner.js +0 -248
  62. package/lib/commonjs/features/devConnect/DevConnectQrScanner.js.map +0 -1
  63. package/lib/commonjs/features/devConnect/cameraKit.js +0 -54
  64. package/lib/commonjs/features/devConnect/cameraKit.js.map +0 -1
  65. package/lib/module/features/devConnect/DevConnectQrScanner.js +0 -243
  66. package/lib/module/features/devConnect/DevConnectQrScanner.js.map +0 -1
  67. package/lib/module/features/devConnect/cameraKit.js +0 -49
  68. package/lib/module/features/devConnect/cameraKit.js.map +0 -1
  69. package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts +0 -10
  70. package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts.map +0 -1
  71. package/lib/typescript/src/features/devConnect/cameraKit.d.ts +0 -47
  72. package/lib/typescript/src/features/devConnect/cameraKit.d.ts.map +0 -1
  73. package/src/features/devConnect/DevConnectQrScanner.tsx +0 -214
  74. package/src/features/devConnect/cameraKit.ts +0 -93
@@ -1,47 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
3
- export interface CameraKitReadCodeEvent {
4
- nativeEvent?: {
5
- codeStringValue?: string;
6
- };
7
- }
8
- export interface CameraKitCameraProps {
9
- style?: StyleProp<ViewStyle>;
10
- cameraType?: unknown;
11
- scanBarcode?: boolean;
12
- onReadCode?: (event: CameraKitReadCodeEvent) => void;
13
- showFrame?: boolean;
14
- laserColor?: string;
15
- frameColor?: string;
16
- allowedBarcodeTypes?: string[];
17
- }
18
- export interface CameraKitModule {
19
- Camera: ComponentType<CameraKitCameraProps>;
20
- CameraType?: {
21
- Back?: unknown;
22
- };
23
- }
24
- export interface ExpoCameraScanResult {
25
- boundingBox?: unknown;
26
- cornerPoints?: unknown;
27
- type?: string;
28
- value?: string;
29
- }
30
- export interface ExpoCameraModule {
31
- Camera: ComponentType<{
32
- style?: StyleProp<ViewStyle>;
33
- onBarCodeScanned?: (result: ExpoCameraScanResult) => void;
34
- barCodeScannerSettings?: {
35
- barCodeTypes: string[];
36
- };
37
- }>;
38
- }
39
- export type ScannerKind = 'camera-kit' | 'expo-camera';
40
- export interface ScannerModule {
41
- kind: ScannerKind;
42
- CameraKit?: CameraKitModule;
43
- ExpoCamera?: ExpoCameraModule;
44
- }
45
- export declare function getScannerModule(): ScannerModule | null;
46
- export declare function isCameraKitAvailable(): boolean;
47
- //# sourceMappingURL=cameraKit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cameraKit.d.ts","sourceRoot":"","sources":["../../../../../src/features/devConnect/cameraKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzD,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE;QACZ,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACjC;AAID,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,aAAa,CAAC;QACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7B,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;QAC1D,sBAAsB,CAAC,EAAE;YAAE,YAAY,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;KACrD,CAAC,CAAC;CACJ;AAID,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,aAAa,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAgCD,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAIvD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
@@ -1,214 +0,0 @@
1
- import React, { Component, useCallback, useEffect, useRef, useState } from 'react';
2
- import {
3
- Modal,
4
- StyleSheet,
5
- Text,
6
- TouchableOpacity,
7
- View,
8
- } from 'react-native';
9
-
10
- import { Colors } from '../../ui/theme/colors';
11
- import {
12
- getScannerModule,
13
- type CameraKitReadCodeEvent,
14
- type ExpoCameraScanResult,
15
- } from './cameraKit';
16
- import { parseMetroQrPayload, type ParsedComputerTarget } from './devConnectUtils';
17
-
18
- // ─── Camera Error Boundary ─────────────────────────────────
19
-
20
- interface CameraBoundaryProps {
21
- children: React.ReactNode;
22
- onCameraError: (msg: string) => void;
23
- }
24
-
25
- interface CameraBoundaryState {
26
- hasError: boolean;
27
- }
28
-
29
- class CameraErrorBoundary extends Component<CameraBoundaryProps, CameraBoundaryState> {
30
- state: CameraBoundaryState = { hasError: false };
31
-
32
- static getDerivedStateFromError(): CameraBoundaryState {
33
- return { hasError: true };
34
- }
35
-
36
- componentDidCatch(error: Error) {
37
- console.warn('[DevConnect] Camera error:', error.message);
38
- this.props.onCameraError(error.message || 'Camera failed to initialize.');
39
- }
40
-
41
- render() {
42
- if (this.state.hasError) {
43
- return null;
44
- }
45
- return this.props.children;
46
- }
47
- }
48
-
49
- // ─── QR Scanner ─────────────────────────────────────────────
50
-
51
- interface DevConnectQrScannerProps {
52
- visible: boolean;
53
- onClose: () => void;
54
- onScanTarget: (target: ParsedComputerTarget) => void;
55
- }
56
-
57
- export function DevConnectQrScanner({ visible, onClose, onScanTarget }: DevConnectQrScannerProps) {
58
- const scannedRef = useRef(false);
59
- const [error, setError] = useState<string | null>(null);
60
- const [cameraFailed, setCameraFailed] = useState(false);
61
- const scanner = getScannerModule();
62
-
63
- useEffect(() => {
64
- if (visible) {
65
- scannedRef.current = false;
66
- setError(null);
67
- setCameraFailed(false);
68
- }
69
- }, [visible]);
70
-
71
- const handleScanned = useCallback((rawValue: string) => {
72
- if (scannedRef.current) {
73
- return;
74
- }
75
- if (typeof rawValue !== 'string') {
76
- return;
77
- }
78
-
79
- const parsed = parseMetroQrPayload(rawValue);
80
- if (!parsed) {
81
- setError('QR code does not contain a supported Metro URL.');
82
- return;
83
- }
84
-
85
- scannedRef.current = true;
86
- setError(null);
87
- onScanTarget({
88
- computerHost: parsed.computerHost,
89
- metroPort: parsed.metroPort,
90
- });
91
- onClose();
92
- }, [onClose, onScanTarget]);
93
-
94
- const handleCameraKitRead = useCallback((event: CameraKitReadCodeEvent) => {
95
- handleScanned(event.nativeEvent?.codeStringValue ?? '');
96
- }, [handleScanned]);
97
-
98
- const handleExpoScanned = useCallback((result: ExpoCameraScanResult) => {
99
- handleScanned(result.value ?? '');
100
- }, [handleScanned]);
101
-
102
- const handleCameraError = useCallback((_msg: string) => {
103
- setCameraFailed(true);
104
- }, []);
105
-
106
- if (!visible || !scanner) {
107
- return null;
108
- }
109
-
110
- return (
111
- <Modal visible={visible} animationType="slide" presentationStyle="fullScreen" onRequestClose={onClose}>
112
- <View style={styles.container}>
113
- <View style={styles.previewLayer}>
114
- {!cameraFailed && (
115
- <CameraErrorBoundary onCameraError={handleCameraError}>
116
- {scanner.kind === 'camera-kit' && scanner.CameraKit ? (
117
- <scanner.CameraKit.Camera
118
- style={styles.camera}
119
- cameraType={scanner.CameraKit.CameraType?.Back}
120
- scanBarcode
121
- onReadCode={handleCameraKitRead}
122
- showFrame
123
- laserColor={Colors.primary}
124
- frameColor={Colors.primary}
125
- allowedBarcodeTypes={['qr']}
126
- />
127
- ) : scanner.kind === 'expo-camera' && scanner.ExpoCamera ? (
128
- <scanner.ExpoCamera.Camera
129
- style={styles.camera}
130
- onBarCodeScanned={handleExpoScanned}
131
- barCodeScannerSettings={{ barCodeTypes: ['qr'] }}
132
- />
133
- ) : null}
134
- </CameraErrorBoundary>
135
- )}
136
- {cameraFailed && (
137
- <View style={styles.cameraFallback}>
138
- <Text style={styles.cameraFallbackText}>Camera unavailable.</Text>
139
- <Text style={styles.cameraFallbackHint}>Please enter computer IP manually.</Text>
140
- </View>
141
- )}
142
- </View>
143
-
144
- <View style={styles.topBar}>
145
- <View style={styles.titleGroup}>
146
- <Text style={styles.title}>Scan Metro QR</Text>
147
- <Text style={styles.subtitle}>Expo or Metro URL</Text>
148
- </View>
149
- <TouchableOpacity style={styles.closeButton} onPress={onClose} activeOpacity={0.75}>
150
- <Text style={styles.closeButtonText}>Close</Text>
151
- </TouchableOpacity>
152
- </View>
153
-
154
- <View style={[styles.statusPill, error && styles.statusPillError]}>
155
- <Text style={[styles.statusText, error && styles.statusTextError]}>
156
- {error ?? 'Point the camera at exp:// or http:// Metro URL.'}
157
- </Text>
158
- </View>
159
- </View>
160
- </Modal>
161
- );
162
- }
163
-
164
- const styles = StyleSheet.create({
165
- container: { flex: 1, backgroundColor: '#000' },
166
- previewLayer: { ...StyleSheet.absoluteFillObject },
167
- camera: { ...StyleSheet.absoluteFillObject },
168
- cameraFallback: { ...StyleSheet.absoluteFillObject, justifyContent: 'center', alignItems: 'center', padding: 24 },
169
- cameraFallbackText: { fontSize: 16, color: '#fff', fontWeight: '600', marginBottom: 8 },
170
- cameraFallbackHint: { fontSize: 13, color: 'rgba(255,255,255,0.6)', textAlign: 'center' },
171
- topBar: {
172
- position: 'absolute',
173
- top: 44,
174
- left: 16,
175
- right: 16,
176
- flexDirection: 'row',
177
- alignItems: 'center',
178
- justifyContent: 'space-between',
179
- paddingLeft: 14,
180
- paddingRight: 8,
181
- paddingVertical: 8,
182
- borderRadius: 12,
183
- backgroundColor: 'rgba(0,0,0,0.62)',
184
- },
185
- titleGroup: { flex: 1, paddingRight: 10 },
186
- title: { color: '#fff', fontSize: 15, fontWeight: '700' },
187
- subtitle: { color: 'rgba(255,255,255,0.68)', fontSize: 11, marginTop: 2 },
188
- closeButton: {
189
- alignItems: 'center',
190
- justifyContent: 'center',
191
- paddingHorizontal: 12,
192
- paddingVertical: 8,
193
- borderRadius: 8,
194
- backgroundColor: 'rgba(255,255,255,0.14)',
195
- },
196
- closeButtonText: { color: '#fff', fontSize: 14, fontWeight: '600' },
197
- statusPill: {
198
- position: 'absolute',
199
- left: 16,
200
- right: 16,
201
- bottom: 30,
202
- paddingHorizontal: 14,
203
- paddingVertical: 11,
204
- borderRadius: 12,
205
- backgroundColor: 'rgba(0,0,0,0.62)',
206
- },
207
- statusPillError: {
208
- backgroundColor: `${Colors.error}22`,
209
- borderWidth: 1,
210
- borderColor: `${Colors.error}66`,
211
- },
212
- statusText: { color: '#fff', fontSize: 13, textAlign: 'center', lineHeight: 18 },
213
- statusTextError: { color: '#fff' },
214
- });
@@ -1,93 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
3
-
4
- // ---- react-native-camera-kit types ----
5
-
6
- export interface CameraKitReadCodeEvent {
7
- nativeEvent?: {
8
- codeStringValue?: string;
9
- };
10
- }
11
-
12
- export interface CameraKitCameraProps {
13
- style?: StyleProp<ViewStyle>;
14
- cameraType?: unknown;
15
- scanBarcode?: boolean;
16
- onReadCode?: (event: CameraKitReadCodeEvent) => void;
17
- showFrame?: boolean;
18
- laserColor?: string;
19
- frameColor?: string;
20
- allowedBarcodeTypes?: string[];
21
- }
22
-
23
- export interface CameraKitModule {
24
- Camera: ComponentType<CameraKitCameraProps>;
25
- CameraType?: { Back?: unknown };
26
- }
27
-
28
- // ---- expo-camera types ----
29
-
30
- export interface ExpoCameraScanResult {
31
- boundingBox?: unknown;
32
- cornerPoints?: unknown;
33
- type?: string;
34
- value?: string;
35
- }
36
-
37
- export interface ExpoCameraModule {
38
- Camera: ComponentType<{
39
- style?: StyleProp<ViewStyle>;
40
- onBarCodeScanned?: (result: ExpoCameraScanResult) => void;
41
- barCodeScannerSettings?: { barCodeTypes: string[] };
42
- }>;
43
- }
44
-
45
- // ---- Unified scanner ----
46
-
47
- export type ScannerKind = 'camera-kit' | 'expo-camera';
48
-
49
- export interface ScannerModule {
50
- kind: ScannerKind;
51
- CameraKit?: CameraKitModule;
52
- ExpoCamera?: ExpoCameraModule;
53
- }
54
-
55
- let cached: ScannerModule | null | false = false;
56
-
57
- function tryCameraKit(): ScannerModule | null {
58
- try {
59
- // eslint-disable-next-line @typescript-eslint/no-require-imports
60
- const mod = require('react-native-camera-kit') as Partial<CameraKitModule>;
61
- if (mod.Camera) {
62
- return {
63
- kind: 'camera-kit',
64
- CameraKit: { Camera: mod.Camera, CameraType: mod.CameraType },
65
- };
66
- }
67
- } catch { /* not installed */ }
68
- return null;
69
- }
70
-
71
- function tryExpoCamera(): ScannerModule | null {
72
- try {
73
- // eslint-disable-next-line @typescript-eslint/no-require-imports
74
- const mod = require('expo-camera') as Partial<ExpoCameraModule>;
75
- if (mod.Camera) {
76
- return {
77
- kind: 'expo-camera',
78
- ExpoCamera: { Camera: mod.Camera },
79
- };
80
- }
81
- } catch { /* not installed */ }
82
- return null;
83
- }
84
-
85
- export function getScannerModule(): ScannerModule | null {
86
- if (cached !== false) return cached;
87
- cached = tryCameraKit() ?? tryExpoCamera();
88
- return cached;
89
- }
90
-
91
- export function isCameraKitAvailable(): boolean {
92
- return getScannerModule() !== null;
93
- }