1*26ad19fcSEvan Bacon/** 2*26ad19fcSEvan Bacon * Copyright (c) 650 Industries. 3*26ad19fcSEvan Bacon * Copyright (c) Meta Platforms, Inc. and affiliates. 4*26ad19fcSEvan Bacon * 5*26ad19fcSEvan Bacon * This source code is licensed under the MIT license found in the 6*26ad19fcSEvan Bacon * LICENSE file in the root directory of this source tree. 7*26ad19fcSEvan Bacon */ 8*26ad19fcSEvan Baconimport React from 'react'; 9*26ad19fcSEvan Baconimport { GestureResponderEvent, StyleSheet, Text, View } from 'react-native'; 10*26ad19fcSEvan Baconimport { StackFrame } from 'stacktrace-parser'; 11*26ad19fcSEvan Bacon 12*26ad19fcSEvan Baconimport { LogBoxButton } from '../UI/LogBoxButton'; 13*26ad19fcSEvan Baconimport * as LogBoxStyle from '../UI/LogBoxStyle'; 14*26ad19fcSEvan Baconimport { CODE_FONT } from '../UI/constants'; 15*26ad19fcSEvan Baconimport { getStackFormattedLocation } from '../formatProjectFilePath'; 16*26ad19fcSEvan Bacon 17*26ad19fcSEvan Bacondeclare const process: any; 18*26ad19fcSEvan Bacon 19*26ad19fcSEvan Bacontype Props = { 20*26ad19fcSEvan Bacon frame: StackFrame & { collapse?: boolean }; 21*26ad19fcSEvan Bacon onPress?: (event: GestureResponderEvent) => void; 22*26ad19fcSEvan Bacon}; 23*26ad19fcSEvan Bacon 24*26ad19fcSEvan Baconexport function LogBoxInspectorStackFrame(props: Props) { 25*26ad19fcSEvan Bacon const { frame, onPress } = props; 26*26ad19fcSEvan Bacon const location = getStackFormattedLocation(process.env.EXPO_PROJECT_ROOT, frame); 27*26ad19fcSEvan Bacon return ( 28*26ad19fcSEvan Bacon <View style={styles.frameContainer}> 29*26ad19fcSEvan Bacon <LogBoxButton 30*26ad19fcSEvan Bacon backgroundColor={{ 31*26ad19fcSEvan Bacon default: 'transparent', 32*26ad19fcSEvan Bacon pressed: onPress ? LogBoxStyle.getBackgroundColor(1) : 'transparent', 33*26ad19fcSEvan Bacon }} 34*26ad19fcSEvan Bacon onPress={onPress} 35*26ad19fcSEvan Bacon style={styles.frame}> 36*26ad19fcSEvan Bacon <Text style={[styles.name, frame.collapse === true && styles.dim]}>{frame.methodName}</Text> 37*26ad19fcSEvan Bacon <Text 38*26ad19fcSEvan Bacon ellipsizeMode="middle" 39*26ad19fcSEvan Bacon numberOfLines={1} 40*26ad19fcSEvan Bacon style={[styles.location, frame.collapse === true && styles.dim]}> 41*26ad19fcSEvan Bacon {location} 42*26ad19fcSEvan Bacon </Text> 43*26ad19fcSEvan Bacon </LogBoxButton> 44*26ad19fcSEvan Bacon </View> 45*26ad19fcSEvan Bacon ); 46*26ad19fcSEvan Bacon} 47*26ad19fcSEvan Bacon 48*26ad19fcSEvan Baconconst styles = StyleSheet.create({ 49*26ad19fcSEvan Bacon frameContainer: { 50*26ad19fcSEvan Bacon flexDirection: 'row', 51*26ad19fcSEvan Bacon paddingHorizontal: 15, 52*26ad19fcSEvan Bacon }, 53*26ad19fcSEvan Bacon frame: { 54*26ad19fcSEvan Bacon flex: 1, 55*26ad19fcSEvan Bacon paddingVertical: 4, 56*26ad19fcSEvan Bacon paddingHorizontal: 10, 57*26ad19fcSEvan Bacon borderRadius: 5, 58*26ad19fcSEvan Bacon }, 59*26ad19fcSEvan Bacon lineLocation: { 60*26ad19fcSEvan Bacon flexDirection: 'row', 61*26ad19fcSEvan Bacon }, 62*26ad19fcSEvan Bacon name: { 63*26ad19fcSEvan Bacon color: LogBoxStyle.getTextColor(1), 64*26ad19fcSEvan Bacon fontSize: 14, 65*26ad19fcSEvan Bacon includeFontPadding: false, 66*26ad19fcSEvan Bacon lineHeight: 18, 67*26ad19fcSEvan Bacon fontWeight: '400', 68*26ad19fcSEvan Bacon fontFamily: CODE_FONT, 69*26ad19fcSEvan Bacon }, 70*26ad19fcSEvan Bacon location: { 71*26ad19fcSEvan Bacon color: LogBoxStyle.getTextColor(0.8), 72*26ad19fcSEvan Bacon fontSize: 12, 73*26ad19fcSEvan Bacon fontWeight: '300', 74*26ad19fcSEvan Bacon includeFontPadding: false, 75*26ad19fcSEvan Bacon lineHeight: 16, 76*26ad19fcSEvan Bacon paddingLeft: 10, 77*26ad19fcSEvan Bacon }, 78*26ad19fcSEvan Bacon dim: { 79*26ad19fcSEvan Bacon color: LogBoxStyle.getTextColor(0.4), 80*26ad19fcSEvan Bacon fontWeight: '300', 81*26ad19fcSEvan Bacon }, 82*26ad19fcSEvan Bacon line: { 83*26ad19fcSEvan Bacon color: LogBoxStyle.getTextColor(0.8), 84*26ad19fcSEvan Bacon fontSize: 12, 85*26ad19fcSEvan Bacon fontWeight: '300', 86*26ad19fcSEvan Bacon includeFontPadding: false, 87*26ad19fcSEvan Bacon lineHeight: 16, 88*26ad19fcSEvan Bacon }, 89*26ad19fcSEvan Bacon}); 90