@zizwar/react-native-debug-console 1.0.0

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/src/Icons.tsx ADDED
@@ -0,0 +1,91 @@
1
+ /**
2
+ * React Native Debug Console - Icons
3
+ * Simple text-based icons to avoid external dependencies
4
+ */
5
+
6
+ import React from 'react';
7
+ import { Text, View, StyleSheet } from 'react-native';
8
+
9
+ interface IconProps {
10
+ name: IconName;
11
+ size?: number;
12
+ color?: string;
13
+ }
14
+
15
+ export type IconName =
16
+ | 'bug'
17
+ | 'close'
18
+ | 'close-circle'
19
+ | 'warning'
20
+ | 'information-circle'
21
+ | 'trash'
22
+ | 'share'
23
+ | 'document'
24
+ | 'ellipse';
25
+
26
+ const ICONS: Record<IconName, string> = {
27
+ 'bug': '🐛',
28
+ 'close': '✕',
29
+ 'close-circle': '⊗',
30
+ 'warning': '⚠',
31
+ 'information-circle': 'ℹ',
32
+ 'trash': '🗑',
33
+ 'share': '↗',
34
+ 'document': '📄',
35
+ 'ellipse': '●',
36
+ };
37
+
38
+ export const DebugIcon: React.FC<IconProps> = ({ name, size = 16, color = '#fff' }) => {
39
+ return (
40
+ <Text style={[styles.icon, { fontSize: size, color }]}>
41
+ {ICONS[name] || '●'}
42
+ </Text>
43
+ );
44
+ };
45
+
46
+ // SVG-based icons for better quality (optional, requires react-native-svg)
47
+ export const SvgIcons = {
48
+ Bug: ({ size = 24, color = '#fff' }: { size?: number; color?: string }) => (
49
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
50
+ <Text style={{ fontSize: size * 0.8, color }}>🐛</Text>
51
+ </View>
52
+ ),
53
+ Close: ({ size = 24, color = '#fff' }: { size?: number; color?: string }) => (
54
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
55
+ <Text style={{ fontSize: size * 0.8, color, fontWeight: 'bold' }}>✕</Text>
56
+ </View>
57
+ ),
58
+ Error: ({ size = 24, color = '#FF5252' }: { size?: number; color?: string }) => (
59
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
60
+ <Text style={{ fontSize: size * 0.8, color }}>⊗</Text>
61
+ </View>
62
+ ),
63
+ Warning: ({ size = 24, color = '#FFD740' }: { size?: number; color?: string }) => (
64
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
65
+ <Text style={{ fontSize: size * 0.8, color }}>⚠</Text>
66
+ </View>
67
+ ),
68
+ Info: ({ size = 24, color = '#40C4FF' }: { size?: number; color?: string }) => (
69
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
70
+ <Text style={{ fontSize: size * 0.8, color }}>ℹ</Text>
71
+ </View>
72
+ ),
73
+ Trash: ({ size = 24, color = '#fff' }: { size?: number; color?: string }) => (
74
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
75
+ <Text style={{ fontSize: size * 0.8, color }}>🗑</Text>
76
+ </View>
77
+ ),
78
+ Share: ({ size = 24, color = '#fff' }: { size?: number; color?: string }) => (
79
+ <View style={{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }}>
80
+ <Text style={{ fontSize: size * 0.8, color }}>↗</Text>
81
+ </View>
82
+ ),
83
+ };
84
+
85
+ const styles = StyleSheet.create({
86
+ icon: {
87
+ textAlign: 'center',
88
+ },
89
+ });
90
+
91
+ export default DebugIcon;
package/src/index.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * React Native Debug Console
3
+ *
4
+ * A floating debug console for React Native / Expo apps.
5
+ * Captures console logs, errors, and warnings with a beautiful overlay UI.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * import { DebugConsole } from 'react-native-debug-console';
10
+ *
11
+ * export default function App() {
12
+ * return (
13
+ * <DebugConsole
14
+ * config={{
15
+ * enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
16
+ * appName: 'MyApp',
17
+ * }}
18
+ * >
19
+ * <YourApp />
20
+ * </DebugConsole>
21
+ * );
22
+ * }
23
+ * ```
24
+ */
25
+
26
+ // Main components
27
+ export { DebugConsole, withDebugConsole } from './DebugConsole';
28
+ export { DebugProvider, useDebugConsole, useDebugConsoleOptional } from './DebugProvider';
29
+ export { DebugOverlay } from './DebugOverlay';
30
+ export { DebugButton } from './DebugButton';
31
+ export { DebugIcon } from './Icons';
32
+
33
+ // Types
34
+ export type {
35
+ LogEntry,
36
+ LogType,
37
+ DebugConsoleConfig,
38
+ DebugConsoleColors,
39
+ ButtonPosition,
40
+ DebugConsoleContextType,
41
+ } from './types';
42
+
43
+ export { DEFAULT_CONFIG } from './types';
44
+
45
+ // Default export
46
+ export { DebugConsole as default } from './DebugConsole';
package/src/types.ts ADDED
@@ -0,0 +1,102 @@
1
+ /**
2
+ * React Native Debug Console - Types
3
+ */
4
+
5
+ export type LogType = 'log' | 'warn' | 'error' | 'info';
6
+
7
+ export interface LogEntry {
8
+ id: string;
9
+ timestamp: Date;
10
+ type: LogType;
11
+ message: string;
12
+ data?: any;
13
+ }
14
+
15
+ export interface DebugConsoleConfig {
16
+ /** Enable or disable the debug console (default: true) */
17
+ enabled?: boolean;
18
+ /** Maximum number of logs to keep (default: 100) */
19
+ maxLogs?: number;
20
+ /** Custom colors for the theme */
21
+ colors?: DebugConsoleColors;
22
+ /** Position of the floating button */
23
+ buttonPosition?: ButtonPosition;
24
+ /** Custom app name for sharing logs */
25
+ appName?: string;
26
+ /** Capture console.log (default: true) */
27
+ captureLog?: boolean;
28
+ /** Capture console.warn (default: true) */
29
+ captureWarn?: boolean;
30
+ /** Capture console.error (default: true) */
31
+ captureError?: boolean;
32
+ /** Capture console.info (default: true) */
33
+ captureInfo?: boolean;
34
+ }
35
+
36
+ export interface DebugConsoleColors {
37
+ /** Primary background color */
38
+ background?: string;
39
+ /** Card/surface background color */
40
+ surface?: string;
41
+ /** Primary text color */
42
+ text?: string;
43
+ /** Secondary text color */
44
+ textSecondary?: string;
45
+ /** Error color */
46
+ error?: string;
47
+ /** Warning color */
48
+ warning?: string;
49
+ /** Info color */
50
+ info?: string;
51
+ /** Log color */
52
+ log?: string;
53
+ /** Floating button background color */
54
+ buttonBackground?: string;
55
+ /** Floating button icon color */
56
+ buttonIcon?: string;
57
+ }
58
+
59
+ export interface ButtonPosition {
60
+ bottom?: number;
61
+ right?: number;
62
+ left?: number;
63
+ top?: number;
64
+ }
65
+
66
+ export interface DebugConsoleContextType {
67
+ logs: LogEntry[];
68
+ isVisible: boolean;
69
+ config: Required<DebugConsoleConfig>;
70
+ addLog: (type: LogType, message: string, data?: any) => void;
71
+ clearLogs: () => void;
72
+ toggleVisibility: () => void;
73
+ showConsole: () => void;
74
+ hideConsole: () => void;
75
+ }
76
+
77
+ /** Default configuration */
78
+ export const DEFAULT_CONFIG: Required<DebugConsoleConfig> = {
79
+ enabled: true,
80
+ maxLogs: 100,
81
+ appName: 'App',
82
+ captureLog: true,
83
+ captureWarn: true,
84
+ captureError: true,
85
+ captureInfo: true,
86
+ colors: {
87
+ background: '#1a1a2e',
88
+ surface: '#2a2a3e',
89
+ text: '#ffffff',
90
+ textSecondary: '#888888',
91
+ error: '#FF5252',
92
+ warning: '#FFD740',
93
+ info: '#40C4FF',
94
+ log: '#888888',
95
+ buttonBackground: '#FF6B6B',
96
+ buttonIcon: '#ffffff',
97
+ },
98
+ buttonPosition: {
99
+ bottom: 100,
100
+ right: 20,
101
+ },
102
+ };