paratext/term-img
Every export of paratext/term-img, with its signature and doc comment: supportsInlineImage, terminalImageFor, UnsupportedTerminalError, terminalImage, plus 3 types.
import terminalImage from 'paratext/term-img';
import { supportsInlineImage, terminalImageFor, UnsupportedTerminalError } from 'paratext/term-img';Functions
supportsInlineImage
term-img's own support question, from the environment alone.
function supportsInlineImage(runtime: Runtime): boolean;| Parameter | Type |
|---|---|
runtime | Runtime |
Returns boolean
terminalImageFor
terminalImage bound to a runtime you supply — the pure form, and what the export wraps.
function terminalImageFor(runtime: Runtime): <FallbackType = never>(image?: TerminalImageInput, options?: TerminalImageOptions<FallbackType>) => string | FallbackType;| Parameter | Type |
|---|---|
runtime | Runtime |
Returns <FallbackType = never>(image?: TerminalImageInput, options?: TerminalImageOptions<FallbackType>) => string \| FallbackType
Classes
UnsupportedTerminalError
Thrown when the terminal is not believed to draw an inline image and the caller supplied
no fallback. Upstream's class, upstream's message, upstream's name — a caller that
matched on error.name or on instanceof keeps working, which is most of what drop-in
means for an error type.
class UnsupportedTerminalError extends Error {
/**
* The parameter is ours; upstream's constructor takes none. It is a superset — `new
* UnsupportedTerminalError()` still produces upstream's exact message — and it exists so a
* caller that knows more about *why* the terminal refused can say so.
*/
constructor(message?: string);
}Constants
default
The default export, declared as terminalImage.
terminalImage(image, options?) against the real process — term-img's default export.
const terminalImage: <FallbackType = never>(image?: TerminalImageInput, options?: TerminalImageOptions<FallbackType>) => string | FallbackType;Interfaces
TerminalImageOptions
term-img's options: ansi-escapes' four, plus the escape hatch from the throw.
interface TerminalImageOptions<FallbackType = unknown> extends ImageOptions {
/** Called instead of throwing when the terminal cannot draw it. What it returns is returned. */
fallback?: () => FallbackType;
}Types
Options
Upstream's name for the options, so import { type Options } from 'term-img' migrates.
type Options<FallbackType = unknown> = TerminalImageOptions<FallbackType>;TerminalImageInput
What upstream's argument accepts — bytes or a file path — plus a file URL, which
readFileSync takes and upstream refuses as Image required only because a URL has no
length. A superset: every call upstream accepts means the same thing here.
type TerminalImageInput = Uint8Array | string | URL | null | undefined;paratext/plugin
Every export of paratext/plugin, with its signature and doc comment: validate, register, reset, registered, contributions, attach and 2 more, plus 5 types.
paratext/terminal-link
Every export of paratext/terminal-link, with its signature and doc comment: terminalLinkFor, terminalLink, plus 4 types.