import type { Loader, OnLoadArgs, BuildResult, OnEndResult, PluginBuild, OnLoadResult, OnResolveArgs, OnResolveResult, BuildOptions, Format, Metafile, Message } from "esbuild";
import type { IncomingMessage, ServerResponse } from "http";
import type { SourceService } from "@remotex-labs/xmap";
import type { Argv } from "yargs";
import type { ChildProcessWithoutNullStreams } from "child_process";
import type { ParsedCommandLine } from "typescript";
import type { Context } from "vm";
/**
 * Interface for the build state that users can modify.
 *
 * This interface allows users to store and manage any custom data related to the build process.
 *
 * @template T - The type of values that can be stored in the state.
 */
export interface BuildState {
    [key: string]: unknown;
}
/**
 * A type that defines the possible return values of a plugin function.
 *
 * The function can return a Promise that resolves to `null` or `void`, or it can return `null` or `void` directly.
 */
export type pluginResultType = Promise<null | void> | null | void;
/**
 * Defines the signature of a function that is called at the end of the build process.
 *
 * @param result - The `BuildResult` object that contains information about the outcome of the build process.
 * @param state - The current build state that users can modify.
 * @returns A `pluginResultType`, which may include asynchronous operations.
 */
export type OnEndType = (result: BuildResult, state: BuildState) => pluginResultType | OnEndResult | Promise<OnEndResult>;
/**
 * Defines the signature of a function that is called at the start of the build process.
 *
 * @param build - The `PluginBuild` object that contains information about the build process and allows modifying build options.
 * @param state - The current build state that users can modify.
 * @returns A `pluginResultType`, which may include asynchronous operations.
 */
export type OnStartType = (build: PluginBuild, state: BuildState) => pluginResultType | OnEndResult | Promise<OnEndResult>;
/**
 * Defines the signature of a function that is called during the resolution of an import path.
 *
 * @param args - The `OnResolveArgs` object, containing information about the file being resolved, such as its path, importer, namespace, etc.
 * @param state - The current build state that users can modify.
 * @returns A `Promise` or a direct `OnResolveResult` which can modify the resolved path, or a `pluginResultType` for
 * performing additional async tasks without altering resolution.
 */
export type OnResolveType = (args: OnResolveArgs, state: BuildState) => Promise<OnResolveResult | pluginResultType> | OnResolveResult | pluginResultType;
/**
 * Defines the signature of a function that is called when a file is loaded.
 *
 * @param content - The content of the file being loaded, as either a `string` or `Uint8Array`.
 * @param loader - The type of loader used for the file, such as `js`, `ts`, `json`, or others. It can also be `undefined`.
 * @param args - The `OnLoadArgs` object, containing information about the file being loaded, such as its path, namespace, etc.
 * @param state - The current build state that users can modify.
 * @returns A `Promise` or direct `OnLoadResult`, which can modify the file content and loader, or a `pluginResultType`
 * for performing additional async tasks without altering the content.
 */
export type OnLoadType = (content: string | Uint8Array, loader: Loader | undefined, args: OnLoadArgs, state: BuildState) => Promise<OnLoadResult | pluginResultType> | OnLoadResult | pluginResultType;
/**
 * Represents the format for specifying entry points in TypeScript declaration generation.
 *
 * This type allows for various formats to specify the entry points from which TypeScript declaration files should be generated.
 * The supported formats are:
 * - `Array<string>`: An array of file paths as strings. Each string represents a path to a TypeScript entry point file.
 * - `Record<string, string>`: An object where each key-value pair represents an entry point.
 *
 * The key is a name or identifier, and the value is the file path to the TypeScript entry point.
 * - `Array<{ in: string, out: string }>`: An array of objects, where each object specifies an input file path (`in`)
 * and an output file path (`out`). This format allows for specifying where each entry point file is located and
 * where its corresponding declaration file should be output.
 *
 * Example usage:
 *
 * ```ts
 * const entryPoints1: EntryPoints = ['src/index.ts', 'src/utils.ts'];
 * const entryPoints2: EntryPoints = { main: 'src/index.ts', utils: 'src/utils.ts' };
 * const entryPoints3: EntryPoints = [{ in: 'src/index.ts', out: 'dist/index.d.ts' }, { in: 'src/utils.ts', out: 'dist/utils.d.ts' }];
 * ```
 */
export type EntryPoints = Array<string> | Record<string, string> | Array<{
    in: string;
    out: string;
}> | undefined;
/**
 * Represents a deeply nested partial version of a given type `T`.
 *
 * This type utility allows for partial objects at any level of nesting.
 * It recursively makes all properties optional and applies the same behavior to nested objects.
 *
 * **Example Usage:**
 *
 * ```ts
 * interface User {
 *     name: string;
 *     address: {
 *         street: string;
 *         city: string;
 *     };
 * }
 *
 * // PartialDeep<User> will allow the following:
 * const partialUser: PartialDeep<User> = {
 *     name: 'Alice',        // 'name' is optional
 *     address: {
 *         city: 'Wonderland' // 'street' is optional
 *     }
 * };
 * ```
 *
 * @template T - The type to be made partially optional and deeply nested.
 *
 * @typeParam T - The base type to apply the partial transformation.
 *
 * @example
 * ```
 * type MyPartial = PartialDeep<{ a: number; b: { c: string; d: { e: boolean } } }>;
 * // MyPartial will be equivalent to:
 * // {
 * //   a?: number;
 * //   b?: {
 * //     c?: string;
 * //     d?: {
 * //       e?: boolean;
 * //     }
 * //   }
 * // }
 * ```
 */
export type PartialDeep<T> = {
    [P in keyof T]?: T[P] extends object ? PartialDeep<T[P]> : T[P];
};
/**
 * Represents a module with its exports and an optional default export.
 *
 * This interface provides a structure to define and interact with the exports of a module.
 * It includes both named and default exports, where default exports are of a specific type.
 *
 * @interface ModuleInterface
 *
 * @property exports - An object representing the exports of the module.
 * The keys are strings that represent the names of the exports, and the values can be of any type.
 *
 * @property exports[key: string] - A dictionary where each key is a string representing the export name,
 * and the associated value can be of any type.
 *
 * @property [exports.default] - An optional default export.
 * The default export, if present, is of type `ConfigurationInterface`.
 */
export interface ModuleInterface {
    /**
     * An object representing the exports of the module.
     * The keys are strings representing export names, and the values can be of any type.
     *
     * @property default - An optional default export of type `ConfigurationInterface`.
     */
    exports: {
        [key: string]: unknown;
        default?: ConfigurationInterface;
    };
}
/**
 * Configuration options for the serve the build.
 *
 * This object allows you to specify various settings related to the server,
 * such as the port, host, SSL/TLS certificates, and request handling functions.
 *
 * @example
 * ```ts
 * const serverConfig = {
 *     serve: {
 *         active: true,
 *         port: 8080,
 *         host: 'localhost',
 *         keyfile: '/path/to/ssl/keyfile.pem',
 *         certfile: '/path/to/ssl/certfile.pem',
 *         onStart: () => {
 *             console.log('Server started');
 *         }
 *         onRequest: (req, res, next) => {
 *             console.log('Server request received');
 *             next();
 *         }
 *     }
 * };
 * ```
 *
 * @public
 */
export interface Serve {
    port: number;
    host: string;
    active: boolean;
    keyfile?: string;
    certfile?: string;
    onRequest?: (req: IncomingMessage, res: ServerResponse, next: () => void) => void;
    onStart?: () => void;
}
/**
 * Defines the lifecycle hooks used in the plugin system.
 *
 * This interface specifies the types for various hooks that can be registered
 * to customize the behavior of the build process. Each hook corresponds to a
 * specific stage in the lifecycle of an esbuild operation.
 *
 * @interface hooks
 *
 * @property onEnd - A hook function that is called after the build process completes.
 *                               This allows for post-processing or cleanup tasks.
 * @property onLoad - A hook function that is called when esbuild attempts to load a module.
 *                                 It can be used to modify the contents of the loaded module.
 * @property onStart - A hook function that is called before the build process starts.
 *                                    This is useful for initialization tasks or logging.
 * @property onResolve - A hook function that is called when esbuild attempts to resolve a module path.
 *                                        It can be used to customize module resolution behavior.
 *
 * @example
 * ```ts
 * const myHooks: hooks = {
 *     onEnd: async (result) => {
 *         console.log('Build finished:', result);
 *     },
 *     onLoad: async (contents, loader, args) => {
 *         // Modify contents if necessary
 *         return { contents, loader };
 *     },
 *     onStart: async (build) => {
 *         console.log('Build started:', build);
 *     },
 *     onResolve: async (args) => {
 *         if (args.path === 'my-module') {
 *             return { path: './src/my-module.ts' };
 *         }
 *         return null;
 *     }
 * };
 * ```
 *
 * @see OnEndType
 * @see OnLoadType
 * @see OnStartType
 * @see OnResolveType
 */
export interface hooks {
    onEnd: OnEndType;
    onLoad: OnLoadType;
    onStart: OnStartType;
    onSuccess: OnEndType;
    onResolve: OnResolveType;
}
/**
 * Represents the configuration options for the build and development process.
 *
 * This interface defines various settings that control how the application is built and run, including development mode,
 * file watching, TypeScript declaration generation, error handling, TypeScript type checking, and esbuild bundler options.
 *
 * @example
 * ```ts
 * const config: ConfigurationInterface = {
 *     dev: true,
 *     watch: true,
 *     declaration: true,
 *     buildOnError: false,
 *     noTypeChecker: false,
 *     esbuild: {
 *         entryPoints: ['./src/index.ts'],
 *         bundle: true,
 *         minify: true,
 *         target: 'es2020'
 *     },
 *     hooks: {
 *         onStart: async (build) => {
 *             console.log('Build started');
 *         },
 *         onEnd: async (result) => {
 *             console.log('Build finished:', result);
 *         }
 *     }
 * };
 * ```
 *
 * In this example, the configuration sets the application to development mode with file watching enabled,
 * generates TypeScript declaration files, continues building on TypeScript errors, and includes esbuild options for bundling and minification.
 * Additionally, custom hooks are provided to log messages at the start and end of the build process.
 *
 * @public
 * @category Configuration
 */
export interface ConfigurationInterface {
    /**
     * Build and run entryPoint for development
     */
    dev: boolean | Array<string>;
    /**
     * Enables watching for file changes during development.
     */
    watch: boolean;
    /**
     * The directory where the generated `package.json` file will be saved,
     * indicating the module type (`"commonjs"` or `"module"`).
     *
     * - If the format is `esm`, the `package.json` file will contain `"type": "module"`.
     * - If the format is `cjs`, the `package.json` file will contain `"type": "commonjs"`.
     *
     * If this field is not set (`undefined`), the `package.json` file will be saved in the
     * `outdir` specified in the esbuild configuration.
     *
     * Example:
     *
     * ```ts
     * {
     *   esbuild: {
     *     outdir: 'dist',
     *     format: 'esm'
     *   },
     *   moduleTypeOutDir: 'custom/dist'
     * }
     * // This will create 'custom/dist/package.json' with the content: {"type": "module"}
     *
     * // If moduleTypeOutDir is not provided:
     * {
     *   esbuild: {
     *     outdir: 'dist',
     *     format: 'cjs'
     *   }
     * }
     * // This will create 'dist/package.json' with the content: {"type": "commonjs"}
     * ```
     */
    moduleTypeOutDir?: string;
    /**
     * Generates TypeScript declaration files.
     */
    declaration: boolean;
    /**
     * Bundle declaration file
     */
    bundleDeclaration: boolean;
    /**
     * Overrides the output directory for TypeScript declaration files (.d.ts).
     *
     * If this option is not set, the output directory specified in the `outDir`
     * field of your `tsconfig.json` will be used.
     * This allows for custom control
     * over where the declaration files are emitted, separate from the main
     * output directory for compiled JavaScript files.
     *
     * @default The `outDir` from `tsconfig.json` will be used if this is not provided.
     */
    declarationOutDir?: string;
    /**
     * Continues building even if TypeScript type errors are present.
     */
    buildOnError: boolean;
    /**
     * Skips TypeScript type checking.
     */
    noTypeChecker: boolean;
    /**
     * Options for the esbuild bundler.
     */
    esbuild: BuildOptions;
    /**
     * Option for the serve the build over http/s
     */
    serve: Serve;
    /**
     * lifecycle hooks to customize the build process.
     *
     * This property allows you to provide implementations for various hooks defined in the `hooks` interface.
     * Using `Partial<hooks>` means you can specify only the hooks you want to implement,
     * while the others will default to `undefined`.
     */
    hooks?: Partial<hooks>;
    /**
     * A dictionary of define options for the build process.
     *
     * This property allows you to specify global constants that can be replaced during the build process.
     * Each key-value pair in the `define` object represents a constant where the key is the name of the
     * constant, and the value is the string to replace it with. This is particularly useful for feature flags,
     * environment-specific configurations, or any other value that you may want to define at compile time.
     *
     * @example
     * ```ts
     * const config: ConfigurationInterface = {
     *     dev: true,
     *     define: {
     *         'process.env.NODE_ENV': 'development',
     *         'API_URL': 'https://api.example.com'
     *     }
     * };
     * ```
     *
     * In this example, the constants `process.env.NODE_ENV` and `API_URL` will be replaced with their
     * corresponding values during the build, making it easy to manage different configurations across
     * various environments.
     *
     * @public
     */
    define: Record<string, unknown>;
    /** Documentation: https://esbuild.github.io/api/#banner */
    banner?: {
        [type: string]: string | (() => string);
    };
    /** Documentation: https://esbuild.github.io/api/#footer */
    footer?: {
        [type: string]: string | (() => string);
    };
}
interface ExportedConfigurationInterface extends ConfigurationInterface {
    /**
     * Options for the esbuild bundler.
     */
    esbuild: Omit<BuildOptions, 'plugins' | 'define'>;
}
/**
 * Type alias for a partial configuration object.
 *
 * This type represents a configuration where all properties of the
 * `ConfigurationInterface` are optional. It allows for flexible configuration
 * objects where only a subset of properties need to be specified.
 */
export type xBuildConfig = PartialDeep<ExportedConfigurationInterface>;
/**
 * Represents a partially deep configuration type based on the `ConfigurationInterface`.
 *
 * This type is used to define configurations that may have some properties
 * missing or undefined. It leverages the `PartialDeep` utility type to allow
 * for flexibility in configuration management.
 */
export type PartialDeepConfigurationsType = PartialDeep<ConfigurationInterface>;
/**
 * Defines the possible types for configurations.
 *
 * This type can either be a single instance of `PartialDeepConfigurationsType`
 * or an array of such instances. This flexibility allows for configurations
 * to be specified as a single object or as multiple objects, enabling
 * support for various build setups.
 *
 * @example
 * ```ts
 * // A single configuration object
 * const config: ConfigurationsType = {
 *     esbuild: {
 *         bundle: true,
 *         outdir: 'dist'
 *     }
 * };
 * ```
 *
 * @example
 * ```ts
 * // An array of configuration objects
 * const configs: ConfigurationsType = [
 *     {
 *         esbuild: {
 *             bundle: true,
 *             outdir: 'dist/esm'
 *         }
 *     },
 *     {
 *         esbuild: {
 *             bundle: false,
 *             outdir: 'dist/cjs',
 *             declaration: false,
 *             noTypeChecker: true
 *         }
 *     }
 * ];
 * ```
 */
export type ConfigurationsType = PartialDeepConfigurationsType | Array<PartialDeepConfigurationsType>;
/**
 * Interface representing the command-line arguments for the build tool.
 *
 * @interface ArgvInterface
 * @property typeCheck - Flag indicating if the tool should perform type checking only.
 * @property node - Flag indicating if the build is intended for Node.js environment.
 * @property file - The entry file(s) to build.
 * @property dev - List of development-related options for the build.
 * @property debug - List of debugging-related options for the build.
 * @property serve - Flag indicating if an HTTP server should be started for the build folder.
 * @property outdir - The output directory for the build files.
 * @property declaration - Flag indicating if TypeScript declaration files should be generated.
 * @property watch - Flag indicating if the build should watch for file changes.
 * @property config - Path to the build configuration file (JavaScript or TypeScript).
 * @property tsconfig - Path to the TypeScript configuration file to use.
 * @property minify - Flag indicating if the code should be minified.
 * @property bundle - Flag indicating if the code should be bundled.
 * @property format - Defines the formats for the build output.
 */
export interface ArgvInterface {
    typeCheck: boolean;
    node: boolean;
    file: string;
    dev: Array<string>;
    debug: Array<string>;
    serve: boolean;
    outdir: string;
    declaration: boolean;
    watch: boolean;
    config: string;
    tsconfig: string;
    minify: boolean;
    bundle: boolean;
    format: Format;
}
/**
 * Represents an enhanced error type that extends the built-in Error object.
 * This type adds an optional property to store call stack information.
 *
 * @type ErrorType
 *
 * @extends Error
 *
 * @property callStacks - An optional array of call sites
 *   captured when the error was created. This can provide additional context
 *   regarding the call stack at the time of the error, useful for debugging.
 *
 * @example
 * ```ts
 * const myError: ErrorType = new Error("Something went wrong!");
 * myError.callStacks = getCallStack(); // Assuming getCallStack captures call sites.
 * console.error(myError);
 * ```
 */
export type ErrorType = Error & {
    callStacks?: Array<NodeJS.CallSite>;
};
/**
 * Represents the state of a stack trace, containing information about the error, associated code, and formatted error message.
 *
 * @interface StackTraceStateInterface
 * @property error - The error object with attached `callStacks`.
 * @property blockCode - The block of code (if any) related to the error, or `null` if unavailable.
 * @property formattedError - A formatted string representing the error details.
 */
export interface StackTraceStateInterface {
    error: ErrorType & BaseError;
    blockCode: null | string;
    formattedError: string;
}
/**
 * Represents detailed information about a specific frame in the call stack.
 *
 * @interface FrameDetailsInterface
 * @property line - The line number where the frame occurred.
 * @property column - The column number where the frame occurred.
 * @property source - The source file path where the frame occurred.
 * @property functionName - The name of the function being executed at this frame, or an empty string if not available.
 */
export interface FrameDetailsInterface {
    line: number;
    column: number;
    source: string;
    functionName: string;
}
/**
 * A base class for custom errors with enhanced stack trace formatting and source code information.
 *
 * The `BaseError` class extends the native `Error` class, adding functionality to format the error stack
 * trace and include details from a source map service. This is useful for debugging errors in compiled
 * or transpiled code by providing clearer information about the source of the error.
 */
export declare abstract class BaseError extends Error {
    readonly sourceMap?: SourceService | undefined;
    callStacks: Array<NodeJS.CallSite>;
    /**
     * Creates a new instance of `BaseError`.
     *
     * This constructor initializes a new `BaseError` instance by setting the error message and formatting
     * the stack trace using the provided source map information. It also ensures the stack trace is maintained
     * correctly by using `Error.captureStackTrace` (if available). The default source map service is used if
     * none is provided.
     *
     * @param message - A descriptive error message to be associated with the error.
     * @param sourceMap - (Optional) The `SourceService` instance used to format and resolve the stack trace.
     *                    If not provided, the default source map service (`defaultSourceService`) is used.
     */
    protected constructor(message: string, sourceMap?: SourceService | undefined);
    /**
     * Reformats the error stack trace using source map information.
     *
     * This function enhances the original error stack trace by attempting to map each entry
     * back to its original position in the source file using the provided source map service.
     * If the source map information is not available, it returns the original stack trace.
     *
     * @param error - The original error with stack trace of the error.
     * @returns The reformatted stack trace or the original stack trace if no mapping is available.
     */
    protected reformatStack(error: ErrorType): string;
}
/**
 * An enumeration of ANSI color codes used for text formatting in the terminal.
 *
 * These colors can be used to format terminal output with various text colors,
 * including different shades of gray, yellow, and orange, among others.
 *
 * Each color code starts with an ANSI escape sequence (`\u001B`), followed by the color code.
 * The `Reset` option can be used to reset the terminal's text formatting back to the default.
 *
 * @example
 * ```ts
 * console.log(Color.BrightPink, 'This is bright pink text', Color.Reset);
 * ```
 */
export declare const enum Colors {
    Reset = "\u001B[0m",
    Red = "\u001B[38;5;9m",
    Gray = "\u001B[38;5;243m",
    Cyan = "\u001B[38;5;81m",
    DarkGray = "\u001B[38;5;238m",
    LightCoral = "\u001B[38;5;203m",
    LightOrange = "\u001B[38;5;215m",
    OliveGreen = "\u001B[38;5;149m",
    BurntOrange = "\u001B[38;5;208m",
    LightGoldenrodYellow = "\u001B[38;5;221m",
    LightYellow = "\u001B[38;5;230m",
    CanaryYellow = "\u001B[38;5;227m",
    DeepOrange = "\u001B[38;5;166m",
    LightGray = "\u001B[38;5;252m",
    BrightPink = "\u001B[38;5;197m"
}
/**
 * Formats a message string with the specified ANSI color and optionally resets it after the message.
 *
 * This function applies an ANSI color code to the provided message,
 * and then appends the reset code to ensure that the color formatting doesn't extend beyond the message.
 * It's useful for outputting colored text in a terminal. If color formatting is not desired,
 * the function can return the message unformatted.
 *
 * @param color - The ANSI color code to apply. This is used only if `activeColor` is true.
 * @param msg - The message to be formatted with the specified color.
 * @param activeColor - A boolean flag indicating whether color formatting should be applied. Default is `__ACTIVE_COLOR`.
 *
 * @returns A string with the specified color applied to the message,
 * followed by a reset sequence if `activeColor` is true.
 *
 * @example
 * ```ts
 * const coloredMessage = setColor(Colors.LightOrange, 'This is a light orange message');
 * console.log(coloredMessage);
 * ```
 *
 * @example
 * ```ts
 * const plainMessage = setColor(Colors.LightOrange, 'This is a light orange message', false);
 * console.log(plainMessage); // Output will be without color formatting
 * ```
 */
export declare function setColor(color: Colors, msg: string, activeColor?: boolean): string;
export declare const xBuildLazy: {
    readonly service: SourceService;
};
/**
 * Prepares the error stack trace for display.
 *
 * This function overrides the default stack trace preparation to provide a custom format,
 * including enhanced stack trace information and error details.
 *
 * @param error - The error object (Error or BaseError).
 * @param stackEntries - The array of stack entries from the call stack.
 * @returns The formatted stack trace as a string.
 */
export declare function formatStackTrace(error: ErrorType & BaseError, stackEntries: Array<NodeJS.CallSite>): string;
/**
 * Parses command-line arguments into an `ArgvInterface` object using `yargs`.
 *
 * This function configures `yargs` to handle various build-related options for a JavaScript and TypeScript toolchain.
 * It returns an object that adheres to the `ArgvInterface` structure based on the parsed arguments.
 *
 * @param argv - An array of command-line arguments (e.g., `process.argv`).
 * @returns An object representing the parsed command-line arguments.
 *
 * @see {@link ArgvInterface} for the structure of the returned object.
 *
 * @example
 * // Example usage:
 * const args = argvParser(process.argv);
 * console.log(args.file); // Output: the file to build
 * console.log(args.dev); // Output: true or false based on the --dev flag
 */
export declare function argvParser(argv: Array<string>): Argv<ArgvInterface>;
/**
 * The `BuildStateInterface` extends the `BuildState` interface to include additional properties related to the build
 * process, specifically for handling `ifdef` conditions and function removals in macros.
 *
 * @interface BuildStateInterface
 */
export interface BuildStateInterface extends BuildState {
    ifdef: Array<string>;
    macros: {
        removeFunctions: Set<string>;
    };
}
/**
 * Spawns a new Node.js process to execute the provided JavaScript file, with optional debugging support.
 *
 * This function creates a new Node.js process to run the specified JavaScript file with source map support enabled.
 * It optionally starts the process in debug mode, which allows WebStorm or other debuggers to attach to the process.
 * The output and error streams of the spawned process are captured and logged to the console.
 *
 * @param filePath - The path to the JavaScript file to execute.
 * @param debug - A boolean flag to enable debugging. If `true`, the process will be started with the `--inspect-brk` option,
 * which opens a debugger on `0.0.0.0:9229`, allowing external debuggers to attach.
 *
 * @returns A `ChildProcessWithoutNullStreams` object representing the spawned process.
 * This object allows interaction with the process, including capturing its output and error streams.
 *
 * @remarks
 * - The `--enable-source-maps` flag is used to enable source map support, which allows better debugging by mapping
 *   errors and stack traces to the original source code.
 * - If `debug` is `true`, the `--inspect-brk=0.0.0.0:9229` flag is added, starting the process in debug mode and pausing
 *   execution until a debugger is attached.
 * - The output (`stdout`) and error (`stderr`) streams of the spawned process are logged to the console.
 * - The function returns a `ChildProcessWithoutNullStreams` object that can be used to interact with the spawned process,
 *   such as handling its termination or sending input.
 *
 * @throws Error Throws an error if the Node.js process fails to start or if there are issues with the provided file path.
 *
 * @example
 * ```ts
 * import { spawn } from '@services/process.service';
 *
 * // Run without debugging
 * const process = spawn('./path/to/script.js', false);
 *
 * process.on('close', (code) => {
 *     console.log(`Process exited with code ${code}`);
 * });
 *
 * // Run with debugging enabled
 * const debugProcess = spawn('./path/to/script.js', true);
 *
 * debugProcess.on('close', (code) => {
 *     console.log(`Debug process exited with code ${code}`);
 * });
 * ```
 *
 * In these examples, the `spawn` function is used to execute a JavaScript file, once in normal mode and once with debugging enabled.
 * The process's exit code is logged when the process completes.
 *
 * @public
 * @category Services
 */
export declare function spawn(filePath: string, debug?: boolean): ChildProcessWithoutNullStreams;
/**
 * Represents the result of transpiling a TypeScript file.
 *
 * This interface defines the structure of the output returned from a TypeScript transpilation process,
 * including the transpiled JavaScript code and the associated source map.
 *
 * @property code - The transpiled JavaScript code generated from the TypeScript file.
 * @property sourceMap - The source map associated with the transpiled JavaScript code.
 *
 * @remarks
 * - The `code` property contains the JavaScript code after TypeScript transpilation.
 * - The `sourceMap` property provides the source map that maps the transpiled JavaScript code back to the original TypeScript source.
 * - The source map is useful for debugging as it allows developers to trace errors in the generated JavaScript back to the original TypeScript code.
 *
 * @example
 * ```typescript
 * import { transpileFileInterface } from './transpileFileInterface';
 *
 * const result: transpileFileInterface = {
 *     code: 'console.log("Hello, world!");',
 *     sourceMap: 'version: 3\nfile: out.js\nsources: ["file.ts"]\n'
 * };
 *
 * console.log(result.code); // Output: console.log("Hello, world!");
 * console.log(result.sourceMap); // Output: version: 3\nfile: out.js\nsources: ["file.ts"]\n
 * ```
 *
 * In this example, the `transpileFileInterface` is used to represent the result of transpiling a TypeScript file.
 * The `code` contains the JavaScript code, while the `sourceMap` provides the mapping information for debugging purposes.
 *
 * @public
 * @category Interfaces
 */
export interface transpileFileInterface {
    code: string;
    sourceMap: string;
}
/**
 * Represents an error specific to the xBuild process.
 *
 * The `xBuildError` class extends the `BaseError` class to provide a custom error type for the xBuild system.
 * It includes additional functionality to maintain stack trace information and assigns a specific name to
 * the error, making it easier to identify and handle in different parts of the application.
 *
 * @augments BaseError
 */
export declare class xBuildError extends BaseError {
    /**
     * Original error stack
     */
    originalErrorStack: string | undefined;
    /**
     * Creates an instance of `xBuildError`.
     *
     * @param message - The error message that describes the error. This message is passed to the base class
     *   `BaseError` constructor and is used to provide context about the nature of the error.
     * @param options - Optional configuration for the error. This can include additional properties or settings
     *   that customize the error's behavior.
     */
    constructor(message: string, options?: ErrorOptions);
}
/**
 * Default build options for esbuild bundler in RemoteX framework.
 *
 * These options are used to configure how esbuild processes and bundles the TypeScript
 * files for the RemoteX testing framework.
 *
 * @public
 * @category Configuration
 */
export declare const defaultBuildOptions: BuildOptions;
/**
 * Extracts the source map from the provided data string and returns the modified code and source map separately.
 *
 * This function searches for the inline source map in the data string using a regular expression, removes the
 * source map comment from the data string, and returns an object containing the code without the source map
 * comment and the extracted source map.
 *
 * @param dataString - The string containing the transpiled code with an inline source map.
 * @returns An object containing the modified code without the source map comment and the extracted source map.
 * @throws Error -Throws an error if the source map URL is not found in the data string.
 *
 * @public
 */
export declare function extractSourceMap(dataString: string): transpileFileInterface;
/**
 * Transpiles a TypeScript file and extracts the source map.
 *
 * This function uses esbuild to transpile the specified TypeScript file based on provided build options,
 * and then extracts the source map from the transpiled code.
 *
 * @param filePath - The path to the TypeScript file to be transpiled.
 * @param buildOptions - Optional build options to override the default build options.
 * @returns A promise that resolves to an object containing the transpiled code and the extracted source map.
 * @throws Error - Throws an error if the build process fails or the source map extraction fails.
 *
 * @public
 * @category Services
 */
export declare function transpileFile(filePath: string, buildOptions?: BuildOptions): Promise<transpileFileInterface>;
/**
 * The `analyzeDependencies` function analyzes the dependencies of a given entry point for a specified platform.
 * It performs a bundling operation and generates a metafile that contains detailed information about the
 * dependencies involved in the build process.
 * This is typically used to inspect the external packages and modules
 * that the entry point depends on.
 *
 * - **Input**:
 *   - `entryPoint`: A string or array of strings representing the entry points for the build.
 *   This defines the starting point(s) for the bundling process.
 *   - `platform`: An optional parameter that specifies the platform to target for the build.
 *   Default is `'browser'`.
 *
 * - **Output**: A `Promise` that resolves to an object containing:
 *   - The `BuildResult` from the bundling process.
 *   - A `metafile`, which contains detailed metadata about the build, including the dependencies analyzed.
 *
 * ## Example:
 *
 * ```ts
 * const result = await analyzeDependencies(['src/index.ts']);
 * console.log(result.metafile); // { inputs: { 'src/index.ts': { ... } }, outputs: { ... } }
 *
 * const nodeResult = await analyzeDependencies(['src/server.ts'], 'node');
 * console.log(nodeResult.metafile); // { inputs: { 'src/server.ts': { ... } }, outputs: { ... } }
 * ```
 *
 * @param entryPoint - The entry point(s) to be analyzed.
 * @param platform - The target platform for the build.
 * @returns A `Promise` that resolves to a `BuildResult` object along with a `metafile` containing dependency details.
 * @throws Error If the build process fails for any reason.
 */
export declare function analyzeDependencies(entryPoint: EntryPoints, platform?: BuildOptions['platform']): Promise<BuildResult & {
    metafile: Metafile;
}>;
/**
 * The `collectFunctionNames` function analyzes the provided TypeScript code and collects the names of functions
 * that should be removed based on specific conditions. The function searches for function declarations and variable
 * declarations where the function name or variable is prefixed with `$$`, and adds these function names to the
 * `removeFunctions` set in the provided `state` object.
 *
 * - **Input**:
 *   - `code`: A string containing the TypeScript code to be analyzed.
 *   - `state`: An object representing the current build state, specifically the `mocks` state, which includes
 *     a `removeFunctions` set that will hold the names of functions that need to be removed.
 *
 * - **Output**: The function does not return any value. Instead, it modifies the `removeFunctions` set inside the
 *   `state` object by adding function names that meet the criteria for removal.
 *
 * ## Error Handling:
 * - The function does not explicitly handle errors. If invalid TypeScript code is provided, `ts.createSourceFile`
 *   may throw an error, which should be handled by the caller if necessary.
 *
 * @param code - The TypeScript code as a string that will be analyzed.
 * @param state - The build state containing the `removeFunctions` set to store the names of functions to be removed.
 * @returns `void` - The function modifies the `state` directly and does not return a value.
 */
export declare function collectFunctionNames(code: string, state: BuildStateInterface['macros']): void;
/**
 * The `collectDeclaredFunctions` function processes the provided `meta` metafile and reads each file's contents
 * to find function declarations within preprocessor directives. It uses regular expressions to match `// ifdef` and
 * `// endif` blocks in the code and collects the function names from the code inside the `ifdef` block, based on the
 * `define` configuration in the `config` object. If the condition defined in the `ifdef` is not met (i.e., not defined
 * in the `config.define`), the function names found inside the block will be collected and added to the `removeFunctions`
 * set in the `state` object.
 *
 * - **Input**:
 *   - `meta`: The `Metafile` object that contains the input files. The keys are file paths, and the values contain
 *     metadata about those files.
 *   - `config`: The configuration object containing a `define` field, which is an object of conditions that may be used
 *     in the `ifdef` blocks. If a condition in an `ifdef` block is not defined in `config.define`, the functions in
 *     that block will be collected.
 *   - `state`: The build state, specifically the `mocks` state, which includes a `removeFunctions` set that stores
 *     function names to be removed.
 *
 * - **Output**: This function does not return a value. It modifies the `removeFunctions` set within the provided `state`
 *   object by adding the names of functions found inside unprocessed `ifdef` blocks.
 *
 * ## Error Handling:
 * - If a file cannot be read due to a filesystem error, the function will throw an error.
 * - If the provided `meta` or `config` is malformed, it may result in runtime errors. The caller should ensure valid input.
 *
 * @param meta - The `Metafile` object containing the list of input files and their metadata.
 * @param config - The configuration object that defines conditions used in `ifdef` blocks.
 * @param state - The build state containing the `removeFunctions` set to store function names to be removed.
 * @returns `void` - The function modifies the `state` directly and does not return a value.
 */
export declare function collectDeclaredFunctions(meta: Metafile, config: ConfigurationInterface, state: BuildStateInterface['macros']): Promise<void>;
/**
 * The `parseMacros` function processes TypeScript or JavaScript files to transform macros defined within the content.
 * It ensures that the build state is initialized if necessary, analyzes file dependencies, collects declared functions
 * that are marked for removal, and applies transformations to the source code based on the macros.
 * If the file's extension is not `.ts` or `.js`, the function returns `undefined`. Otherwise, it transforms the code
 * and returns the result in the specified loader format.
 *
 * - **Input**:
 *   - `content`: The content of the file as a string or `Uint8Array` to be parsed.
 *   - `loader`: A string representing the loader type for transforming the code (e.g., `'ts'`, `'js'`).
 *   - `args`: The `OnLoadArgs` object containing metadata for the current loading process, including the file path.
 *   - `state`: The build state containing the `mocks` object, which includes a `removeFunctions` set that tracks
 *     functions to be removed.
 *   - `config`: The configuration object that defines how macros should be handled (e.g., conditions for macro processing).
 *
 * - **Output**: A `Promise` that resolves to an `OnLoadResult`, `pluginResultType`, or `undefined`. If the file is
 *   of type `.ts` or `.js`, the transformed code is returned in the specified loader format (e.g., `'ts'`). If the file
 *   extension is not recognized, the function returns `undefined`.
 *
 * ## Error Handling:
 * - If the file path does not end with `.ts` or `.js`, the function returns `undefined`.
 * - If `state.mocks` is not initialized, it will be set up by analyzing the file dependencies and collecting declared functions.
 * - If any errors occur during the analysis, function collection, or transformation, the function may throw an error.
 *
 * @param content - The content of the file as a string or `Uint8Array` to be parsed.
 * @param loader - The loader type for transforming the code (e.g., `'ts'` or `'js'`).
 * @param args - The `OnLoadArgs` containing metadata, including the file path.
 * @param state - The build state that includes `mocks` with the `removeFunctions` set.
 * @param config - The configuration object defining how macros should be handled.
 * @returns A `Promise` that resolves to the transformed code (`OnLoadResult` or `pluginResultType`), or `undefined`
 *          if the file is not of type `.ts` or `.js`.
 */
export declare function parseMacros(content: string | Uint8Array, loader: Loader | undefined, args: OnLoadArgs, state: BuildStateInterface, config: ConfigurationInterface): Promise<OnLoadResult | pluginResultType | undefined>;
/**
 * Represents an error that occurs during the esbuild process.
 *
 * This class extends the base error class to provide specific error handling for esbuild-related issues.
 * It captures the error message and maintains the proper stack trace, allowing for easier debugging
 * and identification of errors that occur during the build process.
 *
 * @class esBuildError
 * @extends BaseError
 */
export declare class esBuildError extends BaseError {
    originalErrorStack?: string;
    /**
     * Creates an instance of the EsbuildError class.
     *
     * @param message - An object containing the error message. The `text` property is used to initialize
     * the base error class with a descriptive message about the error encountered during the esbuild process.
     */
    constructor(message: Message);
    /**
     * Generates a formatted error message with highlighted code.
     *
     * @param message - An esbuild Message object containing error information.
     * @returns A formatted string of the error message.
     */
    private generateFormattedError;
    /**
     * Reads code from a file if it exists.
     *
     * @param path - The file path to read from.
     * @returns Array of lines if file exists, otherwise null.
     */
    private readCode;
    /**
     * Formats a code snippet with highlighted errors.
     *
     * @param code - Array of code lines.
     * @param location - The error location within the file.
     * @returns A formatted and highlighted code snippet string.
     */
    private formatCodeSnippet;
    /**
     * Applies color to a given text if colors are enabled.
     *
     * @param color - The color code.
     * @param text - The text to colorize.
     * @returns The colorized text if colors are active, otherwise plain text.
     */
    private applyColor;
}
/**
 * ASCII Logo and Version Information
 *
 * @remarks
 * The `asciiLogo` constant stores an ASCII representation of the project logo
 * that will be displayed in the banner. This banner is rendered in a formatted
 * string in the `bannerComponent` function.
 *
 * The `cleanScreen` constant contains an ANSI escape code to clear the terminal screen.
 */
export declare const asciiLogo = "\n     ______       _ _     _\n     | ___ \\     (_) |   | |\n__  _| |_/ /_   _ _| | __| |\n\\ \\/ / ___ \\ | | | | |/ _` |\n >  <| |_/ / |_| | | | (_| |\n/_/\\_\\____/ \\__,_|_|_|\\__,_|\n";
export declare const cleanScreen = "\u001Bc";
/**
 * Renders the banner with the ASCII logo and version information.
 *
 * This function constructs and returns a formatted banner string that includes an ASCII logo and the version number.
 * The colors used for the ASCII logo and version number can be enabled or disabled based on the `activeColor` parameter.
 * If color formatting is enabled, the ASCII logo will be rendered in burnt orange, and the version number will be in bright pink.
 *
 * @param activeColor - A boolean flag indicating whether ANSI color formatting should be applied. Default is `__ACTIVE_COLOR`.
 *
 * @returns A formatted string containing the ASCII logo, version number, and ANSI color codes if `activeColor` is `true`.
 *
 * @remarks
 * The `bannerComponent` function clears the terminal screen, applies color formatting if enabled, and displays
 * the ASCII logo and version number. The version number is retrieved from the global `__VERSION` variable, and
 * the colors are reset after the text is rendered.
 *
 * @example
 * ```ts
 * console.log(bannerComponent());
 * ```
 *
 * This will output the banner to the console with the ASCII logo, version, and colors.
 *
 * @example
 * ```ts
 * console.log(bannerComponent(false));
 * ```
 *
 * This will output the banner to the console with the ASCII logo and version number without color formatting.
 *
 * @public
 */
export declare function bannerComponent(activeColor?: boolean): string;
/**
 * A formatted string prefix used for logging build-related messages.
 * // todo optimize this
 */
export declare function prefix(): string;
/**
 * A custom error class to handle errors occurring within a virtual machine (VM) execution context.
 *
 * The `VMRuntimeError` class extends the native `Error` class and enhances the error with
 * source map information to map stack traces back to the original source. This is particularly
 * useful when debugging errors from code executed in a `vm` or `evalmachine` environment.
 *
 * @param message - The error message describing the error.
 * @param originalError - The original error object thrown from the VM execution.
 * @param sourceMap - The `SourceService` providing source map data to link the error to its original source.
 *
 * @example
 * ```ts
 * try {
 *    vm.run(someCode);
 * } catch (error) {
 *    throw new VMRuntimeError("VM execution failed", error, sourceMapService);
 * }
 * ```
 */
export declare class VMRuntimeError extends BaseError {
    /**
     * The original error thrown during the VM execution.
     */
    originalError: Error;
    /**
     * Original error stack
     */
    originalErrorStack: string | undefined;
    /**
     * Creates a new VMRuntimeError instance.
     *
     * This constructor initializes a new `VMRuntimeError` object, extending the native `Error` class with
     * additional information, including the original error and optional source map data. It also ensures that
     * the stack trace is correctly captured and reformatted using the source map (if provided) to enhance
     * debugging.
     *
     * @param originalError - The original error object that was thrown during the VM execution.
     * @param sourceMap - (Optional) The source map service used to map the error stack trace to its original
     *                    source code locations. If not provided, this will be `null`.
     *
     * @example
     * ```ts
     * try {
     *    vm.run(code);
     * } catch (error) {
     *    throw new VMRuntimeError(error, sourceMapService);
     * }
     * ```
     */
    constructor(originalError: ErrorType, sourceMap?: SourceService);
}
/**
 * Manages the HTTP or HTTPS server based on the provided configuration.
 *
 * The `ServerProvider` class initializes and starts either an HTTP or HTTPS server based on whether SSL certificates
 * are provided. It handles incoming requests, serves static files, and lists directory contents with appropriate
 * icons and colors.
 *
 * @class
 */
export declare class ServerProvider {
    /**
     * Root dir to serve
     */
    private readonly rootDir;
    /**
     * Indicates whether the server is configured to use HTTPS.
     */
    private readonly isHttps;
    /**
     * The server configuration object, including SSL certificate paths and other settings.
     */
    private readonly config;
    /**
     * Creates an instance of ServerProvider.
     *
     * @param config - The server configuration object, including port number, SSL certificate paths, and an optional request handler.
     * @param dir - The root directory from which to serve files.
     *
     * @example
     * ```ts
     * import { ServerProvider } from './server-provider';
     *
     * const serverConfig = {
     *     port: 8080,
     *     keyfile: './path/to/keyfile',
     *     certfile: './path/to/certfile',
     *     onRequest: (req, res, next) => { /* custom request handling *\/ }
     * };
     * const provider = new ServerProvider(serverConfig, './public');
     * provider.start();
     * ```
     *
     * This example shows how to create an instance of `ServerProvider` and start the server.
     */
    constructor(config: Serve, dir: string);
    /**
     * Starts the server based on the configuration.
     * If SSL certificates are provided and valid, an HTTPS server is started. Otherwise, an HTTP server is started.
     *
     * @example
     * ```ts
     * provider.start();
     * ```
     *
     * This example demonstrates how to start the server. It will either start an HTTP or HTTPS server based on the configuration.
     */
    start(): void;
    /**
     * Starts an HTTP server.
     * This method creates an HTTP server that listens on the configured port and handles incoming requests.
     *
     * @example
     * ```ts
     * provider.startHttpServer();
     * ```
     *
     * This example shows how the `startHttpServer` method is used internally to start an HTTP server.
     */
    private startHttpServer;
    /**
     * Starts an HTTPS server.
     *
     * This method creates an HTTPS server with SSL/TLS certificates, listens on the configured port, and handles incoming requests.
     *
     * @example
     * ```ts
     * provider.startHttpsServer();
     * ```
     *
     * This example shows how the `startHttpsServer` method is used internally to start an HTTPS server.
     */
    private startHttpsServer;
    /**
     * Handles incoming requests.
     *
     * This method checks if a custom request handler is provided in the configuration. If so, it uses the custom handler.
     * Otherwise, it delegates to the default request handler.
     *
     * @param req - The incoming request object.
     * @param res - The response object.
     * @param defaultHandler - The default handler functions to be called if no custom handler is provided.
     *
     * @example
     * ```ts
     * // This method is used internally to handle requests
     * ```
     */
    private handleRequest;
    /**
     * Returns the MIME type for a given file extension.
     *
     * This method maps file extensions to their corresponding MIME types.
     *
     * @param ext - The file extension.
     * @returns The MIME type associated with the file extension.
     *
     * @example
     * ```ts
     * const mimeType = provider.getContentType('html');
     * console.log(mimeType); // 'text/html'
     * ```
     */
    private getContentType;
    /**
     * Handles the default response for requests, serving files or directories.
     *
     * This method serves the content of files or directories. If the request is for a directory, it lists the contents with
     * appropriate icons and colors.
     *
     * @param req - The incoming request object.
     * @param res - The response object.
     *
     * @returns A promise that resolves when the response is sent.
     *
     * @throws  Throws an error if the file or directory cannot be accessed.
     *
     * @example
     * ```ts
     * // This method is used internally to handle file and directory responses
     * ```
     */
    private defaultResponse;
    /**
     * promisifyStat the `fs.stat` method.
     *
     * Converts the `fs.stat` callback-based method to return a promise.
     *
     * @param path - The file or directory path.
     * @returns A promise that resolves with the file statistics.
     *
     * @example
     * ```ts
     * const stats = await provider.promisifyStat('./path/to/file');
     * console.log(stats.isFile()); // true or false
     * ```
     */
    private promisifyStat;
    /**
     * Handles directory listings.
     *
     * Reads the contents of a directory and generates an HTML response with file icons and colors.
     *
     * @param fullPath - The full path to the directory.
     * @param requestPath - The request path for generating relative links.
     * @param res - The response object.
     *
     * @example
     * ```ts
     * // This method is used internally to handle directory listings
     * ```
     */
    private handleDirectory;
    /**
     * Handles file responses.
     *
     * Reads and serves the content of a file.
     *
     * @param fullPath - The full path to the file.
     * @param res - The response object.
     *
     * @example
     * ```ts
     * // This method is used internally to handle file responses
     * ```
     */
    private handleFile;
    /**
     * Sends a 404 Not Found response.
     *
     * @param res - The response object.
     *
     * @example
     * ```ts
     * provider.sendNotFound(response);
     * ```
     *
     * This example demonstrates how to send a 404 response using the `sendNotFound` method.
     */
    private sendNotFound;
    /**
     * Sends an error response.
     *
     * @param res - The response object.
     * @param error - The error object.
     *
     * @example
     * ```ts
     * provider.sendError(response, new Error('Some error'));
     * ```
     *
     * This example shows how to send an error response using the `sendError` method.
     */
    private sendError;
}
/**
 * Plugin provider for esbuild that registers hooks for lifecycle events such as onStart, onEnd, onResolve, and onLoad.
 * This class allows dynamic behavior by registering multiple hooks for different stages of the build process.
 */
export declare class PluginsProvider {
    /**
     * Holds the build state that hooks can modify.
     */
    private buildState;
    /**
     * Holds the registered hooks for the `onEnd` lifecycle event.
     * This array contains functions that are called after the build process completes.
     */
    private onEndHooks;
    /**
     * Holds the registered hooks for the `onSuccess` lifecycle event.
     * This array contains functions that are called after the build success finish.
     */
    private onSuccess;
    /**
     * Holds the registered hooks for the `onLoad` lifecycle event.
     * This array contains functions that are called when esbuild attempts to load a module.
     */
    private onLoadHooks;
    /**
     * Holds the registered hooks for the `onStart` lifecycle event.
     * This array contains functions that are called before the build process starts.
     */
    private onStartHooks;
    /**
     * Holds the registered hooks for the `onResolve` lifecycle event.
     * This array contains functions that are called when esbuild attempts to resolve a module path.
     */
    private onResolveHooks;
    /**
     * Registers a hook function for the `onStart` lifecycle event.
     * The hook will be called before the build process starts.
     *
     * @param fn - A function of type `OnStartType` that will be executed when the build process starts.
     *
     * @example
     * ```ts
     * pluginProvider.registerOnStart(async (build) => {
     *   console.log('Build started:', build);
     * });
     * ```
     */
    registerOnStart(fn: OnStartType | undefined): void;
    /**
     * Registers a hook function for the `onEnd` lifecycle event.
     * The hook will be called after the build process completes.
     *
     * @param fn - A function of type `OnEndType` that will be executed after the build completes.
     *
     * @example
     * ```ts
     * pluginProvider.registerOnEnd(async (result) => {
     *   console.log('Build finished:', result);
     * });
     * ```
     */
    registerOnEnd(fn: OnEndType | undefined): void;
    /**
     * Registers a hook function for the `onSuccess` lifecycle event.
     * The hook will be called after the build success completes.
     *
     * @param fn - A function of type `OnEndType` that will be executed after the build completes.
     *
     * @example
     * ```ts
     * pluginProvider.registerOnSuccess(async (result) => {
     *   console.log('Build Success finished:', result);
     * });
     * ```
     */
    registerOnSuccess(fn: OnEndType | undefined): void;
    /**
     * Registers a hook function for the `onResolve` lifecycle event.
     * The hook will be called when esbuild attempts to resolve a module path.
     *
     * @param fn - A function of type `OnResolveType` that will be executed during module resolution.
     *
     * @example
     * ```ts
     * pluginProvider.registerOnResolve(async (args) => {
     *   if (args.path === 'my-module') {
     *     return { path: './src/my-module.ts' };
     *   }
     *   return null;
     * });
     * ```
     */
    registerOnResolve(fn: OnResolveType | undefined): void;
    /**
     * Registers a hook function for the `onLoad` lifecycle event.
     * The hook will be called when esbuild attempts to load a module.
     *
     * @param fn - A function of type `OnLoadType` that will be executed during module loading.
     *
     * @example
     * ```ts
     * pluginProvider.registerOnLoad(async (contents, loader, args) => {
     *   if (args.path.endsWith('.json')) {
     *     return { contents: JSON.stringify({ key: 'value' }), loader: 'json' };
     *   }
     *   return null;
     * });
     * ```
     */
    registerOnLoad(fn: OnLoadType | undefined): void;
    /**
     * Registers esbuild plugin hooks and sets up the middleware plugin.
     *
     * This function defines the setup for an esbuild plugin, enabling hooks for various lifecycle events:
     * onStart, onEnd, onResolve, and onLoad. It ensures that hooks registered by the user are called at
     * the appropriate stages of the build process.
     *
     * @returns An object with the plugin configuration that can be passed to esbuild's `plugins` array.
     * The configuration includes the plugin name and setup function.
     *
     * @example
     * ```ts
     * // Example usage with esbuild:
     * const esbuild = require('esbuild');
     * const pluginProvider = new PluginsProvider();
     *
     * esbuild.build({
     *   entryPoints: ['./src/index.ts'],
     *   bundle: true,
     *   plugins: [pluginProvider.setup()],
     * }).catch(() => process.exit(1));
     * ```
     */
    setup(): {
        name: string;
        setup: (build: PluginBuild) => void;
    };
    /**
     * Executes all registered onStart hooks.
     *
     * This function is called when the build process starts and invokes each hook registered via
     * `registerOnStart`. Hooks can perform actions such as initializing tasks, logging, or setting
     * up build conditions.
     *
     * @param build - The esbuild `PluginBuild` object that represents the current build process.
     *
     * @returns A promise that resolves when all hooks have been executed.
     *
     * @example
     * ```ts
     * // Registering an onStart hook
     * pluginProvider.registerOnStart(async (build) => {
     *   console.log('Build started:', build);
     * });
     * ```
     */
    private handleOnStart;
    /**
     * Executes all registered onEnd hooks after the build finishes.
     *
     * This function is called after the build process completes and invokes each hook registered via
     * `registerOnEnd`. Hooks can be used to process the build results, such as performing analysis or cleanup.
     *
     * @param buildResult - The build buildResult object provided by esbuild, containing details about the build process.
     *
     * @returns A promise that resolves when all hooks have been executed.
     *
     * @example
     * ```ts
     * // Registering an onEnd hook
     * pluginProvider.registerOnEnd(async (buildResult) => {
     *   console.log('Build completed:', buildResult);
     * });
     * ```
     */
    private handleOnEnd;
    /**
     * Resolves module imports using registered onResolve hooks.
     *
     * This function is called whenever esbuild attempts to resolve a module path. It iterates over all registered
     * onResolve hooks and merges their results. If no hook resolves a path, `null` is returned.
     *
     * @param args - The esbuild `OnResolveArgs` object containing information about the module being resolved.
     *
     * @returns A promise that resolves to an `OnResolveResult` containing the resolved path, or `null` if no path is found.
     *
     * @example
     * ```ts
     * // Registering an onResolve hook
     * pluginProvider.registerOnResolve(async (args) => {
     *   if (args.path === 'my-module') {
     *     return { path: './src/my-module.ts' };
     *   }
     *   return null;
     * });
     * ```
     */
    private handleOnResolve;
    /**
     * Loads module contents using registered onLoad hooks.
     *
     * This function is called when esbuild attempts to load a module. It reads the module contents and then
     * processes it through all registered onLoad hooks. The hooks can modify the contents and loader type.
     *
     * @param args - The esbuild `OnLoadArgs` object containing information about the module being loaded.
     *
     * @returns A promise that resolves to an `OnLoadResult` containing the module contents and loader, or `null` if no contents are loaded.
     *
     * @example
     * ```ts
     * // Registering an onLoad hook
     * pluginProvider.registerOnLoad(async (contents, loader, args) => {
     *   if (args.path.endsWith('.json')) {
     *     return { contents: JSON.stringify({ key: 'value' }), loader: 'json' };
     *   }
     *   return null;
     * });
     * ```
     */
    private handleOnLoad;
}
/**
 * Parses and filters content based on conditional directives.
 *
 * This function processes the given code contents and removes sections that
 * are conditionally compiled based on the provided `defines` object.
 *
 * @param contents - The code contents to be processed.
 * @param defines - An object containing conditional
 *   definitions. Keys are condition names, and values are their definitions.
 * @returns The processed code contents with conditional blocks removed
 *   according to the `defines` object.
 */
export declare function parseIfDefConditionals(contents: string, defines: Record<string, unknown>): string;
/**
 * Resolves path aliases in the provided content based on the specified paths and root directory.
 *
 * This function takes a string of content and replaces occurrences of defined path alias keys
 * with their corresponding relative paths derived from the specified source file and root directory.
 * It ensures that the resulting paths are relative to the directory of the source file and formatted
 * correctly for use in a JavaScript/TypeScript environment.
 *
 * Example:
 * Given the following inputs:
 * ```ts
 * const content = "import { foo } from '@core/foo';";
 * const sourceFile = "/project/src/index.ts";
 * const paths = {
 *   '@core/': 'src/core',
 *   '@utils/': 'src/utils'
 * };
 * const rootDir = "/project";
 * ```
 * The function will replace `@core/foo` with a relative path based on the source file's location,
 * potentially resulting in:
 * ```ts
 * const content = "import { foo } from './core/foo';";
 * ```
 *
 * @param content - The content in which path aliases need to be resolved.
 * @param sourceFile - The path of the source file from which relative paths will be calculated.
 * @param paths - An object mapping path alias keys to their corresponding paths.
 * @param esm -  A flag indicating whether ESM is enabled.
 * @returns The updated content with resolved path aliases.
 */
export declare function resolveAliasPlugin(content: string, sourceFile: string, paths: Record<string, string>, esm: boolean): string;
/**
 * Represents TypeScript node types that can have modifiers applied to them.
 * This union type includes all declaration types that support TypeScript modifiers
 * like export, default, abstract, public, private, etc.
 *
 * @see ts.ClassDeclaration
 * @see ts.InterfaceDeclaration
 * @see ts.EnumDeclaration
 * @see ts.FunctionDeclaration
 * @see ts.TypeAliasDeclaration
 * @see ts.VariableStatement
 * @see ts.ModuleDeclaration
 *
 * @since 1.5.5
 */
export type NodeWithModifiersType = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.EnumDeclaration | ts.FunctionDeclaration | ts.TypeAliasDeclaration | ts.VariableStatement | ts.ModuleDeclaration;
/**
 * Custom error class to represent type-related errors.
 *
 * This class extends the built-in `Error` class to provide more specific
 * error handling for issues related to types. It can be used to distinguish
 * errors that occur due to type mismatches or other type-related problems
 * in your application.
 *
 * @example
 * ```ts
 * throw new TypesError('Invalid type encountered.');
 * ```
 *
 * @augments Error
 */
export declare class TypesError extends Error {
    /**
     * Creates an instance of `TypesError`.
     *
     * @param message - A human-readable message providing details about the error.
     * @param options - Optional configuration for the error, such as a `cause` (ECMAScript 2022+).
     */
    constructor(message?: string, options?: {
        cause?: Error;
    });
}
/**
 * Provides TypeScript-related utilities such as type-checking, generating declaration files,
 * and transforming module specifiers into relative paths based on the output directory.
 *
 * The `TypescriptProvider` class enables users to type-check TypeScript projects, generate
 * declaration files, and transform import/export paths into relative paths that match the output directory.
 * It uses the TypeScript Compiler API to achieve these transformations.
 *
 * @class
 * @example
 * ```ts
 * const tsProvider = new TypescriptProvider(parsedConfig, './dist');
 * tsProvider.typeCheck(entryPoints);
 * tsProvider.generateDeclarations(entryPoints);
 * ```
 */
export declare class TypeScriptProvider {
    tsConfig: ts.ParsedCommandLine;
    private outDir;
    private activeColor;
    /**
     * Compiler options for configuring TypeScript compilation.
     */
    readonly options: ts.CompilerOptions;
    /**
     * Creates an instance of `TypescriptProvider` with the given TypeScript configuration and output directory.
     *
     * This constructor initializes a `TypescriptProvider` with the provided TypeScript configuration
     * and the directory where output files (such as declaration files) will be stored.
     * Additionally, it accepts a flag to control whether ANSI color formatting should be applied in output messages.
     *
     * @param tsConfig - The parsed TypeScript configuration object.
     * @param outDir - The directory where output files (such as declaration files) will be stored.
     * @param activeColor - A boolean flag indicating whether ANSI color formatting should be applied in output messages.
     * Default is `true`.
     *
     * @example
     * ```ts
     * const tsProvider = new TypescriptProvider(parsedConfig, './dist');
     * ```
     *
     * @example
     * ```ts
     * const tsProvider = new TypescriptProvider(parsedConfig, './dist', false);
     * // This instance will not apply ANSI color formatting in output messages
     * ```
     */
    constructor(tsConfig: ts.ParsedCommandLine, outDir: string, activeColor?: boolean);
    /**
     * Performs type-checking on the specified entry points without emitting any files.
     *
     * This method compiles the provided TypeScript files to check for type errors and other diagnostics without
     * generating any output files. It ensures that the code adheres to TypeScript's type constraints and reports
     * any issues found during the type-checking process.
     *
     * @param allowError - A boolean flag indicating whether to throw an error if diagnostics are present. If set to
     * `true`, errors are logged but not thrown, allowing the process to continue. Default to `false`, which throws
     * an error if diagnostics are encountered.
     *
     * @returns void
     *
     * @throws Throws an error if type-checking fails due to TypeScript diagnostics and `allowError` is `false`.
     * The error indicates that the type-checking process has encountered issues.
     *
     * @example
     * ```ts
     * // Type-check files and handle any diagnostics
     * tsProvider.typeCheck(['src/index.ts', 'src/app.ts']);
     * ```
     */
    typeCheck(allowError?: boolean): void;
    /**
     * Generates declaration files (.d.ts) for bundle entry points.
     *
     * @param entryPoints - Map of output declaration file paths to their corresponding input source files
     * @param noTypeChecker - When true, skips type checking during generation (default: false)
     * @param allowError - When true, continues generation even if type errors are found (default: false)
     *
     * @throws Error - If type errors are found and allowError is false
     *
     * @remarks
     * This method creates TypeScript declaration files for each entry point specified in the record.
     * For each entry point:
     *
     * 1. Create a TypeScript program with input file
     * 2. Configure the program to emit declaration files only
     * 3. Applies custom transformers to clean up declarations
     * 4. Performs type checking (unless disabled)
     * 5. Emits the declaration file to the specified output path
     *
     * The generated declarations are processed by the cleanupDeclarations transformer,
     * which removes export modifiers and performs another necessary cleanup.
     *
     * Type errors will normally cause the process to fail unless allowError is set to true.
     *
     * @example
     * ```ts
     * // Generate declarations for multiple entry points
     * generator.generateBundleDeclarations({
     *   './dist/index.d.ts': './src/index.ts',
     *   './dist/core.d.ts': './src/core.ts'
     * });
     * ```
     *
     * @since 1.5.5
     */
    generateBundleDeclarations(entryPoints: Record<string, string>, noTypeChecker?: boolean, allowError?: boolean): void;
    /**
     * Generates TypeScript declaration files (`.d.ts`) for the specified entry points.
     *
     * This method compiles the provided TypeScript files and emits only the declaration files, without generating
     * JavaScript code. It applies a custom transformer to modify module specifiers to relative paths based on the
     * output directory. This ensures that the generated declaration files are accurate and the module paths are
     * aligned with the project's build structure.
     *
     * @param entryPoints - Map of output declaration file paths to their corresponding input source files
     * @param noTypeChecker - Skips TypeScript type checking.
     * @param allowError - A boolean flag indicating whether to throw an error if diagnostics are present. If set to
     * `true`, errors are logged but not thrown, allowing the process to continue. Default to `false`, which throws
     * an error if diagnostics are encountered.
     *
     * @returns void
     *
     * @example
     * ```ts
     * // Generate declaration files for specific entry points
     * tsProvider.generateDeclarations(['src/index.ts', 'src/app.ts']);
     * ```
     */
    generateDeclarations(entryPoints: Record<string, string>, noTypeChecker?: boolean, allowError?: boolean): void;
    /**
     * Checks if the provided node is an import or export declaration.
     *
     * @param node - A TypeScript AST node to check.
     *
     * @returns `true` if the node is either an `ImportDeclaration` or `ExportDeclaration`; otherwise, `false`.
     *
     * @example
     * ```ts
     * const isDeclaration = tsProvider.isImportOrExportDeclaration(node);
     * console.log(isDeclaration); // true or false
     * ```
     */
    private isImportOrExportDeclaration;
    /**
     * Checks if the provided node has a string literal as its module specifier.
     *
     * @param node - A TypeScript AST node to check.
     *
     * @returns `true` if the node has a string literal module specifier; otherwise, `undefined`.
     *
     * @example
     * ```ts
     * const hasModuleSpecifier = tsProvider.hasStringLiteralModuleSpecifier(importNode);
     * console.log(hasModuleSpecifier); // true or undefined
     * ```
     */
    private hasStringLiteralModuleSpecifier;
    /**
     * Resolves the module file name based on the module specifier and TypeScript compiler options.
     *
     * @param specifierText - The module specifier text (e.g., `'./module'`).
     * @param options - The TypeScript compiler options.
     *
     * @returns The resolved file path of the module or `undefined` if the module cannot be resolved.
     *
     * @example
     * ```ts
     * const resolvedPath = tsProvider.resolveModuleFileName('./module', compilerOptions);
     * console.log(resolvedPath); // './dist/module.js'
     * ```
     */
    private resolveModuleFileName;
    /**
     * Computes the relative path from the source file to the resolved target file.
     *
     * @param sourceFile - The absolute path of the source file.
     * @param resolvedTargetFile - The absolute path of the resolved target file.
     *
     * @returns A relative path from the source file to the target file.
     *
     * @example
     * ```ts
     * const relativePath = tsProvider.getRelativePathToOutDir('./src/index.ts', './dist/module.js');
     * console.log(relativePath); // './module.js'
     * ```
     */
    private getRelativePathToOutDir;
    /**
     * Updates the module specifier of an import or export declaration to a relative path based on the output directory.
     *
     * This method takes a TypeScript `ImportDeclaration` or `ExportDeclaration` node and updates its module
     * specifier to a relative path that matches the output directory. It uses the TypeScript compiler options
     * to resolve the full path of the module and converts it into a relative path from the source file.
     *
     * This is useful when transforming module specifiers to ensure the generated declaration files (`.d.ts`)
     * have correct paths when files are moved to the output directory.
     *
     * @param node - The TypeScript `ImportDeclaration` or `ExportDeclaration` node whose module specifier needs to be updated.
     * @param sourceFile - The absolute path of the source file containing the node.
     *
     * @returns The updated `ImportDeclaration` or `ExportDeclaration` node with the new relative module specifier.
     *
     * @example
     * ```ts
     * const updatedNode = tsProvider.updateModuleSpecifier(importNode, './src/index.ts');
     * console.log(updatedNode.moduleSpecifier.text); // './module.js'
     * ```
     */
    private updateModuleSpecifier;
    /**
     * Creates a visitor function that transforms `ImportDeclaration` and `ExportDeclaration` nodes by updating
     * their module specifiers to relative paths based on the output directory.
     *
     * This method returns a visitor function, which is used to traverse and transform the nodes in a TypeScript
     * `SourceFile`. The visitor identifies `ImportDeclaration` and `ExportDeclaration` nodes with module specifiers
     * that are string literals. For these nodes, the module specifiers are resolved to their corresponding file paths
     * and updated to relative paths that align with the output directory.
     *
     * The visitor is designed to recursively visit all nodes in the `SourceFile`, transforming only the relevant
     * import and export declarations while leaving other nodes unchanged.
     *
     * @param sourceFile - The TypeScript `SourceFile` that will be traversed by the visitor.
     * @param context - The transformation context provided by the TypeScript compiler, used for visiting nodes.
     *
     * @returns A visitor function that processes the nodes in the source file, updating module specifiers as needed.
     *
     * @example
     * ```ts
     * const visitor = tsProvider.createVisitor(sourceFile, context);
     * const transformedNode = visitor(importNode);
     * console.log(transformedNode); // ImportDeclaration with updated module specifier
     * ```
     */
    private createVisitor;
    /**
     * Creates a custom transformer factory for TypeScript that processes `SourceFile` nodes.
     *
     * This method returns a custom transformer factory function which generates a transformer that can be used
     * during the TypeScript compilation process. The transformer specifically processes `SourceFile` nodes to
     * apply custom transformations and does not alter `Bundle` nodes.
     *
     * The factory function generates a transformer that performs the following:
     * - **Transforming `SourceFile` nodes**: Uses the `createVisitor` method to visit and transform all nodes in
     *   a `SourceFile`. This allows custom modifications or analysis of TypeScript source files.
     * - **No transformation for `Bundle` nodes**: The `transformBundle` method returns the bundle unchanged, as
     *   no specific transformation is needed for bundles in this implementation.
     *
     * This transformer factory is used primarily for customizing TypeScript file transformations, such as updating
     * module specifiers or other source-level adjustments during the compilation process.
     *
     * @returns A custom transformer factory function that produces a `CustomTransformer` object. This object
     *          implements the `transformSourceFile` and `transformBundle` methods.
     *
     * @example
     * ```ts
     * const transformerFactory = tsProvider.createTransformerFactory();
     * const emitResult = program.emit(undefined, undefined, undefined, true, {
     *     after: [transformerFactory]
     * });
     * ```
     */
    private createTransformerFactory;
    /**
     * Handles and logs TypeScript diagnostics, providing detailed error messages with file and position information.
     *
     * This method processes an array of TypeScript diagnostics, printing formatted error messages to the console.
     * If a diagnostic is associated with a specific file and position, the error message includes the filename,
     * line, and character information. Colors are applied to highlight different parts of the message, such as
     * file paths, positions, error messages, and error codes.
     *
     * If the `allowError` flag is `false`, the method throws an error when diagnostics are present, indicating
     * that type checking has failed. If `allowError` is `true`, errors are logged but not thrown, allowing the process
     * to continue despite the diagnostics.
     *
     * @param diagnostics - An array of readonly `Diagnostic` objects returned by the TypeScript compiler.
     * These diagnostics contain information about errors or warnings that occurred during compilation.
     *
     * @param allowError - A boolean flag that determines whether the method should throw an error when diagnostics
     * are encountered. If set to `true`, the method logs diagnostics but does not throw an error. Defaults to `false`.
     *
     * @throws Will throw an error if diagnostics are present and `allowError` is set to `false`. The error
     * indicates that type checking has failed.
     *
     * @example
     * ```ts
     * const diagnostics = program.getSemanticDiagnostics();
     * handleDiagnostics(diagnostics, false); // Throws an error if any diagnostics exist.
     * ```
     */
    private handleDiagnostics;
    /**
     * Type guard to check if a node is one that can have modifiers.
     *
     * @param node - The TypeScript node to check
     * @returns True if the node is a type that can have modifiers, false otherwise
     *
     * @remarks
     * This type guard function identifies node types that can potentially have
     * modifiers like 'export', 'default', etc. It's used in the AST transformation
     * process to identify nodes where export modifiers need to be removed.
     *
     * The supported node types include:
     * - Class declarations
     * - Interface declarations
     * - Enum declarations
     * - Function declarations
     * - Type alias declarations
     * - Variable statements
     * - Module declarations
     *
     * @see NodeWithModifiersType
     * @see ts.Node
     *
     * @since 1.5.5
     */
    private isNodeWithModifiers;
    /**
     * Filters out export and default modifiers from an array of TypeScript modifiers.
     *
     * @param modifiers - Optional array of TypeScript modifiers to process
     * @returns A new array without export/default modifiers, or undefined if no modifiers remain
     *
     * @remarks
     * This helper method is used when transforming nodes to remove export-related functionality.
     * It returns undefined instead of an empty array when no modifiers remain to ensure
     * proper TypeScript AST structure.
     *
     * @example
     * ```ts
     * // Input: [export, const]
     * // Output: [const]
     *
     * // Input: [export]
     * // Output: undefined
     * ```
     *
     * @see ts.Modifier
     * @see ts.SyntaxKind.ExportKeyword
     * @see ts.SyntaxKind.DefaultKeyword
     *
     * @since 1.5.5
     */
    private removeExportModifiers;
    /**
     * Updates a node by removing its export modifiers.
     *
     * @param node - A TypeScript node that can have modifiers
     * @returns A new node with export and default modifiers removed
     *
     * @remarks
     * This method dynamically determines the node type and applies the appropriate
     * update function from the nodeUpdaters record.
     *
     * It works by:
     * 1. First, removing export modifiers using removeExportModifiers method
     * 2. Identifying the node type by matching it against TypeScript's type guards
     * 3. Applying the corresponding updater function from nodeUpdaters
     * 4. Falling back to returning the original node if no updater is found
     *
     * The dynamic approach avoids repetitive code for each node type while still
     * maintaining type safety through TypeScript's built-in type guards.
     *
     * @see nodeUpdaters
     * @see removeExportModifiers
     * @see NodeWithModifiersType
     *
     * @since 1.5.5
     */
    private updateNodeWithoutExports;
    /**
     * Recursively visits and transforms nodes in the TypeScript AST.
     *
     * @param context - The transformation context provided by TypeScript
     * @param node - The current node being visited
     * @returns A transformed node with export modifiers removed where applicable
     *
     * @remarks
     * This method is the core of the AST transformation process.
     *
     * It:
     * 1. Checks if the current node is one that can have modifiers
     * 2. If so, checks if it has any export or default modifiers
     * 3. If export modifiers are found, remove them using updateNodeWithoutExports
     * 4. Recursively visit all child nodes regardless of whether the current node was modified
     *
     * The recursion ensures that all nodes in the entire syntax tree are processed,
     * resulting in a complete transformation that removes all export modifiers.
     *
     * @see isNodeWithModifiers
     * @see updateNodeWithoutExports
     * @see ts.visitEachChild
     *
     * @since 1.5.5
     */
    private visitNode;
    /**
     * Processes top-level TypeScript statements by handling imports, exports, and module declarations
     * during transformation. This method filters internal imports, removes exports, and flattens module
     * declarations to generate optimized output.
     *
     * @param node - The TypeScript statement being processed
     * @param importMap - Collection of import clauses organized by module specifier
     * @param sourceFiles - Array of internal source file paths that should be excluded
     * @param context - TypeScript transformation context for node factory operations
     * @returns Array of transformed statements or empty array if the statement is removed
     *
     * @throws TypesError - When encountering unsupported node types
     *
     * @remarks
     * The transformation logic handles several specific cases:
     * - Import declarations: Collects external imports and filters internal ones
     * - Import equals declarations: Removes them from output
     * - Export declarations: Removes them entirely
     * - Module declarations: Unwraps content from declare modules, preserves others
     *
     * @example
     * ```ts
     * const result = this.visitTopLevelStatement(
     *   sourceFile.statements[0],
     *   new Map<string, Array<ts.ImportClause>>(),
     *   ['./internal-module'],
     *   transformContext
     * );
     * ```
     *
     * @see ts.Statement
     * @see ts.ImportDeclaration
     * @see ts.ModuleDeclaration
     *
     * @since 1.5.5
     */
    private visitTopLevelStatement;
    /**
     * Transforms a TypeScript source file by processing all its top-level statements and
     * updating the source file with the processed statements while preserving metadata.
     *
     * @param sourceFile - The TypeScript source file to transform
     * @param importMap - Collection mapping module specifiers to their import clauses
     * @param sourceFiles - Array of source file paths used to identify internal modules
     * @param context - The TypeScript transformation context
     * @returns A new TypeScript source file with transformed statements
     *
     * @remarks
     * This method flattens all source file statements by passing them through the
     * visitTopLevelStatement processor, then creates an updated source file that
     * preserves all original metadata including declaration status and references.
     *
     * @example
     * ```ts
     * const transformedFile = this.visitSourceFile(
     *   program.getSourceFile("main.ts"),
     *   new Map<string, Array<ts.ImportClause>>(),
     *   ["./src/internal.ts"],
     *   transformationContext
     * );
     * ```
     *
     * @throws TypesError - When transformation encounters incompatible node types
     *
     * @see ts.SourceFile
     * @see ts.TransformationContext
     *
     * @since 1.5.5
     */
    private visitSourceFile;
    /**
     * Merges multiple TypeScript import clauses into a single consolidated import clause,
     * handling default imports, named imports, and namespace imports.
     *
     * @param importClauses - Array of import clauses to merge
     * @param isTypeOnly - Whether to force the resulting import to be type-only, defaults to true
     * @returns A consolidated import clause or undefined if no import clauses provided
     *
     * @throws TypesError - When encountering incompatible import clause structures
     *
     * @remarks
     * The merging process follows these rules:
     * - Uses the first default import encountered
     * - Collects all unique named imports across all clauses
     * - Uses the first namespace import encountered
     * - Handles type-only status according to the isTypeOnly parameter or source clauses
     * - Returns undefined if the input array is empty
     * - Returns the original clause if there's only one and not forcing type-only
     *
     * @example
     * ```ts
     * const imports = [
     *   ts.factory.createImportClause(false, ts.factory.createIdentifier("default1"), undefined),
     *   ts.factory.createImportClause(
     *     false,
     *     undefined,
     *     ts.factory.createNamedImports([
     *       ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("named1"))
     *     ])
     *   )
     * ];
     * const mergedImport = this.mergeImportClauses(imports, true);
     * ```
     *
     * @see ts.ImportClause
     * @see ts.NamedImports
     * @see ts.NamespaceImport
     *
     * @since 1.5.6
     */
    private mergeImportClauses;
    /**
     * Creates a transformer factory that cleans up declarations in TypeScript bundles.
     * This transformer extracts external imports from each source file in the bundle
     * and consolidates them into a single imports file at the beginning of the bundle.
     *
     * @returns A transformer factory function that transforms TypeScript bundles
     *
     * @throws Error - When the input is not a bundle but a single source file
     *
     * @remarks
     * The transformer processes each source file in the bundle, extracts external imports,
     * and creates a new bundle with all imports consolidated at the beginning.
     *
     * @example
     * ```ts
     * const transformer = myClass.cleanupDeclarations();
     * const result = ts.transform(bundle, [transformer]);
     * ```
     *
     * @see ts.TransformerFactory
     * @see ts.Bundle
     *
     * @since 1.5.5
     */
    private cleanupDeclarations;
}
/**
 * The default configuration options for the build.
 *
 * @example
 * ```ts
 * import { defaultConfiguration } from '@configuration/default-configuration';
 *
 * console.log(defaultConfiguration);
 * ```
 *
 * In this example, the `defaultConfiguration` is imported and logged to the console to view the default settings.
 *
 * @public
 * @category Configuration
 */
export declare const defaultConfiguration: ConfigurationInterface;
/**
 * Executes JavaScript code within a sandboxed environment using Node.js's `vm` module.
 *
 * @param code - The JavaScript code to be executed within the sandbox.
 * @param sandbox - An optional context object to be used as the global scope for the executed code.
 *
 * @returns The result of executing the provided code within the sandboxed environment.
 *
 * @remarks
 * The `sandboxExecute` function creates a new `Script` instance with the provided code and
 * runs it within a sandboxed context using the `createContext` function from the `vm` module.
 * This approach ensures that the executed code is isolated from the rest of the application,
 * mitigating potential security risks.
 *
 * The `sandbox` parameter allows you to provide a custom context or global object for the
 * sandboxed code. If not provided, an empty context is used. The function also supports
 * breaking execution on interrupt signals (e.g., Ctrl+C) with the `breakOnSigint` option.
 *
 * @throws Error Throws an error if the code cannot be compiled or executed within the context.
 *
 * @example
 * ```ts
 * const result = sandboxExecute('return 2 + 2;', { myGlobal: 10 });
 * console.log(result); // Output: 4
 * ```
 *
 * In this example, the `sandboxExecute` function runs a simple JavaScript expression and returns
 * the result. The `sandbox` parameter is provided with an empty object in this case.
 *
 * @public
 * @category Services
 */
export declare function sandboxExecute(code: string, sandbox?: Context): any;
/**
 * Parses a configuration file and returns a wrapped `ConfigurationInterface` object.
 *
 * This function reads the specified configuration file, transpiles it to a CommonJS format, and then executes it
 * in a sandbox environment. The exported configuration object is wrapped so that any functions it contains will
 * have sourcemap information attached to errors thrown during their execution.
 *
 * The wrapping of functions helps in debugging by associating errors with their source maps.
 *
 * @param file - The path to the configuration file that needs to be parsed and transpiled.
 *
 * @returns A promise that resolves to the parsed and transpiled `ConfigurationInterface` object.
 * This object has its functions wrapped to attach sourcemap information to any errors thrown.
 *
 * @throws Will throw an error if the transpilation or execution of the configuration file fails.
 * The thrown error will have sourcemap information attached if available.

 * @example
 * ```ts
 * const config = await parseConfigurationFile('./config.jet.ts');
 * console.log(config);
 * ```
 */
export declare function parseConfigurationFile(file: string): Promise<ConfigurationInterface>;
/**
 * Reads and parses the TypeScript configuration file.
 *
 * @param options - A `BuildOptions` object that may contain a custom `tsconfig` path.
 * @returns A `ParsedCommandLine` object representing the parsed TypeScript configuration.
 * @throws xBuildError - Throws an error if the configuration file contains syntax errors.
 */
export declare function tsConfiguration(options: BuildOptions): ParsedCommandLine;
/**
 * Merges user configurations with CLI configurations and default settings
 * to produce a final configuration object for the build process.
 * This function handles both single and multiple user configurations,
 * allowing for flexible configuration merging.
 *
 * @param userConfig - An array or a single object of type `PartialDeepConfigurationsType`
 *                     representing the user's configurations to merge. If a single object
 *                     is provided, it is wrapped in an array for processing.
 * @param cliConfig - An optional object of type `PartialDeepConfigurationsType` representing
 *                    the CLI configurations to merge with the user configurations. Defaults to an empty object.
 * @returns An array of `ConfigurationInterface` objects, each representing a merged configuration.
 *
 * @throws xBuildError Throws an error if the `entryPoints` property in the merged configuration is undefined.
 *                       This ensures that the configuration is valid and complete for further processing.
 *
 * @example
 * ```ts
 * import { configuration } from './configuration';
 *
 * const userConfigs = [
 *     { esbuild: { entryPoints: ['src/index.ts'] } },
 *     { serve: { port: 3000 } }
 * ];
 * const cliConfigs = { esbuild: { minify: true } };
 *
 * const finalConfigs = await configuration(userConfigs, cliConfigs);
 * console.log('Merged Configuration:', finalConfigs);
 * ```
 */
export declare function configuration(userConfig: Array<PartialDeepConfigurationsType> | PartialDeepConfigurationsType, cliConfig?: PartialDeepConfigurationsType): Promise<ConfigurationInterface[]>;
/**
 * Merges CLI arguments with a configuration file to produce a final configuration object.
 * This function reads the specified configuration file and merges its contents with
 * the CLI arguments provided. The resulting configuration will be validated to ensure
 * that required properties, such as `entryPoints`, are defined.
 *
 * @param configFile - The path to the configuration file to read and merge with CLI arguments.
 * @param cli - An instance of `Argv<ArgvInterface>` containing CLI arguments and options.
 * @returns A promise that resolves to an array of `ConfigurationInterface` objects, representing
 *          the final merged configuration.
 * @throws Error Throws an error if the `entryPoints` property in the final configuration is undefined.
 *                 This ensures that the configuration is valid for further processing.
 *
 * @example
 * ```ts
 * import { cliConfiguration } from './cli-configuration';
 *
 * const configFilePath = './config.json';
 * const cliArgs = argv(); // Assuming `argv` is a function that retrieves CLI arguments
 *
 * cliConfiguration(configFilePath, cliArgs).then((finalConfig) => {
 *     console.log('Final configuration: ', finalConfig);
 * }).catch((error) => {
 *     console.error('Error loading configuration:', error);
 * });
 * ```
 */
export declare function cliConfiguration(configFile: string, cli: Argv<ArgvInterface>): Promise<Array<ConfigurationInterface>>;
/**
 * Maps an array of file paths to an object where the keys are filenames (without extensions)
 * and the values are the corresponding file paths.
 *
 * Each key in the resulting object is derived from the filename by removing the file extension.
 * For example, given a file path `src/index.ts`, the key in the resulting object will be `src/index`.
 *
 * @param filePaths - An array of file paths to map. Each file path should be a string.
 * @returns An object where the keys are filenames (without extensions) and the values are the corresponding file paths.
 *
 * @example
 * ```ts
 * const filePaths = ['src/index.ts', 'src/utils.ts'];
 * const result = mapFilePathsToNames(filePaths);
 * console.log(result);
 * // Output: {
 * //   'src/index': 'src/index.ts',
 * //   'src/utils': 'src/utils.ts'
 * // }
 * ```
 */
export declare function mapFilePathsToNames(filePaths: Array<string>): Record<string, string>;
/**
 * Extracts and returns an object mapping output file paths to input file paths from the provided `EntryPoints` object.
 *
 * This function handles multiple formats of entry points, including:
 * - An array of strings representing file paths.
 * - An array of objects containing `in` and `out` properties, where `in` is the input file path and `out` is the output file path.
 * - A `Record<string, string>` where the keys represent input file paths and the values represent output file paths.
 *
 * Depending on the format, the function constructs an object with the output file paths as keys and the input file paths as values.
 * If the output path is not available, the filename (without extension) is used as the key.
 *
 * If a regular object with string keys and values (not in the supported formats) is provided, it will be returned as is.
 *
 * @param entryPoints - The entry points to extract from, which can be in different formats: an array of strings,
 * an array of objects with `in` and `out` properties, or a `Record<string, string>`.
 *
 * @returns An object mapping output file paths to input file paths, or filename (without extension) to file path.
 *
 * @throws Will throw an `Error` if the entry points format is unsupported.
 *
 * @example
 * ```ts
 * const entryPoints = extractEntryPoints(['src/index.ts', 'src/utils.ts']);
 * console.log(entryPoints); // { 'index': 'src/index.ts', 'utils': 'src/utils.ts' }
 * ```
 *
 * @example
 * ```ts
 * const entryPoints = extractEntryPoints([{ in: 'src/index.ts', out: 'dist/index.js' }]);
 * console.log(entryPoints); // { 'dist/index.js': 'src/index.ts' }
 * ```
 *
 * @example
 * ```ts
 * const entryPoints = extractEntryPoints({ index: 'src/index.ts', index2: 'dist/index2.js' });
 * console.log(entryPoints); // { index: 'src/index.ts', index2: 'dist/index2.js' }
 * ```
 */
export declare function extractEntryPoints(entryPoints: EntryPoints): Record<string, string>;
/**
 * Generates a `package.json` file with the appropriate `type` field
 * based on the format specified in the configuration.
 *
 * - If the format is `esm`, the `type` will be set to `"module"`.
 * - If the format is `cjs`, the `type` will be set to `"commonjs"`.
 *
 * The function will ensure that the specified output directory exists, and if it doesn't,
 * it will create the necessary directories before writing the `package.json` file.
 *
 * @param config - The build configuration object containing
 * esbuild-related settings, such as the format (`format`).
 *
 * - `config.esbuild.format`: The module format, either `'esm'` or `'cjs'`, that determines the `type` field.
 *
 * @throws Will throw an error if there is a problem creating the directory or writing the file.
 *
 * Example usage:
 *
 * ```ts
 * const config = {
 *   esbuild: {
 *     format: 'esm'
 *   }
 * };
 * packageTypeComponent(config);
 * // This will create 'dist/package.json' with the content: {"type": "module"}
 * ```
 */
export declare function packageTypeComponent(config: ConfigurationInterface): void;
/**
 * Manages the build process for a TypeScript project using esbuild.
 *
 * The `BuildService` class orchestrates the build process, including TypeScript compilation, handling of build errors,
 * and lifecycle management of the build. It can operate in various modes, such as watching for file changes or running
 * in development mode. It also provides functionality for spawning development processes and processing entry points.
 *
 * @remarks
 * - The build process can be configured using the provided `ConfigurationInterface`.
 * - Errors related to TypeScript are handled separately and are not logged by default.
 * - The class supports various build modes, including watch mode and development mode, and handles different scenarios
 *   based on the configuration.
 *
 * @public
 * @category Services
 */
export declare class BuildService {
    private config;
    /**
     * Provides TypeScript-related functionality for the build process.
     */
    readonly typeScriptProvider: TypeScriptProvider;
    /**
     * Keeps track of active development processes spawned during the build.
     * This property holds an array of `ChildProcessWithoutNullStreams` instances that represent Node.js processes spawned
     * for running development tasks. These processes are used to handle development builds or runtime tasks and are managed
     * by the `BuildService` class to ensure they are properly started and stopped.
     *
     * @remarks
     * - The array is populated when development processes are spawned, such as when specific development files are
     *   processed or when running in development mode.
     * - The processes are terminated gracefully at the end of the build to avoid leaving orphaned processes running.
     * - It is important to manage these processes correctly to avoid resource leaks and ensure proper cleanup.
     *
     * @see ChildProcessWithoutNullStreams
     */
    private activePossess;
    /**
     * Plugin provider
     *
     * @private
     */
    private pluginsProvider;
    /**
     * Initializes the build service with the provided configuration.
     *
     * The constructor configures the TypeScript provider, suppresses esbuild logging,
     * sets up development modes, and registers the necessary plugins.
     *
     * Declaration files will be output based on the following order of precedence:
     * 1. If `declarationOutDir` is set in the configuration, it will be used.
     * 2. If `declarationOutDir` is not provided, it will use the `outDir` value from the tsconfig.
     * 3. If neither of the above is available, it falls back to using the `outdir` specified in the esbuild configuration.
     *
     * @param config - The configuration object for the build process, including esbuild and TypeScript settings.
     */
    constructor(config: ConfigurationInterface);
    /**
     * Executes the build process.
     * This method performs the build and handles any errors that occur during the execution.
     * If watching or development mode is enabled in the configuration, it starts watching for changes
     * to automatically rebuild as needed.
     * The method logs errors that are not related to TypeScript
     * compilation issues.
     *
     * @returns A promise that resolves with a `BuildResult` when the build process is complete,
     *          or `undefined` if an error occurs during execution.
     *
     * @throws Error Throws an error if the build process encounters issues that are not related
     *                 to TypeScript. Such errors are logged, but the method does not rethrow them.
     *
     * @example
     * ```ts
     * import { BuildService } from './build-service';
     *
     * const buildService = new BuildService(config);
     * buildService.run().then(() => {
     *     console.log('Build process completed successfully.');
     * }).catch((error) => {
     *     console.error('Build process failed:', error);
     * });
     * ```
     *
     * In this example, the `run` method is invoked to execute the build process. It handles both successful
     * completion and logs any encountered errors, allowing the user to understand the outcome of the build.
     */
    run(): Promise<BuildResult | void>;
    /**
     * Runs the build process in debug mode for the specified entry points.
     * This method temporarily disables development and watch mode, initiates the build process, and spawns development processes
     * for the specified entry points. If any errors occur during the build, they are handled appropriately.
     *
     * @param entryPoints - An array of entry point file names for which the development processes will be spawned.
     * These entry points are matched against the build output files.
     *
     * @returns A `Promise<void>` that resolves when the build and process spawning have completed.
     *
     * @throws Handles any build-related errors using the `handleErrors` method.
     *
     * @remarks
     * - The `config.dev` and `config.watch` settings are temporarily disabled to prevent development mode or file watching during the build.
     * - The `build()` method is called to generate the necessary build outputs.
     * - The `spawnDev` method is then invoked to spawn processes for the matching entry points.
     * - If any errors occur during the build, they are caught and passed to the `handleErrors` method.
     *
     * @example
     * ```ts
     * const entryPoints = ['index', 'main'];
     * await this.runDebug(entryPoints);
     * ```
     *
     * In this example, the `runDebug` method runs the build process and spawns development processes for `index` and `main`.
     *
     * @public
     */
    runDebug(entryPoints: Array<string>): Promise<void>;
    /**
     * Serves the project and watches for changes.
     * This method starts the development server using the `ServerProvider`, builds the project using esbuild,
     * and watches for file changes to automatically rebuild as needed. It initializes the server and invokes
     * the build process, enabling continuous development mode.
     *
     * @returns A promise that resolves when the server is started and the build process is complete.
     *
     * @throws This method catches any errors thrown during the build process and handles them using the
     * `handleErrors` method.
     *
     * @example
     * ```ts
     * const buildService = new BuildService(config);
     * buildService.serve().then(() => {
     *     console.log('Server is running and watching for changes.');
     * }).catch((error) => {
     *     console.error('Failed to start the server:', error);
     * });
     * ```
     *
     * In this example, the `serve` method starts the server and watches for changes. If an error occurs during
     * the build or server startup, it is handled and logged.
     */
    serve(): Promise<void>;
    /**
     * Executes a provided asynchronous callback function within a try-catch block.
     * This method ensures that any errors thrown during the execution of the callback
     * are properly handled and logged. If the error appears to be an `esbuild`-related
     * `OnEndResult` error with an array of errors, it avoids redundant logging.
     * Otherwise, it wraps the error in a `VMRuntimeError` and logs the stack trace.
     *
     * @template T - The return type of the callback function, allowing flexibility
     *               in the expected result type. Defaults to `BuildResult`.
     *
     * @param callback - A function that returns a `Promise<T>`, which is executed asynchronously.
     *                   The callback is wrapped in error handling logic to catch and process any exceptions.
     *
     * @returns A `Promise<T | void>` that resolves with the result of the callback function if successful,
     *          or `void` if an error was thrown and handled. This allows for optional chaining on the return value.
     *
     * @throws This method does not throw explicitly but will log an error message if an exception is caught
     *         and is not an `esbuild`-related error. The error stack is logged via `VMRuntimeError` for non-esbuild errors.
     *
     * @example
     * ```ts
     * await execute(async () => {
     *   // Perform some asynchronous operation here
     *   return someResult;
     * });
     * ```
     */
    private execute;
    /**
     * Configures the development mode by ensuring that `config.dev` is set properly.
     */
    private configureDevelopmentMode;
    /**
     * Sets up the plugin's provider and registers the plugin hooks.
     */
    private setupPlugins;
    /**
     * Registers the plugin hooks for start, end, and load events.
     *
     * @param paths - The resolved path aliases.
     * @param rootDir - The root directory for resolving paths.
     */
    private registerPluginHooks;
    /**
     * Generates a path alias object from the TypeScript provider's path options.
     * This method processes the `paths` property from the TypeScript provider's options,
     * which is expected to be an object where each key represents a path alias pattern,
     * and the corresponding value is an array of paths. The method removes any wildcard
     * characters (`*`) from both the keys and the first values of the arrays. It also
     * resolves the paths relative to the specified `rootDir`, returning a simplified
     * object that maps the cleaned keys to their respective paths.
     *
     * The resolved paths will be formatted to use a relative path notation.
     *
     * Example:
     * Given the following paths:
     * ```ts
     * {
     *   '@core/*': ['src/core/*'],
     *   '@utils/*': ['src/utils/*']
     * }
     * ```
     * And assuming `rootDir` is set to the base directory of your project, the method
     * will return:
     * ```ts
     * {
     *   '@core/': './core/',
     *   '@utils/': './utils/'
     * }
     * ```
     *
     * @param rootDir - The root directory to resolve paths against.
     * @returns An object mapping cleaned path aliases to their respective resolved paths.
     */
    private generatePathAlias;
    /**
     * Handles errors during the build process.
     * This method processes and logs errors that occur during the esbuild process. It specifically filters out
     * errors related to TypeScript (`TypesError`) to prevent them from being logged, while logging all other errors
     * to the console. The error object is assumed to contain a list of messages, each with detailed information.
     *
     * @param esbuildError - The error object returned by esbuild, which is expected to contain an array of
     * error messages.
     *
     * @private
     *
     * @remarks
     * - TypeScript errors (denoted as `TypesError`) are skipped and not logged.
     * - Other errors are logged to the console with their text descriptions.
     *
     * @example
     * ```ts
     * try {
     *     await buildService.run();
     * } catch (esbuildError) {
     *     buildService.handleErrors(esbuildError);
     * }
     * ```
     *
     * In this example, if an error occurs during the build process, the `handleErrors` method is used to
     * process and log the errors.
     */
    private handleErrors;
    /**
     * Injects a configuration object (banner or footer) into the `esbuild` options.
     * This method will update the `esbuild` object by adding or modifying the `banner` or `footer`
     * property based on the provided configuration.
     * The function handles both static values
     * and functions within the configuration.
     *
     * @param esbuild - The `esbuild` configuration object where the `banner` or `footer`
     *                  should be injected or updated.
     * @param object - The configuration object that contains the properties to inject.
     *                 The properties can either be static values or functions.
     * @param name - A string that determines whether the method modifies the `banner` or `footer`
     *               property of the `esbuild` object.
     *
     * @returns void - This method does not return any value.
     * It modifies the `esbuild` object directly.
     *
     * @throws Error - If the `object` parameter is not provided, nothing is injected.
     *                   No action will be taken if the specific `name` property (either
     *                   'banner' or 'footer') does not exist in the `esbuild` object.
     */
    private injects;
    /**
     * Builds the project based on the configuration.
     * Depending on the configuration, this method either uses esbuild's `context` for watching or `build` for a one-time build.
     *
     * @returns A promise that resolves with the build context or result.
     *
     * @private
     */
    private build;
    /**
     * Manages development processes for specified entry points.*
     * This method spawns development processes for each file in the metafile that matches any of the specified entry points.
     * It enables features like source maps and optional debugging mode for each spawned process.
     *
     * @param meta - The metafile containing information about build outputs.
     * This typically includes a mapping of output files and their dependencies.
     * @param entryPoint - An array of entry point file names to match against the metafile outputs.
     * Only files that match these entry points will have development processes spawned.
     * @param debug - A boolean flag to enable debugging mode for spawned processes.
     * If `true`, the processes will start in debug mode with the `--inspect-brk` option. Defaults to `false`.
     *
     * @returns void
     *
     * @remarks
     * - Files that contain 'map' in their names (e.g., source map files) are ignored and no process is spawned for them.
     * - For each matching file in the metafile outputs, a new development process is spawned using the `spawn` function.
     * - The `activePossess` array tracks all spawned processes, allowing further management (e.g., termination).
     *
     * @example
     * ```ts
     * const meta = {
     *   outputs: {
     *     'dist/index.js': { \/* ... *\/ },
     *     'dist/index.js.map': { \/* ... *\/ }
     *   }
     * };
     * const entryPoints = ['index'];
     *
     * this.spawnDev(meta, entryPoints, true); // Spawns processes in debug mode
     * ```
     *
     * @private
     */
    private spawnDev;
    /**
     * Starts the build process and type checking.
     * This method performs initial setup for the build and ensures that any child processes are terminated properly.
     *
     * @private
     */
    private start;
    /**
     * Finalizes the build process and logs results.
     * This method handles the end of the build process, logs build results, and processes development files if applicable.
     *
     * @private
     */
    private end;
    /**
     * Processes and updates entry points based on project dependencies.
     * This method analyzes the project's dependencies and adjusts entry points configuration as needed.
     *
     * @private
     */
    private processEntryPoints;
}
/**
 * Main run function that initiates the build process based on CLI arguments.
 *
 * This function parses the CLI arguments, configures the build settings, and executes
 * the appropriate build tasks, including type checking, serving, or running in debug mode.
 *
 * @param argv - An array of strings representing the CLI arguments.
 *
 * @returns A promise that resolves when all build tasks are completed.
 *
 * @example
 * ```ts
 * await buildWithArgv(process.argv);
 * ```
 */
export declare function buildWithArgv(argv: Array<string>): Promise<void>;
/**
 * Builds the project using a configuration file specified by its path.
 *
 * This function reads the configuration from the provided file path, processes it,
 * and initiates the build tasks.
 *
 * @param configFilePath - The path to the configuration file to be used for the build.
 *
 * @returns A promise that resolves to an array of `BuildResult` objects once all build tasks are completed.
 *
 * @throws Error Throws an error if the configuration file does not exist or is invalid.
 *
 * @example
 * ```ts
 * const results = await buildWithPath('./config.ts');
 * console.log('Build results:', results);
 * ```
 */
export declare function buildWithConfigPath(configFilePath: string): Promise<BuildResult[]>;
/**
 * Builds the project based on the provided configuration object.
 *
 * This function processes the given configuration and executes the build tasks accordingly.
 *
 * @param config - A partial configuration object used to define the build settings.
 *
 * @returns A promise that resolves to an array of `BuildResult` objects once all build tasks are completed.
 *
 * @example
 * ```ts
 * const results = await build({ entryPoints: ['./src/index.ts'] });
 * console.log('Build results:', results);
 * ```
 */
export declare function build(config: PartialDeepConfigurationsType): Promise<BuildResult[]>;
