/** * The `/profiles` browser: Harness's profiles, and what each one composes. * * Two sections, unlike `/plugins`' single flat list, because there genuinely * are two things here and one contains the other: the profile roster, and the * bundle layers of whichever profile is selected. `connect/overlay.ts` draws * two sections for the same reason. * * Selection walks both as one sequence, so `↑`/`↓` never needs a mode and a * bundle operation always has an unambiguous target: every bundle row carries * the profile it belongs to. * * Every profile is expanded rather than one at a time. See * {@link selectableRows} for why — inspecting one profile makes the sequence * depend on the index that indexes it, and re-pointing it as the cursor moves * strands the rows the reader is walking toward. * * Every keystroke here reports an intent to its owner (`index.ts`); nothing in * this module runs a command or reads a directory. * @module dshline/profiles/overlay */ import type { TuiOverlay } from '../slots.ts'; import type { BundleRow, PlainDependencyRow, ProfileRow } from './harness.ts'; import type { ProfilesState } from './catalog.ts'; import type { ProfilesActivityView } from './runtime.ts'; /** One selectable line: a profile, one of its bundle layers, or a plain dependency. */ export type ProfilesSelection = /** A profile in the roster. */ { readonly kind: 'profile'; readonly profile: ProfileRow; } /** One bundle layer of the inspected profile. */ | { readonly kind: 'bundle'; readonly profile: ProfileRow; readonly bundle: BundleRow; } /** * One dependency of the profile that is NOT a layer. Selectable so `r` can * remove it: an inert install is the commonest thing a reader wants gone. */ | { readonly kind: 'plain'; readonly profile: ProfileRow; readonly dependency: PlainDependencyRow; }; /** What the browser needs from its owner. */ export interface ProfilesOverlaySpec { /** The current reading of the profile roster. */ readonly state: () => ProfilesState; /** * What is running and what is waiting on a restart. * * Read every render rather than pushed as a notice: a pnpm install takes * minutes and a notice expires in seconds, so a reader would watch the only * evidence of their own install disappear. */ readonly activity: () => ProfilesActivityView; /** Re-read the roster. */ readonly refresh: () => void; /** Install a new bundle into the selected profile. */ readonly addBundle: (profile: ProfileRow) => void; /** Update one bundle, or every bundle when no row names one. */ readonly updateBundle: (profile: ProfileRow, bundle: BundleRow | undefined) => void; /** Remove one bundle from the selected profile. */ readonly removeBundle: (profile: ProfileRow, bundle: BundleRow) => void; /** Remove one non-layer dependency from the selected profile. */ readonly removeDependency: (profile: ProfileRow, dependency: PlainDependencyRow) => void; /** Create (or initialize) a profile. */ readonly createProfile: () => void; /** Explain how the selected profile is booted. */ readonly explainBoot: (profile: ProfileRow) => void; /** Current time, injected so notice expiry is assertable. */ readonly now: () => number; /** Remove this overlay from the live region. */ readonly close: () => void; /** Redraw after a move or a landed read. */ readonly invalidate: () => void; } /** The Profiles overlay, plus what its owner pushes back into it. */ export interface ProfilesOverlay extends TuiOverlay { /** * Show a result over the list. * @param text - the sentence to show. * @param failed - whether it reports a refusal. */ report(text: string, failed: boolean): void; /** * Whether the reader has already closed the browser. * @returns true once this overlay has closed. */ closed(): boolean; } /** * Create the `/profiles` browser overlay. * @param spec - the reading, the action intents, and overlay controls. * @returns a temporary live-region overlay that never writes the transcript. */ export declare function createProfilesOverlay(spec: ProfilesOverlaySpec): ProfilesOverlay; /** * The selectable sequence: every profile, each followed by its own bundle * layers. * * Every profile is expanded, and that is a deliberate simplification over * inspecting one at a time. Both alternatives were built and both are worse. * Expanding only the profile the cursor is on makes the sequence depend on the * selection index that indexes it — circular — and re-pointing the expansion * as the cursor moves creates a dead end: with the bundles drawn after the * whole roster, reaching the first profile's bundles means moving through the * second profile's row, which re-points the section away from the bundles the * reader was walking toward. A roster is a handful of directories under one * home, so showing all of it costs a few rows and owes the reader no mode. * @param state - the current reading. * @param query - the typed filter. * @returns the selectable rows, in draw order. */ export declare function selectableRows(state: ProfilesState, query: string): readonly ProfilesSelection[]; //# sourceMappingURL=overlay.d.ts.map