import type { RolldownOutput, InputOptions, RolldownWatcher } from 'rolldown';
import type { BundlerOptions } from './types/index.js';
export interface NativePluginContext {
    resolve(specifier: string, importer?: string, opts?: {
        skipSelf?: boolean;
        isEntry?: boolean;
    }): Promise<{
        id: string;
        external: boolean;
    } | null>;
    warn(message: string): void;
    error(message: string): never;
}
export interface NativePlugin {
    name: string;
    idFilter?: {
        load?: string;
        transform?: string;
        resolveId?: string;
    };
    load?: (this: NativePluginContext, id: string) => unknown;
    transform?: (this: NativePluginContext, code: string, id: string, moduleType: string) => unknown;
    resolveId?: (this: NativePluginContext, specifier: string, importer: string | undefined, opts: {
        isEntry: boolean;
    }) => unknown;
    renderChunk?: (this: NativePluginContext, code: string, chunk: {
        fileName: string;
        name: string;
        isEntry: boolean;
    }) => unknown;
    banner?: (this: NativePluginContext, chunk: {
        fileName: string;
        name: string;
        isEntry: boolean;
    }) => unknown;
    footer?: (this: NativePluginContext, chunk: {
        fileName: string;
        name: string;
        isEntry: boolean;
    }) => unknown;
    intro?: (this: NativePluginContext, chunk: {
        fileName: string;
        name: string;
        isEntry: boolean;
    }) => unknown;
    outro?: (this: NativePluginContext, chunk: {
        fileName: string;
        name: string;
        isEntry: boolean;
    }) => unknown;
    buildStart?: (this: NativePluginContext) => unknown;
    buildEnd?: (this: NativePluginContext) => unknown;
    generateBundle?: (this: NativePluginContext) => unknown;
    writeBundle?: (this: NativePluginContext) => unknown;
    closeBundle?: (this: NativePluginContext) => unknown;
}
/**
 * In-memory bundle used by `--globals auto` for AST-driven detection.
 * Mirrors the shape of `AnalysisBundler` in
 * `@gjsify/rolldown-plugin-gjsify/utils/auto-globals`. Routes through the
 * same engine as the final build (npm rolldown on Node, native on GJS) so
 * the GJS-bundled CLI doesn't try to load the unloadable npm crate.
 */
export declare function bundleToChunks(input: {
    rolldownInput: InputOptions;
    format: 'esm' | 'cjs' | 'iife';
}): Promise<string[]>;
/**
 * Watch source files and rebuild on change. Only npm rolldown supports
 * this path — `@gjsify/rolldown-native` does not surface a watcher API yet.
 * Returns the watcher; the caller registers `event` / `close` listeners
 * and is responsible for invoking `watcher.close()` on shutdown.
 */
export declare function runWatch(finalOpts: BundlerOptions): Promise<RolldownWatcher>;
/**
 * Run a bundle with the picked engine. Drop-in replacement for the
 * `rolldown(opts).write(opts.output)` flow used directly in build.ts.
 */
export declare function runBundle(finalOpts: BundlerOptions): Promise<RolldownOutput>;
export declare function shouldUseNative(): Promise<boolean>;
export type PluginRecord = {
    name?: string;
    [k: string]: unknown;
};
export declare function isPluginObject(p: unknown): p is PluginRecord;
export declare function toNativePlugin(p: PluginRecord): NativePlugin;
