UNPKG

supapup

Version:

⚡ Lightning-fast MCP browser dev tool. Navigate → Get instant structured data. No screenshots needed! Puppeteer: 📸 → CSS selectors → JS eval. Supapup: semantic IDs ready to use. 10x faster, 90% fewer tokens.

79 lines 2.47 kB
/** * PageSettleDetector V2 - Honest about what we can and cannot detect * * What we CAN reliably detect: * - DOM mutations (additions, removals, attribute changes) * - Network activity * - Navigation events * - Specific element appearance/disappearance * * What we CANNOT reliably detect without heuristics: * - When all JavaScript execution is "done" * - When all animations are complete * - When all async operations are finished * * Our approach: * 1. Use MutationObserver for DOM changes (reliable) * 2. Use network idle detection (reliable) * 3. Use debouncing to wait for mutation "settling" (heuristic) * 4. Provide options for specific expectations (most reliable) */ import { Page } from 'puppeteer'; export interface SettleExpectations { elementToAppear?: string; elementToDisappear?: string; textToAppear?: string; urlPattern?: RegExp; waitForDOMQuiet?: boolean; domQuietTime?: number; waitForNetworkIdle?: boolean; networkIdleTime?: number; timeout?: number; } export interface SettleResultV2 { expectations: { elementAppeared?: boolean; elementDisappeared?: boolean; textAppeared?: boolean; urlMatched?: boolean; domQuiet?: boolean; networkIdle?: boolean; }; mutations: { total: number; additions: number; removals: number; attributes: number; }; duration: number; timedOut: boolean; } export declare class PageSettleDetectorV2 { private page; constructor(page: Page); /** * Wait for page to settle based on specific expectations * This is the most reliable approach - tell us what you expect! */ waitForExpectedChanges(expectations: SettleExpectations): Promise<SettleResultV2>; /** * Perform action and wait for expected changes * This encourages users to specify what they expect */ performActionAndWaitFor(action: () => Promise<any>, expectations: SettleExpectations): Promise<{ actionResult: any; settleResult: SettleResultV2; }>; /** * Legacy method that uses heuristics (less reliable) */ performActionAndGuessSettlement(action: () => Promise<any>, options?: { domQuietTime?: number; networkIdleTime?: number; timeout?: number; }): Promise<{ actionResult: any; settleResult: SettleResultV2; }>; } //# sourceMappingURL=page-settle-detector-v2.d.ts.map