react-native-debug-toolkit 0.5.1 → 0.5.2
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/index.js +10 -1
- package/lib/DebugToolKit.js +25 -2
- package/lib/views/FloatPanelView.js +81 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12,6 +12,14 @@ import { createZustandLogFeature, addZustandLog } from './lib/features/ZustandLo
|
|
|
12
12
|
import { createNavigationLogFeature, addNavigationLog } from './lib/features/NavigationLogFeature'
|
|
13
13
|
import { useNavigationLogger } from './lib/hooks/useNavigationLogger'
|
|
14
14
|
|
|
15
|
+
// Function to clear all logs and close the panel
|
|
16
|
+
const clearAll = () => {
|
|
17
|
+
const instance = DebugToolKit.instance;
|
|
18
|
+
if (instance && typeof instance.clearAll === 'function') {
|
|
19
|
+
instance.clearAll();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
15
23
|
export {
|
|
16
24
|
DebugToolKit,
|
|
17
25
|
initializeDebugToolkit,
|
|
@@ -23,7 +31,8 @@ export {
|
|
|
23
31
|
createNavigationLogFeature,
|
|
24
32
|
addNavigationLog,
|
|
25
33
|
useNavigationLogger,
|
|
26
|
-
isDebugMode
|
|
34
|
+
isDebugMode,
|
|
35
|
+
clearAll
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
export default DebugToolKit
|
package/lib/DebugToolKit.js
CHANGED
|
@@ -53,6 +53,21 @@ export default class DebugToolKit {
|
|
|
53
53
|
return this
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
|
|
57
|
+
clearAll = () => {
|
|
58
|
+
// Clear all logs from all features
|
|
59
|
+
this.features.forEach((feature) => {
|
|
60
|
+
if (typeof feature.cleanup === 'function') {
|
|
61
|
+
feature.cleanup();
|
|
62
|
+
}
|
|
63
|
+
// Re-setup the feature to initialize it again
|
|
64
|
+
if (typeof feature.setup === 'function') {
|
|
65
|
+
feature.setup();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
showDebugPanel = () => {
|
|
57
72
|
if (!this.isDebugMode) {
|
|
58
73
|
return
|
|
@@ -60,7 +75,11 @@ export default class DebugToolKit {
|
|
|
60
75
|
|
|
61
76
|
if (!this.floatPanel) {
|
|
62
77
|
this.floatPanel = new RootSiblings(
|
|
63
|
-
<FloatPanelView
|
|
78
|
+
<FloatPanelView
|
|
79
|
+
features={this.features}
|
|
80
|
+
close={this.hideDebugPanel}
|
|
81
|
+
clearAll={this.clearAll}
|
|
82
|
+
/>,
|
|
64
83
|
)
|
|
65
84
|
}
|
|
66
85
|
this.isPanelVisible = true
|
|
@@ -76,7 +95,11 @@ export default class DebugToolKit {
|
|
|
76
95
|
updateDebugPanel() {
|
|
77
96
|
if (this.floatPanel) {
|
|
78
97
|
this.floatPanel.update(
|
|
79
|
-
<FloatPanelView
|
|
98
|
+
<FloatPanelView
|
|
99
|
+
features={this.features}
|
|
100
|
+
close={this.hideDebugPanel}
|
|
101
|
+
clearAll={this.clearAll}
|
|
102
|
+
/>,
|
|
80
103
|
)
|
|
81
104
|
}
|
|
82
105
|
}
|
|
@@ -387,6 +387,8 @@ export default class FloatPanelView extends Component {
|
|
|
387
387
|
|
|
388
388
|
renderPanel() {
|
|
389
389
|
const { isOpen, panelTranslateY, backdropOpacity } = this.state
|
|
390
|
+
const { clearAll } = this.props
|
|
391
|
+
|
|
390
392
|
|
|
391
393
|
if (!isOpen) {
|
|
392
394
|
return null
|
|
@@ -414,10 +416,23 @@ export default class FloatPanelView extends Component {
|
|
|
414
416
|
</View>
|
|
415
417
|
<SafeAreaView style={styles.panelContent}>
|
|
416
418
|
<View style={styles.header}>
|
|
417
|
-
<Text style={styles.headerTitle}>Debug
|
|
418
|
-
<
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
<Text style={styles.headerTitle}>Debug Toolkit</Text>
|
|
420
|
+
<View style={styles.headerButtons}>
|
|
421
|
+
{clearAll && (
|
|
422
|
+
<TouchableOpacity
|
|
423
|
+
onPress={() => {
|
|
424
|
+
clearAll()
|
|
425
|
+
this._closePanel()
|
|
426
|
+
}}
|
|
427
|
+
style={[styles.clearButton, styles.clearAllButton]}
|
|
428
|
+
>
|
|
429
|
+
<Text style={styles.clearButtonText}>Clear & Close</Text>
|
|
430
|
+
</TouchableOpacity>
|
|
431
|
+
)}
|
|
432
|
+
<Pressable onPress={this._closePanel} style={styles.closeButton}>
|
|
433
|
+
<Text style={styles.closeButtonText}>×</Text>
|
|
434
|
+
</Pressable>
|
|
435
|
+
</View>
|
|
421
436
|
</View>
|
|
422
437
|
|
|
423
438
|
{this.renderTabBar()}
|
|
@@ -531,23 +546,77 @@ const styles = StyleSheet.create({
|
|
|
531
546
|
flexDirection: 'row',
|
|
532
547
|
justifyContent: 'space-between',
|
|
533
548
|
alignItems: 'center',
|
|
534
|
-
paddingHorizontal:
|
|
535
|
-
|
|
549
|
+
paddingHorizontal: 15,
|
|
550
|
+
paddingVertical: 12,
|
|
536
551
|
borderBottomWidth: 1,
|
|
537
|
-
borderBottomColor:
|
|
552
|
+
borderBottomColor: '#e5e5e5',
|
|
553
|
+
backgroundColor: '#f9f9f9',
|
|
554
|
+
shadowColor: "#000",
|
|
555
|
+
shadowOffset: {
|
|
556
|
+
width: 0,
|
|
557
|
+
height: 1,
|
|
558
|
+
},
|
|
559
|
+
shadowOpacity: 0.1,
|
|
560
|
+
shadowRadius: 1.5,
|
|
561
|
+
elevation: 1,
|
|
538
562
|
},
|
|
539
563
|
headerTitle: {
|
|
540
564
|
fontSize: 18,
|
|
541
|
-
fontWeight: '
|
|
542
|
-
color:
|
|
565
|
+
fontWeight: '700',
|
|
566
|
+
color: '#2c3e50',
|
|
567
|
+
},
|
|
568
|
+
headerButtons: {
|
|
569
|
+
flexDirection: 'row',
|
|
570
|
+
alignItems: 'center',
|
|
571
|
+
},
|
|
572
|
+
clearButton: {
|
|
573
|
+
backgroundColor: DebugColors.blue,
|
|
574
|
+
paddingHorizontal: 10,
|
|
575
|
+
paddingVertical: 5,
|
|
576
|
+
borderRadius: 4,
|
|
577
|
+
marginRight: 10,
|
|
578
|
+
},
|
|
579
|
+
clearAllButton: {
|
|
580
|
+
backgroundColor: '#3498db',
|
|
581
|
+
paddingHorizontal: 14,
|
|
582
|
+
paddingVertical: 9,
|
|
583
|
+
borderRadius: 6,
|
|
584
|
+
marginRight: 12,
|
|
585
|
+
shadowColor: "#000",
|
|
586
|
+
shadowOffset: {
|
|
587
|
+
width: 0,
|
|
588
|
+
height: 1,
|
|
589
|
+
},
|
|
590
|
+
shadowOpacity: 0.12,
|
|
591
|
+
shadowRadius: 1,
|
|
592
|
+
elevation: 2,
|
|
593
|
+
},
|
|
594
|
+
clearButtonText: {
|
|
595
|
+
color: '#fff',
|
|
596
|
+
fontSize: 13,
|
|
597
|
+
fontWeight: '600',
|
|
543
598
|
},
|
|
544
599
|
closeButton: {
|
|
545
|
-
|
|
600
|
+
width: 30,
|
|
601
|
+
height: 30,
|
|
602
|
+
borderRadius: 15,
|
|
603
|
+
backgroundColor: '#ecf0f1',
|
|
604
|
+
alignItems: 'center',
|
|
605
|
+
justifyContent: 'center',
|
|
606
|
+
shadowColor: "#000",
|
|
607
|
+
shadowOffset: {
|
|
608
|
+
width: 0,
|
|
609
|
+
height: 1,
|
|
610
|
+
},
|
|
611
|
+
shadowOpacity: 0.1,
|
|
612
|
+
shadowRadius: 1,
|
|
613
|
+
elevation: 1,
|
|
546
614
|
},
|
|
547
615
|
closeButtonText: {
|
|
548
|
-
fontSize:
|
|
549
|
-
color: DebugColors.text,
|
|
616
|
+
fontSize: 20,
|
|
550
617
|
fontWeight: 'bold',
|
|
618
|
+
color: '#34495e',
|
|
619
|
+
lineHeight: 20,
|
|
551
620
|
},
|
|
552
621
|
tabBarContainer: {
|
|
553
622
|
borderBottomWidth: 1,
|
package/package.json
CHANGED