react-native-inapp-inspector 2.3.4 → 2.3.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/dist/commonjs/analytics.d.ts +0 -4
- package/dist/commonjs/analytics.js +0 -4
- package/dist/commonjs/bundle.d.ts +0 -4
- package/dist/commonjs/bundle.js +0 -4
- package/dist/commonjs/components/AnalyticsDetail.js +18 -27
- package/dist/commonjs/components/AnalyticsEventCard.js +9 -12
- package/dist/commonjs/components/AnalyticsGraph.js +10 -15
- package/dist/commonjs/components/AppHeaderLogo.js +0 -3
- package/dist/commonjs/components/BrandCircleIcon.js +15 -15
- package/dist/commonjs/components/BrandSquareIcon.js +20 -20
- package/dist/commonjs/components/CodeSnippet.js +6 -19
- package/dist/commonjs/components/ConsoleLogCard.js +0 -1
- package/dist/commonjs/components/CopyButton.js +0 -4
- package/dist/commonjs/components/DiffViewer.js +0 -2
- package/dist/commonjs/components/DomainHeader.js +0 -4
- package/dist/commonjs/components/EmptyState.js +0 -3
- package/dist/commonjs/components/ErrorBoundary.js +5 -10
- package/dist/commonjs/components/HeadersSection.js +0 -5
- package/dist/commonjs/components/HighlightText.js +1 -4
- package/dist/commonjs/components/Inspector/AnalyticsFilterModal.js +11 -26
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +34 -40
- package/dist/commonjs/components/Inspector/BundleTab.js +56 -84
- package/dist/commonjs/components/Inspector/ConsoleTab.js +7 -7
- package/dist/commonjs/components/Inspector/CrashDetail.js +18 -20
- package/dist/commonjs/components/Inspector/CrashFilterModal.js +0 -1
- package/dist/commonjs/components/Inspector/CrashTab.js +11 -20
- package/dist/commonjs/components/Inspector/DeviceInfoTab.js +12 -24
- package/dist/commonjs/components/Inspector/FabLauncher.js +1 -1
- package/dist/commonjs/components/Inspector/InspectorContext.js +0 -2
- package/dist/commonjs/components/Inspector/InspectorHeader.js +7 -8
- package/dist/commonjs/components/Inspector/LogDetail.js +27 -29
- package/dist/commonjs/components/Inspector/MainScreen.js +168 -9
- package/dist/commonjs/components/Inspector/NetworkDetail.js +10 -11
- package/dist/commonjs/components/Inspector/NetworkTab.js +14 -14
- package/dist/commonjs/components/Inspector/NpmUpdateToast.js +6 -9
- package/dist/commonjs/components/Inspector/PerformanceTab.js +30 -43
- package/dist/commonjs/components/Inspector/ReduxDetail.js +18 -34
- package/dist/commonjs/components/Inspector/ReduxTab.js +11 -20
- package/dist/commonjs/components/Inspector/SettingsPanel.js +32 -36
- package/dist/commonjs/components/Inspector/SkeletonPlaceholder.js +6 -6
- package/dist/commonjs/components/Inspector/StorageTab.js +14 -26
- package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +5 -6
- package/dist/commonjs/components/JsonViewer.js +3 -10
- package/dist/commonjs/components/LogCard.js +7 -7
- package/dist/commonjs/components/MetaAccordion.js +1 -7
- package/dist/commonjs/components/NetworkIcons.js +12 -16
- package/dist/commonjs/components/SectionHeader.js +0 -4
- package/dist/commonjs/components/SkeletonPlaceholder.js +6 -6
- package/dist/commonjs/components/Slider.js +6 -6
- package/dist/commonjs/components/SourcePageCard.js +0 -4
- package/dist/commonjs/components/TreeNode.js +0 -4
- package/dist/commonjs/console.d.ts +0 -4
- package/dist/commonjs/console.js +0 -4
- package/dist/commonjs/constants/index.js +6 -9
- package/dist/commonjs/constants/telemetryConfig.d.ts +7 -0
- package/dist/commonjs/constants/telemetryConfig.js +10 -0
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -3
- package/dist/commonjs/crash.d.ts +0 -4
- package/dist/commonjs/crash.js +0 -4
- package/dist/commonjs/customHooks/analyticsLogger.d.ts +0 -7
- package/dist/commonjs/customHooks/analyticsLogger.js +3 -59
- package/dist/commonjs/customHooks/bundleAnalyzer.d.ts +0 -9
- package/dist/commonjs/customHooks/bundleAnalyzer.js +3 -86
- package/dist/commonjs/customHooks/consoleLogger.js +0 -16
- package/dist/commonjs/customHooks/crashHandler.d.ts +0 -28
- package/dist/commonjs/customHooks/crashHandler.js +0 -55
- package/dist/commonjs/customHooks/logFilters.d.ts +0 -4
- package/dist/commonjs/customHooks/logFilters.js +0 -11
- package/dist/commonjs/customHooks/networkLogger.js +2 -13
- package/dist/commonjs/customHooks/performanceTracker.d.ts +0 -27
- package/dist/commonjs/customHooks/performanceTracker.js +0 -31
- package/dist/commonjs/customHooks/reduxLogger.d.ts +0 -12
- package/dist/commonjs/customHooks/reduxLogger.js +0 -51
- package/dist/commonjs/customHooks/storageInspector.d.ts +0 -40
- package/dist/commonjs/customHooks/storageInspector.js +1 -56
- package/dist/commonjs/decorators/index.d.ts +0 -37
- package/dist/commonjs/decorators/index.js +0 -42
- package/dist/commonjs/helpers/gaAnalyticsRegistry.d.ts +0 -10
- package/dist/commonjs/helpers/gaAnalyticsRegistry.js +0 -26
- package/dist/commonjs/helpers/index.d.ts +0 -7
- package/dist/commonjs/helpers/index.js +1 -42
- package/dist/commonjs/helpers/memoryManager.d.ts +0 -11
- package/dist/commonjs/helpers/memoryManager.js +0 -13
- package/dist/commonjs/helpers/searchQueryParser.d.ts +0 -4
- package/dist/commonjs/helpers/searchQueryParser.js +0 -18
- package/dist/commonjs/helpers/settingsStore.js +0 -8
- package/dist/commonjs/helpers/telemetry.d.ts +2 -0
- package/dist/commonjs/helpers/telemetry.js +302 -0
- package/dist/commonjs/i18n/index.d.ts +0 -9
- package/dist/commonjs/i18n/index.js +0 -15
- package/dist/commonjs/index.d.ts +0 -1
- package/dist/commonjs/index.js +18 -102
- package/dist/commonjs/native/NativeInspector.d.ts +0 -54
- package/dist/commonjs/native/NativeInspector.js +0 -56
- package/dist/commonjs/network.d.ts +0 -4
- package/dist/commonjs/network.js +0 -4
- package/dist/commonjs/performance.d.ts +0 -4
- package/dist/commonjs/performance.js +0 -4
- package/dist/commonjs/redux.d.ts +0 -4
- package/dist/commonjs/redux.js +0 -4
- package/dist/commonjs/storage.d.ts +0 -4
- package/dist/commonjs/storage.js +0 -4
- package/dist/commonjs/styles/AppColors.d.ts +0 -3
- package/dist/commonjs/styles/AppColors.js +15 -30
- package/dist/commonjs/styles/AppFonts.d.ts +0 -4
- package/dist/commonjs/styles/AppFonts.js +0 -4
- package/dist/commonjs/styles/common.js +0 -11
- package/dist/commonjs/styles/index.js +0 -8
- package/dist/commonjs/types/enums.js +0 -3
- package/dist/commonjs/types/interfaces.d.ts +3 -3
- package/dist/esm/analytics.d.ts +0 -4
- package/dist/esm/analytics.js +0 -4
- package/dist/esm/bundle.d.ts +0 -4
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/components/AnalyticsDetail.js +18 -27
- package/dist/esm/components/AnalyticsEventCard.js +9 -12
- package/dist/esm/components/AnalyticsGraph.js +10 -15
- package/dist/esm/components/AppHeaderLogo.js +0 -3
- package/dist/esm/components/BrandCircleIcon.js +15 -15
- package/dist/esm/components/BrandSquareIcon.js +20 -20
- package/dist/esm/components/CodeSnippet.js +6 -19
- package/dist/esm/components/ConsoleLogCard.js +0 -1
- package/dist/esm/components/CopyButton.js +0 -4
- package/dist/esm/components/DiffViewer.js +0 -2
- package/dist/esm/components/DomainHeader.js +0 -4
- package/dist/esm/components/EmptyState.js +0 -3
- package/dist/esm/components/ErrorBoundary.js +5 -10
- package/dist/esm/components/HeadersSection.js +0 -5
- package/dist/esm/components/HighlightText.js +1 -4
- package/dist/esm/components/Inspector/AnalyticsFilterModal.js +11 -26
- package/dist/esm/components/Inspector/AnalyticsTab.js +34 -40
- package/dist/esm/components/Inspector/BundleTab.js +56 -84
- package/dist/esm/components/Inspector/ConsoleTab.js +7 -7
- package/dist/esm/components/Inspector/CrashDetail.js +18 -20
- package/dist/esm/components/Inspector/CrashFilterModal.js +0 -1
- package/dist/esm/components/Inspector/CrashTab.js +11 -20
- package/dist/esm/components/Inspector/DeviceInfoTab.js +12 -24
- package/dist/esm/components/Inspector/FabLauncher.js +1 -1
- package/dist/esm/components/Inspector/InspectorContext.js +0 -2
- package/dist/esm/components/Inspector/InspectorHeader.js +7 -8
- package/dist/esm/components/Inspector/LogDetail.js +27 -29
- package/dist/esm/components/Inspector/MainScreen.js +168 -9
- package/dist/esm/components/Inspector/NetworkDetail.js +10 -11
- package/dist/esm/components/Inspector/NetworkTab.js +14 -14
- package/dist/esm/components/Inspector/NpmUpdateToast.js +6 -9
- package/dist/esm/components/Inspector/PerformanceTab.js +30 -43
- package/dist/esm/components/Inspector/ReduxDetail.js +18 -34
- package/dist/esm/components/Inspector/ReduxTab.js +11 -20
- package/dist/esm/components/Inspector/SettingsPanel.js +32 -36
- package/dist/esm/components/Inspector/SkeletonPlaceholder.js +6 -6
- package/dist/esm/components/Inspector/StorageTab.js +14 -26
- package/dist/esm/components/Inspector/UpdateAvailableModal.js +5 -6
- package/dist/esm/components/JsonViewer.js +3 -10
- package/dist/esm/components/LogCard.js +7 -7
- package/dist/esm/components/MetaAccordion.js +1 -7
- package/dist/esm/components/NetworkIcons.js +12 -16
- package/dist/esm/components/SectionHeader.js +0 -4
- package/dist/esm/components/SkeletonPlaceholder.js +6 -6
- package/dist/esm/components/Slider.js +6 -6
- package/dist/esm/components/SourcePageCard.js +0 -4
- package/dist/esm/components/TreeNode.js +0 -4
- package/dist/esm/console.d.ts +0 -4
- package/dist/esm/console.js +0 -4
- package/dist/esm/constants/index.js +6 -9
- package/dist/esm/constants/telemetryConfig.d.ts +7 -0
- package/dist/esm/constants/telemetryConfig.js +7 -0
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -3
- package/dist/esm/crash.d.ts +0 -4
- package/dist/esm/crash.js +0 -4
- package/dist/esm/customHooks/analyticsLogger.d.ts +0 -7
- package/dist/esm/customHooks/analyticsLogger.js +3 -59
- package/dist/esm/customHooks/bundleAnalyzer.d.ts +0 -9
- package/dist/esm/customHooks/bundleAnalyzer.js +3 -86
- package/dist/esm/customHooks/consoleLogger.js +0 -16
- package/dist/esm/customHooks/crashHandler.d.ts +0 -28
- package/dist/esm/customHooks/crashHandler.js +0 -55
- package/dist/esm/customHooks/logFilters.d.ts +0 -4
- package/dist/esm/customHooks/logFilters.js +0 -11
- package/dist/esm/customHooks/networkLogger.js +2 -13
- package/dist/esm/customHooks/performanceTracker.d.ts +0 -27
- package/dist/esm/customHooks/performanceTracker.js +0 -31
- package/dist/esm/customHooks/reduxLogger.d.ts +0 -12
- package/dist/esm/customHooks/reduxLogger.js +0 -51
- package/dist/esm/customHooks/storageInspector.d.ts +0 -40
- package/dist/esm/customHooks/storageInspector.js +1 -56
- package/dist/esm/decorators/index.d.ts +0 -37
- package/dist/esm/decorators/index.js +0 -42
- package/dist/esm/helpers/gaAnalyticsRegistry.d.ts +0 -10
- package/dist/esm/helpers/gaAnalyticsRegistry.js +0 -26
- package/dist/esm/helpers/index.d.ts +0 -7
- package/dist/esm/helpers/index.js +1 -42
- package/dist/esm/helpers/memoryManager.d.ts +0 -11
- package/dist/esm/helpers/memoryManager.js +0 -13
- package/dist/esm/helpers/searchQueryParser.d.ts +0 -4
- package/dist/esm/helpers/searchQueryParser.js +0 -18
- package/dist/esm/helpers/settingsStore.js +0 -8
- package/dist/esm/helpers/telemetry.d.ts +2 -0
- package/dist/esm/helpers/telemetry.js +298 -0
- package/dist/esm/i18n/index.d.ts +0 -9
- package/dist/esm/i18n/index.js +0 -15
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +15 -98
- package/dist/esm/native/NativeInspector.d.ts +0 -54
- package/dist/esm/native/NativeInspector.js +0 -56
- package/dist/esm/network.d.ts +0 -4
- package/dist/esm/network.js +0 -4
- package/dist/esm/performance.d.ts +0 -4
- package/dist/esm/performance.js +0 -4
- package/dist/esm/redux.d.ts +0 -4
- package/dist/esm/redux.js +0 -4
- package/dist/esm/storage.d.ts +0 -4
- package/dist/esm/storage.js +0 -4
- package/dist/esm/styles/AppColors.d.ts +0 -3
- package/dist/esm/styles/AppColors.js +15 -30
- package/dist/esm/styles/AppFonts.d.ts +0 -4
- package/dist/esm/styles/AppFonts.js +0 -4
- package/dist/esm/styles/common.js +0 -11
- package/dist/esm/styles/index.js +0 -8
- package/dist/esm/types/enums.js +0 -3
- package/dist/esm/types/interfaces.d.ts +3 -3
- package/package.json +2 -2
- package/src/components/Inspector/MainScreen.tsx +188 -2
- package/src/constants/telemetryConfig.ts +16 -0
- package/src/constants/version.ts +1 -1
- package/src/helpers/telemetry.ts +341 -0
- package/src/index.tsx +15 -2
- package/src/types/interfaces.ts +3 -0
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { AppColors } from '../styles/AppColors';
|
|
2
2
|
import { t } from '../i18n';
|
|
3
3
|
import { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Dynamically generates tailored Before/After performance optimization code snippets
|
|
6
|
-
* based on the target component's real identifier, props, and detected anti-pattern.
|
|
7
|
-
*/
|
|
8
4
|
export const generateFixSnippet = (fixKey, componentName = 'Component', context) => {
|
|
9
5
|
const comp = componentName || 'Component';
|
|
10
6
|
const prop = context?.propName || 'onPress';
|
|
@@ -134,11 +130,6 @@ export const generateFixSnippet = (fixKey, componentName = 'Component', context)
|
|
|
134
130
|
};
|
|
135
131
|
}
|
|
136
132
|
};
|
|
137
|
-
/**
|
|
138
|
-
* Dynamically resolves caller file path or runtime source from the active JavaScript stack trace.
|
|
139
|
-
* Does not assume fixed directory hierarchies (such as src/ or components/) and extracts
|
|
140
|
-
* whatever relative path or symbol the host project structure uses.
|
|
141
|
-
*/
|
|
142
133
|
export function getCallerSourceFile(fallbackName) {
|
|
143
134
|
try {
|
|
144
135
|
const stack = new Error().stack;
|
|
@@ -256,9 +247,6 @@ export const trackComponentRender = (params) => {
|
|
|
256
247
|
}
|
|
257
248
|
notifyRenderListeners();
|
|
258
249
|
};
|
|
259
|
-
/**
|
|
260
|
-
* Dynamically queries Hermes or JavaScript runtime memory statistics.
|
|
261
|
-
*/
|
|
262
250
|
export const getHermesMemoryStats = () => {
|
|
263
251
|
try {
|
|
264
252
|
const hermes = globalThis.HermesInternal;
|
|
@@ -287,9 +275,6 @@ export const getHermesMemoryStats = () => {
|
|
|
287
275
|
allocationRateMbPerSec: 1.2,
|
|
288
276
|
};
|
|
289
277
|
};
|
|
290
|
-
/**
|
|
291
|
-
* Dynamically records and evaluates screen navigation transition performance.
|
|
292
|
-
*/
|
|
293
278
|
export const trackNavigationTransition = (screenName, durationMs, options) => {
|
|
294
279
|
const duration = Math.max(1, Number(durationMs.toFixed(1)));
|
|
295
280
|
const tti = options?.ttiMs ? Number(options.ttiMs.toFixed(1)) : duration;
|
|
@@ -313,9 +298,6 @@ export const trackNavigationTransition = (screenName, durationMs, options) => {
|
|
|
313
298
|
severity: duration > 50 ? 'critical' : duration > 25 ? 'warning' : 'optimal',
|
|
314
299
|
});
|
|
315
300
|
};
|
|
316
|
-
/**
|
|
317
|
-
* React Hook that automatically profiles screen mounts and navigation transitions.
|
|
318
|
-
*/
|
|
319
301
|
export const useNavigationProfiler = (screenName, options) => {
|
|
320
302
|
const mountTimeRef = useRef(Date.now());
|
|
321
303
|
useEffect(() => {
|
|
@@ -326,9 +308,6 @@ export const useNavigationProfiler = (screenName, options) => {
|
|
|
326
308
|
}
|
|
327
309
|
}, [screenName]);
|
|
328
310
|
};
|
|
329
|
-
/**
|
|
330
|
-
* Measures synchronous execution duration and alerts on frame budget spikes (>16ms).
|
|
331
|
-
*/
|
|
332
311
|
export const trackHeavyTask = (taskName, syncFn, options) => {
|
|
333
312
|
const start = Date.now();
|
|
334
313
|
try {
|
|
@@ -356,9 +335,6 @@ export const trackHeavyTask = (taskName, syncFn, options) => {
|
|
|
356
335
|
}
|
|
357
336
|
}
|
|
358
337
|
};
|
|
359
|
-
/**
|
|
360
|
-
* Measures async operation / Promise latency and records slow network or disk tasks.
|
|
361
|
-
*/
|
|
362
338
|
export const measureAsync = async (taskName, asyncFn, options) => {
|
|
363
339
|
const start = Date.now();
|
|
364
340
|
try {
|
|
@@ -383,9 +359,6 @@ export const measureAsync = async (taskName, asyncFn, options) => {
|
|
|
383
359
|
}
|
|
384
360
|
}
|
|
385
361
|
};
|
|
386
|
-
/**
|
|
387
|
-
* Custom React Hook to profile any component or screen renders dynamically in runtime.
|
|
388
|
-
*/
|
|
389
362
|
export const useComponentProfiler = (componentName, options) => {
|
|
390
363
|
const renderCountRef = useRef(0);
|
|
391
364
|
const prevPropsRef = useRef(options?.propsToCompare);
|
|
@@ -396,7 +369,6 @@ export const useComponentProfiler = (componentName, options) => {
|
|
|
396
369
|
const duration = Date.now() - startTimeRef.current;
|
|
397
370
|
const now = Date.now();
|
|
398
371
|
renderCountRef.current += 1;
|
|
399
|
-
// Detect rapid re-render loop spikes (>= 10 renders within 500ms)
|
|
400
372
|
renderTimestampsRef.current = [
|
|
401
373
|
...renderTimestampsRef.current.filter(ts => now - ts <= 500),
|
|
402
374
|
now,
|
|
@@ -474,7 +446,6 @@ export const usePerformanceTracker = (enabled = true) => {
|
|
|
474
446
|
const lastFrameTimeRef = useRef(Date.now());
|
|
475
447
|
const rafIdRef = useRef(null);
|
|
476
448
|
const appStartTimestampRef = useRef(Date.now());
|
|
477
|
-
// Live Frame Measurement Loop
|
|
478
449
|
useEffect(() => {
|
|
479
450
|
if (!isTrackerActive || !isRecording)
|
|
480
451
|
return;
|
|
@@ -510,7 +481,6 @@ export const usePerformanceTracker = (enabled = true) => {
|
|
|
510
481
|
setAvgFps(Math.round(sum / next.length));
|
|
511
482
|
return next;
|
|
512
483
|
});
|
|
513
|
-
// Update live memory telemetry from Hermes / engine
|
|
514
484
|
const liveMem = getHermesMemoryStats();
|
|
515
485
|
setMemoryStats(prev => ({
|
|
516
486
|
...prev,
|
|
@@ -577,7 +547,6 @@ export const usePerformanceTracker = (enabled = true) => {
|
|
|
577
547
|
: 'Poor',
|
|
578
548
|
};
|
|
579
549
|
}, [totalFrames, jankyFrameCount, jsLagMs, events]);
|
|
580
|
-
// Aggregate re-render stats
|
|
581
550
|
const reRenderSummary = useMemo(() => {
|
|
582
551
|
const totalRenders = renderProfiles.reduce((sum, p) => sum + p.renderCount, 0);
|
|
583
552
|
const totalWasteful = renderProfiles.reduce((sum, p) => sum + p.wastefulCount, 0);
|
|
@@ -15,17 +15,5 @@ export declare const getActionHistory: () => ReduxHistoryEntry[];
|
|
|
15
15
|
export declare const clearActionHistory: () => void;
|
|
16
16
|
export declare const setReduxState: (state: any) => void;
|
|
17
17
|
export declare const subscribeReduxState: (cb: () => void) => () => void;
|
|
18
|
-
/**
|
|
19
|
-
* Standard Redux middleware — add it to your store to capture every action,
|
|
20
|
-
* including those dispatched from thunks, sagas and RTK Query:
|
|
21
|
-
*
|
|
22
|
-
* const store = configureStore({
|
|
23
|
-
* reducer,
|
|
24
|
-
* middleware: gDM => gDM().concat(inspectorReduxMiddleware),
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* Pair with `connectReduxStore(store)` (safe — they de-duplicate) or rely on
|
|
28
|
-
* the middleware alone; the initial snapshot is taken on the first action.
|
|
29
|
-
*/
|
|
30
18
|
export declare const inspectorReduxMiddleware: (storeApi: any) => (next: (action: any) => any) => (action: any) => any;
|
|
31
19
|
export declare const connectReduxStore: (store: any) => void;
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// #8 — Redux inspector module.
|
|
2
|
-
//
|
|
3
|
-
// Two integration paths, both feeding the same timeline/state snapshot:
|
|
4
|
-
//
|
|
5
|
-
// 1. `inspectorReduxMiddleware` (recommended) — a standard Redux middleware.
|
|
6
|
-
// Because it sits inside the middleware chain it sees EVERY action,
|
|
7
|
-
// including ones dispatched from thunks, sagas, listeners and RTK Query.
|
|
8
|
-
//
|
|
9
|
-
// 2. `connectReduxStore(store)` — zero-config fallback. It wraps the outer
|
|
10
|
-
// `store.dispatch` AND diffs state on `store.subscribe`, so even actions
|
|
11
|
-
// that bypass the wrapped dispatch (thunk/saga internals capture the raw
|
|
12
|
-
// dispatch reference at store-creation time) still update the state tree
|
|
13
|
-
// and per-reducer "last action" consistently.
|
|
14
1
|
import { parseStackLine } from '../helpers';
|
|
15
2
|
let currentReduxState = null;
|
|
16
3
|
const listeners = new Set();
|
|
@@ -41,9 +28,6 @@ export const pruneReduxHistory = (targetCount) => {
|
|
|
41
28
|
}
|
|
42
29
|
return Math.max(0, pruned);
|
|
43
30
|
};
|
|
44
|
-
// Guards against double-instrumentation (e.g. connectReduxStore called twice,
|
|
45
|
-
// or middleware + connect used together) which previously produced duplicate
|
|
46
|
-
// timeline entries and inconsistent counts.
|
|
47
31
|
const connectedStores = new WeakSet();
|
|
48
32
|
let middlewareAttached = false;
|
|
49
33
|
export const isReduxConnected = () => middlewareAttached || currentReduxState != null || actionHistory.length > 0;
|
|
@@ -89,7 +73,6 @@ function actionTypeOf(action) {
|
|
|
89
73
|
function detectActionOrigin(stack, actionType, actionObj) {
|
|
90
74
|
const stackLower = (stack || '').toLowerCase();
|
|
91
75
|
const typeLower = (actionType || '').toLowerCase();
|
|
92
|
-
// Explicit hint on action if developer tagged it
|
|
93
76
|
if (actionObj && actionObj.__origin) {
|
|
94
77
|
const raw = String(actionObj.__origin).toLowerCase();
|
|
95
78
|
if (raw.includes('saga'))
|
|
@@ -99,7 +82,6 @@ function detectActionOrigin(stack, actionType, actionObj) {
|
|
|
99
82
|
if (raw.includes('ui'))
|
|
100
83
|
return { originType: 'ui' };
|
|
101
84
|
}
|
|
102
|
-
// 1. Saga Detection (Stack + Action naming conventions)
|
|
103
85
|
const isSaga = stackLower.includes('redux-saga') ||
|
|
104
86
|
stackLower.includes('runputeffect') ||
|
|
105
87
|
stackLower.includes('proc.js') ||
|
|
@@ -111,7 +93,6 @@ function detectActionOrigin(stack, actionType, actionObj) {
|
|
|
111
93
|
typeLower.includes('saga') ||
|
|
112
94
|
typeLower.startsWith('saga/') ||
|
|
113
95
|
typeLower.startsWith('@saga/');
|
|
114
|
-
// 2. Thunk / RTK Query Detection
|
|
115
96
|
const isThunk = stackLower.includes('createasyncthunk') ||
|
|
116
97
|
stackLower.includes('redux-thunk') ||
|
|
117
98
|
stackLower.includes('rtk-query') ||
|
|
@@ -121,12 +102,10 @@ function detectActionOrigin(stack, actionType, actionObj) {
|
|
|
121
102
|
typeLower.endsWith('/pending') ||
|
|
122
103
|
typeLower.endsWith('/fulfilled') ||
|
|
123
104
|
typeLower.endsWith('/rejected');
|
|
124
|
-
// 3. Parse Stack Frames to find best application caller
|
|
125
105
|
const lines = (stack || '').split('\n').map(l => l.trim()).filter(Boolean);
|
|
126
106
|
let bestFrame = null;
|
|
127
107
|
for (let i = 0; i < lines.length; i++) {
|
|
128
108
|
const line = lines[i];
|
|
129
|
-
// Ignore logger / middleware lines inside inspector
|
|
130
109
|
if (line.includes('reduxLogger') ||
|
|
131
110
|
line.includes('inspectorReduxMiddleware') ||
|
|
132
111
|
line.includes('recordAction') ||
|
|
@@ -177,7 +156,6 @@ function extractSliceName(actionType, affectedSlices) {
|
|
|
177
156
|
if (affectedSlices && affectedSlices.length > 0) {
|
|
178
157
|
return affectedSlices[0];
|
|
179
158
|
}
|
|
180
|
-
// If Redux Toolkit action format: e.g. "users/fetchById" -> "users"
|
|
181
159
|
const match = actionType.match(/^([a-zA-Z0-9_\-]+)\//);
|
|
182
160
|
if (match && match[1] && !match[1].startsWith('@@')) {
|
|
183
161
|
return match[1];
|
|
@@ -242,27 +220,11 @@ function recordAction(action, prevState, nextState, rawStack) {
|
|
|
242
220
|
if (globalReduxAutoRefresh) {
|
|
243
221
|
currentReduxState = nextState;
|
|
244
222
|
}
|
|
245
|
-
// Timeline / last-action map always changed — notify even when the state
|
|
246
|
-
// tree snapshot is paused so those panels stay live.
|
|
247
223
|
notify();
|
|
248
224
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Standard Redux middleware — add it to your store to capture every action,
|
|
251
|
-
* including those dispatched from thunks, sagas and RTK Query:
|
|
252
|
-
*
|
|
253
|
-
* const store = configureStore({
|
|
254
|
-
* reducer,
|
|
255
|
-
* middleware: gDM => gDM().concat(inspectorReduxMiddleware),
|
|
256
|
-
* });
|
|
257
|
-
*
|
|
258
|
-
* Pair with `connectReduxStore(store)` (safe — they de-duplicate) or rely on
|
|
259
|
-
* the middleware alone; the initial snapshot is taken on the first action.
|
|
260
|
-
*/
|
|
261
225
|
export const inspectorReduxMiddleware = (storeApi) => (next) => (action) => {
|
|
262
226
|
middlewareAttached = true;
|
|
263
227
|
const capturedStack = new Error().stack || '';
|
|
264
|
-
// Thunks are functions — let them run; their inner plain-action dispatches
|
|
265
|
-
// pass back through this same middleware, so nothing is lost.
|
|
266
228
|
if (typeof action === 'function') {
|
|
267
229
|
return next(action);
|
|
268
230
|
}
|
|
@@ -281,22 +243,15 @@ export const connectReduxStore = (store) => {
|
|
|
281
243
|
console.warn('[NetworkInspector] Invalid Redux store passed to connectReduxStore.');
|
|
282
244
|
return;
|
|
283
245
|
}
|
|
284
|
-
// Idempotent — connecting the same store twice must not double-wrap
|
|
285
|
-
// dispatch or double-record the timeline.
|
|
286
246
|
if (connectedStores.has(store)) {
|
|
287
247
|
return;
|
|
288
248
|
}
|
|
289
249
|
connectedStores.add(store);
|
|
290
|
-
// Wrap the outer dispatch so directly dispatched actions get full
|
|
291
|
-
// type/payload attribution. Skipped when the middleware is already
|
|
292
|
-
// attached, otherwise every direct dispatch would be recorded twice.
|
|
293
250
|
const originalDispatch = store.dispatch.bind(store);
|
|
294
251
|
let inWrappedDispatch = false;
|
|
295
252
|
store.dispatch = (action) => {
|
|
296
253
|
const capturedStack = new Error().stack || '';
|
|
297
254
|
if (middlewareAttached || typeof action === 'function') {
|
|
298
|
-
// Middleware handles recording, or it's a thunk whose inner dispatches
|
|
299
|
-
// will be picked up individually.
|
|
300
255
|
inWrappedDispatch = true;
|
|
301
256
|
try {
|
|
302
257
|
return originalDispatch(action);
|
|
@@ -318,9 +273,6 @@ export const connectReduxStore = (store) => {
|
|
|
318
273
|
return result;
|
|
319
274
|
};
|
|
320
275
|
setReduxState(store.getState());
|
|
321
|
-
// Subscribe-diff fallback: catches state changes whose dispatch bypassed
|
|
322
|
-
// the wrapper above (thunk/saga internals hold the raw dispatch reference).
|
|
323
|
-
// Without this, the tree and per-reducer last-action drifted out of sync.
|
|
324
276
|
let lastSeenState = store.getState();
|
|
325
277
|
store.subscribe(() => {
|
|
326
278
|
const nextState = store.getState();
|
|
@@ -329,15 +281,12 @@ export const connectReduxStore = (store) => {
|
|
|
329
281
|
const prevState = lastSeenState;
|
|
330
282
|
lastSeenState = nextState;
|
|
331
283
|
if (inWrappedDispatch || middlewareAttached) {
|
|
332
|
-
// Already recorded with proper attribution; just refresh the snapshot.
|
|
333
284
|
if (globalReduxAutoRefresh) {
|
|
334
285
|
currentReduxState = nextState;
|
|
335
286
|
notify();
|
|
336
287
|
}
|
|
337
288
|
return;
|
|
338
289
|
}
|
|
339
|
-
// Change arrived outside the wrapped dispatch — record it so the
|
|
340
|
-
// timeline stays consistent, even without the original action type.
|
|
341
290
|
const subStack = new Error().stack || '';
|
|
342
291
|
recordAction({ type: '@@inspector/EXTERNAL_STATE_CHANGE' }, prevState, nextState, subStack);
|
|
343
292
|
});
|
|
@@ -6,62 +6,22 @@ export interface StorageEntry {
|
|
|
6
6
|
byteSize: number;
|
|
7
7
|
}
|
|
8
8
|
export type StorageDriver = 'asyncStorage' | 'mmkv';
|
|
9
|
-
/**
|
|
10
|
-
* Register an AsyncStorage instance with the inspector (optional override).
|
|
11
|
-
*/
|
|
12
9
|
export declare const connectAsyncStorage: (storageInstance: any) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Register an MMKV instance with the inspector (optional override).
|
|
15
|
-
*/
|
|
16
10
|
export declare const connectMMKV: (mmkvInstance: any, id?: string) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Auto-detect AsyncStorage:
|
|
19
|
-
* 1. Explicit connection
|
|
20
|
-
* 2. Global instance
|
|
21
|
-
* 3. Dynamic require '@react-native-async-storage/async-storage'
|
|
22
|
-
* 4. Native Bridge Direct interface
|
|
23
|
-
*/
|
|
24
11
|
export declare const getResolvedAsyncStorage: () => any;
|
|
25
|
-
/**
|
|
26
|
-
* Auto-detect MMKV:
|
|
27
|
-
* 1. Explicit connection
|
|
28
|
-
* 2. Dynamic require 'react-native-mmkv' & instantiate default instance
|
|
29
|
-
* 3. Global MMKV / JSI instances
|
|
30
|
-
*/
|
|
31
12
|
export declare const getResolvedMMKV: (id?: string) => any;
|
|
32
13
|
export declare const isAsyncStorageConnected: () => boolean;
|
|
33
14
|
export declare const isMMKVConnected: () => boolean;
|
|
34
15
|
export declare const getRegisteredMMKVInstanceIds: () => string[];
|
|
35
|
-
/**
|
|
36
|
-
* Calculate approximate byte size of a UTF-8 string
|
|
37
|
-
*/
|
|
38
16
|
export declare const calculateByteSize: (str: string) => number;
|
|
39
|
-
/**
|
|
40
|
-
* Determine type and format value safely without blocking JS thread
|
|
41
|
-
*/
|
|
42
17
|
export declare const analyzeStorageValue: (rawVal: any) => {
|
|
43
18
|
strVal: string;
|
|
44
19
|
parsedValue?: any;
|
|
45
20
|
type: "json" | "string" | "number" | "boolean" | "null";
|
|
46
21
|
byteSize: number;
|
|
47
22
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Fetch all storage entries for given driver
|
|
50
|
-
*/
|
|
51
23
|
export declare const fetchStorageEntries: (driver: StorageDriver, instanceId?: string) => Promise<StorageEntry[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Create or Update a key-value entry (CRUD: Create / Update)
|
|
54
|
-
*/
|
|
55
24
|
export declare const setStorageEntry: (driver: StorageDriver, key: string, value: string, instanceId?: string) => Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* Delete a single key (CRUD: Delete)
|
|
58
|
-
*/
|
|
59
25
|
export declare const removeStorageEntry: (driver: StorageDriver, key: string, instanceId?: string) => Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Wipe all keys for given storage (CRUD: Clear All)
|
|
62
|
-
*/
|
|
63
26
|
export declare const clearStorageDriver: (driver: StorageDriver, instanceId?: string) => Promise<boolean>;
|
|
64
|
-
/**
|
|
65
|
-
* Subscribe to storage mutations
|
|
66
|
-
*/
|
|
67
27
|
export declare const subscribeToStorageChanges: (listener: () => void) => (() => void);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// Universal In-App Storage Inspector Adapter for AsyncStorage & MMKV
|
|
2
|
-
// Supports automatic module resolution, NativeModules SQLite fallback, custom instances, and full CRUD operations.
|
|
3
1
|
import { NativeModules } from 'react-native';
|
|
4
|
-
// In-memory registered storage references
|
|
5
2
|
let customAsyncStorage = null;
|
|
6
3
|
const customMMKVInstances = new Map();
|
|
7
|
-
// Listeners for storage mutations
|
|
8
4
|
const changeListeners = new Set();
|
|
9
5
|
const notifyChange = () => {
|
|
10
6
|
changeListeners.forEach(listener => {
|
|
@@ -14,28 +10,18 @@ const notifyChange = () => {
|
|
|
14
10
|
catch { }
|
|
15
11
|
});
|
|
16
12
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Register an AsyncStorage instance with the inspector (optional override).
|
|
19
|
-
*/
|
|
20
13
|
export const connectAsyncStorage = (storageInstance) => {
|
|
21
14
|
if (storageInstance) {
|
|
22
15
|
customAsyncStorage = storageInstance;
|
|
23
16
|
notifyChange();
|
|
24
17
|
}
|
|
25
18
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Register an MMKV instance with the inspector (optional override).
|
|
28
|
-
*/
|
|
29
19
|
export const connectMMKV = (mmkvInstance, id = 'default') => {
|
|
30
20
|
if (mmkvInstance) {
|
|
31
21
|
customMMKVInstances.set(id, mmkvInstance);
|
|
32
22
|
notifyChange();
|
|
33
23
|
}
|
|
34
24
|
};
|
|
35
|
-
/**
|
|
36
|
-
* Native Bridge Fallback for AsyncStorage:
|
|
37
|
-
* Directly interfaces with NativeModules.RNCAsyncStorage without needing JS package imports.
|
|
38
|
-
*/
|
|
39
25
|
const getNativeAsyncStorageBridge = () => {
|
|
40
26
|
const nativeModule = NativeModules.RNCAsyncStorage ||
|
|
41
27
|
NativeModules.RNC_AsyncSQLiteDBStorage ||
|
|
@@ -130,17 +116,9 @@ const getNativeAsyncStorageBridge = () => {
|
|
|
130
116
|
}
|
|
131
117
|
return null;
|
|
132
118
|
};
|
|
133
|
-
/**
|
|
134
|
-
* Auto-detect AsyncStorage:
|
|
135
|
-
* 1. Explicit connection
|
|
136
|
-
* 2. Global instance
|
|
137
|
-
* 3. Dynamic require '@react-native-async-storage/async-storage'
|
|
138
|
-
* 4. Native Bridge Direct interface
|
|
139
|
-
*/
|
|
140
119
|
export const getResolvedAsyncStorage = () => {
|
|
141
120
|
if (customAsyncStorage)
|
|
142
121
|
return customAsyncStorage;
|
|
143
|
-
// 1. Global instances
|
|
144
122
|
try {
|
|
145
123
|
const maybeReq = globalThis?.__inAppAsyncStorage ||
|
|
146
124
|
globalThis?.AsyncStorage ||
|
|
@@ -150,7 +128,6 @@ export const getResolvedAsyncStorage = () => {
|
|
|
150
128
|
}
|
|
151
129
|
}
|
|
152
130
|
catch { }
|
|
153
|
-
// 2. Dynamic runtime require
|
|
154
131
|
try {
|
|
155
132
|
const req = typeof globalThis?.require === 'function'
|
|
156
133
|
? globalThis.require
|
|
@@ -177,24 +154,16 @@ export const getResolvedAsyncStorage = () => {
|
|
|
177
154
|
}
|
|
178
155
|
}
|
|
179
156
|
catch { }
|
|
180
|
-
// 3. Native Bridge Fallback (Direct SQLite)
|
|
181
157
|
const nativeBridge = getNativeAsyncStorageBridge();
|
|
182
158
|
if (nativeBridge) {
|
|
183
159
|
return nativeBridge;
|
|
184
160
|
}
|
|
185
161
|
return null;
|
|
186
162
|
};
|
|
187
|
-
/**
|
|
188
|
-
* Auto-detect MMKV:
|
|
189
|
-
* 1. Explicit connection
|
|
190
|
-
* 2. Dynamic require 'react-native-mmkv' & instantiate default instance
|
|
191
|
-
* 3. Global MMKV / JSI instances
|
|
192
|
-
*/
|
|
193
163
|
export const getResolvedMMKV = (id = 'default') => {
|
|
194
164
|
if (customMMKVInstances.has(id)) {
|
|
195
165
|
return customMMKVInstances.get(id);
|
|
196
166
|
}
|
|
197
|
-
// 1. Dynamic require
|
|
198
167
|
try {
|
|
199
168
|
const req = typeof globalThis?.require === 'function'
|
|
200
169
|
? globalThis.require
|
|
@@ -216,7 +185,6 @@ export const getResolvedMMKV = (id = 'default') => {
|
|
|
216
185
|
}
|
|
217
186
|
}
|
|
218
187
|
catch { }
|
|
219
|
-
// 2. Global references
|
|
220
188
|
try {
|
|
221
189
|
const globalMMKV = globalThis?.mmkv ||
|
|
222
190
|
global?.mmkv ||
|
|
@@ -243,20 +211,14 @@ export const isMMKVConnected = () => {
|
|
|
243
211
|
return Boolean(getResolvedMMKV());
|
|
244
212
|
};
|
|
245
213
|
export const getRegisteredMMKVInstanceIds = () => {
|
|
246
|
-
getResolvedMMKV();
|
|
214
|
+
getResolvedMMKV();
|
|
247
215
|
return Array.from(customMMKVInstances.keys());
|
|
248
216
|
};
|
|
249
|
-
/**
|
|
250
|
-
* Calculate approximate byte size of a UTF-8 string
|
|
251
|
-
*/
|
|
252
217
|
export const calculateByteSize = (str) => {
|
|
253
218
|
if (!str)
|
|
254
219
|
return 0;
|
|
255
220
|
return str.length * 2;
|
|
256
221
|
};
|
|
257
|
-
/**
|
|
258
|
-
* Determine type and format value safely without blocking JS thread
|
|
259
|
-
*/
|
|
260
222
|
export const analyzeStorageValue = (rawVal) => {
|
|
261
223
|
if (rawVal === null || rawVal === undefined) {
|
|
262
224
|
return { strVal: 'null', type: 'null', byteSize: 4 };
|
|
@@ -272,7 +234,6 @@ export const analyzeStorageValue = (rawVal) => {
|
|
|
272
234
|
const trimmed = strVal.trim();
|
|
273
235
|
if ((trimmed.startsWith('{') && trimmed.endsWith('}')) ||
|
|
274
236
|
(trimmed.startsWith('[') && trimmed.endsWith(']'))) {
|
|
275
|
-
// For small/medium JSON, parse eagerly; for huge payloads (>10KB), parse lazily on expand
|
|
276
237
|
if (trimmed.length < 10000) {
|
|
277
238
|
try {
|
|
278
239
|
const parsed = JSON.parse(trimmed);
|
|
@@ -290,9 +251,6 @@ export const analyzeStorageValue = (rawVal) => {
|
|
|
290
251
|
}
|
|
291
252
|
return { strVal, type: 'string', byteSize };
|
|
292
253
|
};
|
|
293
|
-
/**
|
|
294
|
-
* Fetch all storage entries for given driver
|
|
295
|
-
*/
|
|
296
254
|
export const fetchStorageEntries = async (driver, instanceId) => {
|
|
297
255
|
const entries = [];
|
|
298
256
|
if (driver === 'asyncStorage') {
|
|
@@ -375,13 +333,9 @@ export const fetchStorageEntries = async (driver, instanceId) => {
|
|
|
375
333
|
console.warn('[StorageInspector] Error reading MMKV keys:', err);
|
|
376
334
|
}
|
|
377
335
|
}
|
|
378
|
-
// Sort alphabetically by key
|
|
379
336
|
entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
380
337
|
return entries;
|
|
381
338
|
};
|
|
382
|
-
/**
|
|
383
|
-
* Create or Update a key-value entry (CRUD: Create / Update)
|
|
384
|
-
*/
|
|
385
339
|
export const setStorageEntry = async (driver, key, value, instanceId) => {
|
|
386
340
|
if (!key.trim())
|
|
387
341
|
return false;
|
|
@@ -408,9 +362,6 @@ export const setStorageEntry = async (driver, key, value, instanceId) => {
|
|
|
408
362
|
}
|
|
409
363
|
return false;
|
|
410
364
|
};
|
|
411
|
-
/**
|
|
412
|
-
* Delete a single key (CRUD: Delete)
|
|
413
|
-
*/
|
|
414
365
|
export const removeStorageEntry = async (driver, key, instanceId) => {
|
|
415
366
|
try {
|
|
416
367
|
if (driver === 'asyncStorage') {
|
|
@@ -435,9 +386,6 @@ export const removeStorageEntry = async (driver, key, instanceId) => {
|
|
|
435
386
|
}
|
|
436
387
|
return false;
|
|
437
388
|
};
|
|
438
|
-
/**
|
|
439
|
-
* Wipe all keys for given storage (CRUD: Clear All)
|
|
440
|
-
*/
|
|
441
389
|
export const clearStorageDriver = async (driver, instanceId) => {
|
|
442
390
|
try {
|
|
443
391
|
if (driver === 'asyncStorage') {
|
|
@@ -462,9 +410,6 @@ export const clearStorageDriver = async (driver, instanceId) => {
|
|
|
462
410
|
}
|
|
463
411
|
return false;
|
|
464
412
|
};
|
|
465
|
-
/**
|
|
466
|
-
* Subscribe to storage mutations
|
|
467
|
-
*/
|
|
468
413
|
export const subscribeToStorageChanges = (listener) => {
|
|
469
414
|
changeListeners.add(listener);
|
|
470
415
|
return () => {
|
|
@@ -4,45 +4,8 @@ export interface InspectLogOptions {
|
|
|
4
4
|
logResult?: boolean;
|
|
5
5
|
logDuration?: boolean;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* `@InspectLog`: Automatically logs method execution, arguments, duration, and return values
|
|
9
|
-
* to the In-App Inspector Console.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* class UserService {
|
|
14
|
-
* @InspectLog({ tag: 'API', logArgs: true, logDuration: true })
|
|
15
|
-
* async fetchUser(id: string) {
|
|
16
|
-
* return api.get(`/users/${id}`);
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
7
|
export declare function InspectLog(options?: InspectLogOptions): (_target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
22
|
-
/**
|
|
23
|
-
* `@InspectTrackTime`: Measures and logs execution duration for critical functions.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* class FeedManager {
|
|
28
|
-
* @InspectTrackTime('Feed Data Processing')
|
|
29
|
-
* processFeedItems(items: FeedItem[]) { ... }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
8
|
export declare function InspectTrackTime(label?: string): (_target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
34
|
-
/**
|
|
35
|
-
* `@InspectCatch`: Safely catches unhandled exceptions thrown inside the method,
|
|
36
|
-
* logs them to the In-App Inspector, and returns a fallback value.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* class AuthService {
|
|
41
|
-
* @InspectCatch({ fallback: null, tag: 'AUTH' })
|
|
42
|
-
* async getCachedToken() { ... }
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
9
|
export declare function InspectCatch(options?: {
|
|
47
10
|
fallback?: any;
|
|
48
11
|
tag?: string;
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
// ─── Method & Class Decorators for React Native In-App Inspector ─────────────
|
|
2
|
-
//
|
|
3
|
-
// Clean TypeScript decorators to seamlessly annotate methods, asynchronous actions,
|
|
4
|
-
// and API services with automatic inspection, logging, timing, and error boundaries.
|
|
5
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
-
/**
|
|
7
|
-
* `@InspectLog`: Automatically logs method execution, arguments, duration, and return values
|
|
8
|
-
* to the In-App Inspector Console.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class UserService {
|
|
13
|
-
* @InspectLog({ tag: 'API', logArgs: true, logDuration: true })
|
|
14
|
-
* async fetchUser(id: string) {
|
|
15
|
-
* return api.get(`/users/${id}`);
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
1
|
export function InspectLog(options = {}) {
|
|
21
2
|
const { tag = 'Inspect', logArgs = true, logResult = true, logDuration = true, } = options;
|
|
22
3
|
return function (_target, propertyKey, descriptor) {
|
|
@@ -62,17 +43,6 @@ export function InspectLog(options = {}) {
|
|
|
62
43
|
return descriptor;
|
|
63
44
|
};
|
|
64
45
|
}
|
|
65
|
-
/**
|
|
66
|
-
* `@InspectTrackTime`: Measures and logs execution duration for critical functions.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```ts
|
|
70
|
-
* class FeedManager {
|
|
71
|
-
* @InspectTrackTime('Feed Data Processing')
|
|
72
|
-
* processFeedItems(items: FeedItem[]) { ... }
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
46
|
export function InspectTrackTime(label) {
|
|
77
47
|
return function (_target, propertyKey, descriptor) {
|
|
78
48
|
const originalMethod = descriptor.value;
|
|
@@ -100,18 +70,6 @@ export function InspectTrackTime(label) {
|
|
|
100
70
|
return descriptor;
|
|
101
71
|
};
|
|
102
72
|
}
|
|
103
|
-
/**
|
|
104
|
-
* `@InspectCatch`: Safely catches unhandled exceptions thrown inside the method,
|
|
105
|
-
* logs them to the In-App Inspector, and returns a fallback value.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```ts
|
|
109
|
-
* class AuthService {
|
|
110
|
-
* @InspectCatch({ fallback: null, tag: 'AUTH' })
|
|
111
|
-
* async getCachedToken() { ... }
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
73
|
export function InspectCatch(options = {}) {
|
|
116
74
|
const { fallback = undefined, tag = 'Catch' } = options;
|
|
117
75
|
return function (_target, propertyKey, descriptor) {
|
|
@@ -4,15 +4,5 @@ export interface GAPlugin {
|
|
|
4
4
|
name: string;
|
|
5
5
|
resolveCategory?: (eventName: string, params?: Record<string, any>) => GAEventCategory | string | null | undefined;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Register a dynamic Google Analytics / Firebase plugin or custom resolver.
|
|
9
|
-
*/
|
|
10
7
|
export declare const registerGAPlugin: (plugin: GAPlugin) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Dynamically resolves the GA4 event category using:
|
|
13
|
-
* 1. Registered dynamic GA plugins
|
|
14
|
-
* 2. Runtime Firebase Analytics inspection
|
|
15
|
-
* 3. GA4 standard event taxonomies (O(1) Set lookup)
|
|
16
|
-
* 4. Semantic pattern & prefix analysis
|
|
17
|
-
*/
|
|
18
8
|
export declare const getEventCategory: (name: string, params?: Record<string, any>) => GAEventCategory;
|