@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
39 lines (38 loc) • 1.79 kB
TypeScript
import type { ShimmerColorGradient, ShimmerColorRgb, ShimmerDirection, ShimmerState } from './types';
// Re-export types for backward compatibility.
export type { ShimmerColor, ShimmerColorGradient, ShimmerColorInherit, ShimmerColorRgb, ShimmerConfig, ShimmerDirection, ShimmerState, } from './types';
/**
* Detected text formatting styles from ANSI codes.
*/
type TextStyles = {
bold: boolean;
dim: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
};
// Internal options for applyShimmer function.
type ShimmerOptions = {
readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined;
readonly direction?: ShimmerDirection | undefined;
readonly shimmerWidth?: number | undefined;
readonly styles?: TextStyles | undefined;
readonly theme?: import('../themes/types').Theme | import('../themes/themes').ThemeName | undefined;
};
export declare const COLOR_INHERIT = "inherit";
export declare const DIR_LTR = "ltr";
export declare const DIR_NONE = "none";
export declare const DIR_RANDOM = "random";
export declare const DIR_RTL = "rtl";
export declare const MODE_BI = "bi";
/**
* Apply shimmer animation effect to text.
* This is the main entry point for shimmer animations. It:
* 1. Strips ANSI codes to get plain text for character positioning
* 2. Detects any styling (bold, italic, underline, etc.) to preserve
* 3. Calculates the current shimmer wave position based on animation step
* 4. Renders each character with appropriate brightness based on distance from wave
* 5. Updates the animation state for the next frame
* 6. Handles direction changes for bidirectional and random modes
*/
export declare function applyShimmer(text: string, state: ShimmerState, options?: ShimmerOptions | undefined): string;