mirror of
https://gitverse.ru/anarchic/claude-code
synced 2026-05-04 15:30:32 +00:00
new initial commit (history rewritten)
This commit is contained in:
commit
c1996f2e3b
1907 changed files with 514172 additions and 0 deletions
487
components/StructuredDiff/Fallback.tsx
Normal file
487
components/StructuredDiff/Fallback.tsx
Normal file
File diff suppressed because one or more lines are too long
37
components/StructuredDiff/colorDiff.ts
Normal file
37
components/StructuredDiff/colorDiff.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import {
|
||||
ColorDiff,
|
||||
ColorFile,
|
||||
getSyntaxTheme as nativeGetSyntaxTheme,
|
||||
type SyntaxTheme,
|
||||
} from 'color-diff-napi'
|
||||
import { isEnvDefinedFalsy } from '../../utils/envUtils.js'
|
||||
|
||||
export type ColorModuleUnavailableReason = 'env'
|
||||
|
||||
/**
|
||||
* Returns a static reason why the color-diff module is unavailable, or null if available.
|
||||
* 'env' = disabled via CLAUDE_CODE_SYNTAX_HIGHLIGHT
|
||||
*
|
||||
* The TS port of color-diff works in all build modes, so the only way to
|
||||
* disable it is via the env var.
|
||||
*/
|
||||
export function getColorModuleUnavailableReason(): ColorModuleUnavailableReason | null {
|
||||
if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_SYNTAX_HIGHLIGHT)) {
|
||||
return 'env'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function expectColorDiff(): typeof ColorDiff | null {
|
||||
return getColorModuleUnavailableReason() === null ? ColorDiff : null
|
||||
}
|
||||
|
||||
export function expectColorFile(): typeof ColorFile | null {
|
||||
return getColorModuleUnavailableReason() === null ? ColorFile : null
|
||||
}
|
||||
|
||||
export function getSyntaxTheme(themeName: string): SyntaxTheme | null {
|
||||
return getColorModuleUnavailableReason() === null
|
||||
? nativeGetSyntaxTheme(themeName)
|
||||
: null
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue