import { Request as ExpressRequest } from 'express';
import { PartialDeep, RequiredDeep } from 'type-fest';
import { AssetInfo } from 'webpack';
import { BootConfig, Bootstrap, InitAppConfig, InitImaConfig } from './Bootstrap';
import { HttpAgentRequestOptions } from './http/HttpAgent';
import { HttpAgentImplCacheOptions } from './http/HttpAgentImpl';
import { ObjectContainer } from './oc/ObjectContainer';
import { RouteAction } from './router/Router';
import { GlobalImaObject } from './types';
export interface ManifestAsset extends AssetInfo {
    name: string;
}
export interface Manifest {
    assets: Record<string, ManifestAsset>;
    assetsByCompiler: Record<'server' | 'client' | 'client.es', Record<string, ManifestAsset>>;
    publicPath: string;
}
export type Resource = string | [
    string,
    {
        [attribute: string]: unknown;
        fallback: boolean;
    }
];
export interface Resources {
    styles: Resource[];
    scripts: Resource[];
    esScripts: Resource[];
}
/**
 * App environment for single env key.
 *
 * The production environment is used as a base template for other
 * environment configurations. Meaning that all `dev` or `test` env
 * definitions are deeply merged into `prod` base config.
 *
 * So you can only define other-env specific overrides without the need
 * to re-define whole custom configuration.
 */
export interface Environment {
    [key: string]: unknown;
    /**
     * Enable/disable debug mode. When enabled you can see additional
     * error messages while this also enable some additional validation
     * that can produce additional errors.
     */
    $Debug?: GlobalImaObject['$Debug'];
    $Language?: Record<string, string>;
    $Version: GlobalImaObject['$Version'];
    $App?: GlobalImaObject['$App'];
    $Resources?: (response: unknown, manifest: Manifest, defaultResources: Resources) => Resources;
    $Server?: {
        /**
         * When defined it overrides any other protocol
         * settings in the urlParser hook.
         */
        protocol?: GlobalImaObject['$Protocol'] | (({ environment, protocol, req, }: {
            environment: Environment;
            protocol: string;
            req: ExpressRequest;
        }) => GlobalImaObject['$Protocol']);
        /**
         * When defined it overrides any other
         * host settings in the urlParser hook.
         */
        host?: string | (({ environment, host, req, }: {
            environment: Environment;
            host: string;
            req: ExpressRequest;
        }) => string);
        /**
         * The port at which the server listens for incoming HTTP connections
         */
        port?: number;
        /**
         * Base path, which serves static files form the build folder,
         * see https://imajs.io/cli/ima-config-js/#publicpath for more info.
         * Used in staticPath middleware definition in app.js.
         */
        staticPath?: string;
        /**
         * The number of application instances (not threads) used to handle
         * concurrent connections within a single thread.
         */
        concurrency?: number;
        /**
         * Define the number of server processes you want to start.
         * Use `null` for the current number of available CPU cores.
         */
        clusters?: null | number;
        /**
         * Cache configuration.
         */
        cache?: {
            /**
             * Enable/disable cache for the server.
             */
            enabled?: boolean | ((req: ExpressRequest) => boolean);
            /**
             * Cache key generator function.
             */
            cacheKeyGenerator?: (req: ExpressRequest) => string;
            /**
             * The maximum time a cache entry is kept. [ms]
             */
            entryTtl?: number;
            /**
             * The time after which the unused entries are discarded. [ms]
             */
            unusedEntryTtl?: number;
            /**
             * The maximum entries in cache.
             */
            maxEntries?: number;
        };
        /**
         * Logger factory function that returns a logger instance with console-like methods.
         * The function may optionally accept environment parameters.
         */
        loggerFactory?: (params?: {
            environment: Environment;
        }) => {
            log: (...args: any[]) => void;
            info: (...args: any[]) => void;
            warn: (...args: any[]) => void;
            error: (...args: any[]) => void;
            debug: (...args: any[]) => void;
            [key: string]: any;
        };
        /**
         * Degradation functions for the server.
         */
        degradation?: {
            isSPA?: (event: any) => boolean;
            isSPAPrefetch?: (event: any) => boolean;
            isOverloaded?: (event: any) => boolean;
            isStatic?: (event: any) => boolean;
        };
    };
}
/**
 * Environment object after it has been processed by the environmentFactory.
 * It has default values set for all optional properties in the Environment
 * interface.
 *
 * The optional properties are made required since the environmentFactory
 * sets default values for them.
 */
export interface ParsedEnvironment extends RequiredDeep<Environment> {
}
/**
 * App Environment structure, used in ./server/config/environment.js
 */
export interface AppEnvironment {
    prod: Environment;
    dev?: PartialDeep<Environment>;
    test?: PartialDeep<Environment>;
    regression?: PartialDeep<Environment>;
}
export interface PageRendererSettings {
    batchResolve?: boolean;
    batchResolveNoTransaction?: boolean;
    masterElementId: string;
    documentView: unknown;
    managedRootView?: unknown;
    viewAdapter?: unknown;
}
/**
 * App settings for single env key.
 */
export interface Settings {
    $Http?: {
        defaultRequestOptions?: Omit<HttpAgentRequestOptions, 'abortController'>;
        cacheOptions?: HttpAgentImplCacheOptions;
    };
    $Router?: {
        /**
         * Middleware execution timeout, see https://imajs.io/basic-features/routing/middlewares#execution-timeout
         * for more information. [ms]
         */
        middlewareTimeout?: number;
        isSPARouted?: (url: string, action?: RouteAction) => boolean;
    };
    $Cache?: {
        /**
         * Default time to live for cached value. [ms]
         */
        ttl?: number;
        /**
         * Turn on/off cache for all application. [ms]
         */
        enabled?: boolean;
    };
    $Page: {
        $Render: PageRendererSettings;
    };
    $Observable?: {
        maxHistoryLength?: number;
    };
}
/**
 * Default settings provided by the ima core.
 */
export interface DefaultSettings extends Omit<Settings, '$Page'> {
}
/**
 * App settings function, used in ./app/config/settings.js
 */
export type AppSettings = {
    prod: Settings;
    dev?: PartialDeep<Settings>;
    test?: PartialDeep<Settings>;
    regression?: PartialDeep<Settings>;
};
export declare function getInitialImaConfigFunctions(): InitImaConfig;
export declare function getInitialPluginConfig(): {
    plugins: {
        name: string;
        plugin: import("./Bootstrap").InitPluginConfig;
    }[];
};
export declare function _getRoot(): typeof globalThis;
export declare function _isClient(): boolean;
export declare function createImaApp(): {
    oc: ObjectContainer;
    bootstrap: Bootstrap;
};
export declare function getClientBootConfig(initialAppConfigFunctions: InitAppConfig): BootConfig;
export declare function bootClientApp(app: {
    bootstrap: Bootstrap;
    oc: ObjectContainer;
}, bootConfig: BootConfig): Promise<{
    bootstrap: Bootstrap;
    oc: ObjectContainer;
}>;
export declare function routeClientApp(app: {
    bootstrap: Bootstrap;
    oc: ObjectContainer;
}, routerRoot?: EventTarget): Promise<void | import("./types").UnknownParameters>;
export declare function reviveClientApp(initialAppConfigFunctions: InitAppConfig, routerRoot?: EventTarget): Promise<import("./types").UnknownParameters & {
    app: {
        oc: ObjectContainer;
        bootstrap: Bootstrap;
    };
    bootConfig: BootConfig;
}>;
export declare function onLoad(): Promise<unknown>;
//# sourceMappingURL=boot.d.ts.map