Files
Febe/src/Febe.App/IFebeBrowser.cs
T

54 lines
2.4 KiB
C#

using Febe.Browser.Cdp;
using Febe.Browser.Hosting;
using Febe.Core.Abstractions;
namespace Febe.App;
/// <summary>
/// The browser of Febe as the shared composition sees it (spec §5, §6.1): Chromium on Xvfb in Docker, WebView2 in the
/// window «Browser di Febe» on Windows, or Edge started as a process (the last fallback of S2). It owns the
/// <see cref="IBrowserHost"/>, starts it with retries, and does the few things the composition needs around it: rest
/// page, «Alberto is driving», showing and hiding the window, «Scollega».
/// </summary>
public interface IFebeBrowser : IAsyncDisposable
{
/// <summary>The page session: stable for the whole life of the composition (a restart keeps the same object).</summary>
ICdpSession Cdp { get; }
/// <summary>Leases taken while Alberto uses the browser (connection page, remote view, the window in front).</summary>
UserDrivingGate UserDriving { get; }
/// <summary>True while at least one lease is open: the engine does not act.</summary>
bool UserIsDriving { get; }
/// <summary>True when the browser runs and commands can be sent.</summary>
bool IsAvailable { get; }
/// <summary>Why the last start failed, in Italian; null when running.</summary>
string? LastError { get; }
/// <summary>Dati/browser: holds the Instagram session.</summary>
string ProfileDirectory { get; }
/// <summary>Width of the page, always the same (spec §6.1).</summary>
int WindowWidth { get; }
/// <summary>Height of the page, always the same (spec §6.1).</summary>
int WindowHeight { get; }
/// <summary>Starts the browser, retrying with a growing wait until it works or <paramref name="ct"/> is cancelled.</summary>
Task RunAsync(CancellationToken ct);
/// <summary>Puts the browser at rest on the blank page (spec §6.1).</summary>
Task<NavigationResult> RestAsync(CancellationToken ct);
/// <summary>Windows: brings the browser window to the front. Docker: nothing (the remote view shows it).</summary>
Task ShowToUserAsync(CancellationToken ct);
/// <summary>Windows: puts the window out of view, still open and painting (S2). Docker: nothing.</summary>
Task HideFromUserAsync(CancellationToken ct);
/// <summary>«Scollega» (spec §4.1): closes the browser, deletes the profile folder and starts it again empty.</summary>
Task RestartWithEmptyProfileAsync(CancellationToken ct);
}