Release 0.0.4

This commit is contained in:
Schluffe committed 2026-10-16 14:57:17 +02:00
1 parent 7856725c72
commit 3ae47dde8e
10 files changed
+56 -26

No files matched your search

+4 -1
View File
@@ -4,7 +4,8 @@ import SendPanel from './components/SendPanel.vue';
import ReceivePanel from './components/ReceivePanel.vue';
const mode = ref<'send' | 'receive'>('send');
const canDownloadApp = import.meta.env.PROD && location.protocol !== 'file:';
const isLocal = location.protocol === 'file:';
const canDownloadApp = import.meta.env.PROD && !isLocal;
</script>
<template>
@@ -17,6 +18,8 @@ const canDownloadApp = import.meta.env.PROD && location.protocol !== 'file:';
</p>
<a v-if="canDownloadApp" class="app-download" href="./hellcon-local.html" download="HellCon.html">Download app for local use</a>
<p v-if="canDownloadApp || isLocal" class="status">For large files in the downloaded local version, use desktop Chrome on the receiving machine and choose “Choose destination &amp; receive to disk”.</p>
<div class="tabs" role="group" aria-label="Transfer mode">
<button :class="{ active: mode === 'send' }" :aria-pressed="mode === 'send'" @click="mode = 'send'">Send</button>
<button :class="{ active: mode === 'receive' }" :aria-pressed="mode === 'receive'" @click="mode = 'receive'">Receive</button>
+6 -6
View File
@@ -5,7 +5,7 @@ import type { FileMetadata, TransferState, FileDestination } from '../lib/transf
import { computed, onBeforeUnmount, ref } from 'vue';
import NetworkSettings from './NetworkSettings.vue';
import { acceptAnswerCode, createAnswerCode, createOfferCode, createPeerConnection, fetchTurnOptions, iceConfiguration, getFingerprints, MAX_SIGNAL_LENGTH, STUN_PROVIDERS } from '../lib/webrtc.ts';
import { FILE_LIMIT, MEMORY_LIMIT, Transfer, validateMetadata } from '../lib/transfer.ts';
import { MEMORY_LIMIT, Transfer, validateMetadata } from '../lib/transfer.ts';
import { ConnectionDiagnostics } from '../lib/connection-diagnostics.ts';
import { createDownloadDestination, supportsStreamingDownload } from '../lib/download.ts';
@@ -103,7 +103,7 @@ function pickFiles(event: Event) {
: event instanceof DragEvent ? event.dataTransfer?.files[0] : undefined;
if (!selected) return;
reset();
if (selected.size > FILE_LIMIT) { file.value = null; error.value = 'The maximum file size is 64 GiB.'; return; }
if (!Number.isSafeInteger(selected.size) || selected.size < 0) { file.value = null; error.value = 'This file’s size cannot be represented accurately.'; return; }
file.value = selected;
}
function attach(session: Session, channel: RTCDataChannel) {
@@ -254,8 +254,8 @@ async function copy() {
}
function formatBytes(bytes: number) {
if (bytes < 1024) return `${bytes} B`;
const index = Math.min(3, Math.floor(Math.log(bytes) / Math.log(1024)));
return `${(bytes / 1024 ** index).toFixed(1)} ${['B', 'KiB', 'MiB', 'GiB'][index]}`;
const index = Math.min(5, Math.floor(Math.log(bytes) / Math.log(1024)));
return `${(bytes / 1024 ** index).toFixed(1)} ${['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'][index]}`;
}
function selectCode(event: FocusEvent) {
if (event.target instanceof HTMLTextAreaElement) event.target.select();
@@ -266,7 +266,7 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<template>
<div class="panel">
<template v-if="sending">
<label class="step" for="file-input">Choose one file (up to 64 GiB)</label>
<label class="step" for="file-input">Choose one file</label>
<div class="dropzone" :class="{ dragover }" @dragover.prevent="dragover = true" @dragleave="dragover = false" @drop.prevent="dragover = false; pickFiles($event)">
<p>Drop a file here or choose one below. Choosing a new file cancels the current connection.</p>
<input id="file-input" type="file" @change="pickFiles" />
@@ -300,7 +300,7 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<div v-if="incoming && step === 'choose-storage'" class="incoming">
<p>{{ incoming.name }} — {{ formatBytes(incoming.size) }}</p>
<p class="status">Only accept files you expect. Encryption does not make their contents safe to open.</p>
<button v-if="canStreamDownload" class="primary" :disabled="choosing" @click="acceptFile('download')">Receive as download (up to 64 GiB)</button>
<button v-if="canStreamDownload" class="primary" :disabled="choosing" @click="acceptFile('download')">Receive as download ({{ formatBytes(incoming.size) }})</button>
<p v-if="canStreamDownload" class="status">Allow the browser download and keep this page open until the transfer finishes. Check Downloads for the final save result.</p>
<button v-if="canSaveToDisk" class="primary" :disabled="choosing" @click="acceptFile('disk')">Choose destination & receive to disk</button>
<button :disabled="choosing || incoming.size > MEMORY_LIMIT" @click="acceptFile('memory')">Receive in memory (up to 64 MiB)</button>
+2 -3
View File
@@ -32,16 +32,15 @@ export interface TransferOptions {
type ControlType = 'ready' | 'meta' | 'accept' | 'ack' | 'end' | 'complete';
export const MEMORY_LIMIT = 64 * 1024 * 1024;
export const FILE_LIMIT = 64 * 1024 * 1024 * 1024;
const CONTROL_LIMIT = 2048;
const WINDOW = MAX_BUFFERED;
export function validateMetadata(meta: unknown): FileMetadata {
if (!isRecord(meta) || typeof meta.name !== 'string' || !meta.name.length || meta.name.length > 255 ||
/[\x00-\x1f\x7f/\\\u202a-\u202e\u2066-\u2069]/.test(meta.name) ||
typeof meta.size !== 'number' || !Number.isSafeInteger(meta.size) || meta.size < 0 || meta.size > FILE_LIMIT ||
typeof meta.size !== 'number' || !Number.isSafeInteger(meta.size) || meta.size < 0 ||
typeof meta.mime !== 'string' || meta.mime.length > 128 || /[^\x20-\x7e]/.test(meta.mime)) {
throw new Error('Invalid file metadata or file exceeds the 64 GiB limit.');
throw new Error('Invalid file metadata. File size must be a nonnegative safe integer.');
}
return { name: meta.name, size: meta.size, mime: meta.mime };
}