paratext
API reference

paratext/terminal-link

Every export of paratext/terminal-link, with its signature and doc comment: terminalLinkFor, terminalLink, plus 4 types.

import terminalLink from 'paratext/terminal-link';
import { terminalLinkFor } from 'paratext/terminal-link';

Functions

terminalLinkFor

terminalLink bound to a runtime you supply — the pure form, and what the export wraps.

function terminalLinkFor(runtime: Runtime): (text: string, url: string, { target, ...options }?: LinkOptions) => string;
ParameterType
runtimeRuntime

Returns (text: string, url: string, { target, ...options }?: LinkOptions) => string

Constants

default

The default export, declared as terminalLink.

const terminalLink: TerminalLink;

Interfaces

LinkOptions

interface LinkOptions {
    target?: Target;
    /**
     * What to print when the terminal is not believed to render OSC 8.
     *
     * `false` returns the text alone, a function is called with `(text, url)`, and anything
     * else — including absent — gives upstream's `text url`, a raw URL bounded by whitespace
     * because that is what terminal linkifiers detect reliably.
     */
    fallback?: boolean | ((text: string, url: string) => string);
}

terminalLink(text, url, options?) against the real process.

isSupported is a snapshot taken at import, which is upstream's shape exactly — it reads supportsHyperlinks.stdout once at module scope. A caller who needs the live answer calls the function and compares, or builds its own through {@link terminalLinkFor}.

interface TerminalLink {
    (text: string, url: string, options?: LinkOptions): string;
    isSupported: boolean;
    stderr: {
        (text: string, url: string, options?: Omit<LinkOptions, 'target'>): string;
        isSupported: boolean;
    };
}

Types

Options

Upstream's name for the options, so import { type Options } from 'terminal-link' migrates.

type Options = LinkOptions;

Target

Which stream a call is bound for. Upstream's target option, spelled the same way.

type Target = 'stdout' | 'stderr';

On this page