({store, compilerOutput}: Props)
| 256 | } |
| 257 | |
| 258 | function OutputContent({store, compilerOutput}: Props): JSX.Element { |
| 259 | const [tabsOpen, setTabsOpen] = useState<Set<string>>( |
| 260 | () => new Set(['Output']), |
| 261 | ); |
| 262 | const [activeTab, setActiveTab] = useState<string>('Output'); |
| 263 | |
| 264 | /* |
| 265 | * Update the active tab back to the output or errors tab when the compilation state |
| 266 | * changes between success/failure. |
| 267 | */ |
| 268 | const [previousOutputKind, setPreviousOutputKind] = useState( |
| 269 | compilerOutput.kind, |
| 270 | ); |
| 271 | if (compilerOutput.kind !== previousOutputKind) { |
| 272 | setPreviousOutputKind(compilerOutput.kind); |
| 273 | setTabsOpen(new Set(['Output'])); |
| 274 | setActiveTab('Output'); |
| 275 | } |
| 276 | const changedPasses: Set<string> = new Set(['Output', 'HIR']); // Initial and final passes should always be bold |
| 277 | let lastResult: string = ''; |
| 278 | for (const [passName, results] of compilerOutput.results) { |
| 279 | for (const result of results) { |
| 280 | let currResult = ''; |
| 281 | if (result.kind === 'hir' || result.kind === 'reactive') { |
| 282 | currResult += `function ${result.fnName}\n\n${result.value}`; |
| 283 | } |
| 284 | if (currResult !== lastResult) { |
| 285 | changedPasses.add(passName); |
| 286 | } |
| 287 | lastResult = currResult; |
| 288 | } |
| 289 | } |
| 290 | const tabs = use(tabifyCached(store, compilerOutput)); |
| 291 | |
| 292 | if (!store.showInternals) { |
| 293 | return ( |
| 294 | <ViewTransition |
| 295 | update={{ |
| 296 | [CONFIG_PANEL_TRANSITION]: 'container', |
| 297 | [TOGGLE_INTERNALS_TRANSITION]: '', |
| 298 | default: 'none', |
| 299 | }}> |
| 300 | <TabbedWindow |
| 301 | tabs={tabs} |
| 302 | activeTab={activeTab} |
| 303 | onTabChange={setActiveTab} |
| 304 | /> |
| 305 | </ViewTransition> |
| 306 | ); |
| 307 | } |
| 308 | |
| 309 | return ( |
| 310 | <ViewTransition |
| 311 | update={{ |
| 312 | [CONFIG_PANEL_TRANSITION]: 'accordion-container', |
| 313 | [TOGGLE_INTERNALS_TRANSITION]: '', |
| 314 | default: 'none', |
| 315 | }}> |
nothing calls this directly
no test coverage detected