Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" }
Expand Down
4 changes: 1 addition & 3 deletions heartwritten.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"readerUrl": ""
}
{ "readerUrl": "https://heartwritten.vercel.app/" }
8 changes: 5 additions & 3 deletions scripts/make-sample.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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('<!--__LETTER_DATA__-->', `<script id="letter-data" type="application/x-heartwritten">${token}</script>`));
const sampleHtml = reader.replace('<!--__LETTER_DATA__-->', `<script id="letter-data" type="application/x-heartwritten">${token}</script>`);
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`);
27 changes: 20 additions & 7 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -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
}
Loading