import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import { NpmrcConfig, TlsSettings, TransportFailureVisibility } from "@packall/registry-npm"; import * as Context from "effect/Context"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; import * as HttpClient from "effect/unstable/http/HttpClient"; //#region src/npmrc.d.ts /** A resolved `.npmrc`, and where its values came from. */ type LoadedNpmrc = { readonly config: NpmrcConfig; /** Sources that were read, in precedence order, for reporting. */ readonly sources: ReadonlyArray; /** * TLS trust, with `cafile` already read. * * Resolved by the host rather than by the transport because it is *file* * work, and which files exist is precisely what separates a workstation from * a tab. What the transport receives is plain data it can hand to a socket. */ readonly tls: TlsSettings; /** * Configuration that was understood but could not be honoured. * * Reported rather than thrown: a `cafile` that will not open should not end a * run the system store might complete, but it must not pass in silence * either — the certificate error it leads to names nothing that would help. */ readonly warnings: ReadonlyArray; }; declare namespace Npmrc { type Service = { /** * Resolves the configuration in force. * * `explicitPath` is `--npmrc`, which outranks everything a host would find * on its own. */ readonly load: (explicitPath: string | undefined) => Effect.Effect; }; } declare const Npmrc_base: Context.ServiceClass; /** Service tag for `.npmrc` resolution. */ declare class Npmrc extends Npmrc_base {} //#endregion //#region src/transport.d.ts declare namespace Transport { /** * Everything that has to be settled before a transport can exist. * * Both members are here for the same reason: they are properties of the * *connection*, not of a request, so neither can be applied after the fact by * a caller holding a client. `tls` in particular is the whole reason this * takes an object — `strict-ssl` and `cafile` in an `.npmrc` are worth * nothing unless they reach the thing that opens the socket. */ type Options = { readonly requestTimeoutMs: number; readonly tls: TlsSettings; }; /** The HTTP backend. */ type Service = { /** * A client whose waits are bounded by `requestTimeoutMs`, trusting what * `tls` says to trust. * * Implementations are expected to bound the *connect* phase too where the * platform allows it. `fetch` does not, so a browser bounds whole requests * and nothing finer; Node can and must — see `./node/transport.ts`. */ readonly layerFor: (options: Options) => Layer.Layer; /** * Whether a bare `GET` of the registry root works as a reachability probe. * * True on Node, where preflight is worth having: it is what turns a dead * VPN into a named error before any real work starts. * * False in a browser, and not as a simplification — `registry.npmjs.org/` * answers 200 but sends no `access-control-allow-origin`, while every path * beneath it does. So the probe fails for a reason that has nothing to do * with whether the registry is reachable, and reporting it as unreachable * would be a lie that sends somebody looking at their network. Skipping it * costs little there: `fetch` rejects promptly on a real network failure, * and every request is bounded anyway. */ readonly canProbeRoot: boolean; /** How much diagnostic information survives when a request rejects. */ readonly failureVisibility: TransportFailureVisibility; }; } declare const Transport_base: Context.ServiceClass; /** * Service tag for the HTTP backend. * * A service handing back a *factory* rather than a layer, because the client * cannot be built until `--timeout` has been parsed: on Node the deadline has * to reach into the connect phase, which is a property of the dispatcher and * not of a request. The composition root supplies a way to make a transport, * and the handler makes one once it knows the number. */ declare class Transport extends Transport_base {} //#endregion //#region src/tty.d.ts declare namespace Tty { /** The host the CLI is attached to. */ type Service = { /** * Whether to draw in place. * * False when output is piped, redirected or captured by CI — the renderer * then emits one line per milestone rather than repainting. */ readonly isInteractive: boolean; /** * Whether a question can be asked. * * Separate from `isInteractive`, which is about the *output* stream. On a * workstation the two coincide and one flag reasonably stood for both; * they are different properties of different streams, and two hosts have * now shown it: * * - `packall … < /dev/null` on a real terminal has a repaintable stderr * and no stdin. Asking there hangs or fails on end-of-input. * - A browser terminal repaints beautifully and cannot yet be read from, * because the page's line editor owns the keystrokes. * * The layout prompt is the one that made this matter: it is deliberately * *not* gated behind `--interactive`, so a large `--file` run reaches it * on any host that claims to be interactive. */ readonly canPrompt: boolean; /** * What this host calls itself — `process.platform` on Node, `browser` in a * page. * * Nothing *above* this service reads it: the CLI has no branch on the * platform, and the one place the engine used to take one has moved behind * `@packall/core/node`. It is here because something *below* it reads the * same fact from a global only one of the two hosts has. See * `announcePlatform`, which is the whole of why the field exists. */ readonly platform: string; /** Width available for the live line. */ readonly columns: number; /** Writes to the diagnostic stream. Everything human-readable goes here. */ readonly write: (text: string) => void; /** Writes to the data stream, which `--json` keeps clean. */ readonly writeOut: (text: string) => void; /** Reports a failed run. */ readonly exit: (code: number) => void; /** Where the command was run, for rendering paths as they were typed. */ readonly cwd: string; /** * Path semantics for this host. Windows-aware on Node, posix in a browser. * * Here rather than taken from `Path` separately so the formatting helpers * in `summary.ts` can stay ordinary functions. They are called from inside * string-building loops, and making them effectful to fetch a path * implementation would put a `yield*` in the middle of a template literal. */ readonly path: Path.Path; }; } declare const Tty_base: Context.ServiceClass; /** Service tag for the host. */ declare class Tty extends Tty_base {} /** * The one reader of `process` that a service cannot be put in front of. * * Effect's prompts choose between unicode and ASCII glyphs by reading * `process.platform` themselves, in an `Effect.sync`, with no `typeof` guard — * and there is nothing to intercept it with: `Prompt.Environment` is * `FileSystem | Path | Terminal`, and the glyphs are not an option on the * prompt. So in a page the first question the CLI asks dies on a bare * `ReferenceError: process is not defined`, after the resolution it was asking * about has already been paid for. * * Every host layer calls this while it is being built, which is why the answer * is a field on the service rather than a constant here: only the layer knows * which host this is, and there is exactly one layer per environment. Node * finds the question already answered and this leaves it alone. A browser has * no `process` to leave alone, so it gets the smallest object that answers this * one question — nothing else about it is true, and nothing else should look * true either. * * A build-time `define` in the page's bundler would also silence the crash, and * was rejected: it puts the answer somewhere no reader of this package would * think to look, and it is per-bundle rather than per-host, so a second * embedder inherits the bug. */ declare const announcePlatform: (platform: string) => void; //#endregion export { Npmrc as a, LoadedNpmrc as i, announcePlatform as n, Transport as r, Tty as t }; //# sourceMappingURL=tty-DNwBIkPj.d.ts.map