import { TestEngine, TestEnvironment } from "@accesslint/core"; import { Frame, Locator, Page } from "@playwright/test"; //#region ../matchers-internal/dist/audit.d.ts //#region src/audit.d.ts type Impact = "critical" | "serious" | "moderate" | "minor"; /** * Option shape shared between matcher packages. Packages extend this with * platform-specific fields — e.g. jest/vitest add `additionalRules` (which * requires the Node-DOM runner), Playwright adds `includeFrames` / * `includeShadowDom`. */ interface BaseAccessibleMatcherOptions { /** Rule IDs to disable for this assertion. */ disabledRules?: string[]; /** Include AAA-level rules (excluded by default). */ includeAAA?: boolean; /** * Skip page-level rules (html-has-lang, document-title, landmarks, etc.) * that don't apply to components rendered in isolation. */ componentMode?: boolean; /** Locale for translated rule messages (e.g. "en", "es"). */ locale?: string; /** * Minimum impact that causes the assertion to fail. * Violations below the threshold are ignored. */ failOn?: Impact; } //#endregion //#region src/audit.d.ts interface AccessibleMatcherOptions extends BaseAccessibleMatcherOptions { /** Also audit iframe content. Defaults to true for Page targets. */ includeFrames?: boolean; /** Also audit shadow DOM content. Defaults to true. */ includeShadowDom?: boolean; } /** * Options subset that `@accesslint/core`'s `runAudit` accepts in-page. Needs * to be JSON-serializable because `page.evaluate` sends it across the boundary. */ interface CoreAuditOptions { disabledRules?: string[]; includeAAA?: boolean; componentMode?: boolean; locale?: string; } interface AuditViolation { ruleId: string; selector: string; html: string; impact: Impact; message: string; } interface AuditResult { url: string; timestamp: number; testEngine: TestEngine; testEnvironment: TestEnvironment; violations: AuditViolation[]; ruleCount: number; skippedRules: { ruleId: string; error: string; }[]; } /** * Wait for the page to reach a stable state before auditing. * * 1. Waits for `domcontentloaded` * 2. Waits for a 100 ms window with no DOM mutations (max 2 s) */ declare function waitForPageSettle(target: Page | Locator): Promise; /** * Inject the `@accesslint/core` IIFE bundle as `window.AccessLint`, unless the * target already carries it. */ declare function ensureInjected(target: Page | Frame): Promise; /** * Audit every shadow root reachable from `target`, one cold-cache rule sweep * per root. Callers composing their own traversal should time-box this: pages * built on a design system can carry hundreds of roots. * * Requires `ensureInjected(target)` first. */ declare function auditShadowDom(target: Page | Frame, coreOpts: CoreAuditOptions): Promise; interface AuditFramesOptions { /** Also audit shadow roots inside each frame. Defaults to true. */ includeShadowDom?: boolean; /** * Restrict to frames sharing the page's origin. Off by default (audit every * frame); callers who don't want third-party iframe cost or noise turn it on. */ sameOriginOnly?: boolean; } /** * Audit each child frame and prefix its violation selectors with the * `>>>iframe>` path that locates the frame from the main document. * * Injects into each frame itself; no `ensureInjected` needed up front. */ declare function auditFrames(page: Page, includeShadowDom: boolean, coreOpts: CoreAuditOptions, options?: AuditFramesOptions): Promise; declare function accesslintAudit(target: Page | Locator, options?: AccessibleMatcherOptions): Promise; /** * Format an audit violation into the shared failure-message block used across * @accesslint/jest, @accesslint/vitest, and @accesslint/playwright. * * Adapts the Playwright `AuditViolation` shape (which doesn't carry `element` * or structured `fix` fields — those are stripped when the audit result * crosses the page boundary) to the `Violation` shape that the shared * formatter expects. */ declare function formatViolation(v: AuditViolation): string; //#endregion export { AccessibleMatcherOptions, AuditFramesOptions, AuditResult, AuditViolation, CoreAuditOptions, type Impact, accesslintAudit, auditFrames, auditShadowDom, ensureInjected, formatViolation, waitForPageSettle };