export type AnnouncerPriority = "polite" | "assertive"; export interface PagefindSearchResult { results: PagefindRawResult[]; filters?: FilterCounts; totalFilters?: FilterCounts; unfilteredTotalCount?: number; } export interface PagefindRawResult { id: string; data: () => Promise; } export interface PagefindResultData { url: string; excerpt: string; meta: Record; sub_results?: PagefindSubResult[]; locations?: number[]; weighted_locations?: WeightedLocation[]; filters?: Record; anchors?: PagefindAnchor[]; content?: string; word_count?: number; } export interface PagefindSubResult { url: string; title: string; excerpt: string; locations?: number[]; weighted_locations?: WeightedLocation[]; anchors?: PagefindAnchor[]; } export interface WeightedLocation { weight: number; balanced_score: number; location: number; } export interface PagefindAnchor { element: string; id: string; text?: string; location?: number; } export type FilterCounts = Record>; export type FilterSelection = Record; export interface InstanceOptions { bundlePath?: string; mergeIndex?: MergeIndexConfig[]; [key: string]: unknown; } export interface MergeIndexConfig { bundlePath: string; [key: string]: unknown; } export type InstanceEventMap = { search: [term: string, filters: FilterSelection]; filters: [data: { available: FilterCounts; total: FilterCounts; }]; loading: []; results: [results: PagefindSearchResult]; error: [error: PagefindError]; translations: [translations: TranslationStrings, direction: TextDirection]; }; export type InstanceEvent = keyof InstanceEventMap; export interface PagefindError { type?: string; message: string; bundlePath?: string; error?: Error; } export type TextDirection = "ltr" | "rtl"; export interface TranslationStrings { language: string; direction: TextDirection; [key: string]: string | TextDirection; } export interface TranslationFile { thanks_to?: string; comments?: string; direction?: TextDirection; strings: Record; } export interface ComponentCapabilities { keyboardNavigation?: boolean; announcements?: boolean; [key: string]: unknown; } export interface Shortcut { label: string; description: string; owner?: Element; } export type HookCallback = (...args: unknown[]) => void; export interface HookEntry { callback: HookCallback; owner?: Element; } export interface PagefindAPI { options: (opts: Record) => Promise; search: (term: string | null, options?: { filters?: FilterSelection; }) => Promise; filters: () => Promise; mergeIndex: (url: string, options?: Record) => Promise; destroy?: () => void; }