|
1 | | -import { c as _c } from "react/compiler-runtime"; |
2 | 1 | import axios from 'axios'; |
3 | 2 | import React, { useEffect, useState } from 'react'; |
4 | 3 | import { logEvent } from 'src/services/analytics/index.js'; |
@@ -75,76 +74,61 @@ async function checkEndpoints(): Promise<PreflightCheckResult> { |
75 | 74 | interface PreflightStepProps { |
76 | 75 | onSuccess: () => void; |
77 | 76 | } |
78 | | -export function PreflightStep(t0) { |
79 | | - const $ = _c(12); |
80 | | - const { |
81 | | - onSuccess |
82 | | - } = t0; |
83 | | - const [result, setResult] = useState(null); |
| 77 | +export function PreflightStep({ onSuccess }: PreflightStepProps) { |
| 78 | + const [result, setResult] = useState<PreflightCheckResult | null>(null); |
84 | 79 | const [isChecking, setIsChecking] = useState(true); |
85 | 80 | const showSpinner = useTimeout(1000) && isChecking; |
86 | | - let t1; |
87 | | - let t2; |
88 | | - if ($[0] === Symbol.for("react.memo_cache_sentinel")) { |
89 | | - t1 = () => { |
90 | | - const run = async function run() { |
91 | | - const checkResult = await checkEndpoints(); |
92 | | - setResult(checkResult); |
93 | | - setIsChecking(false); |
94 | | - }; |
95 | | - run(); |
96 | | - }; |
97 | | - t2 = []; |
98 | | - $[0] = t1; |
99 | | - $[1] = t2; |
100 | | - } else { |
101 | | - t1 = $[0]; |
102 | | - t2 = $[1]; |
103 | | - } |
104 | | - useEffect(t1, t2); |
105 | | - let t3; |
106 | | - let t4; |
107 | | - if ($[2] !== onSuccess || $[3] !== result) { |
108 | | - t3 = () => { |
109 | | - if (result?.success) { |
110 | | - onSuccess(); |
111 | | - } else { |
112 | | - if (result && !result.success) { |
113 | | - const timer = setTimeout(_temp, 100); |
114 | | - return () => clearTimeout(timer); |
115 | | - } |
116 | | - } |
117 | | - }; |
118 | | - t4 = [result, onSuccess]; |
119 | | - $[2] = onSuccess; |
120 | | - $[3] = result; |
121 | | - $[4] = t3; |
122 | | - $[5] = t4; |
123 | | - } else { |
124 | | - t3 = $[4]; |
125 | | - t4 = $[5]; |
126 | | - } |
127 | | - useEffect(t3, t4); |
128 | | - let t5; |
129 | | - if ($[6] !== isChecking || $[7] !== result || $[8] !== showSpinner) { |
130 | | - t5 = isChecking && showSpinner ? <Box paddingLeft={1}><Spinner /><Text>Checking connectivity...</Text></Box> : !result?.success && !isChecking && <Box flexDirection="column" gap={1}><Text color="error">Unable to connect to Anthropic services</Text><Text color="error">{result?.error}</Text>{result?.sslHint ? <Box flexDirection="column" gap={1}><Text>{result.sslHint}</Text><Text color="suggestion">See https://code.claude.com/docs/en/network-config</Text></Box> : <Box flexDirection="column" gap={1}><Text>Please check your internet connection and network settings.</Text><Text>Note: Claude Code might not be available in your country. Check supported countries at{" "}<Text color="suggestion">https://anthropic.com/supported-countries</Text></Text></Box>}</Box>; |
131 | | - $[6] = isChecking; |
132 | | - $[7] = result; |
133 | | - $[8] = showSpinner; |
134 | | - $[9] = t5; |
135 | | - } else { |
136 | | - t5 = $[9]; |
137 | | - } |
138 | | - let t6; |
139 | | - if ($[10] !== t5) { |
140 | | - t6 = <Box flexDirection="column" gap={1} paddingLeft={1}>{t5}</Box>; |
141 | | - $[10] = t5; |
142 | | - $[11] = t6; |
143 | | - } else { |
144 | | - t6 = $[11]; |
| 81 | + |
| 82 | + useEffect(() => { |
| 83 | + checkEndpoints().then((checkResult) => { |
| 84 | + setResult(checkResult); |
| 85 | + setIsChecking(false); |
| 86 | + }); |
| 87 | + }, []); |
| 88 | + |
| 89 | + useEffect(() => { |
| 90 | + if (result?.success) { |
| 91 | + onSuccess(); |
| 92 | + } else if (result && !result.success) { |
| 93 | + logError(result.error ?? 'Preflight connectivity check failed'); |
| 94 | + onSuccess(); |
| 95 | + } |
| 96 | + }, [result, onSuccess]); |
| 97 | + |
| 98 | + let content = null; |
| 99 | + if (isChecking && showSpinner) { |
| 100 | + content = ( |
| 101 | + <Box paddingLeft={1}> |
| 102 | + <Spinner /> |
| 103 | + <Text>Checking connectivity...</Text> |
| 104 | + </Box> |
| 105 | + ); |
| 106 | + } else if (!result?.success && !isChecking) { |
| 107 | + content = ( |
| 108 | + <Box flexDirection="column" gap={1}> |
| 109 | + <Text color="error">Unable to connect to Anthropic services</Text> |
| 110 | + <Text color="error">{result?.error}</Text> |
| 111 | + {result?.sslHint ? ( |
| 112 | + <Box flexDirection="column" gap={1}> |
| 113 | + <Text>{result.sslHint}</Text> |
| 114 | + <Text color="suggestion">See https://code.claude.com/docs/en/network-config</Text> |
| 115 | + </Box> |
| 116 | + ) : ( |
| 117 | + <Box flexDirection="column" gap={1}> |
| 118 | + <Text>Please check your internet connection and network settings.</Text> |
| 119 | + <Text> |
| 120 | + Note: Claude Code might not be available in your country. Check supported countries at{" "} |
| 121 | + <Text color="suggestion">https://anthropic.com/supported-countries</Text> |
| 122 | + </Text> |
| 123 | + </Box> |
| 124 | + )} |
| 125 | + </Box> |
| 126 | + ); |
145 | 127 | } |
146 | | - return t6; |
147 | | -} |
148 | | -function _temp() { |
149 | | - return process.exit(1); |
| 128 | + |
| 129 | + return ( |
| 130 | + <Box flexDirection="column" gap={1} paddingLeft={1}> |
| 131 | + {content} |
| 132 | + </Box> |
| 133 | + ); |
150 | 134 | } |
0 commit comments