import { Manifest } from 'vite';
import { ModuleMap } from 'react-server-dom-webpack/server.edge';
import { RenderToReadableStreamOptions } from 'react-dom/server';

/**
 * A route that was created using `defineRoutes` or created conventionally from
 * looking at the files on the filesystem.
 */
interface ConfigRoute {
    /**
     * The path this route uses to match on the URL pathname.
     */
    path?: string;
    /**
     * Should be `true` if it is an index route. This disallows child routes.
     */
    index?: boolean;
    /**
     * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
     */
    caseSensitive?: boolean;
    /**
     * The unique id for this route, named like its `file` but without the
     * extension. So `app/routes/gists/$username.jsx` will have an `id` of
     * `routes/gists/$username`.
     */
    id: string;
    /**
     * The unique `id` for this route's parent route, if there is one.
     */
    parentId: string;
    /**
     * The path to the entry point for this route, relative to
     * `config.appDirectory`.
     */
    file: string;
    routeHandler?: boolean;
}
interface RouteManifest {
    [routeId: string]: ConfigRoute;
}

type AssetDesc = string | {
    type: "style";
    style: string;
    src?: string;
};
type Env = {
    clientModuleMap: ModuleMap;
    components: {
        [key: string]: any;
    };
    findAssets: () => Promise<Array<AssetDesc>>;
    routesConfig: {
        [key: string]: any;
    };
    manifests?: {
        buildAppRoot: string;
        srcAppRoot: string;
        clientManifest: Manifest;
        serverManifest: Manifest;
        reactServerManifest: Manifest;
        routesConfig: RouteManifest;
        findInServerManifest(chunk: string): string;
    };
    loadModule(id: string): Promise<any>;
    lazyComponent(id: string): React.FC<any>;
} & RenderToReadableStreamOptions;
declare global {
    var env: Env;
}

export { Env as E };
