reactoradar 1.5.5 → 1.5.7
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 +26 -0
- package/bin/setup.js +108 -54
- package/package.json +1 -1
- package/sdk/RNDebugSDK.js +1 -1
package/README.md
CHANGED
|
@@ -145,6 +145,32 @@ npx reactoradar remove
|
|
|
145
145
|
- Deep equality comparison (no false positives from reference changes)
|
|
146
146
|
- Time travel with ◀ ▶ navigation
|
|
147
147
|
|
|
148
|
+
### Redux Setup
|
|
149
|
+
|
|
150
|
+
`npx reactoradar setup` auto-detects Redux and patches your store. If it can't auto-patch, add manually:
|
|
151
|
+
|
|
152
|
+
**Redux Toolkit (configureStore):**
|
|
153
|
+
```js
|
|
154
|
+
// In your store file (e.g. src/store/store.ts)
|
|
155
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
156
|
+
|
|
157
|
+
export const store = configureStore({
|
|
158
|
+
reducer: rootReducer,
|
|
159
|
+
middleware: (getDefaultMiddleware) =>
|
|
160
|
+
__DEV__
|
|
161
|
+
? getDefaultMiddleware().concat(require('../debug/RNDebugSDK').reduxMiddleware)
|
|
162
|
+
: getDefaultMiddleware(),
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Legacy Redux (createStore):**
|
|
167
|
+
```js
|
|
168
|
+
import { reduxEnhancer } from '../debug/RNDebugSDK';
|
|
169
|
+
const store = createStore(reducer, __DEV__ ? reduxEnhancer : undefined);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
> **Note:** The import path is relative from your store file to `src/debug/RNDebugSDK`. Adjust if your store is in a different directory. Run `npx reactoradar setup` to auto-detect the correct path.
|
|
173
|
+
|
|
148
174
|
## Themes
|
|
149
175
|
|
|
150
176
|
9 built-in themes: **Dark** (default), **Light**, **Monokai**, **Dracula**, **Solarized Dark**, **Solarized Light**, **Nord**, **GitHub Dark**, **One Dark**
|
package/bin/setup.js
CHANGED
|
@@ -166,10 +166,18 @@ async function install(projectDir) {
|
|
|
166
166
|
const sdkDestDir = path.join(projectDir, 'src', 'debug');
|
|
167
167
|
const sdkDest = path.join(sdkDestDir, 'RNDebugSDK.js');
|
|
168
168
|
|
|
169
|
-
if (!
|
|
170
|
-
|
|
169
|
+
if (!fileExists(sdkSrc)) {
|
|
170
|
+
err('SDK source file not found at: ' + sdkSrc);
|
|
171
|
+
err('This may be a corrupted installation. Try: npm cache clean --force && npx reactoradar@latest setup');
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
fs.mkdirSync(sdkDestDir, { recursive: true });
|
|
177
|
+
} catch (e) {
|
|
178
|
+
err('Failed to create directory ' + sdkDestDir + ': ' + e.message);
|
|
179
|
+
process.exit(1);
|
|
171
180
|
}
|
|
172
|
-
fs.mkdirSync(sdkDestDir, { recursive: true });
|
|
173
181
|
|
|
174
182
|
// Read SDK, patch HOST
|
|
175
183
|
let sdkContent = fs.readFileSync(sdkSrc, 'utf8');
|
|
@@ -177,7 +185,18 @@ async function install(projectDir) {
|
|
|
177
185
|
/const HOST = '[^']+';/,
|
|
178
186
|
`const HOST = '${host}';`
|
|
179
187
|
);
|
|
180
|
-
|
|
188
|
+
try {
|
|
189
|
+
fs.writeFileSync(sdkDest, sdkContent);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
err('Failed to write SDK file to ' + sdkDest + ': ' + e.message);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Verify the file was actually written
|
|
196
|
+
if (!fileExists(sdkDest)) {
|
|
197
|
+
err('SDK file was not created at ' + sdkDest + ' — check directory permissions');
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
181
200
|
log('Copied RNDebugSDK.js →', C.dim + 'src/debug/RNDebugSDK.js' + C.reset);
|
|
182
201
|
|
|
183
202
|
// 4. Patch entry file
|
|
@@ -207,56 +226,91 @@ ${SDK_MARKER_END}
|
|
|
207
226
|
}
|
|
208
227
|
}
|
|
209
228
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
229
|
+
// 5. Detect and wire Redux
|
|
230
|
+
info('Checking for Redux...');
|
|
231
|
+
const hasRedux = allDeps['@reduxjs/toolkit'] || allDeps['redux'];
|
|
232
|
+
if (hasRedux) {
|
|
233
|
+
const storeFile = findStoreFile(projectDir);
|
|
234
|
+
if (storeFile) {
|
|
235
|
+
const storePath = path.join(projectDir, storeFile);
|
|
236
|
+
const storeContent = fs.readFileSync(storePath, 'utf8');
|
|
237
|
+
|
|
238
|
+
// Compute relative path from store file to SDK
|
|
239
|
+
const storeDir = path.dirname(path.join(projectDir, storeFile));
|
|
240
|
+
let relSDK = path.relative(storeDir, path.join(projectDir, 'src', 'debug', 'RNDebugSDK'))
|
|
241
|
+
.replace(/\\/g, '/'); // Windows compat
|
|
242
|
+
if (!relSDK.startsWith('.')) relSDK = './' + relSDK;
|
|
243
|
+
|
|
244
|
+
if (storeContent.includes('RNDebugSDK')) {
|
|
245
|
+
// Check if the require path is correct — fix stale/wrong paths from older setup versions
|
|
246
|
+
const wrongPathRe = /require\(['"]([^'"]*RNDebugSDK[^'"]*)['"]\)/g;
|
|
247
|
+
let hasWrongPath = false;
|
|
248
|
+
let fixedContent = storeContent;
|
|
249
|
+
let match;
|
|
250
|
+
while ((match = wrongPathRe.exec(storeContent)) !== null) {
|
|
251
|
+
const existingPath = match[1];
|
|
252
|
+
// Normalize: strip .js extension for comparison
|
|
253
|
+
const normalizedExisting = existingPath.replace(/\.js$/, '');
|
|
254
|
+
const normalizedExpected = relSDK.replace(/\.js$/, '');
|
|
255
|
+
if (normalizedExisting !== normalizedExpected) {
|
|
256
|
+
hasWrongPath = true;
|
|
257
|
+
fixedContent = fixedContent.replace(match[0], `require('${relSDK}')`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Also fix import statements
|
|
261
|
+
const wrongImportRe = /from\s+['"]([^'"]*RNDebugSDK[^'"]*)['"]/g;
|
|
262
|
+
while ((match = wrongImportRe.exec(storeContent)) !== null) {
|
|
263
|
+
const existingPath = match[1];
|
|
264
|
+
const normalizedExisting = existingPath.replace(/\.js$/, '');
|
|
265
|
+
const normalizedExpected = relSDK.replace(/\.js$/, '');
|
|
266
|
+
if (normalizedExisting !== normalizedExpected) {
|
|
267
|
+
hasWrongPath = true;
|
|
268
|
+
fixedContent = fixedContent.replace(match[0], `from '${relSDK}'`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (hasWrongPath) {
|
|
272
|
+
fs.writeFileSync(storePath, fixedContent);
|
|
273
|
+
log('Fixed stale SDK path in', C.bold + storeFile + C.reset, '→', C.cyan + relSDK + C.reset);
|
|
274
|
+
} else {
|
|
275
|
+
log('Redux store already has RNDebugSDK wired correctly — skipping');
|
|
276
|
+
}
|
|
277
|
+
} else if (storeContent.includes('configureStore')) {
|
|
278
|
+
// RTK configureStore
|
|
279
|
+
// Try to add middleware to configureStore
|
|
280
|
+
if (storeContent.includes('middleware:') || storeContent.includes('middleware :')) {
|
|
281
|
+
warn('Redux store found at', C.bold + storeFile + C.reset, '— has custom middleware');
|
|
282
|
+
console.log(C.dim + ' Add manually to your middleware:' + C.reset);
|
|
283
|
+
console.log(C.dim + ` import { reduxMiddleware } from '${relSDK}';` + C.reset);
|
|
284
|
+
console.log(C.dim + ' middleware: (getDefault) => __DEV__' + C.reset);
|
|
285
|
+
console.log(C.dim + ' ? getDefault().concat(reduxMiddleware)' + C.reset);
|
|
286
|
+
console.log(C.dim + ' : getDefault(),' + C.reset);
|
|
287
|
+
} else {
|
|
288
|
+
// Add middleware field to configureStore
|
|
289
|
+
const patched = storeContent.replace(
|
|
290
|
+
/(configureStore\s*\(\s*\{)/,
|
|
291
|
+
`$1\n middleware: (getDefaultMiddleware) =>\n __DEV__\n ? getDefaultMiddleware().concat(require('${relSDK}').reduxMiddleware)\n : getDefaultMiddleware(),`
|
|
292
|
+
);
|
|
293
|
+
if (patched !== storeContent) {
|
|
294
|
+
fs.writeFileSync(storePath, patched);
|
|
295
|
+
log('Patched', C.bold + storeFile + C.reset, '— Redux middleware wired');
|
|
296
|
+
} else {
|
|
297
|
+
warn('Could not auto-patch', storeFile, '— wire Redux manually');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} else if (storeContent.includes('createStore')) {
|
|
301
|
+
warn('Legacy createStore found at', C.bold + storeFile + C.reset);
|
|
302
|
+
console.log(C.dim + ' Add manually:' + C.reset);
|
|
303
|
+
console.log(C.dim + ` import { reduxEnhancer } from '${relSDK}';` + C.reset);
|
|
304
|
+
console.log(C.dim + ' const store = createStore(reducer, __DEV__ ? reduxEnhancer : undefined);' + C.reset);
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
warn('Redux detected but store file not found automatically');
|
|
308
|
+
console.log(C.dim + ' Add to your store setup:' + C.reset);
|
|
309
|
+
console.log(C.dim + ' import { reduxMiddleware } from \'./src/debug/RNDebugSDK\';' + C.reset);
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
log('No Redux detected — skipping');
|
|
313
|
+
}
|
|
260
314
|
|
|
261
315
|
// 6. adb reverse for Android
|
|
262
316
|
if (platform.hasAndroidEmu || platform.hasAndroidDevice) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactoradar",
|
|
3
3
|
"productName": "ReactoRadar",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.7",
|
|
5
5
|
"description": "macOS debugger for React Native — Console, Sources, Network, Performance, Memory, Redux, AsyncStorage, React tree. Supports RN 0.74+ with Hermes and New Architecture.",
|
|
6
6
|
"main": "main.js",
|
|
7
7
|
"bin": {
|
package/sdk/RNDebugSDK.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
if (!__DEV__) {
|
|
18
|
-
module.exports = { reduxEnhancer: x => x, watchAsyncStorage: () => {} };
|
|
18
|
+
module.exports = { reduxEnhancer: x => x, reduxMiddleware: () => next => action => next(action), watchAsyncStorage: () => {} };
|
|
19
19
|
} else {
|
|
20
20
|
|
|
21
21
|
// ─── Config ───────────────────────────────────────────────────────────────────
|