/** Platform-specific file path. */ export type LocalPath = string; /** Local URL (file://). */ export type LocalUrl = URL; /** Path-ish type. */ export type PathLike = LocalPath | LocalUrl; /** * Represents the input as a platform-specific path. This path can be * manipulated by the `path` module's utilities. */ export declare function localPath(pl: PathLike, pp?: PosixPath): LocalPath; /** Returns a POSIX equivalent to the input path. */ export declare function posixPath(pl: PathLike): PosixPath; /** * Represents the input as a file URL. Paths without an explicit protocol will * be normalized. Throws if the returned URL does not have the `file:` protocol. */ export declare function localUrl(pl: PathLike, opts?: { /** * Parent URL to use when the input path-like is a relative path. Note that * unlike the `URL`'s `base` constructor argument, the full parent path will * always be used, even if does not end in a slash. By default the CWD is * used. */ readonly parent?: LocalUrl; /** * When true, ensures the returned URL ends with a slash; when false, * ensures the URL does not (except if it is the root path). When not set, * keep the original path. */ readonly trailingSlash?: boolean; }): LocalUrl; export declare function updateTrailingSlash(u: URL, include: boolean): void; /** `/`-delimited file path. */ export type PosixPath = string; export type RelativePosixPath = PosixPath; export type AbsolutePosixPath = PosixPath; export declare const RESOURCES_FOLDER = "resources"; /** Package resource. */ export interface Resource { readonly contents: V; readonly url: LocalUrl; } /** Package resource loader */ export declare class ResourceLoader { readonly dependenciesFolder: string; readonly resourcesFolder: string; private readonly root; private constructor(); get rootPath(): LocalPath; /** Creates a new loader. */ static create(opts?: { /** Defaults to `process.cwd()`. */ readonly root?: PathLike; /** Defaults to `node_modules`. */ readonly dependenciesFolder?: string; /** Defaults to `RESOURCES_FOLDER`. */ readonly resourcesFolder?: string; }): ResourceLoader; /** Returns a loader scoped to the enclosing package. */ static enclosing(pl: PathLike): ResourceLoader; /** * Returns a loader scoped to the input path (i.e. with updated root). * Relative paths are taken relative to the loader's current root. */ scoped(pp: PosixPath): ResourceLoader; /** * Returns a resource loader scoped to the dependency. This assumes that the * `node_modules` dependency structure is identical to PNPM's * (https://pnpm.io/symlinked-node-modules-structure). */ scopedToDependency(name: string): ResourceLoader; /** * Returns a file URL pointing to the resource at the given path. Relative * paths are taken relative to the loader's current resource folder. */ localUrl(...pps: PosixPath[]): LocalUrl; /** Lists all file (including directory) URLs in the given path. */ listLocalUrlsSync(...pps: PosixPath[]): ReadonlyArray; /** * Lists all file (non-directory) URLs under the given path (potentially * nested). Only files and directories under the target can be present (links, * sockets, etc. will cause an error). */ walkLocalFileUrlsSync(...pps: PosixPath[]): ReadonlyArray; /** Reads a text resource's contents from the given relative path. */ load(...pps: PosixPath[]): Promise; }