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,944 +1 @@
|
|
|
1
|
-
import { AppColors } from '../styles/AppColors';
|
|
2
|
-
import { t } from '../i18n';
|
|
3
|
-
import { NativeModules, Platform, TurboModuleRegistry } from 'react-native';
|
|
4
|
-
let cachedAnalysis = null;
|
|
5
|
-
let isAnalyzing = false;
|
|
6
|
-
const subscribers = [];
|
|
7
|
-
let isBundleModuleEnabled = false;
|
|
8
|
-
export const setBundleModuleEnabled = (enabled) => {
|
|
9
|
-
isBundleModuleEnabled = enabled;
|
|
10
|
-
};
|
|
11
|
-
export const getBundleModuleEnabled = () => isBundleModuleEnabled;
|
|
12
|
-
const getSourceCodeModule = () => {
|
|
13
|
-
try {
|
|
14
|
-
const legacy = NativeModules?.SourceCode;
|
|
15
|
-
const scriptURL = legacy?.scriptURL || legacy?.getConstants?.()?.scriptURL;
|
|
16
|
-
if (typeof scriptURL === 'string' && scriptURL.length > 0) {
|
|
17
|
-
return { scriptURL };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
catch { }
|
|
21
|
-
try {
|
|
22
|
-
const turbo = TurboModuleRegistry?.get?.('SourceCode');
|
|
23
|
-
const constants = turbo?.getConstants?.();
|
|
24
|
-
const scriptURL = turbo?.scriptURL || constants?.scriptURL;
|
|
25
|
-
if (typeof scriptURL === 'string' && scriptURL.length > 0) {
|
|
26
|
-
return { scriptURL };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch { }
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
32
|
-
export const getHostScriptURL = () => {
|
|
33
|
-
try {
|
|
34
|
-
const scriptURL = getSourceCodeModule()?.scriptURL;
|
|
35
|
-
if (typeof scriptURL === 'string' && scriptURL.length > 0) {
|
|
36
|
-
return scriptURL;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch { }
|
|
40
|
-
try {
|
|
41
|
-
const serverHost = NativeModules?.PlatformConstants?.serverHost ||
|
|
42
|
-
NativeModules?.AndroidConstants?.serverHost ||
|
|
43
|
-
NativeModules?.DevSettings?.serverHost ||
|
|
44
|
-
NativeModules?.DevSettings?.getConstants?.()?.serverHost;
|
|
45
|
-
if (typeof serverHost === 'string' && serverHost.length > 0) {
|
|
46
|
-
const formattedHost = serverHost.startsWith('http') ? serverHost : `http://${serverHost}`;
|
|
47
|
-
return `${formattedHost}/index.bundle?platform=${Platform.OS}&dev=true`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch { }
|
|
51
|
-
try {
|
|
52
|
-
const globalHost = globalThis?.__DEV_SERVER_URL__ ||
|
|
53
|
-
globalThis?.__METRO_SERVER_HOST__ ||
|
|
54
|
-
globalThis?.__DEV_SERVER_PORT__ ||
|
|
55
|
-
globalThis?.__METRO_PORT__;
|
|
56
|
-
if (typeof globalHost === 'number') {
|
|
57
|
-
const host = Platform.OS === 'android' ? '10.0.2.2' : 'localhost';
|
|
58
|
-
return `http://${host}:${globalHost}/index.bundle?platform=${Platform.OS}&dev=true`;
|
|
59
|
-
}
|
|
60
|
-
if (typeof globalHost === 'string' && globalHost.length > 0) {
|
|
61
|
-
if (/^\d+$/.test(globalHost)) {
|
|
62
|
-
const host = Platform.OS === 'android' ? '10.0.2.2' : 'localhost';
|
|
63
|
-
return `http://${host}:${globalHost}/index.bundle?platform=${Platform.OS}&dev=true`;
|
|
64
|
-
}
|
|
65
|
-
return globalHost.startsWith('http')
|
|
66
|
-
? globalHost
|
|
67
|
-
: `http://${globalHost}/index.bundle?platform=${Platform.OS}&dev=true`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch { }
|
|
71
|
-
return '';
|
|
72
|
-
};
|
|
73
|
-
const DYNAMIC_DEV_PORTS = [8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 19000, 19001, 3000];
|
|
74
|
-
const extractHostAndPort = (scriptURL) => {
|
|
75
|
-
if (!scriptURL || typeof scriptURL !== 'string') {
|
|
76
|
-
return { host: null, port: null };
|
|
77
|
-
}
|
|
78
|
-
const match = scriptURL.match(/^https?:\/\/([^:/]+)(?::(\d+))?/);
|
|
79
|
-
if (match) {
|
|
80
|
-
return {
|
|
81
|
-
host: match[1] || null,
|
|
82
|
-
port: match[2] ? parseInt(match[2], 10) : null,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return { host: null, port: null };
|
|
86
|
-
};
|
|
87
|
-
const probeCandidateUrlsInParallel = async (scriptURL, timeoutMs = 3000) => {
|
|
88
|
-
const { host: extractedHost, port: extractedPort } = extractHostAndPort(scriptURL);
|
|
89
|
-
if (scriptURL && scriptURL.startsWith('http')) {
|
|
90
|
-
try {
|
|
91
|
-
const controller = new AbortController();
|
|
92
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
93
|
-
const res = await fetch(scriptURL, { signal: controller.signal });
|
|
94
|
-
clearTimeout(timer);
|
|
95
|
-
if (res.ok) {
|
|
96
|
-
const contentLength = res.headers.get('content-length');
|
|
97
|
-
const text = await res.text();
|
|
98
|
-
if (text && text.length > 0) {
|
|
99
|
-
const bytes = contentLength ? parseInt(contentLength, 10) || text.length : text.length;
|
|
100
|
-
return { text, bytes, url: scriptURL };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const candidateHosts = extractedHost
|
|
108
|
-
? [extractedHost, 'localhost', '127.0.0.1', ...(Platform.OS === 'android' ? ['10.0.2.2', '10.0.3.2'] : [])]
|
|
109
|
-
: ['localhost', '127.0.0.1', ...(Platform.OS === 'android' ? ['10.0.2.2', '10.0.3.2'] : [])];
|
|
110
|
-
const uniqueHosts = Array.from(new Set(candidateHosts));
|
|
111
|
-
const candidatePorts = extractedPort
|
|
112
|
-
? Array.from(new Set([extractedPort, ...DYNAMIC_DEV_PORTS]))
|
|
113
|
-
: DYNAMIC_DEV_PORTS;
|
|
114
|
-
const probeTasks = [];
|
|
115
|
-
for (const host of uniqueHosts) {
|
|
116
|
-
for (const port of candidatePorts) {
|
|
117
|
-
probeTasks.push(new Promise(async (resolve, reject) => {
|
|
118
|
-
const controller = new AbortController();
|
|
119
|
-
const timer = setTimeout(() => controller.abort(), 700);
|
|
120
|
-
try {
|
|
121
|
-
const res = await fetch(`http://${host}:${port}/status`, { signal: controller.signal });
|
|
122
|
-
clearTimeout(timer);
|
|
123
|
-
if (res.ok) {
|
|
124
|
-
const statusText = await res.text();
|
|
125
|
-
if (statusText && statusText.includes('packager-status:running')) {
|
|
126
|
-
resolve({ host, port });
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
clearTimeout(timer);
|
|
133
|
-
}
|
|
134
|
-
reject(new Error('unreachable'));
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
let activeServer = null;
|
|
139
|
-
try {
|
|
140
|
-
activeServer = await new Promise((resolve, reject) => {
|
|
141
|
-
let pending = probeTasks.length;
|
|
142
|
-
if (pending === 0) {
|
|
143
|
-
reject(new Error('No candidate hosts'));
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
probeTasks.forEach(p => {
|
|
147
|
-
p.then(resolve).catch(() => {
|
|
148
|
-
pending--;
|
|
149
|
-
if (pending === 0) {
|
|
150
|
-
reject(new Error('All probes failed'));
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
activeServer = null;
|
|
158
|
-
}
|
|
159
|
-
if (activeServer) {
|
|
160
|
-
const dynamicBundleUrl = `http://${activeServer.host}:${activeServer.port}/index.bundle?platform=${Platform.OS}&dev=true`;
|
|
161
|
-
try {
|
|
162
|
-
const controller = new AbortController();
|
|
163
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
164
|
-
const res = await fetch(dynamicBundleUrl, { signal: controller.signal });
|
|
165
|
-
clearTimeout(timer);
|
|
166
|
-
if (res.ok) {
|
|
167
|
-
const contentLength = res.headers.get('content-length');
|
|
168
|
-
const text = await res.text();
|
|
169
|
-
if (text && text.length > 0) {
|
|
170
|
-
const bytes = contentLength ? parseInt(contentLength, 10) || text.length : text.length;
|
|
171
|
-
return { text, bytes, url: dynamicBundleUrl };
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
};
|
|
180
|
-
const executedModuleIds = new Set();
|
|
181
|
-
const runtimeModules = new Map();
|
|
182
|
-
export const trackRuntimeModuleExecution = () => {
|
|
183
|
-
try {
|
|
184
|
-
const g = globalThis;
|
|
185
|
-
const r = g.__r;
|
|
186
|
-
if (typeof r === 'function' && !r.__inspectorTracked) {
|
|
187
|
-
const tracked = function (moduleId, ...rest) {
|
|
188
|
-
executedModuleIds.add(Number(moduleId));
|
|
189
|
-
return r.call(this, moduleId, ...rest);
|
|
190
|
-
};
|
|
191
|
-
Object.defineProperty(tracked, '__inspectorTracked', { value: true, enumerable: false });
|
|
192
|
-
g.__r = tracked;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch { }
|
|
196
|
-
};
|
|
197
|
-
export const trackRuntimeDefine = () => {
|
|
198
|
-
try {
|
|
199
|
-
const g = globalThis;
|
|
200
|
-
const originalD = g.__d;
|
|
201
|
-
if (typeof originalD === 'function' && !originalD.__inspectorTracked) {
|
|
202
|
-
const trackedD = function (factory, moduleId, dependencyMap, verboseName, ...rest) {
|
|
203
|
-
if (typeof verboseName === 'string' && verboseName.length > 0) {
|
|
204
|
-
runtimeModules.set(Number(moduleId), { id: Number(moduleId), path: verboseName });
|
|
205
|
-
}
|
|
206
|
-
return originalD.call(this, factory, moduleId, dependencyMap, verboseName, ...rest);
|
|
207
|
-
};
|
|
208
|
-
Object.defineProperty(trackedD, '__inspectorTracked', { value: true, enumerable: false });
|
|
209
|
-
g.__d = trackedD;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch { }
|
|
213
|
-
};
|
|
214
|
-
trackRuntimeModuleExecution();
|
|
215
|
-
trackRuntimeDefine();
|
|
216
|
-
const DEFAULT_BASELINE_MODULES = [
|
|
217
|
-
{ id: 1, deps: [2, 3, 4], path: 'index.js' },
|
|
218
|
-
{ id: 2, deps: [4, 5, 13, 14, 15, 16], path: 'App.tsx' },
|
|
219
|
-
{ id: 3, deps: [], path: 'node_modules/react-native/index.js' },
|
|
220
|
-
{ id: 4, deps: [], path: 'node_modules/react/index.js' },
|
|
221
|
-
{ id: 5, deps: [6, 7], path: 'node_modules/@react-navigation/native/src/index.ts' },
|
|
222
|
-
{ id: 6, deps: [], path: 'node_modules/react-native-screens/src/index.ts' },
|
|
223
|
-
{ id: 7, deps: [], path: 'node_modules/react-native-safe-area-context/src/index.ts' },
|
|
224
|
-
{ id: 8, deps: [], path: 'node_modules/react-native-svg/src/index.ts' },
|
|
225
|
-
{ id: 9, deps: [], path: 'node_modules/axios/index.js' },
|
|
226
|
-
{ id: 10, deps: [], path: 'node_modules/i18next/dist/esm/i18next.js' },
|
|
227
|
-
{ id: 11, deps: [12], path: 'node_modules/react-redux/src/index.ts' },
|
|
228
|
-
{ id: 12, deps: [], path: 'node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js' },
|
|
229
|
-
{ id: 13, deps: [], path: 'src/components/Inspector/BundleTab.tsx' },
|
|
230
|
-
{ id: 14, deps: [], path: 'src/navigation/RootNavigator.tsx' },
|
|
231
|
-
{ id: 15, deps: [], path: 'src/screens/HomeScreen.tsx' },
|
|
232
|
-
{ id: 16, deps: [], path: 'src/store/index.ts' },
|
|
233
|
-
{ id: 17, deps: [], path: 'assets/images/logo.png' },
|
|
234
|
-
{ id: 18, deps: [], path: 'package.json' },
|
|
235
|
-
];
|
|
236
|
-
const extractBundleModules = (bundleText) => {
|
|
237
|
-
const modules = [];
|
|
238
|
-
const seenIds = new Set();
|
|
239
|
-
if (bundleText && bundleText.length > 0) {
|
|
240
|
-
const sourceUrlRegex = /\/\/[#@]\s*sourceURL=(?:https?:\/\/[^\s\r\n/]+\/|file:\/\/)?([^\s\r\n?#]+)/g;
|
|
241
|
-
let srcMatch;
|
|
242
|
-
let autoId = 900000;
|
|
243
|
-
while ((srcMatch = sourceUrlRegex.exec(bundleText)) !== null) {
|
|
244
|
-
const path = srcMatch[1];
|
|
245
|
-
if (path && path.length > 0 && !path.endsWith('.bundle')) {
|
|
246
|
-
const id = autoId++;
|
|
247
|
-
if (!seenIds.has(id)) {
|
|
248
|
-
seenIds.add(id);
|
|
249
|
-
modules.push({ id, deps: [], path });
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
const linearDefineRegex = /,\s*(\d+)\s*,\s*(?:\[[^\]\r\n]{0,500}\]|\{[^}\r\n]{0,500}\})\s*,\s*["']([^"'\r\n]+)["']\s*\)/g;
|
|
254
|
-
let defMatch;
|
|
255
|
-
while ((defMatch = linearDefineRegex.exec(bundleText)) !== null) {
|
|
256
|
-
const id = parseInt(defMatch[1], 10);
|
|
257
|
-
const path = defMatch[2] || '';
|
|
258
|
-
if (!seenIds.has(id) && path.length > 0) {
|
|
259
|
-
seenIds.add(id);
|
|
260
|
-
modules.push({ id, deps: [], path });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
runtimeModules.forEach((item, id) => {
|
|
265
|
-
if (!seenIds.has(id)) {
|
|
266
|
-
seenIds.add(id);
|
|
267
|
-
modules.push({ id, deps: [], path: item.path });
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
if (modules.length === 0) {
|
|
271
|
-
return DEFAULT_BASELINE_MODULES;
|
|
272
|
-
}
|
|
273
|
-
return modules;
|
|
274
|
-
};
|
|
275
|
-
const getStaticStartupModuleIds = (bundleText) => {
|
|
276
|
-
const ids = new Set();
|
|
277
|
-
if (!bundleText)
|
|
278
|
-
return ids;
|
|
279
|
-
const startupRe = /__r\s*\(\s*(\d+)\s*\)/g;
|
|
280
|
-
let m;
|
|
281
|
-
while ((m = startupRe.exec(bundleText)) !== null) {
|
|
282
|
-
ids.add(parseInt(m[1], 10));
|
|
283
|
-
}
|
|
284
|
-
return ids;
|
|
285
|
-
};
|
|
286
|
-
const detectProjectRoot = (allRawPaths) => {
|
|
287
|
-
const normPaths = allRawPaths.map(p => p.replace(/\\/g, '/'));
|
|
288
|
-
for (const norm of normPaths) {
|
|
289
|
-
const nmIdx = norm.indexOf('/node_modules/');
|
|
290
|
-
if (nmIdx !== -1) {
|
|
291
|
-
return norm.slice(0, nmIdx + 1);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
for (const norm of normPaths) {
|
|
295
|
-
const match = norm.match(/^(.*\/)(?:index\.[jt]sx?|app\.[jt]sx?|package\.json)(?:[?#].*)?$/i);
|
|
296
|
-
if (match && match[1]) {
|
|
297
|
-
return match[1];
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const absPaths = normPaths.filter(p => p.startsWith('/') && !p.includes('/node_modules/'));
|
|
301
|
-
if (absPaths.length === 0)
|
|
302
|
-
return '';
|
|
303
|
-
if (absPaths.length === 1) {
|
|
304
|
-
const lastSlash = absPaths[0].lastIndexOf('/');
|
|
305
|
-
return lastSlash > 0 ? absPaths[0].slice(0, lastSlash + 1) : '';
|
|
306
|
-
}
|
|
307
|
-
const splitPaths = absPaths.map(p => p.split('/'));
|
|
308
|
-
let commonLen = 0;
|
|
309
|
-
const first = splitPaths[0];
|
|
310
|
-
const minLen = Math.min(...splitPaths.map(sp => sp.length));
|
|
311
|
-
while (commonLen < minLen - 1) {
|
|
312
|
-
const seg = first[commonLen];
|
|
313
|
-
if (splitPaths.every(sp => sp[commonLen] === seg)) {
|
|
314
|
-
commonLen++;
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return commonLen > 0 ? first.slice(0, commonLen).join('/') + '/' : '';
|
|
321
|
-
};
|
|
322
|
-
const normalizeProjectRelativePath = (rawPath, projectRoot) => {
|
|
323
|
-
let clean = rawPath.replace(/\\/g, '/');
|
|
324
|
-
const qIdx = clean.search(/[?#]/);
|
|
325
|
-
if (qIdx !== -1) {
|
|
326
|
-
clean = clean.slice(0, qIdx);
|
|
327
|
-
}
|
|
328
|
-
clean = clean.replace(/^(?:https?:\/\/[^/]+\/|file:\/\/)/, '');
|
|
329
|
-
if (projectRoot && clean.startsWith(projectRoot)) {
|
|
330
|
-
clean = clean.slice(projectRoot.length);
|
|
331
|
-
}
|
|
332
|
-
clean = clean.replace(/^(\.\.\/)+/, '').replace(/^\.\//, '').replace(/^\/+/, '');
|
|
333
|
-
if (!clean)
|
|
334
|
-
clean = rawPath.split('/').pop() || rawPath;
|
|
335
|
-
return clean;
|
|
336
|
-
};
|
|
337
|
-
const isExternalPackage = (rawPath) => {
|
|
338
|
-
if (rawPath.includes('node_modules/')) {
|
|
339
|
-
const pkgMatch = rawPath.match(/node_modules\/(?:@([^/]+)\/([^/]+)|([^/]+))/);
|
|
340
|
-
if (pkgMatch) {
|
|
341
|
-
const pkgName = pkgMatch[1] && pkgMatch[2] ? `@${pkgMatch[1]}/${pkgMatch[2]}` : pkgMatch[3];
|
|
342
|
-
return { isPkg: true, pkgName };
|
|
343
|
-
}
|
|
344
|
-
return { isPkg: true };
|
|
345
|
-
}
|
|
346
|
-
if (rawPath.includes('react-native-inapp-inspector')) {
|
|
347
|
-
return { isPkg: true, pkgName: 'react-native-inapp-inspector' };
|
|
348
|
-
}
|
|
349
|
-
if (rawPath.includes('.yarn/') || rawPath.includes('.pnpm/')) {
|
|
350
|
-
return { isPkg: true };
|
|
351
|
-
}
|
|
352
|
-
if (rawPath.includes('/dist/esm/') ||
|
|
353
|
-
rawPath.includes('/dist/commonjs/') ||
|
|
354
|
-
rawPath.includes('/dist/cjs/') ||
|
|
355
|
-
rawPath.startsWith('dist/esm/') ||
|
|
356
|
-
rawPath.startsWith('dist/commonjs/') ||
|
|
357
|
-
rawPath.startsWith('dist/') ||
|
|
358
|
-
rawPath.includes('/react-native-inapp-inspector/dist/')) {
|
|
359
|
-
return { isPkg: true, pkgName: 'react-native-inapp-inspector' };
|
|
360
|
-
}
|
|
361
|
-
return { isPkg: false };
|
|
362
|
-
};
|
|
363
|
-
const isInternalModule = (rawPath) => {
|
|
364
|
-
return (rawPath.startsWith('<<') ||
|
|
365
|
-
rawPath.startsWith('[metro]') ||
|
|
366
|
-
rawPath.includes('metro-runtime') ||
|
|
367
|
-
rawPath.includes('polyfills/require.js') ||
|
|
368
|
-
rawPath.includes('prelude_commonjs') ||
|
|
369
|
-
rawPath.includes('Libraries/Core/InitializeCore.js') ||
|
|
370
|
-
rawPath.includes('@babel/runtime'));
|
|
371
|
-
};
|
|
372
|
-
export const parseBundleSource = (bundleText, totalBytes, scriptURL, isLive = true) => {
|
|
373
|
-
const isHermes = Boolean(globalThis.HermesInternal);
|
|
374
|
-
const totalDevMb = Number((totalBytes / (1024 * 1024)).toFixed(2));
|
|
375
|
-
const totalDevKb = Math.round(totalBytes / 1024);
|
|
376
|
-
const modules = extractBundleModules(bundleText);
|
|
377
|
-
const startupIds = getStaticStartupModuleIds(bundleText);
|
|
378
|
-
const modMap = new Map();
|
|
379
|
-
for (const mod of modules) {
|
|
380
|
-
modMap.set(mod.id, mod);
|
|
381
|
-
}
|
|
382
|
-
const consumedIds = new Set();
|
|
383
|
-
const queue = [];
|
|
384
|
-
const markConsumed = (id) => {
|
|
385
|
-
if (!consumedIds.has(id)) {
|
|
386
|
-
consumedIds.add(id);
|
|
387
|
-
queue.push(id);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
markConsumed(0);
|
|
391
|
-
startupIds.forEach(id => markConsumed(id));
|
|
392
|
-
executedModuleIds.forEach(id => markConsumed(id));
|
|
393
|
-
for (const mod of modules) {
|
|
394
|
-
const lower = mod.path.toLowerCase().replace(/\\/g, '/');
|
|
395
|
-
if (lower.endsWith('/index.js') ||
|
|
396
|
-
lower.endsWith('/index.ts') ||
|
|
397
|
-
lower.endsWith('/index.tsx') ||
|
|
398
|
-
lower === 'index.js' ||
|
|
399
|
-
lower.endsWith('/app.tsx') ||
|
|
400
|
-
lower.endsWith('/app.js') ||
|
|
401
|
-
lower.endsWith('/app.jsx') ||
|
|
402
|
-
lower === 'app.tsx' ||
|
|
403
|
-
lower === 'app.js' ||
|
|
404
|
-
lower.endsWith('app.json')) {
|
|
405
|
-
markConsumed(mod.id);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
while (queue.length > 0) {
|
|
409
|
-
const currId = queue.shift();
|
|
410
|
-
const currMod = modMap.get(currId);
|
|
411
|
-
if (currMod && currMod.deps) {
|
|
412
|
-
for (const depId of currMod.deps) {
|
|
413
|
-
markConsumed(depId);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
const discoveredPackagesMap = new Map();
|
|
418
|
-
const rawProjectItems = [];
|
|
419
|
-
for (const mod of modules) {
|
|
420
|
-
const rawPath = mod.path.replace(/\\/g, '/');
|
|
421
|
-
const { isPkg, pkgName } = isExternalPackage(rawPath);
|
|
422
|
-
if (isPkg) {
|
|
423
|
-
if (pkgName && !pkgName.startsWith('.')) {
|
|
424
|
-
discoveredPackagesMap.set(pkgName, (discoveredPackagesMap.get(pkgName) || 0) + 1);
|
|
425
|
-
}
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
if (isInternalModule(rawPath)) {
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
rawProjectItems.push({ mod, rawPath });
|
|
432
|
-
}
|
|
433
|
-
const projectRoot = detectProjectRoot(modules.map(item => item.path));
|
|
434
|
-
const discoveredFiles = [];
|
|
435
|
-
let fileIdx = 0;
|
|
436
|
-
for (const { mod, rawPath } of rawProjectItems) {
|
|
437
|
-
const cleanPath = normalizeProjectRelativePath(rawPath, projectRoot);
|
|
438
|
-
const isLocalFile = cleanPath.endsWith('.tsx') ||
|
|
439
|
-
cleanPath.endsWith('.ts') ||
|
|
440
|
-
cleanPath.endsWith('.jsx') ||
|
|
441
|
-
cleanPath.endsWith('.js') ||
|
|
442
|
-
cleanPath.endsWith('.mjs') ||
|
|
443
|
-
cleanPath.endsWith('.cjs') ||
|
|
444
|
-
cleanPath.endsWith('.json') ||
|
|
445
|
-
cleanPath.endsWith('.png') ||
|
|
446
|
-
cleanPath.endsWith('.jpg') ||
|
|
447
|
-
cleanPath.endsWith('.jpeg') ||
|
|
448
|
-
cleanPath.endsWith('.gif') ||
|
|
449
|
-
cleanPath.endsWith('.webp') ||
|
|
450
|
-
cleanPath.endsWith('.svg') ||
|
|
451
|
-
cleanPath.endsWith('.bmp') ||
|
|
452
|
-
cleanPath.endsWith('.ico') ||
|
|
453
|
-
cleanPath.endsWith('.ttf') ||
|
|
454
|
-
cleanPath.endsWith('.otf') ||
|
|
455
|
-
cleanPath.endsWith('.woff') ||
|
|
456
|
-
cleanPath.endsWith('.woff2') ||
|
|
457
|
-
cleanPath.endsWith('.css') ||
|
|
458
|
-
cleanPath.endsWith('.scss') ||
|
|
459
|
-
cleanPath.endsWith('.html') ||
|
|
460
|
-
cleanPath.endsWith('.md') ||
|
|
461
|
-
cleanPath.endsWith('.graphql') ||
|
|
462
|
-
cleanPath.endsWith('.gql');
|
|
463
|
-
if (!isLocalFile)
|
|
464
|
-
continue;
|
|
465
|
-
const ext = cleanPath.split('.').pop()?.toUpperCase() || 'JS';
|
|
466
|
-
const name = cleanPath.split('/').pop() || cleanPath;
|
|
467
|
-
let category = 'javascript';
|
|
468
|
-
let color = AppColors.indigo500;
|
|
469
|
-
if (ext === 'TSX' || ext === 'TS') {
|
|
470
|
-
category = 'typescript';
|
|
471
|
-
color = AppColors.sky500;
|
|
472
|
-
}
|
|
473
|
-
else if (ext === 'PNG' ||
|
|
474
|
-
ext === 'JPG' ||
|
|
475
|
-
ext === 'JPEG' ||
|
|
476
|
-
ext === 'GIF' ||
|
|
477
|
-
ext === 'WEBP' ||
|
|
478
|
-
ext === 'SVG' ||
|
|
479
|
-
ext === 'BMP' ||
|
|
480
|
-
ext === 'ICO') {
|
|
481
|
-
category = 'image';
|
|
482
|
-
color = AppColors.pink500;
|
|
483
|
-
}
|
|
484
|
-
else if (ext === 'TTF' || ext === 'OTF' || ext === 'WOFF' || ext === 'WOFF2') {
|
|
485
|
-
category = 'font';
|
|
486
|
-
color = AppColors.purple500;
|
|
487
|
-
}
|
|
488
|
-
else if (ext === 'JSON' || ext === 'CSS' || ext === 'SCSS' || ext === 'HTML' || ext === 'MD' || ext === 'GRAPHQL' || ext === 'GQL') {
|
|
489
|
-
category = 'json';
|
|
490
|
-
color = AppColors.emerald500;
|
|
491
|
-
}
|
|
492
|
-
const approxKb = Math.max(2, Math.round((totalDevKb * 0.15) / Math.max(modules.length, 20)));
|
|
493
|
-
const isTestOrFixture = cleanPath.includes('.test.') ||
|
|
494
|
-
cleanPath.includes('.spec.') ||
|
|
495
|
-
cleanPath.includes('__tests__') ||
|
|
496
|
-
cleanPath.includes('__mocks__') ||
|
|
497
|
-
cleanPath.includes('.stories.') ||
|
|
498
|
-
cleanPath.includes('fixtures/');
|
|
499
|
-
const isConsumed = !isTestOrFixture;
|
|
500
|
-
discoveredFiles.push({
|
|
501
|
-
id: `host-file-${fileIdx++}`,
|
|
502
|
-
name,
|
|
503
|
-
path: cleanPath,
|
|
504
|
-
ext,
|
|
505
|
-
category,
|
|
506
|
-
sizeKb: approxKb,
|
|
507
|
-
meta: `Active Host App Module • ${category.toUpperCase()}`,
|
|
508
|
-
color,
|
|
509
|
-
status: isConsumed ? 'optimal' : 'warning',
|
|
510
|
-
advice: isConsumed
|
|
511
|
-
? 'In-Use: Bundled and active in host application dependency tree'
|
|
512
|
-
: 'Not consumed: Test fixture or orphaned file packaged in bundle',
|
|
513
|
-
isConsumed,
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
const getPackageColor = (name) => {
|
|
517
|
-
const colors = [
|
|
518
|
-
AppColors.indigo500, AppColors.sky500, AppColors.pink500, AppColors.purple500, AppColors.emerald500,
|
|
519
|
-
AppColors.amber500, AppColors.red500, AppColors.teal500, '#3B82F6', AppColors.fuchsia500,
|
|
520
|
-
AppColors.orange500, AppColors.lime500, '#06B6D4', '#A855F7', AppColors.errorColor,
|
|
521
|
-
];
|
|
522
|
-
let hash = 0;
|
|
523
|
-
for (let i = 0; i < name.length; i++) {
|
|
524
|
-
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
525
|
-
}
|
|
526
|
-
return colors[Math.abs(hash) % colors.length];
|
|
527
|
-
};
|
|
528
|
-
const getPackageCategory = (name) => {
|
|
529
|
-
const lower = name.toLowerCase();
|
|
530
|
-
if (lower.includes('navigation') || lower.includes('router') || lower.includes('screen')) {
|
|
531
|
-
return 'navigation';
|
|
532
|
-
}
|
|
533
|
-
if (lower.includes('ui') ||
|
|
534
|
-
lower.includes('reanimated') ||
|
|
535
|
-
lower.includes('gesture') ||
|
|
536
|
-
lower.includes('svg') ||
|
|
537
|
-
lower.includes('lottie') ||
|
|
538
|
-
lower.includes('vector') ||
|
|
539
|
-
lower.includes('icon') ||
|
|
540
|
-
lower.includes('image') ||
|
|
541
|
-
lower.includes('gradient')) {
|
|
542
|
-
return 'ui';
|
|
543
|
-
}
|
|
544
|
-
if (lower.includes('axios') ||
|
|
545
|
-
lower.includes('fetch') ||
|
|
546
|
-
lower.includes('query') ||
|
|
547
|
-
lower.includes('apollo') ||
|
|
548
|
-
lower.includes('network') ||
|
|
549
|
-
lower.includes('socket') ||
|
|
550
|
-
lower.includes('http')) {
|
|
551
|
-
return 'network';
|
|
552
|
-
}
|
|
553
|
-
if (lower === 'react' ||
|
|
554
|
-
lower === 'react-native' ||
|
|
555
|
-
lower.includes('metro') ||
|
|
556
|
-
lower.includes('babel') ||
|
|
557
|
-
lower.includes('core')) {
|
|
558
|
-
return 'core';
|
|
559
|
-
}
|
|
560
|
-
return 'utils';
|
|
561
|
-
};
|
|
562
|
-
const getParentPackageName = (name) => {
|
|
563
|
-
if (name.startsWith('@react-navigation/')) {
|
|
564
|
-
if (name === '@react-navigation/native')
|
|
565
|
-
return null;
|
|
566
|
-
return '@react-navigation/native';
|
|
567
|
-
}
|
|
568
|
-
if (name.startsWith('@react-native/')) {
|
|
569
|
-
return 'react-native';
|
|
570
|
-
}
|
|
571
|
-
if (name === 'react-refresh' ||
|
|
572
|
-
name === 'metro-runtime' ||
|
|
573
|
-
name === 'whatwg-fetch' ||
|
|
574
|
-
name === 'promise' ||
|
|
575
|
-
name === 'event-target-shim') {
|
|
576
|
-
return 'react-native';
|
|
577
|
-
}
|
|
578
|
-
if (name === 'scheduler' || name === 'loose-envify' || name === 'object-assign') {
|
|
579
|
-
return 'react';
|
|
580
|
-
}
|
|
581
|
-
if (name === 'use-sync-external-store' ||
|
|
582
|
-
name === 'reselect' ||
|
|
583
|
-
name === 'redux-thunk' ||
|
|
584
|
-
name === 'immer') {
|
|
585
|
-
return 'react-redux';
|
|
586
|
-
}
|
|
587
|
-
if (name === 'follow-redirects' || name === 'form-data' || name === 'proxy-from-env') {
|
|
588
|
-
return 'axios';
|
|
589
|
-
}
|
|
590
|
-
if (name === 'clone-deep' || name === 'html-parse-stringify' || name === '@babel/runtime') {
|
|
591
|
-
return 'i18next';
|
|
592
|
-
}
|
|
593
|
-
if (name === 'css-select' || name === 'css-tree' || name === 'entities') {
|
|
594
|
-
return 'react-native-svg';
|
|
595
|
-
}
|
|
596
|
-
return null;
|
|
597
|
-
};
|
|
598
|
-
const packageEntries = Array.from(discoveredPackagesMap.entries());
|
|
599
|
-
const totalPkgHits = packageEntries.reduce((sum, [, hits]) => sum + hits, 0) || 1;
|
|
600
|
-
const packagesList = [];
|
|
601
|
-
packageEntries.forEach(([pkgName, hits], idx) => {
|
|
602
|
-
const category = getPackageCategory(pkgName);
|
|
603
|
-
const color = getPackageColor(pkgName);
|
|
604
|
-
const parentPackageName = getParentPackageName(pkgName) || undefined;
|
|
605
|
-
const isDirectDefined = !parentPackageName;
|
|
606
|
-
const approxPkgKb = Math.max(8, Math.round((totalDevKb * 0.52 * hits) / Math.max(totalPkgHits, 1)));
|
|
607
|
-
const percentage = Number(((approxPkgKb / Math.max(totalDevKb, 1)) * 100).toFixed(1));
|
|
608
|
-
packagesList.push({
|
|
609
|
-
id: `host-pkg-${idx}`,
|
|
610
|
-
name: pkgName,
|
|
611
|
-
version: '',
|
|
612
|
-
latestVersion: '',
|
|
613
|
-
sizeKb: approxPkgKb,
|
|
614
|
-
percentage,
|
|
615
|
-
type: isDirectDefined ? 'direct' : 'transitive',
|
|
616
|
-
isDirectDefined,
|
|
617
|
-
parentPackageName,
|
|
618
|
-
subpackages: [],
|
|
619
|
-
category,
|
|
620
|
-
color,
|
|
621
|
-
description: `${hits} bundled ${hits === 1 ? 'module' : 'modules'}`,
|
|
622
|
-
npmUrl: `https://www.npmjs.com/package/${pkgName}`,
|
|
623
|
-
isDeprecated: false,
|
|
624
|
-
lastActive: `${hits} modules`,
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
const directPackagesMap = new Map();
|
|
628
|
-
packagesList.forEach(pkg => {
|
|
629
|
-
if (pkg.isDirectDefined) {
|
|
630
|
-
directPackagesMap.set(pkg.name, pkg);
|
|
631
|
-
}
|
|
632
|
-
});
|
|
633
|
-
packagesList.forEach(pkg => {
|
|
634
|
-
if (pkg.parentPackageName && directPackagesMap.has(pkg.parentPackageName)) {
|
|
635
|
-
const parent = directPackagesMap.get(pkg.parentPackageName);
|
|
636
|
-
if (!parent.subpackages)
|
|
637
|
-
parent.subpackages = [];
|
|
638
|
-
parent.subpackages.push(pkg);
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
packagesList.sort((a, b) => b.sizeKb - a.sizeKb);
|
|
642
|
-
let realNodeModulesKb = 0;
|
|
643
|
-
for (const pkg of packagesList) {
|
|
644
|
-
realNodeModulesKb += pkg.sizeKb || 0;
|
|
645
|
-
}
|
|
646
|
-
let realAppSourceKb = 0;
|
|
647
|
-
let realAssetsMediaKb = 0;
|
|
648
|
-
for (const file of discoveredFiles) {
|
|
649
|
-
if (file.category === 'image' || file.category === 'font') {
|
|
650
|
-
realAssetsMediaKb += file.sizeKb || 0;
|
|
651
|
-
}
|
|
652
|
-
else {
|
|
653
|
-
realAppSourceKb += file.sizeKb || 0;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
const appSourceKb = realAppSourceKb > 0 ? realAppSourceKb : Math.round(totalDevKb * 0.18);
|
|
657
|
-
const nodeModulesKb = realNodeModulesKb > 0 ? realNodeModulesKb : Math.round(totalDevKb * 0.58);
|
|
658
|
-
const assetsMediaKb = realAssetsMediaKb > 0 ? realAssetsMediaKb : Math.round(totalDevKb * 0.08);
|
|
659
|
-
const metroOverheadKb = Math.max(0, totalDevKb - appSourceKb - nodeModulesKb - assetsMediaKb);
|
|
660
|
-
const releaseJsMb = Number(((totalDevKb * 0.38) / 1024).toFixed(2));
|
|
661
|
-
const nodeModulesMb = Number((nodeModulesKb / 1024).toFixed(2));
|
|
662
|
-
const assetsMediaMb = Number((assetsMediaKb / 1024).toFixed(2));
|
|
663
|
-
const effectiveNativePkgCount = Math.min(packagesList.length, 55);
|
|
664
|
-
const nativeFrameworksMb = Number((48.0 + effectiveNativePkgCount * 0.35 + nodeModulesMb * 0.9).toFixed(1));
|
|
665
|
-
const nativeMachoMb = Number((38.0 + effectiveNativePkgCount * 0.22 + nodeModulesMb * 0.6).toFixed(1));
|
|
666
|
-
const assetsCatalogMb = Number((30.0 + assetsMediaMb * 2.2).toFixed(1));
|
|
667
|
-
const metadataMb = 6.4;
|
|
668
|
-
const iosInstallMb = Number((releaseJsMb + nativeFrameworksMb + nativeMachoMb + assetsCatalogMb + metadataMb).toFixed(1));
|
|
669
|
-
const iosDownloadMb = Number((iosInstallMb * 0.655).toFixed(1));
|
|
670
|
-
const androidCppMb = Number((20.0 + effectiveNativePkgCount * 0.12 + nodeModulesMb * 0.4).toFixed(1));
|
|
671
|
-
const androidDexMb = Number((14.0 + effectiveNativePkgCount * 0.08 + nodeModulesMb * 0.25).toFixed(1));
|
|
672
|
-
const androidResMb = Number((16.0 + assetsMediaMb * 1.5).toFixed(1));
|
|
673
|
-
const androidInstallMb = Number((releaseJsMb + androidCppMb + androidDexMb + androidResMb + 3.8).toFixed(1));
|
|
674
|
-
const androidDownloadMb = Number((androidInstallMb * 0.54).toFixed(1));
|
|
675
|
-
const androidMultiAbiCppMb = Number((195.0 + effectiveNativePkgCount * 0.55 + nodeModulesMb * 1.6).toFixed(1));
|
|
676
|
-
const androidApkDexMb = Number((54.0 + effectiveNativePkgCount * 0.2 + nodeModulesMb * 0.6).toFixed(1));
|
|
677
|
-
const androidApkResMb = Number((58.0 + assetsMediaMb * 2.8).toFixed(1));
|
|
678
|
-
const androidApkMetaMb = 8.5;
|
|
679
|
-
const androidApkInstallMb = Number((releaseJsMb + androidMultiAbiCppMb + androidApkDexMb + androidApkResMb + androidApkMetaMb).toFixed(1));
|
|
680
|
-
const androidApkDownloadMb = Number(androidApkInstallMb.toFixed(1));
|
|
681
|
-
const iosComponents = [
|
|
682
|
-
{
|
|
683
|
-
id: 'ios-c1',
|
|
684
|
-
name: t('bundle.iosComp1Name'),
|
|
685
|
-
category: 'frameworks',
|
|
686
|
-
sizeMb: nativeFrameworksMb,
|
|
687
|
-
pct: Number(((nativeFrameworksMb / iosInstallMb) * 100).toFixed(1)),
|
|
688
|
-
color: AppColors.indigo500,
|
|
689
|
-
description: t('bundle.iosComp1Desc', { count: packagesList.length }),
|
|
690
|
-
advice: t('bundle.iosComp1Advice'),
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
id: 'ios-c2',
|
|
694
|
-
name: t('bundle.iosComp2Name'),
|
|
695
|
-
category: 'native',
|
|
696
|
-
sizeMb: nativeMachoMb,
|
|
697
|
-
pct: Number(((nativeMachoMb / iosInstallMb) * 100).toFixed(1)),
|
|
698
|
-
color: AppColors.sky500,
|
|
699
|
-
description: t('bundle.iosComp2Desc'),
|
|
700
|
-
advice: t('bundle.iosComp2Advice'),
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
id: 'ios-c3',
|
|
704
|
-
name: t('bundle.iosComp3Name'),
|
|
705
|
-
category: 'assets',
|
|
706
|
-
sizeMb: assetsCatalogMb,
|
|
707
|
-
pct: Number(((assetsCatalogMb / iosInstallMb) * 100).toFixed(1)),
|
|
708
|
-
color: AppColors.pink500,
|
|
709
|
-
description: t('bundle.iosComp3Desc'),
|
|
710
|
-
advice: t('bundle.iosComp3Advice'),
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
id: 'ios-c4',
|
|
714
|
-
name: t('bundle.iosComp4Name'),
|
|
715
|
-
category: 'js',
|
|
716
|
-
sizeMb: releaseJsMb,
|
|
717
|
-
pct: Number(((releaseJsMb / iosInstallMb) * 100).toFixed(1)),
|
|
718
|
-
color: AppColors.emerald500,
|
|
719
|
-
description: t('bundle.iosComp4Desc', { count: discoveredFiles.length }),
|
|
720
|
-
advice: t('bundle.iosComp4Advice'),
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
id: 'ios-c5',
|
|
724
|
-
name: t('bundle.iosComp5Name'),
|
|
725
|
-
category: 'meta',
|
|
726
|
-
sizeMb: metadataMb,
|
|
727
|
-
pct: Number(((metadataMb / iosInstallMb) * 100).toFixed(1)),
|
|
728
|
-
color: AppColors.amber500,
|
|
729
|
-
description: t('bundle.iosComp5Desc'),
|
|
730
|
-
advice: t('bundle.iosComp5Advice'),
|
|
731
|
-
},
|
|
732
|
-
];
|
|
733
|
-
const androidComponents = [
|
|
734
|
-
{
|
|
735
|
-
id: 'and-c1',
|
|
736
|
-
name: t('bundle.andComp1Name'),
|
|
737
|
-
category: 'native',
|
|
738
|
-
sizeMb: androidCppMb,
|
|
739
|
-
pct: Number(((androidCppMb / androidInstallMb) * 100).toFixed(1)),
|
|
740
|
-
color: AppColors.sky500,
|
|
741
|
-
description: t('bundle.andComp1Desc', { count: packagesList.length }),
|
|
742
|
-
advice: t('bundle.andComp1Advice'),
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
id: 'and-c2',
|
|
746
|
-
name: t('bundle.andComp2Name'),
|
|
747
|
-
category: 'frameworks',
|
|
748
|
-
sizeMb: androidDexMb,
|
|
749
|
-
pct: Number(((androidDexMb / androidInstallMb) * 100).toFixed(1)),
|
|
750
|
-
color: AppColors.indigo500,
|
|
751
|
-
description: t('bundle.andComp2Desc'),
|
|
752
|
-
advice: t('bundle.andComp2Advice'),
|
|
753
|
-
},
|
|
754
|
-
{
|
|
755
|
-
id: 'and-c3',
|
|
756
|
-
name: t('bundle.andComp3Name'),
|
|
757
|
-
category: 'assets',
|
|
758
|
-
sizeMb: androidResMb,
|
|
759
|
-
pct: Number(((androidResMb / androidInstallMb) * 100).toFixed(1)),
|
|
760
|
-
color: AppColors.pink500,
|
|
761
|
-
description: t('bundle.andComp3Desc'),
|
|
762
|
-
advice: t('bundle.andComp3Advice'),
|
|
763
|
-
},
|
|
764
|
-
{
|
|
765
|
-
id: 'and-c4',
|
|
766
|
-
name: t('bundle.andComp4Name'),
|
|
767
|
-
category: 'js',
|
|
768
|
-
sizeMb: releaseJsMb,
|
|
769
|
-
pct: Number(((releaseJsMb / androidInstallMb) * 100).toFixed(1)),
|
|
770
|
-
color: AppColors.emerald500,
|
|
771
|
-
description: t('bundle.andComp4Desc', { count: discoveredFiles.length }),
|
|
772
|
-
advice: t('bundle.andComp4Advice'),
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
id: 'and-c5',
|
|
776
|
-
name: t('bundle.andComp5Name'),
|
|
777
|
-
category: 'meta',
|
|
778
|
-
sizeMb: 3.8,
|
|
779
|
-
pct: Number(((3.8 / androidInstallMb) * 100).toFixed(1)),
|
|
780
|
-
color: AppColors.amber500,
|
|
781
|
-
description: t('bundle.andComp5Desc'),
|
|
782
|
-
advice: t('bundle.andComp5Advice'),
|
|
783
|
-
},
|
|
784
|
-
];
|
|
785
|
-
const androidApkComponents = [
|
|
786
|
-
{
|
|
787
|
-
id: 'apk-c1',
|
|
788
|
-
name: t('bundle.apkComp1Name'),
|
|
789
|
-
category: 'native',
|
|
790
|
-
sizeMb: androidMultiAbiCppMb,
|
|
791
|
-
pct: Number(((androidMultiAbiCppMb / androidApkInstallMb) * 100).toFixed(1)),
|
|
792
|
-
color: AppColors.sky500,
|
|
793
|
-
description: t('bundle.apkComp1Desc'),
|
|
794
|
-
advice: t('bundle.apkComp1Advice'),
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
id: 'apk-c2',
|
|
798
|
-
name: t('bundle.apkComp2Name'),
|
|
799
|
-
category: 'frameworks',
|
|
800
|
-
sizeMb: androidApkDexMb,
|
|
801
|
-
pct: Number(((androidApkDexMb / androidApkInstallMb) * 100).toFixed(1)),
|
|
802
|
-
color: AppColors.indigo500,
|
|
803
|
-
description: t('bundle.apkComp2Desc'),
|
|
804
|
-
advice: t('bundle.apkComp2Advice'),
|
|
805
|
-
},
|
|
806
|
-
{
|
|
807
|
-
id: 'apk-c3',
|
|
808
|
-
name: t('bundle.apkComp3Name'),
|
|
809
|
-
category: 'assets',
|
|
810
|
-
sizeMb: androidApkResMb,
|
|
811
|
-
pct: Number(((androidApkResMb / androidApkInstallMb) * 100).toFixed(1)),
|
|
812
|
-
color: AppColors.pink500,
|
|
813
|
-
description: t('bundle.apkComp3Desc'),
|
|
814
|
-
advice: t('bundle.apkComp3Advice'),
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
id: 'apk-c4',
|
|
818
|
-
name: t('bundle.apkComp4Name'),
|
|
819
|
-
category: 'js',
|
|
820
|
-
sizeMb: releaseJsMb,
|
|
821
|
-
pct: Number(((releaseJsMb / androidApkInstallMb) * 100).toFixed(1)),
|
|
822
|
-
color: AppColors.emerald500,
|
|
823
|
-
description: t('bundle.apkComp4Desc', { count: discoveredFiles.length }),
|
|
824
|
-
advice: t('bundle.apkComp4Advice'),
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
id: 'apk-c5',
|
|
828
|
-
name: t('bundle.apkComp5Name'),
|
|
829
|
-
category: 'meta',
|
|
830
|
-
sizeMb: androidApkMetaMb,
|
|
831
|
-
pct: Number(((androidApkMetaMb / androidApkInstallMb) * 100).toFixed(1)),
|
|
832
|
-
color: AppColors.amber500,
|
|
833
|
-
description: t('bundle.apkComp5Desc'),
|
|
834
|
-
advice: t('bundle.apkComp5Advice'),
|
|
835
|
-
},
|
|
836
|
-
];
|
|
837
|
-
return {
|
|
838
|
-
isLive,
|
|
839
|
-
scriptURL,
|
|
840
|
-
totalDevBytes: totalBytes,
|
|
841
|
-
totalDevMb,
|
|
842
|
-
totalDevKb,
|
|
843
|
-
isHermes,
|
|
844
|
-
moduleCount: modules.length || discoveredFiles.length + packagesList.length,
|
|
845
|
-
packageCount: packagesList.length,
|
|
846
|
-
filesCount: discoveredFiles.length,
|
|
847
|
-
splitUp: {
|
|
848
|
-
appSource: {
|
|
849
|
-
kb: appSourceKb,
|
|
850
|
-
mb: Number((appSourceKb / 1024).toFixed(2)),
|
|
851
|
-
pct: 15.0,
|
|
852
|
-
},
|
|
853
|
-
nodeModules: {
|
|
854
|
-
kb: nodeModulesKb,
|
|
855
|
-
mb: Number((nodeModulesKb / 1024).toFixed(2)),
|
|
856
|
-
pct: 52.0,
|
|
857
|
-
},
|
|
858
|
-
assetsMedia: {
|
|
859
|
-
kb: assetsMediaKb,
|
|
860
|
-
mb: Number((assetsMediaKb / 1024).toFixed(2)),
|
|
861
|
-
pct: 12.0,
|
|
862
|
-
},
|
|
863
|
-
metroDevOverhead: {
|
|
864
|
-
kb: metroOverheadKb,
|
|
865
|
-
mb: Number((metroOverheadKb / 1024).toFixed(2)),
|
|
866
|
-
pct: 21.0,
|
|
867
|
-
},
|
|
868
|
-
},
|
|
869
|
-
files: discoveredFiles,
|
|
870
|
-
packages: packagesList,
|
|
871
|
-
production: {
|
|
872
|
-
ios: {
|
|
873
|
-
totalInstallMb: iosInstallMb,
|
|
874
|
-
totalDownloadMb: iosDownloadMb,
|
|
875
|
-
compressionRatioPct: Number((((totalDevMb - releaseJsMb) / Math.max(totalDevMb, 1)) * 100).toFixed(1)),
|
|
876
|
-
components: iosComponents,
|
|
877
|
-
},
|
|
878
|
-
androidAab: {
|
|
879
|
-
totalInstallMb: androidInstallMb,
|
|
880
|
-
totalDownloadMb: androidDownloadMb,
|
|
881
|
-
compressionRatioPct: Number((((totalDevMb - releaseJsMb) / Math.max(totalDevMb, 1)) * 100).toFixed(1)),
|
|
882
|
-
components: androidComponents,
|
|
883
|
-
},
|
|
884
|
-
androidApk: {
|
|
885
|
-
totalInstallMb: androidApkInstallMb,
|
|
886
|
-
totalDownloadMb: androidApkDownloadMb,
|
|
887
|
-
compressionRatioPct: Number((((totalDevMb - releaseJsMb) / Math.max(totalDevMb, 1)) * 0.7).toFixed(1)),
|
|
888
|
-
components: androidApkComponents,
|
|
889
|
-
},
|
|
890
|
-
android: {
|
|
891
|
-
totalInstallMb: androidInstallMb,
|
|
892
|
-
totalDownloadMb: androidDownloadMb,
|
|
893
|
-
compressionRatioPct: Number((((totalDevMb - releaseJsMb) / Math.max(totalDevMb, 1)) * 100).toFixed(1)),
|
|
894
|
-
components: androidComponents,
|
|
895
|
-
},
|
|
896
|
-
},
|
|
897
|
-
};
|
|
898
|
-
};
|
|
899
|
-
export const getInitialBundleAnalysis = () => {
|
|
900
|
-
if (cachedAnalysis)
|
|
901
|
-
return cachedAnalysis;
|
|
902
|
-
const scriptURL = getHostScriptURL();
|
|
903
|
-
const fallbackBytes = 6840000;
|
|
904
|
-
const result = parseBundleSource('', fallbackBytes, scriptURL || 'unknown', false);
|
|
905
|
-
return result;
|
|
906
|
-
};
|
|
907
|
-
export const analyzeHostAppBundle = async (forceRefresh = false) => {
|
|
908
|
-
if (forceRefresh) {
|
|
909
|
-
cachedAnalysis = null;
|
|
910
|
-
}
|
|
911
|
-
if (cachedAnalysis && !forceRefresh)
|
|
912
|
-
return cachedAnalysis;
|
|
913
|
-
if (isAnalyzing) {
|
|
914
|
-
return new Promise(resolve => {
|
|
915
|
-
subscribers.push(resolve);
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
isAnalyzing = true;
|
|
919
|
-
const scriptURL = getHostScriptURL();
|
|
920
|
-
try {
|
|
921
|
-
const fetched = await probeCandidateUrlsInParallel(scriptURL, 2500);
|
|
922
|
-
if (fetched && fetched.text && fetched.text.length > 0) {
|
|
923
|
-
const result = parseBundleSource(fetched.text, fetched.bytes, fetched.url);
|
|
924
|
-
cachedAnalysis = result;
|
|
925
|
-
isAnalyzing = false;
|
|
926
|
-
subscribers.forEach(cb => cb(result));
|
|
927
|
-
subscribers.length = 0;
|
|
928
|
-
return result;
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
catch {
|
|
932
|
-
}
|
|
933
|
-
const fallbackBytes = 6840000;
|
|
934
|
-
const result = parseBundleSource('', fallbackBytes, scriptURL || 'unknown', false);
|
|
935
|
-
cachedAnalysis = result;
|
|
936
|
-
isAnalyzing = false;
|
|
937
|
-
subscribers.forEach(cb => cb(result));
|
|
938
|
-
subscribers.length = 0;
|
|
939
|
-
return result;
|
|
940
|
-
};
|
|
941
|
-
export const clearCachedBundleAnalysis = () => {
|
|
942
|
-
cachedAnalysis = null;
|
|
943
|
-
};
|
|
944
|
-
export const getCachedBundleAnalysis = () => cachedAnalysis;
|
|
1
|
+
import{AppColors as d}from"../styles/AppColors";import{t as r}from"../i18n";import{NativeModules as I,Platform as F,TurboModuleRegistry as ye}from"react-native";let A=null,z=!1;const T=[];let le=!1;export const setBundleModuleEnabled=e=>{le=e},getBundleModuleEnabled=()=>le;const Ne=()=>{try{const e=I?.SourceCode,n=e?.scriptURL||e?.getConstants?.()?.scriptURL;if(typeof n=="string"&&n.length>0)return{scriptURL:n}}catch{}try{const e=ye?.get?.("SourceCode"),n=e?.getConstants?.(),o=e?.scriptURL||n?.scriptURL;if(typeof o=="string"&&o.length>0)return{scriptURL:o}}catch{}return null};export const getHostScriptURL=()=>{try{const e=Ne()?.scriptURL;if(typeof e=="string"&&e.length>0)return e}catch{}try{const e=I?.PlatformConstants?.serverHost||I?.AndroidConstants?.serverHost||I?.DevSettings?.serverHost||I?.DevSettings?.getConstants?.()?.serverHost;if(typeof e=="string"&&e.length>0)return`${e.startsWith("http")?e:`http://${e}`}/index.bundle?platform=${F.OS}&dev=true`}catch{}try{const e=globalThis?.__DEV_SERVER_URL__||globalThis?.__METRO_SERVER_HOST__||globalThis?.__DEV_SERVER_PORT__||globalThis?.__METRO_PORT__;if(typeof e=="number")return`http://${F.OS==="android"?"10.0.2.2":"localhost"}:${e}/index.bundle?platform=${F.OS}&dev=true`;if(typeof e=="string"&&e.length>0)return/^\d+$/.test(e)?`http://${F.OS==="android"?"10.0.2.2":"localhost"}:${e}/index.bundle?platform=${F.OS}&dev=true`:e.startsWith("http")?e:`http://${e}/index.bundle?platform=${F.OS}&dev=true`}catch{}return""};const ue=[8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,19e3,19001,3e3],_e=e=>{if(!e||typeof e!="string")return{host:null,port:null};const n=e.match(/^https?:\/\/([^:/]+)(?::(\d+))?/);return n?{host:n[1]||null,port:n[2]?parseInt(n[2],10):null}:{host:null,port:null}},Fe=async(e,n=3e3)=>{const{host:o,port:l}=_e(e);if(e&&e.startsWith("http"))try{const b=new AbortController,k=setTimeout(()=>b.abort(),n),g=await fetch(e,{signal:b.signal});if(clearTimeout(k),g.ok){const f=g.headers.get("content-length"),x=await g.text();if(x&&x.length>0){const M=f&&parseInt(f,10)||x.length;return{text:x,bytes:M,url:e}}}}catch{}const a=o?[o,"localhost","127.0.0.1",...F.OS==="android"?["10.0.2.2","10.0.3.2"]:[]]:["localhost","127.0.0.1",...F.OS==="android"?["10.0.2.2","10.0.3.2"]:[]],m=Array.from(new Set(a)),h=l?Array.from(new Set([l,...ue])):ue,c=[];for(const b of m)for(const k of h)c.push(new Promise(async(g,f)=>{const x=new AbortController,M=setTimeout(()=>x.abort(),700);try{const j=await fetch(`http://${b}:${k}/status`,{signal:x.signal});if(clearTimeout(M),j.ok){const C=await j.text();if(C&&C.includes("packager-status:running")){g({host:b,port:k});return}}}catch{clearTimeout(M)}f(new Error("unreachable"))}));let u=null;try{u=await new Promise((b,k)=>{let g=c.length;if(g===0){k(new Error("No candidate hosts"));return}c.forEach(f=>{f.then(b).catch(()=>{g--,g===0&&k(new Error("All probes failed"))})})})}catch{u=null}if(u){const b=`http://${u.host}:${u.port}/index.bundle?platform=${F.OS}&dev=true`;try{const k=new AbortController,g=setTimeout(()=>k.abort(),n),f=await fetch(b,{signal:k.signal});if(clearTimeout(g),f.ok){const x=f.headers.get("content-length"),M=await f.text();if(M&&M.length>0){const j=x&&parseInt(x,10)||M.length;return{text:M,bytes:j,url:b}}}}catch{}}return null},pe=new Set,me=new Map;export const trackRuntimeModuleExecution=()=>{try{const e=globalThis,n=e.__r;if(typeof n=="function"&&!n.__inspectorTracked){const o=function(l,...a){return pe.add(Number(l)),n.call(this,l,...a)};Object.defineProperty(o,"__inspectorTracked",{value:!0,enumerable:!1}),e.__r=o}}catch{}},trackRuntimeDefine=()=>{try{const e=globalThis,n=e.__d;if(typeof n=="function"&&!n.__inspectorTracked){const o=function(l,a,m,h,...c){return typeof h=="string"&&h.length>0&&me.set(Number(a),{id:Number(a),path:h}),n.call(this,l,a,m,h,...c)};Object.defineProperty(o,"__inspectorTracked",{value:!0,enumerable:!1}),e.__d=o}}catch{}};trackRuntimeModuleExecution(),trackRuntimeDefine();const Ae=[{id:1,deps:[2,3,4],path:"index.js"},{id:2,deps:[4,5,13,14,15,16],path:"App.tsx"},{id:3,deps:[],path:"node_modules/react-native/index.js"},{id:4,deps:[],path:"node_modules/react/index.js"},{id:5,deps:[6,7],path:"node_modules/@react-navigation/native/src/index.ts"},{id:6,deps:[],path:"node_modules/react-native-screens/src/index.ts"},{id:7,deps:[],path:"node_modules/react-native-safe-area-context/src/index.ts"},{id:8,deps:[],path:"node_modules/react-native-svg/src/index.ts"},{id:9,deps:[],path:"node_modules/axios/index.js"},{id:10,deps:[],path:"node_modules/i18next/dist/esm/i18next.js"},{id:11,deps:[12],path:"node_modules/react-redux/src/index.ts"},{id:12,deps:[],path:"node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js"},{id:13,deps:[],path:"src/components/Inspector/BundleTab.tsx"},{id:14,deps:[],path:"src/navigation/RootNavigator.tsx"},{id:15,deps:[],path:"src/screens/HomeScreen.tsx"},{id:16,deps:[],path:"src/store/index.ts"},{id:17,deps:[],path:"assets/images/logo.png"},{id:18,deps:[],path:"package.json"}],We=e=>{const n=[],o=new Set;if(e&&e.length>0){const l=/\/\/[#@]\s*sourceURL=(?:https?:\/\/[^\s\r\n/]+\/|file:\/\/)?([^\s\r\n?#]+)/g;let a,m=9e5;for(;(a=l.exec(e))!==null;){const u=a[1];if(u&&u.length>0&&!u.endsWith(".bundle")){const b=m++;o.has(b)||(o.add(b),n.push({id:b,deps:[],path:u}))}}const h=/,\s*(\d+)\s*,\s*(?:\[[^\]\r\n]{0,500}\]|\{[^}\r\n]{0,500}\})\s*,\s*["']([^"'\r\n]+)["']\s*\)/g;let c;for(;(c=h.exec(e))!==null;){const u=parseInt(c[1],10),b=c[2]||"";!o.has(u)&&b.length>0&&(o.add(u),n.push({id:u,deps:[],path:b}))}}return me.forEach((l,a)=>{o.has(a)||(o.add(a),n.push({id:a,deps:[],path:l.path}))}),n.length===0?Ae:n},De=e=>{const n=new Set;if(!e)return n;const o=/__r\s*\(\s*(\d+)\s*\)/g;let l;for(;(l=o.exec(e))!==null;)n.add(parseInt(l[1],10));return n},Se=e=>{const n=e.map(c=>c.replace(/\\/g,"/"));for(const c of n){const u=c.indexOf("/node_modules/");if(u!==-1)return c.slice(0,u+1)}for(const c of n){const u=c.match(/^(.*\/)(?:index\.[jt]sx?|app\.[jt]sx?|package\.json)(?:[?#].*)?$/i);if(u&&u[1])return u[1]}const o=n.filter(c=>c.startsWith("/")&&!c.includes("/node_modules/"));if(o.length===0)return"";if(o.length===1){const c=o[0].lastIndexOf("/");return c>0?o[0].slice(0,c+1):""}const l=o.map(c=>c.split("/"));let a=0;const m=l[0],h=Math.min(...l.map(c=>c.length));for(;a<h-1;){const c=m[a];if(l.every(u=>u[a]===c))a++;else break}return a>0?m.slice(0,a).join("/")+"/":""},we=(e,n)=>{let o=e.replace(/\\/g,"/");const l=o.search(/[?#]/);return l!==-1&&(o=o.slice(0,l)),o=o.replace(/^(?:https?:\/\/[^/]+\/|file:\/\/)/,""),n&&o.startsWith(n)&&(o=o.slice(n.length)),o=o.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"").replace(/^\/+/,""),o||(o=e.split("/").pop()||e),o},je=e=>{if(e.includes("node_modules/")){const n=e.match(/node_modules\/(?:@([^/]+)\/([^/]+)|([^/]+))/);return n?{isPkg:!0,pkgName:n[1]&&n[2]?`@${n[1]}/${n[2]}`:n[3]}:{isPkg:!0}}return e.includes("react-native-inapp-inspector")?{isPkg:!0,pkgName:"react-native-inapp-inspector"}:e.includes(".yarn/")||e.includes(".pnpm/")?{isPkg:!0}:e.includes("/dist/esm/")||e.includes("/dist/commonjs/")||e.includes("/dist/cjs/")||e.startsWith("dist/esm/")||e.startsWith("dist/commonjs/")||e.startsWith("dist/")||e.includes("/react-native-inapp-inspector/dist/")?{isPkg:!0,pkgName:"react-native-inapp-inspector"}:{isPkg:!1}},Pe=e=>e.startsWith("<<")||e.startsWith("[metro]")||e.includes("metro-runtime")||e.includes("polyfills/require.js")||e.includes("prelude_commonjs")||e.includes("Libraries/Core/InitializeCore.js")||e.includes("@babel/runtime");export const parseBundleSource=(e,n,o,l=!0)=>{const a=!!globalThis.HermesInternal,m=Number((n/(1024*1024)).toFixed(2)),h=Math.round(n/1024),c=We(e),u=De(e),b=new Map;for(const t of c)b.set(t.id,t);const k=new Set,g=[],f=t=>{k.has(t)||(k.add(t),g.push(t))};f(0),u.forEach(t=>f(t)),pe.forEach(t=>f(t));for(const t of c){const s=t.path.toLowerCase().replace(/\\/g,"/");(s.endsWith("/index.js")||s.endsWith("/index.ts")||s.endsWith("/index.tsx")||s==="index.js"||s.endsWith("/app.tsx")||s.endsWith("/app.js")||s.endsWith("/app.jsx")||s==="app.tsx"||s==="app.js"||s.endsWith("app.json"))&&f(t.id)}for(;g.length>0;){const t=g.shift(),s=b.get(t);if(s&&s.deps)for(const i of s.deps)f(i)}const x=new Map,M=[];for(const t of c){const s=t.path.replace(/\\/g,"/"),{isPkg:i,pkgName:N}=je(s);if(i){N&&!N.startsWith(".")&&x.set(N,(x.get(N)||0)+1);continue}Pe(s)||M.push({mod:t,rawPath:s})}const j=Se(c.map(t=>t.path)),C=[];let he=0;for(const{mod:t,rawPath:s}of M){const i=we(s,j);if(!(i.endsWith(".tsx")||i.endsWith(".ts")||i.endsWith(".jsx")||i.endsWith(".js")||i.endsWith(".mjs")||i.endsWith(".cjs")||i.endsWith(".json")||i.endsWith(".png")||i.endsWith(".jpg")||i.endsWith(".jpeg")||i.endsWith(".gif")||i.endsWith(".webp")||i.endsWith(".svg")||i.endsWith(".bmp")||i.endsWith(".ico")||i.endsWith(".ttf")||i.endsWith(".otf")||i.endsWith(".woff")||i.endsWith(".woff2")||i.endsWith(".css")||i.endsWith(".scss")||i.endsWith(".html")||i.endsWith(".md")||i.endsWith(".graphql")||i.endsWith(".gql")))continue;const p=i.split(".").pop()?.toUpperCase()||"JS",$=i.split("/").pop()||i;let _="javascript",D=d.indigo500;p==="TSX"||p==="TS"?(_="typescript",D=d.sky500):p==="PNG"||p==="JPG"||p==="JPEG"||p==="GIF"||p==="WEBP"||p==="SVG"||p==="BMP"||p==="ICO"?(_="image",D=d.pink500):p==="TTF"||p==="OTF"||p==="WOFF"||p==="WOFF2"?(_="font",D=d.purple500):(p==="JSON"||p==="CSS"||p==="SCSS"||p==="HTML"||p==="MD"||p==="GRAPHQL"||p==="GQL")&&(_="json",D=d.emerald500);const oe=Math.max(2,Math.round(h*.15/Math.max(c.length,20))),ie=!(i.includes(".test.")||i.includes(".spec.")||i.includes("__tests__")||i.includes("__mocks__")||i.includes(".stories.")||i.includes("fixtures/"));C.push({id:`host-file-${he++}`,name:$,path:i,ext:p,category:_,sizeKb:oe,meta:`Active Host App Module \u2022 ${_.toUpperCase()}`,color:D,status:ie?"optimal":"warning",advice:ie?"In-Use: Bundled and active in host application dependency tree":"Not consumed: Test fixture or orphaned file packaged in bundle",isConsumed:ie})}const be=t=>{const s=[d.indigo500,d.sky500,d.pink500,d.purple500,d.emerald500,d.amber500,d.red500,d.teal500,"#3B82F6",d.fuchsia500,d.orange500,d.lime500,"#06B6D4","#A855F7",d.errorColor];let i=0;for(let N=0;N<t.length;N++)i=t.charCodeAt(N)+((i<<5)-i);return s[Math.abs(i)%s.length]},fe=t=>{const s=t.toLowerCase();return s.includes("navigation")||s.includes("router")||s.includes("screen")?"navigation":s.includes("ui")||s.includes("reanimated")||s.includes("gesture")||s.includes("svg")||s.includes("lottie")||s.includes("vector")||s.includes("icon")||s.includes("image")||s.includes("gradient")?"ui":s.includes("axios")||s.includes("fetch")||s.includes("query")||s.includes("apollo")||s.includes("network")||s.includes("socket")||s.includes("http")?"network":s==="react"||s==="react-native"||s.includes("metro")||s.includes("babel")||s.includes("core")?"core":"utils"},ge=t=>t.startsWith("@react-navigation/")?t==="@react-navigation/native"?null:"@react-navigation/native":t.startsWith("@react-native/")||t==="react-refresh"||t==="metro-runtime"||t==="whatwg-fetch"||t==="promise"||t==="event-target-shim"?"react-native":t==="scheduler"||t==="loose-envify"||t==="object-assign"?"react":t==="use-sync-external-store"||t==="reselect"||t==="redux-thunk"||t==="immer"?"react-redux":t==="follow-redirects"||t==="form-data"||t==="proxy-from-env"?"axios":t==="clone-deep"||t==="html-parse-stringify"||t==="@babel/runtime"?"i18next":t==="css-select"||t==="css-tree"||t==="entities"?"react-native-svg":null,re=Array.from(x.entries()),xe=re.reduce((t,[,s])=>t+s,0)||1,y=[];re.forEach(([t,s],i)=>{const N=fe(t),p=be(t),$=ge(t)||void 0,_=!$,D=Math.max(8,Math.round(h*.52*s/Math.max(xe,1))),oe=Number((D/Math.max(h,1)*100).toFixed(1));y.push({id:`host-pkg-${i}`,name:t,version:"",latestVersion:"",sizeKb:D,percentage:oe,type:_?"direct":"transitive",isDirectDefined:_,parentPackageName:$,subpackages:[],category:N,color:p,description:`${s} bundled ${s===1?"module":"modules"}`,npmUrl:`https://www.npmjs.com/package/${t}`,isDeprecated:!1,lastActive:`${s} modules`})});const L=new Map;y.forEach(t=>{t.isDirectDefined&&L.set(t.name,t)}),y.forEach(t=>{if(t.parentPackageName&&L.has(t.parentPackageName)){const s=L.get(t.parentPackageName);s.subpackages||(s.subpackages=[]),s.subpackages.push(t)}}),y.sort((t,s)=>s.sizeKb-t.sizeKb);let H=0;for(const t of y)H+=t.sizeKb||0;let B=0,K=0;for(const t of C)t.category==="image"||t.category==="font"?K+=t.sizeKb||0:B+=t.sizeKb||0;const U=B>0?B:Math.round(h*.18),R=H>0?H:Math.round(h*.58),O=K>0?K:Math.round(h*.08),ce=Math.max(0,h-U-R-O),v=Number((h*.38/1024).toFixed(2)),P=Number((R/1024).toFixed(2)),V=Number((O/1024).toFixed(2)),E=Math.min(y.length,55),q=Number((48+E*.35+P*.9).toFixed(1)),G=Number((38+E*.22+P*.6).toFixed(1)),J=Number((30+V*2.2).toFixed(1)),Q=6.4,S=Number((v+q+G+J+Q).toFixed(1)),ke=Number((S*.655).toFixed(1)),X=Number((20+E*.12+P*.4).toFixed(1)),Y=Number((14+E*.08+P*.25).toFixed(1)),Z=Number((16+V*1.5).toFixed(1)),W=Number((v+X+Y+Z+3.8).toFixed(1)),ae=Number((W*.54).toFixed(1)),ee=Number((195+E*.55+P*1.6).toFixed(1)),te=Number((54+E*.2+P*.6).toFixed(1)),se=Number((58+V*2.8).toFixed(1)),ne=8.5,w=Number((v+ee+te+se+ne).toFixed(1)),Me=Number(w.toFixed(1)),ve=[{id:"ios-c1",name:r("bundle.iosComp1Name"),category:"frameworks",sizeMb:q,pct:Number((q/S*100).toFixed(1)),color:d.indigo500,description:r("bundle.iosComp1Desc",{count:y.length}),advice:r("bundle.iosComp1Advice")},{id:"ios-c2",name:r("bundle.iosComp2Name"),category:"native",sizeMb:G,pct:Number((G/S*100).toFixed(1)),color:d.sky500,description:r("bundle.iosComp2Desc"),advice:r("bundle.iosComp2Advice")},{id:"ios-c3",name:r("bundle.iosComp3Name"),category:"assets",sizeMb:J,pct:Number((J/S*100).toFixed(1)),color:d.pink500,description:r("bundle.iosComp3Desc"),advice:r("bundle.iosComp3Advice")},{id:"ios-c4",name:r("bundle.iosComp4Name"),category:"js",sizeMb:v,pct:Number((v/S*100).toFixed(1)),color:d.emerald500,description:r("bundle.iosComp4Desc",{count:C.length}),advice:r("bundle.iosComp4Advice")},{id:"ios-c5",name:r("bundle.iosComp5Name"),category:"meta",sizeMb:Q,pct:Number((Q/S*100).toFixed(1)),color:d.amber500,description:r("bundle.iosComp5Desc"),advice:r("bundle.iosComp5Advice")}],de=[{id:"and-c1",name:r("bundle.andComp1Name"),category:"native",sizeMb:X,pct:Number((X/W*100).toFixed(1)),color:d.sky500,description:r("bundle.andComp1Desc",{count:y.length}),advice:r("bundle.andComp1Advice")},{id:"and-c2",name:r("bundle.andComp2Name"),category:"frameworks",sizeMb:Y,pct:Number((Y/W*100).toFixed(1)),color:d.indigo500,description:r("bundle.andComp2Desc"),advice:r("bundle.andComp2Advice")},{id:"and-c3",name:r("bundle.andComp3Name"),category:"assets",sizeMb:Z,pct:Number((Z/W*100).toFixed(1)),color:d.pink500,description:r("bundle.andComp3Desc"),advice:r("bundle.andComp3Advice")},{id:"and-c4",name:r("bundle.andComp4Name"),category:"js",sizeMb:v,pct:Number((v/W*100).toFixed(1)),color:d.emerald500,description:r("bundle.andComp4Desc",{count:C.length}),advice:r("bundle.andComp4Advice")},{id:"and-c5",name:r("bundle.andComp5Name"),category:"meta",sizeMb:3.8,pct:Number((3.8/W*100).toFixed(1)),color:d.amber500,description:r("bundle.andComp5Desc"),advice:r("bundle.andComp5Advice")}],Ce=[{id:"apk-c1",name:r("bundle.apkComp1Name"),category:"native",sizeMb:ee,pct:Number((ee/w*100).toFixed(1)),color:d.sky500,description:r("bundle.apkComp1Desc"),advice:r("bundle.apkComp1Advice")},{id:"apk-c2",name:r("bundle.apkComp2Name"),category:"frameworks",sizeMb:te,pct:Number((te/w*100).toFixed(1)),color:d.indigo500,description:r("bundle.apkComp2Desc"),advice:r("bundle.apkComp2Advice")},{id:"apk-c3",name:r("bundle.apkComp3Name"),category:"assets",sizeMb:se,pct:Number((se/w*100).toFixed(1)),color:d.pink500,description:r("bundle.apkComp3Desc"),advice:r("bundle.apkComp3Advice")},{id:"apk-c4",name:r("bundle.apkComp4Name"),category:"js",sizeMb:v,pct:Number((v/w*100).toFixed(1)),color:d.emerald500,description:r("bundle.apkComp4Desc",{count:C.length}),advice:r("bundle.apkComp4Advice")},{id:"apk-c5",name:r("bundle.apkComp5Name"),category:"meta",sizeMb:ne,pct:Number((ne/w*100).toFixed(1)),color:d.amber500,description:r("bundle.apkComp5Desc"),advice:r("bundle.apkComp5Advice")}];return{isLive:l,scriptURL:o,totalDevBytes:n,totalDevMb:m,totalDevKb:h,isHermes:a,moduleCount:c.length||C.length+y.length,packageCount:y.length,filesCount:C.length,splitUp:{appSource:{kb:U,mb:Number((U/1024).toFixed(2)),pct:15},nodeModules:{kb:R,mb:Number((R/1024).toFixed(2)),pct:52},assetsMedia:{kb:O,mb:Number((O/1024).toFixed(2)),pct:12},metroDevOverhead:{kb:ce,mb:Number((ce/1024).toFixed(2)),pct:21}},files:C,packages:y,production:{ios:{totalInstallMb:S,totalDownloadMb:ke,compressionRatioPct:Number(((m-v)/Math.max(m,1)*100).toFixed(1)),components:ve},androidAab:{totalInstallMb:W,totalDownloadMb:ae,compressionRatioPct:Number(((m-v)/Math.max(m,1)*100).toFixed(1)),components:de},androidApk:{totalInstallMb:w,totalDownloadMb:Me,compressionRatioPct:Number(((m-v)/Math.max(m,1)*.7).toFixed(1)),components:Ce},android:{totalInstallMb:W,totalDownloadMb:ae,compressionRatioPct:Number(((m-v)/Math.max(m,1)*100).toFixed(1)),components:de}}}},getInitialBundleAnalysis=()=>{if(A)return A;const e=getHostScriptURL();return parseBundleSource("",684e4,e||"unknown",!1)},analyzeHostAppBundle=async(e=!1)=>{if(e&&(A=null),A&&!e)return A;if(z)return new Promise(a=>{T.push(a)});z=!0;const n=getHostScriptURL();try{const a=await Fe(n,2500);if(a&&a.text&&a.text.length>0){const m=parseBundleSource(a.text,a.bytes,a.url);return A=m,z=!1,T.forEach(h=>h(m)),T.length=0,m}}catch{}const l=parseBundleSource("",684e4,n||"unknown",!1);return A=l,z=!1,T.forEach(a=>a(l)),T.length=0,l},clearCachedBundleAnalysis=()=>{A=null},getCachedBundleAnalysis=()=>A;
|