//#region src/discover.d.ts /** * Relative `.ts` paths documented for convention entries (first extension per base). * Shared by bundler integrations and `@typestyles/next/build`. */ export declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly string[]; /** * Side-effect modules that import every recipe and export `getRegisteredComponentRefs(styles)`. * Used when `extract.include` is `"allRegisteredComponents"`. */ export declare const DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES: readonly ["src/themeable-refs", "src/typestyles/themeable-refs", "src/typestyles-registry", "styles/themeable-refs"]; /** * Resolve the default extraction module when the user did not pass explicit `modules`. * Returns at most one path using `/` separators, relative to `root`. */ export declare function discoverDefaultExtractModules(root: string): string[]; /** * Convention registry module for `extract.include: 'allRegisteredComponents'`. * The file should import all recipe modules and * export `getRegisteredComponentRefs(styles)` from your `createTypeStyles` entry. */ export declare function discoverRegisteredComponentsModule(root: string): string | undefined; //#endregion //#region src/namespaces.d.ts export declare const TYPESTYLES_IMPORT_RE: RegExp; /** * True when this module may register `styles.override` rules and needs Vite HMR * dispose tracking — including Var UI sugar (`createDesignTheme` / `overrideComponent`) * that never spells `styles.override` in source. * * Detects renamed imports (`createDesignTheme as cdt`) and namespace imports * (`Core.createDesignTheme(`), not only the canonical identifier spelling. */ export declare function moduleNeedsOverrideHmr(code: string): boolean; /** * Extract namespace information from source code for invalidation and duplicate checks. */ export declare function extractNamespaces(code: string): { keys: string[]; prefixes: string[]; }; interface DuplicateNamespaceReporter { error(message: string): void; } /** * Fail the build when the same style namespace appears in more than one module. */ export declare function reportDuplicateNamespaces(moduleNamespaces: Map, id: string, prefixes: string[], reporter: DuplicateNamespaceReporter): void; //#endregion //#region src/resolve-extract.d.ts type TypestylesIntegrationMode = 'runtime' | 'build' | 'hybrid'; interface TypestylesExtractOptions { /** * Modules that register typestyles styles, relative to the project root. * When omitted, uses {@link discoverDefaultExtractModules}. */ modules?: string[]; /** * Output CSS filename. Defaults to `typestyles.css`. */ fileName?: string; /** * Additional module that re-exports {@link getRegisteredComponentRefs} (or an * equivalent object of every themeable recipe handle) so extract bundles retain * full design-system CSS without a hand-maintained registry object. */ registeredComponentsModule?: string; /** * When `"allRegisteredComponents"`, appends a convention registry module if present * ({@link discoverRegisteredComponentsModule}) or {@link registeredComponentsModule} * when set. That file must side-effect-import every recipe and reference * `getRegisteredComponentRefs(styles)` — the extract entry alone is not enough. */ include?: 'allRegisteredComponents'; } /** * Resolve extraction modules from explicit config or convention entry discovery. */ export declare function resolveExtractModules(root: string, extract: TypestylesExtractOptions | undefined): string[]; /** * Default to `build` when at least one extraction module resolves; otherwise `runtime`. */ export declare function resolveExtractMode(explicitMode: TypestylesIntegrationMode | undefined, resolvedModules: string[]): TypestylesIntegrationMode; //#endregion //#region src/manifest.d.ts interface TypestylesExtractManifestV1 { version: 1; css: string; } interface TypestylesRouteCssEntry { css: string; } interface TypestylesExtractManifestV2 { version: 2; /** Full-app CSS (union of all registered styles). */ css: string; /** Per-route critical CSS paths relative to project root. */ routes: Record; } type TypestylesExtractManifest = TypestylesExtractManifestV1 | TypestylesExtractManifestV2; export declare function isManifestV2(manifest: TypestylesExtractManifest): manifest is TypestylesExtractManifestV2; /** Normalize App Router paths for manifest lookup (`/about`, no trailing slash). */ export declare function normalizeRoutePath(routePath: string): string; //#endregion //#region src/verify.d.ts interface VerifyTypestylesBuildOptions { /** Project root used to resolve `cssFile` and `manifestFile`. */ root: string; /** Extracted CSS path relative to `root`. */ cssFile: string; /** * Manifest path relative to `root`. When omitted, manifest checks are skipped. * Pass `false` explicitly to skip (same as omitting). */ manifestFile?: string | false; /** Expected manifest `css` field. Defaults to `cssFile`. */ manifestCssPath?: string; /** Expected manifest version. Defaults to `1`. */ manifestVersion?: number; /** Minimum CSS byte length. When omitted, only checks that the file is non-empty. */ minBytes?: number; /** Substrings that must appear in the emitted CSS (app-specific sanity checks). */ requiredCssSubstrings?: readonly string[]; /** * When the manifest is v2, require at least this many route entries. * Ignored for v1 manifests. */ minRouteEntries?: number; } interface VerifyTypestylesBuildResult { cssPath: string; cssBytes: number; manifestPath?: string; manifestVersion?: number; } export declare class VerifyTypestylesBuildError extends Error { readonly code: string; constructor(message: string, code: string); } /** * Verify that a zero-runtime TypeStyles build produced expected CSS (and optional manifest). * * Use after `runTypestylesBuild`, `buildTypestylesForNext`, or a bundler plugin build step in CI * to catch silent extraction gaps — styles unreachable from the convention entry are dropped * without a compile error. */ export declare function verifyTypestylesBuild(options: VerifyTypestylesBuildOptions): VerifyTypestylesBuildResult; //#endregion //#region src/next-routes.d.ts interface NextAppRoute { /** App Router path, e.g. `/`, `/about`, `/blog/[slug]`. */ routePath: string; /** Page file relative to project root with `/` separators. */ pageFile: string; /** Layout files from root to route segment, relative to project root. */ layoutFiles: string[]; } /** * Convert `app/about/page.tsx` (relative to `appDir`) to `/about`. * Route groups `(marketing)` are omitted from the URL. */ export declare function pageRelPathToRoutePath(pageRelPath: string): string; /** * Discover App Router pages under `appDir` (default `app`). */ export declare function discoverNextAppRoutes(root: string, appDir?: string): NextAppRoute[]; //#endregion //#region src/trace-imports.d.ts /** * Trace local modules reachable from entry files and return those that import `typestyles`. * Paths are relative to `root` with `/` separators. */ export declare function traceTypestylesModules(root: string, entryFiles: string[]): Promise; /** Load a traced module for style extraction (cache-busted so re-runs re-register styles). */ export declare function createModuleLoader(root: string, modulePath: string): () => Promise; //#endregion //#region src/route-css.d.ts interface CollectRouteCssOptions { root: string; /** Convention entry modules (relative to root) included in every route bundle. */ sharedModules: string[]; /** App Router directory relative to root. Default `app`. */ appDir?: string; /** Output directory for per-route CSS relative to root. */ routeCssOutDir?: string; /** * Collect CSS from traced modules. * Injected by `@typestyles/next/build` so this package stays bundler-agnostic. */ collectCss: (loaders: Array<() => unknown | Promise>) => Promise; } interface CollectRouteCssResult { routes: Record; } /** * Emit per-route CSS files and return manifest route entries. */ export declare function collectAndWriteRouteCss(options: CollectRouteCssOptions): Promise; export declare function buildManifestV2(cssOutFile: string, routeEntries: Record): TypestylesExtractManifestV2; //#endregion //#region src/route-css-read.d.ts export declare function readTypestylesManifest(root: string, manifestFile?: string): TypestylesExtractManifest; export declare function readCssFile(root: string, cssRelPath: string): string; interface GetRouteCssOptions { /** Project root used to resolve manifest and CSS paths. */ root: string; /** Manifest path relative to `root`. Defaults to `app/typestyles.manifest.json`. */ manifestFile?: string; } /** * Read pre-extracted CSS for an App Router route from the build manifest. * * When the manifest is v2 and includes a route entry, returns that route's CSS. * Otherwise falls back to the full-app stylesheet path in the manifest. */ export declare function getRouteCss(routePath: string, options: GetRouteCssOptions): string; //#endregion //#region src/index.d.ts export interface RunTypestylesBuildOptions { /** * Project root used to resolve extraction entry modules. */ root: string; /** * Module paths (relative to root) that register typestyles styles. */ modules: string[]; } /** * Bundle + execute style registration modules and return collected CSS. * * This is shared by integrations (Vite, Rollup, Rolldown, etc.) so app code * does not need an external TS runtime loader like tsx. */ export declare function runTypestylesBuild({ root, modules }: RunTypestylesBuildOptions): Promise; //#endregion export type { CollectRouteCssOptions, CollectRouteCssResult, DuplicateNamespaceReporter, GetRouteCssOptions, NextAppRoute, TypestylesExtractManifest, TypestylesExtractManifestV1, TypestylesExtractManifestV2, TypestylesExtractOptions, TypestylesIntegrationMode, TypestylesRouteCssEntry, VerifyTypestylesBuildOptions, VerifyTypestylesBuildResult };