/// <reference types="node" />
import * as http from 'http';
import * as https from 'https';
import { UserConfig, ResolvedConfig } from '../config';
import { PluginContainer } from '../server/pluginContainer';
import { FSWatcher, WatchOptions } from 'types/chokidar';
import { WebSocketServer } from '../server/ws';
import { ProxyOptions } from './middlewares/proxy';
import { ModuleGraph } from './moduleGraph';
import { Connect } from 'types/connect';
import { HmrOptions } from './hmr';
import { TransformResult } from 'rollup';
import { EsbuildTransformResult } from '../plugins/esbuild';
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
import { DepOptimizationMetadata } from '../optimizer';
export interface ServerOptions {
    host?: string;
    port?: number;
    /**
     * Enable TLS + HTTP/2.
     * Note: this downgrades to TLS only when the proxy option is also used.
     */
    https?: boolean | https.ServerOptions;
    /**
     * Open browser window on startup
     */
    open?: boolean;
    /**
     * Force dep pre-optimization regardless of whether deps have changed.
     */
    force?: boolean;
    /**
     * Configure HMR-specific options (port, host, path & protocol)
     */
    hmr?: HmrOptions | boolean;
    /**
     * chokidar watch options
     * https://github.com/paulmillr/chokidar#api
     */
    watch?: WatchOptions;
    /**
     * Configure custom proxy rules for the dev server. Expects an object
     * of `{ key: options }` pairs.
     * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
     * Full options [here](https://github.com/http-party/node-http-proxy#options).
     *
     * Example `vite.config.js`:
     * ``` js
     * module.exports = {
     *   proxy: {
     *     // string shorthand
     *     '/foo': 'http://localhost:4567/foo',
     *     // with options
     *     '/api': {
     *       target: 'http://jsonplaceholder.typicode.com',
     *       changeOrigin: true,
     *       rewrite: path => path.replace(/^\/api/, '')
     *     }
     *   }
     * }
     * ```
     */
    proxy?: Record<string, string | ProxyOptions>;
    /**
     * Configure CORS for the dev server.
     * Uses https://github.com/expressjs/cors.
     * Set to `true` to allow all methods from any origin, or configure separately
     * using an object.
     */
    cors?: CorsOptions | boolean;
}
/**
 * https://github.com/expressjs/cors#configuration-options
 */
export interface CorsOptions {
    origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
    methods?: string | string[];
    allowedHeaders?: string | string[];
    exposedHeaders?: string | string[];
    credentials?: boolean;
    maxAge?: number;
    preflightContinue?: boolean;
    optionsSuccessStatus?: number;
}
export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
export interface ViteDevServer {
    /**
     * The resolved vite config object
     */
    config: ResolvedConfig;
    /**
     * connect app instance
     * This can also be used as the handler function of a custom http server
     * https://github.com/senchalabs/connect#use-middleware
     */
    app: Connect.Server;
    /**
     * native Node http server instance
     */
    httpServer: http.Server;
    /**
     * 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;
    /**
     * Programatically resolve, load and transform a URL and get the result
     * without going through the http request pipeline.
     */
    transformRequest(url: string): Promise<TransformResult | null>;
    /**
     * Util for transfoming a file with esbuild.
     * Can be useful for certain plugins.
     */
    transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<EsbuildTransformResult>;
    /**
     * Start the server.
     */
    listen(port?: number): Promise<ViteDevServer>;
    /**
     * Stop the server.
     */
    close(): Promise<void>;
    /**
     * @intenral
     */
    optimizeDepsMetadata: DepOptimizationMetadata | null;
}
export declare function createServer(inlineConfig?: UserConfig & {
    mode?: string;
}, configPath?: string | false): Promise<ViteDevServer>;
