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,607 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < lines.length; i++) {
|
|
24
|
-
const line = lines[i].trim();
|
|
25
|
-
if (!line)
|
|
26
|
-
continue;
|
|
27
|
-
if (line.startsWith('</')) {
|
|
28
|
-
indent = Math.max(0, indent - 1);
|
|
29
|
-
}
|
|
30
|
-
formatted.push(' '.repeat(indent) + line);
|
|
31
|
-
if (line.startsWith('<') &&
|
|
32
|
-
!line.startsWith('</') &&
|
|
33
|
-
!line.startsWith('<!') &&
|
|
34
|
-
!line.endsWith('/>')) {
|
|
35
|
-
const tagNameMatch = line.match(/^<([a-zA-Z0-9:-]+)/);
|
|
36
|
-
if (tagNameMatch) {
|
|
37
|
-
const tagName = tagNameMatch[1];
|
|
38
|
-
if (!selfClosingTags.test(tagName)) {
|
|
39
|
-
const closeTagRegex = new RegExp(`</${escapeRegExp(tagName)}>`);
|
|
40
|
-
if (!closeTagRegex.test(line)) {
|
|
41
|
-
indent++;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return formatted.join('\n');
|
|
48
|
-
};
|
|
49
|
-
const formatCSS = (css) => {
|
|
50
|
-
if (!css)
|
|
51
|
-
return '';
|
|
52
|
-
const cleaned = css
|
|
53
|
-
.replace(/\s*\{\s*/g, ' {\n')
|
|
54
|
-
.replace(/\s*;\s*/g, ';\n')
|
|
55
|
-
.replace(/\s*\}\s*/g, '\n}\n')
|
|
56
|
-
.replace(/\n+/g, '\n');
|
|
57
|
-
const lines = cleaned.split('\n');
|
|
58
|
-
let indent = 0;
|
|
59
|
-
const formatted = [];
|
|
60
|
-
for (let i = 0; i < lines.length; i++) {
|
|
61
|
-
const line = lines[i].trim();
|
|
62
|
-
if (!line)
|
|
63
|
-
continue;
|
|
64
|
-
if (line.startsWith('}')) {
|
|
65
|
-
indent = Math.max(0, indent - 1);
|
|
66
|
-
}
|
|
67
|
-
formatted.push(' '.repeat(indent) + line);
|
|
68
|
-
if (line.endsWith('{')) {
|
|
69
|
-
indent++;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return formatted.join('\n');
|
|
73
|
-
};
|
|
74
|
-
const formatJS = (js) => {
|
|
75
|
-
if (!js)
|
|
76
|
-
return '';
|
|
77
|
-
const lines = js.split(/\r?\n/);
|
|
78
|
-
let indent = 0;
|
|
79
|
-
const formatted = [];
|
|
80
|
-
for (let i = 0; i < lines.length; i++) {
|
|
81
|
-
const line = lines[i].trim();
|
|
82
|
-
if (!line)
|
|
83
|
-
continue;
|
|
84
|
-
let openCount = (line.match(/\{|\[/g) || []).length;
|
|
85
|
-
let closeCount = (line.match(/\}|\]/g) || []).length;
|
|
86
|
-
if (line.startsWith('}') || line.startsWith(']')) {
|
|
87
|
-
indent = Math.max(0, indent - 1);
|
|
88
|
-
}
|
|
89
|
-
else if (closeCount > openCount) {
|
|
90
|
-
indent = Math.max(0, indent - (closeCount - openCount));
|
|
91
|
-
}
|
|
92
|
-
formatted.push(' '.repeat(indent) + line);
|
|
93
|
-
if (openCount > closeCount &&
|
|
94
|
-
!line.startsWith('}') &&
|
|
95
|
-
!line.startsWith(']')) {
|
|
96
|
-
indent += openCount - closeCount;
|
|
97
|
-
}
|
|
98
|
-
else if (line.endsWith('{') || line.endsWith('[')) {
|
|
99
|
-
indent++;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return formatted.join('\n');
|
|
103
|
-
};
|
|
104
|
-
const tokenizeJS = (text) => {
|
|
105
|
-
const tokens = [];
|
|
106
|
-
const regex = /(\/\/.*|\/\*[\s\S]*?\*\/)|(\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\'|\`(?:\\.|[^\`\\])*\`)|(\b(const|let|var|function|return|if|else|for|while|import|export|class|try|catch|new|this|async|await|break|continue|switch|case|default|throw|typeof|yield)\b)|(\b(console|window|document|fetch|global|require|module|exports|Promise|Map|Set|Array|Object|String|Number|Boolean)\b)|(\b\d+(?:\.\d+)?\b)/g;
|
|
107
|
-
let lastIndex = 0;
|
|
108
|
-
let match;
|
|
109
|
-
while ((match = regex.exec(text)) !== null) {
|
|
110
|
-
if (regex.lastIndex === match.index) {
|
|
111
|
-
regex.lastIndex++;
|
|
112
|
-
}
|
|
113
|
-
if (match.index > lastIndex) {
|
|
114
|
-
tokens.push({
|
|
115
|
-
text: text.substring(lastIndex, match.index),
|
|
116
|
-
type: 'plain',
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
const matchedText = match[0];
|
|
120
|
-
if (match[1])
|
|
121
|
-
tokens.push({ text: matchedText, type: 'comment' });
|
|
122
|
-
else if (match[2])
|
|
123
|
-
tokens.push({ text: matchedText, type: 'string' });
|
|
124
|
-
else if (match[3])
|
|
125
|
-
tokens.push({ text: matchedText, type: 'keyword' });
|
|
126
|
-
else if (match[4])
|
|
127
|
-
tokens.push({ text: matchedText, type: 'builtin' });
|
|
128
|
-
else if (match[5])
|
|
129
|
-
tokens.push({ text: matchedText, type: 'number' });
|
|
130
|
-
lastIndex = regex.lastIndex;
|
|
131
|
-
}
|
|
132
|
-
if (lastIndex < text.length) {
|
|
133
|
-
tokens.push({ text: text.substring(lastIndex), type: 'plain' });
|
|
134
|
-
}
|
|
135
|
-
return tokens;
|
|
136
|
-
};
|
|
137
|
-
const tokenizeCSS = (text) => {
|
|
138
|
-
const tokens = [];
|
|
139
|
-
const regex = /(\/\*[\s\S]*?\*\/)|(\.[a-zA-Z0-9_-]+|#[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?=\s*\{))|([a-zA-Z0-9_-]+(?=\s*:))|(:[^;]+;)/g;
|
|
140
|
-
let lastIndex = 0;
|
|
141
|
-
let match;
|
|
142
|
-
while ((match = regex.exec(text)) !== null) {
|
|
143
|
-
if (regex.lastIndex === match.index) {
|
|
144
|
-
regex.lastIndex++;
|
|
145
|
-
}
|
|
146
|
-
if (match.index > lastIndex) {
|
|
147
|
-
tokens.push({
|
|
148
|
-
text: text.substring(lastIndex, match.index),
|
|
149
|
-
type: 'plain',
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
const matchedText = match[0];
|
|
153
|
-
if (match[1])
|
|
154
|
-
tokens.push({ text: matchedText, type: 'comment' });
|
|
155
|
-
else if (match[2])
|
|
156
|
-
tokens.push({ text: matchedText, type: 'selector' });
|
|
157
|
-
else if (match[3])
|
|
158
|
-
tokens.push({ text: matchedText, type: 'property' });
|
|
159
|
-
else if (match[4]) {
|
|
160
|
-
tokens.push({ text: ':', type: 'plain' });
|
|
161
|
-
tokens.push({ text: matchedText.substring(1), type: 'value' });
|
|
162
|
-
}
|
|
163
|
-
lastIndex = regex.lastIndex;
|
|
164
|
-
}
|
|
165
|
-
if (lastIndex < text.length) {
|
|
166
|
-
tokens.push({ text: text.substring(lastIndex), type: 'plain' });
|
|
167
|
-
}
|
|
168
|
-
return tokens;
|
|
169
|
-
};
|
|
170
|
-
const tokenizeHTML = (text) => {
|
|
171
|
-
const tokens = [];
|
|
172
|
-
const regex = /(<!--[\s\S]*?-->)|(<\/?[a-zA-Z0-9:-]+>?)|(\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\')|([a-zA-Z0-9:-]+(?=\s*=))/g;
|
|
173
|
-
let lastIndex = 0;
|
|
174
|
-
let match;
|
|
175
|
-
while ((match = regex.exec(text)) !== null) {
|
|
176
|
-
if (regex.lastIndex === match.index) {
|
|
177
|
-
regex.lastIndex++;
|
|
178
|
-
}
|
|
179
|
-
if (match.index > lastIndex) {
|
|
180
|
-
tokens.push({
|
|
181
|
-
text: text.substring(lastIndex, match.index),
|
|
182
|
-
type: 'plain',
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const matchedText = match[0];
|
|
186
|
-
if (match[1])
|
|
187
|
-
tokens.push({ text: matchedText, type: 'comment' });
|
|
188
|
-
else if (match[2])
|
|
189
|
-
tokens.push({ text: matchedText, type: 'tag' });
|
|
190
|
-
else if (match[3])
|
|
191
|
-
tokens.push({ text: matchedText, type: 'string' });
|
|
192
|
-
else if (match[4])
|
|
193
|
-
tokens.push({ text: matchedText, type: 'attribute' });
|
|
194
|
-
lastIndex = regex.lastIndex;
|
|
195
|
-
}
|
|
196
|
-
if (lastIndex < text.length) {
|
|
197
|
-
tokens.push({ text: text.substring(lastIndex), type: 'plain' });
|
|
198
|
-
}
|
|
199
|
-
return tokens;
|
|
200
|
-
};
|
|
201
|
-
const getStyleForType = (type) => {
|
|
202
|
-
switch (type) {
|
|
203
|
-
case 'comment':
|
|
204
|
-
return styles.comment;
|
|
205
|
-
case 'string':
|
|
206
|
-
return styles.string;
|
|
207
|
-
case 'keyword':
|
|
208
|
-
return styles.keyword;
|
|
209
|
-
case 'builtin':
|
|
210
|
-
return styles.builtin;
|
|
211
|
-
case 'number':
|
|
212
|
-
return styles.number;
|
|
213
|
-
case 'tag':
|
|
214
|
-
return styles.tag;
|
|
215
|
-
case 'attribute':
|
|
216
|
-
return styles.attribute;
|
|
217
|
-
case 'selector':
|
|
218
|
-
return styles.selector;
|
|
219
|
-
case 'property':
|
|
220
|
-
return styles.property;
|
|
221
|
-
case 'value':
|
|
222
|
-
return styles.value;
|
|
223
|
-
default:
|
|
224
|
-
return [styles.plain, { color: AppColors.primaryBlack }];
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
const ArrowUpIcon = ({ color = AppColors.slate500, size = 16 }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
228
|
-
<Path d="M18 15l-6-6-6 6" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
|
|
229
|
-
</Svg>);
|
|
230
|
-
const ArrowDownIcon = ({ color = AppColors.slate500, size = 16 }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
231
|
-
<Path d="M6 9l6 6 6-6" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
|
|
232
|
-
</Svg>);
|
|
233
|
-
const CodeSnippetLine = React.memo(({ line, lineIndex, language, search, isActiveMatch, }) => {
|
|
234
|
-
const tokens = useMemo(() => {
|
|
235
|
-
if (language === 'html')
|
|
236
|
-
return tokenizeHTML(line);
|
|
237
|
-
if (language === 'css')
|
|
238
|
-
return tokenizeCSS(line);
|
|
239
|
-
return tokenizeJS(line);
|
|
240
|
-
}, [line, language]);
|
|
241
|
-
const renderTokenText = (text, type) => {
|
|
242
|
-
const baseStyle = getStyleForType(type);
|
|
243
|
-
if (!search) {
|
|
244
|
-
return <Text style={baseStyle}>{text}</Text>;
|
|
245
|
-
}
|
|
246
|
-
const parts = text.split(new RegExp(`(${escapeRegExp(search)})`, 'gi'));
|
|
247
|
-
return (<Text style={baseStyle}>
|
|
248
|
-
{parts.map((part, index) => {
|
|
249
|
-
const isMatch = part.toLowerCase() === search.toLowerCase();
|
|
250
|
-
return isMatch ? (<Text key={index} style={styles.highlight}>
|
|
251
|
-
{part}
|
|
252
|
-
</Text>) : (part);
|
|
253
|
-
})}
|
|
254
|
-
</Text>);
|
|
255
|
-
};
|
|
256
|
-
return (<View style={[styles.lineRow, isActiveMatch && styles.activeMatchRow]}>
|
|
1
|
+
import B,{useMemo as I,useState as R,useRef as D,useEffect as L}from"react";import{StyleSheet as _,Text as T,View as S,Platform as G,FlatList as Q,TextInput as O,Pressable as U}from"react-native";import F,{Path as A}from"react-native-svg";import{SearchIcon as J,ClearIcon as Y}from"./NetworkIcons";import K from"./CopyButton";import $ from"./TouchableScale";import{AppColors as e}from"../styles/AppColors";import{AppFonts as M}from"../styles/AppFonts";const V=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=n=>{if(!n)return"";let t=0;const i=n.replace(/<([a-zA-Z0-9:-]+)([^>]*)>\s*<\/([a-zA-Z0-9:-]+)>/g,"<$1$2></$3>").replace(/(<[^>]+>)/g,`
|
|
2
|
+
$1
|
|
3
|
+
`).replace(/\n+/g,`
|
|
4
|
+
`).split(`
|
|
5
|
+
`),r=[],o=/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i;for(let d=0;d<i.length;d++){const s=i[d].trim();if(s&&(s.startsWith("</")&&(t=Math.max(0,t-1)),r.push(" ".repeat(t)+s),s.startsWith("<")&&!s.startsWith("</")&&!s.startsWith("<!")&&!s.endsWith("/>"))){const p=s.match(/^<([a-zA-Z0-9:-]+)/);if(p){const g=p[1];o.test(g)||new RegExp(`</${V(g)}>`).test(s)||t++}}}return r.join(`
|
|
6
|
+
`)},ee=n=>{if(!n)return"";const l=n.replace(/\s*\{\s*/g,` {
|
|
7
|
+
`).replace(/\s*;\s*/g,`;
|
|
8
|
+
`).replace(/\s*\}\s*/g,`
|
|
9
|
+
}
|
|
10
|
+
`).replace(/\n+/g,`
|
|
11
|
+
`).split(`
|
|
12
|
+
`);let i=0;const r=[];for(let o=0;o<l.length;o++){const d=l[o].trim();d&&(d.startsWith("}")&&(i=Math.max(0,i-1)),r.push(" ".repeat(i)+d),d.endsWith("{")&&i++)}return r.join(`
|
|
13
|
+
`)},te=n=>{if(!n)return"";const t=n.split(/\r?\n/);let l=0;const i=[];for(let r=0;r<t.length;r++){const o=t[r].trim();if(!o)continue;let d=(o.match(/\{|\[/g)||[]).length,s=(o.match(/\}|\]/g)||[]).length;o.startsWith("}")||o.startsWith("]")?l=Math.max(0,l-1):s>d&&(l=Math.max(0,l-(s-d))),i.push(" ".repeat(l)+o),d>s&&!o.startsWith("}")&&!o.startsWith("]")?l+=d-s:(o.endsWith("{")||o.endsWith("["))&&l++}return i.join(`
|
|
14
|
+
`)},re=n=>{const t=[],l=/(\/\/.*|\/\*[\s\S]*?\*\/)|(\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\'|\`(?:\\.|[^\`\\])*\`)|(\b(const|let|var|function|return|if|else|for|while|import|export|class|try|catch|new|this|async|await|break|continue|switch|case|default|throw|typeof|yield)\b)|(\b(console|window|document|fetch|global|require|module|exports|Promise|Map|Set|Array|Object|String|Number|Boolean)\b)|(\b\d+(?:\.\d+)?\b)/g;let i=0,r;for(;(r=l.exec(n))!==null;){l.lastIndex===r.index&&l.lastIndex++,r.index>i&&t.push({text:n.substring(i,r.index),type:"plain"});const o=r[0];r[1]?t.push({text:o,type:"comment"}):r[2]?t.push({text:o,type:"string"}):r[3]?t.push({text:o,type:"keyword"}):r[4]?t.push({text:o,type:"builtin"}):r[5]&&t.push({text:o,type:"number"}),i=l.lastIndex}return i<n.length&&t.push({text:n.substring(i),type:"plain"}),t},ne=n=>{const t=[],l=/(\/\*[\s\S]*?\*\/)|(\.[a-zA-Z0-9_-]+|#[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?=\s*\{))|([a-zA-Z0-9_-]+(?=\s*:))|(:[^;]+;)/g;let i=0,r;for(;(r=l.exec(n))!==null;){l.lastIndex===r.index&&l.lastIndex++,r.index>i&&t.push({text:n.substring(i,r.index),type:"plain"});const o=r[0];r[1]?t.push({text:o,type:"comment"}):r[2]?t.push({text:o,type:"selector"}):r[3]?t.push({text:o,type:"property"}):r[4]&&(t.push({text:":",type:"plain"}),t.push({text:o.substring(1),type:"value"})),i=l.lastIndex}return i<n.length&&t.push({text:n.substring(i),type:"plain"}),t},oe=n=>{const t=[],l=/(<!--[\s\S]*?-->)|(<\/?[a-zA-Z0-9:-]+>?)|(\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\')|([a-zA-Z0-9:-]+(?=\s*=))/g;let i=0,r;for(;(r=l.exec(n))!==null;){l.lastIndex===r.index&&l.lastIndex++,r.index>i&&t.push({text:n.substring(i,r.index),type:"plain"});const o=r[0];r[1]?t.push({text:o,type:"comment"}):r[2]?t.push({text:o,type:"tag"}):r[3]?t.push({text:o,type:"string"}):r[4]&&t.push({text:o,type:"attribute"}),i=l.lastIndex}return i<n.length&&t.push({text:n.substring(i),type:"plain"}),t},ie=n=>{switch(n){case"comment":return a.comment;case"string":return a.string;case"keyword":return a.keyword;case"builtin":return a.builtin;case"number":return a.number;case"tag":return a.tag;case"attribute":return a.attribute;case"selector":return a.selector;case"property":return a.property;case"value":return a.value;default:return[a.plain,{color:e.primaryBlack}]}},Se=({color:n=e.slate500,size:t=16})=><F width={t}height={t}viewBox="0 0 24 24"fill="none">
|
|
15
|
+
<A d="M18 15l-6-6-6 6"stroke={n}strokeWidth="2.5"strokeLinecap="round"strokeLinejoin="round"/>
|
|
16
|
+
</F>,Ce=({color:n=e.slate500,size:t=16})=><F width={t}height={t}viewBox="0 0 24 24"fill="none">
|
|
17
|
+
<A d="M6 9l6 6 6-6"stroke={n}strokeWidth="2.5"strokeLinecap="round"strokeLinejoin="round"/>
|
|
18
|
+
</F>,Te=B.memo(({line:n,lineIndex:t,language:l,search:i,isActiveMatch:r})=>{const o=I(()=>l==="html"?oe(n):l==="css"?ne(n):re(n),[n,l]),d=(s,p)=>{const g=ie(p);if(!i)return<T style={g}>{s}</T>;const v=s.split(new RegExp(`(${V(i)})`,"gi"));return<T style={g}>
|
|
19
|
+
{v.map((m,z)=>m.toLowerCase()===i.toLowerCase()?<T key={z}style={a.highlight}>
|
|
20
|
+
{m}
|
|
21
|
+
</T>:m)}
|
|
22
|
+
</T>};return<S style={[a.lineRow,r&&a.activeMatchRow]}>
|
|
257
23
|
|
|
258
|
-
<
|
|
259
|
-
<
|
|
260
|
-
</
|
|
24
|
+
<S style={[a.gutter,{backgroundColor:e.grayBackground,borderRightColor:e.grayBorderSecondary},r&&a.activeMatchGutter]}>
|
|
25
|
+
<T style={[a.lineNumber,{color:e.grayTextWeak},r&&a.activeMatchLineNumber]}>{t+1}</T>
|
|
26
|
+
</S>
|
|
261
27
|
|
|
262
28
|
|
|
263
|
-
<
|
|
264
|
-
<
|
|
265
|
-
{
|
|
266
|
-
{
|
|
267
|
-
</
|
|
268
|
-
</
|
|
269
|
-
</
|
|
270
|
-
</
|
|
271
|
-
});
|
|
272
|
-
const CodeSnippet = ({ code, language, search, }) => {
|
|
273
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
274
|
-
const [debouncedQuery, setDebouncedQuery] = useState('');
|
|
275
|
-
const [currentMatchIdx, setCurrentMatchIdx] = useState(-1);
|
|
276
|
-
const [visibleLinesCount, setVisibleLinesCount] = useState(200);
|
|
277
|
-
const flatListRef = useRef(null);
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
if (search !== undefined) {
|
|
280
|
-
setSearchQuery(search);
|
|
281
|
-
}
|
|
282
|
-
}, [search]);
|
|
283
|
-
useEffect(() => {
|
|
284
|
-
const timer = setTimeout(() => {
|
|
285
|
-
setDebouncedQuery(searchQuery);
|
|
286
|
-
}, 300);
|
|
287
|
-
return () => clearTimeout(timer);
|
|
288
|
-
}, [searchQuery]);
|
|
289
|
-
const formattedCode = useMemo(() => {
|
|
290
|
-
if (!code)
|
|
291
|
-
return '';
|
|
292
|
-
if (code.length > 150000) {
|
|
293
|
-
return code;
|
|
294
|
-
}
|
|
295
|
-
if (language === 'html')
|
|
296
|
-
return formatHTML(code);
|
|
297
|
-
if (language === 'css')
|
|
298
|
-
return formatCSS(code);
|
|
299
|
-
if (language === 'javascript')
|
|
300
|
-
return formatJS(code);
|
|
301
|
-
return code;
|
|
302
|
-
}, [code, language]);
|
|
303
|
-
const lines = useMemo(() => {
|
|
304
|
-
if (!formattedCode)
|
|
305
|
-
return [];
|
|
306
|
-
return formattedCode.split(/\r?\n/);
|
|
307
|
-
}, [formattedCode]);
|
|
308
|
-
const matches = useMemo(() => {
|
|
309
|
-
if (!debouncedQuery.trim() || debouncedQuery.length < 2)
|
|
310
|
-
return [];
|
|
311
|
-
const query = debouncedQuery.toLowerCase();
|
|
312
|
-
const indices = [];
|
|
313
|
-
for (let i = 0; i < lines.length; i++) {
|
|
314
|
-
if (lines[i].toLowerCase().includes(query)) {
|
|
315
|
-
indices.push(i);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return indices;
|
|
319
|
-
}, [debouncedQuery, lines]);
|
|
320
|
-
useEffect(() => {
|
|
321
|
-
setVisibleLinesCount(200);
|
|
322
|
-
setSearchQuery(search || '');
|
|
323
|
-
setCurrentMatchIdx(-1);
|
|
324
|
-
}, [code, language]);
|
|
325
|
-
useEffect(() => {
|
|
326
|
-
if (matches.length > 0) {
|
|
327
|
-
setCurrentMatchIdx(0);
|
|
328
|
-
scrollToMatch(0);
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
setCurrentMatchIdx(-1);
|
|
332
|
-
}
|
|
333
|
-
}, [matches]);
|
|
334
|
-
const scrollToMatch = (matchIdx) => {
|
|
335
|
-
if (matches.length === 0 || matchIdx < 0 || matchIdx >= matches.length)
|
|
336
|
-
return;
|
|
337
|
-
const lineIdx = matches[matchIdx];
|
|
338
|
-
if (lineIdx >= visibleLinesCount) {
|
|
339
|
-
setVisibleLinesCount(lineIdx + 100);
|
|
340
|
-
}
|
|
341
|
-
setTimeout(() => {
|
|
342
|
-
try {
|
|
343
|
-
flatListRef.current?.scrollToIndex({
|
|
344
|
-
index: lineIdx,
|
|
345
|
-
animated: false,
|
|
346
|
-
viewPosition: 0.3,
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
catch (e) {
|
|
350
|
-
}
|
|
351
|
-
}, 50);
|
|
352
|
-
};
|
|
353
|
-
const onScrollToIndexFailed = (error) => {
|
|
354
|
-
flatListRef.current?.scrollToOffset({
|
|
355
|
-
offset: error.averageItemLength * error.index,
|
|
356
|
-
animated: false,
|
|
357
|
-
});
|
|
358
|
-
setTimeout(() => {
|
|
359
|
-
try {
|
|
360
|
-
flatListRef.current?.scrollToIndex({
|
|
361
|
-
index: error.index,
|
|
362
|
-
animated: false,
|
|
363
|
-
viewPosition: 0.3,
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
catch (err) {
|
|
367
|
-
console.warn('Scroll to line index failed after fallback retry:', err);
|
|
368
|
-
}
|
|
369
|
-
}, 60);
|
|
370
|
-
};
|
|
371
|
-
const handleNextMatch = () => {
|
|
372
|
-
if (matches.length === 0)
|
|
373
|
-
return;
|
|
374
|
-
const nextIdx = (currentMatchIdx + 1) % matches.length;
|
|
375
|
-
setCurrentMatchIdx(nextIdx);
|
|
376
|
-
scrollToMatch(nextIdx);
|
|
377
|
-
};
|
|
378
|
-
const handlePrevMatch = () => {
|
|
379
|
-
if (matches.length === 0)
|
|
380
|
-
return;
|
|
381
|
-
const prevIdx = (currentMatchIdx - 1 + matches.length) % matches.length;
|
|
382
|
-
setCurrentMatchIdx(prevIdx);
|
|
383
|
-
scrollToMatch(prevIdx);
|
|
384
|
-
};
|
|
385
|
-
const visibleLines = useMemo(() => {
|
|
386
|
-
return lines.slice(0, visibleLinesCount);
|
|
387
|
-
}, [lines, visibleLinesCount]);
|
|
388
|
-
const handleEndReached = () => {
|
|
389
|
-
if (visibleLinesCount < lines.length) {
|
|
390
|
-
setVisibleLinesCount(prev => Math.min(prev + 150, lines.length));
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
const renderLine = ({ item, index }) => {
|
|
394
|
-
const isActiveMatch = matches.length > 0 && currentMatchIdx >= 0 && index === matches[currentMatchIdx];
|
|
395
|
-
return (<CodeSnippetLine line={item} lineIndex={index} language={language} search={debouncedQuery} isActiveMatch={isActiveMatch}/>);
|
|
396
|
-
};
|
|
397
|
-
return (<View style={{ flex: 1 }}>
|
|
29
|
+
<S style={a.codeLine}>
|
|
30
|
+
<T style={[a.codeLineText,{color:e.primaryBlack}]}>
|
|
31
|
+
{o.length===0?<T style={[a.plain,{color:e.primaryBlack}]}> </T>:o.map((s,p)=><B.Fragment key={p}>
|
|
32
|
+
{d(s.text,s.type)}
|
|
33
|
+
</B.Fragment>)}
|
|
34
|
+
</T>
|
|
35
|
+
</S>
|
|
36
|
+
</S>}),ve=({code:n,language:t,search:l})=>{const[i,r]=R(""),[o,d]=R(""),[s,p]=R(-1),[g,v]=R(200),m=D(null);L(()=>{l!==void 0&&r(l)},[l]),L(()=>{const c=setTimeout(()=>{d(i)},300);return()=>clearTimeout(c)},[i]);const z=I(()=>n?n.length>15e4?n:t==="html"?X(n):t==="css"?ee(n):t==="javascript"?te(n):n:"",[n,t]),y=I(()=>z?z.split(/\r?\n/):[],[z]),u=I(()=>{if(!o.trim()||o.length<2)return[];const c=o.toLowerCase(),h=[];for(let C=0;C<y.length;C++)y[C].toLowerCase().includes(c)&&h.push(C);return h},[o,y]);L(()=>{v(200),r(l||""),p(-1)},[n,t]),L(()=>{u.length>0?(p(0),W(0)):p(-1)},[u]);const W=c=>{if(u.length===0||c<0||c>=u.length)return;const h=u[c];h>=g&&v(h+100),setTimeout(()=>{try{m.current?.scrollToIndex({index:h,animated:!1,viewPosition:.3})}catch{}},50)},P=c=>{m.current?.scrollToOffset({offset:c.averageItemLength*c.index,animated:!1}),setTimeout(()=>{try{m.current?.scrollToIndex({index:c.index,animated:!1,viewPosition:.3})}catch(h){console.warn("Scroll to line index failed after fallback retry:",h)}},60)},j=()=>{if(u.length===0)return;const c=(s+1)%u.length;p(c),W(c)},N=()=>{if(u.length===0)return;const c=(s-1+u.length)%u.length;p(c),W(c)},Z=I(()=>y.slice(0,g),[y,g]),E=()=>{g<y.length&&v(c=>Math.min(c+150,y.length))},H=({item:c,index:h})=>{const C=u.length>0&&s>=0&&h===u[s];return<Te line={c}lineIndex={h}language={t}search={o}isActiveMatch={C}/>};return<S style={{flex:1}}>
|
|
398
37
|
|
|
399
|
-
<
|
|
400
|
-
<
|
|
401
|
-
<
|
|
402
|
-
<
|
|
38
|
+
<S style={a.searchRow}>
|
|
39
|
+
<S style={[a.searchBar,{backgroundColor:e.primaryLight,borderColor:e.grayBorderSecondary}]}>
|
|
40
|
+
<J color={e.grayTextWeak}size={15}/>
|
|
41
|
+
<O placeholder={`Search ${t.toUpperCase()}...`}placeholderTextColor={e.grayTextWeak}value={i}onChangeText={r}style={[a.searchInput,{color:e.primaryBlack}]}autoCorrect={!1}autoCapitalize="none"/>
|
|
403
42
|
|
|
404
43
|
|
|
405
|
-
{
|
|
406
|
-
{
|
|
407
|
-
</
|
|
44
|
+
{o.length>=2&&<T style={[a.matchCountText,{backgroundColor:e.grayBackground,color:e.grayTextWeak}]}>
|
|
45
|
+
{u.length>0?`${s+1}/${u.length}`:"0/0"}
|
|
46
|
+
</T>}
|
|
408
47
|
|
|
409
|
-
{
|
|
410
|
-
<
|
|
411
|
-
</
|
|
412
|
-
</
|
|
48
|
+
{i.length>0&&<U onPress={()=>r("")}hitSlop={8}style={a.clearBtn}>
|
|
49
|
+
<Y color={e.grayTextWeak}size={12}/>
|
|
50
|
+
</U>}
|
|
51
|
+
</S>
|
|
413
52
|
|
|
414
53
|
|
|
415
|
-
{
|
|
416
|
-
|
|
417
|
-
<
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
<
|
|
421
|
-
|
|
422
|
-
</
|
|
54
|
+
{u.length>0&&<S style={[a.navArrowsGroup,{backgroundColor:e.primaryLight,borderColor:e.grayBorderSecondary}]}>
|
|
55
|
+
<$ onPress={N}hitSlop={8}style={a.navArrowBtn}>
|
|
56
|
+
<Se color={e.grayTextStrong}size={14}/>
|
|
57
|
+
</$>
|
|
58
|
+
<$ onPress={j}hitSlop={8}style={a.navArrowBtn}>
|
|
59
|
+
<Ce color={e.grayTextStrong}size={14}/>
|
|
60
|
+
</$>
|
|
61
|
+
</S>}
|
|
423
62
|
|
|
424
|
-
<
|
|
425
|
-
</
|
|
63
|
+
<K value={n}label={`${t.toUpperCase()} Source`}/>
|
|
64
|
+
</S>
|
|
426
65
|
|
|
427
66
|
|
|
428
|
-
<
|
|
429
|
-
<
|
|
430
|
-
</
|
|
431
|
-
</
|
|
432
|
-
};
|
|
433
|
-
const monoFont = AppFonts.interRegular;
|
|
434
|
-
const styles = StyleSheet.create({
|
|
435
|
-
container: {
|
|
436
|
-
flex: 1,
|
|
437
|
-
backgroundColor: AppColors.slate50,
|
|
438
|
-
borderRadius: 8,
|
|
439
|
-
borderWidth: 1,
|
|
440
|
-
borderColor: AppColors.slate200,
|
|
441
|
-
overflow: 'hidden',
|
|
442
|
-
},
|
|
443
|
-
searchRow: {
|
|
444
|
-
flexDirection: 'row',
|
|
445
|
-
alignItems: 'center',
|
|
446
|
-
marginBottom: 6,
|
|
447
|
-
gap: 8,
|
|
448
|
-
},
|
|
449
|
-
searchBar: {
|
|
450
|
-
flex: 1,
|
|
451
|
-
flexDirection: 'row',
|
|
452
|
-
alignItems: 'center',
|
|
453
|
-
backgroundColor: AppColors.white,
|
|
454
|
-
borderRadius: 8,
|
|
455
|
-
borderWidth: 1,
|
|
456
|
-
borderColor: AppColors.slate200,
|
|
457
|
-
paddingHorizontal: 8,
|
|
458
|
-
height: 32,
|
|
459
|
-
},
|
|
460
|
-
searchInput: {
|
|
461
|
-
flex: 1,
|
|
462
|
-
fontFamily: AppFonts.interRegular,
|
|
463
|
-
fontSize: 12,
|
|
464
|
-
color: AppColors.slate900,
|
|
465
|
-
marginLeft: 6,
|
|
466
|
-
paddingVertical: 0,
|
|
467
|
-
},
|
|
468
|
-
matchCountText: {
|
|
469
|
-
fontFamily: AppFonts.interMedium,
|
|
470
|
-
fontSize: 10,
|
|
471
|
-
color: AppColors.slate500,
|
|
472
|
-
marginHorizontal: 6,
|
|
473
|
-
backgroundColor: AppColors.slate100,
|
|
474
|
-
paddingHorizontal: 6,
|
|
475
|
-
paddingVertical: 2,
|
|
476
|
-
borderRadius: 4,
|
|
477
|
-
},
|
|
478
|
-
clearBtn: {
|
|
479
|
-
padding: 4,
|
|
480
|
-
},
|
|
481
|
-
navArrowsGroup: {
|
|
482
|
-
flexDirection: 'row',
|
|
483
|
-
alignItems: 'center',
|
|
484
|
-
backgroundColor: AppColors.white,
|
|
485
|
-
borderRadius: 8,
|
|
486
|
-
borderWidth: 1,
|
|
487
|
-
borderColor: AppColors.slate200,
|
|
488
|
-
height: 32,
|
|
489
|
-
paddingHorizontal: 2,
|
|
490
|
-
},
|
|
491
|
-
navArrowBtn: {
|
|
492
|
-
padding: 5,
|
|
493
|
-
borderRadius: 6,
|
|
494
|
-
alignItems: 'center',
|
|
495
|
-
justifyContent: 'center',
|
|
496
|
-
},
|
|
497
|
-
lineRow: {
|
|
498
|
-
flexDirection: 'row',
|
|
499
|
-
alignItems: 'stretch',
|
|
500
|
-
minHeight: 20,
|
|
501
|
-
paddingVertical: 1,
|
|
502
|
-
},
|
|
503
|
-
activeMatchRow: {
|
|
504
|
-
backgroundColor: `${AppColors.amber600}38`,
|
|
505
|
-
borderLeftWidth: 4,
|
|
506
|
-
borderLeftColor: AppColors.amber600,
|
|
507
|
-
},
|
|
508
|
-
gutter: {
|
|
509
|
-
width: 40,
|
|
510
|
-
backgroundColor: AppColors.slate100,
|
|
511
|
-
borderRightWidth: 1,
|
|
512
|
-
borderRightColor: AppColors.slate200,
|
|
513
|
-
justifyContent: 'flex-start',
|
|
514
|
-
alignItems: 'flex-end',
|
|
515
|
-
paddingRight: 6,
|
|
516
|
-
paddingTop: 1,
|
|
517
|
-
},
|
|
518
|
-
activeMatchGutter: {
|
|
519
|
-
backgroundColor: `${AppColors.amber600}59`,
|
|
520
|
-
borderRightColor: `${AppColors.amber600}80`,
|
|
521
|
-
},
|
|
522
|
-
lineNumber: {
|
|
523
|
-
fontFamily: monoFont,
|
|
524
|
-
fontSize: 9,
|
|
525
|
-
color: AppColors.slate400,
|
|
526
|
-
},
|
|
527
|
-
activeMatchLineNumber: {
|
|
528
|
-
color: AppColors.amber800,
|
|
529
|
-
fontWeight: 'bold',
|
|
530
|
-
},
|
|
531
|
-
codeLine: {
|
|
532
|
-
flex: 1,
|
|
533
|
-
paddingLeft: 10,
|
|
534
|
-
paddingRight: 12,
|
|
535
|
-
justifyContent: 'center',
|
|
536
|
-
},
|
|
537
|
-
codeLineText: {
|
|
538
|
-
fontFamily: monoFont,
|
|
539
|
-
fontSize: 10.5,
|
|
540
|
-
color: AppColors.slate700,
|
|
541
|
-
flexWrap: 'wrap',
|
|
542
|
-
},
|
|
543
|
-
plain: {
|
|
544
|
-
fontFamily: monoFont,
|
|
545
|
-
fontSize: 10.5,
|
|
546
|
-
color: AppColors.slate700,
|
|
547
|
-
},
|
|
548
|
-
comment: {
|
|
549
|
-
fontFamily: monoFont,
|
|
550
|
-
fontSize: 10.5,
|
|
551
|
-
color: AppColors.slate500,
|
|
552
|
-
fontStyle: 'italic',
|
|
553
|
-
},
|
|
554
|
-
string: {
|
|
555
|
-
fontFamily: monoFont,
|
|
556
|
-
fontSize: 10.5,
|
|
557
|
-
color: AppColors.amber700,
|
|
558
|
-
},
|
|
559
|
-
keyword: {
|
|
560
|
-
fontFamily: monoFont,
|
|
561
|
-
fontSize: 10.5,
|
|
562
|
-
color: AppColors.violet600,
|
|
563
|
-
fontWeight: 'bold',
|
|
564
|
-
},
|
|
565
|
-
builtin: {
|
|
566
|
-
fontFamily: monoFont,
|
|
567
|
-
fontSize: 10.5,
|
|
568
|
-
color: AppColors.teal600,
|
|
569
|
-
},
|
|
570
|
-
number: {
|
|
571
|
-
fontFamily: monoFont,
|
|
572
|
-
fontSize: 10.5,
|
|
573
|
-
color: AppColors.blue600,
|
|
574
|
-
},
|
|
575
|
-
tag: {
|
|
576
|
-
fontFamily: monoFont,
|
|
577
|
-
fontSize: 10.5,
|
|
578
|
-
color: AppColors.indigo600,
|
|
579
|
-
fontWeight: 'bold',
|
|
580
|
-
},
|
|
581
|
-
attribute: {
|
|
582
|
-
fontFamily: monoFont,
|
|
583
|
-
fontSize: 10.5,
|
|
584
|
-
color: AppColors.teal600,
|
|
585
|
-
},
|
|
586
|
-
selector: {
|
|
587
|
-
fontFamily: monoFont,
|
|
588
|
-
fontSize: 10.5,
|
|
589
|
-
color: AppColors.violet600,
|
|
590
|
-
fontWeight: 'bold',
|
|
591
|
-
},
|
|
592
|
-
property: {
|
|
593
|
-
fontFamily: monoFont,
|
|
594
|
-
fontSize: 10.5,
|
|
595
|
-
color: AppColors.teal600,
|
|
596
|
-
},
|
|
597
|
-
value: {
|
|
598
|
-
fontFamily: monoFont,
|
|
599
|
-
fontSize: 10.5,
|
|
600
|
-
color: AppColors.orange600,
|
|
601
|
-
},
|
|
602
|
-
highlight: {
|
|
603
|
-
backgroundColor: AppColors.highlightYellow,
|
|
604
|
-
color: AppColors.black,
|
|
605
|
-
},
|
|
606
|
-
});
|
|
607
|
-
export default CodeSnippet;
|
|
67
|
+
<S style={[a.container,{backgroundColor:e.grayBackground,borderColor:e.grayBorderSecondary}]}>
|
|
68
|
+
<Q ref={m}data={Z}renderItem={H}keyExtractor={(c,h)=>String(h)}maxToRenderPerBatch={30}windowSize={5}initialNumToRender={50}removeClippedSubviews={G.OS==="android"}onEndReached={E}onEndReachedThreshold={.5}onScrollToIndexFailed={P}/>
|
|
69
|
+
</S>
|
|
70
|
+
</S>},f=M.interRegular,a=_.create({container:{flex:1,backgroundColor:e.slate50,borderRadius:8,borderWidth:1,borderColor:e.slate200,overflow:"hidden"},searchRow:{flexDirection:"row",alignItems:"center",marginBottom:6,gap:8},searchBar:{flex:1,flexDirection:"row",alignItems:"center",backgroundColor:e.white,borderRadius:8,borderWidth:1,borderColor:e.slate200,paddingHorizontal:8,height:32},searchInput:{flex:1,fontFamily:M.interRegular,fontSize:12,color:e.slate900,marginLeft:6,paddingVertical:0},matchCountText:{fontFamily:M.interMedium,fontSize:10,color:e.slate500,marginHorizontal:6,backgroundColor:e.slate100,paddingHorizontal:6,paddingVertical:2,borderRadius:4},clearBtn:{padding:4},navArrowsGroup:{flexDirection:"row",alignItems:"center",backgroundColor:e.white,borderRadius:8,borderWidth:1,borderColor:e.slate200,height:32,paddingHorizontal:2},navArrowBtn:{padding:5,borderRadius:6,alignItems:"center",justifyContent:"center"},lineRow:{flexDirection:"row",alignItems:"stretch",minHeight:20,paddingVertical:1},activeMatchRow:{backgroundColor:`${e.amber600}38`,borderLeftWidth:4,borderLeftColor:e.amber600},gutter:{width:40,backgroundColor:e.slate100,borderRightWidth:1,borderRightColor:e.slate200,justifyContent:"flex-start",alignItems:"flex-end",paddingRight:6,paddingTop:1},activeMatchGutter:{backgroundColor:`${e.amber600}59`,borderRightColor:`${e.amber600}80`},lineNumber:{fontFamily:f,fontSize:9,color:e.slate400},activeMatchLineNumber:{color:e.amber800,fontWeight:"bold"},codeLine:{flex:1,paddingLeft:10,paddingRight:12,justifyContent:"center"},codeLineText:{fontFamily:f,fontSize:10.5,color:e.slate700,flexWrap:"wrap"},plain:{fontFamily:f,fontSize:10.5,color:e.slate700},comment:{fontFamily:f,fontSize:10.5,color:e.slate500,fontStyle:"italic"},string:{fontFamily:f,fontSize:10.5,color:e.amber700},keyword:{fontFamily:f,fontSize:10.5,color:e.violet600,fontWeight:"bold"},builtin:{fontFamily:f,fontSize:10.5,color:e.teal600},number:{fontFamily:f,fontSize:10.5,color:e.blue600},tag:{fontFamily:f,fontSize:10.5,color:e.indigo600,fontWeight:"bold"},attribute:{fontFamily:f,fontSize:10.5,color:e.teal600},selector:{fontFamily:f,fontSize:10.5,color:e.violet600,fontWeight:"bold"},property:{fontFamily:f,fontSize:10.5,color:e.teal600},value:{fontFamily:f,fontSize:10.5,color:e.orange600},highlight:{backgroundColor:e.highlightYellow,color:e.black}});export default ve;
|