react-native-debug-toolkit 0.2.0 → 0.2.1

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.
@@ -5,26 +5,40 @@ const originalConsole = {}; // Store original console methods
5
5
  const _interceptConsole = () => {
6
6
  const levels = ['log', 'info', 'warn', 'error'];
7
7
  levels.forEach(level => {
8
- if (typeof console[level] === 'function') { // Check if it's actually a function
9
- originalConsole[level] = console[level]; // Store original
8
+ if (typeof console[level] === 'function') {
9
+ originalConsole[level] = console[level]; // Store original (still useful for restoration)
10
10
 
11
11
  console[level] = (...args) => {
12
- // Call original console method first
13
- originalConsole[level].apply(console, args); // Use apply for proper context
14
-
15
- // Add log entry
12
+ // --- Log Recording Logic ---
16
13
  if (logs.length >= MAX_LOGS) {
17
- logs.shift(); // Remove the oldest log if limit is reached
14
+ logs.shift();
18
15
  }
19
-
20
- // Store log data
16
+ // Optional: Process arguments for safer storage (recommended)
17
+ const processedArgs = args.map(arg => {
18
+ if (arg instanceof Error) return `Error: ${arg.message}${arg.stack ? `\n${arg.stack}` : ''}`;
19
+ if (arg instanceof Promise) return '[Promise]';
20
+ if (typeof arg === 'function') return '[Function]';
21
+ if (typeof arg === 'object' && arg !== null) {
22
+ try { return JSON.stringify(arg); } catch (e) { return '[Object - Cannot Serialize]'; }
23
+ }
24
+ return arg;
25
+ });
21
26
  logs.push({
22
27
  timestamp: new Date(),
23
28
  level: level,
24
- data: args, // Store all arguments passed to console[level]
29
+ data: processedArgs, // Store processed args
25
30
  });
31
+ // --- End Log Recording Logic ---
32
+
33
+ // --- Do NOT call the original console ---
34
+ // By omitting the following line, the intercepted log message (including
35
+ // the "Unhandled Promise Rejection" warning) will ONLY be stored
36
+ // in this feature's 'logs' array and will NOT be passed through
37
+ // to the standard developer console output (Metro, browser, etc.).
38
+ //
39
+ // originalConsole[level]?.apply(console, args);
26
40
 
27
- // TODO: Notify UI if needed
41
+ // TODO: Notify UI if needed (based on the stored log)
28
42
  };
29
43
  }
30
44
  });
@@ -8,8 +8,8 @@ import {
8
8
  Dimensions,
9
9
  Pressable,
10
10
  SafeAreaView,
11
- Settings,
12
11
  } from 'react-native'
12
+ // import AsyncStorage from '@react-native-async-storage/async-storage'
13
13
  import { IconRadius, DebugColors } from '../utils/DebugConst'
14
14
  import SubViewHTTPLogs from './SubViewHTTPLogs'
15
15
  import SubViewPerformance from './SubViewPerformance'
@@ -85,20 +85,20 @@ export default class FloatPanelView extends Component {
85
85
 
86
86
  async componentDidMount() {
87
87
  try {
88
- const savedPosition = Settings.get('@debug_toolkit_position')
88
+ // const savedPosition = await AsyncStorage.getItem('@debug_toolkit_position')
89
89
 
90
- if (savedPosition) {
91
- const position = JSON.parse(savedPosition)
90
+ // if (savedPosition) {
91
+ // const position = JSON.parse(savedPosition)
92
92
 
93
- // Ensure position is within bounds
94
- const boundedPosition = {
95
- x: Math.max(0, Math.min(position.x, screenWidth - IconRadius)),
96
- y: Math.max(0, Math.min(position.y, screenHeight - IconRadius)),
97
- }
93
+ // // Ensure position is within bounds
94
+ // const boundedPosition = {
95
+ // x: Math.max(0, Math.min(position.x, screenWidth - IconRadius)),
96
+ // y: Math.max(0, Math.min(position.y, screenHeight - IconRadius)),
97
+ // }
98
98
 
99
- this.setState({ lastPosition: boundedPosition })
100
- this.state.pan.setValue(boundedPosition)
101
- }
99
+ // this.setState({ lastPosition: boundedPosition })
100
+ // this.state.pan.setValue(boundedPosition)
101
+ // }
102
102
  } catch (error) {
103
103
  console.error('Failed to load debug toolkit position:', error)
104
104
  }
@@ -156,9 +156,7 @@ export default class FloatPanelView extends Component {
156
156
 
157
157
  // Save position
158
158
  try {
159
- Settings.set({
160
- '@debug_toolkit_position': JSON.stringify(newPosition),
161
- })
159
+ // await AsyncStorage.setItem('@debug_toolkit_position', JSON.stringify(newPosition))
162
160
  } catch (error) {
163
161
  console.error('Failed to save debug toolkit position:', error)
164
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-debug-toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A simple yet powerful debugging toolkit for React Native with a convenient floating UI for development",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,9 +23,10 @@
23
23
  "author": "zcj",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "react-native-root-siblings": "^4.0.0",
26
+ "@react-native-async-storage/async-storage": "^2.1.2",
27
27
  "react-native-json-tree": "^1.5.0",
28
- "react-native-performance": "5.1.2"
28
+ "react-native-performance": "5.1.2",
29
+ "react-native-root-siblings": "^4.0.0"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": "*",