UNPKG

react-native-node-api

Version:
98 lines 4.92 kB
export declare const PLATFORMS: readonly ["android", "apple"]; export type PlatformName = "android" | "apple"; export declare const PLATFORM_EXTENSIONS: { readonly android: ".android.node"; readonly apple: ".apple.node"; }; export type PlatformExtentions = (typeof PLATFORM_EXTENSIONS)[PlatformName]; export declare const PATH_SUFFIX_CHOICES: readonly ["strip", "keep", "omit"]; export type PathSuffixChoice = (typeof PATH_SUFFIX_CHOICES)[number]; export declare function assertPathSuffix(value: unknown): asserts value is PathSuffixChoice; export type NamingStrategy = { /** * Controls how the path of the addon inside a package is transformed into a library name. * The transformation is needed to disambiguate and avoid conflicts between addons with the same name (but in different sub-paths or packages). * * As an example, if the package name is `my-pkg` and the path of the addon within the package is `build/Release/my-addon.node`: * - `"omit"`: Only the package name is used and the library name will be `my-pkg`. * - `"strip"`: Path gets stripped to its basename and the library name will be `my-pkg--my-addon`. * - `"keep"`: The full path is kept and the library name will be `my-pkg--build-Release-my-addon`. */ pathSuffix: PathSuffixChoice; }; /** * @param modulePath Batch-scans the path to the module to check (must be extensionless or end in .node) * @returns True if a platform specific prebuild exists for the module path, warns on unreadable modules. * @throws If the parent directory cannot be read, or if a detected module is unreadable. * TODO: Consider checking for a specific platform extension. */ export declare function isNodeApiModule(modulePath: string): boolean; /** * Strip of any platform specific extensions from a module path. */ export declare function stripExtension(modulePath: string): string; export type ModuleContext = { packageName: string; relativePath: string; }; /** * Traverse the filesystem upward to find a name for the package that which contains a file. */ export declare function determineModuleContext(modulePath: string, originalPath?: string): ModuleContext; export declare function normalizeModulePath(modulePath: string): string; export declare function escapePath(modulePath: string): string; /** * Get the name of the library which will be used when the module is linked in. */ export declare function getLibraryName(modulePath: string, naming: NamingStrategy): string; export declare function prettyPath(p: string): string; export declare function resolvePackageRoot(requireFromPackageRoot: NodeJS.Require, packageName: string): string | undefined; export declare function logModulePaths(modulePaths: string[], naming: NamingStrategy): void; /** * Search upwards from a directory to find a package.json and * return a record mapping from each dependencies of that package to their path on disk. */ export declare function findPackageDependencyPaths(fromPath: string): Record<string, string>; export declare const MAGIC_FILENAME = "react-native-node-api-module"; /** * Default patterns to use when excluding paths from the search for Node-API modules. */ export declare const DEFAULT_EXCLUDE_PATTERNS: RegExp[]; export declare function hasPlatformExtension(platform: PlatformName | Readonly<PlatformName[]>, fileName: string): boolean; export type FindNodeApiModuleOptions = { fromPath: string; excludePatterns?: RegExp[]; platform: PlatformName | Readonly<PlatformName[]>; }; /** * Recursively search into a directory for directories containing Node-API modules. */ export declare function findNodeApiModulePaths(options: FindNodeApiModuleOptions, suffix?: string): Promise<string[]>; /** * Default package names to use when excluding packages from the search for Node-API modules. */ export declare const DEFAULT_EXCLUDE_PACKAGES: string[]; /** * Finds all dependencies of the app package and their xcframeworks. */ export declare function findNodeApiModulePathsByDependency({ fromPath, includeSelf, excludePackages, ...options }: FindNodeApiModuleOptions & { includeSelf: boolean; excludePackages?: string[]; }): Promise<{ [k: string]: { readonly path: string; readonly modulePaths: string[]; }; }>; /** * Determine the library basename (no file extension nor "lib" prefix) based on the library paths. * Errors if all framework paths doesn't produce the same basename. */ export declare function determineLibraryBasename(libraryPaths: string[]): string; export declare function getAutolinkPath(platform: PlatformName): string; /** * Get the latest modification time of all files in a directory and its subdirectories. */ export declare function getLatestMtime(fromPath: string): number; export declare function findNodeAddonForBindings(id: string, fromDir: string): string | undefined; //# sourceMappingURL=path-utils.d.ts.map