import { PreBuildHook } from '@nanoesis/engine';

/**
 * A spawner seam, kept narrow so tests can substitute it without spawning real
 * processes. Resolves with the exit code (or `null` when the child was killed by
 * a signal). The default implementation uses `node:child_process.spawn` with
 * `shell: true` so dev-friendly commands like `npm run build:css` Just Work.
 */
type Spawner = (command: string, options: {
    readonly cwd: string;
    readonly env: NodeJS.ProcessEnv;
}) => Promise<number | null>;
interface ShellPreBuildHookConfig {
    /** The command line to run, exactly as a developer would type it in a terminal. */
    readonly command: string;
    /** Working directory the command runs in (typically the site root). */
    readonly cwd: string;
    /** Environment for the child; defaults to the host's own `process.env`. */
    readonly env?: NodeJS.ProcessEnv;
    /** Injected for tests; defaults to the real `child_process.spawn`. */
    readonly spawn?: Spawner;
}
/**
 * A {@link PreBuildHook} that runs a shell command before compile (DESIGN §11, the
 * spot where a dev's own asset tool, e.g. Tailwind, can rebuild into `public/` so
 * its output is picked up by the engine's passthrough). The child inherits stdio
 * so logs stream live; a non-zero exit code throws, which aborts the publish and
 * leaves the sink untouched (the engine's contract, see `publishSite`).
 */
declare class ShellPreBuildHook implements PreBuildHook {
    private readonly config;
    private readonly spawnFn;
    constructor(config: ShellPreBuildHookConfig);
    run(): Promise<void>;
}

/**
 * Read the optional `nanoesis.prebuild` command from a site's package.json.
 * Returns undefined when the file is missing, the JSON is malformed, the
 * `nanoesis` key is absent, or the command is empty whitespace, anything that
 * means "no prebuild here". A non-empty string command is returned verbatim.
 *
 * Hosts (the Azure Function host, host-mcp, …) read the same key, so a
 * site declares its build hook in one canonical place.
 */
declare function readPrebuildCommand(siteDir: string): Promise<string | undefined>;

export { ShellPreBuildHook, type ShellPreBuildHookConfig, type Spawner, readPrebuildCommand };
