/** * Edge-side tier detection -- wraps the pure tier mapping functions from * `@czap/detect` for use with HTTP Client Hints headers at the edge. * * @module */ import type { CapTier } from '@czap/core'; import type { DesignTier, ExtendedDeviceCapabilities, MotionTier, CapAxis } from '@czap/detect'; import type { ClientHintsHeaders } from './client-hints.js'; /** * Outcome of an edge-side tier detection sweep. * * All three fields use the same branded tier types as the client runtime, * so downstream boundary evaluation and output gating reuse the exact * code paths from `@czap/detect`. */ export interface EdgeTierResult { /** Highest {@link CapTier} the device qualifies for. */ readonly capTier: CapTier; /** Motion complexity tier permitted for this device. */ readonly motionTier: MotionTier; /** Visual fidelity tier permitted for this device. */ readonly designTier: DesignTier; } /** * Map already-parsed {@link ExtendedDeviceCapabilities} to the tier triple * using the same pure functions as the client runtime. */ declare function tierFromParsed(caps: ExtendedDeviceCapabilities): EdgeTierResult; /** * Detect capability tiers from HTTP headers using Client Hints parsing * and the same pure tier mapping functions used on the client. */ declare function detectTier(headers: Headers | ClientHintsHeaders): EdgeTierResult; /** * Structured `data-czap-*` attribute map for the root `` element — the * spreadable form of {@link tierDataAttributes}. * * Keyed by the FULL attribute name (`data-czap-`), built by iterating the * canonical CAP_AXES registry, so a newly-added capability axis appears * automatically. A consumer that spreads this map (``) can never * silently MISS an axis the way a hand-written attribute list does — the whole * point of exposing it alongside the pre-serialized string. * * @example * ```ts * // Astro: * tierDataAttributesMap(result) * // => { 'data-czap-tier': 'reactive', 'data-czap-motion': 'animations', 'data-czap-design': 'enhanced' } * ``` */ declare function tierDataAttributesMap(result: EdgeTierResult): Readonly>; /** * Generate the HTML data-attribute STRING for injection into the `` * element. Serialized from {@link tierDataAttributesMap}, so the string and * spreadable-map forms can never disagree. * * @example * ``` * tierDataAttributes(result) * // => 'data-czap-tier="reactive" data-czap-motion="animations" data-czap-design="enhanced"' * ``` */ declare function tierDataAttributes(result: EdgeTierResult): string; /** * Edge tier detection namespace. * * Pairs {@link ClientHints.parseClientHints} with the pure tier-mapping * functions from `@czap/detect` so the edge and the browser produce the * same `capTier`/`motionTier`/`designTier` triple for a given device. * * @example * ```ts * import { EdgeTier } from '@czap/edge'; * * const result = EdgeTier.detectTier(request.headers); * const html = ``; * // `` * ``` */ export declare const EdgeTier: { /** Detect {@link EdgeTierResult} from a `Headers`-like bag. */ readonly detectTier: typeof detectTier; /** Map parsed Client Hints capabilities to an {@link EdgeTierResult}. */ readonly tierFromParsed: typeof tierFromParsed; /** Render an `EdgeTierResult` into a `data-czap-*` attribute STRING for the root HTML element. */ readonly tierDataAttributes: typeof tierDataAttributes; /** Structured, spreadable `data-czap-*` map for the root HTML element (auto-includes every CAP_AXES axis). */ readonly tierDataAttributesMap: typeof tierDataAttributesMap; }; export declare namespace EdgeTier { /** Alias for {@link EdgeTierResult}. */ type Result = EdgeTierResult; } export {}; //# sourceMappingURL=edge-tier.d.ts.map