/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow strict-local */ 'use strict'; import type {IncomingMessage, ServerResponse} from 'http'; import typeof MetroCache from 'metro-cache'; import type {CacheStore} from 'metro-cache'; import type {CustomResolver} from 'metro-resolver'; import type {BasicSourceMap, MixedSourceMap} from 'metro-source-map'; import type {JsTransformerConfig} from 'metro-transform-worker'; import type { DeltaResult, Graph, Module, SerializerOptions, } from 'metro/src/DeltaBundler/types.flow.js'; import type {TransformResult} from 'metro/src/DeltaBundler'; import type {TransformVariants} from 'metro/src/ModuleGraph/types.flow.js'; import type Server from 'metro/src/Server'; import type {Reporter} from 'metro/src/lib/reporting'; export type PostMinifyProcess = ({ code: string, map: ?BasicSourceMap, ... }) => { code: string, map: ?BasicSourceMap, ... }; export type PostProcessBundleSourcemap = ({ code: Buffer | string, map: MixedSourceMap, outFileName: string, ... }) => { code: Buffer | string, map: MixedSourceMap | string, ... }; type ExtraTransformOptions = { +preloadedModules: {[path: string]: true, ...} | false, +ramGroups: Array, +transform: {| +experimentalImportSupport: boolean, +inlineRequires: {+blockList: {[string]: true, ...}, ...} | boolean, +nonInlinedRequires?: $ReadOnlyArray, +unstable_disableES6Transforms?: boolean, |}, ... }; export type GetTransformOptionsOpts = {| dev: boolean, hot: boolean, platform: ?string, |}; export type GetTransformOptions = ( entryPoints: $ReadOnlyArray, options: GetTransformOptionsOpts, getDependenciesOf: (string) => Promise>, ) => Promise; export type Middleware = ( IncomingMessage, ServerResponse, (e: ?Error) => mixed, ) => mixed; type ResolverConfigT = {| assetExts: $ReadOnlyArray, assetResolutions: $ReadOnlyArray, blacklistRE?: RegExp | Array, blockList: RegExp | Array, dependencyExtractor: ?string, extraNodeModules: {[name: string]: string, ...}, hasteImplModulePath: ?string, nodeModulesPaths: $ReadOnlyArray, platforms: $ReadOnlyArray, resolveRequest: ?CustomResolver, resolverMainFields: $ReadOnlyArray, sourceExts: $ReadOnlyArray, useWatchman: boolean, |}; type SerializerConfigT = {| createModuleIdFactory: () => (path: string) => number, customSerializer: ?( entryPoint: string, preModules: $ReadOnlyArray>, graph: Graph<>, options: SerializerOptions, ) => Promise, experimentalSerializerHook: (graph: Graph<>, delta: DeltaResult<>) => mixed, getModulesRunBeforeMainModule: (entryFilePath: string) => Array, getPolyfills: ({platform: ?string, ...}) => $ReadOnlyArray, getRunModuleStatement: (number | string) => string, polyfillModuleNames: $ReadOnlyArray, postProcessBundleSourcemap: PostProcessBundleSourcemap, processModuleFilter: (modules: Module<>) => boolean, |}; type TransformerConfigT = {| ...JsTransformerConfig, getTransformOptions: GetTransformOptions, postMinifyProcess: PostMinifyProcess, transformVariants: TransformVariants, workerPath: string, publicPath: string, experimentalImportBundleSupport: boolean, |}; type MetalConfigT = {| cacheStores: $ReadOnlyArray>>, cacheVersion: string, hasteMapCacheDirectory?: string, maxWorkers: number, projectRoot: string, stickyWorkers: boolean, transformerPath: string, reporter: Reporter, resetCache: boolean, watchFolders: $ReadOnlyArray, |}; type ServerConfigT = {| enhanceMiddleware: (Middleware, Server) => Middleware, useGlobalHotkey: boolean, port: number, rewriteRequestUrl: string => string, runInspectorProxy: boolean, verifyConnections: boolean, |}; type SymbolicatorConfigT = {| customizeFrame: ({ +file: ?string, +lineNumber: ?number, +column: ?number, +methodName: ?string, ... }) => ?{|+collapse?: boolean|} | Promise, |}; export type InputConfigT = $Shape<{| ...MetalConfigT, ...$ReadOnly<{| cacheStores: | $ReadOnlyArray>> | (MetroCache => $ReadOnlyArray>>), resolver: $Shape, server: $Shape, serializer: $Shape, symbolicator: $Shape, transformer: $Shape, |}>, |}>; export type IntermediateConfigT = {| ...MetalConfigT, ...{| resolver: ResolverConfigT, server: ServerConfigT, serializer: SerializerConfigT, symbolicator: SymbolicatorConfigT, transformer: TransformerConfigT, |}, |}; export type ConfigT = $ReadOnly<{| ...$ReadOnly, ...$ReadOnly<{| resolver: $ReadOnly, server: $ReadOnly, serializer: $ReadOnly, symbolicator: $ReadOnly, transformer: $ReadOnly, |}>, |}>; export type YargArguments = { config?: string, cwd?: string, port?: string | number, host?: string, projectRoot?: string, watchFolders?: Array, assetExts?: Array, sourceExts?: Array, platforms?: Array, 'max-workers'?: string | number, maxWorkers?: string | number, transformer?: string, 'reset-cache'?: boolean, resetCache?: boolean, runInspectorProxy?: boolean, verbose?: boolean, ... };