/** * Merge Byline's required Vite settings into a host application's own * `vite.config.ts`. * * The settings themselves are never written out by hand here. They are * extracted from the canonical template (`templates/host/vite.config.ts`) at * runtime, so that file stays the single source of truth and this module * cannot drift from it. `extractCanonicalPieces` is pinned by a contract test. * * Merging is deliberately conservative: every insertion must land in a key the * host config does not already define. If the config declares any of the keys * Byline owns, or is shaped in a way this module does not recognise, the caller * is told which pieces could not be placed and falls back to asking the user to * merge them by hand. A wrong merge is worse than no merge — it moves the * failure from install time, where the CLI can explain it, to a confusing * runtime or production-build failure. */ export interface CanonicalPieces { /** Source text of each module-level statement, keyed by declaration name. */ statements: Map; /** Source text of each `defineConfig` property, keyed by property name. */ configProps: Map; /** Source text of each `nitro()` option, keyed by property name. */ nitroProps: Map; } export interface MergePlan { /** Human-readable description of each edit, for the phase preview. */ changes: string[]; /** Pieces that could not be placed; the caller surfaces these for hand-merge. */ unplaced: string[]; /** Applies the plan and returns the edited source text. */ apply(): string; } export type MergeAnalysis = { kind: 'canonical'; } | { kind: 'mergeable'; plan: MergePlan; } | { kind: 'unrecognized'; reason: string; }; /** * Pull the Byline-owned pieces out of the canonical template. Throws if the * template no longer contains an expected piece — that is a build-time bug in * Byline, not a problem with the user's config, and it must fail loudly. */ export declare function extractCanonicalPieces(canonicalSource: string): CanonicalPieces; /** * Decide whether the host's config can take Byline's settings, and if so return * a plan that applies them. * * The async-hooks alias references `byline/async-hooks.browser.ts`, which the * scaffold phase writes. Wire runs *before* scaffold, so that file does not * exist yet at this point — we still emit the reference, exactly as the * canonical full-replace path does, because scaffold always follows wire in a * normal `init`. Gating on the file's presence would silently drop the alias * from every fresh install. */ export declare function analyzeUserConfig(userSource: string, canonical: CanonicalPieces): MergeAnalysis; //# sourceMappingURL=vite-config-merge.d.ts.map