@0x1js/highlighter
Version:
67 lines (56 loc) • 2.4 kB
TypeScript
/**
* 0x1 Syntax Highlighter - Enhanced Type Declarations
* Production-ready types with full React/0x1 compatibility
*/
export interface HighlightOptions {
language: 'javascript' | 'typescript' | 'bash' | 'json' | 'html' | 'css';
theme?: 'dark' | 'light' | 'violet';
showLineNumbers?: boolean;
startLineNumber?: number;
maxLines?: number;
wrapLines?: boolean;
}
export interface Token {
type: 'keyword' | 'string' | 'comment' | 'number' | 'operator' | 'function' | 'variable' | 'type' | 'property' | 'constant' | 'plain';
value: string;
start: number;
end: number;
}
export interface SyntaxHighlighterProps extends HighlightOptions {
children: string;
className?: string;
style?: React.CSSProperties;
copyable?: boolean;
title?: string;
footer?: string;
onCopy?: (code: string) => void;
}
export declare function highlight(code: string, options: HighlightOptions): string;
export declare function tokenizeJavaScript(code: string): Token[];
export declare function tokenizeBash(code: string): Token[];
export declare function getSupportedLanguages(): string[];
export declare function SyntaxHighlighter(props: SyntaxHighlighterProps): JSX.Element;
export declare function JavaScriptHighlighter(props: Omit<SyntaxHighlighterProps, 'language'>): JSX.Element;
export declare function TypeScriptHighlighter(props: Omit<SyntaxHighlighterProps, 'language'>): JSX.Element;
export declare function BashHighlighter(props: Omit<SyntaxHighlighterProps, 'language'>): JSX.Element;
export declare function JSONHighlighter(props: Omit<SyntaxHighlighterProps, 'language'>): JSX.Element;
export declare function InlineCode(props: { children: string; language?: HighlightOptions['language']; theme?: HighlightOptions['theme']; }): JSX.Element;
export declare function useHighlight(code: string, options: HighlightOptions): string;
export declare const version: string;
declare const _default: {
highlight: typeof highlight;
tokenizeJavaScript: typeof tokenizeJavaScript;
tokenizeBash: typeof tokenizeBash;
getSupportedLanguages: typeof getSupportedLanguages;
version: string;
};
export default _default;
// Enhanced module resolution for browser environments
declare module '@0x1js/highlighter' {
export * from './index';
export { default } from './index';
}
declare module '@0x1js/highlighter/styles' {
const styles: string;
export default styles;
}