diff --git a/PRIVACY.md b/PRIVACY.md
index a9c4ba9..34d2a33 100644
--- a/PRIVACY.md
+++ b/PRIVACY.md
@@ -55,6 +55,12 @@ You choose, before you start:
requests, it loads nothing from anywhere else, and it sets no cookies and
uses no browser storage. A letter saved as a file opens with no network at
all.
+- **Link previews.** If you paste a letter's link into a chat app that draws
+ link previews, that app fetches the reader page and its preview picture to
+ draw one, as it would for any link. It asks for the address without the `#`
+ part, so it gets the same page everyone gets and not the letter. The
+ preview shows a general picture and title, never anything from your letter.
+ The reader page itself never loads that picture.
- **The app itself** is built on Electron (Chromium). On Windows and Linux,
Chromium may download a spelling dictionary the first time you type; the
spell check itself runs on your computer. On macOS it uses the system's own
diff --git a/README.md b/README.md
index a29358a..7dcf35f 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,11 @@ done, you seal it with a wax seal pressed from your own pulse wave.
The person you send it to opens the envelope and watches the letter being
written again at your pace: the pauses where you thought, the sentence you
-rushed, the ink warming where your heart sped up, the page rising and falling
-with your breath, a soft glow where you smiled. At the end they see where your
-heart was quickest and where it was steadiest.
+rushed. Down the left margin of the paper runs a strip of chart paper with
+your heartline on it, drawn beside each line as it is written. Where your
+heart sped up the line stands taller and the ink warms and feathers; where
+you smiled there is a pencil stroke under the words. A postscript says where
+your heart was quickest and where it was steadiest.
The letter never goes to a server. A sealed letter lives inside its link (in
the part after `#`, which browsers never send) or inside a single HTML file.
@@ -72,8 +74,9 @@ by default. To host your own, deploy `dist/reader` anywhere static (a
```
or set `HEARTWRITTEN_READER_URL`. The reader has a Content Security Policy of
-`default-src 'none'; connect-src 'none'`, so once it has loaded it can't send
-anything anywhere. Whoever hosts the page sees an ordinary page request (an IP
+`default-src 'none'; connect-src 'none'` (fonts and images may only come from
+inside the file itself), so once it has loaded it can't send anything
+anywhere. Whoever hosts the page sees an ordinary page request (an IP
address and a browser), as any website does, but the letter in the `#` part of
the link never reaches the host or its logs.
@@ -81,15 +84,64 @@ the link never reaches the host or its logs.
| Signal (SmartSpectra) | While writing | In the letter |
| --- | --- | --- |
-| Pulse rate (`cardio.pulseRate`, stable values only) | Live number, and each word takes its ink as you type it | Ink colour per character: iron-gall blue-black near the writer's own median, warming through claret to vermilion as the heart quickens, cooling to a clear blue-black as it settles. A pulse in the margin keeps time, and a heartline under the signature draws the whole letter's heart rate. The postscript finds the quickest and steadiest sentences. |
-| Pulse wave (`cardio.arterialPressureTrace`) | Live trace | The wax seal: six seconds of the wave, wrapped into a ring and pressed into wax. Every seal is different. |
-| Breathing (`breathing.upperTrace`, `breathing.rate`) | Breaths a minute | The paper rises and falls with the writer's breathing as it replays. |
-| Smiles (`face.expression`, happy) | A small mark lights up | Words written while smiling glow softly. Optional. |
+| Pulse rate (`cardio.pulseRate`, stable values only) | The same strip, live: the figure at the line you are on, the heartline growing beside your words, and each word taking its ink as you type it | The margin heartline: a pulse trace down a strip of chart paper bound into the left of the sheet, each line of writing beside the stretch drawn while it was written. Beats stand taller, closer and warmer where the heart was quicker, and the line goes quiet at a long pause. The live figure rides at the pen's tip with a mark that beats in time. Ink colour per character: iron-gall blue-black near the writer's own median, warming through claret to vermilion and feathering into the paper as the heart quickens, cooling to a clear blue as it settles. The postscript finds the quickest and steadiest sentences. |
+| Pulse wave (`cardio.arterialPressureTrace`) | The live pulse wave at the top of the strip | The wax seal: six seconds of the wave, wrapped into a ring and pressed into wax. Every seal is different. |
+| Breathing (`breathing.upperTrace`, `breathing.rate`) | Breaths a minute | A faint wash on the margin strip swells and ebbs with the writer's breathing as it replays. |
+| Smiles (`face.expression`, happy) | A small mark, and a pencil stroke under the words | A hand-drawn pencil stroke under the words written while smiling. Optional. |
| Validation status | Plain-language hints: "move a little closer or further", "a little more light, please" | |
Typing is recorded as timed edits, so the replay keeps the real rhythm. Long
-pauses (over eight seconds) are shortened in the replay but noted in the margin.
-Words you delete are dropped from the letter unless you choose to share them.
+pauses (over eight seconds) are shortened in the replay but pencilled in the
+right margin ("paused 9 seconds"). Words you delete are dropped from the
+letter unless you choose to share them.
+
+A letter keeps the heart rate four times a second, not every beat. The
+heartline is drawn from that rate: the spacing and height of its beats follow
+it, so it shows how fast the heart was going, not each beat as it happened.
+
+## How it looks
+
+A letter on a desk at night, with its heartline in the margin. Screenshots are
+in [docs/screens](docs/screens) (the `margin-` files).
+
+- The sheet fits the letter. It comes out of the envelope folded in thirds,
+ opens to its first fold and grows as the writing does.
+- One typeface, [Literata](src/fonts/README.md) (SIL Open Font License 1.1),
+ with small capitals and old-style figures for labels and numbers. Two small
+ font files are built into the reader page itself, so it still loads nothing
+ from anywhere.
+- The front page at https://heartwritten.vercel.app is itself a letter to the
+ visitor, written the same way, with a scripted heartbeat that is labelled as
+ a demonstration.
+- The first time the ink warms, a pencil note in the margin says what that
+ means, once.
+- The camera reports in at the top of the writer's margin strip, where the
+ live pulse will be: waiting for permission, looking for your face, asking
+ for more light, finding your pulse, reading. If it stops, the strip says so
+ and you can keep writing.
+- After sealing you see the envelope as it will arrive, and copying the link
+ is confirmed in words.
+- The reader's icon is inside the page, and `og.png` beside it is the picture
+ chat apps show when a link is pasted. Both were made from the reader
+ itself; nothing is loaded from another site.
+
+## The writer in a browser
+
+The writer is an Electron app today because the SmartSpectra SDK it uses runs
+there. Its page is written so it can also be served as a web page:
+
+- `dist/writer` is plain HTML, CSS and one script, laid out for a laptop and
+ for a phone (390 px wide). It only touches Electron through an optional
+ `window.heartwritten` bridge; without the bridge it runs on simulated
+ signals and says so.
+- Signals reach the desk through one small interface (`start()`, `stop()`
+ and the events `stream`, `validationStatus`, `metrics`, `notice`, `error`).
+ `SOURCES` in `src/writer/writer.js` lists the two there are: the simulator
+ and the Electron SDK. A browser source would be a third entry.
+- What a web version still needs: that browser source and whatever it talks
+ to, a place to serve the page (`/write`), a consent line that says where
+ the measuring happens if it is no longer on the writer's own computer, and
+ an update to [PRIVACY.md](PRIVACY.md) to match.
## Privacy and consent
@@ -116,12 +168,16 @@ src/shared/
playback.js Replays the edits and maps the heart to ink
summary.js Quickest and steadiest sentences, smiles, words taken back
seal.js Draws the wax seal from the pulse wave
- heartline.js Draws the letter's heart rate as one line of ink
+ heartline.js Draws the margin heartline from the heart rate, line by line
+ sheet.js The sheet on the page: ink runs, the strip, folds (shared by reader and writer)
+ sheet.css The paper, the strip, the ink and the type (shared by reader and writer)
+ composeLetter.js Writes a letter from a script: the sample and the front page
+src/fonts/ Literata, cut down to two small files, and its licence
sim-source.js Simulated SDK output for development and tests
test/ node --test: the core, plus the built pages in jsdom
```
-`npm test` builds everything and runs 28 tests, including the reader replaying
+`npm test` builds everything and runs 41 tests, including the reader replaying
a full letter and the writer going from consent to a sealed letter in
simulated mode.
diff --git a/app/main.cjs b/app/main.cjs
index 6cd53bc..03feb6d 100644
--- a/app/main.cjs
+++ b/app/main.cjs
@@ -40,7 +40,7 @@ function createWindow() {
width: 1040,
height: 860,
minWidth: 720,
- backgroundColor: '#e7dcc7',
+ backgroundColor: '#13100e',
title: 'Heartwritten',
webPreferences: {
preload: path.join(DIST, 'preload.cjs'),
@@ -66,7 +66,7 @@ function lockDown(win) {
function openPreview(token) {
if (!/^v1\.[A-Za-z0-9_-]+$/.test(token)) return false;
const win = new BrowserWindow({
- width: 900, height: 900, title: 'Your letter, as they will see it', backgroundColor: '#e9dfcc',
+ width: 900, height: 900, title: 'Your letter, as they will see it', backgroundColor: '#13100e',
webPreferences: { contextIsolation: true, sandbox: true, nodeIntegration: false },
});
win.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
diff --git a/docs/demo-script.md b/docs/demo-script.md
index c33d935..ec51c2f 100644
--- a/docs/demo-script.md
+++ b/docs/demo-script.md
@@ -14,8 +14,8 @@ moment that actually moves you, and one line that makes you smile.
| 2 | 0:08–0:18 | Heartwritten consent screen; tick agree; camera on; live heart trace and bpm settle | "Heartwritten reads your heartbeat, breathing and smiles through the webcam, with Presage SmartSpectra. Nothing is saved while you write, and the letter never goes to a server." |
| 3 | 0:18–0:40 | Write the letter. Let the bpm visibly change at the emotional line. Smile once. Pause for a few seconds before the last line. | (Quiet. Let the typing and the live heart carry it.) |
| 4 | 0:40–0:48 | Press **Seal it with my heartbeat**; the wax seal presses in | "You seal it with your own pulse wave. No two seals are the same." |
-| 5 | 0:48–1:15 | Open the link in a browser as the recipient. Tap the seal, it cracks. The letter writes itself: ink warming at the emotional line, the margin heart beating, a glow on the smiling words, "paused 9 seconds" in the margin | "They watch it written again, at your pace. The ink warms where your heart sped up. The page breathes with you." |
-| 6 | 1:15–1:25 | The closing card: quickest and steadiest sentences | "And at the end, where your heart was quickest, and where it was steadiest." |
+| 5 | 0:48–1:15 | Open the link in a browser as the recipient. Tap the seal, it cracks. The letter writes itself: the heartline drawing down the margin strip beside each line, standing taller and turning red at the emotional line as the ink warms, the figure at the pen's tip, a pencil stroke under the smiling words, "paused 9 seconds" in the right margin | "They watch it written again, at your pace. That line in the margin is your heartbeat. The ink warms where your heart sped up." |
+| 6 | 1:15–1:25 | The postscript at the foot of the letter: "P.S.", with the quickest and steadiest sentences | "And at the end, where your heart was quickest, and where it was steadiest." |
| 7 | 1:25–1:30 | The seal again, with the line "lives only in its link" | "Heartwritten. Letters that carry your heartbeat." |
Tips:
diff --git a/docs/dev-post.md b/docs/dev-post.md
index b31e46c..afe7dcb 100644
--- a/docs/dev-post.md
+++ b/docs/dev-post.md
@@ -17,14 +17,14 @@ You write a letter on your laptop. While you type, SmartSpectra reads your pulse
The person you send it to taps the seal, it cracks, and they watch your letter being written again at your real pace:
- the **ink warms** from blue-black through claret to vermilion where your heart sped up, and cools again as you calmed down
-- a small **heart in the margin beats** at your rate, sentence by sentence
-- the **paper rises and falls** with your breathing
-- words you wrote **while smiling glow**
-- **pauses** stay in, and the long ones are noted in the margin beside the line ("paused 14 seconds")
-- under your signature, a **heartline** draws your whole heart rate across the letter
+- a **heartline runs down the margin**, on a strip of chart paper bound into the letter, drawn beside each line as it is written: taller, tighter and warmer where your heart was quicker, with the figure and a beating mark at the pen's tip
+- the quick-hearted words **feather** a little into the paper, and the calm ones stay crisp
+- a faint wash on the strip **swells and ebbs** with your breathing
+- words you wrote **while smiling** get a pencil stroke under them
+- **pauses** stay in, and the long ones are pencilled in the margin beside the line ("paused 9 seconds")
- if you allow it, they see the words you **typed and took back**
-At the end, a card shows where your heart was quickest and where it was steadiest, with the sentences.
+The letter ends with a postscript: where your heart was quickest and where it was steadiest, with the sentences.
There's no backend, no database and no account. A sealed letter lives entirely inside its link (in the part after `#`, which browsers never send anywhere) or in a single HTML file you can attach to an email.
@@ -51,10 +51,10 @@ Every signal changes something you can see or hold in the finished letter. None
| SmartSpectra signal | What it becomes |
| --- | --- |
-| `cardio.pulseRate` (stable readings only) | The colour of each character's ink, measured against *your own* median for that letter, so a writer with a slow heart and one with a quick heart both get a full range. It also sets the beat of the margin heart, and finds the quickest and steadiest sentences. |
+| `cardio.pulseRate` (stable readings only) | The colour of each character's ink, measured against *your own* median for that letter, so a writer with a slow heart and one with a quick heart both get a full range. It also draws the heartline down the margin, sets the beat of the mark at the pen's tip, and finds the quickest and steadiest sentences. |
| `cardio.arterialPressureTrace` | The wax seal. Six seconds of the pulse wave, wrapped into a ring around your initial. |
-| `breathing.upperTrace`, `breathing.rate` | The page breathing during replay. |
-| `face.expression` (happy) | The glow on words you wrote smiling. Optional, and it's the only face metric I request. |
+| `breathing.upperTrace`, `breathing.rate` | A faint wash on the margin strip that swells and ebbs during replay. |
+| `face.expression` (happy) | The pencil stroke under words you wrote smiling. Optional, and it's the only face metric I request. |
| Validation status | Gentle hints while you write: "move a little closer or further", "a little more light, please". |
A few things I cared about:
diff --git a/docs/screens/margin-after-envelope.png b/docs/screens/margin-after-envelope.png
new file mode 100644
index 0000000..bb87f35
Binary files /dev/null and b/docs/screens/margin-after-envelope.png differ
diff --git a/docs/screens/margin-after-front-end.png b/docs/screens/margin-after-front-end.png
new file mode 100644
index 0000000..3868df8
Binary files /dev/null and b/docs/screens/margin-after-front-end.png differ
diff --git a/docs/screens/margin-after-front.png b/docs/screens/margin-after-front.png
new file mode 100644
index 0000000..74d6483
Binary files /dev/null and b/docs/screens/margin-after-front.png differ
diff --git a/docs/screens/margin-after-phone-10s.png b/docs/screens/margin-after-phone-10s.png
new file mode 100644
index 0000000..de73ca7
Binary files /dev/null and b/docs/screens/margin-after-phone-10s.png differ
diff --git a/docs/screens/margin-after-phone-end.png b/docs/screens/margin-after-phone-end.png
new file mode 100644
index 0000000..377b5fe
Binary files /dev/null and b/docs/screens/margin-after-phone-end.png differ
diff --git a/docs/screens/margin-after-phone-envelope.png b/docs/screens/margin-after-phone-envelope.png
new file mode 100644
index 0000000..80a2271
Binary files /dev/null and b/docs/screens/margin-after-phone-envelope.png differ
diff --git a/docs/screens/margin-after-phone-front-end.png b/docs/screens/margin-after-phone-front-end.png
new file mode 100644
index 0000000..5ccc6ee
Binary files /dev/null and b/docs/screens/margin-after-phone-front-end.png differ
diff --git a/docs/screens/margin-after-phone-front.png b/docs/screens/margin-after-phone-front.png
new file mode 100644
index 0000000..efb7ba1
Binary files /dev/null and b/docs/screens/margin-after-phone-front.png differ
diff --git a/docs/screens/margin-after-phone-mid.png b/docs/screens/margin-after-phone-mid.png
new file mode 100644
index 0000000..0270d64
Binary files /dev/null and b/docs/screens/margin-after-phone-mid.png differ
diff --git a/docs/screens/margin-after-phone-writer-sealed.png b/docs/screens/margin-after-phone-writer-sealed.png
new file mode 100644
index 0000000..56deda2
Binary files /dev/null and b/docs/screens/margin-after-phone-writer-sealed.png differ
diff --git a/docs/screens/margin-after-phone-writer-state-face.png b/docs/screens/margin-after-phone-writer-state-face.png
new file mode 100644
index 0000000..fae9be2
Binary files /dev/null and b/docs/screens/margin-after-phone-writer-state-face.png differ
diff --git a/docs/screens/margin-after-phone-writer-write.png b/docs/screens/margin-after-phone-writer-write.png
new file mode 100644
index 0000000..6448464
Binary files /dev/null and b/docs/screens/margin-after-phone-writer-write.png differ
diff --git a/docs/screens/margin-after-replay-10s.png b/docs/screens/margin-after-replay-10s.png
new file mode 100644
index 0000000..0f0c232
Binary files /dev/null and b/docs/screens/margin-after-replay-10s.png differ
diff --git a/docs/screens/margin-after-replay-end.png b/docs/screens/margin-after-replay-end.png
new file mode 100644
index 0000000..efdf2f6
Binary files /dev/null and b/docs/screens/margin-after-replay-end.png differ
diff --git a/docs/screens/margin-after-replay-mid.png b/docs/screens/margin-after-replay-mid.png
new file mode 100644
index 0000000..757490b
Binary files /dev/null and b/docs/screens/margin-after-replay-mid.png differ
diff --git a/docs/screens/margin-after-writer-consent.png b/docs/screens/margin-after-writer-consent.png
new file mode 100644
index 0000000..dec5093
Binary files /dev/null and b/docs/screens/margin-after-writer-consent.png differ
diff --git a/docs/screens/margin-after-writer-ready.png b/docs/screens/margin-after-writer-ready.png
new file mode 100644
index 0000000..266e5b4
Binary files /dev/null and b/docs/screens/margin-after-writer-ready.png differ
diff --git a/docs/screens/margin-after-writer-sealed.png b/docs/screens/margin-after-writer-sealed.png
new file mode 100644
index 0000000..18349ff
Binary files /dev/null and b/docs/screens/margin-after-writer-sealed.png differ
diff --git a/docs/screens/margin-after-writer-state-error.png b/docs/screens/margin-after-writer-state-error.png
new file mode 100644
index 0000000..29ebc32
Binary files /dev/null and b/docs/screens/margin-after-writer-state-error.png differ
diff --git a/docs/screens/margin-after-writer-state-light.png b/docs/screens/margin-after-writer-state-light.png
new file mode 100644
index 0000000..e2ba160
Binary files /dev/null and b/docs/screens/margin-after-writer-state-light.png differ
diff --git a/docs/screens/margin-after-writer-write.png b/docs/screens/margin-after-writer-write.png
new file mode 100644
index 0000000..b962faa
Binary files /dev/null and b/docs/screens/margin-after-writer-write.png differ
diff --git a/docs/screens/margin-before-envelope.png b/docs/screens/margin-before-envelope.png
new file mode 100644
index 0000000..e5a9c5c
Binary files /dev/null and b/docs/screens/margin-before-envelope.png differ
diff --git a/docs/screens/margin-before-front.png b/docs/screens/margin-before-front.png
new file mode 100644
index 0000000..e2c7c6b
Binary files /dev/null and b/docs/screens/margin-before-front.png differ
diff --git a/docs/screens/margin-before-phone-front.png b/docs/screens/margin-before-phone-front.png
new file mode 100644
index 0000000..2725180
Binary files /dev/null and b/docs/screens/margin-before-phone-front.png differ
diff --git a/docs/screens/margin-before-phone-mid.png b/docs/screens/margin-before-phone-mid.png
new file mode 100644
index 0000000..c0131f1
Binary files /dev/null and b/docs/screens/margin-before-phone-mid.png differ
diff --git a/docs/screens/margin-before-replay-10s.png b/docs/screens/margin-before-replay-10s.png
new file mode 100644
index 0000000..4337535
Binary files /dev/null and b/docs/screens/margin-before-replay-10s.png differ
diff --git a/docs/screens/margin-before-replay-end.png b/docs/screens/margin-before-replay-end.png
new file mode 100644
index 0000000..2b14097
Binary files /dev/null and b/docs/screens/margin-before-replay-end.png differ
diff --git a/docs/screens/margin-before-replay-mid.png b/docs/screens/margin-before-replay-mid.png
new file mode 100644
index 0000000..37acfce
Binary files /dev/null and b/docs/screens/margin-before-replay-mid.png differ
diff --git a/docs/shot-list.md b/docs/shot-list.md
index 4746cc2..c2d2ac0 100644
--- a/docs/shot-list.md
+++ b/docs/shot-list.md
@@ -18,20 +18,20 @@ The script is the story. This is what to capture and in what order.
environment printed, or anyone else's face.
- Two sources:
- **SCREEN**: the screen recording of the app, then the browser.
- - **CAM**: your face. The app's own camera tile (top left of the writing
- desk, with the red dot) is enough. A separate picture-in-picture of you is
+ - **CAM**: your face. The app's own camera tile (top right of the sheet,
+ where a stamp would go, with the red dot) is enough. A separate picture-in-picture of you is
optional and belongs in shot 2 only.
## Shots
| # | Time | Length | Source | What is on screen | Action | Voice-over or caption |
| --- | --- | --- | --- | --- | --- | --- |
-| 1 | 0:00 to 0:06 | 6 s | SCREEN | A plain typed chat message, then cut to the Heartwritten front page (heartwritten.vercel.app) with the ink specimen | Still, slow push in | "Handwritten letters told you how they felt to write. Typed ones don't." |
-| 2 | 0:06 to 0:18 | 12 s | SCREEN + CAM | The consent screen. Open "What the camera reads, and where it goes" for a beat. Tick "I'm the only person on camera, and I agree to this". Press **Turn on the camera**. The camera tile, red dot, pulse trace and bpm appear and settle | Move the pointer slowly. Hold two seconds on the live trace once the bpm shows | "Heartwritten asks first. Then it reads your pulse, breathing and smiles through the webcam, with the Presage SmartSpectra SDK. The measurement runs on this laptop." |
-| 3 | 0:18 to 0:38 | 20 s | SCREEN (camera tile visible) | Typing the letter. The words take their ink as they are typed. The bpm number and the trace move at the line that matters. The "smiling" mark lights once. A real pause of a few seconds before the last line | Type at your real pace. Speed this shot up to 2x in the edit if it runs long, but leave the pause at real speed | No voice. Typing sound only. Caption: "Live from the camera. Ink follows the heart rate." |
+| 1 | 0:00 to 0:06 | 6 s | SCREEN | A plain typed chat message, then cut to the Heartwritten front page (heartwritten.vercel.app), a letter writing itself with the heartline in its margin | Let it write for three seconds, slow push in | "Handwritten letters told you how they felt to write. Typed ones don't." |
+| 2 | 0:06 to 0:18 | 12 s | SCREEN + CAM | The consent screen. Open "What the camera reads, and where it goes" for a beat. Tick "I'm the only person on camera, and I agree to this". Press **Turn on the camera**. The sheet appears with the camera tile where the stamp goes (red dot), and in the margin strip the live pulse wave and the beats-a-minute figure appear and settle | Move the pointer slowly. Hold two seconds on the strip once the figure shows | "Heartwritten asks first. Then it reads your pulse, breathing and smiles through the webcam, with the Presage SmartSpectra SDK. The measurement runs on this laptop." |
+| 3 | 0:18 to 0:38 | 20 s | SCREEN (camera tile visible) | Typing the letter. The words take their ink as they are typed, and the heartline grows down the margin strip beside them. The figure and the line jump at the line that matters. The "smiling" mark shows once and those words get a pencil stroke. A real pause of a few seconds before the last line | Type at your real pace. Speed this shot up to 2x in the edit if it runs long, but leave the pause at real speed | No voice. Typing sound only. Caption: "Live from the camera. Ink follows the heart rate." |
| 4 | 0:38 to 0:46 | 8 s | SCREEN | Press **Seal it with my heartbeat**. The wax seal appears, with "Sealed." and the private link | Hold on the seal for two seconds, then press **Copy link** | "You seal it with six seconds of your own pulse wave. No two seals are alike." |
-| 5 | 0:46 to 1:08 | 22 s | SCREEN (browser, no camera) | Paste the link into a browser. The envelope with the seal. Press the seal, it breaks. The letter writes itself: ink warming at the line that mattered, the margin heart beating with its number, the glow on the smiling words, "paused ... seconds" in the margin | Leave it on "Their pace" for the line that matters, then press **Faster** | "They watch it written again, at your pace. The ink warms where your heart sped up, and the page moves with your breathing." |
-| 6 | 1:08 to 1:16 | 8 s | SCREEN | Press **Show all**. The heartline under the signature and the closing card: "Quickest at", "Steadiest at" | Slow scroll to the card, hold | "At the end, where your heart was quickest, and where it was steadiest." |
+| 5 | 0:46 to 1:08 | 22 s | SCREEN (browser, no camera) | Paste the link into a browser. The envelope with the seal. Press the seal, it breaks. The letter writes itself: the heartline drawing down the margin strip beside each line, tall and red at the line that mattered as the ink warms, the figure and its beating mark at the pen's tip, the pencil stroke under the smiling words, "paused ... seconds" in the right margin, and the one-time note "the ink warms where ...'s heart sped up" | Leave it on "Their pace" for the line that matters, then press **Faster** | "They watch it written again, at your pace. The line in the margin is your heartbeat, and the ink warms where it sped up." |
+| 6 | 1:08 to 1:16 | 8 s | SCREEN | Press **Show all**. The whole heartline down the margin and the postscript: "P.S.", "Quickest at", "Steadiest at" | Slow scroll to the postscript, hold | "At the end, where your heart was quickest, and where it was steadiest." |
| 7 | 1:16 to 1:20 | 4 s | SCREEN | Back to the envelope view with the line "This letter lives only in its link." | Still | "No server, no account, no video kept. Heartwritten." |
Total: 80 seconds. If you need to cut to 60, drop shot 1 to 3 seconds, shot 3
@@ -44,10 +44,11 @@ demo video, and the template asks for a video "showing the live Presage
signal(s)". So these must be visible:
1. The consent tick before the camera turns on (shot 2).
-2. The live trace and bpm number changing while you are on camera (shots 2
- and 3). Keep the camera tile in frame so it is plain the signal is live.
-3. The signal changing the result: ink colour, seal, breathing page, smile
- glow (shots 3 to 6).
+2. The live pulse wave and the beats-a-minute figure in the margin strip
+ changing while you are on camera (shots 2 and 3). Keep the camera tile
+ (top right of the sheet) in frame so it is plain the signal is live.
+3. The signal changing the result: the margin heartline, ink colour, seal,
+ the pencil stroke under a smile (shots 3 to 6).
## Words to avoid in voice-over and captions
diff --git a/scripts/build.mjs b/scripts/build.mjs
index a122d83..b414ce7 100644
--- a/scripts/build.mjs
+++ b/scripts/build.mjs
@@ -14,11 +14,23 @@ const js = await build({
entryPoints: [src('reader/reader.js').pathname],
bundle: true, minify: true, format: 'iife', write: false, target: ['es2022'],
});
-const css = await readFile(src('reader/reader.css'), 'utf8');
+// One serif, Literata (SIL OFL 1.1, see src/fonts), cut down to two small
+// files. The reader carries them inside itself as data: URLs, so it still
+// loads nothing from anywhere; the writer loads them from its own folder.
+const FONTS = [['Literata-Regular.woff2', 'normal'], ['Literata-Italic.woff2', 'italic']];
+const fontFace = (url, style) => `@font-face { font-family: "Literata"; font-style: ${style}; font-weight: 400; font-display: swap; src: url(${url}) format("woff2"); }`;
+const inlineFonts = (await Promise.all(FONTS.map(async ([file, style]) =>
+ fontFace(`data:font/woff2;base64,${(await readFile(src(`fonts/${file}`))).toString('base64')}`, style)))).join('\n');
+const sheetCss = await readFile(src('shared/sheet.css'), 'utf8');
+const css = [inlineFonts, sheetCss, await readFile(src('reader/reader.css'), 'utf8')].join('\n');
+// The address the reader is hosted at, for the link-preview picture only.
+const site = (JSON.parse(await readFile(new URL('../heartwritten.config.json', import.meta.url), 'utf8')).readerUrl || '').replace(/\/?$/, '/');
const html = (await readFile(src('reader/index.html'), 'utf8'))
+ .replaceAll('__SITE__', site)
.replace('/*__READER_CSS__*/', () => css)
.replace('/*__READER_JS__*/', () => js.outputFiles[0].text.replace(/<\/script/gi, '<\\/script'));
await writeFile(out('reader/index.html'), html);
+try { await copyFile(src('reader/og.png'), out('reader/og.png')); } catch { /* the preview picture is optional */ }
// 2. Writer renderer.
await build({
@@ -27,7 +39,14 @@ await build({
outfile: out('writer/writer.js').pathname, loader: { '.html': 'text' }, logLevel: 'warning',
});
await copyFile(src('writer/index.html'), out('writer/index.html'));
-await copyFile(src('writer/writer.css'), out('writer/writer.css'));
+await mkdir(out('writer/fonts/'), { recursive: true });
+for (const [file] of FONTS) await copyFile(src(`fonts/${file}`), out(`writer/fonts/${file}`));
+await copyFile(src('fonts/OFL.txt'), out('writer/fonts/OFL.txt'));
+await writeFile(out('writer/writer.css'), [
+ FONTS.map(([file, style]) => fontFace(`./fonts/${file}`, style)).join('\n'),
+ sheetCss,
+ await readFile(src('writer/writer.css'), 'utf8'),
+].join('\n'));
// 3. Preload: SmartSpectra's bridge plus ours, with only `electron` left external
// so it runs in a sandboxed preload.
diff --git a/scripts/make-sample.mjs b/scripts/make-sample.mjs
index 19e2064..e30bda9 100644
--- a/scripts/make-sample.mjs
+++ b/scripts/make-sample.mjs
@@ -2,49 +2,30 @@
// sample) so the reader can be tried without the app. Prints its token and
// 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 { composeLetter } from '../src/shared/composeLetter.js';
import { encodeLetter } from '../src/shared/letter-format.js';
+import { buildTimeline, bpmAt, heat } from '../src/shared/playback.js';
+import { median } from '../src/shared/summary.js';
-let t = 0;
-const now = () => t;
-const rec = new LetterRecorder({ now });
-let bpm = 66;
-let smile = 0;
-let wavePhase = 0;
-const feed = () => {
- rec.sample({ bpm: bpm + Math.sin(t / 9000) * 2, breath: Math.sin((t / 1000) * (14 / 60) * Math.PI * 2), smile });
-};
-const typeText = (s, gap = 135) => {
- for (const ch of s) {
- t += gap + ((ch.charCodeAt(0) * 37) % 70) + (ch === ' ' ? 40 : 0) + (/[.,]/.test(ch) ? 260 : 0);
- rec.edit(rec.text + ch);
- feed();
- }
-};
-const back = (n) => { for (let i = 0; i < n; i++) { t += 95; rec.edit(rec.text.slice(0, -1)); feed(); } };
-const pause = (ms) => { const end = t + ms; while (t < end) { t += 250; feed(); } };
+// The news comes first, so the heart moves within the first ten seconds of
+// the replay. The rest of the letter is calmer, which is what sets the
+// writer's usual level and makes the opening stand out.
+const { letter, text, ms } = composeLetter([
+ ['type', 'Maya,\n\n'],
+ ['bpm', 85], ['type', 'They called this morning. '],
+ ['bpm', 93], ['smile', 0.9], ['type', 'I got it. I actually got it!'],
+ ['pause', 2500], ['smile', 0], ['bpm', 85],
+ ['type', ' You were the first person I wanted to tell. '],
+ ['bpm', 72], ['pause', 9000],
+ ['bpm', 67], ['type', 'I wanted to write this down instead of saying it on the phone, because I always rush the good parts. '],
+ ['type', 'I keep thinking about the night you sat on my floor and read my application out loud, and I was so sure it was '],
+ ['bpm', 75], ['type', 'terrible'], ['back', 8], ['type', 'not good enough'],
+ ['bpm', 68], ['type', '. You told me to send it anyway. '],
+ ['bpm', 60], ['type', 'I don’t think I would have.\n\n'],
+ ['bpm', 61], ['type', 'Thank you for believing in me before I did. Dinner is on me, wherever you want, as many times as you want.\n\n'],
+ ['bpm', 69], ['smile', 0.85], ['type', 'See you Friday.'],
+], { from: 'Sam', to: 'Maya', day: '2026-11-12' });
-typeText('Maya,\n\n');
-typeText('I wanted to write this down instead of saying it on the phone, because I always rush the good parts. ');
-pause(4000);
-typeText('So, slowly: ');
-bpm = 79; typeText('they called this morning. ');
-bpm = 91; smile = 0.9; typeText('I got it. I actually got it!');
-pause(2500); smile = 0;
-typeText(' You were the first person I wanted to tell. ');
-bpm = 84;
-pause(14000);
-typeText('I keep thinking about the night you sat on my floor and read my application out loud, and I was so sure it was ');
-typeText('terrible'); back(8); typeText('not good enough');
-typeText('. You told me to send it anyway. ');
-bpm = 68;
-typeText('I don’t think I would have.\n\n');
-bpm = 64;
-typeText('Thank you for believing in me before I did. Dinner is on me, wherever you want, as many times as you want.\n\n');
-smile = 0.85; typeText('See you Friday.'); smile = 0;
-for (let i = 0; i < 180; i++) { wavePhase += (66 / 60) / 30; const p = wavePhase % 1; rec.pushWave([p < 0.15 ? Math.sin(p / 0.15 * Math.PI / 2) : Math.exp(-3.2 * (p - 0.15) / 0.85) + 0.12 * Math.exp(-(((p - 0.15) / 0.85 - 0.28) ** 2) / 0.004)]); }
-
-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');
const sampleHtml = reader.replace('', ``);
@@ -52,4 +33,8 @@ await writeFile(new URL('../dist/sample-letter.html', import.meta.url), sampleHt
// 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`);
+
+// When, in the replay, the ink first clearly warms.
+const base = median(letter.vit.bpm);
+const first = buildTimeline(letter).ops.find((op) => heat(bpmAt(letter, op.t), base) >= 0.5);
+console.log(`sample letter: ${text.length} chars, written over ${(ms / 60000).toFixed(1)} min, token ${token.length} chars, usual heart ${base}, ink first warms ${(first.at / 1000).toFixed(1)} s into the replay`);
diff --git a/src/fonts/Literata-Italic.woff2 b/src/fonts/Literata-Italic.woff2
new file mode 100644
index 0000000..d565370
Binary files /dev/null and b/src/fonts/Literata-Italic.woff2 differ
diff --git a/src/fonts/Literata-Regular.woff2 b/src/fonts/Literata-Regular.woff2
new file mode 100644
index 0000000..6ee4ff7
Binary files /dev/null and b/src/fonts/Literata-Regular.woff2 differ
diff --git a/src/fonts/OFL.txt b/src/fonts/OFL.txt
new file mode 100644
index 0000000..9d3b4e3
--- /dev/null
+++ b/src/fonts/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Literata Project Authors (https://github.com/googlefonts/literata)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/src/fonts/README.md b/src/fonts/README.md
new file mode 100644
index 0000000..16de316
--- /dev/null
+++ b/src/fonts/README.md
@@ -0,0 +1,29 @@
+# Fonts
+
+Heartwritten sets everything in **Literata** (The Literata Project Authors,
+https://github.com/googlefonts/literata), licensed under the SIL Open Font
+License 1.1. The licence is in [OFL.txt](OFL.txt).
+
+The two files here are cut down from the upstream variable fonts so the reader
+stays one small file:
+
+- `Literata-Regular.woff2`: optical size 16, weight 400
+- `Literata-Italic.woff2`: optical size 18, weight 400
+
+Both keep Latin, Latin-1, Latin Extended-A and common punctuation, with small
+caps (`smcp`, `c2sc`), old-style and lining figures, kerning and ligatures.
+Text outside that range falls back to the reader's own serif.
+
+`scripts/build.mjs` inlines them into the reader as `data:` URLs, so the page
+still loads nothing from anywhere. The writer loads the same files from its
+own folder.
+
+Made with fontTools:
+
+```
+fonttools varLib.instancer "Literata[opsz,wght].ttf" opsz=16 wght=400 -o r.ttf
+fonttools varLib.instancer "Literata-Italic[opsz,wght].ttf" opsz=18 wght=400 -o i.ttf
+pyftsubset r.ttf --flavor=woff2 --no-hinting --desubroutinize \
+ --unicodes="U+0020-007E,U+00A0-00FF,U+0100-017F,U+2010-2015,U+2018-201E,U+2020-2022,U+2026,U+2032-2033,U+2039-203A,U+20AC,U+2190-2193,U+2212" \
+ --layout-features="kern,liga,smcp,c2sc,onum,pnum,tnum,lnum,ccmp,locl,mark,mkmk,case"
+```
diff --git a/src/reader/index.html b/src/reader/index.html
index e318618..4a1dadf 100644
--- a/src/reader/index.html
+++ b/src/reader/index.html
@@ -4,35 +4,26 @@
-
-
-
Letters that carry the heartbeat they were written with.
-
Write a letter while your camera reads your heartbeat. Whoever you send it to watches it being written again, at your pace, every word in the ink your heart gave it.
-
-
-
So, slowly: they called this morning. I got it. I actually got it! You were the first person I wanted to tell.
Writing opens in the Heartwritten app on a Mac for now, because that is where the camera reading runs. The setup takes a few minutes and is in the project’s README.
+
+
Heart rate and breathing are camera estimates, for feeling, not medicine. Built on the Presage SmartSpectra SDK.