@expo/metro-runtime 3.0.1 → 3.0.2

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.
Files changed (112) hide show
  1. package/build/LoadingView.d.ts +6 -0
  2. package/build/LoadingView.d.ts.map +1 -1
  3. package/build/LoadingView.js +9 -3
  4. package/build/LoadingView.js.map +1 -1
  5. package/build/async-require/fetchAsync.d.ts +6 -0
  6. package/build/async-require/fetchAsync.d.ts.map +1 -1
  7. package/build/async-require/fetchAsync.js +1 -2
  8. package/build/async-require/fetchAsync.js.map +1 -1
  9. package/build/async-require/fetchThenEval.d.ts +1 -6
  10. package/build/async-require/fetchThenEval.d.ts.map +1 -1
  11. package/build/async-require/fetchThenEval.js +2 -32
  12. package/build/async-require/fetchThenEval.js.map +1 -1
  13. package/build/async-require/fetchThenEval.web.js +1 -1
  14. package/build/async-require/fetchThenEval.web.js.map +1 -1
  15. package/build/async-require/fetchThenEvalJs.d.ts +7 -0
  16. package/build/async-require/fetchThenEvalJs.d.ts.map +1 -0
  17. package/build/async-require/fetchThenEvalJs.js +36 -0
  18. package/build/async-require/fetchThenEvalJs.js.map +1 -0
  19. package/build/async-require/index.native.d.ts +7 -0
  20. package/build/async-require/index.native.d.ts.map +1 -0
  21. package/build/async-require/index.native.js +14 -0
  22. package/build/async-require/index.native.js.map +1 -0
  23. package/build/effects.d.ts +0 -1
  24. package/build/effects.js +1 -6
  25. package/build/effects.js.map +1 -1
  26. package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
  27. package/build/error-overlay/Data/parseLogBoxLog.js +1 -2
  28. package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
  29. package/build/error-overlay/LogBox.web.d.ts.map +1 -1
  30. package/build/error-overlay/LogBox.web.js +1 -2
  31. package/build/error-overlay/LogBox.web.js.map +1 -1
  32. package/build/error-overlay/index.d.ts.map +1 -1
  33. package/build/error-overlay/index.js +1 -0
  34. package/build/error-overlay/index.js.map +1 -1
  35. package/build/getDevServer.d.ts.map +1 -1
  36. package/build/getDevServer.js +2 -6
  37. package/build/getDevServer.js.map +1 -1
  38. package/build/index.d.ts +8 -0
  39. package/build/index.d.ts.map +1 -1
  40. package/build/index.js +10 -8
  41. package/build/index.js.map +1 -1
  42. package/build/setupHMR.js +21 -24
  43. package/build/setupHMR.js.map +1 -1
  44. package/package.json +5 -2
  45. package/src/HMRClient.native.ts +3 -0
  46. package/src/HMRClient.ts +316 -0
  47. package/src/LoadingView.native.ts +3 -0
  48. package/src/LoadingView.ts +24 -0
  49. package/src/__mocks__/LoadingView.ts +4 -0
  50. package/src/async-require/buildAsyncRequire.ts +34 -0
  51. package/src/async-require/buildUrlForBundle.native.ts +28 -0
  52. package/src/async-require/buildUrlForBundle.ts +18 -0
  53. package/src/async-require/fetchAsync.native.ts +72 -0
  54. package/src/async-require/fetchAsync.ts +19 -0
  55. package/src/async-require/fetchThenEval.ts +1 -0
  56. package/src/async-require/fetchThenEval.web.ts +70 -0
  57. package/src/async-require/fetchThenEvalJs.ts +39 -0
  58. package/src/async-require/index.native.ts +15 -0
  59. package/src/async-require/index.ts +10 -0
  60. package/src/async-require/loadBundle.ts +46 -0
  61. package/src/effects.native.ts +0 -0
  62. package/src/effects.ts +11 -0
  63. package/src/error-overlay/Data/LogBoxData.tsx +438 -0
  64. package/src/error-overlay/Data/LogBoxLog.ts +221 -0
  65. package/src/error-overlay/Data/LogBoxSymbolication.tsx +64 -0
  66. package/src/error-overlay/Data/LogContext.tsx +41 -0
  67. package/src/error-overlay/Data/parseLogBoxLog.tsx +342 -0
  68. package/src/error-overlay/ErrorOverlay.tsx +191 -0
  69. package/src/error-overlay/LogBox.ts +51 -0
  70. package/src/error-overlay/LogBox.web.ts +174 -0
  71. package/src/error-overlay/UI/AnsiHighlight.tsx +96 -0
  72. package/src/error-overlay/UI/LogBoxButton.tsx +63 -0
  73. package/src/error-overlay/UI/LogBoxMessage.tsx +73 -0
  74. package/src/error-overlay/UI/LogBoxStyle.ts +64 -0
  75. package/src/error-overlay/UI/constants.ts +7 -0
  76. package/src/error-overlay/formatProjectFilePath.ts +38 -0
  77. package/src/error-overlay/index.tsx +34 -0
  78. package/src/error-overlay/modules/ExceptionsManager/index.native.ts +4 -0
  79. package/src/error-overlay/modules/ExceptionsManager/index.ts +82 -0
  80. package/src/error-overlay/modules/NativeLogBox/index.native.ts +3 -0
  81. package/src/error-overlay/modules/NativeLogBox/index.tsx +27 -0
  82. package/src/error-overlay/modules/openFileInEditor/index.native.ts +3 -0
  83. package/src/error-overlay/modules/openFileInEditor/index.ts +16 -0
  84. package/src/error-overlay/modules/parseErrorStack/index.ts +26 -0
  85. package/src/error-overlay/modules/parseErrorStack/parseHermesStack.ts +3 -0
  86. package/src/error-overlay/modules/stringifySafe/index.ts +115 -0
  87. package/src/error-overlay/modules/symbolicateStackTrace/index.native.ts +3 -0
  88. package/src/error-overlay/modules/symbolicateStackTrace/index.ts +39 -0
  89. package/src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx +102 -0
  90. package/src/error-overlay/overlay/LogBoxInspectorFooter.tsx +111 -0
  91. package/src/error-overlay/overlay/LogBoxInspectorHeader.tsx +167 -0
  92. package/src/error-overlay/overlay/LogBoxInspectorMessageHeader.tsx +116 -0
  93. package/src/error-overlay/overlay/LogBoxInspectorSection.tsx +52 -0
  94. package/src/error-overlay/overlay/LogBoxInspectorSourceMapStatus.tsx +125 -0
  95. package/src/error-overlay/overlay/LogBoxInspectorStackFrame.tsx +89 -0
  96. package/src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx +201 -0
  97. package/src/error-overlay/toast/ErrorToast.tsx +167 -0
  98. package/src/error-overlay/toast/ErrorToastContainer.tsx +9 -0
  99. package/src/error-overlay/toast/ErrorToastContainer.web.tsx +92 -0
  100. package/src/error-overlay/toast/ErrorToastMessage.tsx +28 -0
  101. package/src/error-overlay/useRejectionHandler.ts +61 -0
  102. package/src/getDevServer.native.ts +3 -0
  103. package/src/getDevServer.ts +34 -0
  104. package/src/index.ts +12 -0
  105. package/src/location/Location.native.ts +201 -0
  106. package/src/location/Location.ts +3 -0
  107. package/src/location/install.native.ts +90 -0
  108. package/src/location/install.ts +0 -0
  109. package/src/messageSocket.ts +25 -0
  110. package/src/setupFastRefresh.ts +30 -0
  111. package/src/setupHMR.ts +28 -0
  112. package/src/symbolicate.ts +6 -0
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
10
+
11
+ import { useSelectedLog } from '../Data/LogContext';
12
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
13
+
14
+ type Props = {
15
+ onDismiss: () => void;
16
+ onMinimize: () => void;
17
+ };
18
+
19
+ export function LogBoxInspectorFooter(props: Props) {
20
+ const log = useSelectedLog();
21
+
22
+ if (['static', 'syntax'].includes(log.level)) {
23
+ return (
24
+ <View style={styles.root}>
25
+ <View style={styles.button}>
26
+ <Text style={styles.syntaxErrorText}>This error cannot be dismissed.</Text>
27
+ </View>
28
+ </View>
29
+ );
30
+ }
31
+
32
+ return (
33
+ <View style={styles.root}>
34
+ <FooterButton text="Dismiss" onPress={props.onDismiss} />
35
+ <FooterButton text="Minimize" onPress={props.onMinimize} />
36
+ </View>
37
+ );
38
+ }
39
+
40
+ function FooterButton({ text, onPress }: { onPress: () => void; text: string }) {
41
+ return (
42
+ <Pressable onPress={onPress} style={{ flex: 1 }}>
43
+ {({
44
+ /** @ts-expect-error: react-native types are broken. */
45
+ hovered,
46
+ pressed,
47
+ }) => (
48
+ <View
49
+ style={[
50
+ buttonStyles.safeArea,
51
+ {
52
+ // @ts-expect-error: web-only type
53
+ transitionDuration: '150ms',
54
+ backgroundColor: pressed
55
+ ? '#323232'
56
+ : hovered
57
+ ? '#111111'
58
+ : LogBoxStyle.getBackgroundColor(),
59
+ },
60
+ ]}>
61
+ <View style={buttonStyles.content}>
62
+ <Text style={buttonStyles.label}>{text}</Text>
63
+ </View>
64
+ </View>
65
+ )}
66
+ </Pressable>
67
+ );
68
+ }
69
+
70
+ const buttonStyles = StyleSheet.create({
71
+ safeArea: {
72
+ flex: 1,
73
+ borderTopWidth: 1,
74
+ borderColor: '#323232',
75
+ // paddingBottom: DeviceInfo.getConstants().isIPhoneX_deprecated ? 30 : 0,
76
+ },
77
+ content: {
78
+ alignItems: 'center',
79
+ height: 48,
80
+ justifyContent: 'center',
81
+ },
82
+ label: {
83
+ userSelect: 'none',
84
+ color: LogBoxStyle.getTextColor(1),
85
+ fontSize: 14,
86
+ includeFontPadding: false,
87
+ lineHeight: 20,
88
+ },
89
+ });
90
+
91
+ const styles = StyleSheet.create({
92
+ root: {
93
+ backgroundColor: LogBoxStyle.getBackgroundColor(1),
94
+ boxShadow: `0 -2px 0 2px #000`,
95
+ flexDirection: 'row',
96
+ },
97
+ button: {
98
+ flex: 1,
99
+ },
100
+ syntaxErrorText: {
101
+ textAlign: 'center',
102
+ width: '100%',
103
+ height: 48,
104
+ fontSize: 14,
105
+ lineHeight: 20,
106
+ paddingTop: 20,
107
+ paddingBottom: 50,
108
+ fontStyle: 'italic',
109
+ color: LogBoxStyle.getTextColor(0.6),
110
+ },
111
+ });
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { Image, Platform, StatusBar, StyleSheet, Text, View } from 'react-native';
10
+
11
+ import type { LogLevel } from '../Data/LogBoxLog';
12
+ import { useLogs } from '../Data/LogContext';
13
+ import { LogBoxButton } from '../UI/LogBoxButton';
14
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
15
+
16
+ type Props = {
17
+ onSelectIndex: (selectedIndex: number) => void;
18
+ level: LogLevel;
19
+ };
20
+
21
+ export function LogBoxInspectorHeader(props: Props) {
22
+ const { selectedLogIndex: selectedIndex, logs } = useLogs();
23
+ const total = logs.length;
24
+
25
+ if (props.level === 'syntax') {
26
+ return (
27
+ <View style={[styles.safeArea, styles[props.level]]}>
28
+ <View style={styles.header}>
29
+ <View style={styles.title}>
30
+ <Text style={styles.titleText}>Failed to compile</Text>
31
+ </View>
32
+ </View>
33
+ </View>
34
+ );
35
+ }
36
+
37
+ const prevIndex = selectedIndex - 1 < 0 ? total - 1 : selectedIndex - 1;
38
+ const nextIndex = selectedIndex + 1 > total - 1 ? 0 : selectedIndex + 1;
39
+
40
+ const titleText = `Log ${selectedIndex + 1} of ${total}`;
41
+
42
+ return (
43
+ <View style={[styles.safeArea, styles[props.level]]}>
44
+ <View style={styles.header}>
45
+ <LogBoxInspectorHeaderButton
46
+ disabled={total <= 1}
47
+ level={props.level}
48
+ image={require('@expo/metro-runtime/assets/chevron-left.png')}
49
+ onPress={() => props.onSelectIndex(prevIndex)}
50
+ />
51
+ <View style={styles.title}>
52
+ <Text style={styles.titleText}>{titleText}</Text>
53
+ </View>
54
+ <LogBoxInspectorHeaderButton
55
+ disabled={total <= 1}
56
+ level={props.level}
57
+ image={require('@expo/metro-runtime/assets/chevron-right.png')}
58
+ onPress={() => props.onSelectIndex(nextIndex)}
59
+ />
60
+ </View>
61
+ </View>
62
+ );
63
+ }
64
+
65
+ const backgroundForLevel = (level: LogLevel) =>
66
+ ({
67
+ warn: {
68
+ default: 'transparent',
69
+ pressed: LogBoxStyle.getWarningDarkColor(),
70
+ },
71
+ error: {
72
+ default: 'transparent',
73
+ pressed: LogBoxStyle.getErrorDarkColor(),
74
+ },
75
+ fatal: {
76
+ default: 'transparent',
77
+ pressed: LogBoxStyle.getFatalDarkColor(),
78
+ },
79
+ syntax: {
80
+ default: 'transparent',
81
+ pressed: LogBoxStyle.getFatalDarkColor(),
82
+ },
83
+ static: {
84
+ default: 'transparent',
85
+ pressed: LogBoxStyle.getFatalDarkColor(),
86
+ },
87
+ })[level];
88
+
89
+ function LogBoxInspectorHeaderButton(props: {
90
+ disabled: boolean;
91
+ image: number;
92
+ level: LogLevel;
93
+ onPress?: () => void;
94
+ }) {
95
+ return (
96
+ <LogBoxButton
97
+ backgroundColor={backgroundForLevel(props.level)}
98
+ onPress={props.disabled ? undefined : props.onPress}
99
+ style={headerStyles.button}>
100
+ {props.disabled ? null : (
101
+ <Image
102
+ source={props.image}
103
+ tintColor={LogBoxStyle.getTextColor()}
104
+ style={headerStyles.buttonImage}
105
+ />
106
+ )}
107
+ </LogBoxButton>
108
+ );
109
+ }
110
+
111
+ const headerStyles = StyleSheet.create({
112
+ button: {
113
+ alignItems: 'center',
114
+ justifyContent: 'center',
115
+ aspectRatio: 1,
116
+ marginRight: 6,
117
+ marginLeft: 6,
118
+ borderRadius: 3,
119
+ },
120
+ buttonImage: {
121
+ height: 14,
122
+ width: 8,
123
+ },
124
+ });
125
+
126
+ const styles = StyleSheet.create({
127
+ syntax: {
128
+ backgroundColor: LogBoxStyle.getFatalColor(),
129
+ },
130
+ static: {
131
+ backgroundColor: LogBoxStyle.getFatalColor(),
132
+ },
133
+ fatal: {
134
+ backgroundColor: LogBoxStyle.getFatalColor(),
135
+ },
136
+ warn: {
137
+ backgroundColor: LogBoxStyle.getWarningColor(),
138
+ },
139
+ error: {
140
+ backgroundColor: LogBoxStyle.getErrorColor(),
141
+ },
142
+ header: {
143
+ flexDirection: 'row',
144
+ alignItems: 'center',
145
+
146
+ paddingHorizontal: 8,
147
+ height: Platform.select({
148
+ default: 48,
149
+ ios: 44,
150
+ }),
151
+ },
152
+ title: {
153
+ alignItems: 'center',
154
+ flex: 1,
155
+ justifyContent: 'center',
156
+ },
157
+ titleText: {
158
+ color: LogBoxStyle.getTextColor(),
159
+ fontSize: 16,
160
+ fontWeight: '600',
161
+ includeFontPadding: false,
162
+ lineHeight: 20,
163
+ },
164
+ safeArea: {
165
+ paddingTop: Platform.OS !== 'ios' ? StatusBar.currentHeight : 40,
166
+ },
167
+ });
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { StyleSheet, Text, View } from 'react-native';
10
+
11
+ import type { LogLevel } from '../Data/LogBoxLog';
12
+ import type { Message } from '../Data/parseLogBoxLog';
13
+ import { LogBoxMessage } from '../UI/LogBoxMessage';
14
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
15
+
16
+ type Props = {
17
+ collapsed: boolean;
18
+ message: Message;
19
+ level: LogLevel;
20
+ title: string;
21
+ onPress: () => void;
22
+ };
23
+
24
+ const SHOW_MORE_MESSAGE_LENGTH = 300;
25
+
26
+ function ShowMoreButton({
27
+ message,
28
+ collapsed,
29
+ onPress,
30
+ }: Pick<Props, 'collapsed' | 'message' | 'onPress'>) {
31
+ if (message.content.length < SHOW_MORE_MESSAGE_LENGTH || !collapsed) {
32
+ return null;
33
+ }
34
+ return (
35
+ <Text style={styles.collapse} onPress={onPress}>
36
+ ... See More
37
+ </Text>
38
+ );
39
+ }
40
+
41
+ export function LogBoxInspectorMessageHeader(props: Props) {
42
+ return (
43
+ <View style={styles.body}>
44
+ <View style={styles.heading}>
45
+ <Text style={[styles.headingText, styles[props.level]]}>{props.title}</Text>
46
+ </View>
47
+ <Text style={styles.bodyText}>
48
+ <LogBoxMessage
49
+ maxLength={props.collapsed ? SHOW_MORE_MESSAGE_LENGTH : Infinity}
50
+ message={props.message}
51
+ style={styles.messageText}
52
+ />
53
+ <ShowMoreButton {...props} />
54
+ </Text>
55
+ </View>
56
+ );
57
+ }
58
+
59
+ const styles = StyleSheet.create({
60
+ body: {
61
+ backgroundColor: LogBoxStyle.getBackgroundColor(1),
62
+ boxShadow: `0 2px 0 2px #00000080`,
63
+ },
64
+ bodyText: {
65
+ color: LogBoxStyle.getTextColor(1),
66
+ fontSize: 14,
67
+ includeFontPadding: false,
68
+ lineHeight: 20,
69
+ fontWeight: '500',
70
+ paddingHorizontal: 12,
71
+ paddingBottom: 10,
72
+ },
73
+ heading: {
74
+ alignItems: 'center',
75
+ flexDirection: 'row',
76
+ paddingHorizontal: 12,
77
+ marginTop: 10,
78
+ marginBottom: 5,
79
+ },
80
+ headingText: {
81
+ flex: 1,
82
+ fontSize: 20,
83
+ fontWeight: '600',
84
+ includeFontPadding: false,
85
+ lineHeight: 28,
86
+ },
87
+ warn: {
88
+ color: LogBoxStyle.getWarningColor(1),
89
+ },
90
+ error: {
91
+ color: LogBoxStyle.getErrorColor(1),
92
+ },
93
+ fatal: {
94
+ color: LogBoxStyle.getFatalColor(1),
95
+ },
96
+ syntax: {
97
+ color: LogBoxStyle.getFatalColor(1),
98
+ },
99
+ static: {
100
+ color: LogBoxStyle.getFatalColor(1),
101
+ },
102
+ messageText: {
103
+ color: LogBoxStyle.getTextColor(0.6),
104
+ },
105
+ collapse: {
106
+ color: LogBoxStyle.getTextColor(0.7),
107
+ fontSize: 14,
108
+ fontWeight: '300',
109
+ lineHeight: 12,
110
+ },
111
+ button: {
112
+ paddingVertical: 5,
113
+ paddingHorizontal: 10,
114
+ borderRadius: 3,
115
+ },
116
+ });
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { StyleSheet, Text, View } from 'react-native';
10
+
11
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
12
+
13
+ type Props = {
14
+ heading: string;
15
+ children: React.ReactNode;
16
+ action?: any;
17
+ };
18
+
19
+ export function LogBoxInspectorSection(props: Props) {
20
+ return (
21
+ <View style={styles.section}>
22
+ <View style={styles.heading}>
23
+ <Text style={styles.headingText}>{props.heading}</Text>
24
+ {props.action}
25
+ </View>
26
+ <View style={styles.body}>{props.children}</View>
27
+ </View>
28
+ );
29
+ }
30
+
31
+ const styles = StyleSheet.create({
32
+ section: {
33
+ marginTop: 15,
34
+ },
35
+ heading: {
36
+ alignItems: 'center',
37
+ flexDirection: 'row',
38
+ paddingHorizontal: 12,
39
+ marginBottom: 10,
40
+ },
41
+ headingText: {
42
+ color: LogBoxStyle.getTextColor(1),
43
+ flex: 1,
44
+ fontSize: 18,
45
+ fontWeight: '600',
46
+ includeFontPadding: false,
47
+ lineHeight: 20,
48
+ },
49
+ body: {
50
+ paddingBottom: 10,
51
+ },
52
+ });
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React, { useEffect, useState } from 'react';
9
+ import { Animated, Easing, GestureResponderEvent, StyleSheet, Text } from 'react-native';
10
+
11
+ import { LogBoxButton } from '../UI/LogBoxButton';
12
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
13
+
14
+ type Props = {
15
+ onPress?: ((event: GestureResponderEvent) => void) | null;
16
+ status: 'COMPLETE' | 'FAILED' | 'NONE' | 'PENDING';
17
+ };
18
+
19
+ export function LogBoxInspectorSourceMapStatus(props: Props) {
20
+ const [state, setState] = useState<{
21
+ animation: null | Animated.CompositeAnimation;
22
+ rotate: null | Animated.AnimatedInterpolation<string>;
23
+ }>({
24
+ animation: null,
25
+ rotate: null,
26
+ });
27
+
28
+ useEffect(() => {
29
+ if (props.status === 'PENDING') {
30
+ if (state.animation == null) {
31
+ const animated = new Animated.Value(0);
32
+ const animation = Animated.loop(
33
+ Animated.timing(animated, {
34
+ duration: 2000,
35
+ easing: Easing.linear,
36
+ toValue: 1,
37
+ useNativeDriver: true,
38
+ })
39
+ );
40
+ setState({
41
+ animation,
42
+ rotate: animated.interpolate({
43
+ inputRange: [0, 1],
44
+ outputRange: ['0deg', '360deg'],
45
+ }),
46
+ });
47
+ animation.start();
48
+ }
49
+ } else {
50
+ if (state.animation != null) {
51
+ state.animation.stop();
52
+ setState({
53
+ animation: null,
54
+ rotate: null,
55
+ });
56
+ }
57
+ }
58
+
59
+ return () => {
60
+ if (state.animation != null) {
61
+ state.animation.stop();
62
+ }
63
+ };
64
+ }, [props.status, state.animation]);
65
+
66
+ let image;
67
+ let color;
68
+ switch (props.status) {
69
+ case 'FAILED':
70
+ image = require('@expo/metro-runtime/assets/alert-triangle.png');
71
+ color = LogBoxStyle.getErrorColor(1);
72
+ break;
73
+ case 'PENDING':
74
+ image = require('@expo/metro-runtime/assets/loader.png');
75
+ color = LogBoxStyle.getWarningColor(1);
76
+ break;
77
+ }
78
+
79
+ if (props.status === 'COMPLETE' || image == null) {
80
+ return null;
81
+ }
82
+
83
+ return (
84
+ <LogBoxButton
85
+ backgroundColor={{
86
+ default: 'transparent',
87
+ pressed: LogBoxStyle.getBackgroundColor(1),
88
+ }}
89
+ hitSlop={{ bottom: 8, left: 8, right: 8, top: 8 }}
90
+ onPress={props.onPress}
91
+ style={styles.root}>
92
+ <Animated.Image
93
+ source={image}
94
+ tintColor={color ?? LogBoxStyle.getTextColor(0.4)}
95
+ style={[
96
+ styles.image,
97
+ state.rotate == null || props.status !== 'PENDING'
98
+ ? null
99
+ : { transform: [{ rotate: state.rotate }] },
100
+ ]}
101
+ />
102
+ <Text style={[styles.text, { color }]}>Source Map</Text>
103
+ </LogBoxButton>
104
+ );
105
+ }
106
+
107
+ const styles = StyleSheet.create({
108
+ root: {
109
+ alignItems: 'center',
110
+ borderRadius: 12,
111
+ flexDirection: 'row',
112
+ height: 24,
113
+ paddingHorizontal: 8,
114
+ },
115
+ image: {
116
+ height: 14,
117
+ width: 16,
118
+ marginEnd: 4,
119
+ },
120
+ text: {
121
+ fontSize: 12,
122
+ includeFontPadding: false,
123
+ lineHeight: 16,
124
+ },
125
+ });
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { GestureResponderEvent, StyleSheet, Text, View } from 'react-native';
10
+ import { StackFrame } from 'stacktrace-parser';
11
+
12
+ import { LogBoxButton } from '../UI/LogBoxButton';
13
+ import * as LogBoxStyle from '../UI/LogBoxStyle';
14
+ import { CODE_FONT } from '../UI/constants';
15
+ import { getStackFormattedLocation } from '../formatProjectFilePath';
16
+
17
+ declare const process: any;
18
+
19
+ type Props = {
20
+ frame: StackFrame & { collapse?: boolean };
21
+ onPress?: (event: GestureResponderEvent) => void;
22
+ };
23
+
24
+ export function LogBoxInspectorStackFrame(props: Props) {
25
+ const { frame, onPress } = props;
26
+ const location = getStackFormattedLocation(process.env.EXPO_PROJECT_ROOT, frame);
27
+ return (
28
+ <View style={styles.frameContainer}>
29
+ <LogBoxButton
30
+ backgroundColor={{
31
+ default: 'transparent',
32
+ pressed: onPress ? LogBoxStyle.getBackgroundColor(1) : 'transparent',
33
+ }}
34
+ onPress={onPress}
35
+ style={styles.frame}>
36
+ <Text style={[styles.name, frame.collapse === true && styles.dim]}>{frame.methodName}</Text>
37
+ <Text
38
+ ellipsizeMode="middle"
39
+ numberOfLines={1}
40
+ style={[styles.location, frame.collapse === true && styles.dim]}>
41
+ {location}
42
+ </Text>
43
+ </LogBoxButton>
44
+ </View>
45
+ );
46
+ }
47
+
48
+ const styles = StyleSheet.create({
49
+ frameContainer: {
50
+ flexDirection: 'row',
51
+ paddingHorizontal: 15,
52
+ },
53
+ frame: {
54
+ flex: 1,
55
+ paddingVertical: 4,
56
+ paddingHorizontal: 10,
57
+ borderRadius: 5,
58
+ },
59
+ lineLocation: {
60
+ flexDirection: 'row',
61
+ },
62
+ name: {
63
+ color: LogBoxStyle.getTextColor(1),
64
+ fontSize: 14,
65
+ includeFontPadding: false,
66
+ lineHeight: 18,
67
+ fontWeight: '400',
68
+ fontFamily: CODE_FONT,
69
+ },
70
+ location: {
71
+ color: LogBoxStyle.getTextColor(0.8),
72
+ fontSize: 12,
73
+ fontWeight: '300',
74
+ includeFontPadding: false,
75
+ lineHeight: 16,
76
+ paddingLeft: 10,
77
+ },
78
+ dim: {
79
+ color: LogBoxStyle.getTextColor(0.4),
80
+ fontWeight: '300',
81
+ },
82
+ line: {
83
+ color: LogBoxStyle.getTextColor(0.8),
84
+ fontSize: 12,
85
+ fontWeight: '300',
86
+ includeFontPadding: false,
87
+ lineHeight: 16,
88
+ },
89
+ });