From 1b790f8f9cd11b1ad65d72bd6e6f2a23050d7279 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 16:04:02 +0000 Subject: [PATCH] Use the hosted reader for links and serve a sample letter at /sample Co-Authored-By: Claude Opus 5.5 --- README.md | 11 +++++++---- heartwritten.config.json | 4 +--- scripts/make-sample.mjs | 8 +++++--- vercel.json | 27 ++++++++++++++++++++------- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 97b3b6f..b05ef4c 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,10 @@ The SDK ships native libraries for macOS on Apple silicon, Linux (x64 and arm64) and Windows x64. Measurement runs on your computer; the SDK needs a network connection only so Presage can check the key. -To see a finished letter without the app, run `npm run sample` and open -`dist/sample-letter.html` in a browser. +To see a finished letter without the app, open the sample at +https://heartwritten.vercel.app/sample, or run `npm run sample` and open +`dist/sample-letter.html` in a browser. The sample's signals are simulated, +and it says so. ## Sharing by link @@ -52,8 +54,9 @@ reader page somewhere static and tell the writer its address: npm run build # makes dist/reader/index.html, one self-contained file ``` -Deploy `dist/reader` anywhere static (a `vercel.json` is included), then put -the address in `heartwritten.config.json`: +The hosted reader is at https://heartwritten.vercel.app, and the writer uses it +by default. To host your own, deploy `dist/reader` anywhere static (a +`vercel.json` is included), then put the address in `heartwritten.config.json`: ```json { "readerUrl": "https://your-reader.example" } diff --git a/heartwritten.config.json b/heartwritten.config.json index 9a244ac..d23e86c 100644 --- a/heartwritten.config.json +++ b/heartwritten.config.json @@ -1,3 +1 @@ -{ - "readerUrl": "" -} +{ "readerUrl": "https://heartwritten.vercel.app/" } diff --git a/scripts/make-sample.mjs b/scripts/make-sample.mjs index 8c9cd04..19e2064 100644 --- a/scripts/make-sample.mjs +++ b/scripts/make-sample.mjs @@ -1,6 +1,6 @@ // make-sample.mjs: writes a sample letter (simulated signals, marked as a // sample) so the reader can be tried without the app. Prints its token and -// writes dist/sample-letter.html. +// writes dist/sample-letter.html and dist/reader/sample.html. import { writeFile, readFile } from 'node:fs/promises'; import { LetterRecorder } from '../src/shared/recorder.js'; import { encodeLetter } from '../src/shared/letter-format.js'; @@ -47,7 +47,9 @@ for (let i = 0; i < 180; i++) { wavePhase += (66 / 60) / 30; const p = wavePhase const letter = rec.finish({ from: 'Sam', to: 'Maya', day: '2026-11-12', sim: true, share: { edits: true, smiles: true } }); const token = await encodeLetter(letter); const reader = await readFile(new URL('../dist/reader/index.html', import.meta.url), 'utf8'); -await writeFile(new URL('../dist/sample-letter.html', import.meta.url), - reader.replace('', ``)); +const sampleHtml = reader.replace('', ``); +await writeFile(new URL('../dist/sample-letter.html', import.meta.url), sampleHtml); +// Also served by the hosted reader at /sample, so a sample opens from a short link. +await writeFile(new URL('../dist/reader/sample.html', import.meta.url), sampleHtml); await writeFile(new URL('../dist/sample-token.txt', import.meta.url), token); console.log(`sample letter: ${rec.text.length} chars, written over ${(t / 60000).toFixed(1)} min, token ${token.length} chars`); diff --git a/vercel.json b/vercel.json index e00e093..2b71080 100644 --- a/vercel.json +++ b/vercel.json @@ -1,12 +1,25 @@ { "installCommand": "ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm ci", - "buildCommand": "node scripts/build.mjs", + "buildCommand": "node scripts/build.mjs && node scripts/make-sample.mjs", "outputDirectory": "dist/reader", "headers": [ - { "source": "/(.*)", "headers": [ - { "key": "Referrer-Policy", "value": "no-referrer" }, - { "key": "X-Content-Type-Options", "value": "nosniff" }, - { "key": "Cache-Control", "value": "public, max-age=300" } - ] } - ] + { + "source": "/(.*)", + "headers": [ + { + "key": "Referrer-Policy", + "value": "no-referrer" + }, + { + "key": "X-Content-Type-Options", + "value": "nosniff" + }, + { + "key": "Cache-Control", + "value": "public, max-age=300" + } + ] + } + ], + "cleanUrls": true }