/** * What `/profiles` is doing, for as long as the process is doing it. * * Two facts live here, and both outlive any one browser: which profile has an * operation running, and which profile is waiting on a restart to pick up a * change that has already landed. Neither is Harness state and neither is * persisted — the roster itself stays filesystem-authoritative and is re-read * every pass, exactly as before. This is dshline's own presentation state about * work dshline started. * * It is module-scoped, which is to say process-scoped, because the alternative * was demonstrably wrong. Holding it inside `openProfiles` meant: * * ``` * open the browser, start an install, close the browser, open it again * → the new view sees the lock (so it correctly refuses a second run) * → but shows no running row, because its own copy of that state is empty * → and when the install lands, the CLOSED view is the one that hears, * so nothing refreshes the roster or records the restart the new view * should be showing * ``` * * A view is a window onto this; it is not where it lives. Subscribers exist for * the same reason: the view that started an operation may be gone by the time it * finishes, so completion has to reach whichever views are open then rather than * the one that happened to ask. * * The lock lives here too. It is the same fact from the other side — "this * profile has an operation running" — and splitting the authority to refuse from * the state that shows why would be two answers to one question. * @module dshline/profiles/runtime */ /** One operation the process is running, as a view would draw it. */ export interface RunningOperation { /** The profile being written to. */ readonly profile: string; /** What is being done to it, already safe to display. */ readonly what: string; } /** Everything the views need to know about work in flight. */ export interface ProfilesActivityView { /** Operations running right now. */ readonly running: readonly RunningOperation[]; /** Profiles whose landed change this Host picks up only after a restart. */ readonly restartQueued: readonly string[]; } /** * Watch for changes to what is running or owed. * @param listener - called after any change; never called with arguments. * @returns the unsubscribe function. */ export declare function watchProfilesActivity(listener: () => void): () => void; /** * What is running and what is owed, right now. * @returns an immutable snapshot. */ export declare function profilesActivity(): ProfilesActivityView; /** Whether a profile already has an operation running. */ export declare function operationInFlight(profile: string): boolean; /** * Record that a landed change needs a restart before this Host sees it. * @param profile - the profile whose change is waiting. */ export declare function queueRestart(profile: string): void; /** * Run `task` as the one operation on `profile`, or refuse. * * Holds the profile for the whole task and announces both edges, so a view * opened midway sees the running row and a view open at the end hears the * completion — whether or not it is the view that started it. * @param profile - the profile the operation writes to. * @param what - what to show while it runs; must already be safe to display. * @param task - the work to run. * @returns what the task answered, or undefined when the profile was busy. */ export declare function runExclusively(profile: string, what: string, task: () => Promise): Promise; /** * Forget everything, for a test that must not leak state into the next one. * * Exported for tests only; nothing in the running frontend resets this, because * the process is the lifetime. */ export declare function resetProfilesRuntime(): void; //# sourceMappingURL=runtime.d.ts.map