Initial version
This commit is contained in:
commit
e5b6226a85
68 changed files with 7338 additions and 0 deletions
446
DataTransfer.Client/Pages/Link.razor
Normal file
446
DataTransfer.Client/Pages/Link.razor
Normal file
|
|
@ -0,0 +1,446 @@
|
|||
@page "/"
|
||||
@rendermode @(new InteractiveWebAssemblyRenderMode(false))
|
||||
|
||||
@if (!_cryptoSupported)
|
||||
{
|
||||
<header class="page-head">
|
||||
<h1>Start a transfer</h1>
|
||||
</header>
|
||||
<div class="notice notice-danger" role="alert">
|
||||
<Icon Name="alert"/>
|
||||
<div class="notice-text">
|
||||
<strong>End-to-end encryption is not available.</strong>
|
||||
This browser cannot encrypt end-to-end. Please use a current browser and open this site via HTTPS.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (_error is not null)
|
||||
{
|
||||
<div class="notice notice-danger" role="alert" data-testid="error">
|
||||
<Icon Name="alert"/>
|
||||
<span class="notice-text">@_error</span>
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-icon" title="Dismiss" aria-label="Dismiss"
|
||||
@onclick="() => _error = null">
|
||||
<Icon Name="close"/>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@switch (Session.State)
|
||||
{
|
||||
case SessionState.Idle:
|
||||
case SessionState.Joining:
|
||||
<header class="page-head">
|
||||
<h1>Start a transfer</h1>
|
||||
<p>Connect two browsers with a one-time code. Messages and files are encrypted on this device before
|
||||
they are sent.</p>
|
||||
</header>
|
||||
|
||||
<div class="panel connect">
|
||||
<section class="connect-option">
|
||||
<h2 class="connect-title"><span class="connect-icon"><Icon Name="plus"/></span>Create a connection
|
||||
</h2>
|
||||
<p class="connect-text">
|
||||
Generates a one-time code. Share it with the person you want to exchange messages and files
|
||||
with.
|
||||
</p>
|
||||
@if (Load is { } load && IsServerFull)
|
||||
{
|
||||
<p class="capacity-note" data-testid="capacity-note">
|
||||
<Icon Name="clock"/>
|
||||
<span>
|
||||
The server is full (@load.ActiveConnections/@load.MaxConnections connections in use@(load.QueuedClients > 0 ? $", {load.QueuedClients} waiting" : null)).
|
||||
You will be placed in a queue.
|
||||
</span>
|
||||
</p>
|
||||
}
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary" disabled="@IsBusy" @onclick="CreateAsync"
|
||||
data-testid="create">
|
||||
@if (_pending == PendingAction.Create)
|
||||
{
|
||||
<span class="spinner" aria-hidden="true"></span>
|
||||
<span>@(Session.IsVerifyingBrowser ? "Verifying browser…" : "Creating…")</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Create connection</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="connect-divider" aria-hidden="true"><span>or</span></div>
|
||||
|
||||
<section class="connect-option">
|
||||
<h2 class="connect-title"><span class="connect-icon"><Icon Name="join"/></span>Join a connection
|
||||
</h2>
|
||||
<p class="connect-text">Enter the code you received.</p>
|
||||
<div class="join-row">
|
||||
<input class="input code-input" placeholder="ABCDE-FGHJK" maxlength="20"
|
||||
autocomplete="off" spellcheck="false" aria-label="Connection code"
|
||||
data-testid="join-code"
|
||||
@bind="_joinCode" @bind:event="oninput" @onkeydown="OnJoinKeyDownAsync"/>
|
||||
<button type="button" class="btn btn-primary" disabled="@IsBusy" @onclick="JoinAsync"
|
||||
data-testid="join">
|
||||
@if (_pending == PendingAction.Join)
|
||||
{
|
||||
<span class="spinner" aria-hidden="true"></span>
|
||||
<span>Joining…</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Join</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<ol class="steps">
|
||||
<li>
|
||||
<span class="step-no">01</span>
|
||||
<div><strong>Create</strong> One side creates a connection and shares the code.</div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="step-no">02</span>
|
||||
<div><strong>Join</strong> The other side enters the code to connect.</div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="step-no">03</span>
|
||||
<div><strong>Verify & transfer</strong> Compare the safety code, then send messages and files.
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
break;
|
||||
|
||||
case SessionState.Queued:
|
||||
<header class="page-head">
|
||||
<h1>Waiting for a free slot</h1>
|
||||
<p>
|
||||
The server has reached its connection limit. Your connection is created automatically as soon as
|
||||
another
|
||||
one closes – keep this page open.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section class="panel waiting" aria-labelledby="queue-title">
|
||||
<div class="panel-header">
|
||||
<h2 class="panel-title" id="queue-title">Queue</h2>
|
||||
</div>
|
||||
<div class="panel-body waiting-body">
|
||||
<div class="queue-position" aria-live="polite">
|
||||
<span class="queue-number" data-testid="queue-position">@Session.QueuePosition</span>
|
||||
<div class="queue-text">
|
||||
<strong>@QueueAheadText</strong>
|
||||
<span class="muted">Position in the queue</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="waiting-status">
|
||||
<span class="spinner" aria-hidden="true"></span>
|
||||
<span>Waiting for a connection to close…</span>
|
||||
@if (Load is { } queueLoad)
|
||||
{
|
||||
<span class="waiting-expiry">
|
||||
<span class="mono">@queueLoad.ActiveConnections/@queueLoad.MaxConnections</span> connections in use
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button type="button" class="btn btn-danger" @onclick="ResetAsync" data-testid="leave-queue">Leave
|
||||
queue
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
break;
|
||||
|
||||
case SessionState.Waiting:
|
||||
<header class="page-head">
|
||||
<h1>Share the code</h1>
|
||||
<p>Give this code to the person you want to connect with, for example by phone or messenger. It can only
|
||||
be used once.</p>
|
||||
</header>
|
||||
|
||||
<section class="panel waiting" aria-labelledby="code-title">
|
||||
<div class="panel-header">
|
||||
<h2 class="panel-title" id="code-title">Connection code</h2>
|
||||
</div>
|
||||
<div class="panel-body waiting-body">
|
||||
<div class="code-display">
|
||||
<div class="code-chars" data-testid="connection-code">
|
||||
@foreach (var c in DisplayCode ?? string.Empty)
|
||||
{
|
||||
<span class="@(c == '-' ? "code-sep" : "code-char")">@c</span>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="btn" @onclick="CopyCodeAsync">
|
||||
<Icon Name="@(_copied ? "check" : "copy")"/>
|
||||
<span>@(_copied ? "Copied" : "Copy code")</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="waiting-status">
|
||||
<span class="spinner" aria-hidden="true"></span>
|
||||
<span data-testid="waiting-status">@(Session.IsPeerJoining ? "The other person joined. Securing the connection…" : "Waiting for the other person to join…")</span>
|
||||
<span class="waiting-expiry">Expires in <span class="mono">@RemainingTime</span></span>
|
||||
</div>
|
||||
<div class="progress countdown @(RemainingPercent <= 20 ? "is-low" : null)" aria-hidden="true">
|
||||
<div class="progress-bar" style="width: @(RemainingPercent)%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button type="button" class="btn btn-danger" @onclick="ResetAsync">Cancel</button>
|
||||
</div>
|
||||
</section>
|
||||
break;
|
||||
|
||||
default:
|
||||
var connected = Session.State == SessionState.Connected;
|
||||
|
||||
@if (connected)
|
||||
{
|
||||
<section class="panel session">
|
||||
<div class="session-main">
|
||||
<h1 class="session-state"><span class="status status-online"
|
||||
data-testid="status">Connected</span></h1>
|
||||
<dl class="session-facts">
|
||||
<div>
|
||||
<dt>Code</dt>
|
||||
<dd class="mono">@DisplayCode</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Safety code</dt>
|
||||
<dd class="mono safety-code" data-testid="safety-code">@Session.SafetyCode</dd>
|
||||
</div>
|
||||
<div
|
||||
title="The connection closes after @DisplayFormat.Duration(Session.InactivityTimeout) without transfers.">
|
||||
<dt>Idle timeout · @DisplayFormat.Duration(Session.InactivityTimeout)</dt>
|
||||
<dd><span class="mono" data-testid="remaining">@RemainingTime</span> left</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<button type="button" class="btn btn-danger btn-sm" @onclick="DisconnectAsync"
|
||||
data-testid="disconnect">
|
||||
<Icon Name="power"/>
|
||||
<span>Disconnect</span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="session-hint">
|
||||
<Icon Name="shield"/>
|
||||
<span>
|
||||
Compare the safety code with your partner over another channel (e.g. by phone). If both codes match,
|
||||
nobody else – not even this server – can read your messages and files.
|
||||
</span>
|
||||
</p>
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="panel session" role="status">
|
||||
<div class="session-main">
|
||||
<h1 class="session-state"><span class="status status-offline">Disconnected</span></h1>
|
||||
<div class="session-closed">
|
||||
<span data-testid="closed-message">@Session.ClosedMessage</span>
|
||||
@if (Session.HasPeer)
|
||||
{
|
||||
<span
|
||||
class="muted">Received files stay available until you start a new connection.</span>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-sm" @onclick="ResetAsync"
|
||||
data-testid="new-connection">
|
||||
New connection
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (Session.HasPeer)
|
||||
{
|
||||
<div class="workspace @(connected ? null : "is-closed")">
|
||||
@if (connected)
|
||||
{
|
||||
<section class="panel send" aria-labelledby="send-title">
|
||||
<div class="panel-header">
|
||||
<h2 class="panel-title" id="send-title">Send</h2>
|
||||
</div>
|
||||
<div class="panel-body send-body">
|
||||
<label
|
||||
class="dropzone @(_dragging ? "is-dragging" : null) @(Session.IsSendingFiles ? "is-busy" : null)"
|
||||
@ondragenter="() => _dragging = true" @ondragleave="() => _dragging = false"
|
||||
@ondrop="() => _dragging = false"
|
||||
@ondragover:preventDefault="@Session.IsSendingFiles"
|
||||
@ondrop:preventDefault="@Session.IsSendingFiles">
|
||||
@if (Session.IsSendingFiles)
|
||||
{
|
||||
<span class="spinner dropzone-spinner" aria-hidden="true"></span>
|
||||
<strong>Sending files…</strong>
|
||||
<span>You can add more files when these are sent.</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Name="upload" Class="dropzone-icon"/>
|
||||
<strong>Drop files here or <span class="dropzone-browse">browse</span></strong>
|
||||
<span>Up to @MaxFilesPerSelection files at once, max. @(TransferProtocol.MaxFileBytes / (1024 * 1024)) MB each</span>
|
||||
}
|
||||
<InputFile class="dropzone-input" multiple OnChange="OnFilesSelectedAsync"
|
||||
disabled="@Session.IsSendingFiles"
|
||||
title="Choose files to send" data-testid="file-input"/>
|
||||
</label>
|
||||
|
||||
<div class="send-message">
|
||||
<label class="field-label" for="message">Message</label>
|
||||
<textarea id="message" class="input" rows="4"
|
||||
maxlength="@TransferProtocol.MaxMessageLength"
|
||||
placeholder="Text, links, notes…" data-testid="message-input"
|
||||
@bind="_message" @bind:event="oninput"
|
||||
@onkeydown="OnMessageKeyDownAsync"></textarea>
|
||||
<div class="send-actions">
|
||||
<span class="hint"><kbd>Ctrl</kbd> + <kbd>Enter</kbd> to send</span>
|
||||
<button type="button" class="btn btn-primary"
|
||||
disabled="@(_sendingMessage || string.IsNullOrWhiteSpace(_message))"
|
||||
@onclick="SendMessageAsync" data-testid="send">
|
||||
<span>Send</span>
|
||||
<Icon Name="arrow-right"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
<section class="panel log" aria-labelledby="log-title">
|
||||
<div class="panel-header">
|
||||
<h2 class="panel-title" id="log-title">Transfers</h2>
|
||||
<span class="log-summary">
|
||||
<span><Icon Name="arrow-up"/>@SentCount sent</span>
|
||||
<span><Icon Name="arrow-down"/>@ReceivedCount received</span>
|
||||
</span>
|
||||
</div>
|
||||
@* column-reverse keeps the log scrolled to the newest entry without any JavaScript. *@
|
||||
<div class="log-scroll" aria-live="polite" data-testid="chat-log">
|
||||
@if (Session.Entries.Count == 0)
|
||||
{
|
||||
<div class="log-empty">
|
||||
<Icon Name="inbox"/>
|
||||
<strong>Nothing transferred yet</strong>
|
||||
<span>Messages and files are encrypted in your browser before they leave it.</span>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ol class="log-entries">
|
||||
@foreach (var entry in Session.Entries)
|
||||
{
|
||||
@if (entry.Kind == ChatEntryKind.System)
|
||||
{
|
||||
<li class="entry entry-system @(entry.Error is null ? null : "is-error")">
|
||||
<span class="entry-dir"><Icon
|
||||
Name="@(entry.Error is null ? "info" : "alert")"/></span>
|
||||
<div class="entry-body">@entry.Text</div>
|
||||
<div class="entry-meta">
|
||||
<time class="entry-time">@entry.Time.ToString("t")</time>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
var outgoing = entry.Kind == ChatEntryKind.Outgoing;
|
||||
<li class="entry @(outgoing ? "entry-out" : "entry-in")">
|
||||
<span class="entry-dir" title="@(outgoing ? "Sent" : "Received")">
|
||||
<Icon Name="@(outgoing ? "arrow-up" : "arrow-down")"/>
|
||||
<span
|
||||
class="visually-hidden">@(outgoing ? "Sent" : "Received")</span>
|
||||
</span>
|
||||
<div class="entry-body">
|
||||
@if (entry.IsFile)
|
||||
{
|
||||
<div class="entry-file" title="@entry.FileName">
|
||||
<Icon Name="file"/>
|
||||
<span class="entry-name">@entry.FileName</span>
|
||||
</div>
|
||||
@if (entry.IsRiskyFile)
|
||||
{
|
||||
<div class="entry-warning" role="note" data-testid="risky-file-warning">
|
||||
<Icon Name="alert"/>
|
||||
<span>
|
||||
This file type can run programs or scripts on your device. Only open it if
|
||||
you know the sender and expected this file.
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
@if (entry.Error is not null)
|
||||
{
|
||||
<div class="entry-error">@entry.Error</div>
|
||||
}
|
||||
else if (entry.IsTransferring)
|
||||
{
|
||||
<div class="progress entry-progress" role="progressbar"
|
||||
aria-label="@(outgoing ? "Sending" : "Receiving") @entry.FileName"
|
||||
aria-valuenow="@entry.ProgressPercent"
|
||||
aria-valuemin="0" aria-valuemax="100">
|
||||
<div class="progress-bar"
|
||||
style="width: @(entry.ProgressPercent)%"></div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="entry-text">@entry.Text</div>
|
||||
}
|
||||
</div>
|
||||
<div class="entry-meta">
|
||||
<span
|
||||
class="entry-size">@(entry.IsFile ? DisplayFormat.Bytes(entry.FileSize) : null)</span>
|
||||
<time class="entry-time">@entry.Time.ToString("t")</time>
|
||||
</div>
|
||||
<div class="entry-action">
|
||||
@if (!entry.IsFile)
|
||||
{
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-icon"
|
||||
title="Copy text" aria-label="Copy text"
|
||||
@onclick="() => CopyEntryAsync(entry)">
|
||||
<Icon
|
||||
Name="@(ReferenceEquals(_copiedEntry, entry) ? "check" : "copy")"/>
|
||||
</button>
|
||||
}
|
||||
else if (entry.Error is not null)
|
||||
{
|
||||
<span class="tag tag-danger">Failed</span>
|
||||
}
|
||||
else if (entry.IsTransferring)
|
||||
{
|
||||
<span
|
||||
class="tag tag-progress mono">@entry.ProgressPercent%</span>
|
||||
}
|
||||
else if (entry.DownloadUrl is not null)
|
||||
{
|
||||
<a class="btn btn-sm" href="@entry.DownloadUrl"
|
||||
download="@entry.FileName" title="Save @entry.FileName">
|
||||
<Icon Name="download"/>
|
||||
<span>Save</span>
|
||||
<span class="visually-hidden">@entry.FileName</span>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="tag tag-success"><Icon
|
||||
Name="check"/>@(outgoing ? "Sent" : "Received")</span>
|
||||
}
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
398
DataTransfer.Client/Pages/Link.razor.cs
Normal file
398
DataTransfer.Client/Pages/Link.razor.cs
Normal file
|
|
@ -0,0 +1,398 @@
|
|||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using DataTransfer.Client.Services;
|
||||
using DataTransfer.Client.Shared;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using SpawnDev.BlazorJS;
|
||||
using SpawnDev.BlazorJS.Cryptography;
|
||||
using SpawnDev.BlazorJS.JSObjects;
|
||||
|
||||
namespace DataTransfer.Client.Pages;
|
||||
|
||||
public sealed partial class Link : ComponentBase, IAsyncDisposable
|
||||
{
|
||||
private const int MaxFilesPerSelection = 20;
|
||||
|
||||
// Frames can arrive ten times per second; re-rendering the whole log for each would make the page sluggish.
|
||||
private static readonly TimeSpan MinRenderInterval = TimeSpan.FromMilliseconds(250);
|
||||
|
||||
private TransferSession? _session;
|
||||
private SessionState _observedState;
|
||||
private string? _documentTitle;
|
||||
private Window? _window;
|
||||
private bool _isLeaveGuardActive;
|
||||
private long _lastRenderTimestamp;
|
||||
private bool _isRenderScheduled;
|
||||
private Timer? _ticker;
|
||||
private bool _cryptoSupported;
|
||||
private PendingAction _pending;
|
||||
private bool _copied;
|
||||
private bool _dragging;
|
||||
private bool _sendingMessage;
|
||||
private ChatEntry? _copiedEntry;
|
||||
private string? _joinCode;
|
||||
private string? _message;
|
||||
private string? _error;
|
||||
|
||||
private enum PendingAction
|
||||
{
|
||||
None,
|
||||
Create,
|
||||
Join
|
||||
}
|
||||
|
||||
private TransferSession Session => _session!;
|
||||
|
||||
private ServerStatus? Load => Status.Current;
|
||||
|
||||
/// <summary>A new connection would be queued; a non-empty queue also means no slot is available to newcomers.</summary>
|
||||
private bool IsServerFull => Load is { } load && (load.ActiveConnections >= load.MaxConnections || load.QueuedClients > 0);
|
||||
|
||||
private string QueueAheadText => (Session.QueuePosition - 1) switch
|
||||
{
|
||||
<= 0 => "You are next",
|
||||
1 => "1 person ahead of you",
|
||||
var ahead => $"{ahead} people ahead of you"
|
||||
};
|
||||
|
||||
private string Title => _session?.State switch
|
||||
{
|
||||
SessionState.Queued => $"Queue #{Session.QueuePosition} · DataTransfer",
|
||||
SessionState.Waiting => "Waiting for partner · DataTransfer",
|
||||
SessionState.Connected => "Connected · DataTransfer",
|
||||
_ => "DataTransfer"
|
||||
};
|
||||
|
||||
private string? DisplayCode => Session.Code is { } code ? ConnectionCode.Format(code) : null;
|
||||
|
||||
private string RemainingTime => DisplayFormat.Countdown(Session.RemainingTime ?? TimeSpan.Zero);
|
||||
|
||||
private int RemainingPercent => Session.CountdownDuration > TimeSpan.Zero
|
||||
? (int)Math.Clamp((Session.RemainingTime ?? TimeSpan.Zero) / Session.CountdownDuration * 100, 0, 100)
|
||||
: 0;
|
||||
|
||||
private bool IsBusy => _pending != PendingAction.None;
|
||||
|
||||
/// <summary>Reloading or leaving the page now would cancel a queued, pending or established connection.</summary>
|
||||
private bool IsConnectionActive =>
|
||||
_session?.State is SessionState.Queued or SessionState.Joining or SessionState.Waiting or SessionState.Connected;
|
||||
|
||||
private int SentCount => Session.Entries.Count(entry => entry.Kind == ChatEntryKind.Outgoing);
|
||||
|
||||
private int ReceivedCount => Session.Entries.Count(entry => entry.Kind == ChatEntryKind.Incoming);
|
||||
|
||||
[Inject] private NavigationManager Navigation { get; set; } = null!;
|
||||
|
||||
[Inject] private PortableCrypto Crypto { get; set; } = null!;
|
||||
|
||||
[Inject] private BlazorJSRuntime JS { get; set; } = null!;
|
||||
|
||||
[Inject] private ILoggerFactory LoggerFactory { get; set; } = null!;
|
||||
|
||||
[Inject] private ILogger<Link> Logger { get; set; } = null!;
|
||||
|
||||
[Inject] private ServerStatusMonitor Status { get; set; } = null!;
|
||||
|
||||
[Inject] private BotCheckSolver BotCheckSolver { get; set; } = null!;
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
Status.Changed -= OnStatusChanged;
|
||||
SetLeaveGuard(false);
|
||||
_window?.Dispose();
|
||||
if (_ticker is not null)
|
||||
{
|
||||
await _ticker.DisposeAsync();
|
||||
}
|
||||
|
||||
if (_session is not null)
|
||||
{
|
||||
_session.Changed -= OnSessionChanged;
|
||||
await _session.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_cryptoSupported = JS.Get<bool>("isSecureContext") && !JS.IsUndefined("crypto.subtle");
|
||||
_session = new TransferSession(Navigation, Crypto, BotCheckSolver, LoggerFactory.CreateLogger<TransferSession>());
|
||||
_session.Changed += OnSessionChanged;
|
||||
_ticker = new Timer(_ => OnTick(), null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
|
||||
Status.Changed += OnStatusChanged;
|
||||
Status.EnsureStarted();
|
||||
}
|
||||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
// The HeadOutlet is rendered statically, so <PageTitle> cannot reach it from this non-prerendered page.
|
||||
var title = Title;
|
||||
if (title != _documentTitle)
|
||||
{
|
||||
_documentTitle = title;
|
||||
JS.Set("document.title", title);
|
||||
}
|
||||
|
||||
SetLeaveGuard(IsConnectionActive);
|
||||
_lastRenderTimestamp = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// While enabled, the browser asks before a reload, closing the tab or clicking the title (which reloads the
|
||||
/// page) cancels the connection.
|
||||
/// </summary>
|
||||
private void SetLeaveGuard(bool enabled)
|
||||
{
|
||||
if (enabled == _isLeaveGuardActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_window ??= JS.Get<Window>("window");
|
||||
if (enabled)
|
||||
{
|
||||
_window.OnBeforeUnload += OnBeforeUnload;
|
||||
}
|
||||
else
|
||||
{
|
||||
_window.OnBeforeUnload -= OnBeforeUnload;
|
||||
}
|
||||
|
||||
_isLeaveGuardActive = enabled;
|
||||
}
|
||||
|
||||
private static void OnBeforeUnload(BeforeUnloadEvent beforeUnload)
|
||||
{
|
||||
beforeUnload.PreventDefault();
|
||||
|
||||
// Older browsers only show the dialog when a return value is set; its text is no longer displayed.
|
||||
beforeUnload.ReturnValue = string.Empty;
|
||||
}
|
||||
|
||||
private Task CreateAsync() => RunBusyAsync(
|
||||
PendingAction.Create,
|
||||
() =>
|
||||
{
|
||||
_copied = false;
|
||||
return Session.CreateAsync();
|
||||
});
|
||||
|
||||
private Task JoinAsync() => RunBusyAsync(
|
||||
PendingAction.Join,
|
||||
async () =>
|
||||
{
|
||||
var error = await Session.JoinAsync(_joinCode);
|
||||
if (error is null && Session.State == SessionState.Connected)
|
||||
{
|
||||
_joinCode = null;
|
||||
}
|
||||
|
||||
return error;
|
||||
});
|
||||
|
||||
private async Task RunBusyAsync(PendingAction pending, Func<Task<string?>> action)
|
||||
{
|
||||
if (IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_pending = pending;
|
||||
_error = null;
|
||||
try
|
||||
{
|
||||
_error = await action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (IsRateLimited(ex))
|
||||
{
|
||||
Logger.LogWarning("Connecting was rate limited by the server");
|
||||
_error = "Too many connections or connection attempts from your network. Please wait a minute and try again.";
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError(ex, "Connecting failed");
|
||||
_error = "Connecting to the server failed. Please try again.";
|
||||
}
|
||||
|
||||
await Session.ResetAsync();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_pending = PendingAction.None;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsRateLimited(Exception exception) =>
|
||||
exception is HttpRequestException { StatusCode: HttpStatusCode.TooManyRequests }
|
||||
|| (exception is AggregateException aggregate && aggregate.InnerExceptions.Any(IsRateLimited))
|
||||
|| (exception.InnerException is { } inner && IsRateLimited(inner));
|
||||
|
||||
private async Task OnJoinKeyDownAsync(KeyboardEventArgs args)
|
||||
{
|
||||
if (args.Key == "Enter")
|
||||
{
|
||||
await JoinAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnMessageKeyDownAsync(KeyboardEventArgs args)
|
||||
{
|
||||
if (args.Key == "Enter" && (args.CtrlKey || args.MetaKey))
|
||||
{
|
||||
await SendMessageAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendMessageAsync()
|
||||
{
|
||||
var text = _message;
|
||||
if (_sendingMessage || string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sendingMessage = true;
|
||||
try
|
||||
{
|
||||
var error = await Session.SendTextAsync(text);
|
||||
if (error is not null)
|
||||
{
|
||||
_error = error;
|
||||
}
|
||||
else if (_message == text)
|
||||
{
|
||||
_message = string.Empty;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_sendingMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnFilesSelectedAsync(InputFileChangeEventArgs args)
|
||||
{
|
||||
_dragging = false;
|
||||
IReadOnlyList<IBrowserFile> files;
|
||||
try
|
||||
{
|
||||
files = args.GetMultipleFiles(MaxFilesPerSelection);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
_error = $"Please select at most {MaxFilesPerSelection} files at once.";
|
||||
return;
|
||||
}
|
||||
|
||||
await Session.SendFilesAsync(files);
|
||||
}
|
||||
|
||||
private async Task CopyCodeAsync()
|
||||
{
|
||||
if (DisplayCode is not { } code)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_copied = await TryCopyAsync(code);
|
||||
if (!_copied)
|
||||
{
|
||||
_error = "Copying failed. Please copy the code manually.";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CopyEntryAsync(ChatEntry entry)
|
||||
{
|
||||
if (entry.Text is not { } text)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (await TryCopyAsync(text))
|
||||
{
|
||||
_copiedEntry = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
_error = "Copying failed. Please select and copy the text manually.";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> TryCopyAsync(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var navigator = JS.Get<Navigator>("navigator");
|
||||
using var clipboard = navigator.Clipboard;
|
||||
await clipboard.WriteText(text);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Copying to the clipboard failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Task DisconnectAsync() => Session.DisconnectAsync();
|
||||
|
||||
private async Task ResetAsync()
|
||||
{
|
||||
_error = null;
|
||||
_copied = false;
|
||||
_copiedEntry = null;
|
||||
_dragging = false;
|
||||
_message = null;
|
||||
await Session.ResetAsync();
|
||||
}
|
||||
|
||||
private void OnSessionChanged()
|
||||
{
|
||||
// Connections opening or closing change the server load, so don't wait for the next poll.
|
||||
if (_session is { } session && session.State != _observedState)
|
||||
{
|
||||
_observedState = session.State;
|
||||
_ = Status.RefreshAsync();
|
||||
}
|
||||
|
||||
RequestRender();
|
||||
}
|
||||
|
||||
private void OnStatusChanged() => RequestRender();
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
if (_session?.State is SessionState.Waiting or SessionState.Connected)
|
||||
{
|
||||
RequestRender();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders right away if the last render is long enough ago, otherwise once <see cref="MinRenderInterval" /> has
|
||||
/// passed; changes in between are coalesced into that render.
|
||||
/// </summary>
|
||||
private void RequestRender()
|
||||
{
|
||||
if (_isRenderScheduled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isRenderScheduled = true;
|
||||
var wait = MinRenderInterval - Stopwatch.GetElapsedTime(_lastRenderTimestamp);
|
||||
_ = InvokeAsync(async () =>
|
||||
{
|
||||
if (wait > TimeSpan.Zero)
|
||||
{
|
||||
await Task.Delay(wait);
|
||||
}
|
||||
|
||||
_isRenderScheduled = false;
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
783
DataTransfer.Client/Pages/Link.razor.css
Normal file
783
DataTransfer.Client/Pages/Link.razor.css
Normal file
|
|
@ -0,0 +1,783 @@
|
|||
/* ---------- Page heading ---------- */
|
||||
|
||||
.page-head {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.page-head h1 {
|
||||
font-size: 1.375rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.page-head p {
|
||||
max-width: 46rem;
|
||||
margin-top: 0.25rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ---------- Create / join ---------- */
|
||||
|
||||
.connect {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.connect-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.connect-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.connect-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.connect-text {
|
||||
flex: 1;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.connect-divider {
|
||||
position: relative;
|
||||
width: 1px;
|
||||
margin: 1.25rem 0;
|
||||
background-color: var(--border);
|
||||
}
|
||||
|
||||
.connect-divider span {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 0.25rem 0;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: var(--surface);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.join-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
max-width: 26rem;
|
||||
}
|
||||
|
||||
.code-input {
|
||||
font-family: var(--mono);
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.code-input::placeholder {
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
|
||||
.steps {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1rem 1.5rem;
|
||||
margin-top: 1.5rem;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.steps li {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
padding-top: 0.75rem;
|
||||
border-top: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.steps strong {
|
||||
display: block;
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.step-no {
|
||||
color: var(--accent);
|
||||
font-family: var(--mono);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.capacity-note {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--warning-soft);
|
||||
color: var(--warning);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.capacity-note ::deep .icon {
|
||||
flex: none;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin-top: 0.1875rem;
|
||||
}
|
||||
|
||||
/* ---------- Queue ---------- */
|
||||
|
||||
.queue-position {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.queue-number {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
min-width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
padding: 0 0.75rem;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--surface-2);
|
||||
font-family: var(--mono);
|
||||
font-size: 1.75rem;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.queue-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.queue-text strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.queue-text .muted {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* ---------- Waiting for the peer ---------- */
|
||||
|
||||
.waiting {
|
||||
max-width: 44rem;
|
||||
}
|
||||
|
||||
.waiting-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.code-display {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.code-chars {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--mono);
|
||||
user-select: all;
|
||||
}
|
||||
|
||||
.code-char {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 2.25rem;
|
||||
aspect-ratio: 4 / 5;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--surface-2);
|
||||
font-size: 1.375rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.code-sep {
|
||||
padding: 0 0.25rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.waiting-status {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 0.625rem;
|
||||
}
|
||||
|
||||
.waiting-status .spinner {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.waiting-expiry {
|
||||
margin-left: auto;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.countdown {
|
||||
margin-top: -0.75rem;
|
||||
}
|
||||
|
||||
.countdown .progress-bar {
|
||||
transition: width 1s linear;
|
||||
}
|
||||
|
||||
.countdown.is-low .progress-bar {
|
||||
background-color: var(--warning);
|
||||
}
|
||||
|
||||
/* ---------- Session status ---------- */
|
||||
|
||||
.session {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.session-main {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.75rem 2rem;
|
||||
padding: 0.875rem 1rem;
|
||||
}
|
||||
|
||||
.session-state {
|
||||
min-width: 8.5rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.session-facts {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem 2.25rem;
|
||||
}
|
||||
|
||||
.session-facts dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.safety-code {
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.session-hint {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border-top: 1px solid var(--border);
|
||||
border-radius: 0 0 var(--radius-lg) var(--radius-lg);
|
||||
background-color: var(--surface-2);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.session-hint ::deep .icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin-top: 0.125rem;
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.session-closed {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.session-closed .muted {
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
/* ---------- Workspace ---------- */
|
||||
|
||||
.workspace {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.workspace.is-closed {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
/* ---------- Send ---------- */
|
||||
|
||||
.send-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.dropzone {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.125rem;
|
||||
min-height: 10rem;
|
||||
padding: 1.25rem 1rem;
|
||||
border: 1.5px dashed var(--border-strong);
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--surface-2);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8125rem;
|
||||
text-align: center;
|
||||
transition: border-color 0.12s, background-color 0.12s;
|
||||
}
|
||||
|
||||
.dropzone strong {
|
||||
color: var(--text);
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dropzone.is-dragging {
|
||||
border-color: var(--accent);
|
||||
background-color: var(--accent-soft);
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.dropzone:not(.is-busy):hover {
|
||||
border-color: var(--accent);
|
||||
background-color: var(--accent-soft);
|
||||
}
|
||||
}
|
||||
|
||||
.dropzone:has(:focus-visible) {
|
||||
border-color: var(--accent);
|
||||
box-shadow: var(--focus-ring);
|
||||
}
|
||||
|
||||
.dropzone.is-busy {
|
||||
border-style: solid;
|
||||
border-color: var(--border);
|
||||
background-color: var(--surface-2);
|
||||
}
|
||||
|
||||
.dropzone-browse {
|
||||
color: var(--accent);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.dropzone ::deep .dropzone-icon {
|
||||
width: 1.75rem;
|
||||
height: 1.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--accent);
|
||||
stroke-width: 1.75;
|
||||
}
|
||||
|
||||
.dropzone-spinner {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
margin-bottom: 0.625rem;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* The native file input covers the whole zone, so clicking and dropping both work without JavaScript. */
|
||||
.dropzone ::deep .dropzone-input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropzone.is-busy ::deep .dropzone-input {
|
||||
cursor: progress;
|
||||
}
|
||||
|
||||
.send-message {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.send-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
/* ---------- Transfer log ---------- */
|
||||
|
||||
.log {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: min(70vh, 40rem);
|
||||
min-height: 22rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.log-summary {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-summary > span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.log-summary ::deep .icon {
|
||||
width: 0.875rem;
|
||||
height: 0.875rem;
|
||||
}
|
||||
|
||||
.log-scroll {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column-reverse;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.log-entries {
|
||||
/* Keeps short logs at the top while column-reverse anchors the scroll position at the newest entry. */
|
||||
margin-bottom: auto;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
max-width: 22rem;
|
||||
margin: auto;
|
||||
padding: 2rem 1.5rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.log-empty strong {
|
||||
color: var(--text);
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.log-empty ::deep .icon {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--border-strong);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.entry {
|
||||
display: grid;
|
||||
grid-template-columns: 1.75rem minmax(0, 1fr) auto 5.5rem;
|
||||
grid-template-areas: "dir body meta action";
|
||||
align-items: start;
|
||||
gap: 0.25rem 1rem;
|
||||
padding: 0.625rem 1rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.entry:not(.entry-system):hover {
|
||||
background-color: var(--surface-2);
|
||||
}
|
||||
}
|
||||
|
||||
.entry-dir {
|
||||
grid-area: dir;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 1.75rem;
|
||||
height: 1.75rem;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.entry-dir ::deep .icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
}
|
||||
|
||||
.entry-out .entry-dir {
|
||||
background-color: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.entry-in .entry-dir {
|
||||
background-color: var(--success-soft);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.entry-body {
|
||||
grid-area: body;
|
||||
min-width: 0;
|
||||
padding-top: 0.1875rem;
|
||||
}
|
||||
|
||||
.entry-file {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.entry-file ::deep .icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.entry-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.entry-text {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.entry-progress {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.entry-error {
|
||||
margin-top: 0.125rem;
|
||||
color: var(--danger);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.entry-warning {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.375rem;
|
||||
margin-top: 0.25rem;
|
||||
padding: 0.375rem 0.5rem;
|
||||
border: 1px solid var(--warning);
|
||||
border-radius: var(--radius);
|
||||
background-color: var(--warning-soft);
|
||||
color: var(--text);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.entry-warning ::deep .icon {
|
||||
flex: none;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin-top: 0.0625rem;
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.entry-meta {
|
||||
grid-area: meta;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 1rem;
|
||||
padding-top: 0.3125rem;
|
||||
color: var(--text-muted);
|
||||
font-family: var(--mono);
|
||||
font-size: 0.8125rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.entry-size {
|
||||
min-width: 4.75rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.entry-time {
|
||||
min-width: 3.25rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.entry-action {
|
||||
grid-area: action;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-top: 0.125rem;
|
||||
}
|
||||
|
||||
.entry-action .tag {
|
||||
margin-top: 0.0625rem;
|
||||
}
|
||||
|
||||
.entry-system {
|
||||
grid-template-columns: 1.75rem minmax(0, 1fr) auto;
|
||||
grid-template-areas: "dir body meta";
|
||||
background-color: var(--surface-2);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.entry-system.is-error {
|
||||
background-color: var(--danger-soft);
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
/* ---------- Small screens ---------- */
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.workspace {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.log {
|
||||
height: auto;
|
||||
min-height: 16rem;
|
||||
max-height: 70vh;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.connect {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.connect-option {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.connect-divider {
|
||||
width: auto;
|
||||
height: 1px;
|
||||
margin: 0 1.25rem;
|
||||
}
|
||||
|
||||
.connect-divider span {
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.join-row {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.steps {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.waiting-body {
|
||||
padding: 1.25rem 1rem;
|
||||
}
|
||||
|
||||
.code-chars {
|
||||
gap: 0.1875rem;
|
||||
}
|
||||
|
||||
.code-char {
|
||||
width: clamp(1.5rem, 6.8vw, 2.25rem);
|
||||
font-size: clamp(1rem, 4.6vw, 1.375rem);
|
||||
}
|
||||
|
||||
.code-sep {
|
||||
padding: 0 0.125rem;
|
||||
}
|
||||
|
||||
.waiting-expiry {
|
||||
margin-left: 0;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
.session-main {
|
||||
gap: 0.75rem 1.5rem;
|
||||
}
|
||||
|
||||
.session-facts {
|
||||
flex-basis: 100%;
|
||||
order: 1;
|
||||
gap: 0.5rem 1.5rem;
|
||||
}
|
||||
|
||||
.session-closed {
|
||||
flex-basis: 100%;
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.session-state {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.entry {
|
||||
grid-template-columns: 1.75rem minmax(0, 1fr) auto;
|
||||
grid-template-areas:
|
||||
"dir body action"
|
||||
"dir meta action";
|
||||
column-gap: 0.75rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
}
|
||||
|
||||
.entry-system {
|
||||
grid-template-areas:
|
||||
"dir body"
|
||||
"dir meta";
|
||||
grid-template-columns: 1.75rem minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.entry-meta {
|
||||
justify-content: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding-top: 0;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.entry-size,
|
||||
.entry-time {
|
||||
min-width: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.entry-size:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.entry-action {
|
||||
align-self: center;
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue