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