Add the V2 web app: design system, shell, study flows, AI, settings, sharing

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-11 08:53:01 -07:00
parent eae109c166
commit 74a98ac1f1
52 changed files with 11976 additions and 1 deletions

14
scripts/build-server.mjs Normal file
View file

@ -0,0 +1,14 @@
// Bundles the server into one file. Dependencies stay external and are installed in the image.
import { build } from 'esbuild';
await build({
entryPoints: ['server/main.ts'],
outfile: 'dist/server/main.js',
bundle: true,
platform: 'node',
format: 'esm',
target: 'node24',
packages: 'external',
sourcemap: true,
logLevel: 'info',
});

60
scripts/make-icons.mjs Normal file
View file

@ -0,0 +1,60 @@
// Renders the PNG app icons (no image library needed): a dark tile with two "cards".
import fs from 'node:fs';
import zlib from 'node:zlib';
function png(size, draw) {
const px = Buffer.alloc(size * size * 4);
draw(px, size);
const raw = Buffer.alloc((size * 4 + 1) * size);
for (let y = 0; y < size; y++) px.copy(raw, y * (size * 4 + 1) + 1, y * size * 4, (y + 1) * size * 4);
const chunk = (type, data) => {
const len = Buffer.alloc(4);
len.writeUInt32BE(data.length);
const body = Buffer.concat([Buffer.from(type), data]);
const crc = Buffer.alloc(4);
crc.writeUInt32BE(zlib.crc32(body) >>> 0);
return Buffer.concat([len, body, crc]);
};
const ihdr = Buffer.alloc(13);
ihdr.writeUInt32BE(size, 0);
ihdr.writeUInt32BE(size, 4);
ihdr[8] = 8;
ihdr[9] = 6;
return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk('IHDR', ihdr), chunk('IDAT', zlib.deflateSync(raw, { level: 9 })), chunk('IEND', Buffer.alloc(0))]);
}
const hex = (h) => [parseInt(h.slice(1, 3), 16), parseInt(h.slice(3, 5), 16), parseInt(h.slice(5, 7), 16)];
function icon(px, size) {
const s = size / 64;
const set = (x, y, [r, g, b], a = 1) => {
if (x < 0 || y < 0 || x >= size || y >= size) return;
const i = (y * size + x) * 4;
px[i] = px[i] * (1 - a) + r * a;
px[i + 1] = px[i + 1] * (1 - a) + g * a;
px[i + 2] = px[i + 2] * (1 - a) + b * a;
px[i + 3] = 255;
};
const rrect = (x0, y0, w, h, r, color, rot = 0, cx = 0, cy = 0, alpha = 1) => {
const cos = Math.cos(-rot), sin = Math.sin(-rot);
for (let y = 0; y < size; y++)
for (let x = 0; x < size; x++) {
// rotate the sample point back into the rectangle's frame
const dx = x + 0.5 - cx * s, dy = y + 0.5 - cy * s;
const lx = (dx * cos - dy * sin) / s + cx, ly = (dx * sin + dy * cos) / s + cy;
const qx = Math.max(x0 + r - lx, 0, lx - (x0 + w - r)), qy = Math.max(y0 + r - ly, 0, ly - (y0 + h - r));
const d = Math.hypot(qx, qy) - r;
const a = Math.max(0, Math.min(1, 0.5 - d * s));
if (a > 0 && lx >= x0 - 1 && lx <= x0 + w + 1 && ly >= y0 - 1 && ly <= y0 + h + 1) set(x, y, color, a * alpha);
}
};
rrect(0, 0, 64, 64, 0, hex('#1B1A17')); // full-bleed so maskable crops look right
rrect(14, 17, 30, 36, 4, hex('#FBFAF7'), (-7 * Math.PI) / 180, 29, 35);
rrect(21, 13, 30, 36, 4, hex('#FFE36E'));
rrect(27, 23, 18, 3.4, 1.7, hex('#1B1A17'));
rrect(27, 30.5, 13, 3.4, 1.7, hex('#1B1A17'), 0, 0, 0, 0.55);
rrect(27, 38, 15.5, 3.4, 1.7, hex('#1B1A17'), 0, 0, 0, 0.55);
}
for (const size of [180, 192, 512]) fs.writeFileSync(`web/public/icon-${size}.png`, png(size, icon));
console.log('icons written');