import type Hook from '../util/hook'; export type RootElement = Document | HTMLElement; export interface HighlighterOptions { $root?: RootElement; exceptSelectors?: string[]; wrapTag?: string; verbose?: boolean; style?: { className?: string[] | string; }; } export interface PainterOptions { $root: RootElement; wrapTag: string; className: string[] | string; exceptSelectors: string[]; } /** * how the native selection should be handled after a highlight is created * - keep: leave it to the caller (the default of .fromRange) * - clear: drop the native selection * - restore: select the created wrappers */ export type SelectionMode = 'keep' | 'clear' | 'restore'; export interface FromRangeOptions { selection?: SelectionMode; } /** * Controls how much evidence `getDiagnostics()` includes. * The default is safe: no DOM HTML and no persisted source text. */ export interface DiagnosticOptions { /** Include root DOM evidence: `none` (default), `redacted`, or explicit `full` HTML. */ dom?: 'none' | 'redacted' | 'full'; /** Include persisted sources: metadata (default) or explicit full source objects. */ sources?: 'metadata' | 'full'; /** Limit exported DOM HTML in redacted/full modes. Defaults to 20,000 characters. */ maxDomLength?: number; } /** * A reproducible runtime snapshot for bug reports. * DOM and source text are included only when explicitly requested through `DiagnosticOptions`. */ export interface DiagnosticSnapshot { libraryVersion: string; timestamp: string; lifecycle: { isRunning: boolean; isDisposed: boolean; }; runtime: { userAgent: string; platform?: string; language: string; viewport?: { width: number; height: number; }; capabilities: { selection: boolean; range: boolean; touch: boolean; }; }; configuration: { root: { nodeName: string; id: string | null; className: string | null; }; wrapTag: string; exceptSelectors: string[] | null; verbose: boolean; }; selection: { rangeCount: number; isCollapsed: boolean; textLength: number; start?: { nodeType: number; nodeName: string; offset: number; }; end?: { nodeType: number; nodeName: string; offset: number; }; }; highlights: { wrapperCount: number; sourceCount: number; sources: Array<{ id: string; textLength: number; startMeta: DomMeta; endMeta: DomMeta; }>; }; errors: Array<{ type: ERROR; message?: string; sourceId?: string; }>; document?: { mode: 'redacted' | 'full'; html: string; originalLength: number; truncated: boolean; }; fullSources?: Array<{ startMeta: DomMeta; endMeta: DomMeta; text: string; id: string; extra?: unknown; }>; } export declare enum SplitType { none = "none", head = "head", tail = "tail", both = "both" } export declare enum ERROR { DOM_TYPE_ERROR = "[DOM] Receive wrong node type.", DOM_SELECTION_EMPTY = "[DOM] The selection contains no dom node, may be you except them.", RANGE_INVALID = "[RANGE] Got invalid dom range, can't convert to a valid highlight range.", RANGE_NODE_INVALID = "[RANGE] Start or end node isn't a text node, it may occur an error.", RANGE_OUT_OF_ROOT = "[RANGE] Start or end node is outside the root node.", DB_ID_DUPLICATE_ERROR = "[STORE] Unique id conflict.", CACHE_SET_ERROR = "[CACHE] Cache.data can't be set manually, please use .save().", SOURCE_TYPE_ERROR = "[SOURCE] Object isn't a highlight source instance.", HIGHLIGHT_RANGE_FROZEN = "[HIGHLIGHT_RANGE] A highlight range must be frozen before render.", HIGHLIGHT_SOURCE_RECREATE = "[HIGHLIGHT_SOURCE] Recreate highlights from sources error.", HIGHLIGHT_SOURCE_NONE_RENDER = "[HIGHLIGHT_SOURCE] This highlight source isn't rendered. May be the exception skips it or the dom structure has changed." } export declare enum EventType { CREATE = "selection:create", REMOVE = "selection:remove", MODIFY = "selection:modify", HOVER = "selection:hover", HOVER_OUT = "selection:hover-out", CLICK = "selection:click" } export declare enum CreateFrom { STORE = "from-store", INPUT = "from-input" } export declare enum SelectedNodeType { text = "text", span = "span" } export interface SelectedNode { $node: Node | Text; type: SelectedNodeType; splitType: SplitType; } export interface DomMeta { parentTagName: string; parentIndex: number; textOffset: number; extra?: unknown; } export interface DomNode { $node: Node; offset: number; } export interface HighlightPosition { start: { top: number; left: number; }; end: { top: number; left: number; }; } export interface HookMap { Render: { UUID: Hook; SelectedNodes: Hook; WrapNode: Hook; }; Serialize: { Restore: Hook; RecordInfo: Hook; }; Remove: { UpdateNodes: Hook; }; } export declare enum UserInputEvent { touchend = "touchend", mouseup = "mouseup", touchstart = "touchstart", click = "click", mouseover = "mouseover" } export interface IInteraction { PointerEnd: UserInputEvent; PointerTap: UserInputEvent; PointerOver: UserInputEvent; }