dreaction-react-native 1.7.2 → 1.8.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.md +490 -0
- package/lib/components/OverlayImage.d.ts +3 -0
- package/lib/components/OverlayImage.d.ts.map +1 -0
- package/lib/components/OverlayImage.js +75 -0
- package/lib/dreaction.d.ts +3 -0
- package/lib/dreaction.d.ts.map +1 -1
- package/lib/dreaction.js +6 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/plugins/networking.js +1 -1
- package/lib/plugins/overlay/index.d.ts +7 -2
- package/lib/plugins/overlay/index.d.ts.map +1 -1
- package/lib/plugins/overlay/index.js +4 -9
- package/lib/plugins/overlay/overlay.d.ts +5 -158
- package/lib/plugins/overlay/overlay.d.ts.map +1 -1
- package/lib/plugins/overlay/overlay.js +20 -95
- package/lib/plugins/overlay.d.ts +8 -0
- package/lib/plugins/overlay.d.ts.map +1 -0
- package/lib/plugins/overlay.js +25 -0
- package/package.json +22 -5
- package/src/components/OverlayImage.tsx +56 -0
- package/src/dreaction.ts +8 -0
- package/src/index.ts +2 -0
- package/src/plugins/networking.ts +1 -1
- package/src/plugins/overlay.ts +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
# DReaction React Native
|
|
2
|
+
|
|
3
|
+
DReaction client library for React Native applications with powerful debugging tools and built-in UI components.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- 🟠 **Draggable Debug Ball** - Visual debug interface that can be moved anywhere on screen
|
|
8
|
+
- 📜 **Logs & Network Monitoring** - Track console logs and network requests in real-time
|
|
9
|
+
- 🔍 **Data Watcher** - Monitor React state changes in real-time
|
|
10
|
+
- ⚡ **Custom Commands** - Execute custom debugging commands remotely
|
|
11
|
+
- 📈 **Performance Monitor** - Track app performance metrics
|
|
12
|
+
- 💾 **AsyncStorage Tracking** - Monitor all AsyncStorage operations
|
|
13
|
+
- 🎯 **Error Tracking** - Capture unhandled errors and promise rejections
|
|
14
|
+
- 📱 **Platform Agnostic** - Works on both iOS and Android
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install dreaction-react-native @react-native-async-storage/async-storage
|
|
20
|
+
# or
|
|
21
|
+
yarn add dreaction-react-native @react-native-async-storage/async-storage
|
|
22
|
+
# or
|
|
23
|
+
pnpm add dreaction-react-native @react-native-async-storage/async-storage
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Prerequisites
|
|
27
|
+
|
|
28
|
+
DReaction requires the DReaction desktop application to be running. Download it from:
|
|
29
|
+
|
|
30
|
+
[https://github.com/moonrailgun/dreaction/releases](https://github.com/moonrailgun/dreaction/releases)
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Setup DReaction
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { dreaction } from 'dreaction-react-native';
|
|
38
|
+
|
|
39
|
+
dreaction
|
|
40
|
+
.configure({
|
|
41
|
+
host: 'YOUR_COMPUTER_IP', // e.g., '192.168.1.100'
|
|
42
|
+
port: 9600,
|
|
43
|
+
name: 'My React Native App',
|
|
44
|
+
})
|
|
45
|
+
.useReactNative() // Enable all plugins
|
|
46
|
+
.connect();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Add the Draggable Debug Ball
|
|
50
|
+
|
|
51
|
+
The draggable ball provides quick access to connection settings and debug features:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { DraggableBall } from 'dreaction-react-native';
|
|
55
|
+
|
|
56
|
+
export default function App() {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<YourApp />
|
|
60
|
+
{__DEV__ && <DraggableBall />}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The draggable ball can be moved anywhere on screen and provides:
|
|
67
|
+
- Quick connection status indicator
|
|
68
|
+
- Access to configuration dialog
|
|
69
|
+
- One-tap connect/disconnect
|
|
70
|
+
|
|
71
|
+
## Components
|
|
72
|
+
|
|
73
|
+
### DraggableBall
|
|
74
|
+
|
|
75
|
+
A floating button that can be dragged anywhere on the screen. Perfect for production testing and QA.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { DraggableBall } from 'dreaction-react-native';
|
|
79
|
+
|
|
80
|
+
<DraggableBall />
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Features:**
|
|
84
|
+
- Draggable to any position on screen
|
|
85
|
+
- Visual connection status indicator
|
|
86
|
+
- Opens configuration dialog on tap
|
|
87
|
+
- Automatically saves position
|
|
88
|
+
|
|
89
|
+
### ConfigDialog
|
|
90
|
+
|
|
91
|
+
A configuration dialog for connection settings. Usually opened via DraggableBall.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { ConfigDialog } from 'dreaction-react-native';
|
|
95
|
+
|
|
96
|
+
<ConfigDialog
|
|
97
|
+
visible={visible}
|
|
98
|
+
onClose={() => setVisible(false)}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Plugins
|
|
103
|
+
|
|
104
|
+
DReaction React Native comes with comprehensive built-in plugins:
|
|
105
|
+
|
|
106
|
+
### 1. **Networking Plugin**
|
|
107
|
+
Intercepts and monitors all network requests including fetch and XMLHttpRequest.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
dreaction.useReactNative({
|
|
111
|
+
networking: {
|
|
112
|
+
ignoreUrls: /analytics|tracking/,
|
|
113
|
+
ignoreContentTypes: /image|video/,
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 2. **AsyncStorage Plugin**
|
|
119
|
+
Tracks all AsyncStorage operations (getItem, setItem, removeItem, clear).
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
dreaction.useReactNative({
|
|
123
|
+
asyncStorage: {
|
|
124
|
+
ignore: ['some-key-to-ignore']
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3. **Console Logs Plugin**
|
|
130
|
+
Captures all console methods (log, warn, error, debug, info).
|
|
131
|
+
|
|
132
|
+
### 4. **Global Errors Plugin**
|
|
133
|
+
Catches unhandled errors and promise rejections with stack traces.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
dreaction.useReactNative({
|
|
137
|
+
errors: {
|
|
138
|
+
veto: (frame) => {
|
|
139
|
+
// Return true to ignore this error
|
|
140
|
+
return frame.file?.includes('node_modules');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 5. **DevTools Plugin**
|
|
147
|
+
Enables React DevTools integration and debugging features.
|
|
148
|
+
|
|
149
|
+
### 6. **Open In Editor Plugin**
|
|
150
|
+
Allows opening files directly in your code editor from error stacks.
|
|
151
|
+
|
|
152
|
+
## Plugin Configuration
|
|
153
|
+
|
|
154
|
+
### Enable All Plugins (Recommended)
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
dreaction.useReactNative(); // Uses default settings for all plugins
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Customize Plugin Settings
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
dreaction.useReactNative({
|
|
164
|
+
// Enable/disable error tracking
|
|
165
|
+
errors: true, // or provide options
|
|
166
|
+
|
|
167
|
+
// Enable/disable console logging
|
|
168
|
+
log: true,
|
|
169
|
+
|
|
170
|
+
// Configure AsyncStorage monitoring
|
|
171
|
+
asyncStorage: {
|
|
172
|
+
ignore: ['IGNORED_KEY']
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
// Configure network monitoring
|
|
176
|
+
networking: {
|
|
177
|
+
ignoreUrls: /analytics/,
|
|
178
|
+
ignoreContentTypes: /image/,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
// DevTools integration
|
|
182
|
+
devTools: true,
|
|
183
|
+
|
|
184
|
+
// Open in editor support
|
|
185
|
+
openInEditor: true,
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Disable Specific Plugins
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
dreaction.useReactNative({
|
|
193
|
+
errors: false, // Disable error tracking
|
|
194
|
+
log: false, // Disable console logging
|
|
195
|
+
asyncStorage: false, // Disable AsyncStorage monitoring
|
|
196
|
+
networking: false, // Disable network monitoring
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Data Watchers
|
|
201
|
+
|
|
202
|
+
Monitor React Native state in real-time:
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { dreaction } from 'dreaction-react-native';
|
|
206
|
+
|
|
207
|
+
// Register a data watcher
|
|
208
|
+
export const { useDebugDataWatch: useDebugUserInfo } =
|
|
209
|
+
dreaction.registerDataWatcher('userInfo', 'json');
|
|
210
|
+
|
|
211
|
+
// Use in your component
|
|
212
|
+
function UserProfile() {
|
|
213
|
+
const [user, setUser] = useState({ name: 'John', age: 30 });
|
|
214
|
+
|
|
215
|
+
// This will send updates to DReaction desktop app
|
|
216
|
+
useDebugUserInfo(user);
|
|
217
|
+
|
|
218
|
+
return <Text>{user.name}</Text>;
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Data Watch Types
|
|
223
|
+
|
|
224
|
+
- `'text'` - Display as plain text
|
|
225
|
+
- `'json'` - Display as formatted JSON (best for objects)
|
|
226
|
+
- `'list'` - Display as a list
|
|
227
|
+
|
|
228
|
+
### Example: Watching Multiple Values
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// Register multiple watchers
|
|
232
|
+
const { useDebugDataWatch: useDebugCounter } =
|
|
233
|
+
dreaction.registerDataWatcher('counter', 'text');
|
|
234
|
+
|
|
235
|
+
const { useDebugDataWatch: useDebugState } =
|
|
236
|
+
dreaction.registerDataWatcher('appState', 'json');
|
|
237
|
+
|
|
238
|
+
function MyComponent() {
|
|
239
|
+
const [count, setCount] = useState(0);
|
|
240
|
+
const [state, setState] = useState({ loading: false, data: [] });
|
|
241
|
+
|
|
242
|
+
useDebugCounter(count);
|
|
243
|
+
useDebugState(state);
|
|
244
|
+
|
|
245
|
+
// Your component logic...
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Custom Commands
|
|
250
|
+
|
|
251
|
+
Register commands that can be triggered remotely from the DReaction desktop app:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
// Simple command
|
|
255
|
+
dreaction.registerCustomCommand({
|
|
256
|
+
title: 'Clear Cache',
|
|
257
|
+
command: 'clearCache',
|
|
258
|
+
description: 'Clear all cached data',
|
|
259
|
+
handler: async () => {
|
|
260
|
+
await AsyncStorage.clear();
|
|
261
|
+
return 'Cache cleared successfully!';
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Command with arguments
|
|
266
|
+
dreaction.registerCustomCommand({
|
|
267
|
+
title: 'Set Environment',
|
|
268
|
+
command: 'setEnv',
|
|
269
|
+
description: 'Switch environment',
|
|
270
|
+
args: [
|
|
271
|
+
{
|
|
272
|
+
name: 'environment',
|
|
273
|
+
type: 'string',
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
handler: async (args) => {
|
|
277
|
+
console.log('Switching to:', args.environment);
|
|
278
|
+
// Switch environment logic...
|
|
279
|
+
return `Environment set to: ${args.environment}`;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// Command with multiple arguments
|
|
284
|
+
dreaction.registerCustomCommand({
|
|
285
|
+
title: 'Mock User Login',
|
|
286
|
+
command: 'mockLogin',
|
|
287
|
+
description: 'Login as a test user',
|
|
288
|
+
args: [
|
|
289
|
+
{ name: 'userId', type: 'string' },
|
|
290
|
+
{ name: 'role', type: 'string' },
|
|
291
|
+
],
|
|
292
|
+
handler: async (args) => {
|
|
293
|
+
// Mock login logic...
|
|
294
|
+
return `Logged in as ${args.userId} with role ${args.role}`;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Performance Monitoring
|
|
300
|
+
|
|
301
|
+
DReaction automatically tracks performance metrics when connected:
|
|
302
|
+
|
|
303
|
+
- JavaScript thread FPS
|
|
304
|
+
- UI thread FPS
|
|
305
|
+
- Memory usage
|
|
306
|
+
- Bridge calls
|
|
307
|
+
|
|
308
|
+
Access these metrics in real-time through the DReaction desktop app.
|
|
309
|
+
|
|
310
|
+
## Connection Setup
|
|
311
|
+
|
|
312
|
+
### Finding Your Computer's IP Address
|
|
313
|
+
|
|
314
|
+
**macOS/Linux:**
|
|
315
|
+
```bash
|
|
316
|
+
ifconfig | grep "inet "
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Windows:**
|
|
320
|
+
```bash
|
|
321
|
+
ipconfig
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Look for your local network IP (usually starts with `192.168.` or `10.`).
|
|
325
|
+
|
|
326
|
+
### Example Setup
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// utils/dreaction.ts
|
|
330
|
+
import { dreaction } from 'dreaction-react-native';
|
|
331
|
+
|
|
332
|
+
dreaction
|
|
333
|
+
.configure({
|
|
334
|
+
host: '192.168.1.100', // Your computer's IP
|
|
335
|
+
port: 9600, // Default DReaction port
|
|
336
|
+
info: {
|
|
337
|
+
appName: 'My App',
|
|
338
|
+
version: '1.0.0',
|
|
339
|
+
},
|
|
340
|
+
})
|
|
341
|
+
.useReactNative();
|
|
342
|
+
|
|
343
|
+
export { dreaction };
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
// App.tsx
|
|
348
|
+
import { DraggableBall } from 'dreaction-react-native';
|
|
349
|
+
import './utils/dreaction'; // Initialize DReaction
|
|
350
|
+
|
|
351
|
+
export default function App() {
|
|
352
|
+
return (
|
|
353
|
+
<>
|
|
354
|
+
<YourAppContent />
|
|
355
|
+
{__DEV__ && <DraggableBall />}
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## API Reference
|
|
362
|
+
|
|
363
|
+
### `dreaction.useReactNative(options?)`
|
|
364
|
+
|
|
365
|
+
Enable React Native plugins with optional configuration.
|
|
366
|
+
|
|
367
|
+
**Parameters:**
|
|
368
|
+
- `options.errors` - Error tracking options or boolean
|
|
369
|
+
- `options.log` - Enable console logging (boolean)
|
|
370
|
+
- `options.asyncStorage` - AsyncStorage monitoring options or boolean
|
|
371
|
+
- `options.networking` - Network monitoring options or boolean
|
|
372
|
+
- `options.devTools` - Enable DevTools integration (boolean)
|
|
373
|
+
- `options.openInEditor` - Enable open in editor feature (boolean)
|
|
374
|
+
|
|
375
|
+
**Returns:** `dreaction` instance (chainable)
|
|
376
|
+
|
|
377
|
+
### `dreaction.configure(options)`
|
|
378
|
+
|
|
379
|
+
Configure DReaction client settings.
|
|
380
|
+
|
|
381
|
+
**Parameters:**
|
|
382
|
+
- `options.host` - Server host (e.g., '192.168.1.100')
|
|
383
|
+
- `options.port` - Server port (default: 9600)
|
|
384
|
+
- `options.name` - Application name
|
|
385
|
+
- `options.info` - Additional info object
|
|
386
|
+
|
|
387
|
+
**Returns:** `dreaction` instance (chainable)
|
|
388
|
+
|
|
389
|
+
### `dreaction.connect()`
|
|
390
|
+
|
|
391
|
+
Connect to DReaction server and activate all plugins.
|
|
392
|
+
|
|
393
|
+
**Returns:** `dreaction` instance (chainable)
|
|
394
|
+
|
|
395
|
+
### `dreaction.close()`
|
|
396
|
+
|
|
397
|
+
Disconnect from server and deactivate plugins.
|
|
398
|
+
|
|
399
|
+
**Returns:** `dreaction` instance (chainable)
|
|
400
|
+
|
|
401
|
+
### `dreaction.registerDataWatcher(name, type, options?)`
|
|
402
|
+
|
|
403
|
+
Register a data watcher for monitoring React Native state.
|
|
404
|
+
|
|
405
|
+
**Parameters:**
|
|
406
|
+
- `name` - Watcher identifier
|
|
407
|
+
- `type` - Display type ('text' | 'json' | 'list')
|
|
408
|
+
- `options.enabled` - Enable/disable watcher (default: true in development)
|
|
409
|
+
|
|
410
|
+
**Returns:** Object with `useDebugDataWatch` hook
|
|
411
|
+
|
|
412
|
+
### `dreaction.registerCustomCommand(config)`
|
|
413
|
+
|
|
414
|
+
Register a custom command.
|
|
415
|
+
|
|
416
|
+
**Parameters:**
|
|
417
|
+
- `config.title` - Command title
|
|
418
|
+
- `config.command` - Command identifier
|
|
419
|
+
- `config.description` - Command description
|
|
420
|
+
- `config.args` - Array of argument definitions
|
|
421
|
+
- `config.handler` - Async handler function
|
|
422
|
+
|
|
423
|
+
**Returns:** Unregister function
|
|
424
|
+
|
|
425
|
+
## Best Practices
|
|
426
|
+
|
|
427
|
+
1. **Only Enable in Development**
|
|
428
|
+
```tsx
|
|
429
|
+
{__DEV__ && <DraggableBall />}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
2. **Use Descriptive Watcher Names**
|
|
433
|
+
```typescript
|
|
434
|
+
dreaction.registerDataWatcher('user-profile', 'json');
|
|
435
|
+
dreaction.registerDataWatcher('cart-items-count', 'text');
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
3. **Filter Sensitive Data**
|
|
439
|
+
```typescript
|
|
440
|
+
dreaction.useReactNative({
|
|
441
|
+
asyncStorage: {
|
|
442
|
+
ignore: ['auth-token', 'user-password']
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
4. **Optimize Network Monitoring**
|
|
448
|
+
```typescript
|
|
449
|
+
dreaction.useReactNative({
|
|
450
|
+
networking: {
|
|
451
|
+
ignoreUrls: /\.jpg|\.png|\.gif/,
|
|
452
|
+
ignoreContentTypes: /^image\//,
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Troubleshooting
|
|
458
|
+
|
|
459
|
+
### Cannot Connect to Server
|
|
460
|
+
|
|
461
|
+
1. Ensure DReaction desktop app is running
|
|
462
|
+
2. Verify your computer's IP address is correct
|
|
463
|
+
3. Check that your device and computer are on the same network
|
|
464
|
+
4. For Android, ensure port 9600 is not blocked
|
|
465
|
+
|
|
466
|
+
### Draggable Ball Not Showing
|
|
467
|
+
|
|
468
|
+
1. Make sure it's only rendered in development: `{__DEV__ && <DraggableBall />}`
|
|
469
|
+
2. Check that it's not hidden behind other components (it has `zIndex: 999999`)
|
|
470
|
+
3. Verify DReaction is properly configured before rendering the ball
|
|
471
|
+
|
|
472
|
+
### Network Requests Not Showing
|
|
473
|
+
|
|
474
|
+
1. Ensure networking plugin is enabled
|
|
475
|
+
2. Check if URLs are being filtered by `ignoreUrls` pattern
|
|
476
|
+
3. Verify the connection is established before making requests
|
|
477
|
+
|
|
478
|
+
## Example
|
|
479
|
+
|
|
480
|
+
Check out the complete example in the `example/expo-app/` directory of the DReaction repository.
|
|
481
|
+
|
|
482
|
+
## License
|
|
483
|
+
|
|
484
|
+
MIT
|
|
485
|
+
|
|
486
|
+
## Links
|
|
487
|
+
|
|
488
|
+
- [GitHub Repository](https://github.com/moonrailgun/dreaction)
|
|
489
|
+
- [DReaction Desktop App Releases](https://github.com/moonrailgun/dreaction/releases)
|
|
490
|
+
- [Report Issues](https://github.com/moonrailgun/dreaction/issues)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayImage.d.ts","sourceRoot":"","sources":["../../src/components/OverlayImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAkD/B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OverlayImage = void 0;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const react_native_1 = require("react-native");
|
|
40
|
+
const overlay_1 = require("../plugins/overlay");
|
|
41
|
+
exports.OverlayImage = react_1.default.memo(() => {
|
|
42
|
+
const [uri, setUri] = (0, react_1.useState)(null);
|
|
43
|
+
const [opacity, setOpacity] = (0, react_1.useState)(0.5);
|
|
44
|
+
(0, react_1.useEffect)(() => {
|
|
45
|
+
const handler = (payload) => {
|
|
46
|
+
setUri(payload.uri);
|
|
47
|
+
if (payload.opacity !== undefined) {
|
|
48
|
+
setOpacity(payload.opacity);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
overlay_1.emitter.on('overlay', handler);
|
|
52
|
+
return () => {
|
|
53
|
+
overlay_1.emitter.off('overlay', handler);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
if (!uri) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const { width, height } = react_native_1.Dimensions.get('window');
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: "none", style: {
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
top: 0,
|
|
63
|
+
left: 0,
|
|
64
|
+
width: width,
|
|
65
|
+
height: height,
|
|
66
|
+
}, children: (0, jsx_runtime_1.jsx)(react_native_1.Image, { source: { uri: uri }, resizeMode: "contain", style: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
top: 0,
|
|
69
|
+
left: 0,
|
|
70
|
+
width: width,
|
|
71
|
+
height: height,
|
|
72
|
+
opacity: opacity,
|
|
73
|
+
} }) }));
|
|
74
|
+
});
|
|
75
|
+
exports.OverlayImage.displayName = 'OverlayImage';
|
package/lib/dreaction.d.ts
CHANGED
|
@@ -5,12 +5,15 @@ import { OpenInEditorOptions } from './plugins/openInEditor';
|
|
|
5
5
|
import { TrackGlobalErrorsOptions } from './plugins/trackGlobalErrors';
|
|
6
6
|
import { NetworkingOptions } from './plugins/networking';
|
|
7
7
|
import { DataWatchPayload } from 'dreaction-protocol';
|
|
8
|
+
import overlay from './plugins/overlay';
|
|
8
9
|
export type { ClientOptions };
|
|
10
|
+
export { overlay };
|
|
9
11
|
export declare const reactNativeCorePlugins: any[];
|
|
10
12
|
export interface UseReactNativeOptions {
|
|
11
13
|
errors?: TrackGlobalErrorsOptions | boolean;
|
|
12
14
|
log?: boolean;
|
|
13
15
|
editor?: OpenInEditorOptions | boolean;
|
|
16
|
+
overlay?: boolean;
|
|
14
17
|
asyncStorage?: AsyncStorageOptions | boolean;
|
|
15
18
|
networking?: NetworkingOptions | boolean;
|
|
16
19
|
devTools?: boolean;
|
package/lib/dreaction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dreaction.d.ts","sourceRoot":"","sources":["../src/dreaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EAExB,SAAS,EACT,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAA0B,EACxB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"dreaction.d.ts","sourceRoot":"","sources":["../src/dreaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EAExB,SAAS,EACT,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAA0B,EACxB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,CAAC;AAMnB,eAAO,MAAM,sBAAsB,OAOO,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,KAAK,yBAAyB,GAAG,wBAAwB,CACvD,aAAa,EACb,OAAO,sBAAsB,CAC9B,CAAC;AAEF,MAAM,WAAW,oBACf,SAAQ,SAAS,EAEf,yBAAyB;IAC3B,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1D,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,sBAAsB,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnE,mBAAmB,EAAE,CAAC,CAAC,GAAG,OAAO,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KACE;QACH,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;QACjC,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;QAC1C,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;KAC9C,CAAC;CACH;AAkFD,eAAO,MAAM,SAAS,sBAA+C,CAAC;AA6FtE,wBAAgB,QAAQ,eAMvB"}
|
package/lib/dreaction.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.dreaction = exports.reactNativeCorePlugins = void 0;
|
|
6
|
+
exports.dreaction = exports.reactNativeCorePlugins = exports.overlay = void 0;
|
|
7
7
|
exports.watchFPS = watchFPS;
|
|
8
8
|
const react_native_1 = require("react-native");
|
|
9
9
|
const dreaction_client_core_1 = require("dreaction-client-core");
|
|
@@ -19,6 +19,8 @@ const getReactNativePlatformConstants_1 = __importDefault(require("./helpers/get
|
|
|
19
19
|
const react_1 = require("react");
|
|
20
20
|
const getHost_1 = require("./helpers/getHost");
|
|
21
21
|
const common_1 = require("./helpers/common");
|
|
22
|
+
const overlay_1 = __importDefault(require("./plugins/overlay"));
|
|
23
|
+
exports.overlay = overlay_1.default;
|
|
22
24
|
const DREACTION_ASYNC_CLIENT_ID = '@DREACTION/clientId';
|
|
23
25
|
let tempClientId = null;
|
|
24
26
|
exports.reactNativeCorePlugins = [
|
|
@@ -100,6 +102,9 @@ exports.dreaction.useReactNative = (options = {}) => {
|
|
|
100
102
|
if (options.editor !== false) {
|
|
101
103
|
exports.dreaction.use((0, openInEditor_1.default)(getPluginOptions(options.editor)));
|
|
102
104
|
}
|
|
105
|
+
if (options.overlay !== false) {
|
|
106
|
+
exports.dreaction.use((0, overlay_1.default)());
|
|
107
|
+
}
|
|
103
108
|
if (options.asyncStorage !== false) {
|
|
104
109
|
exports.dreaction.use((0, asyncStorage_1.default)(getPluginOptions(options.asyncStorage)));
|
|
105
110
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type { Command } from 'dreaction-protocol';
|
|
2
2
|
import { DraggableBall } from './components/DraggableBall';
|
|
3
3
|
import { Profiler } from './components/Profiler';
|
|
4
|
+
import { OverlayImage } from './components/OverlayImage';
|
|
4
5
|
export { DraggableBall as DReactionDraggableBall };
|
|
6
|
+
export { OverlayImage as DReactionOverlayImage };
|
|
5
7
|
export { Profiler as DReactionProfiler };
|
|
6
8
|
export * from './dreaction';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AACnD,OAAO,EAAE,YAAY,IAAI,qBAAqB,EAAE,CAAC;AACjD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,CAAC;AAEzC,cAAc,aAAa,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DReactionProfiler = exports.DReactionDraggableBall = void 0;
|
|
17
|
+
exports.DReactionProfiler = exports.DReactionOverlayImage = exports.DReactionDraggableBall = void 0;
|
|
18
18
|
const DraggableBall_1 = require("./components/DraggableBall");
|
|
19
19
|
Object.defineProperty(exports, "DReactionDraggableBall", { enumerable: true, get: function () { return DraggableBall_1.DraggableBall; } });
|
|
20
20
|
const Profiler_1 = require("./components/Profiler");
|
|
21
21
|
Object.defineProperty(exports, "DReactionProfiler", { enumerable: true, get: function () { return Profiler_1.Profiler; } });
|
|
22
|
+
const OverlayImage_1 = require("./components/OverlayImage");
|
|
23
|
+
Object.defineProperty(exports, "DReactionOverlayImage", { enumerable: true, get: function () { return OverlayImage_1.OverlayImage; } });
|
|
22
24
|
__exportStar(require("./dreaction"), exports);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export declare const emitter: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
|
|
2
|
+
export default function OverlayCreator(): () => {
|
|
3
|
+
/**
|
|
4
|
+
* Fires when any Reactotron message arrives.
|
|
5
|
+
*/
|
|
6
|
+
onCommand: (command: import("dreaction-protocol").Command) => void;
|
|
7
|
+
};
|
|
3
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAAS,CAAC;AAE9B,MAAM,CAAC,OAAO,UAAU,cAAc;IAGhC;;OAEG;;EAQR"}
|
|
@@ -3,26 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emitter = void 0;
|
|
6
7
|
exports.default = OverlayCreator;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_native_1 = require("react-native");
|
|
9
8
|
const mitt_1 = __importDefault(require("mitt"));
|
|
10
|
-
|
|
9
|
+
exports.emitter = (0, mitt_1.default)();
|
|
11
10
|
function OverlayCreator() {
|
|
12
11
|
return function overlay() {
|
|
13
|
-
const emitter = (0, mitt_1.default)();
|
|
14
12
|
return {
|
|
15
13
|
/**
|
|
16
14
|
* Fires when any Reactotron message arrives.
|
|
17
15
|
*/
|
|
18
16
|
onCommand: (command) => {
|
|
19
|
-
if (command.type !==
|
|
17
|
+
if (command.type !== 'overlay')
|
|
20
18
|
return;
|
|
21
19
|
// relay this payload on to the emitter
|
|
22
|
-
emitter.emit(
|
|
23
|
-
},
|
|
24
|
-
features: {
|
|
25
|
-
overlay: (WrappedComponent) => (props = {}) => ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(WrappedComponent, { ...props }), (0, jsx_runtime_1.jsx)(overlay_1.default, { emitter: emitter })] })),
|
|
20
|
+
exports.emitter.emit('overlay', command.payload);
|
|
26
21
|
},
|
|
27
22
|
};
|
|
28
23
|
};
|
|
@@ -1,161 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
emitter: any;
|
|
5
|
-
}
|
|
6
|
-
interface State {
|
|
7
|
-
opacity: AnimatableNumericValue;
|
|
8
|
-
uri: string;
|
|
9
|
-
justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
10
|
-
alignItems: FlexAlignType;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
growToWindow?: boolean;
|
|
14
|
-
resizeMode?: ImageResizeMode;
|
|
15
|
-
marginLeft?: number;
|
|
16
|
-
marginRight?: number;
|
|
17
|
-
marginTop?: number;
|
|
18
|
-
marginBottom?: number;
|
|
19
|
-
showDebug?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/** An overlay for showing an image to help with layout.
|
|
22
|
-
*
|
|
23
|
-
* @class FullScreenOverlay
|
|
24
|
-
* @extends {Component}
|
|
25
|
-
*/
|
|
26
|
-
declare class FullScreenOverlay extends Component<Props, State> {
|
|
27
|
-
constructor(props: Props);
|
|
28
|
-
createContainerStyle(): {
|
|
29
|
-
opacity: AnimatableNumericValue;
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
justifyContent: "center" | "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
33
|
-
alignItems: FlexAlignType;
|
|
34
|
-
backfaceVisibility?: "visible" | "hidden" | undefined;
|
|
35
|
-
backgroundColor?: import("react-native").ColorValue | undefined;
|
|
36
|
-
borderBlockColor?: import("react-native").ColorValue | undefined;
|
|
37
|
-
borderBlockEndColor?: import("react-native").ColorValue | undefined;
|
|
38
|
-
borderBlockStartColor?: import("react-native").ColorValue | undefined;
|
|
39
|
-
borderBottomColor?: import("react-native").ColorValue | undefined;
|
|
40
|
-
borderBottomEndRadius?: AnimatableNumericValue | string | undefined;
|
|
41
|
-
borderBottomLeftRadius?: AnimatableNumericValue | string | undefined;
|
|
42
|
-
borderBottomRightRadius?: AnimatableNumericValue | string | undefined;
|
|
43
|
-
borderBottomStartRadius?: AnimatableNumericValue | string | undefined;
|
|
44
|
-
borderColor?: import("react-native").ColorValue | undefined;
|
|
45
|
-
borderCurve?: "circular" | "continuous" | undefined;
|
|
46
|
-
borderEndColor?: import("react-native").ColorValue | undefined;
|
|
47
|
-
borderEndEndRadius?: AnimatableNumericValue | string | undefined;
|
|
48
|
-
borderEndStartRadius?: AnimatableNumericValue | string | undefined;
|
|
49
|
-
borderLeftColor?: import("react-native").ColorValue | undefined;
|
|
50
|
-
borderRadius?: AnimatableNumericValue | string | undefined;
|
|
51
|
-
borderRightColor?: import("react-native").ColorValue | undefined;
|
|
52
|
-
borderStartColor?: import("react-native").ColorValue | undefined;
|
|
53
|
-
borderStartEndRadius?: AnimatableNumericValue | string | undefined;
|
|
54
|
-
borderStartStartRadius?: AnimatableNumericValue | string | undefined;
|
|
55
|
-
borderStyle?: "solid" | "dotted" | "dashed" | undefined;
|
|
56
|
-
borderTopColor?: import("react-native").ColorValue | undefined;
|
|
57
|
-
borderTopEndRadius?: AnimatableNumericValue | string | undefined;
|
|
58
|
-
borderTopLeftRadius?: AnimatableNumericValue | string | undefined;
|
|
59
|
-
borderTopRightRadius?: AnimatableNumericValue | string | undefined;
|
|
60
|
-
borderTopStartRadius?: AnimatableNumericValue | string | undefined;
|
|
61
|
-
elevation?: number | undefined;
|
|
62
|
-
pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
|
|
63
|
-
isolation?: "auto" | "isolate" | undefined;
|
|
64
|
-
cursor?: import("react-native").CursorValue | undefined;
|
|
65
|
-
boxShadow?: ReadonlyArray<import("react-native").BoxShadowValue> | string | undefined;
|
|
66
|
-
filter?: ReadonlyArray<import("react-native").FilterFunction> | string | undefined;
|
|
67
|
-
alignContent?: "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
|
68
|
-
alignSelf?: "auto" | FlexAlignType | undefined;
|
|
69
|
-
aspectRatio?: number | string | undefined;
|
|
70
|
-
borderBottomWidth?: number | undefined;
|
|
71
|
-
borderEndWidth?: number | undefined;
|
|
72
|
-
borderLeftWidth?: number | undefined;
|
|
73
|
-
borderRightWidth?: number | undefined;
|
|
74
|
-
borderStartWidth?: number | undefined;
|
|
75
|
-
borderTopWidth?: number | undefined;
|
|
76
|
-
borderWidth?: number | undefined;
|
|
77
|
-
bottom?: import("react-native").DimensionValue | undefined;
|
|
78
|
-
display?: "none" | "flex" | undefined;
|
|
79
|
-
end?: import("react-native").DimensionValue | undefined;
|
|
80
|
-
flex?: number | undefined;
|
|
81
|
-
flexBasis?: import("react-native").DimensionValue | undefined;
|
|
82
|
-
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" | undefined;
|
|
83
|
-
rowGap?: number | string | undefined;
|
|
84
|
-
gap?: number | string | undefined;
|
|
85
|
-
columnGap?: number | string | undefined;
|
|
86
|
-
flexGrow?: number | undefined;
|
|
87
|
-
flexShrink?: number | undefined;
|
|
88
|
-
flexWrap?: "wrap" | "nowrap" | "wrap-reverse" | undefined;
|
|
89
|
-
left?: import("react-native").DimensionValue | undefined;
|
|
90
|
-
margin?: import("react-native").DimensionValue | undefined;
|
|
91
|
-
marginBottom?: import("react-native").DimensionValue | undefined;
|
|
92
|
-
marginEnd?: import("react-native").DimensionValue | undefined;
|
|
93
|
-
marginHorizontal?: import("react-native").DimensionValue | undefined;
|
|
94
|
-
marginLeft?: import("react-native").DimensionValue | undefined;
|
|
95
|
-
marginRight?: import("react-native").DimensionValue | undefined;
|
|
96
|
-
marginStart?: import("react-native").DimensionValue | undefined;
|
|
97
|
-
marginTop?: import("react-native").DimensionValue | undefined;
|
|
98
|
-
marginVertical?: import("react-native").DimensionValue | undefined;
|
|
99
|
-
maxHeight?: import("react-native").DimensionValue | undefined;
|
|
100
|
-
maxWidth?: import("react-native").DimensionValue | undefined;
|
|
101
|
-
minHeight?: import("react-native").DimensionValue | undefined;
|
|
102
|
-
minWidth?: import("react-native").DimensionValue | undefined;
|
|
103
|
-
overflow?: "visible" | "hidden" | "scroll" | undefined;
|
|
104
|
-
padding?: import("react-native").DimensionValue | undefined;
|
|
105
|
-
paddingBottom?: import("react-native").DimensionValue | undefined;
|
|
106
|
-
paddingEnd?: import("react-native").DimensionValue | undefined;
|
|
107
|
-
paddingHorizontal?: import("react-native").DimensionValue | undefined;
|
|
108
|
-
paddingLeft?: import("react-native").DimensionValue | undefined;
|
|
109
|
-
paddingRight?: import("react-native").DimensionValue | undefined;
|
|
110
|
-
paddingStart?: import("react-native").DimensionValue | undefined;
|
|
111
|
-
paddingTop?: import("react-native").DimensionValue | undefined;
|
|
112
|
-
paddingVertical?: import("react-native").DimensionValue | undefined;
|
|
113
|
-
position?: "absolute" | "relative" | "static" | undefined;
|
|
114
|
-
right?: import("react-native").DimensionValue | undefined;
|
|
115
|
-
start?: import("react-native").DimensionValue | undefined;
|
|
116
|
-
top?: import("react-native").DimensionValue | undefined;
|
|
117
|
-
zIndex?: number | undefined;
|
|
118
|
-
direction?: "inherit" | "ltr" | "rtl" | undefined;
|
|
119
|
-
inset?: import("react-native").DimensionValue | undefined;
|
|
120
|
-
insetBlock?: import("react-native").DimensionValue | undefined;
|
|
121
|
-
insetBlockEnd?: import("react-native").DimensionValue | undefined;
|
|
122
|
-
insetBlockStart?: import("react-native").DimensionValue | undefined;
|
|
123
|
-
insetInline?: import("react-native").DimensionValue | undefined;
|
|
124
|
-
insetInlineEnd?: import("react-native").DimensionValue | undefined;
|
|
125
|
-
insetInlineStart?: import("react-native").DimensionValue | undefined;
|
|
126
|
-
marginBlock?: import("react-native").DimensionValue | undefined;
|
|
127
|
-
marginBlockEnd?: import("react-native").DimensionValue | undefined;
|
|
128
|
-
marginBlockStart?: import("react-native").DimensionValue | undefined;
|
|
129
|
-
marginInline?: import("react-native").DimensionValue | undefined;
|
|
130
|
-
marginInlineEnd?: import("react-native").DimensionValue | undefined;
|
|
131
|
-
marginInlineStart?: import("react-native").DimensionValue | undefined;
|
|
132
|
-
paddingBlock?: import("react-native").DimensionValue | undefined;
|
|
133
|
-
paddingBlockEnd?: import("react-native").DimensionValue | undefined;
|
|
134
|
-
paddingBlockStart?: import("react-native").DimensionValue | undefined;
|
|
135
|
-
paddingInline?: import("react-native").DimensionValue | undefined;
|
|
136
|
-
paddingInlineEnd?: import("react-native").DimensionValue | undefined;
|
|
137
|
-
paddingInlineStart?: import("react-native").DimensionValue | undefined;
|
|
138
|
-
shadowColor?: import("react-native").ColorValue | undefined;
|
|
139
|
-
shadowOffset?: Readonly<{
|
|
140
|
-
width: number;
|
|
141
|
-
height: number;
|
|
142
|
-
}> | undefined;
|
|
143
|
-
shadowOpacity?: AnimatableNumericValue | undefined;
|
|
144
|
-
shadowRadius?: number | undefined;
|
|
145
|
-
transform?: Readonly<import("react-native").MaximumOneOf<import("react-native").PerspectiveTransform & import("react-native").RotateTransform & import("react-native").RotateXTransform & import("react-native").RotateYTransform & import("react-native").RotateZTransform & import("react-native").ScaleTransform & import("react-native").ScaleXTransform & import("react-native").ScaleYTransform & import("react-native").TranslateXTransform & import("react-native").TranslateYTransform & import("react-native").SkewXTransform & import("react-native").SkewYTransform & import("react-native").MatrixTransform>[]> | string | undefined;
|
|
146
|
-
transformOrigin?: Array<string | number> | string | undefined;
|
|
147
|
-
transformMatrix?: Array<number> | undefined;
|
|
148
|
-
rotation?: AnimatableNumericValue | undefined;
|
|
149
|
-
scaleX?: AnimatableNumericValue | undefined;
|
|
150
|
-
scaleY?: AnimatableNumericValue | undefined;
|
|
151
|
-
translateX?: AnimatableNumericValue | undefined;
|
|
152
|
-
translateY?: AnimatableNumericValue | undefined;
|
|
153
|
-
};
|
|
154
|
-
renderDebug(): import("react/jsx-runtime").JSX.Element | null;
|
|
1
|
+
export declare const emitter: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
|
|
2
|
+
export default function OverlayCreator(): () => {
|
|
155
3
|
/**
|
|
156
|
-
*
|
|
4
|
+
* Fires when any Reactotron message arrives.
|
|
157
5
|
*/
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
export default FullScreenOverlay;
|
|
6
|
+
onCommand: (command: import("dreaction-protocol").Command) => void;
|
|
7
|
+
};
|
|
161
8
|
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/overlay.
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/overlay.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAAS,CAAC;AAE9B,MAAM,CAAC,OAAO,UAAU,cAAc;IAGhC;;OAEG;;EAQR"}
|
|
@@ -1,99 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const react_native_1 = require("react-native");
|
|
6
|
-
const Styles = {
|
|
7
|
-
container: {
|
|
8
|
-
position: "absolute",
|
|
9
|
-
left: 0,
|
|
10
|
-
top: 0,
|
|
11
|
-
right: 0,
|
|
12
|
-
bottom: 0,
|
|
13
|
-
zIndex: 1000,
|
|
14
|
-
opacity: 0.25,
|
|
15
|
-
},
|
|
16
|
-
debugContainer: {
|
|
17
|
-
position: "absolute",
|
|
18
|
-
top: 0,
|
|
19
|
-
left: 0,
|
|
20
|
-
right: 0,
|
|
21
|
-
bottom: 0,
|
|
22
|
-
justifyContent: "center",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
backgroundColor: "transparent",
|
|
25
|
-
zIndex: 2000,
|
|
26
|
-
},
|
|
27
|
-
debugTextContainer: {
|
|
28
|
-
backgroundColor: "lightgray",
|
|
29
|
-
margin: 50,
|
|
30
|
-
padding: 20,
|
|
31
|
-
},
|
|
32
|
-
debugText: {
|
|
33
|
-
color: "red",
|
|
34
|
-
fontSize: 16,
|
|
35
|
-
marginBottom: 10,
|
|
36
|
-
},
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
createContainerStyle() {
|
|
58
|
-
const { opacity, justifyContent, alignItems } = this.state;
|
|
59
|
-
const { width, height } = react_native_1.Dimensions.get("window");
|
|
60
|
-
const containerStyle = {
|
|
61
|
-
...Styles.container,
|
|
62
|
-
opacity,
|
|
63
|
-
width,
|
|
64
|
-
height,
|
|
65
|
-
justifyContent,
|
|
66
|
-
alignItems,
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emitter = void 0;
|
|
7
|
+
exports.default = OverlayCreator;
|
|
8
|
+
const mitt_1 = __importDefault(require("mitt"));
|
|
9
|
+
exports.emitter = (0, mitt_1.default)();
|
|
10
|
+
function OverlayCreator() {
|
|
11
|
+
return function overlay() {
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* Fires when any Reactotron message arrives.
|
|
15
|
+
*/
|
|
16
|
+
onCommand: (command) => {
|
|
17
|
+
if (command.type !== 'overlay')
|
|
18
|
+
return;
|
|
19
|
+
// relay this payload on to the emitter
|
|
20
|
+
exports.emitter.emit('overlay', command.payload);
|
|
21
|
+
},
|
|
67
22
|
};
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
renderDebug() {
|
|
71
|
-
const { showDebug } = this.state;
|
|
72
|
-
// If Reactotron is configured properly it should be disabled in production.
|
|
73
|
-
// We'll throw a __DEV__ check in here just in case it get's feisty.
|
|
74
|
-
if (!__DEV__ || !showDebug)
|
|
75
|
-
return null;
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: Styles.debugContainer, pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: Styles.debugTextContainer, children: Object.keys(this.state).map((key) => {
|
|
77
|
-
if (key === "showDebug")
|
|
78
|
-
return null;
|
|
79
|
-
const keyName = key === "uri" ? "have image" : key;
|
|
80
|
-
const value = key === "uri" ? !!this.state[key] : this.state[key];
|
|
81
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: Styles.debugText, children: `${keyName}: ${value}` }, key));
|
|
82
|
-
}) }) }));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Draw.
|
|
86
|
-
*/
|
|
87
|
-
render() {
|
|
88
|
-
const { uri, width, height, growToWindow, resizeMode, marginLeft = 0, marginRight = 0, marginTop = 0, marginBottom = 0, } = this.state;
|
|
89
|
-
const imageStyle = { width, height, marginTop, marginRight, marginBottom, marginLeft };
|
|
90
|
-
if (growToWindow) {
|
|
91
|
-
const windowSize = react_native_1.Dimensions.get("window");
|
|
92
|
-
imageStyle.width = windowSize.width;
|
|
93
|
-
imageStyle.height = windowSize.height;
|
|
94
|
-
}
|
|
95
|
-
const image = uri ? ((0, jsx_runtime_1.jsx)(react_native_1.Image, { source: { uri }, style: imageStyle, resizeMode: growToWindow ? resizeMode : null })) : ((0, jsx_runtime_1.jsx)(react_native_1.View, {}));
|
|
96
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: this.createContainerStyle(), pointerEvents: "none", children: image }), this.renderDebug()] }));
|
|
97
|
-
}
|
|
23
|
+
};
|
|
98
24
|
}
|
|
99
|
-
exports.default = FullScreenOverlay;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const emitter: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
|
|
2
|
+
export default function OverlayCreator(): () => {
|
|
3
|
+
/**
|
|
4
|
+
* Fires when any Reactotron message arrives.
|
|
5
|
+
*/
|
|
6
|
+
onCommand: (command: import("dreaction-protocol").Command) => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/overlay.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,mEAAS,CAAC;AAE9B,MAAM,CAAC,OAAO,UAAU,cAAc;IAGhC;;OAEG;;EAWR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emitter = void 0;
|
|
7
|
+
exports.default = OverlayCreator;
|
|
8
|
+
const mitt_1 = __importDefault(require("mitt"));
|
|
9
|
+
exports.emitter = (0, mitt_1.default)();
|
|
10
|
+
function OverlayCreator() {
|
|
11
|
+
return function overlay() {
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* Fires when any Reactotron message arrives.
|
|
15
|
+
*/
|
|
16
|
+
onCommand: (command) => {
|
|
17
|
+
if (command.type !== 'overlay') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// relay this payload on to the emitter
|
|
21
|
+
exports.emitter.emit('overlay', command.payload);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreaction-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "",
|
|
5
|
+
"description": "DReaction client for React Native applications with draggable debug ball and powerful debugging tools",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"assets",
|
|
@@ -10,13 +10,30 @@
|
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
12
|
"keywords": [
|
|
13
|
-
"dreaction"
|
|
13
|
+
"dreaction",
|
|
14
|
+
"react-native",
|
|
15
|
+
"debug",
|
|
16
|
+
"debugger",
|
|
17
|
+
"monitoring",
|
|
18
|
+
"logging",
|
|
19
|
+
"network",
|
|
20
|
+
"performance"
|
|
14
21
|
],
|
|
15
22
|
"author": "moonrailgun <moonrailgun@gmail.com>",
|
|
16
23
|
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/moonrailgun/dreaction.git",
|
|
27
|
+
"directory": "packages/dreaction-react-native"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/moonrailgun/dreaction/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/moonrailgun/dreaction#readme",
|
|
17
33
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"dreaction-
|
|
34
|
+
"mitt": "^3.0.1",
|
|
35
|
+
"dreaction-client-core": "1.2.1",
|
|
36
|
+
"dreaction-protocol": "1.0.9"
|
|
20
37
|
},
|
|
21
38
|
"devDependencies": {
|
|
22
39
|
"@react-native-async-storage/async-storage": "^2.1.0",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Image, Dimensions, View } from 'react-native';
|
|
3
|
+
import { emitter } from '../plugins/overlay';
|
|
4
|
+
|
|
5
|
+
export const OverlayImage: React.FC = React.memo(() => {
|
|
6
|
+
const [uri, setUri] = useState<string | null>(null);
|
|
7
|
+
const [opacity, setOpacity] = useState(0.5);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const handler = (payload: any) => {
|
|
11
|
+
setUri(payload.uri);
|
|
12
|
+
if (payload.opacity !== undefined) {
|
|
13
|
+
setOpacity(payload.opacity);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
emitter.on('overlay', handler);
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
emitter.off('overlay', handler);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
if (!uri) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { width, height } = Dimensions.get('window');
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
pointerEvents="none"
|
|
33
|
+
style={{
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
top: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
width: width,
|
|
38
|
+
height: height,
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<Image
|
|
42
|
+
source={{ uri: uri }}
|
|
43
|
+
resizeMode="contain"
|
|
44
|
+
style={{
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
width: width,
|
|
49
|
+
height: height,
|
|
50
|
+
opacity: opacity,
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
OverlayImage.displayName = 'OverlayImage';
|
package/src/dreaction.ts
CHANGED
|
@@ -23,9 +23,12 @@ import { DataWatchPayload } from 'dreaction-protocol';
|
|
|
23
23
|
import { useEffect } from 'react';
|
|
24
24
|
import { getHost } from './helpers/getHost';
|
|
25
25
|
import { isDev } from './helpers/common';
|
|
26
|
+
import overlay from './plugins/overlay';
|
|
26
27
|
|
|
27
28
|
export type { ClientOptions };
|
|
28
29
|
|
|
30
|
+
export { overlay };
|
|
31
|
+
|
|
29
32
|
const DREACTION_ASYNC_CLIENT_ID = '@DREACTION/clientId';
|
|
30
33
|
|
|
31
34
|
let tempClientId: string | null = null;
|
|
@@ -43,6 +46,7 @@ export interface UseReactNativeOptions {
|
|
|
43
46
|
errors?: TrackGlobalErrorsOptions | boolean;
|
|
44
47
|
log?: boolean;
|
|
45
48
|
editor?: OpenInEditorOptions | boolean;
|
|
49
|
+
overlay?: boolean;
|
|
46
50
|
asyncStorage?: AsyncStorageOptions | boolean;
|
|
47
51
|
networking?: NetworkingOptions | boolean;
|
|
48
52
|
devTools?: boolean;
|
|
@@ -177,6 +181,10 @@ dreaction.useReactNative = (options: UseReactNativeOptions = {}) => {
|
|
|
177
181
|
dreaction.use(openInEditor(getPluginOptions(options.editor as any)));
|
|
178
182
|
}
|
|
179
183
|
|
|
184
|
+
if (options.overlay !== false) {
|
|
185
|
+
dreaction.use(overlay());
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
if (options.asyncStorage !== false) {
|
|
181
189
|
dreaction.use(
|
|
182
190
|
asyncStorage(getPluginOptions(options.asyncStorage) as any) as any
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type { Command } from 'dreaction-protocol';
|
|
2
2
|
import { DraggableBall } from './components/DraggableBall';
|
|
3
3
|
import { Profiler } from './components/Profiler';
|
|
4
|
+
import { OverlayImage } from './components/OverlayImage';
|
|
4
5
|
|
|
5
6
|
export { DraggableBall as DReactionDraggableBall };
|
|
7
|
+
export { OverlayImage as DReactionOverlayImage };
|
|
6
8
|
export { Profiler as DReactionProfiler };
|
|
7
9
|
|
|
8
10
|
export * from './dreaction';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import mitt from 'mitt';
|
|
2
|
+
import type { DReactionCore, Plugin } from 'dreaction-client-core';
|
|
3
|
+
|
|
4
|
+
export const emitter = mitt();
|
|
5
|
+
|
|
6
|
+
export default function OverlayCreator() {
|
|
7
|
+
return function overlay() {
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Fires when any Reactotron message arrives.
|
|
11
|
+
*/
|
|
12
|
+
onCommand: (command) => {
|
|
13
|
+
if (command.type !== 'overlay') {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// relay this payload on to the emitter
|
|
18
|
+
emitter.emit('overlay', command.payload);
|
|
19
|
+
},
|
|
20
|
+
} satisfies Plugin<DReactionCore>;
|
|
21
|
+
};
|
|
22
|
+
}
|