diff --git a/CHANGELOG.md b/CHANGELOG.md index d128111..a81b115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [0.0.3] - 2026-10-09 + +### Added + +- A downloadable single-file HTML app that can be opened directly from disk, + without the website host. Local copies can transfer files through WebRTC. +- A browser check that transfers a file between two `file://` copies. + +### Changed + +- Labeled the download "for local use" and documented that peers may still need + internet access and reachable STUN or TURN servers. +- Disabled the host's managed TURN credential endpoint when running from a local + file; manual TURN settings remain available. + ## [0.0.2] - 2026-10-09 ### Added diff --git a/README.md b/README.md index c446a11..d32277e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HellCon -Current version: **0.0.2**. See the [changelog](CHANGELOG.md) for release notes +Current version: **0.0.3**. See the [changelog](CHANGELOG.md) for release notes and compatibility changes. Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling @@ -122,6 +122,25 @@ Vue visibility. Test headers on the actual host; CSP is defense in depth and is not a substitute for trusting the host or a portable WebRTC egress filter. `robots.txt` and indexing metadata are crawler requests, not access control. +## Download and run locally + +Run `bun run build`, then open `dist/hellcon-local.html` directly in a browser. +This single HTML file includes the app code, styles, and icon. A hosted production +build also offers **Download app for local use**. Download that file instead of +using the browser's **Save Page As** command, which may save only the hosted page +without its required assets. You can share the downloaded HTML file with the +other participant; both can open it from disk. No web server is needed to load +the app itself. + +The app still needs network access to connect peers on different machines, and +the selected STUN or TURN servers must be reachable. A `file://` copy cannot use +the host's managed TURN credential endpoint; enter your own relay details when +needed. Direct-to-disk receiving depends on browser support and may be unavailable +from a local file. The in-memory receive option remains available. + +To self-host the regular multi-file build, serve the whole `dist/` directory, +including `assets/`. Serve it over HTTPS for access from other machines. + ## Development ### Local STUN/TURN environment (Linux) diff --git a/package.json b/package.json index fb388a6..30b11e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hellcon", "private": true, - "version": "0.0.2", + "version": "0.0.3", "license": "MIT", "type": "module", "scripts": { @@ -10,7 +10,7 @@ "turn:up": "docker compose --env-file .env.development up -d", "turn:down": "docker compose --env-file .env.development down", "test:turn": "node scripts/browser-check.ts --turn", - "build": "vue-tsc --noEmit && vite build", + "build": "vue-tsc --noEmit && vite build && node scripts/build-local.ts", "preview": "vite preview", "test": "node --test tests/*.test.ts", "test:browser": "node scripts/browser-check.ts", diff --git a/scripts/browser-check.ts b/scripts/browser-check.ts index 0061091..d3b1760 100644 --- a/scripts/browser-check.ts +++ b/scripts/browser-check.ts @@ -7,7 +7,7 @@ import { createServer } from 'node:http'; import { mkdtemp, readFile, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { dirname, extname, join, resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { fileURLToPath, pathToFileURL } from 'node:url'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const axeSource = await readFile(join(root, 'node_modules/axe-core/axe.min.js'), 'utf8'); const provider = process.argv.includes('--default-network') ? 'google' : 'none'; @@ -88,20 +88,21 @@ async function wait(session: string, check: () => unknown) { const result = await call('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, session); if (result.exceptionDetails) throw new Error(JSON.stringify(result.exceptionDetails)); } -async function page() { +async function page(url = origin) { const { targetId } = await call('Target.createTarget', { url: 'about:blank' }); const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true }); await call('Runtime.enable', {}, sessionId); await call('Page.enable', {}, sessionId); await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${installBrowserContext.toString()})()` }, sessionId); if (turn) await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${forceRelay.toString()})(${JSON.stringify(transport)})` }, sessionId); - await call('Page.navigate', { url: origin }, sessionId); + await call('Page.navigate', { url }, sessionId); for (let n = 0; n < 100; n++) { - try { if (await evaluate(sessionId, (expected: string) => location.origin === expected && document.readyState === 'complete', origin)) break; } + try { if (await evaluate(sessionId, (expected: string) => location.href.startsWith(expected) && document.readyState === 'complete', url)) break; } catch (err) { if (!(err instanceof Error) || !err.message.includes('context')) throw err; } await new Promise(resolve => setTimeout(resolve, 20)); } - await wait(sessionId, () => !!document.querySelector('#stun-provider')); + try { await wait(sessionId, () => !!document.querySelector('#stun-provider')); } + catch (error) { throw new Error(`${url}: ${String(error)}; browser errors: ${JSON.stringify(browserErrors)}`); } return sessionId; } async function checkAccessibility(session: string, mode: string) { @@ -159,6 +160,23 @@ async function connect(sender: string, receiver: string, size: number) { } try { const sender = await page(), receiver = await page(); + if (!turn) { + const localUrl = pathToFileURL(join(root, 'dist/hellcon-local.html')).href; + const localReceiver = await page(localUrl); + assert.equal(await evaluate(localReceiver, () => document.querySelector('h1')?.textContent), 'HellCon'); + await click(localReceiver, 'Receive'); + assert.equal(await evaluate(localReceiver, () => !!document.querySelector('#offer-input')), true); + const localSender = await page(localUrl); + await connect(localSender, localReceiver, 1024); + await click(localReceiver, 'Receive in memory (up to 64 MiB)'); + await wait(localReceiver, () => !!document.querySelector('a.download')); + const data = await evaluate(localReceiver, async () => { + const bytes = new Uint8Array(await (await fetch(document.querySelector('a.download')!.href)).arrayBuffer()); + return { length: bytes.length, valid: bytes.every(byte => byte === 123) }; + }); + assert.deepEqual(data, { length: 1024, valid: true }); + console.log('PASS: standalone HTML opens from file:// and transfers a file between two local copies.'); + } await click(receiver, 'Receive'); await checkAccessibility(sender, 'Send'); await checkAccessibility(receiver, 'Receive'); diff --git a/scripts/build-local.ts b/scripts/build-local.ts new file mode 100644 index 0000000..652ea51 --- /dev/null +++ b/scripts/build-local.ts @@ -0,0 +1,25 @@ +import { readFile, writeFile } from 'node:fs/promises'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const dist = resolve(dirname(fileURLToPath(import.meta.url)), '../dist'); +let html = await readFile(join(dist, 'index.html'), 'utf8'); + +const scriptTag = /\n `); +if (/src="\.\/assets\/|href="\.\/assets\/|href="\.\/HellNet_alt\.png"/.test(html)) { + throw new Error('Standalone HTML still references external build assets'); +} +await writeFile(join(dist, 'hellcon-local.html'), html); diff --git a/src/App.vue b/src/App.vue index d1dea56..71999a0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,6 +4,7 @@ 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:';