/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * * @format * @oncall react_native */ import type { AssetData } from "./Assets"; import type { ReadOnlyGraph } from "./DeltaBundler"; import type { ServerOptions } from "./Server"; import type { BuildOptions, OutputOptions, RequestOptions } from "./shared/types"; import type { HandleFunction } from "connect"; import type { TransformProfile } from "../metro-babel-transformer"; import type { ConfigT, InputConfigT, MetroConfig, Middleware } from "../metro-config"; import type { CustomResolverOptions } from "../metro-resolver"; import type { CustomTransformOptions } from "../metro-transform-worker"; import type { Server as HttpServer } from "node:http"; import type { Server as HttpsServer, ServerOptions as HttpsServerOptions } from "node:https"; import type { Server as WebSocketServer } from "ws"; import type $$IMPORT_TYPEOF_1$$ from "yargs"; type Yargs = typeof $$IMPORT_TYPEOF_1$$; import getSchemeResolvers from "./lib/getSchemeResolvers"; import JsonReporter from "./lib/JsonReporter"; import TerminalReporter from "./lib/TerminalReporter"; import MetroServer from "./Server"; import { loadConfig, mergeConfig, resolveConfig } from "../metro-config"; import { Terminal } from "../metro-core"; export interface MetroMiddleWare { attachHmrServer: (httpServer: HttpServer | HttpsServer) => void; end: () => Promise; metroServer: MetroServer; middleware: Middleware; } export interface RunMetroOptions extends ServerOptions { waitForBundler?: boolean; } export interface _RunServerOptions_websocketEndpoints { readonly [path: string]: WebSocketServer; } export interface RunServerOptions { readonly hasReducedPerformance?: boolean; readonly host?: string; readonly onError?: (err: Error & { code?: string; }) => void; readonly onReady?: (server: HttpServer | HttpsServer) => void; readonly onClose?: () => void; readonly secureServerOptions?: HttpsServerOptions; readonly secure?: boolean; readonly secureCert?: string; readonly secureKey?: string; readonly unstable_extraMiddleware?: ReadonlyArray; readonly waitForBundler?: boolean; readonly watch?: boolean; readonly websocketEndpoints?: _RunServerOptions_websocketEndpoints; } export interface RunServerResult { httpServer?: HttpServer | HttpsServer; } export interface BuildGraphOptions { entries: ReadonlyArray; customTransformOptions?: CustomTransformOptions; dev?: boolean; minify?: boolean; onProgress?: (transformedFileCount: number, totalFileCount: number) => void; platform?: string; type?: "module" | "script"; } export interface _RunBuildOptions_output { readonly build: (server: MetroServer, requestOptions: RequestOptions, buildOptions?: BuildOptions) => Promise<{ code: string; map: string; assets?: ReadonlyArray; }>; readonly save: (output: { code: string; map: string; }, opts: OutputOptions, logger: (logMessage: string) => void) => Promise; } export interface RunBuildOptions { entry: string; assets?: boolean; dev?: boolean; out?: string; bundleOut?: string; sourceMapOut?: string; onBegin?: () => void; onComplete?: () => void; onProgress?: (transformedFileCount: number, totalFileCount: number) => void; minify?: boolean; output?: _RunBuildOptions_output; platform?: string; sourceMap?: boolean; sourceMapUrl?: string; customResolverOptions?: CustomResolverOptions; customTransformOptions?: CustomTransformOptions; unstable_transformProfile?: TransformProfile; } export interface RunBuildResult { code: string; map: string; assets?: ReadonlyArray; } type BuildCommandOptions = { readonly [$$Key$$: string]: unknown; } | null; type ServeCommandOptions = { readonly [$$Key$$: string]: unknown; } | null; type DependenciesCommandOptions = { readonly [$$Key$$: string]: unknown; } | null; export { Terminal, JsonReporter, TerminalReporter, getSchemeResolvers }; export type { AssetData } from "./Assets"; export type { AsyncDependencyType, DeltaResult, Dependency, MixedOutput, Module, ReadOnlyDependencies, ReadOnlyGraph, SerializerOptions, TransformInputOptions, TransformResult, TransformResultDependency } from "./DeltaBundler/types"; export type { default as DependencyGraph } from "./node-haste/DependencyGraph"; export type { BundleDetails, Reporter, ReportableEvent } from "./lib/reporting"; export type { TerminalReportableEvent } from "./lib/TerminalReporter"; export type { ContextMode, RequireContextParams } from "./ModuleGraph/worker/collectDependencies"; export type { ServerOptions } from "./Server"; export type { MetroConfig, MetroServer }; export declare function runMetro(config: InputConfigT, options?: RunMetroOptions): Promise; export { loadConfig, mergeConfig, resolveConfig }; export declare const createConnectMiddleware: (config: ConfigT, options?: RunMetroOptions) => Promise; export declare const runServer: (config: ConfigT, opts: RunServerOptions) => Promise; export declare const runBuild: (config: ConfigT, opts: RunBuildOptions) => Promise; export declare const buildGraph: (config: InputConfigT, opts: BuildGraphOptions) => Promise; export interface AttachMetroCLIOptions { build?: BuildCommandOptions; serve?: ServeCommandOptions; dependencies?: DependenciesCommandOptions; } export declare const attachMetroCli: (yargs: Yargs, options?: AttachMetroCLIOptions) => Yargs;