Unione di funzione/decoder-hevc in funzione/senza-terzi (catena della 0.3.0)
Porta in senza-terzi tutta la catena: documenti ed esportazione, S4b, codec delle immagini, H.264 e HEVC. Conflitti risolti tenendo le due parti: CI e Dockerfile di senza-terzi (solo comandi, Febe processo 1, un carattere) senza ffmpeg, che il ramo dei video ha tolto; categoria «da fare» di riepilogo-prove.sh tenuta; decisioni.md con tutte le righe, prima quelle della catena e poi quelle di C6; CLAUDE.md con le righe della CI di C6 senza ffmpeg; prove della pipeline con tutti e due i controlli. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
e4dbc5ad68
919 files changed
+65484
-1299
No files matched your search
@@ -1,4 +1,6 @@
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Collection.Requests;
|
||||
using Febe.Core.Storage;
|
||||
using Febe.Web.Connection;
|
||||
using Febe.Web.Engine;
|
||||
using Febe.Web.Native;
|
||||
@@ -36,7 +38,9 @@ public static class ConnectionApi
|
||||
});
|
||||
|
||||
// «Annulla», or a page left without either button ({ pageLeft: true }). On Windows the browser is a window of its
|
||||
// own: leaving a page of Febe leaves it as it is, on screen until Alberto closes it (issue #52).
|
||||
// own: leaving a page of Febe leaves it as it is, on screen until Alberto closes it (issue #52). In Docker leaving
|
||||
// the page lets go of the browser like closing that window: the session is copied, not cancelled (answer of
|
||||
// 25 November 2026). Only the button «Annulla» cancels without copying.
|
||||
endpoints.MapPost("/api/connection/cancel", async (HttpContext context, IConnectionService connection, IBrowserWindow window, CancellationToken ct) =>
|
||||
{
|
||||
var body = await ApiHttp.OptionalBodyAsync(context, FebeJsonContext.Default.CancelDrivingRequest, new CancelDrivingRequest(false)).ConfigureAwait(false);
|
||||
@@ -44,6 +48,10 @@ public static class ConnectionApi
|
||||
{
|
||||
await connection.ReleaseAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
else if (body.PageLeft)
|
||||
{
|
||||
await connection.LeavePageAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await connection.CancelAsync(ct).ConfigureAwait(false);
|
||||
@@ -57,19 +65,54 @@ public static class ConnectionApi
|
||||
await connection.DisconnectAsync(ct).ConfigureAwait(false);
|
||||
return Results.NoContent();
|
||||
});
|
||||
|
||||
// What an incomplete copy of the session does (issue #36, S4b, answer 9): read at every copy, no restart.
|
||||
endpoints.MapGet("/api/connection/settings", async (IFebeStorage storage, CancellationToken ct) =>
|
||||
ApiHttp.Json(await SettingsAsync(storage, ct).ConfigureAwait(false), FebeJsonContext.Default.ConnectionSettingsDto));
|
||||
|
||||
endpoints.MapPut("/api/connection/settings", async (HttpContext context, IFebeStorage storage, CancellationToken ct) =>
|
||||
{
|
||||
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.ConnectionSettingsDto).ConfigureAwait(false);
|
||||
var choice = SessionCopySettings.Parse(body.IncompleteCopy)
|
||||
?? throw new BadRequestException($"Scelta sconosciuta per la copia incompleta: ammesse «{SessionCopySettings.ReplaceText}» e «{SessionCopySettings.KeepCompleteText}».");
|
||||
await new SessionCopySettings(choice).SaveAsync(storage.Settings, ct).ConfigureAwait(false);
|
||||
return ApiHttp.Json(await SettingsAsync(storage, ct).ConfigureAwait(false), FebeJsonContext.Default.ConnectionSettingsDto);
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<ConnectionSettingsDto> SettingsAsync(IFebeStorage storage, CancellationToken ct)
|
||||
{
|
||||
var settings = await SessionCopySettings.LoadAsync(storage.Settings, ct).ConfigureAwait(false);
|
||||
return new ConnectionSettingsDto(SessionCopySettings.ToText(settings.IncompleteCopy));
|
||||
}
|
||||
|
||||
public static ConnectionStatusDto ToDto(ConnectionStatus status)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(status);
|
||||
return new ConnectionStatusDto(State(status.State), status.Username, status.DisplayName, status.UserIsDriving, status.CurrentUrl);
|
||||
return new ConnectionStatusDto(State(status.State), status.Username, status.DisplayName, status.UserIsDriving, status.CurrentUrl, ToDto(status.SavedSession));
|
||||
}
|
||||
|
||||
/// <summary>The saved session in counts and names; null without one.</summary>
|
||||
public static SavedSessionDto? ToDto(SavedSessionStatus? saved) => saved is null
|
||||
? null
|
||||
: new SavedSessionDto(
|
||||
saved.State,
|
||||
saved.CopiedAt?.ToUnixTimeMilliseconds(),
|
||||
saved.Cookies,
|
||||
saved.ValuesPresent,
|
||||
saved.ValuesExpected,
|
||||
saved.MissingValues,
|
||||
saved.DocIdsPresent,
|
||||
saved.DocIdsExpected,
|
||||
saved.MissingDocIds,
|
||||
saved.NeededMissing);
|
||||
|
||||
public static string State(ConnectionState state) => state switch
|
||||
{
|
||||
ConnectionState.NotConnected => "notConnected",
|
||||
ConnectionState.Connected => "connected",
|
||||
ConnectionState.VerificationRequired => "verificationRequired",
|
||||
ConnectionState.SessionCopyMissing => "copyMissing",
|
||||
_ => "browserUnavailable",
|
||||
};
|
||||
}
|
||||
@@ -77,7 +77,8 @@ public sealed record MediaDto(
|
||||
string? Folder,
|
||||
string? Thumb,
|
||||
bool Available,
|
||||
string State);
|
||||
string State,
|
||||
bool Damaged = false);
|
||||
|
||||
/// <summary>Everything the viewer shows of an entry.</summary>
|
||||
public sealed record EntryDto(
|
||||
|
||||
@@ -84,8 +84,9 @@ public static class EngineApi
|
||||
/// <summary>
|
||||
/// The engine as the interface needs it. The link comes from the session cookie, never from whether «Tu» is known:
|
||||
/// the name of the connected account may come much later (H10), and meanwhile the sidebar says «Collegato» with
|
||||
/// «Nome non ancora noto». The engine looks at the cookie on every turn and its mode says so; when it does not run
|
||||
/// (or there is none in this process) the connection is asked.
|
||||
/// «Nome non ancora noto». The engine looks at the cookie on every turn and its mode says so, and whether the copy for
|
||||
/// the requests is missing too (<see cref="EngineSnapshot.SessionCopyMissing"/>, no round trip to the browser at every
|
||||
/// event); only when it does not run (or there is none in this process) the connection is asked.
|
||||
/// </summary>
|
||||
public static async Task<EngineDto> SnapshotAsync(IEngineMonitor monitor, IFebeStorage storage, BrowserUseTracker tracker, IClock clock, IConnectionService connection, CancellationToken ct)
|
||||
{
|
||||
@@ -98,10 +99,16 @@ public static class EngineApi
|
||||
var mine = await storage.Accounts.GetMineAsync(ct).ConfigureAwait(false);
|
||||
var state = snapshot.Mode switch
|
||||
{
|
||||
EngineMode.NotConnected => "notConnected",
|
||||
// The cookie is there but the copy for the requests is missing (S4b): «Serve «Ho finito»», with the account.
|
||||
EngineMode.NotConnected => snapshot.SessionCopyMissing ? "copyMissing" : "notConnected",
|
||||
EngineMode.StoppedForVerification => "verification",
|
||||
EngineMode.Disconnected => "disconnected",
|
||||
EngineMode.Off => (await connection.GetStatusAsync(ct).ConfigureAwait(false)).State == ConnectionState.Connected ? "connected" : "notConnected",
|
||||
EngineMode.Off => (await connection.GetStatusAsync(ct).ConfigureAwait(false)).State switch
|
||||
{
|
||||
ConnectionState.Connected => "connected",
|
||||
ConnectionState.SessionCopyMissing => "copyMissing",
|
||||
_ => "notConnected",
|
||||
},
|
||||
_ => "connected",
|
||||
};
|
||||
var link = state == "notConnected"
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Febe.Web.Api;
|
||||
[JsonSerializable(typeof(LoginDto))]
|
||||
[JsonSerializable(typeof(Library.LibraryChange))]
|
||||
[JsonSerializable(typeof(ConnectionStatusDto))]
|
||||
[JsonSerializable(typeof(ConnectionSettingsDto))]
|
||||
[JsonSerializable(typeof(BeginDrivingRequest))]
|
||||
[JsonSerializable(typeof(CancelDrivingRequest))]
|
||||
[JsonSerializable(typeof(FinishDto))]
|
||||
|
||||
@@ -237,6 +237,7 @@ public static class LibraryApi
|
||||
folder = string.IsNullOrEmpty(directory) ? accountFolder : Path.Combine(accountFolder, directory);
|
||||
}
|
||||
|
||||
var path = files.Resolve(account, m);
|
||||
return new MediaDto(
|
||||
m.Id,
|
||||
m.Position,
|
||||
@@ -248,8 +249,9 @@ public static class LibraryApi
|
||||
relative is null ? null : Path.GetFileName(LibraryLayout.ToPlatform(relative)),
|
||||
folder,
|
||||
m.HasThumbnail && m.Sha256 is not null ? m.Sha256 : m.Kind == MediaKind.Video ? "video" : null,
|
||||
files.Resolve(account, m) is not null,
|
||||
ApiMapping.State(m.State));
|
||||
path is not null,
|
||||
ApiMapping.State(m.State),
|
||||
IsDamaged(m, path));
|
||||
}).ToList();
|
||||
|
||||
return new EntryDto(
|
||||
@@ -272,6 +274,14 @@ public static class LibraryApi
|
||||
media);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// «File danneggiato o incompleto» (spec §4.6, §8.4): a photo on disk with no thumbnail whose bytes are damaged or
|
||||
/// truncated. A photo with a thumbnail was decoded when it was stored, so only those without one are looked at,
|
||||
/// one file each time the viewer opens it; the file is only read, never touched (rule 12).
|
||||
/// </summary>
|
||||
private static bool IsDamaged(Media media, string? path) =>
|
||||
media.Kind == MediaKind.Photo && !media.HasThumbnail && path is not null && DamagedImage.IsFileDamaged(path);
|
||||
|
||||
private static async Task<(Account Account, Media Media)> MediaAsync(IFebeStorage storage, long mediaId, CancellationToken ct)
|
||||
{
|
||||
var media = await storage.Media.GetAsync(mediaId, ct).ConfigureAwait(false) ?? throw new NotFoundException("File non trovato.");
|
||||
|
||||
@@ -5,8 +5,33 @@ namespace Febe.Web.Api;
|
||||
|
||||
// ---------------------------------------------------------------- connection (PROTOCOLLO.md)
|
||||
|
||||
/// <summary><c>GET /api/connection</c>. <see cref="State"/>: notConnected, connected, verificationRequired, browserUnavailable.</summary>
|
||||
public sealed record ConnectionStatusDto(string State, string? Username, string? DisplayName, bool UserIsDriving, string? CurrentUrl);
|
||||
/// <summary>
|
||||
/// <c>GET /api/connection</c>. <see cref="State"/>: notConnected, connected, copyMissing, verificationRequired,
|
||||
/// browserUnavailable. <see cref="SavedSession"/> only with the raccolta «richieste».
|
||||
/// </summary>
|
||||
public sealed record ConnectionStatusDto(string State, string? Username, string? DisplayName, bool UserIsDriving, string? CurrentUrl, SavedSessionDto? SavedSession = null);
|
||||
|
||||
/// <summary>
|
||||
/// The saved session in counts and names (issue #36, S4b): <see cref="State"/> present, none or unreadable;
|
||||
/// <see cref="CopiedAt"/> Unix milliseconds. Never a value.
|
||||
/// </summary>
|
||||
public sealed record SavedSessionDto(
|
||||
string State,
|
||||
long? CopiedAt,
|
||||
int Cookies,
|
||||
int ValuesPresent,
|
||||
int ValuesExpected,
|
||||
IReadOnlyList<string> MissingValues,
|
||||
int DocIdsPresent,
|
||||
int DocIdsExpected,
|
||||
IReadOnlyList<string> MissingDocIds,
|
||||
int NeededMissing);
|
||||
|
||||
/// <summary>
|
||||
/// <c>GET/PUT /api/connection/settings</c>: what an incomplete copy of the session does, <c>sostituisci</c> (the
|
||||
/// default) or <c>tieni-completa</c>.
|
||||
/// </summary>
|
||||
public sealed record ConnectionSettingsDto(string IncompleteCopy);
|
||||
|
||||
/// <summary><c>POST /api/connection/begin</c>.</summary>
|
||||
public sealed record BeginDrivingRequest(bool OpenLogin);
|
||||
|
||||
@@ -14,6 +14,48 @@ public enum ConnectionState
|
||||
|
||||
/// <summary>The browser is not available (starting, crashed, demo without browser).</summary>
|
||||
BrowserUnavailable,
|
||||
|
||||
/// <summary>
|
||||
/// The session cookie is in the browser, but the raccolta «richieste» has no readable saved session to send it with
|
||||
/// (issue #36, S4b): «Serve «Ho finito»». The engine waits until a copy is made.
|
||||
/// </summary>
|
||||
SessionCopyMissing,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The saved session of the raccolta «richieste» as the Collegamento page shows it (issue #36, S4b): counts and names
|
||||
/// only, never a value (rule 10).
|
||||
/// </summary>
|
||||
/// <param name="State"><see cref="Present"/>, <see cref="None"/> or <see cref="Unreadable"/>.</param>
|
||||
/// <param name="CopiedAt">When the copy was made; null when there is none or it is not known.</param>
|
||||
/// <param name="Cookies">How many cookies it holds.</param>
|
||||
/// <param name="ValuesPresent">Values of the page it holds.</param>
|
||||
/// <param name="ValuesExpected">Values of the page the copy reads.</param>
|
||||
/// <param name="MissingValues">Names of the values it lacks.</param>
|
||||
/// <param name="DocIdsPresent">doc_id it holds.</param>
|
||||
/// <param name="DocIdsExpected">doc_id the copy reads.</param>
|
||||
/// <param name="MissingDocIds">Operations whose doc_id it lacks.</param>
|
||||
/// <param name="NeededMissing">How many of those a configured operation sends (its requests do not leave).</param>
|
||||
public sealed record SavedSessionStatus(
|
||||
string State,
|
||||
DateTimeOffset? CopiedAt,
|
||||
int Cookies,
|
||||
int ValuesPresent,
|
||||
int ValuesExpected,
|
||||
IReadOnlyList<string> MissingValues,
|
||||
int DocIdsPresent,
|
||||
int DocIdsExpected,
|
||||
IReadOnlyList<string> MissingDocIds,
|
||||
int NeededMissing)
|
||||
{
|
||||
/// <summary>A readable saved session.</summary>
|
||||
public const string Present = "present";
|
||||
|
||||
/// <summary>No saved session.</summary>
|
||||
public const string None = "none";
|
||||
|
||||
/// <summary>A file that cannot be read: counts as none.</summary>
|
||||
public const string Unreadable = "unreadable";
|
||||
}
|
||||
|
||||
/// <summary>What the interface knows about the link to Instagram.</summary>
|
||||
@@ -22,12 +64,14 @@ public enum ConnectionState
|
||||
/// <param name="DisplayName">Display name, when known.</param>
|
||||
/// <param name="UserIsDriving">True while Alberto is using the browser (login page, remote view, browser window): the engine is still.</param>
|
||||
/// <param name="CurrentUrl">Address shown in the remote view's address bar, without query string.</param>
|
||||
/// <param name="SavedSession">The saved session (raccolta «richieste»); null when this start keeps none.</param>
|
||||
public sealed record ConnectionStatus(
|
||||
ConnectionState State,
|
||||
string? Username,
|
||||
string? DisplayName,
|
||||
bool UserIsDriving,
|
||||
string? CurrentUrl);
|
||||
string? CurrentUrl,
|
||||
SavedSessionStatus? SavedSession = null);
|
||||
|
||||
/// <summary>Result of «Ho finito» on the Collegamento page.</summary>
|
||||
/// <param name="Connected">True when the session cookie now exists.</param>
|
||||
@@ -70,6 +114,15 @@ public interface IConnectionService
|
||||
/// </summary>
|
||||
Task ReleaseAsync(CancellationToken ct);
|
||||
|
||||
/// <summary>
|
||||
/// The Febe page that took the browser was left (another page, a reload, the tab closed) while the browser is the
|
||||
/// remote view (Docker, answer of Alberto of 25 November 2026, spec §6.0 «Quando si copia»): like closing the window
|
||||
/// «Browser di Febe» on Windows, not like «Annulla». If within a moment no view opens again and no «Accedi» / «Usa il
|
||||
/// browser» comes (a reload is not leaving), the session is copied while the page is still his, and then the page goes
|
||||
/// back to the engine. By default, for a service without a saved session to copy, it is «Annulla».
|
||||
/// </summary>
|
||||
Task LeavePageAsync(CancellationToken ct) => CancelAsync(ct);
|
||||
|
||||
/// <summary>«Scollega» (after confirmation in the UI): stops the engine and deletes the browser profile.</summary>
|
||||
Task DisconnectAsync(CancellationToken ct);
|
||||
}
|
||||
@@ -7,11 +7,12 @@ Lo usano due parti scritte in parallelo: non cambiarlo senza aggiornare entrambe
|
||||
|
||||
| Endpoint | Corpo e risposta |
|
||||
|---|---|
|
||||
| `GET /api/connection` | `{ state: "notConnected"\|"connected"\|"verificationRequired"\|"browserUnavailable", username, displayName, userIsDriving, currentUrl }` |
|
||||
| `GET /api/connection` | `{ state: "notConnected"\|"connected"\|"copyMissing"\|"verificationRequired"\|"browserUnavailable", username, displayName, userIsDriving, currentUrl, savedSession }` |
|
||||
| `POST /api/connection/begin` | `{ openLogin: bool }` → 204. Alberto usa il browser; con `openLogin` il browser carica la pagina di accesso vera; senza, se il browser è a riposo (`about:blank`) apre la pagina iniziale (sotto) |
|
||||
| `POST /api/connection/finish` | → `{ connected: bool, message }` («Ho finito») |
|
||||
| `POST /api/connection/cancel` | corpo facoltativo `{ pageLeft: bool }` → 204 («Annulla»; con `pageLeft` la pagina è stata lasciata, sotto) |
|
||||
| `POST /api/connection/disconnect` | → 204 («Scollega», dopo la conferma nell'interfaccia) |
|
||||
| `GET /api/connection/settings`, `PUT /api/connection/settings` | `{ incompleteCopy: "sostituisci"\|"tieni-completa" }`: che cosa fa una copia della sessione incompleta (raccolta «richieste»); un altro valore → 400 |
|
||||
| `POST /api/browser/show` | corpo facoltativo `{ openLogin: bool }` → `{ message }`. Solo Windows: porta in primo piano la finestra «Browser di Febe»; come `begin` apre la pagina di accesso (`openLogin`) o, se era a riposo, la pagina iniziale |
|
||||
|
||||
**Pagina iniziale** (issue #52): la home del sito se Febe è collegato e non scollegato da Instagram, altrimenti la
|
||||
@@ -27,9 +28,23 @@ di una disconnessione apre il browser con `openLogin: true` (in Docker la pagina
|
||||
|
||||
In modalità dimostrativa la scena `scollegato` dà `notConnected`, la scena `fermo` dà `verificationRequired`.
|
||||
|
||||
**Raccolta «richieste»** (issue #36, S4b): `savedSession` è `null` senza sessione salvata in questo avvio («pagine», o
|
||||
nessuna operazione configurata); altrimenti `{ state: "present"|"none"|"unreadable", copiedAt (ms Unix o null), cookies,
|
||||
valuesPresent, valuesExpected, missingValues: [nomi], docIdsPresent, docIdsExpected, missingDocIds: [operazioni],
|
||||
neededMissing }`: solo conteggi e nomi, mai valori. Con il cookie di sessione nel browser ma senza una sessione salvata
|
||||
leggibile lo stato è `copyMissing` («Serve «Ho finito»»): il motore aspetta, e `/api/engine` dice `copyMissing` nel
|
||||
collegamento. La sessione si copia a «Ho finito», alla chiusura della finestra del browser su Windows, lasciando la
|
||||
pagina del browser in Docker (sotto) e quando il permesso di guida finisce da solo, sempre prima che la pagina torni al
|
||||
motore. «Annulla» non copia mai.
|
||||
|
||||
L'interfaccia manda `cancel` con `{ "pageLeft": true }` anche quando Alberto lascia la pagina Browser, o la pagina
|
||||
Collegamento mentre accede, senza «Ho finito» né «Annulla»: un'altra pagina, la scheda chiusa o ricaricata (`fetch`
|
||||
con `keepalive`, che porta l'`Origin` dell'interfaccia). In Docker vale come «Annulla» (il browser torna a riposo).
|
||||
con `keepalive`, che porta l'`Origin` dell'interfaccia). In Docker non è «Annulla» (`IConnectionService.LeavePageAsync`,
|
||||
risposta di Alberto del 25 novembre 2026): è come chiudere la finestra del browser su Windows. Febe lo nota e aspetta
|
||||
5 secondi; anche la vista remota chiusa dalla sua pagina (scheda chiusa, collegamento perso, non sostituita da un'altra
|
||||
scheda) fa ricominciare l'attesa. Se in quel tempo non si apre un'altra vista e non arriva un `begin` (una pagina
|
||||
ricaricata fa tutti e due), copia la sessione come alla chiusura della finestra (solo da una pagina del sito che non sia
|
||||
di accesso o di verifica), poi il permesso finisce e il motore rimette il browser a riposo.
|
||||
Su Windows, dove il browser è una finestra a parte, finisce solo il permesso tenuto dalla pagina: la finestra resta
|
||||
com'è, sullo schermo e con la sua pagina, finché Alberto non la chiude (e finché è sullo schermo il motore resta
|
||||
fermo). Dopo un «Ho finito» riuscito la pagina chiude la vista remota e non manda un nuovo `begin`.
|
||||
|
||||
+89
-105
@@ -1,4 +1,6 @@
|
||||
using SkiaSharp;
|
||||
using System.Numerics;
|
||||
using Febe.Core.Codecs.Images;
|
||||
using Febe.Core.Drawing;
|
||||
|
||||
namespace Febe.Web.Demo;
|
||||
|
||||
@@ -35,8 +37,8 @@ public static class DemoImages
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(width, 16);
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(height, 16);
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul));
|
||||
using (var canvas = new SKCanvas(bitmap))
|
||||
var image = new RgbaImage(width, height);
|
||||
using (var canvas = new Canvas(image))
|
||||
{
|
||||
var painter = new Painter(canvas, width, height, new Random(seed * 7919 + (int)subject));
|
||||
switch (subject)
|
||||
@@ -59,64 +61,54 @@ public static class DemoImages
|
||||
}
|
||||
}
|
||||
|
||||
using var image = SKImage.FromBitmap(bitmap);
|
||||
using var data = image.Encode(SKEncodedImageFormat.Jpeg, quality);
|
||||
return data.ToArray();
|
||||
return JpegEncoder.Encode(image, new JpegEncoderOptions { Quality = quality });
|
||||
}
|
||||
|
||||
private sealed class Painter(SKCanvas canvas, float w, float h, Random random)
|
||||
/// <summary>A rectangle by its edges.</summary>
|
||||
private readonly record struct Box(float Left, float Top, float Right, float Bottom);
|
||||
|
||||
private sealed class Painter(Canvas canvas, float w, float h, Random random)
|
||||
{
|
||||
private float R(float min, float max) => min + ((float)random.NextDouble() * (max - min));
|
||||
|
||||
private T Pick<T>(params T[] items) => items[random.Next(items.Length)];
|
||||
|
||||
private static SKColor C(uint rgb) => new((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb);
|
||||
private static Color C(uint rgb) => Color.FromRgb(rgb);
|
||||
|
||||
private static SKColor Mix(SKColor a, SKColor b, float t) => new(
|
||||
(byte)(a.Red + ((b.Red - a.Red) * t)),
|
||||
(byte)(a.Green + ((b.Green - a.Green) * t)),
|
||||
(byte)(a.Blue + ((b.Blue - a.Blue) * t)));
|
||||
private static Color Mix(Color a, Color b, float t) => a.Mix(b, t).WithAlpha(255);
|
||||
|
||||
private void Gradient(SKRect rect, SKColor top, SKColor bottom)
|
||||
private void Gradient(Box rect, Color top, Color bottom) =>
|
||||
canvas.FillRect(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, new LinearGradientBrush(new Vector2(0, rect.Top), new Vector2(0, rect.Bottom), [top, bottom]));
|
||||
|
||||
private void Fill(PathBuilder path, Color color) => canvas.Fill(path, color);
|
||||
|
||||
private void Circle(float x, float y, float r, Color color) => canvas.FillCircle(x, y, r, color);
|
||||
|
||||
private void Oval(float cx, float cy, float rx, float ry, Color color, float rotate = 0)
|
||||
{
|
||||
using var paint = new SKPaint { IsAntialias = true };
|
||||
paint.Shader = SKShader.CreateLinearGradient(new SKPoint(0, rect.Top), new SKPoint(0, rect.Bottom), [top, bottom], null, SKShaderTileMode.Clamp);
|
||||
canvas.DrawRect(rect, paint);
|
||||
}
|
||||
|
||||
private void Fill(SKPathBuilder builder, SKColor color)
|
||||
{
|
||||
using var path = builder.Detach();
|
||||
using var paint = new SKPaint { IsAntialias = true, Color = color, Style = SKPaintStyle.Fill };
|
||||
canvas.DrawPath(path, paint);
|
||||
}
|
||||
|
||||
private void Circle(float x, float y, float r, SKColor color)
|
||||
{
|
||||
using var paint = new SKPaint { IsAntialias = true, Color = color };
|
||||
canvas.DrawCircle(x, y, r, paint);
|
||||
}
|
||||
|
||||
private void Oval(float cx, float cy, float rx, float ry, SKColor color, float rotate = 0)
|
||||
{
|
||||
using var paint = new SKPaint { IsAntialias = true, Color = color };
|
||||
canvas.Save();
|
||||
canvas.Translate(cx, cy);
|
||||
canvas.RotateDegrees(rotate);
|
||||
canvas.DrawOval(new SKRect(-rx, -ry, rx, ry), paint);
|
||||
canvas.Rotate(rotate);
|
||||
canvas.FillEllipse(0, 0, rx, ry, color);
|
||||
canvas.Restore();
|
||||
}
|
||||
|
||||
private void Rect(float x, float y, float rw, float rh, SKColor color, float radius = 0)
|
||||
private void Rect(float x, float y, float rw, float rh, Color color, float radius = 0)
|
||||
{
|
||||
using var paint = new SKPaint { IsAntialias = true, Color = color };
|
||||
canvas.DrawRoundRect(new SKRect(x, y, x + rw, y + rh), radius, radius, paint);
|
||||
if (radius > 0)
|
||||
{
|
||||
canvas.FillRoundRect(x, y, rw, rh, radius, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas.FillRect(x, y, rw, rh, color);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A soft ridge across the picture at height <paramref name="baseY"/>, filled down to the bottom.</summary>
|
||||
private static SKPathBuilder Ridge(float w, float h, float baseY, float amplitude, int bumps, float phase)
|
||||
private static PathBuilder Ridge(float w, float h, float baseY, float amplitude, int bumps, float phase)
|
||||
{
|
||||
var path = new SKPathBuilder();
|
||||
var path = new PathBuilder();
|
||||
path.MoveTo(0, h);
|
||||
const int steps = 48;
|
||||
for (var i = 0; i <= steps; i++)
|
||||
@@ -138,23 +130,23 @@ public static class DemoImages
|
||||
var cx = R(-0.1f, 1.1f) * w;
|
||||
var cy = R(top, bottom) * h;
|
||||
var size = R(0.07f, 0.13f) * Math.Max(w, h);
|
||||
var color = new SKColor(255, 255, 255, (byte)R(200, 240));
|
||||
var color = new Color(255, 255, 255, (byte)R(200, 240));
|
||||
Oval(cx, cy, size, size * 0.32f, color);
|
||||
Oval(cx - (size * 0.35f), cy + (size * 0.05f), size * 0.55f, size * 0.25f, color);
|
||||
Oval(cx + (size * 0.25f), cy - (size * 0.12f), size * 0.5f, size * 0.3f, new SKColor(255, 255, 255, (byte)R(220, 250)));
|
||||
Oval(cx + (size * 0.25f), cy - (size * 0.12f), size * 0.5f, size * 0.3f, new Color(255, 255, 255, (byte)R(220, 250)));
|
||||
}
|
||||
}
|
||||
|
||||
private void Cypress(float x, float baseY, float size, SKColor color)
|
||||
private void Cypress(float x, float baseY, float size, Color color)
|
||||
{
|
||||
Oval(x, baseY - (size * 0.55f), size * 0.22f, size * 0.55f, color);
|
||||
Rect(x - (size * 0.03f), baseY - (size * 0.08f), size * 0.06f, size * 0.12f, Mix(color, SKColors.Black, 0.3f));
|
||||
Rect(x - (size * 0.03f), baseY - (size * 0.08f), size * 0.06f, size * 0.12f, Mix(color, Color.Black, 0.3f));
|
||||
}
|
||||
|
||||
public void Hills(bool road)
|
||||
{
|
||||
var sky = Pick(C(0x6FA8DC), C(0x7FB3E0), C(0x5E9BD6), C(0x8DBBE3));
|
||||
Gradient(new SKRect(0, 0, w, h), sky, Mix(sky, SKColors.White, 0.45f));
|
||||
Gradient(new Box(0, 0, w, h), sky, Mix(sky, Color.White, 0.45f));
|
||||
Clouds(0.08f, 0.35f, random.Next(2, 5));
|
||||
var greens = Pick(
|
||||
new[] { C(0x8DB867), C(0x6E9E4C), C(0x4F8A3E), C(0x3C7232) },
|
||||
@@ -164,7 +156,7 @@ public static class DemoImages
|
||||
for (var layer = 0; layer < 4; layer++)
|
||||
{
|
||||
var y = baseY + (layer * h * R(0.08f, 0.12f));
|
||||
using var ridge = Ridge(w, h, y, h * R(0.015f, 0.04f), random.Next(1, 4), R(0, 6));
|
||||
var ridge = Ridge(w, h, y, h * R(0.015f, 0.04f), random.Next(1, 4), R(0, 6));
|
||||
Fill(ridge, greens[layer]);
|
||||
if (!road && layer < 3)
|
||||
{
|
||||
@@ -178,7 +170,7 @@ public static class DemoImages
|
||||
if (road)
|
||||
{
|
||||
var horizon = baseY + (h * 0.03f);
|
||||
using var path = new SKPathBuilder();
|
||||
var path = new PathBuilder();
|
||||
path.MoveTo(w * 0.47f, horizon);
|
||||
path.LineTo(w * 0.53f, horizon);
|
||||
path.LineTo(w * 0.86f, h);
|
||||
@@ -208,13 +200,13 @@ public static class DemoImages
|
||||
public void Mountains()
|
||||
{
|
||||
var sky = Pick(C(0x5D8FC8), C(0x6E9BD0), C(0x7FA8D6));
|
||||
Gradient(new SKRect(0, 0, w, h), sky, Mix(sky, SKColors.White, 0.55f));
|
||||
Gradient(new Box(0, 0, w, h), sky, Mix(sky, Color.White, 0.55f));
|
||||
var ranges = new[] { C(0x8C9BB2), C(0x6F7F99), C(0x56647E) };
|
||||
for (var r = 0; r < 3; r++)
|
||||
{
|
||||
var baseY = h * (0.55f + (r * 0.08f));
|
||||
var peaks = random.Next(2, 4) + r;
|
||||
using var path = new SKPathBuilder();
|
||||
var path = new PathBuilder();
|
||||
path.MoveTo(0, h);
|
||||
path.LineTo(0, baseY);
|
||||
var snow = new List<(float X, float Y, float Half)>();
|
||||
@@ -239,7 +231,7 @@ public static class DemoImages
|
||||
{
|
||||
var depth = (baseY - py) * 0.32f;
|
||||
var ratio = depth / (baseY - py);
|
||||
using var cap = new SKPathBuilder();
|
||||
var cap = new PathBuilder();
|
||||
cap.MoveTo(px, py);
|
||||
cap.LineTo(px + (half * ratio), py + depth);
|
||||
cap.LineTo(px + (half * ratio * 0.3f), py + (depth * 0.8f));
|
||||
@@ -260,7 +252,7 @@ public static class DemoImages
|
||||
var x = R(0, 1) * w;
|
||||
var size = h * R(0.06f, 0.11f);
|
||||
var y = groundY + (h * R(-0.01f, 0.08f));
|
||||
using var tree = new SKPathBuilder();
|
||||
var tree = new PathBuilder();
|
||||
tree.MoveTo(x, y - size);
|
||||
tree.LineTo(x + (size * 0.28f), y);
|
||||
tree.LineTo(x - (size * 0.28f), y);
|
||||
@@ -273,16 +265,16 @@ public static class DemoImages
|
||||
{
|
||||
var top = Pick(C(0x3B2A5A), C(0x4A2F63), C(0x2E2350));
|
||||
var bottom = Pick(C(0xF0784C), C(0xE86A5A), C(0xF29A57));
|
||||
Gradient(new SKRect(0, 0, w, h * 0.75f), top, bottom);
|
||||
Gradient(new Box(0, 0, w, h * 0.75f), top, bottom);
|
||||
var sunX = w * R(0.35f, 0.65f);
|
||||
var sunY = h * R(0.5f, 0.6f);
|
||||
var r = Math.Min(w, h) * R(0.09f, 0.13f);
|
||||
Circle(sunX, sunY, r * 1.8f, new SKColor(255, 220, 170, 60));
|
||||
Circle(sunX, sunY, r * 1.8f, new Color(255, 220, 170, 60));
|
||||
Circle(sunX, sunY, r, C(0xFBE3B0));
|
||||
var hills = new[] { C(0x6B4A73), C(0x4E3A63), C(0x35294D) };
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
using var ridge = Ridge(w, h, h * (0.66f + (i * 0.09f)), h * R(0.02f, 0.05f), random.Next(1, 3), R(0, 6));
|
||||
var ridge = Ridge(w, h, h * (0.66f + (i * 0.09f)), h * R(0.02f, 0.05f), random.Next(1, 3), R(0, 6));
|
||||
Fill(ridge, hills[i]);
|
||||
}
|
||||
}
|
||||
@@ -291,32 +283,31 @@ public static class DemoImages
|
||||
{
|
||||
var sky = Pick(C(0x8CC4E8), C(0x7BB8E2), C(0x9CCDEB));
|
||||
var horizon = h * R(0.42f, 0.55f);
|
||||
Gradient(new SKRect(0, 0, w, horizon), Mix(sky, C(0x4F8FC8), 0.3f), Mix(sky, SKColors.White, 0.5f));
|
||||
Gradient(new Box(0, 0, w, horizon), Mix(sky, C(0x4F8FC8), 0.3f), Mix(sky, Color.White, 0.5f));
|
||||
Clouds(0.08f, 0.25f, random.Next(0, 3));
|
||||
var water = Pick(C(0x2AA3C1), C(0x1F8FB3), C(0x31A9BE));
|
||||
var sand = random.Next(3) == 0;
|
||||
Gradient(new SKRect(0, horizon, w, h), water, Mix(water, C(0x0B4A6B), 0.55f));
|
||||
using (var wave = new SKPaint { IsAntialias = true, Color = new SKColor(255, 255, 255, 110), StrokeWidth = Math.Max(2, h * 0.004f), StrokeCap = SKStrokeCap.Round })
|
||||
Gradient(new Box(0, horizon, w, h), water, Mix(water, C(0x0B4A6B), 0.55f));
|
||||
var foam = new Color(255, 255, 255, 110);
|
||||
var waveWidth = Math.Max(2, h * 0.004f);
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
var y = horizon + ((h - horizon) * R(0.1f, 0.9f));
|
||||
var x = R(0.05f, 0.85f) * w;
|
||||
canvas.DrawLine(x, y, x + (w * R(0.03f, 0.08f)), y, wave);
|
||||
}
|
||||
var y = horizon + ((h - horizon) * R(0.1f, 0.9f));
|
||||
var x = R(0.05f, 0.85f) * w;
|
||||
canvas.DrawLine(x, y, x + (w * R(0.03f, 0.08f)), y, waveWidth, foam, LineCap.Round);
|
||||
}
|
||||
|
||||
if (sand)
|
||||
{
|
||||
using var shore = Ridge(w, h, h * 0.9f, h * 0.02f, 2, R(0, 6));
|
||||
var shore = Ridge(w, h, h * 0.9f, h * 0.02f, 2, R(0, 6));
|
||||
Fill(shore, C(0xE9D8B4));
|
||||
}
|
||||
|
||||
var bx = w * R(0.3f, 0.65f);
|
||||
var by = horizon + ((h - horizon) * R(0.2f, 0.4f));
|
||||
var s = Math.Min(w, h) * R(0.06f, 0.09f);
|
||||
using (var sail = new SKPathBuilder())
|
||||
{
|
||||
var sail = new PathBuilder();
|
||||
sail.MoveTo(bx, by - s);
|
||||
sail.LineTo(bx + (s * 0.45f), by - (s * 0.1f));
|
||||
sail.LineTo(bx, by - (s * 0.1f));
|
||||
@@ -324,8 +315,8 @@ public static class DemoImages
|
||||
Fill(sail, C(0xF6F6F4));
|
||||
}
|
||||
|
||||
using (var sail2 = new SKPathBuilder())
|
||||
{
|
||||
var sail2 = new PathBuilder();
|
||||
sail2.MoveTo(bx - (s * 0.04f), by - (s * 0.85f));
|
||||
sail2.LineTo(bx - (s * 0.04f), by - (s * 0.12f));
|
||||
sail2.LineTo(bx - (s * 0.38f), by - (s * 0.12f));
|
||||
@@ -333,8 +324,8 @@ public static class DemoImages
|
||||
Fill(sail2, C(0xE0533F));
|
||||
}
|
||||
|
||||
using (var hull = new SKPathBuilder())
|
||||
{
|
||||
var hull = new PathBuilder();
|
||||
hull.MoveTo(bx - (s * 0.5f), by - (s * 0.05f));
|
||||
hull.LineTo(bx + (s * 0.55f), by - (s * 0.05f));
|
||||
hull.LineTo(bx + (s * 0.4f), by + (s * 0.1f));
|
||||
@@ -346,10 +337,10 @@ public static class DemoImages
|
||||
|
||||
public void City()
|
||||
{
|
||||
Gradient(new SKRect(0, 0, w, h), C(0x1E1B3A), Pick(C(0x3E2F5C), C(0x4A3566), C(0x2F2A52)));
|
||||
Gradient(new Box(0, 0, w, h), C(0x1E1B3A), Pick(C(0x3E2F5C), C(0x4A3566), C(0x2F2A52)));
|
||||
for (var i = 0; i < 70; i++)
|
||||
{
|
||||
Circle(R(0, 1) * w, R(0, 0.45f) * h, R(0.6f, 1.8f), new SKColor(255, 255, 255, (byte)R(60, 180)));
|
||||
Circle(R(0, 1) * w, R(0, 0.45f) * h, R(0.6f, 1.8f), new Color(255, 255, 255, (byte)R(60, 180)));
|
||||
}
|
||||
|
||||
for (var layer = 0; layer < 2; layer++)
|
||||
@@ -384,7 +375,7 @@ public static class DemoImages
|
||||
public void Leaves(bool flowers)
|
||||
{
|
||||
var dark = Pick(C(0x1F4D33), C(0x24533A), C(0x2B5C3C));
|
||||
Gradient(new SKRect(0, 0, w, h), Mix(dark, SKColors.Black, 0.1f), dark);
|
||||
Gradient(new Box(0, 0, w, h), Mix(dark, Color.Black, 0.1f), dark);
|
||||
var greens = new[] { C(0x3E8C4E), C(0x5AA45A), C(0x2F7A45), C(0x78B861), C(0x4C9A6A), C(0x8BC46A) };
|
||||
var size = Math.Max(w, h);
|
||||
for (var i = 0; i < 46; i++)
|
||||
@@ -395,11 +386,10 @@ public static class DemoImages
|
||||
var angle = R(0, 360);
|
||||
var color = greens[random.Next(greens.Length)];
|
||||
Oval(cx, cy, rx, rx * 0.42f, color, angle);
|
||||
using var vein = new SKPaint { IsAntialias = true, Color = Mix(color, SKColors.White, 0.25f), StrokeWidth = Math.Max(1.5f, size * 0.003f) };
|
||||
canvas.Save();
|
||||
canvas.Translate(cx, cy);
|
||||
canvas.RotateDegrees(angle);
|
||||
canvas.DrawLine(-rx * 0.85f, 0, rx * 0.85f, 0, vein);
|
||||
canvas.Rotate(angle);
|
||||
canvas.DrawLine(-rx * 0.85f, 0, rx * 0.85f, 0, Math.Max(1.5f, size * 0.003f), Mix(color, Color.White, 0.25f));
|
||||
canvas.Restore();
|
||||
}
|
||||
|
||||
@@ -426,21 +416,16 @@ public static class DemoImages
|
||||
{
|
||||
var table = Pick(C(0xE9E6E1), C(0xEFEBE4), C(0xDCD7CF));
|
||||
Rect(0, 0, w, h, table);
|
||||
using (var line = new SKPaint { IsAntialias = true, Color = Mix(table, SKColors.Black, 0.08f), StrokeWidth = Math.Max(2, w * 0.004f) })
|
||||
var grooves = Mix(table, Color.Black, 0.08f);
|
||||
for (var y = h * 0.12f; y < h; y += h * 0.16f)
|
||||
{
|
||||
for (var y = h * 0.12f; y < h; y += h * 0.16f)
|
||||
{
|
||||
canvas.DrawLine(0, y, w, y + (h * 0.01f), line);
|
||||
}
|
||||
canvas.DrawLine(0, y, w, y + (h * 0.01f), Math.Max(2, w * 0.004f), grooves);
|
||||
}
|
||||
|
||||
var r = Math.Min(w, h) * R(0.28f, 0.34f);
|
||||
var cx = w * R(0.42f, 0.55f);
|
||||
var cy = h * R(0.48f, 0.58f);
|
||||
using (var shadow = new SKPaint { IsAntialias = true, Color = new SKColor(0, 0, 0, 40), MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, r * 0.06f) })
|
||||
{
|
||||
canvas.DrawCircle(cx + (r * 0.04f), cy + (r * 0.06f), r, shadow);
|
||||
}
|
||||
canvas.FillBlurredCircle(cx + (r * 0.04f), cy + (r * 0.06f), r, r * 0.06f, new Color(0, 0, 0, 40));
|
||||
|
||||
Circle(cx, cy, r, C(0xFAFAF8));
|
||||
Circle(cx, cy, r * 0.78f, C(0xF0EEEA));
|
||||
@@ -458,24 +443,23 @@ public static class DemoImages
|
||||
var cr = Math.Min(w, h) * 0.085f;
|
||||
Circle(cupX, cupY, cr, C(0xF5F3EF));
|
||||
Circle(cupX, cupY, cr * 0.75f, C(0x5B3A26));
|
||||
using var fork = new SKPaint { IsAntialias = true, Color = C(0xC9C6C0), StrokeWidth = Math.Max(3, w * 0.008f), StrokeCap = SKStrokeCap.Round };
|
||||
canvas.DrawLine(cx + (r * 1.18f), cy - (r * 0.5f), cx + (r * 1.18f), cy + (r * 0.75f), fork);
|
||||
canvas.DrawLine(cx + (r * 1.18f), cy - (r * 0.5f), cx + (r * 1.18f), cy + (r * 0.75f), Math.Max(3, w * 0.008f), C(0xC9C6C0), LineCap.Round);
|
||||
}
|
||||
|
||||
public void Portrait()
|
||||
{
|
||||
var bg = Pick(C(0xB27FC0), C(0xC98F9B), C(0x8FA8C9), C(0xD3A26F), C(0x7FB8A3), C(0xA88FC7));
|
||||
Gradient(new SKRect(0, 0, w, h), Mix(bg, SKColors.White, 0.15f), Mix(bg, SKColors.Black, 0.12f));
|
||||
Gradient(new Box(0, 0, w, h), Mix(bg, Color.White, 0.15f), Mix(bg, Color.Black, 0.12f));
|
||||
var skin = Pick(C(0xD9A27B), C(0xC88A63), C(0xA86F4D), C(0xE8B996), C(0x8D5A3B));
|
||||
var hair = Pick(C(0x8A4B2A), C(0x3B2A20), C(0xD8B45A), C(0x5A3A22), C(0x1F1B18));
|
||||
var shirt = Pick(C(0xA8B04A), C(0x5F8F57), C(0xB84A4A), C(0x4F6FA8), C(0xE0C35A));
|
||||
var cx = w * 0.5f;
|
||||
var unit = Math.Min(w, h * 0.8f);
|
||||
Oval(cx, h * 1.02f, unit * 0.42f, h * 0.32f, shirt);
|
||||
Rect(cx - (unit * 0.06f), h * 0.52f, unit * 0.12f, h * 0.16f, Mix(skin, SKColors.Black, 0.08f));
|
||||
Rect(cx - (unit * 0.06f), h * 0.52f, unit * 0.12f, h * 0.16f, Mix(skin, Color.Black, 0.08f));
|
||||
Oval(cx, h * 0.44f, unit * 0.16f, unit * 0.2f, skin);
|
||||
using var top = new SKPathBuilder();
|
||||
top.AddArc(new SKRect(cx - (unit * 0.17f), (h * 0.44f) - (unit * 0.22f), cx + (unit * 0.17f), (h * 0.44f) + (unit * 0.04f)), 180, 180);
|
||||
var top = new PathBuilder();
|
||||
top.AddArc(cx - (unit * 0.17f), (h * 0.44f) - (unit * 0.22f), cx + (unit * 0.17f), (h * 0.44f) + (unit * 0.04f), 180, 180);
|
||||
top.Close();
|
||||
Fill(top, hair);
|
||||
}
|
||||
@@ -484,23 +468,23 @@ public static class DemoImages
|
||||
{
|
||||
var wall = Pick(C(0xE5DFCF), C(0xE9E2D2), C(0xDCD6C6));
|
||||
var floorY = h * R(0.68f, 0.74f);
|
||||
Gradient(new SKRect(0, 0, w, floorY), Mix(wall, SKColors.White, 0.2f), wall);
|
||||
Gradient(new SKRect(0, floorY, w, h), C(0xC9AE84), C(0xB89A6E));
|
||||
Gradient(new Box(0, 0, w, floorY), Mix(wall, Color.White, 0.2f), wall);
|
||||
Gradient(new Box(0, floorY, w, h), C(0xC9AE84), C(0xB89A6E));
|
||||
var winX = w * R(0.25f, 0.45f);
|
||||
var winW = w * R(0.26f, 0.34f);
|
||||
var winY = h * 0.1f;
|
||||
var winH = h * 0.38f;
|
||||
Rect(winX - 6, winY - 6, winW + 12, winH + 12, C(0xF7F7F5));
|
||||
Gradient(new SKRect(winX, winY, winX + winW, winY + winH), C(0x9CCBEB), C(0xC9E4F4));
|
||||
Gradient(new Box(winX, winY, winX + winW, winY + winH), C(0x9CCBEB), C(0xC9E4F4));
|
||||
Rect(winX + (winW / 2) - 3, winY, 6, winH, C(0xF7F7F5));
|
||||
Rect(winX, winY + (winH / 2) - 3, winW, 6, C(0xF7F7F5));
|
||||
var sofa = Pick(C(0x6E9F7A), C(0x4E8F86), C(0x8A6A9E), C(0xA05A5A));
|
||||
var sx = w * R(0.05f, 0.15f);
|
||||
var sw = w * R(0.48f, 0.58f);
|
||||
Rect(sx, floorY - (h * 0.2f), sw, h * 0.12f, Mix(sofa, SKColors.White, 0.15f), 10);
|
||||
Rect(sx, floorY - (h * 0.2f), sw, h * 0.12f, Mix(sofa, Color.White, 0.15f), 10);
|
||||
Rect(sx, floorY - (h * 0.1f), sw, h * 0.12f, sofa, 10);
|
||||
var px = w * R(0.75f, 0.85f);
|
||||
using var pot = new SKPathBuilder();
|
||||
var pot = new PathBuilder();
|
||||
pot.MoveTo(px - (w * 0.045f), floorY - (h * 0.08f));
|
||||
pot.LineTo(px + (w * 0.045f), floorY - (h * 0.08f));
|
||||
pot.LineTo(px + (w * 0.035f), floorY + (h * 0.01f));
|
||||
@@ -518,34 +502,34 @@ public static class DemoImages
|
||||
|
||||
public void Bokeh()
|
||||
{
|
||||
Gradient(new SKRect(0, 0, w, h), C(0x1B1530), Pick(C(0x2A1E3A), C(0x1E1A2E)));
|
||||
Gradient(new Box(0, 0, w, h), C(0x1B1530), Pick(C(0x2A1E3A), C(0x1E1A2E)));
|
||||
var colors = new[] { C(0xF2B84B), C(0xE0567A), C(0x6BC5E8), C(0xB06BE0), C(0xF08A4B), C(0x7FD38A) };
|
||||
var size = Math.Max(w, h);
|
||||
for (var i = 0; i < 40; i++)
|
||||
{
|
||||
var color = colors[random.Next(colors.Length)].WithAlpha((byte)R(90, 200));
|
||||
using var paint = new SKPaint { IsAntialias = true, Color = color, MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, size * R(0.004f, 0.012f)) };
|
||||
canvas.DrawCircle(R(0, 1) * w, R(0, 1) * h, size * R(0.02f, 0.06f), paint);
|
||||
var sigma = size * R(0.004f, 0.012f);
|
||||
var x = R(0, 1) * w;
|
||||
var y = R(0, 1) * h;
|
||||
canvas.FillBlurredCircle(x, y, size * R(0.02f, 0.06f), sigma, color);
|
||||
}
|
||||
}
|
||||
|
||||
public void Concert()
|
||||
{
|
||||
Gradient(new SKRect(0, 0, w, h), C(0x14121C), C(0x1E1A2A));
|
||||
Gradient(new Box(0, 0, w, h), C(0x14121C), C(0x1E1A2A));
|
||||
var beams = new[] { C(0xE04A5A), C(0xF2C14B), C(0x4A7FE0), C(0xA04AE0), C(0x4AC0E0) };
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var x = w * (0.12f + (i * 0.19f)) + R(-0.04f, 0.04f) * w;
|
||||
var color = beams[random.Next(beams.Length)];
|
||||
using var paint = new SKPaint { IsAntialias = true };
|
||||
paint.Shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(0, h * 0.75f), [color.WithAlpha(40), color.WithAlpha(190)], null, SKShaderTileMode.Clamp);
|
||||
using var beam = new SKPathBuilder();
|
||||
var light = new LinearGradientBrush(new Vector2(0, 0), new Vector2(0, h * 0.75f), [color.WithAlpha(40), color.WithAlpha(190)]);
|
||||
var beam = new PathBuilder();
|
||||
beam.MoveTo(x, 0);
|
||||
beam.LineTo(x + (w * R(-0.12f, 0.12f)) + (w * 0.08f), h * 0.75f);
|
||||
beam.LineTo(x + (w * R(-0.12f, 0.12f)) - (w * 0.08f), h * 0.75f);
|
||||
beam.Close();
|
||||
using var beamPath = beam.Detach();
|
||||
canvas.DrawPath(beamPath, paint);
|
||||
canvas.Fill(beam, light);
|
||||
}
|
||||
|
||||
Rect(0, h * 0.72f, w, h * 0.04f, C(0x2B2838));
|
||||
@@ -560,7 +544,7 @@ public static class DemoImages
|
||||
public void Houses()
|
||||
{
|
||||
var sky = Pick(C(0x8CC4E8), C(0x9CCDEB));
|
||||
Gradient(new SKRect(0, 0, w, h), sky, Mix(sky, SKColors.White, 0.4f));
|
||||
Gradient(new Box(0, 0, w, h), sky, Mix(sky, Color.White, 0.4f));
|
||||
var facades = new[] { C(0xF2C55C), C(0xE88B6A), C(0xF0A3A0), C(0xE5D37A), C(0xD9774F), C(0x9FC7B4), C(0xF4E2B8) };
|
||||
var x = 0f;
|
||||
while (x < w)
|
||||
@@ -569,7 +553,7 @@ public static class DemoImages
|
||||
var top = h * R(0.12f, 0.4f);
|
||||
var color = facades[random.Next(facades.Length)];
|
||||
Rect(x, top, fw, h - top, color);
|
||||
Rect(x, top, fw, h * 0.02f, Mix(color, SKColors.Black, 0.2f));
|
||||
Rect(x, top, fw, h * 0.02f, Mix(color, Color.Black, 0.2f));
|
||||
var cell = fw / 5;
|
||||
for (var wy = top + (cell * 0.8f); wy < h - cell; wy += cell * 1.4f)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Security.Cryptography;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Codecs.Images;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Drawing;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Core.Storage;
|
||||
using Febe.Web.Api;
|
||||
@@ -8,7 +10,6 @@ using Febe.Web.Connection;
|
||||
using Febe.Web.Engine;
|
||||
using Febe.Web.Library;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Febe.Web.Demo;
|
||||
|
||||
@@ -90,18 +91,18 @@ public sealed class DemoBrowserPreview(IHttpContextAccessor accessor, DemoWorld
|
||||
|
||||
const int width = 640;
|
||||
const int height = 360;
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul));
|
||||
using (var canvas = new SKCanvas(bitmap))
|
||||
using var frame = new RgbaImage(width, height);
|
||||
using (var canvas = new Canvas(frame))
|
||||
{
|
||||
canvas.Clear(new SKColor(0x1A, 0x1A, 0x1A));
|
||||
canvas.Clear(new Color(0x1A, 0x1A, 0x1A));
|
||||
var tall = height - 40f;
|
||||
var wide = tall * 9 / 16;
|
||||
var gap = 26f;
|
||||
var left = (width - (3 * wide) - (2 * gap)) / 2;
|
||||
using var dim = new SKPaint { Color = new SKColor(0, 0, 0, 110) };
|
||||
var dim = new Color(0, 0, 0, 110);
|
||||
for (var i = 0; i < files.Count; i++)
|
||||
{
|
||||
using var image = SKImage.FromEncodedData(files[i]);
|
||||
using var image = DecodeOrNull(files[i]);
|
||||
if (image is null)
|
||||
{
|
||||
continue;
|
||||
@@ -112,18 +113,27 @@ public sealed class DemoBrowserPreview(IHttpContextAccessor accessor, DemoWorld
|
||||
var h = tall * scale;
|
||||
var x = left + (i * (wide + gap)) + ((wide - w) / 2);
|
||||
var y = (height - h) / 2;
|
||||
var rect = new SKRect(x, y, x + w, y + h);
|
||||
canvas.DrawImage(image, rect, new SKSamplingOptions(SKCubicResampler.Mitchell));
|
||||
canvas.DrawImage(image, x, y, w, h);
|
||||
if (i != 1)
|
||||
{
|
||||
canvas.DrawRect(rect, dim);
|
||||
canvas.FillRect(x, y, w, h, dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using var frame = SKImage.FromBitmap(bitmap);
|
||||
using var encoded = frame.Encode(SKEncodedImageFormat.Jpeg, 80);
|
||||
return encoded.ToArray();
|
||||
return JpegEncoder.Encode(frame, new JpegEncoderOptions { Quality = 80 });
|
||||
}
|
||||
|
||||
private static RgbaImage? DecodeOrNull(byte[] bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ImageDecoder.Decode(bytes);
|
||||
}
|
||||
catch (ImageDecodeException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,22 +280,22 @@ internal static class DemoDuplicates
|
||||
/// <summary>The picture resized by <paramref name="scale"/> and recompressed: the same photo saved again, smaller.</summary>
|
||||
public static (byte[] Bytes, int Width, int Height)? Variant(byte[] jpeg, double scale, int quality)
|
||||
{
|
||||
using var image = SKImage.FromEncodedData(jpeg);
|
||||
if (image is null)
|
||||
RgbaImage image;
|
||||
try
|
||||
{
|
||||
image = ImageDecoder.Decode(jpeg);
|
||||
}
|
||||
catch (ImageDecodeException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var width = Math.Max(16, (int)Math.Round(image.Width * scale));
|
||||
var height = Math.Max(16, (int)Math.Round(image.Height * scale));
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul));
|
||||
using (var canvas = new SKCanvas(bitmap))
|
||||
using (image)
|
||||
{
|
||||
canvas.DrawImage(image, new SKRect(0, 0, width, height), new SKSamplingOptions(SKCubicResampler.Mitchell));
|
||||
var width = Math.Max(16, (int)Math.Round(image.Width * scale));
|
||||
var height = Math.Max(16, (int)Math.Round(image.Height * scale));
|
||||
using var resized = ImageResampler.Resize(image, width, height);
|
||||
return (JpegEncoder.Encode(resized, new JpegEncoderOptions { Quality = quality }), width, height);
|
||||
}
|
||||
|
||||
using var result = SKImage.FromBitmap(bitmap);
|
||||
using var encoded = result.Encode(SKEncodedImageFormat.Jpeg, quality);
|
||||
return (encoded.ToArray(), width, height);
|
||||
}
|
||||
}
|
||||
@@ -122,8 +122,8 @@ public sealed class ImportHub : IAsyncDisposable
|
||||
Clock = _clock,
|
||||
Thumbnails = library.Thumbnails,
|
||||
HashIndex = library.HashIndex,
|
||||
Frames = VideoFrameExtractor.TryCreate(),
|
||||
VideoProbe = FfprobeVideoMetadataProbe.TryCreate(),
|
||||
Frames = VideoFrameDecoder.Instance,
|
||||
VideoProbe = new ContainerVideoMetadataProbe(_clock),
|
||||
SetFileTimeToPublication = settings.SetFileTimeToPublication,
|
||||
Sources = SourceRoot is { } root ? ImportSourceOptions.Docker(root) : ImportSourceOptions.AnyFolder,
|
||||
DataFolder = library.Data.Root,
|
||||
|
||||
@@ -71,7 +71,7 @@ Tutti con un ripiego registrato con `TryAdd`; la composizione registra i propri
|
||||
| `IDiagnosticSource` (`Engine/DiagnosticSource.cs`) | `NoDiagnosticSource`: niente registrato, il rapporto ha gli elenchi vuoti (prove, avvio con un problema di configurazione) | `Febe.App`: `RecordedDiagnosticSource` sul registratore `CollectionDiagnostics` (registro in `Dati/diagnostica`, 14 giorni, e sessioni in corso); dimostrazione: `DemoDiagnosticSource`, secondo la scena |
|
||||
| `IAlertTestSender` (Core) | `NoTelegramSender`: nessun messaggio parte (dimostrazione, prove), la risposta lo dice | La composizione (`Febe.App`, le due vesti): `TelegramAlertChannel` (Core, `Alerts/Telegram.cs`), lo stesso canale che usa `AlertService` |
|
||||
| `IDataFolderChange` | `FixedDataFolder`: la cartella dei dati non si cambia dall'interfaccia | Desktop: `DesktopDataFolderChange` registra la scelta e `DataFolderMove` sposta la cartella al prossimo avvio, con copia verificata (SHA-256) |
|
||||
| `ImportService` (Core) | `ImportHub` ne costruisce uno sulla libreria (Docker: solo sotto `FebeWebOptions.ImportRoot`, di serie `/importa`; desktop: qualsiasi cartella) | La composizione, se vuole opzioni diverse (ffmpeg, cartella sorgente) |
|
||||
| `ImportService` (Core) | `ImportHub` ne costruisce uno sulla libreria (Docker: solo sotto `FebeWebOptions.ImportRoot`, di serie `/importa`; desktop: qualsiasi cartella) | La composizione, se vuole opzioni diverse (decodificatore dei fotogrammi, cartella sorgente) |
|
||||
|
||||
- `ImportHub.LibrarySettingsChanged()` va chiamato quando cambiano cartella o schema dei nomi (lo fa già
|
||||
`PUT /api/settings/general`); a copia finita pubblica `LibraryChange` con motivo `import`.
|
||||
|
||||
@@ -200,7 +200,7 @@ public sealed class RebuildJob(IFebeStorage storage, FebeLibrary library, IClock
|
||||
var progress = new SyncProgress<RebuildProgress>(p => State = State with { Folder = p.Folder, FoldersDone = p.FoldersDone, FoldersTotal = p.FoldersTotal, FilesChecked = p.FilesChecked });
|
||||
try
|
||||
{
|
||||
var rebuilder = new LibraryRebuilder(storage, library.Layout, clock, library.Thumbnails, VideoFrameExtractor.TryCreate(), library.HashIndex);
|
||||
var rebuilder = new LibraryRebuilder(storage, library.Layout, clock, library.Thumbnails, VideoFrameDecoder.Instance, library.HashIndex);
|
||||
var report = await rebuilder.RebuildAsync(new RebuildOptions(), progress).ConfigureAwait(false);
|
||||
State = State with { Running = false, Report = report, FinishedAt = clock.Now };
|
||||
changes.Publish(new LibraryChange(clock.Now, null, "rebuild"));
|
||||
|
||||
@@ -793,6 +793,15 @@ input[type=range].cursore.lungo::-webkit-slider-thumb{border-color:var(--accento
|
||||
.collega-destra h2.sez{margin-bottom:12px}
|
||||
.collega-destra .avviso{font-size:13.5px;line-height:1.5;padding:13px 16px}
|
||||
.nota-password{background:var(--accento-tinta)}
|
||||
.sessione-salvata{padding:14px 16px;font-size:13.5px;line-height:1.5}
|
||||
.sessione-salvata p{margin:0 0 6px}
|
||||
.sessione-salvata h2.sez{margin-bottom:8px}
|
||||
.sessione-salvata h3.sez{font-size:13.5px;font-weight:650;margin:12px 0 8px}
|
||||
.sessione-salvata .avviso{margin:4px 0 8px}
|
||||
.sessione-salvata .scelte{display:flex;flex-direction:column;gap:10px}
|
||||
.sessione-salvata .scelte .voce{align-items:flex-start}
|
||||
.sessione-salvata .scelte .voce .tondo{margin-top:2px}
|
||||
.sessione-salvata .scelte small{display:block;color:var(--testo-2);font-size:12.5px}
|
||||
.passi-collegamento{list-style:none;margin:0 0 8px;padding:0;display:flex;flex-direction:column;gap:18px}
|
||||
.passi-collegamento li{display:flex;gap:14px}
|
||||
.passi-collegamento .numero{width:24px;height:24px;border-radius:50%;flex:none;display:inline-flex;align-items:center;justify-content:center;background:var(--accento-tinta);color:var(--accento-scuro);font-weight:650;font-size:12.5px;margin-top:1px}
|
||||
|
||||
@@ -63,7 +63,7 @@ function renderStatus(state) {
|
||||
const s = state.snapshot;
|
||||
const meter = s.profilesOpenedToday;
|
||||
const connection = state.connection;
|
||||
const linkState = t(connection.state === 'verification' ? 'stato.verifica' : connection.state === 'disconnected' ? 'stato.scollegato' : 'stato.collegato');
|
||||
const linkState = t(connection.state === 'verification' ? 'stato.verifica' : connection.state === 'disconnected' ? 'stato.scollegato' : connection.state === 'copyMissing' ? 'stato.copiaMancante' : 'stato.collegato');
|
||||
// The own account is known only after the first sweep (a verification can come before it): no «@null».
|
||||
const who = connection.state === 'notConnected'
|
||||
? h('div.chi', h('span.av.segnaposto', icon('user', 's')),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Browser (spec §10.3 «Apri il browser»; mockup 10 without the steps column): in Docker the remote view of the
|
||||
// server's browser and «Ho finito»; on Windows the browser is its own window. While Alberto uses the browser the
|
||||
// engine is still; «Ho finito» lets «Riprendi» become active after a verification. Leaving the page without «Ho finito»
|
||||
// (another page, a reload, closing the tab) gives the browser back, like «Annulla» (on Windows the window stays as it
|
||||
// is until Alberto closes it). A browser at rest opens its start page; «?accesso=1» (the red strip of a disconnection)
|
||||
// (another page, a reload, closing the tab) gives the browser back, like closing the window on Windows: the server copies
|
||||
// the session if no view opens again within a moment (on Windows the window stays as it is until Alberto closes it). A browser at rest opens its start page; «?accesso=1» (the red strip of a disconnection)
|
||||
// opens the login page, once: the parameter leaves the address straight away.
|
||||
|
||||
import { api } from '../core/api.js';
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
// the steps «Come collegarti», the note that the password goes only to Instagram (keys pass through the server without
|
||||
// being recorded), the risk note, Annulla and «Ho finito». Windows: the browser is the separate window «Browser di
|
||||
// Febe» and the large area says so, with «Portalo in primo piano». When connected: the account, «Usa il browser» and
|
||||
// «Scollega» with its confirmation. While Alberto uses the browser the engine is still.
|
||||
// «Scollega» with its confirmation. While Alberto uses the browser the engine is still. With the raccolta «richieste»
|
||||
// (issue #36, S4b) the page also shows the saved session in counts and names (never values), the choice for an
|
||||
// incomplete copy, and «Serve «Ho finito»» when the browser is connected but the copy is missing.
|
||||
|
||||
import { api } from '../core/api.js';
|
||||
import { caps } from '../core/context.js';
|
||||
@@ -10,10 +12,10 @@ import { h, icon, fill } from '../core/dom.js';
|
||||
import { engineState, refreshEngine } from '../core/engine.js';
|
||||
import { navigate } from '../core/shell.js';
|
||||
import { t } from '../core/text.js';
|
||||
import { avatar, confirmDialog, label, showError, toast } from '../core/ui.js';
|
||||
import { avatar, confirmDialog, label, radio, showError, toast } from '../core/ui.js';
|
||||
import { remoteView } from './remote-view.js';
|
||||
|
||||
const STATE_KIND = { notConnected: 'ambra', connected: 'verde', verificationRequired: 'rosso', browserUnavailable: '' };
|
||||
const STATE_KIND = { notConnected: 'ambra', connected: 'verde', copyMissing: 'ambra', verificationRequired: 'rosso', browserUnavailable: '' };
|
||||
|
||||
/** True while the engine waits for «Riprendi» (the stop strip of a verification or a disconnection). */
|
||||
function waitsForResume(state) {
|
||||
@@ -40,9 +42,10 @@ export async function beginDriving(openLogin) {
|
||||
/**
|
||||
* The browser as a page uses it (spec §4.1, §10.3: the engine is still only while Alberto uses the browser). begin()
|
||||
* takes it; «Ho finito», «Annulla» and «Scollega» give it back on the server, and the page calls settled(). Leaving the
|
||||
* page in any other way — another page, a reload, closing the tab — gives it back too: in Docker like «Annulla» (the
|
||||
* browser goes back to the empty page and the engine may work again); on Windows the window «Browser di Febe» stays as
|
||||
* it is, on screen until Alberto closes it (issue #52), and only the page's hold ends.
|
||||
* page in any other way — another page, a reload, closing the tab — gives it back too: in Docker like closing the
|
||||
* window on Windows, not like «Annulla» (answer of 25 November 2026: if no view opens again within a moment, the
|
||||
* server copies the session and the engine may work again; a reload opens the view again); on Windows the window
|
||||
* «Browser di Febe» stays as it is, on screen until Alberto closes it (issue #52), and only the page's hold ends.
|
||||
*/
|
||||
export function drivingLease(page) {
|
||||
let held = false;
|
||||
@@ -120,6 +123,7 @@ export async function mountConnection(page) {
|
||||
fill(stateLabel, label(t(`impostazioni.collegamento.stati.${status.state}`), STATE_KIND[status.state] || ''));
|
||||
if (status.state === 'connected') drawConnected();
|
||||
else if (status.state === 'browserUnavailable') drawUnavailable();
|
||||
else if (status.state === 'copyMissing') drawLogin({ copyMissing: true });
|
||||
else drawLogin();
|
||||
}
|
||||
|
||||
@@ -145,15 +149,17 @@ export async function mountConnection(page) {
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------------------- login or verification
|
||||
function drawLogin() {
|
||||
function drawLogin({ copyMissing = false } = {}) {
|
||||
const verification = status.state === 'verificationRequired';
|
||||
// Connected but without the copy for the requests: the start page (the site's home), never the login page.
|
||||
const login = !verification && !copyMissing;
|
||||
waitingResume = false;
|
||||
closeView();
|
||||
lease.begin(!verification);
|
||||
lease.begin(login);
|
||||
if (windows) {
|
||||
fill(left, windowPanel());
|
||||
} else {
|
||||
view = remoteView(page, { url: status.currentUrl, login: !verification });
|
||||
view = remoteView(page, { url: status.currentUrl, login });
|
||||
fill(left, view.element);
|
||||
}
|
||||
const steps = t(windows ? 'impostazioni.collegamento.passiWindows' : 'impostazioni.collegamento.passi');
|
||||
@@ -161,6 +167,8 @@ export async function mountConnection(page) {
|
||||
fill(right,
|
||||
verification
|
||||
? h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', h('b', t('impostazioni.collegamento.verificaTitolo')), ' ', t('impostazioni.collegamento.verificaTesto')))
|
||||
: copyMissing
|
||||
? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', h('b', t('impostazioni.collegamento.copiaMancanteTitolo')), ' ', t('impostazioni.collegamento.copiaMancanteTesto')))
|
||||
: h('div',
|
||||
h('h2.sez', t('impostazioni.collegamento.come')),
|
||||
h('ol.passi-collegamento', (Array.isArray(steps) ? steps : []).map((s, i) => h('li', h('span.numero', String(i + 1)), h('div', h('b', s.titolo), h('p', s.testo)))))),
|
||||
@@ -168,6 +176,7 @@ export async function mountConnection(page) {
|
||||
h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('impostazioni.collegamento.rischio'))),
|
||||
// Windows: one engine per account (spec §5) said before the login too; Docker keeps mockup 10 as it is.
|
||||
windows ? h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))) : null,
|
||||
copyMissing ? savedSessionBox(status.savedSession, page) : null,
|
||||
message,
|
||||
h('div.molla'),
|
||||
h('div.bottoni-collegamento',
|
||||
@@ -235,7 +244,8 @@ export async function mountConnection(page) {
|
||||
fill(right,
|
||||
passwordNote(windows),
|
||||
h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('impostazioni.collegamento.rischio'))),
|
||||
h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))));
|
||||
h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))),
|
||||
savedSessionBox(status.savedSession, page));
|
||||
}
|
||||
|
||||
async function useBrowser() {
|
||||
@@ -287,6 +297,81 @@ export async function mountConnection(page) {
|
||||
await draw();
|
||||
}
|
||||
|
||||
/**
|
||||
* The saved session of the raccolta «richieste» (issue #36, S4b): when it was copied, the values and doc_id present
|
||||
* and the names of the missing ones — counts and names only, the server never sends a value — and the choice for an
|
||||
* incomplete copy. Nothing without a saved session in this start («pagine»).
|
||||
*/
|
||||
export function savedSessionBox(saved, page) {
|
||||
if (!saved) return null;
|
||||
const k = (key, vars) => t(`impostazioni.collegamento.salvata.${key}`, vars);
|
||||
const lines = [];
|
||||
if (saved.state === 'present') {
|
||||
if (saved.copiedAt) {
|
||||
const when = new Date(saved.copiedAt).toLocaleString('it-IT', { dateStyle: 'medium', timeStyle: 'short' });
|
||||
lines.push(h('p', k('copiata', { quando: when })));
|
||||
}
|
||||
lines.push(h('p.muto', [
|
||||
k('valori', { presenti: String(saved.valuesPresent), attesi: String(saved.valuesExpected) }),
|
||||
k('docId', { presenti: String(saved.docIdsPresent), attesi: String(saved.docIdsExpected) }),
|
||||
k('cookie', { n: String(saved.cookies) }),
|
||||
].join(' ')));
|
||||
const missing = [...(saved.missingValues || []), ...(saved.missingDocIds || [])];
|
||||
if (missing.length) lines.push(h('p', k('mancano', { nomi: missing.join(', ') })));
|
||||
lines.push(saved.neededMissing
|
||||
? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', k('servono', { n: String(saved.neededMissing) })))
|
||||
: h('p', k('completa')));
|
||||
} else {
|
||||
lines.push(h('p', k(saved.state === 'unreadable' ? 'illeggibile' : 'nessuna')));
|
||||
}
|
||||
|
||||
// Neither choice is shown as chosen, and neither can be picked, until the server says which one is stored: the page
|
||||
// never claims a choice the next copy will not follow. Once Alberto picks one, a late answer no longer changes it;
|
||||
// a choice the server did not save goes back to the one before.
|
||||
let saved = null;
|
||||
let chosen = false;
|
||||
const show = (value) => {
|
||||
keep.input.checked = value === 'tieni-completa';
|
||||
replace.input.checked = value === 'sostituisci';
|
||||
};
|
||||
const choose = async (value) => {
|
||||
chosen = true;
|
||||
const before = saved;
|
||||
try {
|
||||
const settings = await api('/api/connection/settings', { method: 'PUT', body: { incompleteCopy: value } });
|
||||
saved = settings && settings.incompleteCopy ? settings.incompleteCopy : value;
|
||||
unknown.hidden = true;
|
||||
toast(k('salvato'));
|
||||
} catch (error) {
|
||||
show(before);
|
||||
showError(error);
|
||||
}
|
||||
};
|
||||
const replace = radio({ name: 'copia-incompleta', value: 'sostituisci', onchange: choose, labelNode: h('span', h('b', k('sostituisci')), h('small', k('sostituisciAiuto'))) });
|
||||
const keep = radio({ name: 'copia-incompleta', value: 'tieni-completa', onchange: choose, labelNode: h('span', h('b', k('tieni')), h('small', k('tieniAiuto'))) });
|
||||
const unknown = h('p.aiuto.piccolo.scelta-ignota', { hidden: true }, k('sceltaIgnota'));
|
||||
for (const choice of [replace, keep]) choice.input.disabled = true;
|
||||
api('/api/connection/settings', { signal: page && page.signal }).then((settings) => {
|
||||
if (chosen) return;
|
||||
saved = settings.incompleteCopy;
|
||||
show(saved);
|
||||
}).catch(() => {
|
||||
if (page && page.signal && page.signal.aborted) return; // the page was left
|
||||
if (!chosen) unknown.hidden = false;
|
||||
}).finally(() => {
|
||||
if (page && page.signal && page.signal.aborted) return;
|
||||
for (const choice of [replace, keep]) choice.input.disabled = false;
|
||||
});
|
||||
|
||||
return h('div.pannello.sessione-salvata',
|
||||
h('h2.sez', k('titolo')),
|
||||
...lines,
|
||||
h('p.aiuto.piccolo', k('nota')),
|
||||
h('h3.sez', k('incompleta')),
|
||||
h('div.scelte', { role: 'radiogroup', 'aria-label': k('incompleta') }, replace, keep),
|
||||
unknown);
|
||||
}
|
||||
|
||||
/** «La password va solo a Instagram», with the true wording of each shell (spec §10.3). */
|
||||
export function passwordNote(windows) {
|
||||
return h('div.avviso.nota-password', icon('shield-check', 's'),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Impostazioni, Informazioni: version and shell, where the guide is (the wiki of the repository), the folders, the
|
||||
// statement on the risk for the account (spec §1, §15 «che cosa la guida deve dire»), the licenses of what Febe
|
||||
// carries inside (SQLite, SkiaSharp, .NET, WebView2) and a line saying that font and icons are not third-party.
|
||||
// carries inside (SQLite, .NET, WebView2) and a line saying that font, icons and images (codecs, thumbnails, drawing)
|
||||
// are Febe's own code, not third-party.
|
||||
|
||||
import { api } from '../core/api.js';
|
||||
import { h, icon, fill, brand } from '../core/dom.js';
|
||||
|
||||
@@ -143,6 +143,11 @@ export function openViewer({ tile, source, origin, onDeleted }) {
|
||||
h('p', t(media.kind === 'video' ? 'vis.videoMancante' : 'vis.mancante'))));
|
||||
return;
|
||||
}
|
||||
if (media.damaged) {
|
||||
// Spec §4.6, §8.4: a truncated or damaged photo is never shown half; the file stays, its actions too.
|
||||
fill(stage, h('div.mancante', icon('image', 'l'), h('p', h('b', t('vis.danneggiato'))), h('p', t('vis.danneggiatoTesto'))));
|
||||
return;
|
||||
}
|
||||
const src = `/api/media/${media.id}/file`;
|
||||
if (media.kind === 'video') {
|
||||
fill(stage, h('video', { src, poster: thumb, controls: true, autoplay: true, muted: true, playsinline: true, preload: 'metadata', 'aria-label': t('libreria.tipiTessera.' + entry.kind) }));
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"nessunAccount": "Nessun account",
|
||||
"verifica": "Verifica richiesta",
|
||||
"scollegato": "Sessione chiusa",
|
||||
"copiaMancante": "Serve «Ho finito»",
|
||||
"accountDaLeggere": "Nome non ancora noto",
|
||||
"nonDisponibile": "Stato del motore non disponibile"
|
||||
},
|
||||
@@ -201,6 +202,8 @@
|
||||
"elimina": "Elimina dalla libreria",
|
||||
"mancante": "Il file non è sul disco: forse è stato spostato o cancellato fuori da Febe.",
|
||||
"videoMancante": "Il video non è sul disco: qui si vede solo la sua copertina.",
|
||||
"danneggiato": "File danneggiato o incompleto",
|
||||
"danneggiatoTesto": "Febe non riesce a leggere questa foto: forse lo scaricamento o la copia si sono interrotti. Il file resta nella libreria così com'è.",
|
||||
"tipoFile": "{tipo}, {media} {n} di {totale}",
|
||||
"tipoSingolo": "{tipo}, {media}",
|
||||
"seguito": "Seguito",
|
||||
@@ -690,9 +693,32 @@
|
||||
"stati": {
|
||||
"notConnected": "Non collegato",
|
||||
"connected": "Collegato",
|
||||
"copyMissing": "Serve «Ho finito»",
|
||||
"verificationRequired": "Verifica richiesta",
|
||||
"browserUnavailable": "Browser non disponibile"
|
||||
},
|
||||
"copiaMancanteTitolo": "Manca la copia della sessione",
|
||||
"copiaMancanteTesto": "Il browser è collegato, ma Febe non ha ancora una copia della sessione per le richieste (o non riesce a leggerla). Apri la tua pagina iniziale nel browser e premi «Ho finito»: fino ad allora il motore aspetta.",
|
||||
"salvata": {
|
||||
"titolo": "Sessione salvata per le richieste",
|
||||
"copiata": "Copiata {quando}.",
|
||||
"nessuna": "Nessuna copia: premi «Ho finito» sulla tua pagina iniziale.",
|
||||
"illeggibile": "C'è un file, ma Febe non riesce a leggerlo (un'altra chiave o un file rovinato): conta come nessuna copia. Il prossimo «Ho finito» lo sostituisce.",
|
||||
"valori": "Valori della pagina: {presenti} su {attesi}.",
|
||||
"docId": "doc_id: {presenti} su {attesi}.",
|
||||
"cookie": "Cookie: {n}.",
|
||||
"mancano": "Mancano: {nomi}.",
|
||||
"servono": "{n} di questi serve alle richieste configurate: le richieste che lo usano non partono e, alla prima, Febe si ferma come disconnessione.|{n} di questi servono alle richieste configurate: quelle richieste non partono e, alla prima, Febe si ferma come disconnessione.",
|
||||
"completa": "Nulla di ciò che le richieste configurate mandano manca.",
|
||||
"nota": "Qui ci sono solo conteggi e nomi, mai i valori.",
|
||||
"incompleta": "Se una copia nuova è incompleta",
|
||||
"sostituisci": "Sostituisci comunque (consigliato)",
|
||||
"sostituisciAiuto": "La copia nuova prende sempre il posto di quella salvata: una copia più vecchia potrebbe avere i cookie di un altro accesso.",
|
||||
"tieni": "Tieni la copia completa",
|
||||
"tieniAiuto": "Se alla copia nuova manca qualcosa che le richieste usano e quella salvata è completa, Febe tiene quella salvata e te lo dice.",
|
||||
"salvato": "Scelta salvata: vale dalla prossima copia.",
|
||||
"sceltaIgnota": "Febe non è riuscito a leggere la scelta salvata: scegline una per salvarla di nuovo."
|
||||
},
|
||||
"come": "Come collegarti",
|
||||
"passi": [
|
||||
{
|
||||
@@ -815,7 +841,6 @@
|
||||
"licenzeAiuto": "Febe usa questi componenti, copiati nel programma con le loro licenze:",
|
||||
"componenti": [
|
||||
{ "nome": "SQLite e Microsoft.Data.Sqlite", "testo": "database, pubblico dominio e licenza MIT" },
|
||||
{ "nome": "SkiaSharp", "testo": "miniature e impronte delle immagini, licenza MIT" },
|
||||
{ "nome": ".NET e ASP.NET Core", "testo": "licenza MIT" },
|
||||
{ "nome": "WebView2", "testo": "solo versione Windows, licenza Microsoft" }
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user