react-native-inapp-inspector 2.3.18 → 2.3.20
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/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +57 -0
- package/dist/commonjs/analytics.js +1 -24
- package/dist/commonjs/bundle.js +1 -16
- package/dist/commonjs/capture.d.ts +2 -0
- package/dist/commonjs/capture.js +1 -32
- package/dist/commonjs/components/AnalyticsDetail.js +92 -623
- package/dist/commonjs/components/AnalyticsEventCard.js +54 -350
- package/dist/commonjs/components/AnalyticsGraph.js +70 -370
- package/dist/commonjs/components/AnimatedEntrance.js +1 -11
- package/dist/commonjs/components/AppHeaderLogo.js +7 -134
- package/dist/commonjs/components/BrandCircleIcon.js +73 -118
- package/dist/commonjs/components/BrandSquareIcon.js +63 -108
- package/dist/commonjs/components/CodeSnippet.js +48 -623
- package/dist/commonjs/components/ConsoleLogCard.js +63 -537
- package/dist/commonjs/components/CopyButton.js +3 -89
- package/dist/commonjs/components/DiffViewer.js +19 -83
- package/dist/commonjs/components/DomainHeader.js +27 -127
- package/dist/commonjs/components/EmptyState.d.ts +1 -0
- package/dist/commonjs/components/EmptyState.js +10 -87
- package/dist/commonjs/components/EndOfListFooter.js +7 -81
- package/dist/commonjs/components/ErrorBoundary.js +72 -566
- package/dist/commonjs/components/HeadersSection.js +31 -110
- package/dist/commonjs/components/HighlightText.js +17 -58
- package/dist/commonjs/components/Inspector/AboutModal.d.ts +6 -0
- package/dist/commonjs/components/Inspector/AboutModal.js +351 -0
- package/dist/commonjs/components/Inspector/AnalyticsFilterModal.js +98 -797
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +284 -930
- package/dist/commonjs/components/Inspector/BundleTab.js +551 -2918
- package/dist/commonjs/components/Inspector/ConsoleTab.js +79 -492
- package/dist/commonjs/components/Inspector/CrashDetail.js +123 -672
- package/dist/commonjs/components/Inspector/CrashFilterModal.js +66 -498
- package/dist/commonjs/components/Inspector/CrashTab.js +98 -670
- package/dist/commonjs/components/Inspector/DebuggingTab.js +64 -871
- package/dist/commonjs/components/Inspector/DeviceInfoTab.js +143 -907
- package/dist/commonjs/components/Inspector/FabLauncher.js +85 -54
- package/dist/commonjs/components/Inspector/FeatureUnderDevNotice.js +6 -99
- package/dist/commonjs/components/Inspector/FeedbackModal.d.ts +9 -0
- package/dist/commonjs/components/Inspector/FeedbackModal.js +167 -521
- package/dist/commonjs/components/Inspector/InspectorContext.js +1 -21
- package/dist/commonjs/components/Inspector/InspectorHeader.js +219 -1093
- package/dist/commonjs/components/Inspector/LogDetail.js +168 -994
- package/dist/commonjs/components/Inspector/MainScreen.js +60 -332
- package/dist/commonjs/components/Inspector/MediaGalleryTab.js +136 -278
- package/dist/commonjs/components/Inspector/MediaPreviewModal.js +134 -361
- package/dist/commonjs/components/Inspector/NavigationTracker.js +1 -12
- package/dist/commonjs/components/Inspector/NetworkDetail.js +96 -432
- package/dist/commonjs/components/Inspector/NetworkFilterModal.js +60 -576
- package/dist/commonjs/components/Inspector/NetworkTab.js +84 -514
- package/dist/commonjs/components/Inspector/NpmStarPrompt.js +17 -433
- package/dist/commonjs/components/Inspector/NpmUpdateToast.js +25 -298
- package/dist/commonjs/components/Inspector/PerformanceTab.js +182 -1397
- package/dist/commonjs/components/Inspector/ReduxDetail.js +188 -1089
- package/dist/commonjs/components/Inspector/ReduxTab.js +85 -701
- package/dist/commonjs/components/Inspector/SettingsPanel.js +431 -3431
- package/dist/commonjs/components/Inspector/SkeletonPlaceholder.js +11 -180
- package/dist/commonjs/components/Inspector/StorageTab.js +93 -826
- package/dist/commonjs/components/Inspector/TabBar.js +47 -183
- package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +34 -408
- package/dist/commonjs/components/JsonViewer.js +168 -380
- package/dist/commonjs/components/LogCard.js +57 -567
- package/dist/commonjs/components/LogSyntaxHighlighter.js +11 -130
- package/dist/commonjs/components/MetaAccordion.js +69 -238
- package/dist/commonjs/components/MiniBarChart.js +3 -56
- package/dist/commonjs/components/MiniLineChart.js +3 -58
- package/dist/commonjs/components/NetworkIcons.d.ts +7 -0
- package/dist/commonjs/components/NetworkIcons.js +479 -997
- package/dist/commonjs/components/QRCodeView.js +5 -79
- package/dist/commonjs/components/SectionHeader.js +15 -37
- package/dist/commonjs/components/SegmentedTabs.js +7 -61
- package/dist/commonjs/components/SkeletonPlaceholder.js +11 -180
- package/dist/commonjs/components/Slider.js +15 -243
- package/dist/commonjs/components/SourcePageCard.js +30 -89
- package/dist/commonjs/components/Toast.js +5 -147
- package/dist/commonjs/components/TouchableScale.js +3 -24
- package/dist/commonjs/components/TreeNode.js +55 -130
- package/dist/commonjs/console.js +1 -16
- package/dist/commonjs/constants/index.js +1 -32
- package/dist/commonjs/constants/telemetryConfig.js +1 -6
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -4
- package/dist/commonjs/crash.js +1 -23
- package/dist/commonjs/customHooks/analyticsLogger.js +1 -250
- package/dist/commonjs/customHooks/bundleAnalyzer.js +1 -957
- package/dist/commonjs/customHooks/consoleLogger.js +6 -445
- package/dist/commonjs/customHooks/crashHandler.js +7 -656
- package/dist/commonjs/customHooks/logFilters.js +1 -23
- package/dist/commonjs/customHooks/networkLogger.js +2 -536
- package/dist/commonjs/customHooks/performanceTracker.js +63 -750
- package/dist/commonjs/customHooks/reduxLogger.js +2 -313
- package/dist/commonjs/customHooks/storageInspector.js +1 -435
- package/dist/commonjs/customHooks/useAccordion.js +1 -18
- package/dist/commonjs/decorators/index.js +1 -100
- package/dist/commonjs/helpers/gaAnalyticsRegistry.js +1 -148
- package/dist/commonjs/helpers/index.js +8 -921
- package/dist/commonjs/helpers/memoryManager.js +1 -99
- package/dist/commonjs/helpers/qrGenerator.js +1 -367
- package/dist/commonjs/helpers/remoteConfig.js +1 -165
- package/dist/commonjs/helpers/searchQueryParser.js +1 -62
- package/dist/commonjs/helpers/settingsStore.js +1 -144
- package/dist/commonjs/helpers/telemetry.js +1 -501
- package/dist/commonjs/helpers/toast.js +1 -20
- package/dist/commonjs/i18n/index.js +1 -90
- package/dist/commonjs/i18n/locales/en.json +1 -1122
- package/dist/commonjs/index.js +5 -2153
- package/dist/commonjs/metro.js +6 -468
- package/dist/commonjs/native/NativeInspector.d.ts +3 -0
- package/dist/commonjs/native/NativeInspector.js +1 -402
- package/dist/commonjs/native/NativeNetworkInspector.d.ts +1 -0
- package/dist/commonjs/native/NativeNetworkInspector.js +1 -4
- package/dist/commonjs/network.js +1 -13
- package/dist/commonjs/performance.js +1 -29
- package/dist/commonjs/redux.js +1 -20
- package/dist/commonjs/storage.js +1 -14
- package/dist/commonjs/styles/AppColors.js +1 -423
- package/dist/commonjs/styles/AppFonts.js +1 -17
- package/dist/commonjs/styles/common.js +1 -190
- package/dist/commonjs/styles/index.d.ts +6 -0
- package/dist/commonjs/styles/index.js +1 -1589
- package/dist/commonjs/types/enums.d.ts +2 -1
- package/dist/commonjs/types/enums.js +1 -150
- package/dist/commonjs/types/index.js +1 -18
- package/dist/commonjs/types/interfaces.d.ts +7 -0
- package/dist/commonjs/types/interfaces.js +1 -2
- package/dist/esm/analytics.js +1 -2
- package/dist/esm/bundle.js +1 -2
- package/dist/esm/capture.d.ts +2 -0
- package/dist/esm/capture.js +1 -29
- package/dist/esm/components/AnalyticsDetail.js +171 -664
- package/dist/esm/components/AnalyticsEventCard.js +77 -335
- package/dist/esm/components/AnalyticsGraph.js +95 -357
- package/dist/esm/components/AnimatedEntrance.js +1 -6
- package/dist/esm/components/AppHeaderLogo.js +7 -94
- package/dist/esm/components/BrandCircleIcon.js +114 -119
- package/dist/esm/components/BrandSquareIcon.js +73 -78
- package/dist/esm/components/CodeSnippet.js +58 -595
- package/dist/esm/components/ConsoleLogCard.js +91 -526
- package/dist/esm/components/CopyButton.js +3 -51
- package/dist/esm/components/DiffViewer.js +22 -48
- package/dist/esm/components/DomainHeader.js +43 -138
- package/dist/esm/components/EmptyState.d.ts +1 -0
- package/dist/esm/components/EmptyState.js +17 -56
- package/dist/esm/components/EndOfListFooter.js +15 -83
- package/dist/esm/components/ErrorBoundary.js +125 -582
- package/dist/esm/components/HeadersSection.js +52 -93
- package/dist/esm/components/HighlightText.js +17 -53
- package/dist/esm/components/Inspector/AboutModal.d.ts +6 -0
- package/dist/esm/components/Inspector/AboutModal.js +351 -0
- package/dist/esm/components/Inspector/AnalyticsFilterModal.js +225 -886
- package/dist/esm/components/Inspector/AnalyticsTab.js +296 -904
- package/dist/esm/components/Inspector/BundleTab.js +1175 -3502
- package/dist/esm/components/Inspector/ConsoleTab.js +113 -488
- package/dist/esm/components/Inspector/CrashDetail.js +236 -747
- package/dist/esm/components/Inspector/CrashFilterModal.js +149 -541
- package/dist/esm/components/Inspector/CrashTab.js +177 -711
- package/dist/esm/components/Inspector/DebuggingTab.js +156 -923
- package/dist/esm/components/Inspector/DeviceInfoTab.js +199 -924
- package/dist/esm/components/Inspector/FabLauncher.js +85 -49
- package/dist/esm/components/Inspector/FeatureUnderDevNotice.js +14 -70
- package/dist/esm/components/Inspector/FeedbackModal.d.ts +9 -0
- package/dist/esm/components/Inspector/FeedbackModal.js +182 -499
- package/dist/esm/components/Inspector/InspectorContext.js +1 -12
- package/dist/esm/components/Inspector/InspectorHeader.js +309 -1145
- package/dist/esm/components/Inspector/LogDetail.js +235 -1023
- package/dist/esm/components/Inspector/MainScreen.js +86 -320
- package/dist/esm/components/Inspector/MediaGalleryTab.js +157 -259
- package/dist/esm/components/Inspector/MediaPreviewModal.js +153 -340
- package/dist/esm/components/Inspector/NavigationTracker.js +1 -10
- package/dist/esm/components/Inspector/NetworkDetail.js +141 -472
- package/dist/esm/components/Inspector/NetworkFilterModal.js +122 -597
- package/dist/esm/components/Inspector/NetworkTab.js +125 -517
- package/dist/esm/components/Inspector/NpmStarPrompt.js +58 -434
- package/dist/esm/components/Inspector/NpmUpdateToast.js +45 -281
- package/dist/esm/components/Inspector/PerformanceTab.js +393 -1570
- package/dist/esm/components/Inspector/ReduxDetail.js +307 -1170
- package/dist/esm/components/Inspector/ReduxTab.js +144 -722
- package/dist/esm/components/Inspector/SettingsPanel.js +647 -3609
- package/dist/esm/components/Inspector/SkeletonPlaceholder.js +30 -163
- package/dist/esm/components/Inspector/StorageTab.js +172 -866
- package/dist/esm/components/Inspector/TabBar.js +52 -183
- package/dist/esm/components/Inspector/UpdateAvailableModal.js +79 -416
- package/dist/esm/components/JsonViewer.js +179 -353
- package/dist/esm/components/LogCard.js +93 -565
- package/dist/esm/components/LogSyntaxHighlighter.js +11 -123
- package/dist/esm/components/MetaAccordion.js +136 -267
- package/dist/esm/components/MiniBarChart.js +3 -18
- package/dist/esm/components/MiniLineChart.js +3 -20
- package/dist/esm/components/NetworkIcons.d.ts +7 -0
- package/dist/esm/components/NetworkIcons.js +481 -817
- package/dist/esm/components/QRCodeView.js +8 -45
- package/dist/esm/components/SectionHeader.js +22 -39
- package/dist/esm/components/SegmentedTabs.js +8 -57
- package/dist/esm/components/SkeletonPlaceholder.js +30 -163
- package/dist/esm/components/Slider.js +24 -213
- package/dist/esm/components/SourcePageCard.js +65 -86
- package/dist/esm/components/Toast.js +10 -117
- package/dist/esm/components/TouchableScale.js +3 -19
- package/dist/esm/components/TreeNode.js +58 -95
- package/dist/esm/console.js +1 -2
- package/dist/esm/constants/index.js +1 -28
- package/dist/esm/constants/telemetryConfig.js +1 -3
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/crash.js +1 -2
- package/dist/esm/customHooks/analyticsLogger.js +1 -230
- package/dist/esm/customHooks/bundleAnalyzer.js +1 -944
- package/dist/esm/customHooks/consoleLogger.js +6 -432
- package/dist/esm/customHooks/crashHandler.js +7 -630
- package/dist/esm/customHooks/logFilters.js +1 -20
- package/dist/esm/customHooks/networkLogger.js +2 -519
- package/dist/esm/customHooks/performanceTracker.js +63 -723
- package/dist/esm/customHooks/reduxLogger.js +2 -293
- package/dist/esm/customHooks/storageInspector.js +1 -418
- package/dist/esm/customHooks/useAccordion.js +1 -16
- package/dist/esm/decorators/index.js +1 -95
- package/dist/esm/helpers/gaAnalyticsRegistry.js +1 -143
- package/dist/esm/helpers/index.js +8 -861
- package/dist/esm/helpers/memoryManager.js +1 -91
- package/dist/esm/helpers/qrGenerator.js +1 -364
- package/dist/esm/helpers/remoteConfig.js +1 -160
- package/dist/esm/helpers/searchQueryParser.js +1 -59
- package/dist/esm/helpers/settingsStore.js +1 -134
- package/dist/esm/helpers/telemetry.js +1 -489
- package/dist/esm/helpers/toast.js +1 -15
- package/dist/esm/i18n/index.js +1 -78
- package/dist/esm/i18n/locales/en.json +1 -1122
- package/dist/esm/index.js +7 -1967
- package/dist/esm/metro.js +6 -459
- package/dist/esm/native/NativeInspector.d.ts +3 -0
- package/dist/esm/native/NativeInspector.js +1 -370
- package/dist/esm/native/NativeNetworkInspector.d.ts +1 -0
- package/dist/esm/native/NativeNetworkInspector.js +1 -2
- package/dist/esm/network.js +1 -1
- package/dist/esm/performance.js +1 -2
- package/dist/esm/redux.js +1 -1
- package/dist/esm/storage.js +1 -1
- package/dist/esm/styles/AppColors.js +1 -417
- package/dist/esm/styles/AppFonts.js +1 -13
- package/dist/esm/styles/common.js +1 -186
- package/dist/esm/styles/index.d.ts +6 -0
- package/dist/esm/styles/index.js +1 -1551
- package/dist/esm/types/enums.d.ts +2 -1
- package/dist/esm/types/enums.js +1 -147
- package/dist/esm/types/index.js +1 -2
- package/dist/esm/types/interfaces.d.ts +7 -0
- package/dist/esm/types/interfaces.js +1 -1
- package/ios/NetworkInspectorModule.mm +253 -136
- package/package.json +5 -3
- package/react-native-inapp-inspector.podspec +1 -1
- package/src/native/NativeInspector.ts +17 -0
- package/src/native/NativeNetworkInspector.ts +1 -0
- package/src/analytics.ts +0 -35
- package/src/bundle.ts +0 -25
- package/src/capture.ts +0 -101
- package/src/components/AnalyticsDetail.tsx +0 -870
- package/src/components/AnalyticsEventCard.tsx +0 -444
- package/src/components/AnalyticsGraph.tsx +0 -583
- package/src/components/AnimatedEntrance.tsx +0 -20
- package/src/components/AppHeaderLogo.tsx +0 -143
- package/src/components/BrandCircleIcon.tsx +0 -144
- package/src/components/BrandSquareIcon.tsx +0 -184
- package/src/components/CodeSnippet.tsx +0 -725
- package/src/components/ConsoleLogCard.tsx +0 -679
- package/src/components/CopyButton.tsx +0 -87
- package/src/components/DiffViewer.tsx +0 -82
- package/src/components/DomainHeader.tsx +0 -224
- package/src/components/EmptyState.tsx +0 -95
- package/src/components/EndOfListFooter.tsx +0 -100
- package/src/components/ErrorBoundary.tsx +0 -688
- package/src/components/HeadersSection.tsx +0 -172
- package/src/components/HighlightText.tsx +0 -100
- package/src/components/Inspector/AnalyticsFilterModal.tsx +0 -1250
- package/src/components/Inspector/AnalyticsTab.tsx +0 -1362
- package/src/components/Inspector/BundleTab.tsx +0 -4768
- package/src/components/Inspector/ConsoleTab.tsx +0 -726
- package/src/components/Inspector/CrashDetail.tsx +0 -997
- package/src/components/Inspector/CrashFilterModal.tsx +0 -721
- package/src/components/Inspector/CrashTab.tsx +0 -933
- package/src/components/Inspector/DebuggingTab.tsx +0 -1103
- package/src/components/Inspector/DeviceInfoTab.tsx +0 -1397
- package/src/components/Inspector/FabLauncher.tsx +0 -80
- package/src/components/Inspector/FeatureUnderDevNotice.tsx +0 -94
- package/src/components/Inspector/FeedbackModal.tsx +0 -626
- package/src/components/Inspector/InspectorContext.tsx +0 -28
- package/src/components/Inspector/InspectorHeader.tsx +0 -1545
- package/src/components/Inspector/LogDetail.tsx +0 -1431
- package/src/components/Inspector/MainScreen.tsx +0 -459
- package/src/components/Inspector/MediaGalleryTab.tsx +0 -355
- package/src/components/Inspector/MediaPreviewModal.tsx +0 -435
- package/src/components/Inspector/NavigationTracker.tsx +0 -13
- package/src/components/Inspector/NetworkDetail.tsx +0 -795
- package/src/components/Inspector/NetworkFilterModal.tsx +0 -730
- package/src/components/Inspector/NetworkTab.tsx +0 -820
- package/src/components/Inspector/NpmStarPrompt.tsx +0 -532
- package/src/components/Inspector/NpmUpdateToast.tsx +0 -387
- package/src/components/Inspector/PerformanceTab.tsx +0 -1967
- package/src/components/Inspector/ReduxDetail.tsx +0 -1651
- package/src/components/Inspector/ReduxTab.tsx +0 -987
- package/src/components/Inspector/SettingsPanel.tsx +0 -4580
- package/src/components/Inspector/SkeletonPlaceholder.tsx +0 -206
- package/src/components/Inspector/StorageTab.tsx +0 -1159
- package/src/components/Inspector/TabBar.tsx +0 -263
- package/src/components/Inspector/UpdateAvailableModal.tsx +0 -555
- package/src/components/JsonViewer.tsx +0 -547
- package/src/components/LogCard.tsx +0 -694
- package/src/components/LogSyntaxHighlighter.tsx +0 -178
- package/src/components/MetaAccordion.tsx +0 -355
- package/src/components/MiniBarChart.tsx +0 -42
- package/src/components/MiniLineChart.tsx +0 -33
- package/src/components/NetworkIcons.tsx +0 -2599
- package/src/components/QRCodeView.tsx +0 -75
- package/src/components/SectionHeader.tsx +0 -101
- package/src/components/SegmentedTabs.tsx +0 -83
- package/src/components/SkeletonPlaceholder.tsx +0 -206
- package/src/components/Slider.tsx +0 -300
- package/src/components/SourcePageCard.tsx +0 -150
- package/src/components/Toast.tsx +0 -131
- package/src/components/TouchableScale.tsx +0 -61
- package/src/components/TreeNode.tsx +0 -171
- package/src/console.ts +0 -24
- package/src/constants/index.ts +0 -41
- package/src/constants/telemetryConfig.ts +0 -4
- package/src/constants/version.ts +0 -3
- package/src/crash.ts +0 -32
- package/src/customHooks/analyticsLogger.ts +0 -336
- package/src/customHooks/bundleAnalyzer.ts +0 -1256
- package/src/customHooks/consoleLogger.ts +0 -530
- package/src/customHooks/crashHandler.ts +0 -944
- package/src/customHooks/logFilters.ts +0 -32
- package/src/customHooks/networkLogger.ts +0 -624
- package/src/customHooks/performanceTracker.ts +0 -1014
- package/src/customHooks/reduxLogger.ts +0 -406
- package/src/customHooks/storageInspector.ts +0 -513
- package/src/customHooks/useAccordion.tsx +0 -27
- package/src/decorators/index.ts +0 -184
- package/src/helpers/gaAnalyticsRegistry.ts +0 -204
- package/src/helpers/index.ts +0 -1092
- package/src/helpers/memoryManager.ts +0 -138
- package/src/helpers/qrGenerator.ts +0 -430
- package/src/helpers/remoteConfig.ts +0 -212
- package/src/helpers/searchQueryParser.ts +0 -84
- package/src/helpers/settingsStore.ts +0 -171
- package/src/helpers/telemetry.ts +0 -568
- package/src/helpers/toast.ts +0 -17
- package/src/i18n/index.ts +0 -104
- package/src/i18n/locales/en.json +0 -1125
- package/src/index.tsx +0 -2635
- package/src/metro.ts +0 -598
- package/src/network.ts +0 -22
- package/src/performance.ts +0 -38
- package/src/redux.ts +0 -23
- package/src/storage.ts +0 -18
- package/src/styles/AppColors.ts +0 -455
- package/src/styles/AppFonts.ts +0 -26
- package/src/styles/common.ts +0 -209
- package/src/styles/index.ts +0 -1606
- package/src/types/enums.ts +0 -208
- package/src/types/index.ts +0 -34
- package/src/types/interfaces.ts +0 -530
|
@@ -1,656 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const NativeInspector_1 = require("../native/NativeInspector");
|
|
9
|
-
const i18n_1 = require("../i18n");
|
|
10
|
-
let crashListeners = [];
|
|
11
|
-
let isCrashHandlerInitialized = false;
|
|
12
|
-
let lastHandledErrorTimestamp = 0;
|
|
13
|
-
let crashRecordsStore = [];
|
|
14
|
-
let breadcrumbsStore = [];
|
|
15
|
-
const MAX_BREADCRUMBS = 50;
|
|
16
|
-
let maxStoredCrashes = 100;
|
|
17
|
-
const appStartTime = Date.now();
|
|
18
|
-
let isCrashModuleEnabled = false;
|
|
19
|
-
const setCrashModuleEnabled = (enabled) => {
|
|
20
|
-
isCrashModuleEnabled = enabled;
|
|
21
|
-
};
|
|
22
|
-
exports.setCrashModuleEnabled = setCrashModuleEnabled;
|
|
23
|
-
const getCrashModuleEnabled = () => isCrashModuleEnabled;
|
|
24
|
-
exports.getCrashModuleEnabled = getCrashModuleEnabled;
|
|
25
|
-
const setMaxCrashLogsLimit = (max) => {
|
|
26
|
-
maxStoredCrashes = Math.max(10, max);
|
|
27
|
-
if (crashRecordsStore.length > maxStoredCrashes) {
|
|
28
|
-
crashRecordsStore = crashRecordsStore.slice(0, maxStoredCrashes);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.setMaxCrashLogsLimit = setMaxCrashLogsLimit;
|
|
32
|
-
const getMaxCrashLogsLimit = () => maxStoredCrashes;
|
|
33
|
-
exports.getMaxCrashLogsLimit = getMaxCrashLogsLimit;
|
|
34
|
-
const pruneCrashRecords = (targetCount) => {
|
|
35
|
-
const countToKeep = targetCount !== undefined ? Math.max(0, targetCount) : Math.floor(crashRecordsStore.length / 2);
|
|
36
|
-
const pruned = crashRecordsStore.length - countToKeep;
|
|
37
|
-
if (pruned > 0) {
|
|
38
|
-
crashRecordsStore = crashRecordsStore.slice(0, countToKeep);
|
|
39
|
-
}
|
|
40
|
-
if (breadcrumbsStore.length > 20) {
|
|
41
|
-
breadcrumbsStore = breadcrumbsStore.slice(0, 20);
|
|
42
|
-
}
|
|
43
|
-
return Math.max(0, pruned);
|
|
44
|
-
};
|
|
45
|
-
exports.pruneCrashRecords = pruneCrashRecords;
|
|
46
|
-
const addCrashBreadcrumb = (type, message, data) => {
|
|
47
|
-
if (!isCrashModuleEnabled)
|
|
48
|
-
return;
|
|
49
|
-
try {
|
|
50
|
-
const entry = {
|
|
51
|
-
type,
|
|
52
|
-
message,
|
|
53
|
-
timestamp: Date.now(),
|
|
54
|
-
data,
|
|
55
|
-
};
|
|
56
|
-
breadcrumbsStore.unshift(entry);
|
|
57
|
-
if (breadcrumbsStore.length > MAX_BREADCRUMBS) {
|
|
58
|
-
breadcrumbsStore = breadcrumbsStore.slice(0, MAX_BREADCRUMBS);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch { }
|
|
62
|
-
};
|
|
63
|
-
exports.addCrashBreadcrumb = addCrashBreadcrumb;
|
|
64
|
-
const recordNavigationBreadcrumb = (fromRoute, toRoute) => {
|
|
65
|
-
(0, exports.addCrashBreadcrumb)('navigation', (0, i18n_1.t)('crash.breadcrumbNavigation', { from: fromRoute || '/', to: toRoute || '/' }), {
|
|
66
|
-
from: fromRoute,
|
|
67
|
-
to: toRoute,
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
exports.recordNavigationBreadcrumb = recordNavigationBreadcrumb;
|
|
71
|
-
const recordNetworkBreadcrumb = (url, method, status, duration) => {
|
|
72
|
-
const statusStr = status != null ? ` [${status}]` : '';
|
|
73
|
-
const durStr = duration != null ? ` (${Math.round(duration)}ms)` : '';
|
|
74
|
-
(0, exports.addCrashBreadcrumb)('network', `${method.toUpperCase()} ${url}${statusStr}${durStr}`, {
|
|
75
|
-
url,
|
|
76
|
-
method,
|
|
77
|
-
status,
|
|
78
|
-
duration,
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
exports.recordNetworkBreadcrumb = recordNetworkBreadcrumb;
|
|
82
|
-
const recordReduxBreadcrumb = (actionType, payload) => {
|
|
83
|
-
(0, exports.addCrashBreadcrumb)('redux', (0, i18n_1.t)('crash.breadcrumbAction', { actionType }), {
|
|
84
|
-
type: actionType,
|
|
85
|
-
payloadSummary: typeof payload === 'object' && payload !== null
|
|
86
|
-
? Object.keys(payload)
|
|
87
|
-
: typeof payload,
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
exports.recordReduxBreadcrumb = recordReduxBreadcrumb;
|
|
91
|
-
const recordUserActionBreadcrumb = (action, metadata) => {
|
|
92
|
-
(0, exports.addCrashBreadcrumb)('user', action, metadata);
|
|
93
|
-
};
|
|
94
|
-
exports.recordUserActionBreadcrumb = recordUserActionBreadcrumb;
|
|
95
|
-
const clearCrashBreadcrumbs = () => {
|
|
96
|
-
breadcrumbsStore = [];
|
|
97
|
-
};
|
|
98
|
-
exports.clearCrashBreadcrumbs = clearCrashBreadcrumbs;
|
|
99
|
-
const getCrashBreadcrumbs = () => {
|
|
100
|
-
return [...breadcrumbsStore];
|
|
101
|
-
};
|
|
102
|
-
exports.getCrashBreadcrumbs = getCrashBreadcrumbs;
|
|
103
|
-
const parseCrashStackTrace = (stack) => {
|
|
104
|
-
if (!stack || typeof stack !== 'string')
|
|
105
|
-
return [];
|
|
106
|
-
const lines = stack.split('\n');
|
|
107
|
-
const frames = [];
|
|
108
|
-
for (const line of lines) {
|
|
109
|
-
const trimmed = line.trim();
|
|
110
|
-
if (!trimmed)
|
|
111
|
-
continue;
|
|
112
|
-
if (trimmed.includes('crashHandler.ts') ||
|
|
113
|
-
trimmed.includes('handleInterceptedCrash') ||
|
|
114
|
-
trimmed.includes('addLogFromCrash') ||
|
|
115
|
-
trimmed.includes('setupGlobalCrashHandler')) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const iosMatch = trimmed.match(/^([^@]+)@(.*):(\d+):(\d+)$/);
|
|
119
|
-
if (iosMatch) {
|
|
120
|
-
const [, method, file, lineNum, colNum] = iosMatch;
|
|
121
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
122
|
-
const isAppCode = !file.includes('node_modules') &&
|
|
123
|
-
!file.includes('react-native') &&
|
|
124
|
-
!file.includes('react-dom') &&
|
|
125
|
-
!file.includes('hermes') &&
|
|
126
|
-
!file.includes('internal');
|
|
127
|
-
frames.push({
|
|
128
|
-
method: method.trim(),
|
|
129
|
-
file: cleanFile,
|
|
130
|
-
lineNumber: parseInt(lineNum, 10),
|
|
131
|
-
column: parseInt(colNum, 10),
|
|
132
|
-
raw: trimmed,
|
|
133
|
-
isAppCode,
|
|
134
|
-
});
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const androidMatch = trimmed.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);
|
|
138
|
-
if (androidMatch) {
|
|
139
|
-
const [, method, file, lineNum, colNum] = androidMatch;
|
|
140
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
141
|
-
const isAppCode = !file.includes('node_modules') &&
|
|
142
|
-
!file.includes('react-native') &&
|
|
143
|
-
!file.includes('react-dom') &&
|
|
144
|
-
!file.includes('internal');
|
|
145
|
-
frames.push({
|
|
146
|
-
method: method.trim(),
|
|
147
|
-
file: cleanFile,
|
|
148
|
-
lineNumber: parseInt(lineNum, 10),
|
|
149
|
-
column: parseInt(colNum, 10),
|
|
150
|
-
raw: trimmed,
|
|
151
|
-
isAppCode,
|
|
152
|
-
});
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const simpleMatch = trimmed.match(/^at\s+(.+):(\d+):(\d+)$/);
|
|
156
|
-
if (simpleMatch) {
|
|
157
|
-
const [, file, lineNum, colNum] = simpleMatch;
|
|
158
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
159
|
-
const isAppCode = !file.includes('node_modules') && !file.includes('react-native');
|
|
160
|
-
frames.push({
|
|
161
|
-
method: '<anonymous>',
|
|
162
|
-
file: cleanFile,
|
|
163
|
-
lineNumber: parseInt(lineNum, 10),
|
|
164
|
-
column: parseInt(colNum, 10),
|
|
165
|
-
raw: trimmed,
|
|
166
|
-
isAppCode,
|
|
167
|
-
});
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
const javaMatch = trimmed.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);
|
|
171
|
-
if (javaMatch) {
|
|
172
|
-
const [, methodPath, fileName, lineNum] = javaMatch;
|
|
173
|
-
const isAppCode = !methodPath.startsWith('com.facebook.react') &&
|
|
174
|
-
!methodPath.startsWith('android.');
|
|
175
|
-
frames.push({
|
|
176
|
-
method: methodPath,
|
|
177
|
-
file: fileName,
|
|
178
|
-
lineNumber: parseInt(lineNum, 10),
|
|
179
|
-
column: 0,
|
|
180
|
-
raw: trimmed,
|
|
181
|
-
isAppCode,
|
|
182
|
-
});
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
const machOMatch = trimmed.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);
|
|
186
|
-
if (machOMatch) {
|
|
187
|
-
const [, binaryName, address, symbol] = machOMatch;
|
|
188
|
-
const isAppCode = !binaryName.startsWith('lib') &&
|
|
189
|
-
!binaryName.startsWith('Core') &&
|
|
190
|
-
!binaryName.startsWith('React');
|
|
191
|
-
frames.push({
|
|
192
|
-
method: symbol,
|
|
193
|
-
file: binaryName,
|
|
194
|
-
lineNumber: 0,
|
|
195
|
-
column: 0,
|
|
196
|
-
raw: trimmed,
|
|
197
|
-
isAppCode,
|
|
198
|
-
});
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
frames.push({
|
|
202
|
-
method: trimmed.startsWith('at ') ? trimmed.slice(3) : trimmed,
|
|
203
|
-
file: 'runtime',
|
|
204
|
-
lineNumber: 0,
|
|
205
|
-
column: 0,
|
|
206
|
-
raw: trimmed,
|
|
207
|
-
isAppCode: false,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return frames;
|
|
211
|
-
};
|
|
212
|
-
exports.parseCrashStackTrace = parseCrashStackTrace;
|
|
213
|
-
const getMemoryDiagnostics = () => {
|
|
214
|
-
try {
|
|
215
|
-
const performance = globalThis.performance;
|
|
216
|
-
if (performance && performance.memory) {
|
|
217
|
-
return {
|
|
218
|
-
usedJSHeapSize: Math.round(performance.memory.usedJSHeapSize / (1024 * 1024)),
|
|
219
|
-
totalJSHeapSize: Math.round(performance.memory.totalJSHeapSize / (1024 * 1024)),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
catch { }
|
|
224
|
-
return undefined;
|
|
225
|
-
};
|
|
226
|
-
const getScreenDimensions = () => {
|
|
227
|
-
try {
|
|
228
|
-
const window = react_native_1.Dimensions.get('window');
|
|
229
|
-
return `${Math.round(window.width)}x${Math.round(window.height)} (${window.scale}x)`;
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
return (0, i18n_1.t)('crash.unknown');
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
const computeCrashFingerprint = (crash) => {
|
|
236
|
-
const type = crash.type || 'js';
|
|
237
|
-
const name = crash.name || 'Error';
|
|
238
|
-
const topFrame = crash.parsedStack && crash.parsedStack.length > 0
|
|
239
|
-
? crash.parsedStack[0]
|
|
240
|
-
: null;
|
|
241
|
-
const location = topFrame
|
|
242
|
-
? `${topFrame.file}:${topFrame.lineNumber}`
|
|
243
|
-
: 'unknown';
|
|
244
|
-
return `${type}_${name}_${location}`;
|
|
245
|
-
};
|
|
246
|
-
exports.computeCrashFingerprint = computeCrashFingerprint;
|
|
247
|
-
const getCrashRecords = () => {
|
|
248
|
-
return [...crashRecordsStore];
|
|
249
|
-
};
|
|
250
|
-
exports.getCrashRecords = getCrashRecords;
|
|
251
|
-
const clearCrashRecords = () => {
|
|
252
|
-
crashRecordsStore = [];
|
|
253
|
-
(0, exports.emitCrashEvent)({
|
|
254
|
-
error: null,
|
|
255
|
-
message: '__CLEARED__',
|
|
256
|
-
timestamp: Date.now(),
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
exports.clearCrashRecords = clearCrashRecords;
|
|
260
|
-
const subscribeCrashEvents = (listener) => {
|
|
261
|
-
crashListeners.push(listener);
|
|
262
|
-
return () => {
|
|
263
|
-
crashListeners = crashListeners.filter(l => l !== listener);
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
exports.subscribeCrashEvents = subscribeCrashEvents;
|
|
267
|
-
const emitCrashEvent = (payload) => {
|
|
268
|
-
if (payload.message !== '__CLEARED__') {
|
|
269
|
-
const now = Date.now();
|
|
270
|
-
if (now - lastHandledErrorTimestamp < 250) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
lastHandledErrorTimestamp = now;
|
|
274
|
-
}
|
|
275
|
-
crashListeners.forEach(listener => {
|
|
276
|
-
try {
|
|
277
|
-
listener(payload);
|
|
278
|
-
}
|
|
279
|
-
catch { }
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
exports.emitCrashEvent = emitCrashEvent;
|
|
283
|
-
const handleInterceptedCrash = (errorOrTitle, rawStack, isFatal = false, customType, componentStack) => {
|
|
284
|
-
try {
|
|
285
|
-
const errorObj = errorOrTitle instanceof Error
|
|
286
|
-
? errorOrTitle
|
|
287
|
-
: typeof errorOrTitle === 'object' && errorOrTitle !== null
|
|
288
|
-
? errorOrTitle
|
|
289
|
-
: new Error(String(errorOrTitle || (0, i18n_1.t)('crash.runtimeException')));
|
|
290
|
-
const rawMsg = errorObj.message ||
|
|
291
|
-
(typeof errorOrTitle === 'string' ? errorOrTitle : (0, i18n_1.t)('crash.runtimeException'));
|
|
292
|
-
let stackString = '';
|
|
293
|
-
if (typeof rawStack === 'string') {
|
|
294
|
-
stackString = rawStack;
|
|
295
|
-
}
|
|
296
|
-
else if (Array.isArray(rawStack)) {
|
|
297
|
-
stackString = rawStack
|
|
298
|
-
.map(f => `at ${f.methodName || '<anonymous>'} (${f.file || 'unknown'}:${f.lineNumber || 0}:${f.column || 0})`)
|
|
299
|
-
.join('\n');
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
stackString = errorObj.stack || new Error().stack || '';
|
|
303
|
-
}
|
|
304
|
-
let inferredType = customType || enums_1.CrashType.Js;
|
|
305
|
-
const lowMsg = rawMsg.toLowerCase();
|
|
306
|
-
if (!customType) {
|
|
307
|
-
if (lowMsg.includes('native') ||
|
|
308
|
-
lowMsg.includes('sigsegv') ||
|
|
309
|
-
lowMsg.includes('nsrange') ||
|
|
310
|
-
lowMsg.includes('nullpointerexception') ||
|
|
311
|
-
lowMsg.includes('fatal signal')) {
|
|
312
|
-
inferredType = enums_1.CrashType.Native;
|
|
313
|
-
}
|
|
314
|
-
else if (lowMsg.includes('promise') ||
|
|
315
|
-
lowMsg.includes('unhandled rejection') ||
|
|
316
|
-
lowMsg.includes('unhandledrejection')) {
|
|
317
|
-
inferredType = enums_1.CrashType.Promise;
|
|
318
|
-
}
|
|
319
|
-
else if (lowMsg.includes('render') ||
|
|
320
|
-
lowMsg.includes('errorboundary') ||
|
|
321
|
-
componentStack) {
|
|
322
|
-
inferredType = enums_1.CrashType.Render;
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
inferredType = enums_1.CrashType.Js;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const now = new Date();
|
|
329
|
-
const dateStr = now.toLocaleDateString();
|
|
330
|
-
const timeStr = now.toLocaleTimeString();
|
|
331
|
-
const parsedStack = (0, exports.parseCrashStackTrace)(stackString);
|
|
332
|
-
const log = (0, consoleLogger_1.addLogFromCrash)(errorObj, `[${isFatal ? (0, i18n_1.t)('crash.logFatalCrash') : (0, i18n_1.t)('crash.logUnhandledError')}] ${rawMsg}`, stackString, isFatal);
|
|
333
|
-
const isHermes = typeof globalThis.HermesInternal !== 'undefined';
|
|
334
|
-
const isFabric = typeof globalThis.nativeFabricUIManager !== 'undefined';
|
|
335
|
-
const crashRecord = {
|
|
336
|
-
id: `crash_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
337
|
-
error: errorObj,
|
|
338
|
-
isFatal,
|
|
339
|
-
type: inferredType,
|
|
340
|
-
message: rawMsg,
|
|
341
|
-
name: errorObj.name || (isFatal ? (0, i18n_1.t)('crash.errorNameFatal') : (0, i18n_1.t)('crash.errorNameUnhandled')),
|
|
342
|
-
stack: stackString,
|
|
343
|
-
parsedStack,
|
|
344
|
-
componentStack: componentStack || undefined,
|
|
345
|
-
timestamp: Date.now(),
|
|
346
|
-
dateStr,
|
|
347
|
-
timeStr,
|
|
348
|
-
deviceInfo: {
|
|
349
|
-
platform: react_native_1.Platform.OS,
|
|
350
|
-
osVersion: String(react_native_1.Platform.Version),
|
|
351
|
-
rnVersion: react_native_1.Platform.constants?.reactNativeVersion
|
|
352
|
-
? `${react_native_1.Platform.constants.reactNativeVersion.major}.${react_native_1.Platform.constants.reactNativeVersion.minor}.${react_native_1.Platform.constants.reactNativeVersion.patch}`
|
|
353
|
-
: (0, i18n_1.t)('crash.unknown'),
|
|
354
|
-
isHermes,
|
|
355
|
-
isFabric,
|
|
356
|
-
appState: react_native_1.AppState.currentState || 'active',
|
|
357
|
-
},
|
|
358
|
-
memoryInfo: getMemoryDiagnostics(),
|
|
359
|
-
breadcrumbs: [...breadcrumbsStore],
|
|
360
|
-
logId: log?.id,
|
|
361
|
-
};
|
|
362
|
-
crashRecordsStore.unshift(crashRecord);
|
|
363
|
-
if (crashRecordsStore.length > maxStoredCrashes) {
|
|
364
|
-
crashRecordsStore = crashRecordsStore.slice(0, maxStoredCrashes);
|
|
365
|
-
}
|
|
366
|
-
(0, exports.emitCrashEvent)({
|
|
367
|
-
error: errorObj,
|
|
368
|
-
isFatal,
|
|
369
|
-
message: `[${isFatal ? (0, i18n_1.t)('crash.logFatalCrash') : (0, i18n_1.t)('crash.logUnhandledError')}] ${rawMsg}`,
|
|
370
|
-
stack: stackString,
|
|
371
|
-
timestamp: Date.now(),
|
|
372
|
-
logId: log?.id,
|
|
373
|
-
crashRecord,
|
|
374
|
-
});
|
|
375
|
-
try {
|
|
376
|
-
(0, NativeInspector_1.showNativeFloatingButton)();
|
|
377
|
-
(0, NativeInspector_1.setNativeFloatingButtonBadge)(true);
|
|
378
|
-
}
|
|
379
|
-
catch { }
|
|
380
|
-
return crashRecord;
|
|
381
|
-
}
|
|
382
|
-
catch (err) {
|
|
383
|
-
const fallbackRecord = {
|
|
384
|
-
id: `crash_${Date.now()}`,
|
|
385
|
-
isFatal: true,
|
|
386
|
-
type: enums_1.CrashType.Js,
|
|
387
|
-
message: String(errorOrTitle || (0, i18n_1.t)('crash.unknownException')),
|
|
388
|
-
timestamp: Date.now(),
|
|
389
|
-
dateStr: new Date().toLocaleDateString(),
|
|
390
|
-
timeStr: new Date().toLocaleTimeString(),
|
|
391
|
-
};
|
|
392
|
-
return fallbackRecord;
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
exports.handleInterceptedCrash = handleInterceptedCrash;
|
|
396
|
-
const recordCustomCrash = (error, options) => {
|
|
397
|
-
return (0, exports.handleInterceptedCrash)(error, typeof error === 'object' ? error.stack : undefined, options?.isFatal ?? false, options?.type || enums_1.CrashType.Custom, options?.componentStack);
|
|
398
|
-
};
|
|
399
|
-
exports.recordCustomCrash = recordCustomCrash;
|
|
400
|
-
const simulateTestCrash = (type = enums_1.CrashType.Js, customMessage, customStack) => {
|
|
401
|
-
const err = new Error(customMessage || _defaultSimMessage(type));
|
|
402
|
-
return (0, exports.handleInterceptedCrash)(type === enums_1.CrashType.Native ? err.message : err, customStack || err.stack, type === enums_1.CrashType.Native, type, type === enums_1.CrashType.Render ? _buildComponentStack() : undefined);
|
|
403
|
-
};
|
|
404
|
-
exports.simulateTestCrash = simulateTestCrash;
|
|
405
|
-
const _defaultSimMessage = (type) => {
|
|
406
|
-
switch (type) {
|
|
407
|
-
case 'native':
|
|
408
|
-
return (0, i18n_1.t)('crash.simNativeMessage');
|
|
409
|
-
case 'promise':
|
|
410
|
-
return (0, i18n_1.t)('crash.simPromiseMessage');
|
|
411
|
-
case 'render':
|
|
412
|
-
return (0, i18n_1.t)('crash.simRenderMessage');
|
|
413
|
-
default:
|
|
414
|
-
return (0, i18n_1.t)('crash.simJsMessage');
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
const _buildComponentStack = () => {
|
|
418
|
-
try {
|
|
419
|
-
const err = new Error();
|
|
420
|
-
if (err.stack) {
|
|
421
|
-
return err.stack
|
|
422
|
-
.split('\n')
|
|
423
|
-
.slice(1, 6)
|
|
424
|
-
.map(line => ` ${line.trim()}`)
|
|
425
|
-
.join('\n');
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
catch { }
|
|
429
|
-
return undefined;
|
|
430
|
-
};
|
|
431
|
-
const exportCrashReport = (crash, format = 'text') => {
|
|
432
|
-
if (format === 'json') {
|
|
433
|
-
return JSON.stringify(crash, null, 2);
|
|
434
|
-
}
|
|
435
|
-
const uptimeSec = Math.round((crash.timestamp - appStartTime) / 1000);
|
|
436
|
-
if (format === 'markdown') {
|
|
437
|
-
const lines = [];
|
|
438
|
-
lines.push(`## ${(0, i18n_1.t)('crash.mdReportTitle', { name: crash.name || 'Error' })}`);
|
|
439
|
-
lines.push(`> **${crash.message}**`);
|
|
440
|
-
lines.push('');
|
|
441
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportType')}** \`${crash.type.toUpperCase()}\``);
|
|
442
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportFatal')}** \`${crash.isFatal
|
|
443
|
-
? (0, i18n_1.t)('crash.mdSeverityFatal')
|
|
444
|
-
: (0, i18n_1.t)('crash.mdSeverityHandled')}\``);
|
|
445
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportTimestamp')}** ${crash.dateStr} ${crash.timeStr}`);
|
|
446
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportUptime')}** ${uptimeSec}s`);
|
|
447
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportPlatform')}** ${crash.deviceInfo?.platform?.toUpperCase()} (v${crash.deviceInfo?.osVersion})`);
|
|
448
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportReactNative')}** v${crash.deviceInfo?.rnVersion || 'N/A'}`);
|
|
449
|
-
lines.push(`- **${(0, i18n_1.t)('crash.jsEngine')}** ${crash.deviceInfo?.isHermes ? (0, i18n_1.t)('crash.hermesEngine') : (0, i18n_1.t)('crash.jsc')}`);
|
|
450
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportArchitecture')}** ${crash.deviceInfo?.isFabric
|
|
451
|
-
? (0, i18n_1.t)('crash.reportFabricNew')
|
|
452
|
-
: (0, i18n_1.t)('crash.reportPaperLegacy')}`);
|
|
453
|
-
if (crash.memoryInfo) {
|
|
454
|
-
lines.push(`- **${(0, i18n_1.t)('crash.reportJsMemory')}** ${crash.memoryInfo.usedJSHeapSize} MB / ${crash.memoryInfo.totalJSHeapSize} MB`);
|
|
455
|
-
}
|
|
456
|
-
lines.push('');
|
|
457
|
-
lines.push(`### ${(0, i18n_1.t)('crash.mdStackTrace')}`);
|
|
458
|
-
lines.push('```');
|
|
459
|
-
lines.push(crash.stack || (0, i18n_1.t)('crash.reportNoStackTrace'));
|
|
460
|
-
lines.push('```');
|
|
461
|
-
if (crash.componentStack) {
|
|
462
|
-
lines.push('');
|
|
463
|
-
lines.push(`### ${(0, i18n_1.t)('crash.mdComponentHierarchy')}`);
|
|
464
|
-
lines.push('```');
|
|
465
|
-
lines.push(crash.componentStack);
|
|
466
|
-
lines.push('```');
|
|
467
|
-
}
|
|
468
|
-
if (crash.breadcrumbs && crash.breadcrumbs.length > 0) {
|
|
469
|
-
lines.push('');
|
|
470
|
-
lines.push(`### ${(0, i18n_1.t)('crash.mdRecentBreadcrumbs')}`);
|
|
471
|
-
crash.breadcrumbs.forEach(b => {
|
|
472
|
-
const time = new Date(b.timestamp).toLocaleTimeString();
|
|
473
|
-
lines.push(`- \`[${time}]\` **[${b.type.toUpperCase()}]** ${b.message}`);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return lines.join('\n');
|
|
477
|
-
}
|
|
478
|
-
const lines = [];
|
|
479
|
-
lines.push('====================================================');
|
|
480
|
-
lines.push(` ${(0, i18n_1.t)('crash.reportTitle')} `);
|
|
481
|
-
lines.push('====================================================');
|
|
482
|
-
lines.push(`${(0, i18n_1.t)('crash.reportErrorName')} ${crash.name || 'Error'}`);
|
|
483
|
-
lines.push(`${(0, i18n_1.t)('crash.reportMessage')} ${crash.message}`);
|
|
484
|
-
lines.push(`${(0, i18n_1.t)('crash.reportType')} ${crash.type.toUpperCase()}`);
|
|
485
|
-
lines.push(`${(0, i18n_1.t)('crash.reportFatal')} ${crash.isFatal ? (0, i18n_1.t)('crash.reportFatalYes') : (0, i18n_1.t)('crash.reportFatalNo')}`);
|
|
486
|
-
lines.push(`${(0, i18n_1.t)('crash.reportTimestamp')} ${crash.dateStr} ${crash.timeStr} (${crash.timestamp})`);
|
|
487
|
-
lines.push(`${(0, i18n_1.t)('crash.reportUptime')} ${(0, i18n_1.t)('crash.reportUptimeValue', {
|
|
488
|
-
seconds: uptimeSec,
|
|
489
|
-
})}`);
|
|
490
|
-
lines.push(`${(0, i18n_1.t)('crash.reportPlatform')} ${crash.deviceInfo?.platform?.toUpperCase()} (v${crash.deviceInfo?.osVersion})`);
|
|
491
|
-
lines.push(`${(0, i18n_1.t)('crash.reportReactNative')} ${crash.deviceInfo?.rnVersion || 'N/A'}`);
|
|
492
|
-
lines.push(`${(0, i18n_1.t)('crash.reportHermes')} ${crash.deviceInfo?.isHermes
|
|
493
|
-
? (0, i18n_1.t)('crash.reportEnabled')
|
|
494
|
-
: (0, i18n_1.t)('crash.reportDisabled')}`);
|
|
495
|
-
lines.push(`${(0, i18n_1.t)('crash.reportArchitecture')} ${crash.deviceInfo?.isFabric
|
|
496
|
-
? (0, i18n_1.t)('crash.reportFabricNew')
|
|
497
|
-
: (0, i18n_1.t)('crash.reportPaperLegacy')}`);
|
|
498
|
-
lines.push(`${(0, i18n_1.t)('crash.reportScreenSize')} ${getScreenDimensions()}`);
|
|
499
|
-
lines.push(`${(0, i18n_1.t)('crash.reportAppState')} ${crash.deviceInfo?.appState || 'active'}`);
|
|
500
|
-
if (crash.memoryInfo) {
|
|
501
|
-
lines.push(`${(0, i18n_1.t)('crash.reportJsMemory')} ${crash.memoryInfo.usedJSHeapSize} MB / ${crash.memoryInfo.totalJSHeapSize} MB`);
|
|
502
|
-
}
|
|
503
|
-
lines.push('----------------------------------------------------');
|
|
504
|
-
lines.push(`${(0, i18n_1.t)('crash.reportStackTrace')}`);
|
|
505
|
-
lines.push(crash.stack || (0, i18n_1.t)('crash.reportNoStackTrace'));
|
|
506
|
-
if (crash.componentStack) {
|
|
507
|
-
lines.push('----------------------------------------------------');
|
|
508
|
-
lines.push(`${(0, i18n_1.t)('crash.reportComponentHierarchy')}`);
|
|
509
|
-
lines.push(crash.componentStack);
|
|
510
|
-
}
|
|
511
|
-
if (crash.breadcrumbs && crash.breadcrumbs.length > 0) {
|
|
512
|
-
lines.push('----------------------------------------------------');
|
|
513
|
-
lines.push(`${(0, i18n_1.t)('crash.reportRecentBreadcrumbs')}`);
|
|
514
|
-
crash.breadcrumbs.forEach(b => {
|
|
515
|
-
const time = new Date(b.timestamp).toLocaleTimeString();
|
|
516
|
-
lines.push(` [${time}] [${b.type.toUpperCase()}] ${b.message}`);
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
lines.push('====================================================');
|
|
520
|
-
return lines.join('\n');
|
|
521
|
-
};
|
|
522
|
-
exports.exportCrashReport = exportCrashReport;
|
|
523
|
-
const setupGlobalCrashHandler = () => {
|
|
524
|
-
if (isCrashHandlerInitialized)
|
|
525
|
-
return;
|
|
526
|
-
isCrashHandlerInitialized = true;
|
|
527
|
-
try {
|
|
528
|
-
if (react_native_1.LogBox && typeof react_native_1.LogBox.ignoreAllLogs === 'function') {
|
|
529
|
-
react_native_1.LogBox.ignoreAllLogs(true);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
catch { }
|
|
533
|
-
try {
|
|
534
|
-
const LogBoxData = require('react-native/Libraries/LogBox/Data/LogBoxData');
|
|
535
|
-
if (LogBoxData && typeof LogBoxData.setDisabled === 'function') {
|
|
536
|
-
LogBoxData.setDisabled(true);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
catch { }
|
|
540
|
-
try {
|
|
541
|
-
const networkInspectorModule = react_native_1.NativeModules?.NetworkInspectorModule;
|
|
542
|
-
if (networkInspectorModule) {
|
|
543
|
-
if (typeof networkInspectorModule.enableNativeCrashProtection === 'function') {
|
|
544
|
-
networkInspectorModule.enableNativeCrashProtection();
|
|
545
|
-
}
|
|
546
|
-
const nativeEmitter = new react_native_1.NativeEventEmitter(networkInspectorModule);
|
|
547
|
-
nativeEmitter.addListener('onNativeCrash', (event) => {
|
|
548
|
-
const platform = event?.platform || react_native_1.Platform.OS;
|
|
549
|
-
const msg = `[${platform.toUpperCase()} ${(0, i18n_1.t)('crash.nativeCrashTitle')}] ${event?.message || (0, i18n_1.t)('crash.nativeUncaughtException')}`;
|
|
550
|
-
const stack = event?.stack || '';
|
|
551
|
-
(0, exports.handleInterceptedCrash)(msg, stack, true, 'native');
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
catch { }
|
|
556
|
-
try {
|
|
557
|
-
const tmReg = react_native_1.TurboModuleRegistry || globalThis.__turboModuleProxy;
|
|
558
|
-
const nativeExceptionsManager = react_native_1.NativeModules?.ExceptionsManager ||
|
|
559
|
-
(tmReg?.get ? tmReg.get('ExceptionsManager') : null);
|
|
560
|
-
if (nativeExceptionsManager) {
|
|
561
|
-
nativeExceptionsManager.reportFatalException = (title, stack, exceptionId) => {
|
|
562
|
-
(0, exports.handleInterceptedCrash)(title, stack, true, 'native');
|
|
563
|
-
try {
|
|
564
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
565
|
-
nativeExceptionsManager.dismissRedbox();
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
catch { }
|
|
569
|
-
};
|
|
570
|
-
nativeExceptionsManager.reportSoftException = (title, stack, exceptionId) => {
|
|
571
|
-
(0, exports.handleInterceptedCrash)(title, stack, false, 'js');
|
|
572
|
-
try {
|
|
573
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
574
|
-
nativeExceptionsManager.dismissRedbox();
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
catch { }
|
|
578
|
-
};
|
|
579
|
-
nativeExceptionsManager.reportException = (data) => {
|
|
580
|
-
const msg = data?.message || data?.title || (0, i18n_1.t)('crash.nativeException');
|
|
581
|
-
const stack = data?.stack || data?.rawStack;
|
|
582
|
-
(0, exports.handleInterceptedCrash)(msg, stack, data?.isFatal ?? true, 'js');
|
|
583
|
-
try {
|
|
584
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
585
|
-
nativeExceptionsManager.dismissRedbox();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
catch { }
|
|
589
|
-
};
|
|
590
|
-
nativeExceptionsManager.updateExceptionMessage = () => { };
|
|
591
|
-
try {
|
|
592
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
593
|
-
nativeExceptionsManager.dismissRedbox();
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
catch { }
|
|
597
|
-
}
|
|
598
|
-
const nativeRedBox = react_native_1.NativeModules?.RedBox ||
|
|
599
|
-
react_native_1.NativeModules?.RCTRedBox ||
|
|
600
|
-
(tmReg?.get ? tmReg.get('RedBox') || tmReg.get('RCTRedBox') : null);
|
|
601
|
-
if (nativeRedBox) {
|
|
602
|
-
if (typeof nativeRedBox.showErrorMessage === 'function') {
|
|
603
|
-
nativeRedBox.showErrorMessage = () => { };
|
|
604
|
-
}
|
|
605
|
-
if (typeof nativeRedBox.showUserError === 'function') {
|
|
606
|
-
nativeRedBox.showUserError = () => { };
|
|
607
|
-
}
|
|
608
|
-
if (typeof nativeRedBox.dismiss === 'function') {
|
|
609
|
-
nativeRedBox.dismiss();
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
catch { }
|
|
614
|
-
try {
|
|
615
|
-
const globalObj = globalThis;
|
|
616
|
-
const errorUtils = globalObj.ErrorUtils;
|
|
617
|
-
if (errorUtils) {
|
|
618
|
-
if (typeof errorUtils.setGlobalHandler === 'function') {
|
|
619
|
-
errorUtils.setGlobalHandler((error, isFatal) => {
|
|
620
|
-
(0, exports.handleInterceptedCrash)(error, error?.stack, isFatal ?? false, 'js');
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
if (typeof errorUtils.reportFatalError === 'function') {
|
|
624
|
-
errorUtils.reportFatalError = (error) => {
|
|
625
|
-
(0, exports.handleInterceptedCrash)(error, error?.stack, true, 'js');
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
if (typeof errorUtils.reportError === 'function') {
|
|
629
|
-
errorUtils.reportError = (error) => {
|
|
630
|
-
(0, exports.handleInterceptedCrash)(error, error?.stack, false, 'js');
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
catch { }
|
|
636
|
-
try {
|
|
637
|
-
const globalObj = globalThis;
|
|
638
|
-
const handleUnhandledPromise = (eventOrError) => {
|
|
639
|
-
try {
|
|
640
|
-
const reason = eventOrError?.reason || eventOrError?.detail?.reason || eventOrError;
|
|
641
|
-
const message = reason?.message || String(reason || (0, i18n_1.t)('crash.unhandledPromiseRejection'));
|
|
642
|
-
const stack = reason?.stack || (eventOrError?.stack ?? new Error().stack);
|
|
643
|
-
(0, exports.handleInterceptedCrash)(reason, stack, false, 'promise');
|
|
644
|
-
}
|
|
645
|
-
catch { }
|
|
646
|
-
};
|
|
647
|
-
if (typeof globalObj.addEventListener === 'function') {
|
|
648
|
-
globalObj.addEventListener('unhandledrejection', handleUnhandledPromise);
|
|
649
|
-
}
|
|
650
|
-
if (typeof globalObj.onunhandledrejection !== 'undefined') {
|
|
651
|
-
globalObj.onunhandledrejection = handleUnhandledPromise;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
catch { }
|
|
655
|
-
};
|
|
656
|
-
exports.setupGlobalCrashHandler = setupGlobalCrashHandler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setupGlobalCrashHandler=exports.exportCrashReport=exports.simulateTestCrash=exports.recordCustomCrash=exports.handleInterceptedCrash=exports.emitCrashEvent=exports.subscribeCrashEvents=exports.clearCrashRecords=exports.getCrashRecords=exports.computeCrashFingerprint=exports.parseCrashStackTrace=exports.getCrashBreadcrumbs=exports.clearCrashBreadcrumbs=exports.recordUserActionBreadcrumb=exports.recordReduxBreadcrumb=exports.recordNetworkBreadcrumb=exports.recordNavigationBreadcrumb=exports.addCrashBreadcrumb=exports.pruneCrashRecords=exports.getMaxCrashLogsLimit=exports.setMaxCrashLogsLimit=exports.getCrashModuleEnabled=exports.setCrashModuleEnabled=exports.CrashExportFormat=void 0;const react_native_1=require("react-native"),enums_1=require("../types/enums");Object.defineProperty(exports,"CrashExportFormat",{enumerable:!0,get:function(){return enums_1.CrashExportFormat}});const consoleLogger_1=require("./consoleLogger"),NativeInspector_1=require("../native/NativeInspector"),i18n_1=require("../i18n");let crashListeners=[],isCrashHandlerInitialized=!1,lastHandledErrorTimestamp=0,crashRecordsStore=[],breadcrumbsStore=[];const MAX_BREADCRUMBS=50;let maxStoredCrashes=100;const appStartTime=Date.now();let isCrashModuleEnabled=!1;const setCrashModuleEnabled=e=>{isCrashModuleEnabled=e};exports.setCrashModuleEnabled=setCrashModuleEnabled;const getCrashModuleEnabled=()=>isCrashModuleEnabled;exports.getCrashModuleEnabled=getCrashModuleEnabled;const setMaxCrashLogsLimit=e=>{maxStoredCrashes=Math.max(10,e),crashRecordsStore.length>maxStoredCrashes&&(crashRecordsStore=crashRecordsStore.slice(0,maxStoredCrashes))};exports.setMaxCrashLogsLimit=setMaxCrashLogsLimit;const getMaxCrashLogsLimit=()=>maxStoredCrashes;exports.getMaxCrashLogsLimit=getMaxCrashLogsLimit;const pruneCrashRecords=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(crashRecordsStore.length/2),o=crashRecordsStore.length-t;return o>0&&(crashRecordsStore=crashRecordsStore.slice(0,t)),breadcrumbsStore.length>20&&(breadcrumbsStore=breadcrumbsStore.slice(0,20)),Math.max(0,o)};exports.pruneCrashRecords=pruneCrashRecords;const addCrashBreadcrumb=(e,t,o)=>{if(isCrashModuleEnabled)try{const s={type:e,message:t,timestamp:Date.now(),data:o};breadcrumbsStore.unshift(s),breadcrumbsStore.length>MAX_BREADCRUMBS&&(breadcrumbsStore=breadcrumbsStore.slice(0,MAX_BREADCRUMBS))}catch{}};exports.addCrashBreadcrumb=addCrashBreadcrumb;const recordNavigationBreadcrumb=(e,t)=>{(0,exports.addCrashBreadcrumb)("navigation",(0,i18n_1.t)("crash.breadcrumbNavigation",{from:e||"/",to:t||"/"}),{from:e,to:t})};exports.recordNavigationBreadcrumb=recordNavigationBreadcrumb;const recordNetworkBreadcrumb=(e,t,o,s)=>{const r=o!=null?` [${o}]`:"",a=s!=null?` (${Math.round(s)}ms)`:"";(0,exports.addCrashBreadcrumb)("network",`${t.toUpperCase()} ${e}${r}${a}`,{url:e,method:t,status:o,duration:s})};exports.recordNetworkBreadcrumb=recordNetworkBreadcrumb;const recordReduxBreadcrumb=(e,t)=>{(0,exports.addCrashBreadcrumb)("redux",(0,i18n_1.t)("crash.breadcrumbAction",{actionType:e}),{type:e,payloadSummary:typeof t=="object"&&t!==null?Object.keys(t):typeof t})};exports.recordReduxBreadcrumb=recordReduxBreadcrumb;const recordUserActionBreadcrumb=(e,t)=>{(0,exports.addCrashBreadcrumb)("user",e,t)};exports.recordUserActionBreadcrumb=recordUserActionBreadcrumb;const clearCrashBreadcrumbs=()=>{breadcrumbsStore=[]};exports.clearCrashBreadcrumbs=clearCrashBreadcrumbs;const getCrashBreadcrumbs=()=>[...breadcrumbsStore];exports.getCrashBreadcrumbs=getCrashBreadcrumbs;const parseCrashStackTrace=e=>{if(!e||typeof e!="string")return[];const t=e.split(`
|
|
2
|
+
`),o=[];for(const s of t){const r=s.trim();if(!r||r.includes("crashHandler.ts")||r.includes("handleInterceptedCrash")||r.includes("addLogFromCrash")||r.includes("setupGlobalCrashHandler"))continue;const a=r.match(/^([^@]+)@(.*):(\d+):(\d+)$/);if(a){const[,c,n,p,d]=a,m=n.split("?")[0].split("/").pop()||n,f=!n.includes("node_modules")&&!n.includes("react-native")&&!n.includes("react-dom")&&!n.includes("hermes")&&!n.includes("internal");o.push({method:c.trim(),file:m,lineNumber:parseInt(p,10),column:parseInt(d,10),raw:r,isAppCode:f});continue}const u=r.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);if(u){const[,c,n,p,d]=u,m=n.split("?")[0].split("/").pop()||n,f=!n.includes("node_modules")&&!n.includes("react-native")&&!n.includes("react-dom")&&!n.includes("internal");o.push({method:c.trim(),file:m,lineNumber:parseInt(p,10),column:parseInt(d,10),raw:r,isAppCode:f});continue}const l=r.match(/^at\s+(.+):(\d+):(\d+)$/);if(l){const[,c,n,p]=l,d=c.split("?")[0].split("/").pop()||c,m=!c.includes("node_modules")&&!c.includes("react-native");o.push({method:"<anonymous>",file:d,lineNumber:parseInt(n,10),column:parseInt(p,10),raw:r,isAppCode:m});continue}const h=r.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);if(h){const[,c,n,p]=h,d=!c.startsWith("com.facebook.react")&&!c.startsWith("android.");o.push({method:c,file:n,lineNumber:parseInt(p,10),column:0,raw:r,isAppCode:d});continue}const i=r.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);if(i){const[,c,n,p]=i,d=!c.startsWith("lib")&&!c.startsWith("Core")&&!c.startsWith("React");o.push({method:p,file:c,lineNumber:0,column:0,raw:r,isAppCode:d});continue}o.push({method:r.startsWith("at ")?r.slice(3):r,file:"runtime",lineNumber:0,column:0,raw:r,isAppCode:!1})}return o};exports.parseCrashStackTrace=parseCrashStackTrace;const getMemoryDiagnostics=()=>{try{const e=globalThis.performance;if(e&&e.memory)return{usedJSHeapSize:Math.round(e.memory.usedJSHeapSize/(1024*1024)),totalJSHeapSize:Math.round(e.memory.totalJSHeapSize/(1024*1024))}}catch{}},getScreenDimensions=()=>{try{const e=react_native_1.Dimensions.get("window");return`${Math.round(e.width)}x${Math.round(e.height)} (${e.scale}x)`}catch{return(0,i18n_1.t)("crash.unknown")}},computeCrashFingerprint=e=>{const t=e.type||"js",o=e.name||"Error",s=e.parsedStack&&e.parsedStack.length>0?e.parsedStack[0]:null,r=s?`${s.file}:${s.lineNumber}`:"unknown";return`${t}_${o}_${r}`};exports.computeCrashFingerprint=computeCrashFingerprint;const getCrashRecords=()=>[...crashRecordsStore];exports.getCrashRecords=getCrashRecords;const clearCrashRecords=()=>{crashRecordsStore=[],(0,exports.emitCrashEvent)({error:null,message:"__CLEARED__",timestamp:Date.now()})};exports.clearCrashRecords=clearCrashRecords;const subscribeCrashEvents=e=>(crashListeners.push(e),()=>{crashListeners=crashListeners.filter(t=>t!==e)});exports.subscribeCrashEvents=subscribeCrashEvents;const emitCrashEvent=e=>{if(e.message!=="__CLEARED__"){const t=Date.now();if(t-lastHandledErrorTimestamp<250)return;lastHandledErrorTimestamp=t}crashListeners.forEach(t=>{try{t(e)}catch{}})};exports.emitCrashEvent=emitCrashEvent;const handleInterceptedCrash=(e,t,o=!1,s,r)=>{try{const a=e instanceof Error||typeof e=="object"&&e!==null?e:new Error(String(e||(0,i18n_1.t)("crash.runtimeException"))),u=a.message||(typeof e=="string"?e:(0,i18n_1.t)("crash.runtimeException"));let l="";typeof t=="string"?l=t:Array.isArray(t)?l=t.map(g=>`at ${g.methodName||"<anonymous>"} (${g.file||"unknown"}:${g.lineNumber||0}:${g.column||0})`).join(`
|
|
3
|
+
`):l=a.stack||new Error().stack||"";let h=s||enums_1.CrashType.Js;const i=u.toLowerCase();s||(i.includes("native")||i.includes("sigsegv")||i.includes("nsrange")||i.includes("nullpointerexception")||i.includes("fatal signal")?h=enums_1.CrashType.Native:i.includes("promise")||i.includes("unhandled rejection")||i.includes("unhandledrejection")?h=enums_1.CrashType.Promise:i.includes("render")||i.includes("errorboundary")||r?h=enums_1.CrashType.Render:h=enums_1.CrashType.Js);const c=new Date,n=c.toLocaleDateString(),p=c.toLocaleTimeString(),d=(0,exports.parseCrashStackTrace)(l),m=(0,consoleLogger_1.addLogFromCrash)(a,`[${o?(0,i18n_1.t)("crash.logFatalCrash"):(0,i18n_1.t)("crash.logUnhandledError")}] ${u}`,l,o),f=typeof globalThis.HermesInternal<"u",x=typeof globalThis.nativeFabricUIManager<"u",C={id:`crash_${Date.now()}_${Math.random().toString(36).substr(2,6)}`,error:a,isFatal:o,type:h,message:u,name:a.name||(o?(0,i18n_1.t)("crash.errorNameFatal"):(0,i18n_1.t)("crash.errorNameUnhandled")),stack:l,parsedStack:d,componentStack:r||void 0,timestamp:Date.now(),dateStr:n,timeStr:p,deviceInfo:{platform:react_native_1.Platform.OS,osVersion:String(react_native_1.Platform.Version),rnVersion:react_native_1.Platform.constants?.reactNativeVersion?`${react_native_1.Platform.constants.reactNativeVersion.major}.${react_native_1.Platform.constants.reactNativeVersion.minor}.${react_native_1.Platform.constants.reactNativeVersion.patch}`:(0,i18n_1.t)("crash.unknown"),isHermes:f,isFabric:x,appState:react_native_1.AppState.currentState||"active"},memoryInfo:getMemoryDiagnostics(),breadcrumbs:[...breadcrumbsStore],logId:m?.id};crashRecordsStore.unshift(C),crashRecordsStore.length>maxStoredCrashes&&(crashRecordsStore=crashRecordsStore.slice(0,maxStoredCrashes)),(0,exports.emitCrashEvent)({error:a,isFatal:o,message:`[${o?(0,i18n_1.t)("crash.logFatalCrash"):(0,i18n_1.t)("crash.logUnhandledError")}] ${u}`,stack:l,timestamp:Date.now(),logId:m?.id,crashRecord:C});try{(0,NativeInspector_1.showNativeFloatingButton)(),(0,NativeInspector_1.setNativeFloatingButtonBadge)(!0)}catch{}return C}catch{return{id:`crash_${Date.now()}`,isFatal:!0,type:enums_1.CrashType.Js,message:String(e||(0,i18n_1.t)("crash.unknownException")),timestamp:Date.now(),dateStr:new Date().toLocaleDateString(),timeStr:new Date().toLocaleTimeString()}}};exports.handleInterceptedCrash=handleInterceptedCrash;const recordCustomCrash=(e,t)=>(0,exports.handleInterceptedCrash)(e,typeof e=="object"?e.stack:void 0,t?.isFatal??!1,t?.type||enums_1.CrashType.Custom,t?.componentStack);exports.recordCustomCrash=recordCustomCrash;const simulateTestCrash=(e=enums_1.CrashType.Js,t,o)=>{const s=new Error(t||_defaultSimMessage(e));return(0,exports.handleInterceptedCrash)(e===enums_1.CrashType.Native?s.message:s,o||s.stack,e===enums_1.CrashType.Native,e,e===enums_1.CrashType.Render?_buildComponentStack():void 0)};exports.simulateTestCrash=simulateTestCrash;const _defaultSimMessage=e=>{switch(e){case"native":return(0,i18n_1.t)("crash.simNativeMessage");case"promise":return(0,i18n_1.t)("crash.simPromiseMessage");case"render":return(0,i18n_1.t)("crash.simRenderMessage");default:return(0,i18n_1.t)("crash.simJsMessage")}},_buildComponentStack=()=>{try{const e=new Error;if(e.stack)return e.stack.split(`
|
|
4
|
+
`).slice(1,6).map(t=>` ${t.trim()}`).join(`
|
|
5
|
+
`)}catch{}},exportCrashReport=(e,t="text")=>{if(t==="json")return JSON.stringify(e,null,2);const o=Math.round((e.timestamp-appStartTime)/1e3);if(t==="markdown"){const r=[];return r.push(`## ${(0,i18n_1.t)("crash.mdReportTitle",{name:e.name||"Error"})}`),r.push(`> **${e.message}**`),r.push(""),r.push(`- **${(0,i18n_1.t)("crash.reportType")}** \`${e.type.toUpperCase()}\``),r.push(`- **${(0,i18n_1.t)("crash.reportFatal")}** \`${e.isFatal?(0,i18n_1.t)("crash.mdSeverityFatal"):(0,i18n_1.t)("crash.mdSeverityHandled")}\``),r.push(`- **${(0,i18n_1.t)("crash.reportTimestamp")}** ${e.dateStr} ${e.timeStr}`),r.push(`- **${(0,i18n_1.t)("crash.reportUptime")}** ${o}s`),r.push(`- **${(0,i18n_1.t)("crash.reportPlatform")}** ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),r.push(`- **${(0,i18n_1.t)("crash.reportReactNative")}** v${e.deviceInfo?.rnVersion||"N/A"}`),r.push(`- **${(0,i18n_1.t)("crash.jsEngine")}** ${e.deviceInfo?.isHermes?(0,i18n_1.t)("crash.hermesEngine"):(0,i18n_1.t)("crash.jsc")}`),r.push(`- **${(0,i18n_1.t)("crash.reportArchitecture")}** ${e.deviceInfo?.isFabric?(0,i18n_1.t)("crash.reportFabricNew"):(0,i18n_1.t)("crash.reportPaperLegacy")}`),e.memoryInfo&&r.push(`- **${(0,i18n_1.t)("crash.reportJsMemory")}** ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),r.push(""),r.push(`### ${(0,i18n_1.t)("crash.mdStackTrace")}`),r.push("```"),r.push(e.stack||(0,i18n_1.t)("crash.reportNoStackTrace")),r.push("```"),e.componentStack&&(r.push(""),r.push(`### ${(0,i18n_1.t)("crash.mdComponentHierarchy")}`),r.push("```"),r.push(e.componentStack),r.push("```")),e.breadcrumbs&&e.breadcrumbs.length>0&&(r.push(""),r.push(`### ${(0,i18n_1.t)("crash.mdRecentBreadcrumbs")}`),e.breadcrumbs.forEach(a=>{const u=new Date(a.timestamp).toLocaleTimeString();r.push(`- \`[${u}]\` **[${a.type.toUpperCase()}]** ${a.message}`)})),r.join(`
|
|
6
|
+
`)}const s=[];return s.push("===================================================="),s.push(` ${(0,i18n_1.t)("crash.reportTitle")} `),s.push("===================================================="),s.push(`${(0,i18n_1.t)("crash.reportErrorName")} ${e.name||"Error"}`),s.push(`${(0,i18n_1.t)("crash.reportMessage")} ${e.message}`),s.push(`${(0,i18n_1.t)("crash.reportType")} ${e.type.toUpperCase()}`),s.push(`${(0,i18n_1.t)("crash.reportFatal")} ${e.isFatal?(0,i18n_1.t)("crash.reportFatalYes"):(0,i18n_1.t)("crash.reportFatalNo")}`),s.push(`${(0,i18n_1.t)("crash.reportTimestamp")} ${e.dateStr} ${e.timeStr} (${e.timestamp})`),s.push(`${(0,i18n_1.t)("crash.reportUptime")} ${(0,i18n_1.t)("crash.reportUptimeValue",{seconds:o})}`),s.push(`${(0,i18n_1.t)("crash.reportPlatform")} ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),s.push(`${(0,i18n_1.t)("crash.reportReactNative")} ${e.deviceInfo?.rnVersion||"N/A"}`),s.push(`${(0,i18n_1.t)("crash.reportHermes")} ${e.deviceInfo?.isHermes?(0,i18n_1.t)("crash.reportEnabled"):(0,i18n_1.t)("crash.reportDisabled")}`),s.push(`${(0,i18n_1.t)("crash.reportArchitecture")} ${e.deviceInfo?.isFabric?(0,i18n_1.t)("crash.reportFabricNew"):(0,i18n_1.t)("crash.reportPaperLegacy")}`),s.push(`${(0,i18n_1.t)("crash.reportScreenSize")} ${getScreenDimensions()}`),s.push(`${(0,i18n_1.t)("crash.reportAppState")} ${e.deviceInfo?.appState||"active"}`),e.memoryInfo&&s.push(`${(0,i18n_1.t)("crash.reportJsMemory")} ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),s.push("----------------------------------------------------"),s.push(`${(0,i18n_1.t)("crash.reportStackTrace")}`),s.push(e.stack||(0,i18n_1.t)("crash.reportNoStackTrace")),e.componentStack&&(s.push("----------------------------------------------------"),s.push(`${(0,i18n_1.t)("crash.reportComponentHierarchy")}`),s.push(e.componentStack)),e.breadcrumbs&&e.breadcrumbs.length>0&&(s.push("----------------------------------------------------"),s.push(`${(0,i18n_1.t)("crash.reportRecentBreadcrumbs")}`),e.breadcrumbs.forEach(r=>{const a=new Date(r.timestamp).toLocaleTimeString();s.push(` [${a}] [${r.type.toUpperCase()}] ${r.message}`)})),s.push("===================================================="),s.join(`
|
|
7
|
+
`)};exports.exportCrashReport=exportCrashReport;const setupGlobalCrashHandler=()=>{if(!isCrashHandlerInitialized){isCrashHandlerInitialized=!0;try{react_native_1.LogBox&&typeof react_native_1.LogBox.ignoreAllLogs=="function"&&react_native_1.LogBox.ignoreAllLogs(!0)}catch{}try{const e=require("react-native/Libraries/LogBox/Data/LogBoxData");e&&typeof e.setDisabled=="function"&&e.setDisabled(!0)}catch{}try{const e=react_native_1.NativeModules?.NetworkInspectorModule;e&&(typeof e.enableNativeCrashProtection=="function"&&e.enableNativeCrashProtection(),new react_native_1.NativeEventEmitter(e).addListener("onNativeCrash",o=>{const r=`[${(o?.platform||react_native_1.Platform.OS).toUpperCase()} ${(0,i18n_1.t)("crash.nativeCrashTitle")}] ${o?.message||(0,i18n_1.t)("crash.nativeUncaughtException")}`,a=o?.stack||"";(0,exports.handleInterceptedCrash)(r,a,!0,"native")}))}catch{}try{const e=react_native_1.TurboModuleRegistry||globalThis.__turboModuleProxy,t=react_native_1.NativeModules?.ExceptionsManager||(e?.get?e.get("ExceptionsManager"):null);if(t){t.reportFatalException=(s,r,a)=>{(0,exports.handleInterceptedCrash)(s,r,!0,"native");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportSoftException=(s,r,a)=>{(0,exports.handleInterceptedCrash)(s,r,!1,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportException=s=>{const r=s?.message||s?.title||(0,i18n_1.t)("crash.nativeException"),a=s?.stack||s?.rawStack;(0,exports.handleInterceptedCrash)(r,a,s?.isFatal??!0,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.updateExceptionMessage=()=>{};try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}}const o=react_native_1.NativeModules?.RedBox||react_native_1.NativeModules?.RCTRedBox||(e?.get?e.get("RedBox")||e.get("RCTRedBox"):null);o&&(typeof o.showErrorMessage=="function"&&(o.showErrorMessage=()=>{}),typeof o.showUserError=="function"&&(o.showUserError=()=>{}),typeof o.dismiss=="function"&&o.dismiss())}catch{}try{const t=globalThis.ErrorUtils;t&&(typeof t.setGlobalHandler=="function"&&t.setGlobalHandler((o,s)=>{(0,exports.handleInterceptedCrash)(o,o?.stack,s??!1,"js")}),typeof t.reportFatalError=="function"&&(t.reportFatalError=o=>{(0,exports.handleInterceptedCrash)(o,o?.stack,!0,"js")}),typeof t.reportError=="function"&&(t.reportError=o=>{(0,exports.handleInterceptedCrash)(o,o?.stack,!1,"js")}))}catch{}try{const e=globalThis,t=o=>{try{const s=o?.reason||o?.detail?.reason||o,r=s?.message||String(s||(0,i18n_1.t)("crash.unhandledPromiseRejection")),a=s?.stack||(o?.stack??new Error().stack);(0,exports.handleInterceptedCrash)(s,a,!1,"promise")}catch{}};typeof e.addEventListener=="function"&&e.addEventListener("unhandledrejection",t),typeof e.onunhandledrejection<"u"&&(e.onunhandledrejection=t)}catch{}}};exports.setupGlobalCrashHandler=setupGlobalCrashHandler;
|