reactoradar 1.5.5 → 1.5.6

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/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 (!dirExists(path.join(projectDir, 'src'))) {
170
- fs.mkdirSync(path.join(projectDir, 'src'), { recursive: true });
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
- fs.writeFileSync(sdkDest, sdkContent);
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,60 @@ ${SDK_MARKER_END}
207
226
  }
208
227
  }
209
228
 
210
- // 5. Detect and wire Redux
211
- info('Checking for Redux...');
212
- const hasRedux = allDeps['@reduxjs/toolkit'] || allDeps['redux'];
213
- if (hasRedux) {
214
- const storeFile = findStoreFile(projectDir);
215
- if (storeFile) {
216
- const storePath = path.join(projectDir, storeFile);
217
- const storeContent = fs.readFileSync(storePath, 'utf8');
218
-
219
- if (storeContent.includes('RNDebugSDK')) {
220
- log('Redux store already has RNDebugSDK wired — skipping');
221
- } else if (storeContent.includes('configureStore')) {
222
- // RTK configureStore
223
- const patchedStore = `${SDK_MARKER_START}\nimport { reduxMiddleware } from '../debug/RNDebugSDK';\n${SDK_MARKER_END}\n` + storeContent;
224
-
225
- // Try to add middleware to configureStore
226
- if (storeContent.includes('middleware:') || storeContent.includes('middleware :')) {
227
- warn('Redux store found at', C.bold + storeFile + C.reset, '— has custom middleware');
228
- console.log(C.dim + ' Add manually to your middleware:' + C.reset);
229
- console.log(C.dim + ' import { reduxMiddleware } from \'./src/debug/RNDebugSDK\';' + C.reset);
230
- console.log(C.dim + ' middleware: (getDefault) => __DEV__' + C.reset);
231
- console.log(C.dim + ' ? getDefault().concat(reduxMiddleware)' + C.reset);
232
- console.log(C.dim + ' : getDefault(),' + C.reset);
233
- } else {
234
- // Add middleware field to configureStore
235
- const patched = storeContent.replace(
236
- /(configureStore\s*\(\s*\{)/,
237
- `$1\n middleware: (getDefaultMiddleware) =>\n __DEV__\n ? getDefaultMiddleware().concat(require('./src/debug/RNDebugSDK').reduxMiddleware)\n : getDefaultMiddleware(),`
238
- );
239
- if (patched !== storeContent) {
240
- fs.writeFileSync(storePath, patched);
241
- log('Patched', C.bold + storeFile + C.reset, '— Redux middleware wired');
242
- } else {
243
- warn('Could not auto-patch', storeFile, '— wire Redux manually');
244
- }
245
- }
246
- } else if (storeContent.includes('createStore')) {
247
- warn('Legacy createStore found at', C.bold + storeFile + C.reset);
248
- console.log(C.dim + ' Add manually:' + C.reset);
249
- console.log(C.dim + ' import { reduxEnhancer } from \'./src/debug/RNDebugSDK\';' + C.reset);
250
- console.log(C.dim + ' const store = createStore(reducer, __DEV__ ? reduxEnhancer : undefined);' + C.reset);
251
- }
252
- } else {
253
- warn('Redux detected but store file not found automatically');
254
- console.log(C.dim + ' Add to your store setup:' + C.reset);
255
- console.log(C.dim + ' import { reduxMiddleware } from \'./src/debug/RNDebugSDK\';' + C.reset);
256
- }
257
- } else {
258
- log('No Redux detected skipping');
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
+ log('Redux store already has RNDebugSDK wired — skipping');
246
+ } else if (storeContent.includes('configureStore')) {
247
+ // RTK configureStore
248
+ // Try to add middleware to configureStore
249
+ if (storeContent.includes('middleware:') || storeContent.includes('middleware :')) {
250
+ warn('Redux store found at', C.bold + storeFile + C.reset, '— has custom middleware');
251
+ console.log(C.dim + ' Add manually to your middleware:' + C.reset);
252
+ console.log(C.dim + ` import { reduxMiddleware } from '${relSDK}';` + C.reset);
253
+ console.log(C.dim + ' middleware: (getDefault) => __DEV__' + C.reset);
254
+ console.log(C.dim + ' ? getDefault().concat(reduxMiddleware)' + C.reset);
255
+ console.log(C.dim + ' : getDefault(),' + C.reset);
256
+ } else {
257
+ // Add middleware field to configureStore
258
+ const patched = storeContent.replace(
259
+ /(configureStore\s*\(\s*\{)/,
260
+ `$1\n middleware: (getDefaultMiddleware) =>\n __DEV__\n ? getDefaultMiddleware().concat(require('${relSDK}').reduxMiddleware)\n : getDefaultMiddleware(),`
261
+ );
262
+ if (patched !== storeContent) {
263
+ fs.writeFileSync(storePath, patched);
264
+ log('Patched', C.bold + storeFile + C.reset, '— Redux middleware wired');
265
+ } else {
266
+ warn('Could not auto-patch', storeFile, '— wire Redux manually');
267
+ }
268
+ }
269
+ } else if (storeContent.includes('createStore')) {
270
+ warn('Legacy createStore found at', C.bold + storeFile + C.reset);
271
+ console.log(C.dim + ' Add manually:' + C.reset);
272
+ console.log(C.dim + ` import { reduxEnhancer } from '${relSDK}';` + C.reset);
273
+ console.log(C.dim + ' const store = createStore(reducer, __DEV__ ? reduxEnhancer : undefined);' + C.reset);
274
+ }
275
+ } else {
276
+ warn('Redux detected but store file not found automatically');
277
+ console.log(C.dim + ' Add to your store setup:' + C.reset);
278
+ console.log(C.dim + ' import { reduxMiddleware } from \'./src/debug/RNDebugSDK\';' + C.reset);
279
+ }
280
+ } else {
281
+ log('No Redux detected — skipping');
282
+ }
260
283
 
261
284
  // 6. adb reverse for Android
262
285
  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.5",
4
+ "version": "1.5.6",
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 ───────────────────────────────────────────────────────────────────