/** * Deterministic media/feature condition evaluation. * * `window.matchMedia` is not used, for two reasons. JSDOM stubs it to always * return `false`, which would drop every `@media` rule and silently produce a * snapshot of the wrong breakpoint. And relying on the host would mean the two * profiles evaluate conditions differently — exactly the divergence ADR-0001's * single-normalizer split exists to prevent. * * So conditions are evaluated here, against the declared environment, and the * same code runs under both engines. The one exception is the pointing device, * which the declared environment does not hold: see `ConditionEnvironment.device`. */ export interface ConditionEnvironment { readonly width: number; readonly height: number; readonly deviceScaleFactor: number; readonly colorScheme: 'light' | 'dark'; /** Extra features a project declares, e.g. `prefers-reduced-motion: reduce`. */ readonly features?: Readonly>; /** * Engine feature test for `@supports`, or absent when none is available. * * Unlike media queries, `@supports` genuinely asks the *engine* a question, so * a correct answer must come from the engine. That the two profiles may answer * differently is not divergence to be avoided: it is the truth being reported, * and it is why the engine is part of the environment key. */ readonly supports?: (condition: string) => boolean | null; /** * The engine's answer for a pointing-device feature, or absent when no engine * answers. * * `pointer`, `any-pointer`, `hover` and `any-hover` describe the input device, * and nothing in the declared viewport says what that is. The engine does: * Playwright's `hasTouch` and `isMobile` set it, and a desktop page answers * `fine` and `hover`. Resolving every one of them to *matching* flattened a * touch page and a desktop page into the same key, and painted a desktop * baseline with the touch rules applied. */ readonly device?: (feature: string) => boolean | null; } /** * Ask the view's `matchMedia` about the pointing device, or return `null` when * the view has no engine behind it. * * A stand-in is refused by asking two questions every engine answers the same * way: `all` matches and `not all` does not. A JSDOM `matchMedia` is a stub * that answers one constant for every query, so it fails one of the two. */ export declare function deviceProbe(view: Window | null): ((feature: string) => boolean | null) | null; export interface ConditionResult { readonly matches: boolean; /** * `true` when some part of the query could not be evaluated. * * An unknown feature resolves to *matching*, deliberately. Over-including a * rule costs a review that was not needed; excluding one drops a declaration * from the hash, which is a false `unchanged`. Every ambiguity in this * codebase resolves toward over-reporting. */ readonly uncertain: boolean; } /** Evaluate a `@media` prelude, which may be a comma-separated list. */ export declare function evaluateMedia(query: string, environment: ConditionEnvironment): ConditionResult; /** * Evaluate a `@supports` prelude by asking the engine. * * `CSS.supports` turns out to be present and correct in JSDOM as well as in * browsers — it rejects `display: nonsense-value` and accepts `display: grid` — * so the honest answer is available on both profiles after all. * * This was previously hard-coded to "matches", on the assumption that JSDOM * lacked the API. That assumption cost a corpus case: a `@supports` block * guarding an unsupported value was always included, so its rules applied and a * no-op perturbation reported as a change. Over-reporting is the right default * for something genuinely unknowable; it is the wrong answer for something we * simply had not checked. * * Without a probe the old behaviour stands: include, and mark uncertain. */ export declare function evaluateSupports(condition: string, environment?: ConditionEnvironment): ConditionResult; //# sourceMappingURL=media.d.ts.map