/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { Logger, PackageJson } from "@fluidframework/build-tools"; import { ApiLevel } from "./apiLevel.js"; /** * Properties for an "exports" leaf entry block in package.json. * A block is the set of conditions and final results as in: * ```json * { * "types": "./index.d.ts", * "default": "./index.js" * } * ``` */ export interface ExportData { /** * Location of file relative to package */ relPath: string; /** * Conditions required for export access; in hierarchy order. */ conditions: readonly string[]; /** * Package export path is only for "types" (expected .d.ts file(s)). * Precisely, there are no alternate conditions where "types" condition * is set, from the package path this export relates to. * In other words, if "types" condition is removed from all of those that * are required to resolve to this file, there are *definitely* no other * resolutions. */ isTypeOnly: boolean; } /** * Minimal set of properties required from an "exports" entry to generate * Node10 compatible redirection files. */ export type Node10CompatExportData = Pick; /** * Read package "exports" to determine which of given "types" file paths are present. * * @param packageJson - json content of package.json * @param mapQueryPathToOutKey - keys of map represent paths to match. When one of those * paths is found in the package.json's exports, the corresponding value (if defined) is * used to set entry key in output mapKeyToOutput. * @param node10TypeCompat - when true, populates output mapNode10CompatExportPathToData. * @param onlyFirstMatches - when true, only the first matches are returned per exports path. * @param logger - optional Logger * @returns object with mapKeyToOutput, map of ApiTags to output paths, and * mapNode10CompatExportPathToData, map of compat file path to Node16 path. */ export declare function queryTypesResolutionPathsFromPackageExports(packageJson: Pick, mapQueryPathToOutKey: ReadonlyMap, { node10TypeCompat, onlyFirstMatches, }: { node10TypeCompat: boolean; onlyFirstMatches: boolean; }, logger?: Logger): { mapKeyToOutput: Map; mapNode10CompatExportPathToData: Map; mapTypesPathToExportPaths: Map[]>; }; /** * Finds the path to the types of a package using the package's export map or types/typings field. * If the path is found, it is returned. Otherwise it returns undefined. * * This implementation uses resolve.exports to resolve the path to types for a level. * * @param packageJson - The package.json object to check for types paths. * @param level - An API level to get types paths for. * @returns A package relative path to the types. * * @remarks * * This implementation loosely follows TypeScript's process for finding types as described at * {@link https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-main-and-types}. If an export * map is found, the `types` and `typings` field are ignored. If an export map is not found, then the `types`/`typings` * fields will be used as a fallback _only_ for the public API level (which corresponds to the default export). * * Importantly, this code _does not_ implement falling back to the `main` field when `types` and `typings` are missing, * nor does it look up types from DefinitelyTyped (i.e. \@types/* packages). This fallback logic is not needed for our * packages because we always specify types explicitly in the types field, and types are always included in our packages * (as opposed to a separate \@types package). */ export declare function getTypesPathFromPackage(packageJson: PackageJson, level: ApiLevel, log: Logger): string | undefined; //# sourceMappingURL=packageExports.d.ts.map