/// <reference types="react" />
import Config = require("webpack-chain");
import webpack = require("webpack");
import WebpackDevServer from "webpack-dev-server";
import { StaticRouterContext } from "react-router";
import { RematchStore } from "@rematch/core";
import { RootOptions as rootOptions, RawPlugin as rawPlugin, Preset as preset, BasePkgFields as basePkgFields } from "@luban-cli/cli-shared-types/dist/shared";
import { CommandPluginAPI, ConfigPluginAPI } from "./lib/PluginAPI";
import { ProjectConfig } from "./main";
export declare type builtinServiceCommandName = "serve" | "build" | "inspect" | "help";
export declare type RootOptions = rootOptions;
export declare type RawPlugin = rawPlugin;
/**
 * @description package.json fields, name and version must required
 *
 * @see https://docs.npmjs.com/creating-a-package-json-file
 */
export declare type BasePkgFields = basePkgFields;
export declare type CommonFields<Args extends CliArgs> = {
    projectConfig: ProjectConfig;
    options: rootOptions;
    mode: string;
    commandName: builtinServiceCommandName;
    args: ParsedArgs<Args>;
    rawArgv: string[];
};
export declare type CommandPluginApplyCallbackArgs<Args extends CliArgs> = {
    api: CommandPluginAPI;
} & CommonFields<Args>;
export declare type CommandPluginApplyCallback<Args extends CliArgs> = (options: CommandPluginApplyCallbackArgs<Args>) => void;
export declare type CommandPluginAddWebpackConfigCallbackArgs = {
    api: CommandPluginAPI;
    projectConfig: ProjectConfig;
};
export interface CommandPluginInstance<Args extends CliArgs> {
    apply: CommandPluginApplyCallback<Args>;
    addWebpackConfig?: (options: CommandPluginAddWebpackConfigCallbackArgs) => void;
}
export declare type CommandPlugin<Args extends CliArgs> = {
    id: string;
    instance: CommandPluginInstance<Args>;
};
export declare type ConfigPluginApplyCallbackArgs<Args extends CliArgs = CliArgs> = {
    api: ConfigPluginAPI;
} & CommonFields<Args>;
export declare type ConfigPluginApplyCallback<Args extends CliArgs = CliArgs> = (options: ConfigPluginApplyCallbackArgs<Args>) => void;
export interface ConfigPluginInstance<Args extends CliArgs = CliArgs> {
    apply: ConfigPluginApplyCallback<Args>;
}
export declare type ConfigPlugin<Args extends CliArgs = CliArgs> = {
    id: string;
    instance: ConfigPluginInstance<Args>;
};
export declare type WebpackConfiguration = webpack.Configuration & {
    devServer?: WebpackDevServer.Configuration;
};
export declare class UserConfig extends Config.ChainedMap<void> {
    externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this;
    module: Config.Module;
    plugins: Config.Plugins<this, webpack.Plugin>;
}
export declare type WebpackChainCallback = (config: Config, id: WebpackConfigName) => void;
export declare type WebpackRawConfigCallbackConfiguration = {
    module?: webpack.Module;
    plugins?: webpack.Plugin[];
    externals?: webpack.ExternalsElement[] | webpack.ExternalsElement;
};
export declare type WebpackRawConfigCallback = ((config: WebpackRawConfigCallbackConfiguration, id: WebpackConfigName) => WebpackRawConfigCallbackConfiguration | void) | WebpackRawConfigCallbackConfiguration;
export declare type CommandCallback = () => void | Promise<void>;
export declare type CommandList = Record<builtinServiceCommandName, {
    commandCallback: CommandCallback;
    opts: Record<string, unknown> | CommandCallback;
}>;
export declare type BuiltinWebpackConfigName = "public";
export declare type WebpackConfigName = "client" | "server";
export declare type WebpackConfigItem = {
    id: WebpackConfigName | BuiltinWebpackConfigName;
    config: Config;
    chainCallback: WebpackChainCallback[];
    rawCallback: WebpackRawConfigCallback[];
};
export declare type WebpackConfigQueue = Map<WebpackConfigName | BuiltinWebpackConfigName, WebpackConfigItem>;
export declare type ServeCliArgs = Partial<{
    entry: string;
    config: string;
    open: boolean;
    mode: string;
    host: string;
    port: string | number;
    https: boolean;
    public: string;
    help: boolean;
}>;
export declare type BuildCliArgs = Partial<{
    entry: string;
    config: string;
    mode: string;
    dest: string;
    report: boolean;
    help: boolean;
}>;
export declare type InspectCliArgs = Partial<{
    name: WebpackConfigName;
    mode: string;
    config: string;
    rule: string;
    plugin: string;
    rules: string[];
    plugins: string[];
    verbose: boolean;
    help: boolean;
}>;
export declare type Preset = preset;
export declare type PLUGIN_IDS = keyof RawPlugin;
export declare type CliArgs = ServeCliArgs | BuildCliArgs | InspectCliArgs;
export declare type ParsedArgs<T extends Record<string | number, unknown> = CliArgs> = {
    [K in keyof T]: T[K];
} & {
    "--"?: string[];
    _: string[];
};
export declare type UrlLoaderOptions = {
    limit: number;
    fallback: {
        loader: string;
        options: {
            name: string;
        };
    };
};
export declare type Context = {
    url: string;
    path: string;
    query: {};
    initProps: {};
    initState: {};
};
export declare type ServerEntry = (req: Context, staticRouterContext: StaticRouterContext, store: RematchStore | null, shared: Record<PropertyKey, unknown>) => null | Promise<JSX.Element>;
export declare type ServerBundle = {
    default: ServerEntry;
    createStore?: (initState: Record<PropertyKey, unknown>) => RematchStore | null;
};
