/** * 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 * @generated SignedSource<<0f12d9416b13e4b57d3f7aae9795c8e3>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro/src/lib/RootUrlMap.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ import type {DynamicRoot} from './dynamicRoots'; import type {ConfigT} from 'metro-config'; /** * The most `watchFolders` that keep every index shorter than a dynamic root * id, so that the two cannot be confused. */ export declare const MAX_WATCH_FOLDERS: number; export declare type MAX_WATCH_FOLDERS = typeof MAX_WATCH_FOLDERS; /** * Bidirectional map between URL pathnames and filesystem paths, encoding the * `[metro-project]` and `[metro-watchFolders]` virtual prefix conventions. * * The id after `[metro-watchFolders]` is either an index into the configured * `watchFolders`, or, if it has `DYNAMIC_ROOT_ID_LENGTH` characters, the id of * a dynamic root. The routes for `projectRoot` * and `watchFolders` are fixed, and dynamic roots are read on each use. */ declare class RootUrlMap { readonly serverRootDir: string; readonly _projectRootDirPrefix: string; readonly _watchFolderDirPrefixes: ReadonlyArray; readonly _filePathRoutes: ReadonlyArray<{ rootDirPrefix: string; pathnamePrefix: string; }>; readonly _getDynamicRoots: () => ReadonlyArray; constructor(config: ConfigT, getDynamicRoots?: () => ReadonlyArray); /** * Decode a URL pathname and resolve it to an absolute filesystem path. */ filePathOfUrlPathname(pathname: string): string | null; /** * Convert a URL pathname or entry-file path to an absolute filesystem path. * * Accepts both URL-style (`/[metro-watchFolders]/1/foo`) and entry-file-style * (`./[metro-watchFolders]/1/foo`) prefixes. * * Returns `null` when the pathname does not match a known virtual prefix, * or for out-of-bounds watchFolder indices. */ filePathOfUrlDecodedPathname(pathname: string): string | null; /** * Convert an absolute filesystem path to a URL pathname using the first * matching virtual prefix. * * Falls back to the absolute path (as a POSIX-style URL) when the file is * not under any configured route. */ urlPathnameOfFilePath(filePath: string): string; } export default RootUrlMap;