/** * Boundary manifest contract -- the build-to-edge handoff for precompiled * boundary outputs (ADR-0003 content addressing). * * The build pipeline (`@czap/vite` `collectBoundaryManifest`) derives every * boundary's `ContentAddress` and per-tier {@link CompiledOutputs} at build * time; edge hosts consume the manifest so they never hand-type a boundary * id or re-implement the CSS compiler inside a worker bundle. * * @module */ import type { ContentAddress, MotionTier } from '@czap/core'; import type { DesignTier } from '@czap/detect'; import type { EdgeTierResult } from './edge-tier.js'; import type { CompiledOutputs } from './kv-cache.js'; /** * Every {@link MotionTier}, in escalation order. Kept in lockstep with the * `MotionTier` union in `@czap/core` -- the `satisfies` clause plus the * exhaustiveness check below fail compilation if the vocabulary drifts. */ export declare const MOTION_TIERS: readonly ["none", "transitions", "animations", "physics", "compute"]; /** * Every `DesignTier`, in escalation order. Kept in lockstep with the * `DesignTier` union in `@czap/detect` -- the `satisfies` clause plus the * exhaustiveness check below fail compilation if the vocabulary drifts. */ export declare const DESIGN_TIERS: readonly ["minimal", "standard", "enhanced", "rich"]; /** * Key of one cell in the (motion x design) tier grid -- * `":"`. The same encoding the KV boundary cache * uses in its keys, so manifest lookups and cache keys can never disagree. */ export type TierKey = `${MotionTier}:${DesignTier}`; /** * Encode a tier result (or any motion/design pair) as a {@link TierKey}. */ export declare function tierKey(tier: Pick): TierKey; /** * Enumerate the full finite tier grid (every motion x design combination). * Build pipelines iterate this to precompile outputs for every tier a * request could resolve to. */ export declare function enumerateTierKeys(): readonly TierKey[]; /** * One boundary's manifest entry: its minted `ContentAddress` (always * `Boundary.make`'s id -- never hand-typed) plus precompiled * {@link CompiledOutputs} for the tier grid, deduplicated. * * Most of a boundary's compiled CSS is tier-invariant (the container * queries adapt via `@container`, not per tier), so storing the strings * once per grid cell would ship ~20 copies of the same bytes to the edge * host. Instead `outputs` is a pool of the DISTINCT compiled outputs and * `outputsByTier` maps each {@link TierKey} to a pool index. Hosts call * {@link resolveOutputsByTier} to inflate the per-tier map back to the * exact same bytes the build compiled. * * `assetUrls`, when present, maps the SAME pooled output indices to immutable * static-asset URLs emitted by the build. It is optional and additive: hosts * that do not opt into static asset emission keep using `outputs` directly. * * Both fields are empty when the boundary has no `@quantize` CSS block * (nothing to compile) -- the entry still carries the id so hosts can * derive cache configuration from it. */ export interface BoundaryManifestEntry { /** Content address minted by `Boundary.make` (`fnv1a:xxxxxxxx`). */ readonly id: ContentAddress; /** Deduplicated pool of distinct compiled outputs; `outputsByTier` cells index into it. */ readonly outputs: readonly CompiledOutputs[]; /** Pool index per {@link TierKey}; missing keys mean that tier was never compiled. */ readonly outputsByTier: Readonly>>; /** Optional immutable static-asset URL per output-pool index. */ readonly assetUrls?: Readonly>; } /** * Deduplicate a fully-materialized per-tier outputs map into the pooled * {@link BoundaryManifestEntry} shape (`outputs` + index refs). * * Identity is the full `css` / `propertyRegistrations` / `containerQueries` / * `aria` / `glsl` / `wgsl` tuple, and cells are visited in * {@link enumerateTierKeys} order so the pool order -- and the serialized * manifest bytes -- are stable regardless of the producer's insertion order. * Each non-CSS cast is part of identity so two boundaries that differ only in * their `@glsl` / `@wgsl` cast get distinct content addresses (and distinct * pool entries). */ export declare function dedupeOutputsByTier(outputsByTier: Readonly>>): Pick; /** * Inflate a pooled {@link BoundaryManifestEntry} back into the per-tier * {@link CompiledOutputs} map that `EdgeHostCacheConfig.precompiled` * consumes. Resolved cells share pool object references, so per-tier * lookups return byte-identical strings to what the build compiled. */ export declare function resolveOutputsByTier(entry: Pick): Readonly>>; /** * Resolve the immutable static-asset URL for one tier, when the manifest was * built with boundary asset emission enabled. Missing `assetUrls` means the * host should fall back to inline / Worker-served {@link CompiledOutputs}. */ export declare function resolveAssetUrlByTier(entry: Pick, key: TierKey): string | undefined; /** * Build-derived boundary manifest: boundary export name to * {@link BoundaryManifestEntry}. This is the value of the * `virtual:czap/boundaries` virtual module and the `boundaries` field of * the emitted `czap-boundary-manifest.json`. */ export type BoundaryManifest = Readonly>; /** * Versioned envelope written to `czap-boundary-manifest.json` by the * `@czap/astro` integration at `astro:build:done` -- for hosts that read * the manifest from disk instead of importing `virtual:czap/boundaries`. */ export interface BoundaryManifestFile { readonly _tag: 'CzapBoundaryManifest'; /** v2: entries carry a deduplicated `outputs` pool; `outputsByTier` cells are pool indices. */ readonly _version: 2; readonly boundaries: BoundaryManifest; } //# sourceMappingURL=manifest.d.ts.map