Add local HTML download and release 0.0.3
This commit is contained in:
1 parent
bee62a79a9
commit
62c749de73
10 files changed
+98
-12
No files matched your search
@@ -1,5 +1,20 @@
|
|||||||
# Changelog
|
# 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
|
## [0.0.2] - 2026-10-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# HellCon
|
# 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.
|
and compatibility changes.
|
||||||
|
|
||||||
Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling
|
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.
|
not a substitute for trusting the host or a portable WebRTC egress filter.
|
||||||
`robots.txt` and indexing metadata are crawler requests, not access control.
|
`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
|
## Development
|
||||||
|
|
||||||
### Local STUN/TURN environment (Linux)
|
### Local STUN/TURN environment (Linux)
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "hellcon",
|
"name": "hellcon",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"turn:up": "docker compose --env-file .env.development up -d",
|
"turn:up": "docker compose --env-file .env.development up -d",
|
||||||
"turn:down": "docker compose --env-file .env.development down",
|
"turn:down": "docker compose --env-file .env.development down",
|
||||||
"test:turn": "node scripts/browser-check.ts --turn",
|
"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",
|
"preview": "vite preview",
|
||||||
"test": "node --test tests/*.test.ts",
|
"test": "node --test tests/*.test.ts",
|
||||||
"test:browser": "node scripts/browser-check.ts",
|
"test:browser": "node scripts/browser-check.ts",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { createServer } from 'node:http';
|
|||||||
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
||||||
import { tmpdir } from 'node:os';
|
import { tmpdir } from 'node:os';
|
||||||
import { dirname, extname, join, resolve } from 'node:path';
|
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 root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
const axeSource = await readFile(join(root, 'node_modules/axe-core/axe.min.js'), 'utf8');
|
const axeSource = await readFile(join(root, 'node_modules/axe-core/axe.min.js'), 'utf8');
|
||||||
const provider = process.argv.includes('--default-network') ? 'google' : 'none';
|
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);
|
const result = await call('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, session);
|
||||||
if (result.exceptionDetails) throw new Error(JSON.stringify(result.exceptionDetails));
|
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 { targetId } = await call('Target.createTarget', { url: 'about:blank' });
|
||||||
const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true });
|
const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true });
|
||||||
await call('Runtime.enable', {}, sessionId);
|
await call('Runtime.enable', {}, sessionId);
|
||||||
await call('Page.enable', {}, sessionId);
|
await call('Page.enable', {}, sessionId);
|
||||||
await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${installBrowserContext.toString()})()` }, sessionId);
|
await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${installBrowserContext.toString()})()` }, sessionId);
|
||||||
if (turn) await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${forceRelay.toString()})(${JSON.stringify(transport)})` }, 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++) {
|
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; }
|
catch (err) { if (!(err instanceof Error) || !err.message.includes('context')) throw err; }
|
||||||
await new Promise(resolve => setTimeout(resolve, 20));
|
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;
|
return sessionId;
|
||||||
}
|
}
|
||||||
async function checkAccessibility(session: string, mode: string) {
|
async function checkAccessibility(session: string, mode: string) {
|
||||||
@@ -159,6 +160,23 @@ async function connect(sender: string, receiver: string, size: number) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const sender = await page(), receiver = await page();
|
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<HTMLAnchorElement>('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 click(receiver, 'Receive');
|
||||||
await checkAccessibility(sender, 'Send');
|
await checkAccessibility(sender, 'Send');
|
||||||
await checkAccessibility(receiver, 'Receive');
|
await checkAccessibility(receiver, 'Receive');
|
||||||
|
|||||||
@@ -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 = /<script type="module"(?: [^>]*)? src="(\.\/assets\/[^"<>]+\.js)"><\/script>/;
|
||||||
|
const scriptPath = html.match(scriptTag)?.[1];
|
||||||
|
if (!scriptPath) throw new Error('Expected a Vite JavaScript asset in dist/index.html');
|
||||||
|
|
||||||
|
const [javascript, icon] = await Promise.all([
|
||||||
|
readFile(join(dist, scriptPath)),
|
||||||
|
readFile(join(dist, 'HellNet_alt.png')),
|
||||||
|
]);
|
||||||
|
const js = javascript.toString('utf8');
|
||||||
|
if (/<\/script/i.test(js)) throw new Error('Built JavaScript contains an unsafe inline closing tag');
|
||||||
|
|
||||||
|
html = html.replace(scriptTag, '');
|
||||||
|
html = html.replace('href="./HellNet_alt.png"', `href="data:image/png;base64,${icon.toString('base64')}"`);
|
||||||
|
html = html.replace('</body>', () => ` <script>${js}</script>\n </body>`);
|
||||||
|
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);
|
||||||
@@ -4,6 +4,7 @@ import SendPanel from './components/SendPanel.vue';
|
|||||||
import ReceivePanel from './components/ReceivePanel.vue';
|
import ReceivePanel from './components/ReceivePanel.vue';
|
||||||
|
|
||||||
const mode = ref<'send' | 'receive'>('send');
|
const mode = ref<'send' | 'receive'>('send');
|
||||||
|
const canDownloadApp = import.meta.env.PROD && location.protocol !== 'file:';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -14,6 +15,7 @@ const mode = ref<'send' | 'receive'>('send');
|
|||||||
Browser-to-browser file sharing. No account or file-hosting backend.
|
Browser-to-browser file sharing. No account or file-hosting backend.
|
||||||
Direct WebRTC connections, with an optional relay you explicitly enable.
|
Direct WebRTC connections, with an optional relay you explicitly enable.
|
||||||
</p>
|
</p>
|
||||||
|
<a v-if="canDownloadApp" class="app-download" href="./hellcon-local.html" download="HellCon.html">Download app for local use</a>
|
||||||
|
|
||||||
<div class="tabs" role="group" aria-label="Transfer mode">
|
<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 === 'send' }" :aria-pressed="mode === 'send'" @click="mode = 'send'">Send</button>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { IceOptions, NetworkSettings } from '../lib/webrtc.ts';
|
|||||||
import { STUN_PROVIDERS } from '../lib/webrtc.ts';
|
import { STUN_PROVIDERS } from '../lib/webrtc.ts';
|
||||||
const settings = defineModel<NetworkSettings>({ required: true });
|
const settings = defineModel<NetworkSettings>({ required: true });
|
||||||
defineProps<{ disabled?: boolean; managedCredentials?: IceOptions | null }>();
|
defineProps<{ disabled?: boolean; managedCredentials?: IceOptions | null }>();
|
||||||
const iceEndpoint = import.meta.env.VITE_ICE_ENDPOINT || '';
|
const iceEndpoint = location.protocol === 'file:' ? '' : import.meta.env.VITE_ICE_ENDPOINT || '';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ const incoming = ref<FileMetadata | null>(null);
|
|||||||
const downloadUrl = ref('');
|
const downloadUrl = ref('');
|
||||||
const choosing = ref(false);
|
const choosing = ref(false);
|
||||||
const dragover = ref(false);
|
const dragover = ref(false);
|
||||||
const iceEndpoint = import.meta.env.VITE_ICE_ENDPOINT || '';
|
const iceEndpoint = location.protocol === 'file:' ? '' : import.meta.env.VITE_ICE_ENDPOINT || '';
|
||||||
const defaultStun = import.meta.env.VITE_STUN_URL || '';
|
const defaultStun = location.protocol === 'file:' ? '' : import.meta.env.VITE_STUN_URL || '';
|
||||||
const settings = ref<NetworkSettingsModel>({ stunChoice: defaultStun ? 'custom' : 'google', customStun: defaultStun, allowTurn: false, managedTurn: !!iceEndpoint, turnUrl: '', username: '', credential: '' });
|
const settings = ref<NetworkSettingsModel>({ stunChoice: defaultStun ? 'custom' : 'google', customStun: defaultStun, allowTurn: false, managedTurn: !!iceEndpoint, turnUrl: '', username: '', credential: '' });
|
||||||
const managedCredentials = ref<IceOptions | null>(null);
|
const managedCredentials = ref<IceOptions | null>(null);
|
||||||
const canSaveToDisk = typeof window.showSaveFilePicker === 'function';
|
const canSaveToDisk = typeof window.showSaveFilePicker === 'function';
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ h1 {
|
|||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-download {
|
||||||
|
color: var(--accent);
|
||||||
|
margin: -0.5rem 0 1.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|||||||
+2
-1
@@ -2,11 +2,12 @@ import { defineConfig, loadEnv } from 'vite';
|
|||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import { iceMiddleware } from './dev/ice-server.ts';
|
import { iceMiddleware } from './dev/ice-server.ts';
|
||||||
|
|
||||||
// base './' so the built app can be served from any static path (or opened from a subdirectory)
|
// Relative paths let the hosted build work from any static subdirectory.
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const env = { ...loadEnv(mode, process.cwd(), ''), ...process.env };
|
const env = { ...loadEnv(mode, process.cwd(), ''), ...process.env };
|
||||||
return {
|
return {
|
||||||
base: './',
|
base: './',
|
||||||
|
build: { rollupOptions: { output: { format: 'iife' } } },
|
||||||
server: { host: '127.0.0.1' },
|
server: { host: '127.0.0.1' },
|
||||||
plugins: [vue(), {
|
plugins: [vue(), {
|
||||||
name: 'local-turn-credentials',
|
name: 'local-turn-credentials',
|
||||||
|
|||||||
Reference in new issue
Block a user