import type { VeryfrontConfig } from "../../config/index.js"; import type { RuntimeAdapter } from "../../platform/adapters/base.js"; import type { ImportMapConfig } from "./types.js"; import { loadImportMap } from "./loader.js"; export interface PreloadImportMapContext { /** Immutable content source selected for this render (release, branch, or environment). */ contentSourceId?: string; /** Config already validated for the authenticated request. */ config?: VeryfrontConfig; /** Project root used by cache-inspection callers when the cache key is a project ID. */ projectDir?: string; } export interface ImportMapPreloaderOptions { /** Maximum tenant/project buckets retained by one preloader. */ maxProjects?: number; /** Maximum content-source/config variants retained for one project. */ maxVariantsPerProject?: number; /** Retention lifetime after a successful load. */ ttlMs?: number; /** Maximum caller wait for a load or for occupied capacity to settle. */ loadTimeoutMs?: number; /** Monotonic-enough clock seam; defaults to Date.now. */ now?: () => number; /** * Timer seam, paired with `now`. Defaults to the host timers. * * Without this, a caller that injects `now` still has its deadlines measured * against the wall clock, so a starved process can trip a timeout during work * that took no virtual time at all. Override both halves together. */ setTimer?: (callback: () => void, delayMs: number) => ReturnType; cancelTimer?: (handle: ReturnType) => void; /** * Elapsed-time seam for the capacity-retry deadline; defaults to * performance.now. * * Deliberately separate from `now`: that clock carries absolute time for TTL * and expiry, and defaults to Date.now, which can jump backwards under NTP * correction. Deadline arithmetic needs a monotonic source, so the two cannot * share one seam without either breaking expiry semantics or making timeouts * clock-skew sensitive. */ monotonicNow?: () => number; /** Loader seam for alternate runtimes and deterministic verification. */ loadImportMap?: typeof loadImportMap; } /** * Bounded two-level import-map cache. * * Map insertion order is the LRU order at both levels. Expiry is lazy, avoiding * a process-wide timer while still placing a hard ceiling on retained values. */ export declare class ImportMapPreloader { private readonly projects; /** Underlying loader work remains accounted for even after explicit invalidation. */ private readonly activeLoads; private readonly activeIdentityBuilds; /** Every underlying loader stays reserved here until it actually settles. */ private readonly reservedLoadsByProject; private readonly orphanedLoadsByProject; private readonly capacityErrors; private capacityChange; private globalGeneration; private readonly maxProjects; private readonly maxVariantsPerProject; private readonly maxConcurrentLoads; private readonly ttlMs; private readonly loadTimeoutMs; private readonly now; private readonly setTimer; private readonly cancelTimer; private readonly monotonicNow; private readonly loader; constructor(options?: ImportMapPreloaderOptions); private readNow; private touchProject; private touchVariant; private deleteEntry; private getEntry; private getSingleVariantEntry; private capacityError; private isCapacityError; private notifyCapacityChange; private projectOrphanCount; private hasProjectLoadCapacity; private projectOccupancy; private hasProjectOccupancy; private waitForActiveWork; private makeProjectRoom; private makeVariantRoom; private trackOrphanedLoad; private releaseOrphanedLoad; private reportTimedOutLoad; private trackActiveLoad; private reserveUnderlyingLoad; private hasActiveWorkCapacity; private releaseIdentityBuild; private getOrCreateIdentityBuild; private isCurrentGeneration; private removeEmptyProject; private startTrackedLoad; preload(projectDir: string, adapter: RuntimeAdapter, projectId?: string, context?: PreloadImportMapContext): Promise; private preloadOnce; getCached(cacheKey: string, context?: PreloadImportMapContext): Promise; clear(cacheKey?: string): void; } export declare function preloadImportMap(projectDir: string, adapter: RuntimeAdapter, projectId?: string, context?: PreloadImportMapContext): Promise; export declare function getCachedImportMap(cacheKey: string, context?: PreloadImportMapContext): Promise; export declare function clearImportMapCache(cacheKey?: string): void; //# sourceMappingURL=preloader.d.ts.map