/** * The compartment mapper requires certain host capabilities. * These are the platform-neutral types for those capabilities. * For example, {@file node-powers.js} adapts Node.js how modules * to various subsets of these capabilities. * * @module */ import type { SomeObject } from './typescript.js'; /** * All available read powers * * @template T The expected input/output type of the {@link CanonicalFn}. */ export type ReadPowers = { canonical: CanonicalFn; read: ReadFn; maybeRead?: MaybeReadFn; readNow?: ReadNowFn; maybeReadNow?: MaybeReadNowFn; computeSha512?: HashFn; fileURLToPath?: FileURLToPathFn; pathToFileURL?: PathToFileURLFn; requireResolve?: RequireResolveFn; isAbsolute?: IsAbsoluteFn; }; /** * @template T The expected input/output type of the {@link CanonicalFn}. */ export type MaybeReadPowers = ReadPowers & { maybeRead: MaybeReadFn; }; /** * The extension of {@link ReadPowers} necessary for dynamic require support * * For a `ReadPowers` to be a `ReadNowPowers`: * * 1. It must be an object (not a {@link ReadFn}) * 2. Prop `maybeReadNow` is a function * 3. Prop `fileURLToPath` is a function * 4. Prop `isAbsolute` is a function * * @template T The expected input/output type of the {@link CanonicalFn}. */ export type ReadNowPowers = Omit, ReadNowPowersProp> & Required, ReadNowPowersProp>>; /** * These properties are necessary for dynamic require support */ export type ReadNowPowersProp = 'fileURLToPath' | 'isAbsolute' | 'maybeReadNow'; /** * Returns a canonical URL for a given URL, following redirects or symbolic * links if any exist along the path. Must return the given logical location if * the real location does not exist. * * @template T The expected input/output type of the {@link CanonicalFn}. This * may be a particular type of URL, such as a `FileUrlString`. */ export type CanonicalFn = (location: T) => Promise; /** * A function which reads some location and resolves with bytes. */ export type ReadFn = (location: string) => Promise; /** * A resolution of `undefined` indicates `ENOENT` or the equivalent. */ export type MaybeReadFn = (location: string) => Promise; /** * A function which reads some location and returns bytes. */ export type ReadNowFn = (location: string) => Uint8Array; /** * A resolution of `undefined` indicates `ENOENT` or the equivalent. */ export type MaybeReadNowFn = (location: string) => Uint8Array | undefined; /** * Returns a string hash of a byte array */ export type HashFn = (bytes: Uint8Array) => string; export type FileURLToPathFn = (url: URL | string) => string; export type PathToFileURLFn = (path: string) => URL; export type RequireResolveFn = (fromLocation: string, specifier: string, options?: { paths?: string[]; } | undefined) => any; export type IsAbsoluteFn = (location: string) => boolean; export type ArchiveReader = { read: ReadFn; }; /** * Read powers with a {@link HashFn}. * * @template T The expected input/output type of the {@link CanonicalFn}. */ export type HashPowers = { read: ReadFn; canonical: CanonicalFn; computeSha512: HashFn; }; export type WritePowers = { write: WriteFn; }; export type WriteFn = (location: string, bytes: Uint8Array) => Promise; export type ArchiveWriter = { write: WriteFn; snapshot: SnapshotFn; }; export type SnapshotFn = () => Promise; export type Application = { import: ExecuteFn; sha512?: string | undefined; }; export type ExecuteFn = (options?: any) => Promise; //# sourceMappingURL=powers.d.ts.map