/// <reference types="node" />
import type * as http from 'http';
import type { FSWatcher, WatchOptions } from 'types/chokidar';
import type { Connect } from 'types/connect';
import type { SourceMap } from 'rollup';
import type { CommonServerOptions } from '../http';
import type { InlineConfig, ResolvedConfig } from '../config';
import type { Logger } from '../logger';
import type { PluginContainer } from './pluginContainer';
import type { WebSocketServer } from './ws';
import { ModuleGraph } from './moduleGraph';
import type { HmrOptions } from './hmr';
import type { TransformOptions, TransformResult } from './transformRequest';
export { searchForWorkspaceRoot } from './searchRoot';
export interface ServerOptions extends CommonServerOptions {
    /**
     * Configure HMR-specific options (port, host, path & protocol)
     */
    hmr?: HmrOptions | boolean;
    /**
     * chokidar watch options
     * https://github.com/paulmillr/chokidar#api
     */
    watch?: WatchOptions;
    /**
     * Create Vite dev server to be used as a middleware in an existing server
     */
    middlewareMode?: boolean | 'html' | 'ssr';
    /**
     * Prepend this folder to http requests, for use when proxying vite as a subfolder
     * Should start and end with the `/` character
     */
    base?: string;
    /**
     * Options for files served via '/\@fs/'.
     */
    fs?: FileSystemServeOptions;
    /**
     * Origin for the generated asset URLs.
     *
     * @example `http://127.0.0.1:8080`
     */
    origin?: string;
    /**
     * Pre-transform known direct imports
     * @default true
     */
    preTransformRequests?: boolean;
}
export interface ResolvedServerOptions extends ServerOptions {
    fs: Required<FileSystemServeOptions>;
}
export interface FileSystemServeOptions {
    /**
     * Strictly restrict file accessing outside of allowing paths.
     *
     * Set to `false` to disable the warning
     *
     * @default true
     */
    strict?: boolean;
    /**
     * Restrict accessing files outside the allowed directories.
     *
     * Accepts absolute path or a path relative to project root.
     * Will try to search up for workspace root by default.
     */
    allow?: string[];
    /**
     * Restrict accessing files that matches the patterns.
     *
     * This will have higher priority than `allow`.
     * Glob patterns are supported.
     *
     * @default ['.env', '.env.*', '*.crt', '*.pem']
     */
    deny?: string[];
}
export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
export interface ViteDevServer {
    /**
     * The resolved vite config object
     */
    config: ResolvedConfig;
    /**
     * A connect app instance.
     * - Can be used to attach custom middlewares to the dev server.
     * - Can also be used as the handler function of a custom http server
     *   or as a middleware in any connect-style Node.js frameworks
     *
     * https://github.com/senchalabs/connect#use-middleware
     */
    middlewares: Connect.Server;
    /**
     * native Node http server instance
     * will be null in middleware mode
     */
    httpServer: http.Server | null;
    /**
     * chokidar watcher instance
     * https://github.com/paulmillr/chokidar#api
     */
    watcher: FSWatcher;
    /**
     * web socket server with `send(payload)` method
     */
    ws: WebSocketServer;
    /**
     * Rollup plugin container that can run plugin hooks on a given file
     */
    pluginContainer: PluginContainer;
    /**
     * Module graph that tracks the import relationships, url to file mapping
     * and hmr state.
     */
    moduleGraph: ModuleGraph;
    /**
     * Programmatically resolve, load and transform a URL and get the result
     * without going through the http request pipeline.
     */
    transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
    /**
     * Apply vite built-in HTML transforms and any plugin HTML transforms.
     */
    transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
    /**
     * Transform module code into SSR format.
     */
    ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
    /**
     * Load a given URL as an instantiated module for SSR.
     */
    ssrLoadModule(url: string, opts?: {
        fixStacktrace?: boolean;
    }): Promise<Record<string, any>>;
    /**
     * Returns a fixed version of the given stack
     */
    ssrRewriteStacktrace(stack: string): string;
    /**
     * Mutates the given SSR error by rewriting the stacktrace
     */
    ssrFixStacktrace(e: Error): void;
    /**
     * Start the server.
     */
    listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
    /**
     * Stop the server.
     */
    close(): Promise<void>;
    /**
     * Print server urls
     */
    printUrls(): void;
    /**
     * Restart the server.
     *
     * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
     */
    restart(forceOptimize?: boolean): Promise<void>;
    /**
     * @internal
     */
    _importGlobMap: Map<string, string[][]>;
    /**
     * Deps that are externalized
     * @internal
     */
    _ssrExternals: string[] | null;
    /**
     * @internal
     */
    _restartPromise: Promise<void> | null;
    /**
     * @internal
     */
    _forceOptimizeOnRestart: boolean;
    /**
     * @internal
     */
    _pendingRequests: Map<string, {
        request: Promise<TransformResult | null>;
        timestamp: number;
        abort: () => void;
    }>;
}
export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
export declare function resolveServerOptions(root: string, raw: ServerOptions | undefined, logger: Logger): ResolvedServerOptions;
