@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/README.ar.md +193 -0
- package/README.md +288 -0
- package/dist/DebugButton.d.ts +7 -0
- package/dist/DebugButton.js +58 -0
- package/dist/DebugConsole.d.ts +58 -0
- package/dist/DebugConsole.js +70 -0
- package/dist/DebugOverlay.d.ts +7 -0
- package/dist/DebugOverlay.js +176 -0
- package/dist/DebugProvider.d.ts +20 -0
- package/dist/DebugProvider.js +139 -0
- package/dist/Icons.d.ts +43 -0
- package/dist/Icons.js +37 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +33 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.js +29 -0
- package/package.json +52 -0
- package/src/DebugButton.tsx +84 -0
- package/src/DebugConsole.tsx +112 -0
- package/src/DebugOverlay.tsx +310 -0
- package/src/DebugProvider.tsx +182 -0
- package/src/Icons.tsx +91 -0
- package/src/index.ts +46 -0
- package/src/types.ts +102 -0
package/README.ar.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# React Native Debug Console
|
|
2
|
+
|
|
3
|
+
وحدة تحكم تصحيح عائمة لتطبيقات React Native / Expo. تلتقط سجلات console والأخطاء والتحذيرات مع واجهة مستخدم جميلة.
|
|
4
|
+
|
|
5
|
+
مثالية لتصحيح أخطاء إصدارات الإنتاج ومشاركة السجلات مع فريقك.
|
|
6
|
+
|
|
7
|
+
## المميزات
|
|
8
|
+
|
|
9
|
+
- زر تصحيح عائم مع شارة عدد الأخطاء
|
|
10
|
+
- نافذة منبثقة كاملة الشاشة مع جميع السجلات الملتقطة
|
|
11
|
+
- إدخالات سجل ملونة (خطأ، تحذير، معلومات، سجل)
|
|
12
|
+
- وظيفة مشاركة السجلات
|
|
13
|
+
- ألوان وموضع قابل للتخصيص بالكامل
|
|
14
|
+
- دعم متغيرات البيئة للتفعيل/الإلغاء
|
|
15
|
+
- بدون تبعيات خارجية
|
|
16
|
+
- دعم TypeScript
|
|
17
|
+
- يعمل مع Expo و React Native
|
|
18
|
+
|
|
19
|
+
## التثبيت
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# باستخدام npm
|
|
23
|
+
npm install react-native-debug-console
|
|
24
|
+
|
|
25
|
+
# باستخدام yarn
|
|
26
|
+
yarn add react-native-debug-console
|
|
27
|
+
|
|
28
|
+
# باستخدام pnpm
|
|
29
|
+
pnpm add react-native-debug-console
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## البدء السريع
|
|
33
|
+
|
|
34
|
+
قم بتغليف تطبيقك بمكون `DebugConsole`:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { DebugConsole } from 'react-native-debug-console';
|
|
38
|
+
|
|
39
|
+
export default function App() {
|
|
40
|
+
return (
|
|
41
|
+
<DebugConsole>
|
|
42
|
+
<YourApp />
|
|
43
|
+
</DebugConsole>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
هذا كل شيء! سيظهر زر عائم في زاوية تطبيقك. اضغط عليه لرؤية جميع سجلات console.
|
|
49
|
+
|
|
50
|
+
## التكوين
|
|
51
|
+
|
|
52
|
+
### استخدام متغيرات البيئة
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { DebugConsole } from 'react-native-debug-console';
|
|
56
|
+
|
|
57
|
+
export default function App() {
|
|
58
|
+
return (
|
|
59
|
+
<DebugConsole
|
|
60
|
+
config={{
|
|
61
|
+
// تفعيل بناءً على متغير البيئة
|
|
62
|
+
enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
|
|
63
|
+
appName: 'تطبيقي',
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<YourApp />
|
|
67
|
+
</DebugConsole>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
في ملف `.env`:
|
|
73
|
+
|
|
74
|
+
```env
|
|
75
|
+
EXPO_PUBLIC_DEBUG=true
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### خيارات التكوين الكاملة
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { DebugConsole, DebugConsoleConfig } from 'react-native-debug-console';
|
|
82
|
+
|
|
83
|
+
const config: DebugConsoleConfig = {
|
|
84
|
+
// تفعيل أو إلغاء (الافتراضي: true)
|
|
85
|
+
enabled: true,
|
|
86
|
+
|
|
87
|
+
// الحد الأقصى للسجلات (الافتراضي: 100)
|
|
88
|
+
maxLogs: 100,
|
|
89
|
+
|
|
90
|
+
// اسم التطبيق للمشاركة (الافتراضي: 'App')
|
|
91
|
+
appName: 'تطبيقي',
|
|
92
|
+
|
|
93
|
+
// التقاط أنواع محددة من السجلات (الافتراضي: true للجميع)
|
|
94
|
+
captureLog: true,
|
|
95
|
+
captureWarn: true,
|
|
96
|
+
captureError: true,
|
|
97
|
+
captureInfo: true,
|
|
98
|
+
|
|
99
|
+
// ألوان مخصصة
|
|
100
|
+
colors: {
|
|
101
|
+
background: '#1a1a2e',
|
|
102
|
+
surface: '#2a2a3e',
|
|
103
|
+
text: '#ffffff',
|
|
104
|
+
textSecondary: '#888888',
|
|
105
|
+
error: '#FF5252',
|
|
106
|
+
warning: '#FFD740',
|
|
107
|
+
info: '#40C4FF',
|
|
108
|
+
log: '#888888',
|
|
109
|
+
buttonBackground: '#FF6B6B',
|
|
110
|
+
buttonIcon: '#ffffff',
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// موضع الزر
|
|
114
|
+
buttonPosition: {
|
|
115
|
+
bottom: 100,
|
|
116
|
+
right: 20,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default function App() {
|
|
121
|
+
return (
|
|
122
|
+
<DebugConsole config={config}>
|
|
123
|
+
<YourApp />
|
|
124
|
+
</DebugConsole>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## الاستخدام المتقدم
|
|
130
|
+
|
|
131
|
+
### استخدام HOC
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { withDebugConsole } from 'react-native-debug-console';
|
|
135
|
+
|
|
136
|
+
function App() {
|
|
137
|
+
return <YourApp />;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default withDebugConsole(App, {
|
|
141
|
+
enabled: __DEV__,
|
|
142
|
+
appName: 'تطبيقي',
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### التحكم اليدوي باستخدام Hook
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { DebugProvider, useDebugConsole, DebugButton, DebugOverlay } from 'react-native-debug-console';
|
|
150
|
+
|
|
151
|
+
function MyComponent() {
|
|
152
|
+
const { logs, showConsole, hideConsole, clearLogs, addLog } = useDebugConsole();
|
|
153
|
+
|
|
154
|
+
// إضافة سجل يدويًا
|
|
155
|
+
const handlePress = () => {
|
|
156
|
+
addLog('info', 'تم الضغط على الزر!');
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Button onPress={handlePress} title="اضغط هنا" />
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// في App.tsx
|
|
165
|
+
export default function App() {
|
|
166
|
+
return (
|
|
167
|
+
<DebugProvider config={{ enabled: true }}>
|
|
168
|
+
<YourApp />
|
|
169
|
+
<DebugButton />
|
|
170
|
+
<DebugOverlay />
|
|
171
|
+
</DebugProvider>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### إخفاء الزر العائم
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<DebugConsole showButton={false}>
|
|
180
|
+
<YourApp />
|
|
181
|
+
</DebugConsole>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## نصائح
|
|
185
|
+
|
|
186
|
+
1. **إصدارات الإنتاج**: اضبط `enabled: false` في الإنتاج، أو استخدم متغيرات البيئة
|
|
187
|
+
2. **الأداء**: تحتفظ وحدة التحكم بآخر 100 سجل فقط لمنع مشاكل الذاكرة
|
|
188
|
+
3. **المشاركة**: يمكن مشاركة السجلات عبر Share API للتصحيح السهل
|
|
189
|
+
4. **التنسيق المخصص**: جميع الألوان قابلة للتخصيص لتتناسب مع ثيم تطبيقك
|
|
190
|
+
|
|
191
|
+
## الترخيص
|
|
192
|
+
|
|
193
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# React Native Debug Console
|
|
2
|
+
|
|
3
|
+
A floating debug console for React Native / Expo apps. Captures console logs, errors, and warnings with a beautiful overlay UI.
|
|
4
|
+
|
|
5
|
+
Perfect for debugging production builds and sharing logs with your team.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Floating debug button with error count badge
|
|
10
|
+
- Full-screen modal console with all captured logs
|
|
11
|
+
- Color-coded log entries (error, warning, info, log)
|
|
12
|
+
- Share logs functionality
|
|
13
|
+
- Fully customizable colors and positioning
|
|
14
|
+
- Environment variable support for enabling/disabling
|
|
15
|
+
- Zero external dependencies (optional react-native-svg)
|
|
16
|
+
- TypeScript support
|
|
17
|
+
- Works with Expo and bare React Native
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Using npm
|
|
23
|
+
npm install react-native-debug-console
|
|
24
|
+
|
|
25
|
+
# Using yarn
|
|
26
|
+
yarn add react-native-debug-console
|
|
27
|
+
|
|
28
|
+
# Using pnpm
|
|
29
|
+
pnpm add react-native-debug-console
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Wrap your app with the `DebugConsole` component:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { DebugConsole } from 'react-native-debug-console';
|
|
38
|
+
|
|
39
|
+
export default function App() {
|
|
40
|
+
return (
|
|
41
|
+
<DebugConsole>
|
|
42
|
+
<YourApp />
|
|
43
|
+
</DebugConsole>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
That's it! A floating bug button will appear in the corner of your app. Tap it to see all console logs.
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
### Using Environment Variables
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { DebugConsole } from 'react-native-debug-console';
|
|
56
|
+
|
|
57
|
+
export default function App() {
|
|
58
|
+
return (
|
|
59
|
+
<DebugConsole
|
|
60
|
+
config={{
|
|
61
|
+
// Enable based on environment variable
|
|
62
|
+
enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
|
|
63
|
+
appName: 'MyApp',
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<YourApp />
|
|
67
|
+
</DebugConsole>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
In your `.env` file:
|
|
73
|
+
|
|
74
|
+
```env
|
|
75
|
+
EXPO_PUBLIC_DEBUG=true
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Full Configuration Options
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { DebugConsole, DebugConsoleConfig } from 'react-native-debug-console';
|
|
82
|
+
|
|
83
|
+
const config: DebugConsoleConfig = {
|
|
84
|
+
// Enable or disable (default: true)
|
|
85
|
+
enabled: true,
|
|
86
|
+
|
|
87
|
+
// Max logs to keep (default: 100)
|
|
88
|
+
maxLogs: 100,
|
|
89
|
+
|
|
90
|
+
// App name for sharing (default: 'App')
|
|
91
|
+
appName: 'MyApp',
|
|
92
|
+
|
|
93
|
+
// Capture specific log types (all default to true)
|
|
94
|
+
captureLog: true,
|
|
95
|
+
captureWarn: true,
|
|
96
|
+
captureError: true,
|
|
97
|
+
captureInfo: true,
|
|
98
|
+
|
|
99
|
+
// Custom colors
|
|
100
|
+
colors: {
|
|
101
|
+
background: '#1a1a2e',
|
|
102
|
+
surface: '#2a2a3e',
|
|
103
|
+
text: '#ffffff',
|
|
104
|
+
textSecondary: '#888888',
|
|
105
|
+
error: '#FF5252',
|
|
106
|
+
warning: '#FFD740',
|
|
107
|
+
info: '#40C4FF',
|
|
108
|
+
log: '#888888',
|
|
109
|
+
buttonBackground: '#FF6B6B',
|
|
110
|
+
buttonIcon: '#ffffff',
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// Button position
|
|
114
|
+
buttonPosition: {
|
|
115
|
+
bottom: 100,
|
|
116
|
+
right: 20,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default function App() {
|
|
121
|
+
return (
|
|
122
|
+
<DebugConsole config={config}>
|
|
123
|
+
<YourApp />
|
|
124
|
+
</DebugConsole>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Advanced Usage
|
|
130
|
+
|
|
131
|
+
### Using HOC (Higher-Order Component)
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { withDebugConsole } from 'react-native-debug-console';
|
|
135
|
+
|
|
136
|
+
function App() {
|
|
137
|
+
return <YourApp />;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default withDebugConsole(App, {
|
|
141
|
+
enabled: __DEV__,
|
|
142
|
+
appName: 'MyApp',
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Manual Control with Hook
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { DebugProvider, useDebugConsole, DebugButton, DebugOverlay } from 'react-native-debug-console';
|
|
150
|
+
|
|
151
|
+
function MyComponent() {
|
|
152
|
+
const { logs, showConsole, hideConsole, clearLogs, addLog } = useDebugConsole();
|
|
153
|
+
|
|
154
|
+
// Manually add a log
|
|
155
|
+
const handlePress = () => {
|
|
156
|
+
addLog('info', 'Button pressed!');
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Button onPress={handlePress} title="Press me" />
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// In your App.tsx
|
|
165
|
+
export default function App() {
|
|
166
|
+
return (
|
|
167
|
+
<DebugProvider config={{ enabled: true }}>
|
|
168
|
+
<YourApp />
|
|
169
|
+
<DebugButton />
|
|
170
|
+
<DebugOverlay />
|
|
171
|
+
</DebugProvider>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Hide Floating Button
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<DebugConsole showButton={false}>
|
|
180
|
+
<YourApp />
|
|
181
|
+
</DebugConsole>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Custom Button or Overlay
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { DebugConsole, useDebugConsole } from 'react-native-debug-console';
|
|
188
|
+
|
|
189
|
+
const CustomButton = () => {
|
|
190
|
+
const { toggleVisibility, logs } = useDebugConsole();
|
|
191
|
+
const errorCount = logs.filter(l => l.type === 'error').length;
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<TouchableOpacity onPress={toggleVisibility}>
|
|
195
|
+
<Text>Debug ({errorCount} errors)</Text>
|
|
196
|
+
</TouchableOpacity>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export default function App() {
|
|
201
|
+
return (
|
|
202
|
+
<DebugConsole customButton={CustomButton}>
|
|
203
|
+
<YourApp />
|
|
204
|
+
</DebugConsole>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## API Reference
|
|
210
|
+
|
|
211
|
+
### Components
|
|
212
|
+
|
|
213
|
+
| Component | Description |
|
|
214
|
+
|-----------|-------------|
|
|
215
|
+
| `DebugConsole` | Main wrapper component |
|
|
216
|
+
| `DebugProvider` | Context provider (for manual setup) |
|
|
217
|
+
| `DebugButton` | Floating action button |
|
|
218
|
+
| `DebugOverlay` | Full-screen log viewer modal |
|
|
219
|
+
|
|
220
|
+
### Hooks
|
|
221
|
+
|
|
222
|
+
| Hook | Description |
|
|
223
|
+
|------|-------------|
|
|
224
|
+
| `useDebugConsole()` | Access debug context (throws if not in provider) |
|
|
225
|
+
| `useDebugConsoleOptional()` | Access debug context (returns null if not in provider) |
|
|
226
|
+
|
|
227
|
+
### Context Values (from useDebugConsole)
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
interface DebugConsoleContextType {
|
|
231
|
+
logs: LogEntry[];
|
|
232
|
+
isVisible: boolean;
|
|
233
|
+
config: DebugConsoleConfig;
|
|
234
|
+
addLog: (type: LogType, message: string, data?: any) => void;
|
|
235
|
+
clearLogs: () => void;
|
|
236
|
+
toggleVisibility: () => void;
|
|
237
|
+
showConsole: () => void;
|
|
238
|
+
hideConsole: () => void;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Types
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
type LogType = 'log' | 'warn' | 'error' | 'info';
|
|
246
|
+
|
|
247
|
+
interface LogEntry {
|
|
248
|
+
id: string;
|
|
249
|
+
timestamp: Date;
|
|
250
|
+
type: LogType;
|
|
251
|
+
message: string;
|
|
252
|
+
data?: any;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Environment Variables for Expo
|
|
257
|
+
|
|
258
|
+
Add to your `.env` file:
|
|
259
|
+
|
|
260
|
+
```env
|
|
261
|
+
# Enable debug console
|
|
262
|
+
EXPO_PUBLIC_DEBUG=true
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Then use in your app:
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
<DebugConsole
|
|
269
|
+
config={{
|
|
270
|
+
enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
|
|
271
|
+
}}
|
|
272
|
+
>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Tips
|
|
276
|
+
|
|
277
|
+
1. **Production builds**: Set `enabled: false` in production, or use environment variables
|
|
278
|
+
2. **Performance**: The console keeps only the last 100 logs by default to prevent memory issues
|
|
279
|
+
3. **Sharing**: Logs can be shared via the native Share API for easy debugging
|
|
280
|
+
4. **Custom styling**: All colors are customizable to match your app's theme
|
|
281
|
+
|
|
282
|
+
## License
|
|
283
|
+
|
|
284
|
+
MIT
|
|
285
|
+
|
|
286
|
+
## Contributing
|
|
287
|
+
|
|
288
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* React Native Debug Console - Floating Button
|
|
4
|
+
* A floating action button that shows error count and toggles the debug console
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { TouchableOpacity, View, Text, StyleSheet, } from 'react-native';
|
|
8
|
+
import { useDebugConsole } from './DebugProvider';
|
|
9
|
+
import { DebugIcon } from './Icons';
|
|
10
|
+
export const DebugButton = () => {
|
|
11
|
+
const { toggleVisibility, logs, config } = useDebugConsole();
|
|
12
|
+
if (!config.enabled)
|
|
13
|
+
return null;
|
|
14
|
+
const errorCount = logs.filter(l => l.type === 'error').length;
|
|
15
|
+
const position = config.buttonPosition;
|
|
16
|
+
const colors = config.colors;
|
|
17
|
+
return (_jsxs(TouchableOpacity, { style: [
|
|
18
|
+
styles.floatingButton,
|
|
19
|
+
{ backgroundColor: colors.buttonBackground },
|
|
20
|
+
position.bottom !== undefined && { bottom: position.bottom },
|
|
21
|
+
position.top !== undefined && { top: position.top },
|
|
22
|
+
position.right !== undefined && { right: position.right },
|
|
23
|
+
position.left !== undefined && { left: position.left },
|
|
24
|
+
], onPress: toggleVisibility, activeOpacity: 0.8, children: [_jsx(DebugIcon, { name: "bug", size: 20, color: colors.buttonIcon }), errorCount > 0 && (_jsx(View, { style: styles.errorBadge, children: _jsx(Text, { style: [styles.errorBadgeText, { color: colors.buttonBackground }], children: errorCount > 9 ? '9+' : errorCount }) }))] }));
|
|
25
|
+
};
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
floatingButton: {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
width: 50,
|
|
30
|
+
height: 50,
|
|
31
|
+
borderRadius: 25,
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
elevation: 5,
|
|
35
|
+
shadowColor: '#000',
|
|
36
|
+
shadowOffset: { width: 0, height: 2 },
|
|
37
|
+
shadowOpacity: 0.3,
|
|
38
|
+
shadowRadius: 4,
|
|
39
|
+
zIndex: 9999,
|
|
40
|
+
},
|
|
41
|
+
errorBadge: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
top: -4,
|
|
44
|
+
right: -4,
|
|
45
|
+
backgroundColor: '#fff',
|
|
46
|
+
borderRadius: 10,
|
|
47
|
+
minWidth: 20,
|
|
48
|
+
height: 20,
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
paddingHorizontal: 4,
|
|
52
|
+
},
|
|
53
|
+
errorBadgeText: {
|
|
54
|
+
fontSize: 11,
|
|
55
|
+
fontWeight: 'bold',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export default DebugButton;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native Debug Console - Main Component
|
|
3
|
+
* All-in-one wrapper that provides the debug console functionality
|
|
4
|
+
*/
|
|
5
|
+
import React, { ReactNode } from 'react';
|
|
6
|
+
import { DebugConsoleConfig } from './types';
|
|
7
|
+
interface DebugConsoleProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Configuration options */
|
|
10
|
+
config?: DebugConsoleConfig;
|
|
11
|
+
/** Show the floating button (default: true) */
|
|
12
|
+
showButton?: boolean;
|
|
13
|
+
/** Custom floating button component */
|
|
14
|
+
customButton?: React.ComponentType;
|
|
15
|
+
/** Custom overlay component */
|
|
16
|
+
customOverlay?: React.ComponentType;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* DebugConsole - Main wrapper component
|
|
20
|
+
*
|
|
21
|
+
* Wrap your app with this component to enable debug console functionality.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { DebugConsole } from 'react-native-debug-console';
|
|
26
|
+
*
|
|
27
|
+
* export default function App() {
|
|
28
|
+
* return (
|
|
29
|
+
* <DebugConsole
|
|
30
|
+
* config={{
|
|
31
|
+
* enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
|
|
32
|
+
* appName: 'MyApp',
|
|
33
|
+
* }}
|
|
34
|
+
* >
|
|
35
|
+
* <YourApp />
|
|
36
|
+
* </DebugConsole>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const DebugConsole: React.FC<DebugConsoleProps>;
|
|
42
|
+
/**
|
|
43
|
+
* withDebugConsole - HOC to wrap any component with debug console
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { withDebugConsole } from 'react-native-debug-console';
|
|
48
|
+
*
|
|
49
|
+
* const App = () => <YourApp />;
|
|
50
|
+
*
|
|
51
|
+
* export default withDebugConsole(App, {
|
|
52
|
+
* enabled: __DEV__,
|
|
53
|
+
* appName: 'MyApp',
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function withDebugConsole<P extends object>(WrappedComponent: React.ComponentType<P>, config?: DebugConsoleConfig): React.FC<P>;
|
|
58
|
+
export default DebugConsole;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* React Native Debug Console - Main Component
|
|
4
|
+
* All-in-one wrapper that provides the debug console functionality
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { View, StyleSheet } from 'react-native';
|
|
8
|
+
import { DebugProvider } from './DebugProvider';
|
|
9
|
+
import { DebugOverlay } from './DebugOverlay';
|
|
10
|
+
import { DebugButton } from './DebugButton';
|
|
11
|
+
/**
|
|
12
|
+
* DebugConsole - Main wrapper component
|
|
13
|
+
*
|
|
14
|
+
* Wrap your app with this component to enable debug console functionality.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { DebugConsole } from 'react-native-debug-console';
|
|
19
|
+
*
|
|
20
|
+
* export default function App() {
|
|
21
|
+
* return (
|
|
22
|
+
* <DebugConsole
|
|
23
|
+
* config={{
|
|
24
|
+
* enabled: process.env.EXPO_PUBLIC_DEBUG === 'true',
|
|
25
|
+
* appName: 'MyApp',
|
|
26
|
+
* }}
|
|
27
|
+
* >
|
|
28
|
+
* <YourApp />
|
|
29
|
+
* </DebugConsole>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const DebugConsole = ({ children, config, showButton = true, customButton: CustomButton, customOverlay: CustomOverlay, }) => {
|
|
35
|
+
// If disabled, just render children without any debug UI
|
|
36
|
+
if (config?.enabled === false) {
|
|
37
|
+
return _jsx(_Fragment, { children: children });
|
|
38
|
+
}
|
|
39
|
+
const ButtonComponent = CustomButton || DebugButton;
|
|
40
|
+
const OverlayComponent = CustomOverlay || DebugOverlay;
|
|
41
|
+
return (_jsx(DebugProvider, { config: config, children: _jsxs(View, { style: styles.container, children: [children, showButton && _jsx(ButtonComponent, {}), _jsx(OverlayComponent, {})] }) }));
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* withDebugConsole - HOC to wrap any component with debug console
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* import { withDebugConsole } from 'react-native-debug-console';
|
|
49
|
+
*
|
|
50
|
+
* const App = () => <YourApp />;
|
|
51
|
+
*
|
|
52
|
+
* export default withDebugConsole(App, {
|
|
53
|
+
* enabled: __DEV__,
|
|
54
|
+
* appName: 'MyApp',
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function withDebugConsole(WrappedComponent, config) {
|
|
59
|
+
const WithDebugConsole = (props) => {
|
|
60
|
+
return (_jsx(DebugConsole, { config: config, children: _jsx(WrappedComponent, { ...props }) }));
|
|
61
|
+
};
|
|
62
|
+
WithDebugConsole.displayName = `WithDebugConsole(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
63
|
+
return WithDebugConsole;
|
|
64
|
+
}
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
container: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
export default DebugConsole;
|