/** * 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. * * @noformat * @oncall react_native * @generated SignedSource<<161e77301d04ce6cc254f1dbf15ef06b>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro/src/Server.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ import type {AssetData} from './Assets'; import type {ExplodedSourceMap} from './DeltaBundler/Serializers/getExplodedSourceMap'; import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo'; import type { Module, ReadOnlyDependencies, ReadOnlyGraph, TransformInputOptions, } from './DeltaBundler/types'; import type {RevisionId} from './IncrementalBundler'; import type {GraphId} from './lib/getGraphId'; import type {Reporter} from './lib/reporting'; import type { BuildOptions, BundleOptions, GraphOptions, ResolverInputOptions, SplitBundleOptions, } from './shared/types'; import type {IncomingMessage} from 'connect'; import type {ServerResponse} from 'http'; import type {ConfigT, RootPerfLogger} from 'metro-config'; import type { ActionLogEntryData, ActionStartLogEntry, } from 'metro-core/private/Logger'; import type {CustomResolverOptions} from 'metro-resolver/private/types'; import type {CustomTransformOptions} from 'metro-transform-worker'; import IncrementalBundler from './IncrementalBundler'; import MultipartResponse from './Server/MultipartResponse'; import {SourcePathsMode} from './shared/types'; import {Logger} from 'metro-core'; export type SegmentLoadData = { [$$Key$$: number]: [Array, null | undefined | number]; }; export type BundleMetadata = { hash: string; otaBuildNumber: null | undefined | string; mobileConfigs: Array; segmentHashes: Array; segmentLoadData: SegmentLoadData; }; type ProcessStartContext = Omit< SplitBundleOptions, keyof { readonly buildNumber: number; readonly bundleOptions: BundleOptions; readonly graphId: GraphId; readonly graphOptions: GraphOptions; readonly mres: MultipartResponse | ServerResponse; readonly req: IncomingMessage; readonly revisionId?: null | undefined | RevisionId; readonly bundlePerfLogger: RootPerfLogger; readonly requestStartTimestamp: number; } > & { readonly buildNumber: number; readonly bundleOptions: BundleOptions; readonly graphId: GraphId; readonly graphOptions: GraphOptions; readonly mres: MultipartResponse | ServerResponse; readonly req: IncomingMessage; readonly revisionId?: null | undefined | RevisionId; readonly bundlePerfLogger: RootPerfLogger; readonly requestStartTimestamp: number; }; type ProcessDeleteContext = { readonly graphId: GraphId; readonly req: IncomingMessage; readonly res: ServerResponse; }; type ProcessEndContext = Omit< ProcessStartContext, keyof {readonly result: T} > & {readonly result: T}; export type ServerOptions = Readonly<{ hasReducedPerformance?: boolean; onBundleBuilt?: (bundlePath: string) => void; watch?: boolean; }>; type FetchTiming = { graphId: GraphId; startTime: number; endTime: number | null; isPrefetch: boolean; }; declare class Server { _bundler: IncrementalBundler; _config: ConfigT; _createModuleId: (path: string) => number; _isEnded: boolean; _logger: typeof Logger; _nextBundleBuildNumber: number; _platforms: Set; _reporter: Reporter; _serverOptions: ServerOptions | void; _allowedSuffixesForSourceRequests: ReadonlyArray; _sourceRequestRoutingMap: ReadonlyArray< [pathnamePrefix: string, normalizedRootDir: string] >; _fetchTimings: Array; _activeFetchCount: number; constructor(config: ConfigT, options?: ServerOptions); end(): void; getBundler(): IncrementalBundler; getCreateModuleId(): (path: string) => number; _serializeGraph( $$PARAM_0$$: Readonly<{ splitOptions: SplitBundleOptions; prepend: ReadonlyArray; graph: ReadOnlyGraph; }>, ): Promise<{code: string; map: string}>; build( bundleOptions: BundleOptions, $$PARAM_1$$?: BuildOptions, ): Promise<{code: string; map: string; assets?: ReadonlyArray}>; getRamBundleInfo(options: BundleOptions): Promise; getAssets(options: BundleOptions): Promise>; _getAssetsFromDependencies( dependencies: ReadOnlyDependencies, platform: null | undefined | string, ): Promise>; getOrderedDependencyPaths(options: { readonly dev: boolean; readonly entryFile: string; readonly minify: boolean; readonly platform: null | undefined | string; }): Promise>; _rangeRequestMiddleware( req: IncomingMessage, res: ServerResponse, data: string | Buffer, assetPath: string, ): Buffer | string; _processSingleAssetRequest( req: IncomingMessage, res: ServerResponse, ): Promise; processRequest: ( $$PARAM_0$$: IncomingMessage, $$PARAM_1$$: ServerResponse, $$PARAM_2$$: (e: null | undefined | Error) => void, ) => void; _parseOptions(url: string): BundleOptions; _rewriteAndNormalizeUrl(requestUrl: string): string; _processRequest( req: IncomingMessage, res: ServerResponse, next: ($$PARAM_0$$: null | undefined | Error) => void, ): Promise; _processSourceRequest( relativeFilePathname: string, rootDir: string, res: ServerResponse, ): Promise; _createRequestProcessor($$PARAM_0$$: { readonly bundleType: 'assets' | 'bundle' | 'map'; readonly createStartEntry: ( context: ProcessStartContext, ) => ActionLogEntryData; readonly createEndEntry: ( context: ProcessEndContext, ) => Partial; readonly build: (context: ProcessStartContext) => Promise; readonly delete?: (context: ProcessDeleteContext) => Promise; readonly finish: (context: ProcessEndContext) => void; }): ( req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: Readonly<{ buildNumber: number; bundlePerfLogger: RootPerfLogger; }>, ) => Promise; _processBundleRequest: ( req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: Readonly<{ buildNumber: number; bundlePerfLogger: RootPerfLogger; }>, ) => Promise; _getSortedModules(graph: ReadOnlyGraph): ReadonlyArray; _processSourceMapRequest: ( req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: Readonly<{ buildNumber: number; bundlePerfLogger: RootPerfLogger; }>, ) => Promise; _processAssetsRequest: ( req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: Readonly<{ buildNumber: number; bundlePerfLogger: RootPerfLogger; }>, ) => Promise; _symbolicate(req: IncomingMessage, res: ServerResponse): Promise; _explodedSourceMapForBundleOptions( bundleOptions: BundleOptions, ): Promise; _resolveRelativePath( filePath: string, $$PARAM_1$$: Readonly<{ relativeTo: 'project' | 'server'; resolverOptions: ResolverInputOptions; transformOptions: TransformInputOptions; }>, ): Promise; getNewBuildNumber(): number; getPlatforms(): ReadonlyArray; getWatchFolders(): ReadonlyArray; static DEFAULT_GRAPH_OPTIONS: Readonly<{ customResolverOptions: CustomResolverOptions; customTransformOptions: CustomTransformOptions; dev: boolean; minify: boolean; unstable_transformProfile: 'default'; }>; static DEFAULT_BUNDLE_OPTIONS: Omit< typeof Server.DEFAULT_GRAPH_OPTIONS, keyof { excludeSource: false; inlineSourceMap: false; lazy: false; modulesOnly: false; onProgress: null; runModule: true; shallow: false; sourceMapUrl: null; sourceUrl: null; sourcePaths: SourcePathsMode; } > & { excludeSource: false; inlineSourceMap: false; lazy: false; modulesOnly: false; onProgress: null; runModule: true; shallow: false; sourceMapUrl: null; sourceUrl: null; sourcePaths: SourcePathsMode; }; _getServerRootDir(): string; _getEntryPointAbsolutePath(entryFile: string): string; ready(): Promise; _shouldAddModuleToIgnoreList(module: Module): boolean; _getModuleSourceUrl(module: Module, mode: SourcePathsMode): string; } export default Server;