(content: string)
| 499 | } |
| 500 | |
| 501 | const extractZedTheme = (content: string): ThemeName | null => { |
| 502 | try { |
| 503 | const sanitized = stripJsonStyleComments(content) |
| 504 | const parsed = JSON.parse(sanitized) as Record<string, unknown> |
| 505 | const candidates: unknown[] = [] |
| 506 | |
| 507 | const themeSetting = parsed.theme |
| 508 | if (typeof themeSetting === 'string') { |
| 509 | candidates.push(themeSetting) |
| 510 | } else if (themeSetting && typeof themeSetting === 'object') { |
| 511 | const themeConfig = themeSetting as Record<string, unknown> |
| 512 | const modeRaw = themeConfig.mode |
| 513 | if (typeof modeRaw === 'string') { |
| 514 | const mode = modeRaw.toLowerCase() |
| 515 | // If mode is 'system', return null to trigger platform detection |
| 516 | if (mode === 'system') { |
| 517 | return null |
| 518 | } |
| 519 | if (mode === 'dark' || mode === 'light') { |
| 520 | candidates.push(mode) |
| 521 | const modeTheme = themeConfig[mode] |
| 522 | if (typeof modeTheme === 'string') { |
| 523 | candidates.push(modeTheme) |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | const darkTheme = themeConfig.dark |
| 529 | if (typeof darkTheme === 'string') { |
| 530 | candidates.push(darkTheme) |
| 531 | } |
| 532 | |
| 533 | const lightTheme = themeConfig.light |
| 534 | if (typeof lightTheme === 'string') { |
| 535 | candidates.push(lightTheme) |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | const appearance = parsed.appearance |
| 540 | if (appearance && typeof appearance === 'object') { |
| 541 | const appearanceTheme = (appearance as Record<string, unknown>).theme |
| 542 | if (typeof appearanceTheme === 'string') { |
| 543 | candidates.push(appearanceTheme) |
| 544 | } |
| 545 | |
| 546 | const preference = (appearance as Record<string, unknown>) |
| 547 | .theme_preference |
| 548 | if (typeof preference === 'string') { |
| 549 | candidates.push(preference) |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | const ui = parsed.ui |
| 554 | if (ui && typeof ui === 'object') { |
| 555 | const uiTheme = (ui as Record<string, unknown>).theme |
| 556 | if (typeof uiTheme === 'string') { |
| 557 | candidates.push(uiTheme) |
| 558 | } |
no test coverage detected