Documentation Index Fetch the complete documentation index at: https://mintlify.com/ragaeeb/dyelight/llms.txt
Use this file to discover all available pages before exploring further.
DyeLight is written in TypeScript and provides comprehensive type definitions for all its APIs.
CharacterRange
Represents a character range to highlight in the entire text using absolute positions.
type CharacterRange = {
/** Zero-based start index in the entire text (inclusive) */
start : number ;
/** Zero-based end index in the entire text (exclusive) */
end : number ;
/** Optional CSS class name to apply to the highlighted range */
className ?: string ;
/** Optional inline styles to apply to the highlighted range */
style ?: React . CSSProperties ;
};
Example:
const highlight : CharacterRange = {
start: 0 ,
end: 5 ,
className: 'highlight-keyword' ,
style: { backgroundColor: 'yellow' , fontWeight: 'bold' }
};
DyeLightProps
Props for the DyeLight component. Extends standard textarea props while replacing onChange with a simplified version.
Controlled value of the textarea.
Default value for uncontrolled usage.
Callback fired when the textarea value changes. Simplified from the standard React onChange signature.
Character range highlights using absolute positions in the entire text.
lineHighlights
{ [lineNumber: number]: string }
Line-level highlights mapped by line number (0-based) to CSS color or class name.
Enable automatic height adjustment based on content.
Number of visible text lines.
CSS class name for the textarea element.
CSS class name for the container wrapper element.
dir
'ltr' | 'rtl'
default: "'ltr'"
Text direction - supports left-to-right and right-to-left.
Enable debug mode to collect telemetry data.
Maximum number of telemetry events to retain in memory.
Type definition:
interface DyeLightProps extends Omit < React . TextareaHTMLAttributes < HTMLTextAreaElement >, 'onChange' > {
className ?: string ;
containerClassName ?: string ;
defaultValue ?: string ;
dir ?: 'ltr' | 'rtl' ;
enableAutoResize ?: boolean ;
highlights ?: CharacterRange [];
lineHighlights ?: { [ lineNumber : number ] : string };
onChange ?: ( value : string ) => void ;
rows ?: number ;
value ?: string ;
debug ?: boolean ;
debugMaxEvents ?: number ;
}
DyeLightRef
Methods exposed by the DyeLight component through its ref. Provides programmatic access to common textarea operations and debug features.
Gets the current value of the textarea.
Sets the value of the textarea programmatically.
Sets focus to the textarea.
Removes focus from the textarea.
Selects all text in the textarea.
setSelectionRange
(start: number, end: number) => void
Sets the selection range in the textarea.
scrollToPosition
(pos: number, offset?: number, behavior?: ScrollBehavior) => void
Scrolls the character position into view with an optional pixel offset.
Exports AI-optimized debug report as JSON string (requires debug mode). The report includes value deduplication - large text values are stored once in a valueRegistry and referenced as <REF:value_N> to reduce JSON size.
Type definition:
type DyeLightRef = {
blur : () => void ;
focus : () => void ;
getValue : () => string ;
select : () => void ;
setSelectionRange : ( start : number , end : number ) => void ;
setValue : ( value : string ) => void ;
scrollToPosition : ( pos : number , offset ?: number , behavior ?: ScrollBehavior ) => void ;
exportForAI : () => string ;
};
Example:
import { useRef } from 'react' ;
import type { DyeLightRef } from 'dyelight' ;
const MyComponent = () => {
const dyeLightRef = useRef < DyeLightRef >( null );
const handleFocus = () => {
dyeLightRef . current ?. focus ();
};
const handleGetValue = () => {
const value = dyeLightRef . current ?. getValue ();
console . log ( 'Current value:' , value );
};
const handleExportDebug = async () => {
const report = dyeLightRef . current ?. exportForAI ();
if ( report ) {
await navigator . clipboard . writeText ( report );
alert ( 'Debug report copied to clipboard' );
}
};
return (
<>
< DyeLight ref = { dyeLightRef } debug = { true } />
< button onClick = { handleExportDebug } > Export Debug Report </ button >
</>
);
};
AITelemetryEvent
Represents a single telemetry event with full context. Used in debug mode to track component behavior.
Unix timestamp in milliseconds.
ISO 8601 formatted timestamp.
Milliseconds since the last event, or null for first event.
Event type identifier (e.g., ‘onChange’, ‘syncStyles’, ‘selectionChange’).
category
'state' | 'dom' | 'sync' | 'user' | 'system'
Event category for grouping and analysis.
Human-readable description of the event.
Event-specific data payload.
Complete state snapshot at the time of this event. Show State snapshot fields
Actual value in the textarea DOM element (may be <REF:value_N> if deduplicated).
Value in React state (may be <REF:value_N> if deduplicated).
Whether DOM and React state are synchronized.
Current height of the textarea in pixels.
Whether the component is in controlled mode.
Textarea selection/caret state when available.
start: number | null
end: number | null
direction: ‘forward’ | ‘backward’ | ‘none’ | null
Textarea geometry measurements at this event (clientWidth, clientHeight, scrollWidth, scrollHeight, etc.).
Overlay geometry measurements when available.
Derived deltas to quickly detect visual divergence (contentWidthDelta, contentHeightDelta, scrollTopDelta, scrollLeftDelta).
Signals for identifying style ownership conflicts.
Detected anomalies or issues at this event.
Type definition:
type AITelemetryEvent = {
timestamp : number ;
timestampISO : string ;
timeSinceLastEvent : number | null ;
type : string ;
category : 'state' | 'dom' | 'sync' | 'user' | 'system' ;
description : string ;
data : Record < string , unknown >;
stateSnapshot : {
textareaValue : string ;
reactValue : string ;
valuesMatch : boolean ;
textareaHeight : number | undefined ;
isControlled : boolean ;
selection ?: {
start : number | null ;
end : number | null ;
direction : 'forward' | 'backward' | 'none' | null ;
};
textareaMetrics ?: { /* ... */ };
overlayMetrics ?: { /* ... */ };
layoutDeltas ?: { /* ... */ };
styleOwnership ?: { /* ... */ };
};
anomalies : string [];
};
AIDebugReport
Complete AI-readable debug report structure returned by exportForAI().
Metadata about the report and environment. When this report was generated (ISO timestamp).
Total number of events recorded.
Time range covered by events.
start: ISO timestamp of first event
end: ISO timestamp of last event
durationMs: Duration in milliseconds
Browser user agent string.
Analysis summary with detected issues. High-level description of findings.
List of detected issues sorted by severity. Each issue includes:
severity: ‘critical’ | ‘warning’ | ‘info’
issue: Issue description
firstOccurrence: When this issue first occurred
occurrenceCount: How many times this issue occurred
relatedEvents: Event indices where this issue occurred
Suspicious patterns detected in event sequences.
Recommended actions to resolve issues.
Different views of the event timeline. User interactions and their impacts.
All state mutations in chronological order.
Synchronization operations between textarea and overlay.
Complete chronological list of all events.
Final state at time of export. Current textarea DOM value (may be <REF:value_N>).
Current React state value (may be <REF:value_N>).
Whether values are synchronized.
Current height in pixels.
Current scroll position (top and left).
Current highlights configuration.
valueRegistry
{ [key: string]: string }
Value registry for deduplicated text values. Large text values (>1000 chars) are stored here once and referenced as <REF:value_N>. This dramatically reduces JSON size when the same large text appears in many events.
Type definition:
type AIDebugReport = {
metadata : {
generatedAt : string ;
componentVersion : string ;
totalEvents : number ;
timespan : {
start : string ;
end : string ;
durationMs : number ;
};
browser : string ;
platform : string ;
};
summary : {
description : string ;
detectedIssues : Array <{
severity : 'critical' | 'warning' | 'info' ;
issue : string ;
firstOccurrence : string ;
occurrenceCount : number ;
relatedEvents : number [];
}>;
suspiciousPatterns : string [];
recommendations : string [];
};
timeline : {
userActions : Array <{ /* ... */ }>;
stateChanges : Array <{ /* ... */ }>;
syncOperations : Array <{ /* ... */ }>;
};
events : AITelemetryEvent [];
finalState : {
textareaValue : string ;
reactValue : string ;
inSync : boolean ;
height : number | undefined ;
scrollPosition : { top : number ; left : number };
highlights : unknown [];
};
valueRegistry : { [ key : string ] : string };
};
Example:
const report = editorRef . current ?. exportForAI ();
if ( report ) {
const parsed : AIDebugReport = JSON . parse ( report );
// Check for critical issues
const criticalIssues = parsed . summary . detectedIssues . filter (
issue => issue . severity === 'critical'
);
// Access deduplicated values
const firstEventValue = parsed . events [ 0 ]. stateSnapshot . textareaValue ;
if ( firstEventValue . startsWith ( '<REF:' )) {
const actualValue = parsed . valueRegistry [ firstEventValue ];
console . log ( 'Actual value:' , actualValue );
}
}