Send files directly between devices over the internet - no cloud storage, no size limits.
TypeScript cross-platformdata-transferdecentralizedfile-sharingfile-transferhole-punchingopen-sourcep2ppeer-to-peerprivacyprivacy-tools
show transfer speed and time remaining (#77)
Denis Lupookov355efb0be65d
diff --git a/apps/desktop/src/renderer/pages/ReceivePage/ReceiveConnectedView.tsx b/apps/desktop/src/renderer/pages/ReceivePage/ReceiveConnectedView.tsxindex 417b28d..8ddc8f1 100644--- a/apps/desktop/src/renderer/pages/ReceivePage/ReceiveConnectedView.tsx+++ b/apps/desktop/src/renderer/pages/ReceivePage/ReceiveConnectedView.tsx@@ -6,6 +6,7 @@ import { useToast } from '../../components/Toast'import { isAskEveryTime } from '../../lifecycle/downloadLocationStorage'import {clearSession,+ formatTransferRate,getDownloadRowLabels,getPrimaryDownloadLabel,getOfferKey,@@ -92,6 +93,8 @@ export function ReceiveConnectedView() {key={rowKey(row)}row={row}states={downloads.states}+ rates={downloads.rates}+ rateLabelFor={(rate) => formatTransferRate(rate, t)}labelsFor={(display) => getDownloadRowLabels(t, display)}transferActive={downloads.isDownloading}isFirst={index === 0}diff --git a/apps/desktop/src/renderer/pages/SendPage/ShareView.tsx b/apps/desktop/src/renderer/pages/SendPage/ShareView.tsxindex a7cf3f9..7b1b7f5 100644--- a/apps/desktop/src/renderer/pages/SendPage/ShareView.tsx+++ b/apps/desktop/src/renderer/pages/SendPage/ShareView.tsx@@ -269,6 +269,7 @@ export function ShareView() {label={row.name}subtitle={row.subtitle}subtitleTone={row.subtitleTone}+ status={row.status}progressPercent={row.progressPercent}trailing={row.action === 'pair' ? (diff --git a/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx b/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsxindex b2f9646..45484ba 100644--- a/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx+++ b/apps/mobile/src/transfer/receive/views/ReceiveIncomingView.tsx@@ -2,6 +2,7 @@ import { Linking, View, StyleSheet } from 'react-native'import * as Clipboard from 'expo-clipboard'import { DownloadRow, ReceivedTextRow, RowGroup, rowKey, useTheme } from '@altersend/components'import {+ formatTransferRate,getDownloadRowLabels,getOfferKey,useCopiedFlag,@@ -44,6 +45,8 @@ export function ReceiveIncomingView() {key={rowKey(row)}row={row}states={downloads.states}+ rates={downloads.rates}+ rateLabelFor={(rate) => formatTransferRate(rate, t)}labelsFor={(display) => getDownloadRowLabels(t, display)}transferActive={downloads.isDownloading}isFirst={index === 0}diff --git a/apps/mobile/src/transfer/send/views/ShareView.tsx b/apps/mobile/src/transfer/send/views/ShareView.tsxindex 2dee9ca..560373a 100644--- a/apps/mobile/src/transfer/send/views/ShareView.tsx+++ b/apps/mobile/src/transfer/send/views/ShareView.tsx@@ -264,6 +264,7 @@ export function ShareView() {label={row.name}subtitle={row.subtitle}subtitleTone={row.subtitleTone}+ status={row.status}progressPercent={row.progressPercent}trailing={row.action === 'pair' ? (diff --git a/apps/web/src/screens/DownloadScreen/DownloadScreen.tsx b/apps/web/src/screens/DownloadScreen/DownloadScreen.tsxindex 7f92ff7..48fecf5 100644--- a/apps/web/src/screens/DownloadScreen/DownloadScreen.tsx+++ b/apps/web/src/screens/DownloadScreen/DownloadScreen.tsx@@ -9,7 +9,12 @@ import {useTheme} from '@altersend/components'import { ArrowLeftIcon, CheckIcon, DownloadIcon, PlayIcon } from '@altersend/components/icons'-import { getDownloadRowLabels, getPrimaryDownloadLabel, useCopiedFlag } from '@altersend/domain'+import {+ formatTransferRate,+ getDownloadRowLabels,+ getPrimaryDownloadLabel,+ useCopiedFlag+} from '@altersend/domain'import { useEffect, useState } from 'react'import { useTranslation } from '@altersend/locales'import {@@ -82,6 +87,8 @@ export function DownloadScreen({key={rowKey(row)}row={row}states={summary.states}+ rates={summary.rates}+ rateLabelFor={(rate) => formatTransferRate(rate, t)}labelsFor={(display) => getDownloadRowLabels(t, display)}transferActive={summary.isDownloading}isFirst={index === 0}diff --git a/apps/web/src/screens/DownloadScreen/useDownloadSummary.ts b/apps/web/src/screens/DownloadScreen/useDownloadSummary.tsindex d2be27d..d12eb9f 100644--- a/apps/web/src/screens/DownloadScreen/useDownloadSummary.ts+++ b/apps/web/src/screens/DownloadScreen/useDownloadSummary.ts@@ -6,10 +6,12 @@ import {getPrimaryDownloadAction,groupReceiveRows,isResumable,+ useDownloadRates,type DownloadItemState,type DownloadTotals,type PrimaryDownloadAction,- type ReceiveRow+ type ReceiveRow,+ type TransferRate} from '@altersend/domain'import type { TextOffer } from '../../transfer/peerProtocol'import type { TransferFile } from '../../types'@@ -19,6 +21,7 @@ export interface DownloadSummary {rows: ReceiveRow[]states: Record<string, DownloadItemState>totals: DownloadTotals+ rates: Record<string, TransferRate>count: numbertextCount: numberisDownloading: boolean@@ -27,7 +30,7 @@ export interface DownloadSummary {}export function useDownloadSummary(files: TransferFile[], texts: TextOffer[]): DownloadSummary {- return useMemo(() => {+ const summary = useMemo(() => {const offers = files.map((file) => file.offer)const states = toDownloadStates(files)const totals = getDownloadTotals(offers, states)@@ -56,4 +59,8 @@ export function useDownloadSummary(files: TransferFile[], texts: TextOffer[]): D})}}, [files, texts])++ const rates = useDownloadRates(summary.states, summary.isDownloading)++ return { ...summary, rates }}diff --git a/packages/components/src/components/DownloadRow/DownloadRow.tsx b/packages/components/src/components/DownloadRow/DownloadRow.tsxindex d5bc70a..fcc4663 100644--- a/packages/components/src/components/DownloadRow/DownloadRow.tsx+++ b/packages/components/src/components/DownloadRow/DownloadRow.tsx@@ -5,15 +5,17 @@ import {getDownloadRowDisplay,getFolderRowAction,getFolderRowDisplay,+ getFolderTransferRate,getOfferKey,type DownloadItemState,type DownloadRowDisplay,type DownloadRowAction,type DownloadRowLabels,- type ReceiveRow+ type ReceiveRow,+ type TransferRate} from '@altersend/domain'import type { IncomingFileOffer } from '@altersend/core'-import { LinkRow } from '../LinkRow'+import { LinkRow, type LinkRowStatus } from '../LinkRow'import { ChevronRightIcon, FolderIcon } from '../../icons'import { useTheme } from '../../theme'import { RowActionButton } from './RowActionButton'@@ -28,6 +30,8 @@ export function rowKey(row: ReceiveRow): string {export interface DownloadRowProps {row: ReceiveRowstates: Record<string, DownloadItemState>+ rates: Record<string, TransferRate>+ rateLabelFor: (rate: TransferRate | undefined) => string | undefinedlabelsFor: (display: DownloadRowDisplay) => DownloadRowLabelstransferActive: booleanisFirst?: boolean@@ -42,14 +46,28 @@ export interface DownloadRowProps {type RowHandlers = Pick<DownloadRowProps, 'onResume' | 'onPause' | 'onOpen'>-interface FileRowProps extends RowHandlers {+type RowPresentation = Pick<+ DownloadRowProps,+ | 'states'+ | 'rates'+ | 'rateLabelFor'+ | 'labelsFor'+ | 'transferActive'+ | 'isFirst'+ | 'compact'+ | 'standalone'+>++interface FileRowProps extends RowHandlers, RowPresentation {offer: FileOffer- states: Record<string, DownloadItemState>- labelsFor: (display: DownloadRowDisplay) => DownloadRowLabels- transferActive: boolean- isFirst?: boolean- compact?: boolean- standalone?: boolean+}++function toRowStatus(+ display: DownloadRowDisplay,+ labels: DownloadRowLabels+): LinkRowStatus | undefined {+ if (!labels.status) return undefined+ return { label: labels.status, tone: display.status.tone, detail: display.rateLabel }}function runRowAction(@@ -78,6 +96,8 @@ export function DownloadRow(props: DownloadRowProps) {function FileRow({offer,states,+ rates,+ rateLabelFor,labelsFor,transferActive,isFirst = false,@@ -87,8 +107,9 @@ function FileRow({onPause,onOpen}: FileRowProps) {- const state = states[getOfferKey(offer)]- const display = getDownloadRowDisplay(offer, state, transferActive)+ const key = getOfferKey(offer)+ const state = states[key]+ const display = getDownloadRowDisplay(offer, state, transferActive, rateLabelFor(rates[key]))const labels = labelsFor(display)const action = getDownloadRowAction(display, state)@@ -102,7 +123,7 @@ function FileRow({label={offer.name}size={offer.size}description={display.description}- status={labels.status ? { label: labels.status, tone: display.status.tone } : undefined}+ status={toRowStatus(display, labels)}progressPercent={display.progressPercent}trailing={action ? (@@ -120,6 +141,8 @@ function FileRow({function FolderRow({folder,states,+ rates,+ rateLabelFor,labelsFor,transferActive,isFirst = false,@@ -133,7 +156,11 @@ function FolderRow({}: DownloadRowProps & { folder: Extract<ReceiveRow, { kind: 'folder' }> }) {const { theme } = useTheme()const [expanded, setExpanded] = useState(false)- const display = getFolderRowDisplay(folder.offers, states)+ const display = getFolderRowDisplay(+ folder.offers,+ states,+ rateLabelFor(getFolderTransferRate(folder.offers, states, rates))+ )const labels = labelsFor(display)const action = getFolderRowAction(folder.offers, states)@@ -148,7 +175,7 @@ function FolderRow({label={folder.name}size={folder.totalSize}description={display.description}- status={labels.status ? { label: labels.status, tone: display.status.tone } : undefined}+ status={toRowStatus(display, labels)}progressPercent={display.progressPercent}onPress={() => setExpanded((open) => !open)}trailing={@@ -177,6 +204,8 @@ function FolderRow({key={getOfferKey(offer)}offer={offer}states={states}+ rates={rates}+ rateLabelFor={rateLabelFor}labelsFor={labelsFor}transferActive={transferActive}onResume={onResume}diff --git a/packages/components/src/components/LinkRow/LinkRow.tsx b/packages/components/src/components/LinkRow/LinkRow.tsxindex 7525417..5dce6a7 100644--- a/packages/components/src/components/LinkRow/LinkRow.tsx+++ b/packages/components/src/components/LinkRow/LinkRow.tsx@@ -10,6 +10,12 @@ import { formatFileSize } from '@altersend/domain'export type LinkRowStatusTone = 'muted' | 'active' | 'success'export type LinkRowProgressState = 'waiting' | 'uploading' | 'completed'+export interface LinkRowStatus {+ label: string+ tone?: LinkRowStatusTone+ detail?: string+}+interface LinkRowBaseProps {icon?: ReactNodeiconBackground?: string@@ -32,7 +38,7 @@ interface LinkRowBaseProps {standalone?: booleanalignTop?: booleandisabled?: boolean- status?: { label: string; tone?: LinkRowStatusTone }+ status?: LinkRowStatusprogress?: LinkRowProgressStateprogressPercent?: number}@@ -224,15 +230,22 @@ export function LinkRow({</html.div>{status ? (- <html.div style={styles.statusGroup}>- {status.tone === 'success' ? (- <CheckIcon size={14} color={theme.colors.colorSuccess} />- ) : (- <html.div style={[styles.statusDot, statusToneStyle[status.tone ?? 'muted']]} />- )}- <html.p style={[styles.statusLabel, statusLabelToneStyle[status.tone ?? 'muted']]}>- {status.label}- </html.p>+ <html.div style={styles.statusColumn}>+ <html.div style={styles.statusGroup}>+ {status.tone === 'success' ? (+ <CheckIcon size={14} color={theme.colors.colorSuccess} />+ ) : (+ <html.div style={[styles.statusDot, statusToneStyle[status.tone ?? 'muted']]} />+ )}+ <html.p+ style={[styles.statusLabel, statusLabelToneStyle[status.tone ?? 'muted']]}+ >+ {status.label}+ </html.p>+ </html.div>+ {status.detail ? (+ <html.p style={styles.statusDetail}>{status.detail}</html.p>+ ) : null}</html.div>) : null}</html.div>diff --git a/packages/components/src/components/LinkRow/styles.ts b/packages/components/src/components/LinkRow/styles.tsindex d001b69..ca50dac 100644--- a/packages/components/src/components/LinkRow/styles.ts+++ b/packages/components/src/components/LinkRow/styles.ts@@ -165,6 +165,13 @@ export const styles = css.create({subtitleInfo: {color: tokens.colorInfo},+ statusColumn: {+ display: 'flex',+ flexDirection: 'column',+ alignItems: 'flex-end',+ gap: tokens.space05,+ flexShrink: 0+ },statusGroup: {display: 'flex',flexDirection: 'row',@@ -172,6 +179,14 @@ export const styles = css.create({gap: tokens.space15,flexShrink: 0},+ statusDetail: {+ margin: 0,+ color: tokens.colorTextMuted,+ fontFamily: tokens.fontFamilySans,+ fontSize: tokens.fontSizeSm,+ lineHeight: tokens.lineHeightNormal,+ whiteSpace: 'nowrap'+ },statusDot: {width: tokens.space15,height: tokens.space15,diff --git a/packages/domain/src/format.test.ts b/packages/domain/src/format.test.tsindex beb5ec7..6835619 100644--- a/packages/domain/src/format.test.ts+++ b/packages/domain/src/format.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { formatFileSize } from './format'+import { formatDuration, formatFileSize, formatTransferRate, formatTransferSpeed } from './format'describe('formatFileSize', () => {it('formats bytes when under 1 KB', () => {@@ -21,3 +21,65 @@ describe('formatFileSize', () => {expect(formatFileSize(1024 ** 3)).toBe('1.0 GB')})})++describe('formatTransferSpeed', () => {+ it('appends a per-second suffix to the transferred size', () => {+ expect(formatTransferSpeed(1024 * 1024)).toBe('1.0 MB/s')+ expect(formatTransferSpeed(512)).toBe('512 B/s')+ })+})++const EN_US: Record<string, string> = {+ 'common:transfer.timeLeft': '{{duration}} left',+ 'common:transfer.durationSeconds': '{{seconds}}s',+ 'common:transfer.durationMinutes': '{{minutes}}m',+ 'common:transfer.durationMinutesSeconds': '{{minutes}}m {{seconds}}s',+ 'common:transfer.durationHours': '{{hours}}h',+ 'common:transfer.durationHoursMinutes': '{{hours}}h {{minutes}}m'+}++const t = (key: string, vars?: Record<string, unknown>) =>+ (EN_US[key] ?? key).replace(/\{\{(\w+)\}\}/g, (_, name: string) => String(vars?.[name] ?? ''))++describe('formatDuration', () => {+ it('formats seconds under a minute', () => {+ expect(formatDuration(0, t)).toBe('1s')+ expect(formatDuration(45.4, t)).toBe('45s')+ })++ it('adds seconds only for short minute spans', () => {+ expect(formatDuration(150, t)).toBe('2m 30s')+ expect(formatDuration(1800, t)).toBe('30m')+ })++ it('formats hours', () => {+ expect(formatDuration(3600, t)).toBe('1h')+ expect(formatDuration(5400, t)).toBe('1h 30m')+ })++ it('routes every unit through the catalog', () => {+ const localized = (key: string, vars?: Record<string, unknown>) =>+ `${key}:${JSON.stringify(vars)}`+ expect(formatDuration(45, localized)).toBe('common:transfer.durationSeconds:{"seconds":45}')+ expect(formatDuration(5400, localized)).toBe(+ 'common:transfer.durationHoursMinutes:{"hours":1,"minutes":30}'+ )+ })+})++describe('formatTransferRate', () => {+ it('returns nothing while throughput is unknown', () => {+ expect(formatTransferRate({}, t)).toBeUndefined()+ expect(formatTransferRate({ bytesPerSecond: 0 }, t)).toBeUndefined()+ })++ it('shows speed alone when no estimate is available', () => {+ expect(formatTransferRate({ bytesPerSecond: 1024 * 1024 }, t)).toBe('1.0 MB/s')+ })++ it('joins speed and remaining time', () => {+ expect(formatTransferRate({ bytesPerSecond: 1024 * 1024, etaSeconds: 90 }, t)).toBe(+ '1.0 MB/s · 1m 30s left'+ )+ })+})diff --git a/packages/domain/src/format.ts b/packages/domain/src/format.tsindex 21143c3..63cc273 100644--- a/packages/domain/src/format.ts+++ b/packages/domain/src/format.ts@@ -1,4 +1,5 @@import type { Translate } from './i18n'+import type { TransferRate } from './transfer/rate'export type InviteStatus = 'inviting' | 'sent' | 'offline'@@ -23,6 +24,42 @@ export function formatFileSize(bytes: number): string {return `${(bytes / 1024 ** 3).toFixed(1)} GB`}+export function formatTransferSpeed(bytesPerSecond: number): string {+ return `${formatFileSize(Math.round(bytesPerSecond))}/s`+}++const PRECISE_MINUTES_BELOW = 10++export function formatDuration(seconds: number, t: Translate): string {+ const total = Math.max(1, Math.round(seconds))+ if (total < 60) return t('common:transfer.durationSeconds', { seconds: total })++ const minutes = Math.floor(total / 60)+ if (minutes < 60) {+ const restSeconds = total % 60+ return minutes < PRECISE_MINUTES_BELOW && restSeconds > 0+ ? t('common:transfer.durationMinutesSeconds', { minutes, seconds: restSeconds })+ : t('common:transfer.durationMinutes', { minutes })+ }++ const hours = Math.floor(minutes / 60)+ const restMinutes = minutes % 60+ return restMinutes > 0+ ? t('common:transfer.durationHoursMinutes', { hours, minutes: restMinutes })+ : t('common:transfer.durationHours', { hours })+}++export function formatTransferRate(+ rate: TransferRate | undefined,+ t: Translate+): string | undefined {+ if (!rate?.bytesPerSecond) return undefined++ const speed = formatTransferSpeed(rate.bytesPerSecond)+ if (rate.etaSeconds === undefined) return speed+ return `${speed} · ${t('common:transfer.timeLeft', { duration: formatDuration(rate.etaSeconds, t) })}`+}+export function formatRelativeTime(timestamp: number, now: number = Date.now()): string {const diff = Math.max(0, now - timestamp)const minutes = Math.floor(diff / 60_000)diff --git a/packages/domain/src/receive/downloadModel.test.ts b/packages/domain/src/receive/downloadModel.test.tsindex a798d0f..2714ea0 100644--- a/packages/domain/src/receive/downloadModel.test.ts+++ b/packages/domain/src/receive/downloadModel.test.ts@@ -5,8 +5,10 @@ import {applyDownloadMessage,getDownloadTotals,getFolderRowDisplay,+ getFolderTransferRate,getDownloadRowAction,getDownloadRowDisplay,+ getActiveDownloadProgress,isResumable,canStopDownload,getFolderRowAction,@@ -549,3 +551,87 @@ describe('stopping a download that never started', () => {expect(getDownloadRowDisplay(offer('/a.bin'), next['/a.bin']).status.kind).toBe('paused')})})++describe('transfer rate on rows', () => {+ const file = offer('/a.bin')++ it('reports the rate separately from the transferred bytes', () => {+ const row = getDownloadRowDisplay(file, state('downloading', 40), true, '2.0 MB/s · 30s left')+ expect(row.description).toBe('40 B / 100 B')+ expect(row.rateLabel).toBe('2.0 MB/s · 30s left')+ })++ it('leaves the rate unset when none was measured', () => {+ const row = getDownloadRowDisplay(file, state('downloading', 40), true)+ expect(row.description).toBe('40 B / 100 B')+ expect(row.rateLabel).toBeUndefined()+ })++ it('omits the rate on paused rows', () => {+ const paused: DownloadItemState = {+ status: 'failed',+ bytesTransferred: 40,+ totalBytes: 100,+ resumable: true,+ savedTo: '/tmp/a.bin'+ }+ expect(getDownloadRowDisplay(file, paused, false, '2.0 MB/s').rateLabel).toBeUndefined()+ })++ it('reports the rate on folder rows with files in flight', () => {+ const offers = [offer('/Photos/a.png'), offer('/Photos/b.png')]+ const row = getFolderRowDisplay(+ offers,+ { '/Photos/a.png': state('completed', 100), '/Photos/b.png': state('downloading', 50) },+ '4.0 MB/s · 10s left'+ )+ expect(row.description).toBe('150 B / 200 B')+ expect(row.rateLabel).toBe('4.0 MB/s · 10s left')+ })++ it('omits the rate on folder rows with nothing in flight', () => {+ const offers = [offer('/Photos/a.png'), offer('/Photos/b.png')]+ const row = getFolderRowDisplay(+ offers,+ { '/Photos/a.png': state('completed', 100) },+ '4.0 MB/s'+ )+ expect(row.rateLabel).toBeUndefined()+ })+})++describe('getActiveDownloadProgress', () => {+ it('tracks only downloading files with a known size', () => {+ expect(+ getActiveDownloadProgress({+ '/a.bin': state('downloading', 40),+ '/b.bin': state('completed', 100),+ '/c.bin': { status: 'downloading', bytesTransferred: 10, totalBytes: 0 }+ })+ ).toEqual({ '/a.bin': { bytesTransferred: 40, totalBytes: 100 } })+ })+})++describe('getFolderTransferRate', () => {+ const offers = [offer('/Photos/a.png'), offer('/Photos/b.png')]++ it('ignores rates left over from files that already completed', () => {+ const rate = getFolderTransferRate(+ offers,+ { '/Photos/a.png': state('completed', 100), '/Photos/b.png': state('downloading', 20) },+ { '/Photos/a.png': { bytesPerSecond: 900 }, '/Photos/b.png': { bytesPerSecond: 100 } }+ )+ expect(rate.bytesPerSecond).toBe(100)+ expect(rate.etaSeconds).toBe(0.8)+ })++ it('sums the rates of every file still in flight', () => {+ const rate = getFolderTransferRate(+ offers,+ { '/Photos/a.png': state('downloading', 50), '/Photos/b.png': state('downloading', 50) },+ { '/Photos/a.png': { bytesPerSecond: 40 }, '/Photos/b.png': { bytesPerSecond: 60 } }+ )+ expect(rate.bytesPerSecond).toBe(100)+ expect(rate.etaSeconds).toBe(1)+ })+})diff --git a/packages/domain/src/receive/downloadModel.ts b/packages/domain/src/receive/downloadModel.tsindex 0a22449..eb35bce 100644--- a/packages/domain/src/receive/downloadModel.ts+++ b/packages/domain/src/receive/downloadModel.ts@@ -1,5 +1,6 @@import type { DownloadFileRequest, IncomingFileOffer, RendererTransferEvent } from '@altersend/core'import { formatFileSize } from '../format'+import { sumTransferRates, type TransferProgress, type TransferRate } from '../transfer/rate'export type DownloadStatus = 'idle' | 'downloading' | 'completed' | 'failed'@@ -23,6 +24,7 @@ export type DownloadRowStatusTone = 'muted' | 'active' | 'success'export interface DownloadRowDisplay {description: string | undefined+ rateLabel?: stringprogressPercent: number | undefinedstatus: {kind: 'saved' | 'failed' | 'paused' | 'resuming' | 'progress' | 'ready' | 'waiting'@@ -53,6 +55,39 @@ function getProgressPercent(bytesTransferred: number, totalBytes: number) {return Math.max(0, Math.min(100, Math.round((bytesTransferred / totalBytes) * 100)))}+function getRemainingBytes(+ offers: IncomingFileOffer[],+ states: Record<string, DownloadItemState>+): number {+ const totals = getDownloadTotals(offers, states)+ return Math.max(0, totals.totalBytes - totals.bytesTransferred)+}++export function getFolderTransferRate(+ offers: IncomingFileOffer[],+ states: Record<string, DownloadItemState>,+ rates: Record<string, TransferRate>+): TransferRate {+ const active = offers.filter((offer) => states[getOfferKey(offer)]?.status === 'downloading')+ return sumTransferRates(+ active.map((offer) => rates[getOfferKey(offer)]),+ getRemainingBytes(offers, states)+ )+}++export function getActiveDownloadProgress(+ states: Record<string, DownloadItemState>+): Record<string, TransferProgress> {+ const progress: Record<string, TransferProgress> = {}++ for (const [key, state] of Object.entries(states)) {+ if (state.status !== 'downloading' || state.totalBytes <= 0) continue+ progress[key] = { bytesTransferred: state.bytesTransferred, totalBytes: state.totalBytes }+ }++ return progress+}+export function createDownloadStateMap(current: Record<string, DownloadItemState>,files: IncomingFileOffer[]@@ -79,7 +114,8 @@ function stoppedRowKind(state: DownloadItemState): DownloadRowDisplay['status'][export function getDownloadRowDisplay(file: IncomingFileOffer,state: DownloadItemState | undefined,- transferActive = false+ transferActive = false,+ rateLabel?: string): DownloadRowDisplay {const totalBytes = state?.totalBytes || (file.kind === 'file' ? file.size : 0)const percent = getProgressPercent(state?.bytesTransferred ?? 0, totalBytes)@@ -128,6 +164,7 @@ export function getDownloadRowDisplay(if (isActive) {return {description: `${formatFileSize(state!.bytesTransferred)} / ${formatFileSize(totalBytes)}`,+ rateLabel,progressPercent: percent,status: { kind: 'progress', tone: percent > 0 ? 'active' : 'muted' },percent,@@ -451,7 +488,8 @@ export function groupReceiveRows(offers: IncomingFileOffer[]): ReceiveRow[] {export function getFolderRowDisplay(offers: FileOffer[],- states: Record<string, DownloadItemState>+ states: Record<string, DownloadItemState>,+ rateLabel?: string): DownloadRowDisplay {const totals = getDownloadTotals(offers, states)const anyFailed = offers.some((offer) => {@@ -485,6 +523,7 @@ export function getFolderRowDisplay(if (totals.activeCount > 0 || totals.completedCount > 0 || anyPaused) {return {description: `${formatFileSize(totals.bytesTransferred)} / ${formatFileSize(totals.totalBytes)}`,+ rateLabel: totals.activeCount > 0 ? rateLabel : undefined,progressPercent: totals.percent,status: {kind: totals.activeCount === 0 && anyPaused ? 'paused' : 'progress',diff --git a/packages/domain/src/receive/useReceiveDownloads.ts b/packages/domain/src/receive/useReceiveDownloads.tsindex cec536d..afe1db0 100644--- a/packages/domain/src/receive/useReceiveDownloads.ts+++ b/packages/domain/src/receive/useReceiveDownloads.ts@@ -2,9 +2,12 @@ import { useCallback, useMemo } from 'react'import type { IncomingFileOffer } from '@altersend/core'import { useTransferStore } from '../transfer/store'import { downloadFiles, pauseDownload } from '../transfer/commands'+import { useTransferRates } from '../transfer/useTransferRates'+import type { TransferRate } from '../transfer/rate'import {createDirectoryDownloadRequests,createSingleDownloadRequest,+ getActiveDownloadProgress,getDownloadTotals,getOfferKey,canStopDownload,@@ -21,6 +24,14 @@ import {export type ReceiveFileOffer = Extract<IncomingFileOffer, { kind: 'file' }>export type ReceiveTextOffer = Extract<IncomingFileOffer, { kind: 'text' }>+export function useDownloadRates(+ states: Record<string, DownloadItemState>,+ enabled: boolean+): Record<string, TransferRate> {+ const progress = useMemo(() => getActiveDownloadProgress(states), [states])+ return useTransferRates(progress, enabled)+}+export interface ReceiveDownloads {rows: ReceiveRow[]fileOffers: ReceiveFileOffer[]@@ -29,6 +40,7 @@ export interface ReceiveDownloads {pausedOffers: ReceiveFileOffer[]states: Record<string, DownloadItemState>totals: DownloadTotals+ rates: Record<string, TransferRate>hasFiles: booleanisDownloading: booleanallDownloaded: boolean@@ -64,6 +76,7 @@ export function useReceiveDownloads(): ReceiveDownloads {)const isDownloading = totals.activeCount > 0+ const rates = useDownloadRates(states, isDownloading)const hasFiles = fileOffers.length > 0const allDownloaded = hasFiles && totals.completedCount === fileOffers.lengthconst canResumeAll =@@ -85,6 +98,7 @@ export function useReceiveDownloads(): ReceiveDownloads {pausedOffers,states,totals,+ rates,hasFiles,isDownloading,allDownloaded,diff --git a/packages/domain/src/send/peerListUi.ts b/packages/domain/src/send/peerListUi.tsindex 2469689..58a39e7 100644--- a/packages/domain/src/send/peerListUi.ts+++ b/packages/domain/src/send/peerListUi.ts@@ -1,5 +1,6 @@import type { ConnectedPeer, PeerDownloadEvent, PeerListStatus, PeerStatusData } from './shareModel'import { derivePeerStatus } from './shareModel'+import type { TransferProgress } from '../transfer/rate'export type PeerListEntryDetail =| { type: 'failed-file'; fileName: string }@@ -40,6 +41,20 @@ export function applyPairState(})}+export function getActivePeerProgress(entries: PeerListEntry[]): Record<string, TransferProgress> {+ const progress: Record<string, TransferProgress> = {}++ for (const entry of entries) {+ if (entry.status !== 'downloading' || entry.detail?.type !== 'progress-bytes') continue+ progress[entry.peerKey] = {+ bytesTransferred: entry.detail.transferredBytes,+ totalBytes: entry.detail.totalBytes+ }+ }++ return progress+}+function getStatusDetail(data: PeerStatusData): PeerListEntryDetail | null {switch (data.status) {case 'failed':diff --git a/packages/domain/src/send/useShareViewModel.ts b/packages/domain/src/send/useShareViewModel.tsindex 805048a..57f44a3 100644--- a/packages/domain/src/send/useShareViewModel.ts+++ b/packages/domain/src/send/useShareViewModel.ts@@ -1,6 +1,13 @@import { useEffect, useMemo, useRef, useState } from 'react'import type { RememberedPeer } from '@altersend/core'-import { formatFileSize, formatRelativeTime, type InviteStatus } from '../format'+import {+ formatFileSize,+ formatRelativeTime,+ formatTransferRate,+ type InviteStatus+} from '../format'+import { useTransferRates } from '../transfer/useTransferRates'+import type { TransferRate } from '../transfer/rate'import {forgetPeer,inviteDevice,@@ -9,7 +16,7 @@ import {startSendSession} from '../transfer/commands'import { useTransferStore } from '../transfer/store'-import { applyPairState, getPeerListEntries } from './peerListUi'+import { applyPairState, getActivePeerProgress, getPeerListEntries } from './peerListUi'import type { PairState, PeerListEntryWithPair } from './peerListUi'import type { Translate } from '../i18n'import { useCopiedFlag } from '../useCopiedFlag'@@ -20,6 +27,12 @@ const PEER_JOIN_TOAST_DELAY_MS = 600export type SubtitleTone = 'muted' | 'success' | 'danger' | 'info'+interface DeviceRowStatus {+ label: string+ tone: 'muted' | 'active' | 'success'+ detail?: string+}+interface InviteStatusState {status: InviteStatustopic?: string@@ -35,6 +48,7 @@ export interface ConnectedDeviceRow {subtitle: stringsubtitleTone: SubtitleToneprogressPercent?: number+ status?: DeviceRowStatusaction: 'pair' | 'pair-requested' | 'pair-done' | 'none'}@@ -145,6 +159,19 @@ function connectedDeviceSubtitle(}}+function connectedDeviceStatus(+ entry: PeerListEntryWithPair,+ rate: TransferRate | undefined,+ t: Translate+): DeviceRowStatus | undefined {+ if (entry.status !== 'downloading' || entry.progressPercent === undefined) return undefined+ return {+ label: t('send:status.percent', { percent: entry.progressPercent }),+ tone: 'active',+ detail: formatTransferRate(rate, t)+ }+}+function toPairAction(pairState: PairState | undefined): ConnectedDeviceRow['action'] {if (pairState === 'requested') return 'pair-requested'if (pairState === 'paired') return 'pair-done'@@ -238,6 +265,9 @@ export function useShareViewModel([peerEntries, pairStatus, peerDisplayNames])+ const peerProgress = useMemo(() => getActivePeerProgress(peerEntries), [peerEntries])+ const peerRates = useTransferRates(peerProgress, Object.keys(peerProgress).length > 0)+const offlineRemembered = useMemo(() =>rememberedPeers@@ -274,6 +304,7 @@ export function useShareViewModel(subtitle,subtitleTone,progressPercent: entry.status === 'downloading' ? entry.progressPercent : undefined,+ status: connectedDeviceStatus(entry, peerRates[entry.peerKey], t),action: connectedAction(entry, isWeb, isOutdated)}})diff --git a/packages/domain/src/transfer/index.ts b/packages/domain/src/transfer/index.tsindex 17bc064..9899458 100644--- a/packages/domain/src/transfer/index.ts+++ b/packages/domain/src/transfer/index.ts@@ -10,6 +10,8 @@ export {type BindTransferApiOptions,type ErrorHandler} from './binding'+export * from './rate'+export * from './useTransferRates'export * from './effects/appActive'export * from './effects/peerWatchdog'export * from './effects/backgroundReconnectEffect'diff --git a/packages/domain/src/transfer/rate.test.ts b/packages/domain/src/transfer/rate.test.tsnew file mode 100644index 0000000..4af6be6--- /dev/null+++ b/packages/domain/src/transfer/rate.test.ts@@ -0,0 +1,123 @@+import { describe, expect, it } from 'vitest'+import {+ getBytesPerSecond,+ getEtaSeconds,+ getTransferRate,+ pushRateSample,+ sumTransferRates+} from './rate'++function windowOf(entries: Array<[number, number]>) {+ return entries.reduce<ReturnType<typeof pushRateSample>>(+ (samples, [bytes, at]) => pushRateSample(samples, bytes, at),+ []+ )+}++describe('pushRateSample', () => {+ it('drops history when bytes go backwards', () => {+ const samples = pushRateSample([{ bytes: 500, at: 1000 }], 100, 2000)+ expect(samples).toEqual([{ bytes: 100, at: 2000 }])+ })++ it('ignores samples that do not advance the clock', () => {+ const existing = [{ bytes: 500, at: 1000 }]+ expect(pushRateSample(existing, 900, 1000)).toBe(existing)+ })++ it('keeps at least two samples once the window has passed', () => {+ const samples = windowOf([+ [0, 0],+ [1000, 20_000]+ ])+ expect(samples).toHaveLength(2)+ })++ it('trims samples older than the window', () => {+ const samples = windowOf([+ [0, 0],+ [1000, 1000],+ [2000, 2000],+ [3000, 3000],+ [7000, 7000]+ ])+ expect(samples.map((s) => s.at)).toEqual([1000, 2000, 3000, 7000])+ })+})++describe('getBytesPerSecond', () => {+ it('returns undefined without enough span to measure', () => {+ const samples = windowOf([+ [0, 0],+ [100, 200]+ ])+ expect(getBytesPerSecond(samples)).toBeUndefined()+ })++ it('averages throughput across the window', () => {+ const samples = windowOf([+ [0, 0],+ [4_000_000, 2000]+ ])+ expect(getBytesPerSecond(samples)).toBe(2_000_000)+ })++ it('reports zero once the whole window stops advancing', () => {+ const samples = windowOf([+ [4_000_000, 0],+ [4_000_000, 2000],+ [4_000_000, 4000]+ ])+ expect(getBytesPerSecond(samples)).toBe(0)+ })+})++describe('getEtaSeconds', () => {+ it('divides remaining bytes by throughput', () => {+ expect(getEtaSeconds(1_000_000, 5_000_000)).toBe(5)+ })++ it('returns undefined when stalled or finished', () => {+ expect(getEtaSeconds(0, 5_000_000)).toBeUndefined()+ expect(getEtaSeconds(undefined, 5_000_000)).toBeUndefined()+ expect(getEtaSeconds(1_000_000, 0)).toBeUndefined()+ })++ it('suppresses implausibly distant estimates', () => {+ expect(getEtaSeconds(1, 1_000_000_000)).toBeUndefined()+ })+})++describe('getTransferRate', () => {+ it('combines throughput and remaining time', () => {+ const samples = windowOf([+ [0, 0],+ [2_000_000, 2000]+ ])+ expect(+ getTransferRate(samples, { bytesTransferred: 2_000_000, totalBytes: 6_000_000 })+ ).toEqual({ bytesPerSecond: 1_000_000, etaSeconds: 4 })+ })+})++describe('sumTransferRates', () => {+ it('adds throughput across concurrent files', () => {+ expect(+ sumTransferRates([{ bytesPerSecond: 1_000_000 }, { bytesPerSecond: 3_000_000 }], 8_000_000)+ ).toEqual({ bytesPerSecond: 4_000_000, etaSeconds: 2 })+ })++ it('ignores files with no measurement yet', () => {+ expect(sumTransferRates([{ bytesPerSecond: 2_000_000 }, undefined, {}], 4_000_000)).toEqual({+ bytesPerSecond: 2_000_000,+ etaSeconds: 2+ })+ })++ it('reports nothing when no file has a measurement', () => {+ expect(sumTransferRates([undefined, {}], 4_000_000)).toEqual({+ bytesPerSecond: undefined,+ etaSeconds: undefined+ })+ })+})diff --git a/packages/domain/src/transfer/rate.ts b/packages/domain/src/transfer/rate.tsnew file mode 100644index 0000000..2dc9f1e--- /dev/null+++ b/packages/domain/src/transfer/rate.ts@@ -0,0 +1,71 @@+const WINDOW_MS = 6000+const MIN_SPAN_MS = 750+const MAX_ETA_SECONDS = 24 * 60 * 60++export interface RateSample {+ bytes: number+ at: number+}++export interface TransferRate {+ bytesPerSecond?: number+ etaSeconds?: number+}++export interface TransferProgress {+ bytesTransferred: number+ totalBytes: number+}++export function pushRateSample(samples: RateSample[], bytes: number, at: number): RateSample[] {+ const last = samples[samples.length - 1]+ if (last && bytes < last.bytes) return [{ bytes, at }]+ if (last && at <= last.at) return samples++ const next = [...samples, { bytes, at }]+ const recent = next.filter((sample) => sample.at >= at - WINDOW_MS)+ return recent.length >= 2 ? recent : next.slice(-2)+}++export function getBytesPerSecond(samples: RateSample[]): number | undefined {+ const first = samples[0]+ const last = samples[samples.length - 1]+ if (!first || !last) return undefined++ const spanMs = last.at - first.at+ if (spanMs < MIN_SPAN_MS) return undefined++ const delta = last.bytes - first.bytes+ return delta <= 0 ? 0 : (delta * 1000) / spanMs+}++export function getEtaSeconds(+ bytesPerSecond: number | undefined,+ bytesRemaining: number+): number | undefined {+ if (!bytesPerSecond || bytesPerSecond <= 0 || bytesRemaining <= 0) return undefined+ const seconds = bytesRemaining / bytesPerSecond+ return seconds > MAX_ETA_SECONDS ? undefined : seconds+}++export function sumTransferRates(+ rates: Array<TransferRate | undefined>,+ bytesRemaining: number+): TransferRate {+ let bytesPerSecond: number | undefined++ for (const rate of rates) {+ if (rate?.bytesPerSecond === undefined) continue+ bytesPerSecond = (bytesPerSecond ?? 0) + rate.bytesPerSecond+ }++ return { bytesPerSecond, etaSeconds: getEtaSeconds(bytesPerSecond, bytesRemaining) }+}++export function getTransferRate(samples: RateSample[], progress: TransferProgress): TransferRate {+ const bytesPerSecond = getBytesPerSecond(samples)+ return {+ bytesPerSecond,+ etaSeconds: getEtaSeconds(bytesPerSecond, progress.totalBytes - progress.bytesTransferred)+ }+}diff --git a/packages/domain/src/transfer/useTransferRates.test.ts b/packages/domain/src/transfer/useTransferRates.test.tsnew file mode 100644index 0000000..a4b806d--- /dev/null+++ b/packages/domain/src/transfer/useTransferRates.test.ts@@ -0,0 +1,30 @@+import { describe, expect, it } from 'vitest'+import { isSameRates } from './useTransferRates'++describe('isSameRates', () => {+ it('treats identical maps as unchanged', () => {+ expect(+ isSameRates(+ { a: { bytesPerSecond: 10, etaSeconds: 2 } },+ { a: { bytesPerSecond: 10, etaSeconds: 2 } }+ )+ ).toBe(true)+ })++ it('detects a swapped key even when both values are unmeasured', () => {+ expect(isSameRates({ a: {} }, { b: {} })).toBe(false)+ })++ it('detects a swapped key when the count stays the same', () => {+ expect(isSameRates({ a: { bytesPerSecond: 500 } }, { b: {} })).toBe(false)+ })++ it('detects a changed value', () => {+ expect(isSameRates({ a: { bytesPerSecond: 10 } }, { a: { bytesPerSecond: 20 } })).toBe(false)+ })++ it('detects added and removed keys', () => {+ expect(isSameRates({ a: {} }, { a: {}, b: {} })).toBe(false)+ expect(isSameRates({ a: {}, b: {} }, { a: {} })).toBe(false)+ })+})diff --git a/packages/domain/src/transfer/useTransferRates.ts b/packages/domain/src/transfer/useTransferRates.tsnew file mode 100644index 0000000..29406de--- /dev/null+++ b/packages/domain/src/transfer/useTransferRates.ts@@ -0,0 +1,66 @@+import { useEffect, useRef, useState } from 'react'+import {+ getTransferRate,+ pushRateSample,+ type RateSample,+ type TransferProgress,+ type TransferRate+} from './rate'++const TICK_MS = 1000++export function isSameRates(+ current: Record<string, TransferRate>,+ next: Record<string, TransferRate>+): boolean {+ const keys = Object.keys(next)+ if (keys.length !== Object.keys(current).length) return false++ return keys.every((key) => {+ const before = current[key]+ return (+ before !== undefined &&+ before.bytesPerSecond === next[key].bytesPerSecond &&+ before.etaSeconds === next[key].etaSeconds+ )+ })+}++export function useTransferRates(+ progress: Record<string, TransferProgress>,+ enabled: boolean+): Record<string, TransferRate> {+ const samplesRef = useRef<Record<string, RateSample[]>>({})+ const progressRef = useRef(progress)+ const [rates, setRates] = useState<Record<string, TransferRate>>({})+ progressRef.current = progress++ useEffect(() => {+ if (!enabled) {+ samplesRef.current = {}+ setRates((current) => (Object.keys(current).length === 0 ? current : {}))+ return+ }++ const tick = () => {+ const now = Date.now()+ const nextSamples: Record<string, RateSample[]> = {}+ const nextRates: Record<string, TransferRate> = {}++ for (const [key, item] of Object.entries(progressRef.current)) {+ const samples = pushRateSample(samplesRef.current[key] ?? [], item.bytesTransferred, now)+ nextSamples[key] = samples+ nextRates[key] = getTransferRate(samples, item)+ }++ samplesRef.current = nextSamples+ setRates((current) => (isSameRates(current, nextRates) ? current : nextRates))+ }++ tick()+ const timer = setInterval(tick, TICK_MS)+ return () => clearInterval(timer)+ }, [enabled])++ return rates+}diff --git a/packages/drive/src/engine/constants.ts b/packages/drive/src/engine/constants.tsnew file mode 100644index 0000000..4d8d90b--- /dev/null+++ b/packages/drive/src/engine/constants.ts@@ -0,0 +1,5 @@+export const PEER_SILENCE_TIMEOUT_MS = 60_000++export const PROGRESS_STEP_BYTES = 2 * 1024 * 1024++export const PROGRESS_INTERVAL_MS = 500diff --git a/packages/drive/src/engine/errors.ts b/packages/drive/src/engine/errors.tsindex 01da8fa..0144b58 100644--- a/packages/drive/src/engine/errors.ts+++ b/packages/drive/src/engine/errors.ts@@ -4,7 +4,3 @@ export class IntegrityError extends Error {this.name = 'IntegrityError'}}--export const PEER_SILENCE_TIMEOUT_MS = 60_000--export const PROGRESS_STEP_BYTES = 2 * 1024 * 1024diff --git a/packages/drive/src/engine/loopback.test.ts b/packages/drive/src/engine/loopback.test.tsindex 91a6377..69e72cb 100644--- a/packages/drive/src/engine/loopback.test.ts+++ b/packages/drive/src/engine/loopback.test.ts@@ -135,6 +135,33 @@ describe('full sender ↔ receiver loopback', () => {expect(lastReceived).toBe(input.length)})+ it('reports progress on an interval when the byte step is never reached', async () => {+ const input = pseudoRandom(200 * 1024)+ const src = join(dir, 'src.bin')+ const dst = join(dir, 'dst.bin')+ await writeFile(src, input)++ const [senderChannel, receiverChannel] = createChannelPair()+ const progress: number[] = []+ const receiver = new ReceiverSession(new DiskWriter(dst), receiverChannel, {+ transferId: 't',+ progressStepBytes: Number.MAX_SAFE_INTEGER,+ progressIntervalMs: 0,+ onProgress: (bytes) => progress.push(bytes)+ })+ const sender = new SenderSession(new DiskReader(src), senderChannel, {+ transferId: 't',+ name: 'file.bin'+ })++ await Promise.all([receiver.receive(), sender.start()])+ await sender.close()++ expect(progress.length).toBeGreaterThan(1)+ expect(progress).toStrictEqual([...progress].sort((a, b) => a - b))+ expect(progress.at(-1)).toBe(input.length)+ })+it('reports absolute progress when the peer only needs the tail', async () => {const input = pseudoRandom(200 * 1024)const src = join(dir, 'src.bin')diff --git a/packages/drive/src/engine/receiver.ts b/packages/drive/src/engine/receiver.tsindex d0b2940..34fcbeb 100644--- a/packages/drive/src/engine/receiver.ts+++ b/packages/drive/src/engine/receiver.ts@@ -1,7 +1,8 @@import type { ChunkWriter, DriveChannel, ChunkHeader, ControlMessage } from './types'import { selectChunkSize, chunkCount, chunkRange } from './chunker'import { Bitmap } from './bitmap'-import { IntegrityError, PEER_SILENCE_TIMEOUT_MS, PROGRESS_STEP_BYTES } from './errors'+import { IntegrityError } from './errors'+import { PEER_SILENCE_TIMEOUT_MS, PROGRESS_INTERVAL_MS, PROGRESS_STEP_BYTES } from './constants'import { Timeout } from './timeout'interface CancelOptions {@@ -14,6 +15,7 @@ export interface ReceiverOptions {resumeBits?: Uint8ArraystallTimeoutMs?: numberprogressStepBytes?: number+ progressIntervalMs?: numberonProgress?: (receivedBytes: number, totalBytes: number) => voidonChunkWritten?: (bitmap: Bitmap) => void}@@ -28,6 +30,7 @@ export class ReceiverSession {private bitmap: Bitmap | null = nullprivate receivedBytes = 0private reportedBytes = 0+ private reportedAt = 0private transferId: string | nullprivate settled = falseprivate cancelling = false@@ -173,9 +176,17 @@ export class ReceiverSession {}private reportProgress(force: boolean): void {+ if (!force && this.receivedBytes === this.reportedBytes) return+const step = this.opts.progressStepBytes ?? PROGRESS_STEP_BYTES- if (!force && this.receivedBytes - this.reportedBytes < step) return+ const now = Date.now()+ const interval = this.opts.progressIntervalMs ?? PROGRESS_INTERVAL_MS+ const steppedEnough = this.receivedBytes - this.reportedBytes >= step+ const waitedEnough = now - this.reportedAt >= interval+ if (!force && !steppedEnough && !waitedEnough) return+this.reportedBytes = this.receivedBytes+ this.reportedAt = nowthis.opts.onProgress?.(this.receivedBytes, this.size)}diff --git a/packages/drive/src/engine/sender.ts b/packages/drive/src/engine/sender.tsindex e3f4909..b7d30ef 100644--- a/packages/drive/src/engine/sender.ts+++ b/packages/drive/src/engine/sender.ts@@ -1,6 +1,6 @@import type { ChunkReader, DriveChannel, ControlMessage } from './types'import { selectChunkSize, chunkCount, chunkRange } from './chunker'-import { PEER_SILENCE_TIMEOUT_MS, PROGRESS_STEP_BYTES } from './errors'+import { PEER_SILENCE_TIMEOUT_MS, PROGRESS_STEP_BYTES } from './constants'import { Timeout } from './timeout'interface CancelOptions {diff --git a/packages/drive/src/index.ts b/packages/drive/src/index.tsindex 137bb68..4d6a647 100644--- a/packages/drive/src/index.ts+++ b/packages/drive/src/index.ts@@ -1,6 +1,7 @@export { SenderSession, type SenderOptions } from './engine/sender'export { ReceiverSession, type ReceiverOptions } from './engine/receiver'-export { IntegrityError, PEER_SILENCE_TIMEOUT_MS } from './engine/errors'+export { IntegrityError } from './engine/errors'+export { PEER_SILENCE_TIMEOUT_MS } from './engine/constants'export { Bitmap } from './engine/bitmap'export { selectChunkSize, chunkCount, chunkRange, type ChunkRange } from './engine/chunker'export type {diff --git a/packages/locales/src/locales/de-DE/common.json b/packages/locales/src/locales/de-DE/common.jsonindex 35e0f41..1c7bdf3 100644--- a/packages/locales/src/locales/de-DE/common.json+++ b/packages/locales/src/locales/de-DE/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} Zeichen","chars_other": "{{count}} Zeichen"+ },+ "transfer": {+ "timeLeft": "noch {{duration}}",+ "durationSeconds": "{{seconds}} Sek.",+ "durationMinutes": "{{minutes}} Min.",+ "durationMinutesSeconds": "{{minutes}} Min. {{seconds}} Sek.",+ "durationHours": "{{hours}} Std.",+ "durationHoursMinutes": "{{hours}} Std. {{minutes}} Min."}}diff --git a/packages/locales/src/locales/de-DE/send.json b/packages/locales/src/locales/de-DE/send.jsonindex b35a3c5..aad2b5a 100644--- a/packages/locales/src/locales/de-DE/send.json+++ b/packages/locales/src/locales/de-DE/send.json@@ -47,6 +47,7 @@"online": "Verbunden","downloading": "Herunterladen","downloadingPercent": "{{percent}} % wird heruntergeladen",+ "percent": "{{percent}}%","waitingForJoin": "Warten, dass jemand beitritt","pairedToast": "Mit {{name}} gekoppelt","inviteFailedToast": "{{name}} nicht erreichbar",diff --git a/packages/locales/src/locales/en-GB/common.json b/packages/locales/src/locales/en-GB/common.jsonindex a6bd46c..c259e07 100644--- a/packages/locales/src/locales/en-GB/common.json+++ b/packages/locales/src/locales/en-GB/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} char","chars_other": "{{count}} chars"+ },+ "transfer": {+ "timeLeft": "{{duration}} left",+ "durationSeconds": "{{seconds}}s",+ "durationMinutes": "{{minutes}}m",+ "durationMinutesSeconds": "{{minutes}}m {{seconds}}s",+ "durationHours": "{{hours}}h",+ "durationHoursMinutes": "{{hours}}h {{minutes}}m"}}diff --git a/packages/locales/src/locales/en-GB/send.json b/packages/locales/src/locales/en-GB/send.jsonindex 2d7248b..2b8cc8c 100644--- a/packages/locales/src/locales/en-GB/send.json+++ b/packages/locales/src/locales/en-GB/send.json@@ -47,6 +47,7 @@"online": "Online","downloading": "Downloading","downloadingPercent": "Downloading {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Waiting for someone to join","pairedToast": "Paired with {{name}}","inviteFailedToast": "Couldn't reach {{name}}",diff --git a/packages/locales/src/locales/en-US/common.json b/packages/locales/src/locales/en-US/common.jsonindex a6bd46c..c259e07 100644--- a/packages/locales/src/locales/en-US/common.json+++ b/packages/locales/src/locales/en-US/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} char","chars_other": "{{count}} chars"+ },+ "transfer": {+ "timeLeft": "{{duration}} left",+ "durationSeconds": "{{seconds}}s",+ "durationMinutes": "{{minutes}}m",+ "durationMinutesSeconds": "{{minutes}}m {{seconds}}s",+ "durationHours": "{{hours}}h",+ "durationHoursMinutes": "{{hours}}h {{minutes}}m"}}diff --git a/packages/locales/src/locales/en-US/send.json b/packages/locales/src/locales/en-US/send.jsonindex 2d7248b..2b8cc8c 100644--- a/packages/locales/src/locales/en-US/send.json+++ b/packages/locales/src/locales/en-US/send.json@@ -47,6 +47,7 @@"online": "Online","downloading": "Downloading","downloadingPercent": "Downloading {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Waiting for someone to join","pairedToast": "Paired with {{name}}","inviteFailedToast": "Couldn't reach {{name}}",diff --git a/packages/locales/src/locales/es-419/common.json b/packages/locales/src/locales/es-419/common.jsonindex fb99a25..dc0aa4c 100644--- a/packages/locales/src/locales/es-419/common.json+++ b/packages/locales/src/locales/es-419/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} carácter","chars_other": "{{count}} caracteres"+ },+ "transfer": {+ "timeLeft": "quedan {{duration}}",+ "durationSeconds": "{{seconds}} s",+ "durationMinutes": "{{minutes}} min",+ "durationMinutesSeconds": "{{minutes}} min {{seconds}} s",+ "durationHours": "{{hours}} h",+ "durationHoursMinutes": "{{hours}} h {{minutes}} min"}}diff --git a/packages/locales/src/locales/es-419/send.json b/packages/locales/src/locales/es-419/send.jsonindex eee444d..8d54776 100644--- a/packages/locales/src/locales/es-419/send.json+++ b/packages/locales/src/locales/es-419/send.json@@ -47,6 +47,7 @@"online": "En línea","downloading": "Descargando","downloadingPercent": "Descargando {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Esperando a que alguien se una","pairedToast": "Emparejado con {{name}}","inviteFailedToast": "No se pudo contactar con {{name}}",diff --git a/packages/locales/src/locales/es-ES/common.json b/packages/locales/src/locales/es-ES/common.jsonindex 7c8d93a..8e059b0 100644--- a/packages/locales/src/locales/es-ES/common.json+++ b/packages/locales/src/locales/es-ES/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} carácter","chars_other": "{{count}} caracteres"+ },+ "transfer": {+ "timeLeft": "quedan {{duration}}",+ "durationSeconds": "{{seconds}} s",+ "durationMinutes": "{{minutes}} min",+ "durationMinutesSeconds": "{{minutes}} min {{seconds}} s",+ "durationHours": "{{hours}} h",+ "durationHoursMinutes": "{{hours}} h {{minutes}} min"}}diff --git a/packages/locales/src/locales/es-ES/send.json b/packages/locales/src/locales/es-ES/send.jsonindex 08687b1..5017da9 100644--- a/packages/locales/src/locales/es-ES/send.json+++ b/packages/locales/src/locales/es-ES/send.json@@ -47,6 +47,7 @@"online": "En línea","downloading": "Descargando","downloadingPercent": "Descargando {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Esperando a que alguien se una","pairedToast": "Emparejado con {{name}}","inviteFailedToast": "No se pudo contactar con {{name}}",diff --git a/packages/locales/src/locales/fr-FR/common.json b/packages/locales/src/locales/fr-FR/common.jsonindex 3b6e783..7b5b19c 100644--- a/packages/locales/src/locales/fr-FR/common.json+++ b/packages/locales/src/locales/fr-FR/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} caractère","chars_other": "{{count}} caractères"+ },+ "transfer": {+ "timeLeft": "il reste {{duration}}",+ "durationSeconds": "{{seconds}} s",+ "durationMinutes": "{{minutes}} min",+ "durationMinutesSeconds": "{{minutes}} min {{seconds}} s",+ "durationHours": "{{hours}} h",+ "durationHoursMinutes": "{{hours}} h {{minutes}} min"}}diff --git a/packages/locales/src/locales/fr-FR/send.json b/packages/locales/src/locales/fr-FR/send.jsonindex ca6108b..2a49a36 100644--- a/packages/locales/src/locales/fr-FR/send.json+++ b/packages/locales/src/locales/fr-FR/send.json@@ -47,6 +47,7 @@"online": "En ligne","downloading": "Téléchargement","downloadingPercent": "Téléchargement de {{percent}} %",+ "percent": "{{percent}}%","waitingForJoin": "En attente de quelqu’un","pairedToast": "Associé à {{name}}","inviteFailedToast": "Impossible de joindre {{name}}",diff --git a/packages/locales/src/locales/it-IT/common.json b/packages/locales/src/locales/it-IT/common.jsonindex 74baeec..88e0260 100644--- a/packages/locales/src/locales/it-IT/common.json+++ b/packages/locales/src/locales/it-IT/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} carattere","chars_other": "{{count}} caratteri"+ },+ "transfer": {+ "timeLeft": "{{duration}} rimanenti",+ "durationSeconds": "{{seconds}} s",+ "durationMinutes": "{{minutes}} min",+ "durationMinutesSeconds": "{{minutes}} min {{seconds}} s",+ "durationHours": "{{hours}} h",+ "durationHoursMinutes": "{{hours}} h {{minutes}} min"}}diff --git a/packages/locales/src/locales/it-IT/send.json b/packages/locales/src/locales/it-IT/send.jsonindex cad96f1..0c41326 100644--- a/packages/locales/src/locales/it-IT/send.json+++ b/packages/locales/src/locales/it-IT/send.json@@ -47,6 +47,7 @@"online": "In linea","downloading": "Download in corso","downloadingPercent": "Download di {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "In attesa che qualcuno si unisca","pairedToast": "Accoppiato con {{name}}","inviteFailedToast": "Impossibile raggiungere {{name}}",diff --git a/packages/locales/src/locales/ja-JP/common.json b/packages/locales/src/locales/ja-JP/common.jsonindex 267b36e..ab74696 100644--- a/packages/locales/src/locales/ja-JP/common.json+++ b/packages/locales/src/locales/ja-JP/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} 文字","chars_other": "{{count}} 文字"+ },+ "transfer": {+ "timeLeft": "残り {{duration}}",+ "durationSeconds": "{{seconds}}秒",+ "durationMinutes": "{{minutes}}分",+ "durationMinutesSeconds": "{{minutes}}分{{seconds}}秒",+ "durationHours": "{{hours}}時間",+ "durationHoursMinutes": "{{hours}}時間{{minutes}}分"}}diff --git a/packages/locales/src/locales/ja-JP/send.json b/packages/locales/src/locales/ja-JP/send.jsonindex 32882c9..c01bec8 100644--- a/packages/locales/src/locales/ja-JP/send.json+++ b/packages/locales/src/locales/ja-JP/send.json@@ -47,6 +47,7 @@"online": "オンライン","downloading": "ダウンロード中","downloadingPercent": "{{percent}}% ダウンロード中",+ "percent": "{{percent}}%","waitingForJoin": "参加を待っています","pairedToast": "{{name}} とペアリングしました","inviteFailedToast": "{{name}} に接続できませんでした",diff --git a/packages/locales/src/locales/ko-KR/common.json b/packages/locales/src/locales/ko-KR/common.jsonindex e0ab732..a00e774 100644--- a/packages/locales/src/locales/ko-KR/common.json+++ b/packages/locales/src/locales/ko-KR/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}}자","chars_other": "{{count}}자"+ },+ "transfer": {+ "timeLeft": "{{duration}} 남음",+ "durationSeconds": "{{seconds}}초",+ "durationMinutes": "{{minutes}}분",+ "durationMinutesSeconds": "{{minutes}}분 {{seconds}}초",+ "durationHours": "{{hours}}시간",+ "durationHoursMinutes": "{{hours}}시간 {{minutes}}분"}}diff --git a/packages/locales/src/locales/ko-KR/send.json b/packages/locales/src/locales/ko-KR/send.jsonindex 49fb7e7..95e63af 100644--- a/packages/locales/src/locales/ko-KR/send.json+++ b/packages/locales/src/locales/ko-KR/send.json@@ -47,6 +47,7 @@"online": "온라인","downloading": "다운로드 중","downloadingPercent": "{{percent}}% 다운로드 중",+ "percent": "{{percent}}%","waitingForJoin": "참여를 기다리는 중","pairedToast": "{{name}}와(과) 페어링됨","inviteFailedToast": "{{name}}에 연결할 수 없습니다",diff --git a/packages/locales/src/locales/pt-BR/common.json b/packages/locales/src/locales/pt-BR/common.jsonindex 29f9f1a..15b7db5 100644--- a/packages/locales/src/locales/pt-BR/common.json+++ b/packages/locales/src/locales/pt-BR/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} caractere","chars_other": "{{count}} caracteres"+ },+ "transfer": {+ "timeLeft": "faltam {{duration}}",+ "durationSeconds": "{{seconds}} s",+ "durationMinutes": "{{minutes}} min",+ "durationMinutesSeconds": "{{minutes}} min {{seconds}} s",+ "durationHours": "{{hours}} h",+ "durationHoursMinutes": "{{hours}} h {{minutes}} min"}}diff --git a/packages/locales/src/locales/pt-BR/send.json b/packages/locales/src/locales/pt-BR/send.jsonindex d03910c..e97c5d3 100644--- a/packages/locales/src/locales/pt-BR/send.json+++ b/packages/locales/src/locales/pt-BR/send.json@@ -47,6 +47,7 @@"online": "On-line","downloading": "Baixando","downloadingPercent": "Baixando {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Aguardando alguém entrar","pairedToast": "Emparelhado com {{name}}","inviteFailedToast": "Não foi possível alcançar {{name}}",diff --git a/packages/locales/src/locales/ru-RU/common.json b/packages/locales/src/locales/ru-RU/common.jsonindex d1d3055..601a5a0 100644--- a/packages/locales/src/locales/ru-RU/common.json+++ b/packages/locales/src/locales/ru-RU/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} символ","chars_other": "{{count}} символа"+ },+ "transfer": {+ "timeLeft": "осталось {{duration}}",+ "durationSeconds": "{{seconds}} с",+ "durationMinutes": "{{minutes}} мин",+ "durationMinutesSeconds": "{{minutes}} мин {{seconds}} с",+ "durationHours": "{{hours}} ч",+ "durationHoursMinutes": "{{hours}} ч {{minutes}} мин"}}diff --git a/packages/locales/src/locales/ru-RU/send.json b/packages/locales/src/locales/ru-RU/send.jsonindex 4e0bb1e..632c55a 100644--- a/packages/locales/src/locales/ru-RU/send.json+++ b/packages/locales/src/locales/ru-RU/send.json@@ -47,6 +47,7 @@"online": "В сети","downloading": "Загрузка","downloadingPercent": "Загрузка {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "Ожидание подключения","pairedToast": "Сопряжено с {{name}}","inviteFailedToast": "Не удалось связаться с {{name}}",diff --git a/packages/locales/src/locales/zh-CN/common.json b/packages/locales/src/locales/zh-CN/common.jsonindex b4f3421..8042e1b 100644--- a/packages/locales/src/locales/zh-CN/common.json+++ b/packages/locales/src/locales/zh-CN/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} 个字符","chars_other": "{{count}} 个字符"+ },+ "transfer": {+ "timeLeft": "剩余 {{duration}}",+ "durationSeconds": "{{seconds}}秒",+ "durationMinutes": "{{minutes}}分钟",+ "durationMinutesSeconds": "{{minutes}}分{{seconds}}秒",+ "durationHours": "{{hours}}小时",+ "durationHoursMinutes": "{{hours}}小时{{minutes}}分"}}diff --git a/packages/locales/src/locales/zh-CN/send.json b/packages/locales/src/locales/zh-CN/send.jsonindex 6ea76a6..f484f6f 100644--- a/packages/locales/src/locales/zh-CN/send.json+++ b/packages/locales/src/locales/zh-CN/send.json@@ -47,6 +47,7 @@"online": "在线","downloading": "正在下载","downloadingPercent": "正在下载 {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "等待他人加入","pairedToast": "已与 {{name}} 配对","inviteFailedToast": "无法连接 {{name}}",diff --git a/packages/locales/src/locales/zh-TW/common.json b/packages/locales/src/locales/zh-TW/common.jsonindex b9ab5d6..169c115 100644--- a/packages/locales/src/locales/zh-TW/common.json+++ b/packages/locales/src/locales/zh-TW/common.json@@ -88,5 +88,13 @@"units": {"chars_one": "{{count}} 個字元","chars_other": "{{count}} 個字元"+ },+ "transfer": {+ "timeLeft": "剩餘 {{duration}}",+ "durationSeconds": "{{seconds}}秒",+ "durationMinutes": "{{minutes}}分鐘",+ "durationMinutesSeconds": "{{minutes}}分{{seconds}}秒",+ "durationHours": "{{hours}}小時",+ "durationHoursMinutes": "{{hours}}小時{{minutes}}分"}}diff --git a/packages/locales/src/locales/zh-TW/send.json b/packages/locales/src/locales/zh-TW/send.jsonindex 9a0682b..04dab4e 100644--- a/packages/locales/src/locales/zh-TW/send.json+++ b/packages/locales/src/locales/zh-TW/send.json@@ -47,6 +47,7 @@"online": "網路","downloading": "正在下載","downloadingPercent": "正在下載 {{percent}}%",+ "percent": "{{percent}}%","waitingForJoin": "等待他人加入","pairedToast": "已與 {{name}} 配對","inviteFailedToast": "無法連線到 {{name}}",