Branchwell / source / commits / d6b85796
Branchwell source: open Git hosting where votes decide new
written by Branchwell · d6b8579688cb5399d25870271f708e4706f24066
24 files changed
.gitignore added
| 1 | + node_modules/ | |
| 2 | + .wrangler/ |
README.md added
| 1 | + # Branchwell | |
| 2 | + | |
| 3 | + Open Git hosting at https://branchwell.ai. Anyone can pull. Anyone signed in (passkeys only) can push | |
| 4 | + straight to a branch. No pull requests and no reviews: 3 votes down removes a commit or branch, 3 votes | |
| 5 | + up keeps it for good. Public domain (CC0). | |
| 6 | + | |
| 7 | + - `src/repo.ts`: one Durable Object (SQLite) per repository: Git objects, branches, commit records, votes, removals. | |
| 8 | + - `src/git/`: pkt-lines, pack reading/writing, deltas, SHA-1. Smart HTTP protocol v0 (clone, fetch, push). | |
| 9 | + - `src/auth.ts`: passkeys (WebAuthn) and push keys for Git. | |
| 10 | + - `src/checks.ts`: what every pushed file must pass. | |
| 11 | + - `src/features.ts`: the "New feature" badge + thumbs widget for apps (`/widget/features.v1.js`). | |
| 12 | + - `migrations/`: D1 schema (accounts, passkeys, sessions, push keys, repos, feature votes). | |
| 13 | + | |
| 14 | + Run locally: `npm install && npx wrangler d1 execute branchwell --local --file migrations/0001_init.sql && npm run dev`. | |
| 15 | + Deploy: `npm run deploy`. |
build-static.mjs added
| 1 | + // Bundles the files in static/ into src/static.ts (run before deploy: npm run build). | |
| 2 | + import { readFileSync, writeFileSync } from 'node:fs'; | |
| 3 | + const f = (p) => JSON.stringify(readFileSync(new URL('./static/' + p, import.meta.url), 'utf8')); | |
| 4 | + writeFileSync(new URL('./src/static.ts', import.meta.url), `// Generated by build-static.mjs from static/. Do not edit. | |
| 5 | + export const NO_ORPHANS: string = ${f('no-orphans.html')}; | |
| 6 | + export const ODOMETER_CSS: string = ${f('visitor-odometer.v1.css')}; | |
| 7 | + export const ODOMETER_JS: string = ${f('visitor-odometer.v1.js')}; | |
| 8 | + export const APP_JS: string = ${f('app.js')}; | |
| 9 | + `); |
migrations/0001_init.sql added
| 1 | + -- Branchwell accounts, passkeys, push keys, repositories and app feature votes. | |
| 2 | + CREATE TABLE IF NOT EXISTS accounts (id TEXT PRIMARY KEY, handle TEXT NOT NULL UNIQUE COLLATE NOCASE, created_at INTEGER NOT NULL, ip_hash TEXT); | |
| 3 | + CREATE TABLE IF NOT EXISTS passkeys (id TEXT PRIMARY KEY, account_id TEXT NOT NULL, public_key TEXT NOT NULL, counter INTEGER NOT NULL DEFAULT 0, | |
| 4 | + transports TEXT, created_at INTEGER NOT NULL, last_used INTEGER); | |
| 5 | + CREATE INDEX IF NOT EXISTS passkeys_account ON passkeys (account_id); | |
| 6 | + CREATE TABLE IF NOT EXISTS challenges (id TEXT PRIMARY KEY, challenge TEXT NOT NULL, kind TEXT NOT NULL, data TEXT, created_at INTEGER NOT NULL); | |
| 7 | + CREATE TABLE IF NOT EXISTS sessions (id TEXT PRIMARY KEY, account_id TEXT NOT NULL, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL); | |
| 8 | + CREATE TABLE IF NOT EXISTS push_keys (id TEXT PRIMARY KEY, account_id TEXT NOT NULL, name TEXT NOT NULL, hash TEXT NOT NULL UNIQUE, created_at INTEGER NOT NULL, last_used INTEGER); | |
| 9 | + CREATE TABLE IF NOT EXISTS repos (name TEXT PRIMARY KEY COLLATE NOCASE, description TEXT, created_by TEXT, created_at INTEGER NOT NULL, updated_at INTEGER); | |
| 10 | + CREATE TABLE IF NOT EXISTS features (app TEXT NOT NULL, feature TEXT NOT NULL, label TEXT, status TEXT NOT NULL DEFAULT 'new', up INTEGER NOT NULL DEFAULT 0, down INTEGER NOT NULL DEFAULT 0, | |
| 11 | + created_at INTEGER NOT NULL, decided_at INTEGER, PRIMARY KEY (app, feature)); | |
| 12 | + CREATE TABLE IF NOT EXISTS feature_votes (app TEXT NOT NULL, feature TEXT NOT NULL, account_id TEXT NOT NULL, value INTEGER NOT NULL, at INTEGER NOT NULL, PRIMARY KEY (app, feature, account_id)); |
migrations/0002_companies.sql added
| 1 | + -- Company accounts (orgs). Every repository now lives under an owner: owner/project. | |
| 2 | + -- do_name keeps the Durable Object key, so repos first pushed under a flat name keep their storage. | |
| 3 | + CREATE TABLE IF NOT EXISTS orgs (handle TEXT PRIMARY KEY COLLATE NOCASE, name TEXT NOT NULL, domain TEXT, about TEXT, created_at INTEGER NOT NULL); | |
| 4 | + CREATE TABLE IF NOT EXISTS org_members (org TEXT NOT NULL, account_id TEXT NOT NULL, role TEXT NOT NULL DEFAULT 'member', PRIMARY KEY (org, account_id)); | |
| 5 | + CREATE INDEX IF NOT EXISTS org_members_account ON org_members (account_id); | |
| 6 | + ALTER TABLE repos ADD COLUMN owner TEXT; | |
| 7 | + ALTER TABLE repos ADD COLUMN do_name TEXT; | |
| 8 | + UPDATE repos SET do_name = name WHERE do_name IS NULL; | |
| 9 | + CREATE INDEX IF NOT EXISTS repos_owner ON repos (owner); |
package-lock.json added
| 1 | + { | |
| 2 | + "name": "branchwell", | |
| 3 | + "version": "1.0.0", | |
| 4 | + "lockfileVersion": 3, | |
| 5 | + "requires": true, | |
| 6 | + "packages": { | |
| 7 | + "": { | |
| 8 | + "name": "branchwell", | |
| 9 | + "version": "1.0.0", | |
| 10 | + "license": "CC0-1.0", | |
| 11 | + "dependencies": { | |
| 12 | + "@simplewebauthn/server": "^13.3.3", | |
| 13 | + "pako": "^2.2.0" | |
| 14 | + }, | |
| 15 | + "devDependencies": { | |
| 16 | + "@cloudflare/workers-types": "^5.20261201.1", | |
| 17 | + "@types/pako": "^2.0.4", | |
| 18 | + "typescript": "^7.0.2", | |
| 19 | + "wrangler": "^4.170.0" | |
| 20 | + } | |
| 21 | + }, | |
| 22 | + "node_modules/@cloudflare/kv-asset-handler": { | |
| 23 | + "version": "0.5.1", | |
| 24 | + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.1.tgz", | |
| 25 | + "integrity": "sha512-48OysfSW3MkQY1XjkhkpPkgrEkOvgfoyHzA2eyX5wpzFpijC02uWigv3hkNdJdT3C7ybW/U17yYHXeR68pLeww==", | |
| 26 | + "dev": true, | |
| 27 | + "license": "MIT OR Apache-2.0", | |
| 28 | + "engines": { | |
| 29 | + "node": ">=22.0.0" | |
| 30 | + } | |
| 31 | + }, | |
| 32 | + "node_modules/@cloudflare/unenv-preset": { | |
| 33 | + "version": "2.16.2", | |
| 34 | + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.2.tgz", | |
| 35 | + "integrity": "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==", | |
| 36 | + "dev": true, | |
| 37 | + "license": "MIT OR Apache-2.0", | |
| 38 | + "peerDependencies": { | |
| 39 | + "unenv": "2.0.0-rc.24", | |
| 40 | + "workerd": ">1.20260305.0 <2.0.0-0" | |
| 41 | + }, | |
| 42 | + "peerDependenciesMeta": { | |
| 43 | + "workerd": { | |
| 44 | + "optional": true | |
| 45 | + } | |
| 46 | + } | |
| 47 | + }, | |
| 48 | + "node_modules/@cloudflare/workerd-darwin-64": { | |
| 49 | + "version": "1.20261129.1", | |
| 50 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261129.1.tgz", | |
| 51 | + "integrity": "sha512-3CBFQhU+hPjGUEVuBydhVIlV1vpFG2BR9Xv62LbgIL/DzY8F6oLgA+2iRzN49OZCyUbHFa7WEv766KcL2Amfrg==", | |
| 52 | + "cpu": [ | |
| 53 | + "x64" | |
| 54 | + ], | |
| 55 | + "dev": true, | |
| 56 | + "license": "Apache-2.0", | |
| 57 | + "optional": true, | |
| 58 | + "os": [ | |
| 59 | + "darwin" | |
| 60 | + ], | |
| 61 | + "engines": { | |
| 62 | + "node": ">=16" | |
| 63 | + } | |
| 64 | + }, | |
| 65 | + "node_modules/@cloudflare/workerd-darwin-arm64": { | |
| 66 | + "version": "1.20261129.1", | |
| 67 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261129.1.tgz", | |
| 68 | + "integrity": "sha512-8Jj+pF2yLP9iYEXAtioO6F8S+D9Vn1u/7VDcGxELMxg299cN37xS0JG10mmOTGQbsmabRAV/aKuYwApLufogNA==", | |
| 69 | + "cpu": [ | |
| 70 | + "arm64" | |
| 71 | + ], | |
| 72 | + "dev": true, | |
| 73 | + "license": "Apache-2.0", | |
| 74 | + "optional": true, | |
| 75 | + "os": [ | |
| 76 | + "darwin" | |
| 77 | + ], | |
| 78 | + "engines": { | |
| 79 | + "node": ">=16" | |
| 80 | + } | |
| 81 | + }, | |
| 82 | + "node_modules/@cloudflare/workerd-linux-64": { | |
| 83 | + "version": "1.20261129.1", | |
| 84 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261129.1.tgz", | |
| 85 | + "integrity": "sha512-MDIGDtM+yOV95KNN48GcGbOTl9+ngWVr2J32T09Ou88fdhL4S+vDTAiVMOZsK+ipZWprtBW+crcU7ek2MpXkyQ==", | |
| 86 | + "cpu": [ | |
| 87 | + "x64" | |
| 88 | + ], | |
| 89 | + "dev": true, | |
| 90 | + "license": "Apache-2.0", | |
| 91 | + "optional": true, | |
| 92 | + "os": [ | |
| 93 | + "linux" | |
| 94 | + ], | |
| 95 | + "engines": { | |
| 96 | + "node": ">=16" | |
| 97 | + } | |
| 98 | + }, | |
| 99 | + "node_modules/@cloudflare/workerd-linux-arm64": { | |
| 100 | + "version": "1.20261129.1", | |
| 101 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261129.1.tgz", | |
| 102 | + "integrity": "sha512-0U7jPlNHfiAaeD2TROHzzZZUYwSX4SJTu5SA/A89jqlqhBY4raZBlRf1IzQwfYvQwKzmtlvju2ZjguvapwsFqg==", | |
| 103 | + "cpu": [ | |
| 104 | + "arm64" | |
| 105 | + ], | |
| 106 | + "dev": true, | |
| 107 | + "license": "Apache-2.0", | |
| 108 | + "optional": true, | |
| 109 | + "os": [ | |
| 110 | + "linux" | |
| 111 | + ], | |
| 112 | + "engines": { | |
| 113 | + "node": ">=16" | |
| 114 | + } | |
| 115 | + }, | |
| 116 | + "node_modules/@cloudflare/workerd-windows-64": { | |
| 117 | + "version": "1.20261129.1", | |
| 118 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261129.1.tgz", | |
| 119 | + "integrity": "sha512-Wzli8yhmD7Hj16hCDrwBTfF5L0xt2B/yr09UJFRYs32IVx0gmOYd8d9EhHQ9S4DODAQBKUnMWdZipdqZWK/k0g==", | |
| 120 | + "cpu": [ | |
| 121 | + "x64" | |
| 122 | + ], | |
| 123 | + "dev": true, | |
| 124 | + "license": "Apache-2.0", | |
| 125 | + "optional": true, | |
| 126 | + "os": [ | |
| 127 | + "win32" | |
| 128 | + ], | |
| 129 | + "engines": { | |
| 130 | + "node": ">=16" | |
| 131 | + } | |
| 132 | + }, | |
| 133 | + "node_modules/@cloudflare/workers-types": { | |
| 134 | + "version": "5.20261201.1", | |
| 135 | + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-5.20261201.1.tgz", | |
| 136 | + "integrity": "sha512-L34Vr3QDacBmZY9nVxyqU/dj6XNgl/c+MduZDcxlwE9f4qH7uifcyIfDHmdekn6XFL0VMzpj6Z7QVnuFZ30pug==", | |
| 137 | + "dev": true, | |
| 138 | + "license": "MIT OR Apache-2.0" | |
| 139 | + }, | |
| 140 | + "node_modules/@cloudflare/workers-utils": { | |
| 141 | + "version": "0.60.0", | |
| 142 | + "resolved": "https://registry.npmjs.org/@cloudflare/workers-utils/-/workers-utils-0.60.0.tgz", | |
| 143 | + "integrity": "sha512-E7AmXbkvFNjFiqc/6JctU/Y8pacsAEnc/AzMMWrJfYJz61SGgzp9Q0sk06KGJFrWxifIL5afA0hRnN+1RSNB0Q==", | |
| 144 | + "dev": true, | |
| 145 | + "license": "MIT OR Apache-2.0", | |
| 146 | + "dependencies": { | |
| 147 | + "@cspotcode/source-map-support": "0.8.1", | |
| 148 | + "chalk": "5.3.0", | |
| 149 | + "dotenv": "16.3.1", | |
| 150 | + "undici": "7.30.2" | |
| 151 | + }, | |
| 152 | + "peerDependencies": { | |
| 153 | + "vitest": "^4.1.0 || ^5.0.0" | |
| 154 | + }, | |
| 155 | + "peerDependenciesMeta": { | |
| 156 | + "vitest": { | |
| 157 | + "optional": true | |
| 158 | + } | |
| 159 | + } | |
| 160 | + }, | |
| 161 | + "node_modules/@cspotcode/source-map-support": { | |
| 162 | + "version": "0.8.1", | |
| 163 | + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", | |
| 164 | + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", | |
| 165 | + "dev": true, | |
| 166 | + "license": "MIT", | |
| 167 | + "dependencies": { | |
| 168 | + "@jridgewell/trace-mapping": "0.3.9" | |
| 169 | + }, | |
| 170 | + "engines": { | |
| 171 | + "node": ">=12" | |
| 172 | + } | |
| 173 | + }, | |
| 174 | + "node_modules/@emnapi/runtime": { | |
| 175 | + "version": "1.11.3", | |
| 176 | + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", | |
| 177 | + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", | |
| 178 | + "dev": true, | |
| 179 | + "license": "MIT", | |
| 180 | + "optional": true, | |
| 181 | + "dependencies": { | |
| 182 | + "tslib": "^2.4.0" | |
| 183 | + } | |
| 184 | + }, | |
| 185 | + "node_modules/@esbuild/aix-ppc64": { | |
| 186 | + "version": "0.28.2", | |
| 187 | + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", | |
| 188 | + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", | |
| 189 | + "cpu": [ | |
| 190 | + "ppc64" | |
| 191 | + ], | |
| 192 | + "dev": true, | |
| 193 | + "license": "MIT", | |
| 194 | + "optional": true, | |
| 195 | + "os": [ | |
| 196 | + "aix" | |
| 197 | + ], | |
| 198 | + "engines": { | |
| 199 | + "node": ">=18" | |
| 200 | + } | |
| 201 | + }, | |
| 202 | + "node_modules/@esbuild/android-arm": { | |
| 203 | + "version": "0.28.2", | |
| 204 | + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", | |
| 205 | + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", | |
| 206 | + "cpu": [ | |
| 207 | + "arm" | |
| 208 | + ], | |
| 209 | + "dev": true, | |
| 210 | + "license": "MIT", | |
| 211 | + "optional": true, | |
| 212 | + "os": [ | |
| 213 | + "android" | |
| 214 | + ], | |
| 215 | + "engines": { | |
| 216 | + "node": ">=18" | |
| 217 | + } | |
| 218 | + }, | |
| 219 | + "node_modules/@esbuild/android-arm64": { | |
| 220 | + "version": "0.28.2", | |
| 221 | + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", | |
| 222 | + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", | |
| 223 | + "cpu": [ | |
| 224 | + "arm64" | |
| 225 | + ], | |
| 226 | + "dev": true, | |
| 227 | + "license": "MIT", | |
| 228 | + "optional": true, | |
| 229 | + "os": [ | |
| 230 | + "android" | |
| 231 | + ], | |
| 232 | + "engines": { | |
| 233 | + "node": ">=18" | |
| 234 | + } | |
| 235 | + }, | |
| 236 | + "node_modules/@esbuild/android-x64": { | |
| 237 | + "version": "0.28.2", | |
| 238 | + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", | |
| 239 | + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", | |
| 240 | + "cpu": [ | |
| 241 | + "x64" | |
| 242 | + ], | |
| 243 | + "dev": true, | |
| 244 | + "license": "MIT", | |
| 245 | + "optional": true, | |
| 246 | + "os": [ | |
| 247 | + "android" | |
| 248 | + ], | |
| 249 | + "engines": { | |
| 250 | + "node": ">=18" | |
| 251 | + } | |
| 252 | + }, | |
| 253 | + "node_modules/@esbuild/darwin-arm64": { | |
| 254 | + "version": "0.28.2", | |
| 255 | + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", | |
| 256 | + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", | |
| 257 | + "cpu": [ | |
| 258 | + "arm64" | |
| 259 | + ], | |
| 260 | + "dev": true, | |
| 261 | + "license": "MIT", | |
| 262 | + "optional": true, | |
| 263 | + "os": [ | |
| 264 | + "darwin" | |
| 265 | + ], | |
| 266 | + "engines": { | |
| 267 | + "node": ">=18" | |
| 268 | + } | |
| 269 | + }, | |
| 270 | + "node_modules/@esbuild/darwin-x64": { | |
| 271 | + "version": "0.28.2", | |
| 272 | + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", | |
| 273 | + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", | |
| 274 | + "cpu": [ | |
| 275 | + "x64" | |
| 276 | + ], | |
| 277 | + "dev": true, | |
| 278 | + "license": "MIT", | |
| 279 | + "optional": true, | |
| 280 | + "os": [ | |
| 281 | + "darwin" | |
| 282 | + ], | |
| 283 | + "engines": { | |
| 284 | + "node": ">=18" | |
| 285 | + } | |
| 286 | + }, | |
| 287 | + "node_modules/@esbuild/freebsd-arm64": { | |
| 288 | + "version": "0.28.2", | |
| 289 | + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", | |
| 290 | + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", | |
| 291 | + "cpu": [ | |
| 292 | + "arm64" | |
| 293 | + ], | |
| 294 | + "dev": true, | |
| 295 | + "license": "MIT", | |
| 296 | + "optional": true, | |
| 297 | + "os": [ | |
| 298 | + "freebsd" | |
| 299 | + ], | |
| 300 | + "engines": { | |
| 301 | + "node": ">=18" | |
| 302 | + } | |
| 303 | + }, | |
| 304 | + "node_modules/@esbuild/freebsd-x64": { | |
| 305 | + "version": "0.28.2", | |
| 306 | + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", | |
| 307 | + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", | |
| 308 | + "cpu": [ | |
| 309 | + "x64" | |
| 310 | + ], | |
| 311 | + "dev": true, | |
| 312 | + "license": "MIT", | |
| 313 | + "optional": true, | |
| 314 | + "os": [ | |
| 315 | + "freebsd" | |
| 316 | + ], | |
| 317 | + "engines": { | |
| 318 | + "node": ">=18" | |
| 319 | + } | |
| 320 | + }, | |
| 321 | + "node_modules/@esbuild/linux-arm": { | |
| 322 | + "version": "0.28.2", | |
| 323 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", | |
| 324 | + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", | |
| 325 | + "cpu": [ | |
| 326 | + "arm" | |
| 327 | + ], | |
| 328 | + "dev": true, | |
| 329 | + "license": "MIT", | |
| 330 | + "optional": true, | |
| 331 | + "os": [ | |
| 332 | + "linux" | |
| 333 | + ], | |
| 334 | + "engines": { | |
| 335 | + "node": ">=18" | |
| 336 | + } | |
| 337 | + }, | |
| 338 | + "node_modules/@esbuild/linux-arm64": { | |
| 339 | + "version": "0.28.2", | |
| 340 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", | |
| 341 | + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", | |
| 342 | + "cpu": [ | |
| 343 | + "arm64" | |
| 344 | + ], | |
| 345 | + "dev": true, | |
| 346 | + "license": "MIT", | |
| 347 | + "optional": true, | |
| 348 | + "os": [ | |
| 349 | + "linux" | |
| 350 | + ], | |
| 351 | + "engines": { | |
| 352 | + "node": ">=18" | |
| 353 | + } | |
| 354 | + }, | |
| 355 | + "node_modules/@esbuild/linux-ia32": { | |
| 356 | + "version": "0.28.2", | |
| 357 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", | |
| 358 | + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", | |
| 359 | + "cpu": [ | |
| 360 | + "ia32" | |
| 361 | + ], | |
| 362 | + "dev": true, | |
| 363 | + "license": "MIT", | |
| 364 | + "optional": true, | |
| 365 | + "os": [ | |
| 366 | + "linux" | |
| 367 | + ], | |
| 368 | + "engines": { | |
| 369 | + "node": ">=18" | |
| 370 | + } | |
| 371 | + }, | |
| 372 | + "node_modules/@esbuild/linux-loong64": { | |
| 373 | + "version": "0.28.2", | |
| 374 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", | |
| 375 | + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", | |
| 376 | + "cpu": [ | |
| 377 | + "loong64" | |
| 378 | + ], | |
| 379 | + "dev": true, | |
| 380 | + "license": "MIT", | |
| 381 | + "optional": true, | |
| 382 | + "os": [ | |
| 383 | + "linux" | |
| 384 | + ], | |
| 385 | + "engines": { | |
| 386 | + "node": ">=18" | |
| 387 | + } | |
| 388 | + }, | |
| 389 | + "node_modules/@esbuild/linux-mips64el": { | |
| 390 | + "version": "0.28.2", | |
| 391 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", | |
| 392 | + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", | |
| 393 | + "cpu": [ | |
| 394 | + "mips64el" | |
| 395 | + ], | |
| 396 | + "dev": true, | |
| 397 | + "license": "MIT", | |
| 398 | + "optional": true, | |
| 399 | + "os": [ | |
| 400 | + "linux" | |
| 401 | + ], | |
| 402 | + "engines": { | |
| 403 | + "node": ">=18" | |
| 404 | + } | |
| 405 | + }, | |
| 406 | + "node_modules/@esbuild/linux-ppc64": { | |
| 407 | + "version": "0.28.2", | |
| 408 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", | |
| 409 | + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", | |
| 410 | + "cpu": [ | |
| 411 | + "ppc64" | |
| 412 | + ], | |
| 413 | + "dev": true, | |
| 414 | + "license": "MIT", | |
| 415 | + "optional": true, | |
| 416 | + "os": [ | |
| 417 | + "linux" | |
| 418 | + ], | |
| 419 | + "engines": { | |
| 420 | + "node": ">=18" | |
| 421 | + } | |
| 422 | + }, | |
| 423 | + "node_modules/@esbuild/linux-riscv64": { | |
| 424 | + "version": "0.28.2", | |
| 425 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", | |
| 426 | + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", | |
| 427 | + "cpu": [ | |
| 428 | + "riscv64" | |
| 429 | + ], | |
| 430 | + "dev": true, | |
| 431 | + "license": "MIT", | |
| 432 | + "optional": true, | |
| 433 | + "os": [ | |
| 434 | + "linux" | |
| 435 | + ], | |
| 436 | + "engines": { | |
| 437 | + "node": ">=18" | |
| 438 | + } | |
| 439 | + }, | |
| 440 | + "node_modules/@esbuild/linux-s390x": { | |
| 441 | + "version": "0.28.2", | |
| 442 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", | |
| 443 | + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", | |
| 444 | + "cpu": [ | |
| 445 | + "s390x" | |
| 446 | + ], | |
| 447 | + "dev": true, | |
| 448 | + "license": "MIT", | |
| 449 | + "optional": true, | |
| 450 | + "os": [ | |
| 451 | + "linux" | |
| 452 | + ], | |
| 453 | + "engines": { | |
| 454 | + "node": ">=18" | |
| 455 | + } | |
| 456 | + }, | |
| 457 | + "node_modules/@esbuild/linux-x64": { | |
| 458 | + "version": "0.28.2", | |
| 459 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", | |
| 460 | + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", | |
| 461 | + "cpu": [ | |
| 462 | + "x64" | |
| 463 | + ], | |
| 464 | + "dev": true, | |
| 465 | + "license": "MIT", | |
| 466 | + "optional": true, | |
| 467 | + "os": [ | |
| 468 | + "linux" | |
| 469 | + ], | |
| 470 | + "engines": { | |
| 471 | + "node": ">=18" | |
| 472 | + } | |
| 473 | + }, | |
| 474 | + "node_modules/@esbuild/netbsd-arm64": { | |
| 475 | + "version": "0.28.2", | |
| 476 | + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", | |
| 477 | + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", | |
| 478 | + "cpu": [ | |
| 479 | + "arm64" | |
| 480 | + ], | |
| 481 | + "dev": true, | |
| 482 | + "license": "MIT", | |
| 483 | + "optional": true, | |
| 484 | + "os": [ | |
| 485 | + "netbsd" | |
| 486 | + ], | |
| 487 | + "engines": { | |
| 488 | + "node": ">=18" | |
| 489 | + } | |
| 490 | + }, | |
| 491 | + "node_modules/@esbuild/netbsd-x64": { | |
| 492 | + "version": "0.28.2", | |
| 493 | + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", | |
| 494 | + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", | |
| 495 | + "cpu": [ | |
| 496 | + "x64" | |
| 497 | + ], | |
| 498 | + "dev": true, | |
| 499 | + "license": "MIT", | |
| 500 | + "optional": true, | |
| 501 | + "os": [ | |
| 502 | + "netbsd" | |
| 503 | + ], | |
| 504 | + "engines": { | |
| 505 | + "node": ">=18" | |
| 506 | + } | |
| 507 | + }, | |
| 508 | + "node_modules/@esbuild/openbsd-arm64": { | |
| 509 | + "version": "0.28.2", | |
| 510 | + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", | |
| 511 | + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", | |
| 512 | + "cpu": [ | |
| 513 | + "arm64" | |
| 514 | + ], | |
| 515 | + "dev": true, | |
| 516 | + "license": "MIT", | |
| 517 | + "optional": true, | |
| 518 | + "os": [ | |
| 519 | + "openbsd" | |
| 520 | + ], | |
| 521 | + "engines": { | |
| 522 | + "node": ">=18" | |
| 523 | + } | |
| 524 | + }, | |
| 525 | + "node_modules/@esbuild/openbsd-x64": { | |
| 526 | + "version": "0.28.2", | |
| 527 | + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", | |
| 528 | + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", | |
| 529 | + "cpu": [ | |
| 530 | + "x64" | |
| 531 | + ], | |
| 532 | + "dev": true, | |
| 533 | + "license": "MIT", | |
| 534 | + "optional": true, | |
| 535 | + "os": [ | |
| 536 | + "openbsd" | |
| 537 | + ], | |
| 538 | + "engines": { | |
| 539 | + "node": ">=18" | |
| 540 | + } | |
| 541 | + }, | |
| 542 | + "node_modules/@esbuild/openharmony-arm64": { | |
| 543 | + "version": "0.28.2", | |
| 544 | + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", | |
| 545 | + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", | |
| 546 | + "cpu": [ | |
| 547 | + "arm64" | |
| 548 | + ], | |
| 549 | + "dev": true, | |
| 550 | + "license": "MIT", | |
| 551 | + "optional": true, | |
| 552 | + "os": [ | |
| 553 | + "openharmony" | |
| 554 | + ], | |
| 555 | + "engines": { | |
| 556 | + "node": ">=18" | |
| 557 | + } | |
| 558 | + }, | |
| 559 | + "node_modules/@esbuild/sunos-x64": { | |
| 560 | + "version": "0.28.2", | |
| 561 | + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", | |
| 562 | + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", | |
| 563 | + "cpu": [ | |
| 564 | + "x64" | |
| 565 | + ], | |
| 566 | + "dev": true, | |
| 567 | + "license": "MIT", | |
| 568 | + "optional": true, | |
| 569 | + "os": [ | |
| 570 | + "sunos" | |
| 571 | + ], | |
| 572 | + "engines": { | |
| 573 | + "node": ">=18" | |
| 574 | + } | |
| 575 | + }, | |
| 576 | + "node_modules/@esbuild/win32-arm64": { | |
| 577 | + "version": "0.28.2", | |
| 578 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", | |
| 579 | + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", | |
| 580 | + "cpu": [ | |
| 581 | + "arm64" | |
| 582 | + ], | |
| 583 | + "dev": true, | |
| 584 | + "license": "MIT", | |
| 585 | + "optional": true, | |
| 586 | + "os": [ | |
| 587 | + "win32" | |
| 588 | + ], | |
| 589 | + "engines": { | |
| 590 | + "node": ">=18" | |
| 591 | + } | |
| 592 | + }, | |
| 593 | + "node_modules/@esbuild/win32-ia32": { | |
| 594 | + "version": "0.28.2", | |
| 595 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", | |
| 596 | + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", | |
| 597 | + "cpu": [ | |
| 598 | + "ia32" | |
| 599 | + ], | |
| 600 | + "dev": true, | |
| 601 | + "license": "MIT", | |
| 602 | + "optional": true, | |
| 603 | + "os": [ | |
| 604 | + "win32" | |
| 605 | + ], | |
| 606 | + "engines": { | |
| 607 | + "node": ">=18" | |
| 608 | + } | |
| 609 | + }, | |
| 610 | + "node_modules/@esbuild/win32-x64": { | |
| 611 | + "version": "0.28.2", | |
| 612 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", | |
| 613 | + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", | |
| 614 | + "cpu": [ | |
| 615 | + "x64" | |
| 616 | + ], | |
| 617 | + "dev": true, | |
| 618 | + "license": "MIT", | |
| 619 | + "optional": true, | |
| 620 | + "os": [ | |
| 621 | + "win32" | |
| 622 | + ], | |
| 623 | + "engines": { | |
| 624 | + "node": ">=18" | |
| 625 | + } | |
| 626 | + }, | |
| 627 | + "node_modules/@hexagon/base64": { | |
| 628 | + "version": "1.1.28", | |
| 629 | + "resolved": "https://registry.npmjs.org/@hexagon/base64/-/base64-1.1.28.tgz", | |
| 630 | + "integrity": "sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw==", | |
| 631 | + "license": "MIT" | |
| 632 | + }, | |
| 633 | + "node_modules/@img/colour": { | |
| 634 | + "version": "1.1.0", | |
| 635 | + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", | |
| 636 | + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", | |
| 637 | + "dev": true, | |
| 638 | + "license": "MIT", | |
| 639 | + "engines": { | |
| 640 | + "node": ">=18" | |
| 641 | + } | |
| 642 | + }, | |
| 643 | + "node_modules/@img/sharp-darwin-arm64": { | |
| 644 | + "version": "0.35.5", | |
| 645 | + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", | |
| 646 | + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", | |
| 647 | + "cpu": [ | |
| 648 | + "arm64" | |
| 649 | + ], | |
| 650 | + "dev": true, | |
| 651 | + "license": "Apache-2.0", | |
| 652 | + "optional": true, | |
| 653 | + "os": [ | |
| 654 | + "darwin" | |
| 655 | + ], | |
| 656 | + "engines": { | |
| 657 | + "node": ">=20.9.0" | |
| 658 | + }, | |
| 659 | + "funding": { | |
| 660 | + "url": "https://opencollective.com/libvips" | |
| 661 | + }, | |
| 662 | + "optionalDependencies": { | |
| 663 | + "@img/sharp-libvips-darwin-arm64": "1.3.4" | |
| 664 | + } | |
| 665 | + }, | |
| 666 | + "node_modules/@img/sharp-darwin-x64": { | |
| 667 | + "version": "0.35.5", | |
| 668 | + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", | |
| 669 | + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", | |
| 670 | + "cpu": [ | |
| 671 | + "x64" | |
| 672 | + ], | |
| 673 | + "dev": true, | |
| 674 | + "license": "Apache-2.0", | |
| 675 | + "optional": true, | |
| 676 | + "os": [ | |
| 677 | + "darwin" | |
| 678 | + ], | |
| 679 | + "engines": { | |
| 680 | + "node": ">=20.9.0" | |
| 681 | + }, | |
| 682 | + "funding": { | |
| 683 | + "url": "https://opencollective.com/libvips" | |
| 684 | + }, | |
| 685 | + "optionalDependencies": { | |
| 686 | + "@img/sharp-libvips-darwin-x64": "1.3.4" | |
| 687 | + } | |
| 688 | + }, | |
| 689 | + "node_modules/@img/sharp-freebsd-wasm32": { | |
| 690 | + "version": "0.35.5", | |
| 691 | + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", | |
| 692 | + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", | |
| 693 | + "dev": true, | |
| 694 | + "license": "Apache-2.0", | |
| 695 | + "optional": true, | |
| 696 | + "os": [ | |
| 697 | + "freebsd" | |
| 698 | + ], | |
| 699 | + "dependencies": { | |
| 700 | + "@img/sharp-wasm32": "0.35.5" | |
| 701 | + }, | |
| 702 | + "engines": { | |
| 703 | + "node": ">=20.9.0" | |
| 704 | + }, | |
| 705 | + "funding": { | |
| 706 | + "url": "https://opencollective.com/libvips" | |
| 707 | + } | |
| 708 | + }, | |
| 709 | + "node_modules/@img/sharp-libvips-darwin-arm64": { | |
| 710 | + "version": "1.3.4", | |
| 711 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", | |
| 712 | + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", | |
| 713 | + "cpu": [ | |
| 714 | + "arm64" | |
| 715 | + ], | |
| 716 | + "dev": true, | |
| 717 | + "license": "LGPL-3.0-or-later", | |
| 718 | + "optional": true, | |
| 719 | + "os": [ | |
| 720 | + "darwin" | |
| 721 | + ], | |
| 722 | + "funding": { | |
| 723 | + "url": "https://opencollective.com/libvips" | |
| 724 | + } | |
| 725 | + }, | |
| 726 | + "node_modules/@img/sharp-libvips-darwin-x64": { | |
| 727 | + "version": "1.3.4", | |
| 728 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", | |
| 729 | + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", | |
| 730 | + "cpu": [ | |
| 731 | + "x64" | |
| 732 | + ], | |
| 733 | + "dev": true, | |
| 734 | + "license": "LGPL-3.0-or-later", | |
| 735 | + "optional": true, | |
| 736 | + "os": [ | |
| 737 | + "darwin" | |
| 738 | + ], | |
| 739 | + "funding": { | |
| 740 | + "url": "https://opencollective.com/libvips" | |
| 741 | + } | |
| 742 | + }, | |
| 743 | + "node_modules/@img/sharp-libvips-linux-arm": { | |
| 744 | + "version": "1.3.4", | |
| 745 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", | |
| 746 | + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", | |
| 747 | + "cpu": [ | |
| 748 | + "arm" | |
| 749 | + ], | |
| 750 | + "dev": true, | |
| 751 | + "license": "LGPL-3.0-or-later", | |
| 752 | + "optional": true, | |
| 753 | + "os": [ | |
| 754 | + "linux" | |
| 755 | + ], | |
| 756 | + "funding": { | |
| 757 | + "url": "https://opencollective.com/libvips" | |
| 758 | + } | |
| 759 | + }, | |
| 760 | + "node_modules/@img/sharp-libvips-linux-arm64": { | |
| 761 | + "version": "1.3.4", | |
| 762 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", | |
| 763 | + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", | |
| 764 | + "cpu": [ | |
| 765 | + "arm64" | |
| 766 | + ], | |
| 767 | + "dev": true, | |
| 768 | + "license": "LGPL-3.0-or-later", | |
| 769 | + "optional": true, | |
| 770 | + "os": [ | |
| 771 | + "linux" | |
| 772 | + ], | |
| 773 | + "funding": { | |
| 774 | + "url": "https://opencollective.com/libvips" | |
| 775 | + } | |
| 776 | + }, | |
| 777 | + "node_modules/@img/sharp-libvips-linux-ppc64": { | |
| 778 | + "version": "1.3.4", | |
| 779 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", | |
| 780 | + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", | |
| 781 | + "cpu": [ | |
| 782 | + "ppc64" | |
| 783 | + ], | |
| 784 | + "dev": true, | |
| 785 | + "license": "LGPL-3.0-or-later", | |
| 786 | + "optional": true, | |
| 787 | + "os": [ | |
| 788 | + "linux" | |
| 789 | + ], | |
| 790 | + "funding": { | |
| 791 | + "url": "https://opencollective.com/libvips" | |
| 792 | + } | |
| 793 | + }, | |
| 794 | + "node_modules/@img/sharp-libvips-linux-riscv64": { | |
| 795 | + "version": "1.3.4", | |
| 796 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", | |
| 797 | + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", | |
| 798 | + "cpu": [ | |
| 799 | + "riscv64" | |
| 800 | + ], | |
| 801 | + "dev": true, | |
| 802 | + "license": "LGPL-3.0-or-later", | |
| 803 | + "optional": true, | |
| 804 | + "os": [ | |
| 805 | + "linux" | |
| 806 | + ], | |
| 807 | + "funding": { | |
| 808 | + "url": "https://opencollective.com/libvips" | |
| 809 | + } | |
| 810 | + }, | |
| 811 | + "node_modules/@img/sharp-libvips-linux-s390x": { | |
| 812 | + "version": "1.3.4", | |
| 813 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", | |
| 814 | + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", | |
| 815 | + "cpu": [ | |
| 816 | + "s390x" | |
| 817 | + ], | |
| 818 | + "dev": true, | |
| 819 | + "license": "LGPL-3.0-or-later", | |
| 820 | + "optional": true, | |
| 821 | + "os": [ | |
| 822 | + "linux" | |
| 823 | + ], | |
| 824 | + "funding": { | |
| 825 | + "url": "https://opencollective.com/libvips" | |
| 826 | + } | |
| 827 | + }, | |
| 828 | + "node_modules/@img/sharp-libvips-linux-x64": { | |
| 829 | + "version": "1.3.4", | |
| 830 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", | |
| 831 | + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", | |
| 832 | + "cpu": [ | |
| 833 | + "x64" | |
| 834 | + ], | |
| 835 | + "dev": true, | |
| 836 | + "license": "LGPL-3.0-or-later", | |
| 837 | + "optional": true, | |
| 838 | + "os": [ | |
| 839 | + "linux" | |
| 840 | + ], | |
| 841 | + "funding": { | |
| 842 | + "url": "https://opencollective.com/libvips" | |
| 843 | + } | |
| 844 | + }, | |
| 845 | + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { | |
| 846 | + "version": "1.3.4", | |
| 847 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", | |
| 848 | + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", | |
| 849 | + "cpu": [ | |
| 850 | + "arm64" | |
| 851 | + ], | |
| 852 | + "dev": true, | |
| 853 | + "license": "LGPL-3.0-or-later", | |
| 854 | + "optional": true, | |
| 855 | + "os": [ | |
| 856 | + "linux" | |
| 857 | + ], | |
| 858 | + "funding": { | |
| 859 | + "url": "https://opencollective.com/libvips" | |
| 860 | + } | |
| 861 | + }, | |
| 862 | + "node_modules/@img/sharp-libvips-linuxmusl-x64": { | |
| 863 | + "version": "1.3.4", | |
| 864 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", | |
| 865 | + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", | |
| 866 | + "cpu": [ | |
| 867 | + "x64" | |
| 868 | + ], | |
| 869 | + "dev": true, | |
| 870 | + "license": "LGPL-3.0-or-later", | |
| 871 | + "optional": true, | |
| 872 | + "os": [ | |
| 873 | + "linux" | |
| 874 | + ], | |
| 875 | + "funding": { | |
| 876 | + "url": "https://opencollective.com/libvips" | |
| 877 | + } | |
| 878 | + }, | |
| 879 | + "node_modules/@img/sharp-linux-arm": { | |
| 880 | + "version": "0.35.5", | |
| 881 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", | |
| 882 | + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", | |
| 883 | + "cpu": [ | |
| 884 | + "arm" | |
| 885 | + ], | |
| 886 | + "dev": true, | |
| 887 | + "license": "Apache-2.0", | |
| 888 | + "optional": true, | |
| 889 | + "os": [ | |
| 890 | + "linux" | |
| 891 | + ], | |
| 892 | + "engines": { | |
| 893 | + "node": ">=20.9.0" | |
| 894 | + }, | |
| 895 | + "funding": { | |
| 896 | + "url": "https://opencollective.com/libvips" | |
| 897 | + }, | |
| 898 | + "optionalDependencies": { | |
| 899 | + "@img/sharp-libvips-linux-arm": "1.3.4" | |
| 900 | + } | |
| 901 | + }, | |
| 902 | + "node_modules/@img/sharp-linux-arm64": { | |
| 903 | + "version": "0.35.5", | |
| 904 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", | |
| 905 | + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", | |
| 906 | + "cpu": [ | |
| 907 | + "arm64" | |
| 908 | + ], | |
| 909 | + "dev": true, | |
| 910 | + "license": "Apache-2.0", | |
| 911 | + "optional": true, | |
| 912 | + "os": [ | |
| 913 | + "linux" | |
| 914 | + ], | |
| 915 | + "engines": { | |
| 916 | + "node": ">=20.9.0" | |
| 917 | + }, | |
| 918 | + "funding": { | |
| 919 | + "url": "https://opencollective.com/libvips" | |
| 920 | + }, | |
| 921 | + "optionalDependencies": { | |
| 922 | + "@img/sharp-libvips-linux-arm64": "1.3.4" | |
| 923 | + } | |
| 924 | + }, | |
| 925 | + "node_modules/@img/sharp-linux-ppc64": { | |
| 926 | + "version": "0.35.5", | |
| 927 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", | |
| 928 | + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", | |
| 929 | + "cpu": [ | |
| 930 | + "ppc64" | |
| 931 | + ], | |
| 932 | + "dev": true, | |
| 933 | + "license": "Apache-2.0", | |
| 934 | + "optional": true, | |
| 935 | + "os": [ | |
| 936 | + "linux" | |
| 937 | + ], | |
| 938 | + "engines": { | |
| 939 | + "node": ">=20.9.0" | |
| 940 | + }, | |
| 941 | + "funding": { | |
| 942 | + "url": "https://opencollective.com/libvips" | |
| 943 | + }, | |
| 944 | + "optionalDependencies": { | |
| 945 | + "@img/sharp-libvips-linux-ppc64": "1.3.4" | |
| 946 | + } | |
| 947 | + }, | |
| 948 | + "node_modules/@img/sharp-linux-riscv64": { | |
| 949 | + "version": "0.35.5", | |
| 950 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", | |
| 951 | + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", | |
| 952 | + "cpu": [ | |
| 953 | + "riscv64" | |
| 954 | + ], | |
| 955 | + "dev": true, | |
| 956 | + "license": "Apache-2.0", | |
| 957 | + "optional": true, | |
| 958 | + "os": [ | |
| 959 | + "linux" | |
| 960 | + ], | |
| 961 | + "engines": { | |
| 962 | + "node": ">=20.9.0" | |
| 963 | + }, | |
| 964 | + "funding": { | |
| 965 | + "url": "https://opencollective.com/libvips" | |
| 966 | + }, | |
| 967 | + "optionalDependencies": { | |
| 968 | + "@img/sharp-libvips-linux-riscv64": "1.3.4" | |
| 969 | + } | |
| 970 | + }, | |
| 971 | + "node_modules/@img/sharp-linux-s390x": { | |
| 972 | + "version": "0.35.5", | |
| 973 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", | |
| 974 | + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", | |
| 975 | + "cpu": [ | |
| 976 | + "s390x" | |
| 977 | + ], | |
| 978 | + "dev": true, | |
| 979 | + "license": "Apache-2.0", | |
| 980 | + "optional": true, | |
| 981 | + "os": [ | |
| 982 | + "linux" | |
| 983 | + ], | |
| 984 | + "engines": { | |
| 985 | + "node": ">=20.9.0" | |
| 986 | + }, | |
| 987 | + "funding": { | |
| 988 | + "url": "https://opencollective.com/libvips" | |
| 989 | + }, | |
| 990 | + "optionalDependencies": { | |
| 991 | + "@img/sharp-libvips-linux-s390x": "1.3.4" | |
| 992 | + } | |
| 993 | + }, | |
| 994 | + "node_modules/@img/sharp-linux-x64": { | |
| 995 | + "version": "0.35.5", | |
| 996 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", | |
| 997 | + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", | |
| 998 | + "cpu": [ | |
| 999 | + "x64" | |
| 1000 | + ], | |
| 1001 | + "dev": true, | |
| 1002 | + "license": "Apache-2.0", | |
| 1003 | + "optional": true, | |
| 1004 | + "os": [ | |
| 1005 | + "linux" | |
| 1006 | + ], | |
| 1007 | + "engines": { | |
| 1008 | + "node": ">=20.9.0" | |
| 1009 | + }, | |
| 1010 | + "funding": { | |
| 1011 | + "url": "https://opencollective.com/libvips" | |
| 1012 | + }, | |
| 1013 | + "optionalDependencies": { | |
| 1014 | + "@img/sharp-libvips-linux-x64": "1.3.4" | |
| 1015 | + } | |
| 1016 | + }, | |
| 1017 | + "node_modules/@img/sharp-linuxmusl-arm64": { | |
| 1018 | + "version": "0.35.5", | |
| 1019 | + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", | |
| 1020 | + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", | |
| 1021 | + "cpu": [ | |
| 1022 | + "arm64" | |
| 1023 | + ], | |
| 1024 | + "dev": true, | |
| 1025 | + "license": "Apache-2.0", | |
| 1026 | + "optional": true, | |
| 1027 | + "os": [ | |
| 1028 | + "linux" | |
| 1029 | + ], | |
| 1030 | + "engines": { | |
| 1031 | + "node": ">=20.9.0" | |
| 1032 | + }, | |
| 1033 | + "funding": { | |
| 1034 | + "url": "https://opencollective.com/libvips" | |
| 1035 | + }, | |
| 1036 | + "optionalDependencies": { | |
| 1037 | + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" | |
| 1038 | + } | |
| 1039 | + }, | |
| 1040 | + "node_modules/@img/sharp-linuxmusl-x64": { | |
| 1041 | + "version": "0.35.5", | |
| 1042 | + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", | |
| 1043 | + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", | |
| 1044 | + "cpu": [ | |
| 1045 | + "x64" | |
| 1046 | + ], | |
| 1047 | + "dev": true, | |
| 1048 | + "license": "Apache-2.0", | |
| 1049 | + "optional": true, | |
| 1050 | + "os": [ | |
| 1051 | + "linux" | |
| 1052 | + ], | |
| 1053 | + "engines": { | |
| 1054 | + "node": ">=20.9.0" | |
| 1055 | + }, | |
| 1056 | + "funding": { | |
| 1057 | + "url": "https://opencollective.com/libvips" | |
| 1058 | + }, | |
| 1059 | + "optionalDependencies": { | |
| 1060 | + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" | |
| 1061 | + } | |
| 1062 | + }, | |
| 1063 | + "node_modules/@img/sharp-wasm32": { | |
| 1064 | + "version": "0.35.5", | |
| 1065 | + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", | |
| 1066 | + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", | |
| 1067 | + "dev": true, | |
| 1068 | + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", | |
| 1069 | + "optional": true, | |
| 1070 | + "dependencies": { | |
| 1071 | + "@emnapi/runtime": "^1.11.3" | |
| 1072 | + }, | |
| 1073 | + "engines": { | |
| 1074 | + "node": ">=20.9.0" | |
| 1075 | + }, | |
| 1076 | + "funding": { | |
| 1077 | + "url": "https://opencollective.com/libvips" | |
| 1078 | + } | |
| 1079 | + }, | |
| 1080 | + "node_modules/@img/sharp-webcontainers-wasm32": { | |
| 1081 | + "version": "0.35.5", | |
| 1082 | + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", | |
| 1083 | + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", | |
| 1084 | + "cpu": [ | |
| 1085 | + "wasm32" | |
| 1086 | + ], | |
| 1087 | + "dev": true, | |
| 1088 | + "license": "Apache-2.0", | |
| 1089 | + "optional": true, | |
| 1090 | + "dependencies": { | |
| 1091 | + "@img/sharp-wasm32": "0.35.5" | |
| 1092 | + }, | |
| 1093 | + "engines": { | |
| 1094 | + "node": ">=20.9.0" | |
| 1095 | + }, | |
| 1096 | + "funding": { | |
| 1097 | + "url": "https://opencollective.com/libvips" | |
| 1098 | + } | |
| 1099 | + }, | |
| 1100 | + "node_modules/@img/sharp-win32-arm64": { | |
| 1101 | + "version": "0.35.5", | |
| 1102 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", | |
| 1103 | + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", | |
| 1104 | + "cpu": [ | |
| 1105 | + "arm64" | |
| 1106 | + ], | |
| 1107 | + "dev": true, | |
| 1108 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1109 | + "optional": true, | |
| 1110 | + "os": [ | |
| 1111 | + "win32" | |
| 1112 | + ], | |
| 1113 | + "engines": { | |
| 1114 | + "node": ">=20.9.0" | |
| 1115 | + }, | |
| 1116 | + "funding": { | |
| 1117 | + "url": "https://opencollective.com/libvips" | |
| 1118 | + } | |
| 1119 | + }, | |
| 1120 | + "node_modules/@img/sharp-win32-ia32": { | |
| 1121 | + "version": "0.35.5", | |
| 1122 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", | |
| 1123 | + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", | |
| 1124 | + "cpu": [ | |
| 1125 | + "ia32" | |
| 1126 | + ], | |
| 1127 | + "dev": true, | |
| 1128 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1129 | + "optional": true, | |
| 1130 | + "os": [ | |
| 1131 | + "win32" | |
| 1132 | + ], | |
| 1133 | + "engines": { | |
| 1134 | + "node": "^20.9.0" | |
| 1135 | + }, | |
| 1136 | + "funding": { | |
| 1137 | + "url": "https://opencollective.com/libvips" | |
| 1138 | + } | |
| 1139 | + }, | |
| 1140 | + "node_modules/@img/sharp-win32-x64": { | |
| 1141 | + "version": "0.35.5", | |
| 1142 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", | |
| 1143 | + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", | |
| 1144 | + "cpu": [ | |
| 1145 | + "x64" | |
| 1146 | + ], | |
| 1147 | + "dev": true, | |
| 1148 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1149 | + "optional": true, | |
| 1150 | + "os": [ | |
| 1151 | + "win32" | |
| 1152 | + ], | |
| 1153 | + "engines": { | |
| 1154 | + "node": ">=20.9.0" | |
| 1155 | + }, | |
| 1156 | + "funding": { | |
| 1157 | + "url": "https://opencollective.com/libvips" | |
| 1158 | + } | |
| 1159 | + }, | |
| 1160 | + "node_modules/@jridgewell/resolve-uri": { | |
| 1161 | + "version": "3.1.3", | |
| 1162 | + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", | |
| 1163 | + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", | |
| 1164 | + "dev": true, | |
| 1165 | + "license": "MIT", | |
| 1166 | + "engines": { | |
| 1167 | + "node": ">=6.0.0" | |
| 1168 | + } | |
| 1169 | + }, | |
| 1170 | + "node_modules/@jridgewell/sourcemap-codec": { | |
| 1171 | + "version": "1.6.0", | |
| 1172 | + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", | |
| 1173 | + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", | |
| 1174 | + "dev": true, | |
| 1175 | + "license": "MIT" | |
| 1176 | + }, | |
| 1177 | + "node_modules/@jridgewell/trace-mapping": { | |
| 1178 | + "version": "0.3.9", | |
| 1179 | + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", | |
| 1180 | + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", | |
| 1181 | + "dev": true, | |
| 1182 | + "license": "MIT", | |
| 1183 | + "dependencies": { | |
| 1184 | + "@jridgewell/resolve-uri": "^3.0.3", | |
| 1185 | + "@jridgewell/sourcemap-codec": "^1.4.10" | |
| 1186 | + } | |
| 1187 | + }, | |
| 1188 | + "node_modules/@levischuck/tiny-cbor": { | |
| 1189 | + "version": "0.2.13", | |
| 1190 | + "resolved": "https://registry.npmjs.org/@levischuck/tiny-cbor/-/tiny-cbor-0.2.13.tgz", | |
| 1191 | + "integrity": "sha512-cGi6gJbe8/gC11KLNeBSUlq6jyuPTO4xQWka+8xn3m3JROdW062nu/x156z/7N4TnhMMBKSNOOpNw7++prLr5Q==", | |
| 1192 | + "license": "MIT" | |
| 1193 | + }, | |
| 1194 | + "node_modules/@peculiar/asn1-android": { | |
| 1195 | + "version": "2.11.1", | |
| 1196 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-android/-/asn1-android-2.11.1.tgz", | |
| 1197 | + "integrity": "sha512-AuUBRDNdWrgtnuJGXARa0Xdtq6OAD8GqezDQz6Qka7kyynMo9fzkcrtpBEHuX984uEB570BrhMZfJfkUDfpQfw==", | |
| 1198 | + "license": "MIT", | |
| 1199 | + "dependencies": { | |
| 1200 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1201 | + "asn1js": "^3.0.10", | |
| 1202 | + "tslib": "^2.8.1" | |
| 1203 | + }, | |
| 1204 | + "engines": { | |
| 1205 | + "node": ">=14" | |
| 1206 | + } | |
| 1207 | + }, | |
| 1208 | + "node_modules/@peculiar/asn1-cms": { | |
| 1209 | + "version": "2.11.1", | |
| 1210 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.11.1.tgz", | |
| 1211 | + "integrity": "sha512-Bk+oatE62dW0Tzzpfk6vdQxfGGEfvuGdWgmijnKjcv7HqZCJISs85z4zw2uDArrk+R1Oel1wts/BBl7HHrtAcA==", | |
| 1212 | + "license": "MIT", | |
| 1213 | + "dependencies": { | |
| 1214 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1215 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1216 | + "@peculiar/asn1-x509-attr": "^2.11.1", | |
| 1217 | + "asn1js": "^3.0.10", | |
| 1218 | + "tslib": "^2.8.1" | |
| 1219 | + }, | |
| 1220 | + "engines": { | |
| 1221 | + "node": ">=14" | |
| 1222 | + } | |
| 1223 | + }, | |
| 1224 | + "node_modules/@peculiar/asn1-csr": { | |
| 1225 | + "version": "2.11.1", | |
| 1226 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.11.1.tgz", | |
| 1227 | + "integrity": "sha512-KVfbXaKng8886/tOPG55t5K1XkTkGbR4amjIJzytXWobFU5nZgw/sKnSpa1hxP17nUSsrOF/7Mt9WUYeyLsi6Q==", | |
| 1228 | + "license": "MIT", | |
| 1229 | + "dependencies": { | |
| 1230 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1231 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1232 | + "asn1js": "^3.0.10", | |
| 1233 | + "tslib": "^2.8.1" | |
| 1234 | + }, | |
| 1235 | + "engines": { | |
| 1236 | + "node": ">=14" | |
| 1237 | + } | |
| 1238 | + }, | |
| 1239 | + "node_modules/@peculiar/asn1-ecc": { | |
| 1240 | + "version": "2.11.1", | |
| 1241 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.11.1.tgz", | |
| 1242 | + "integrity": "sha512-7MSNji77fQa/oN3WAfwagMy8EoJFg50sW4hZ1dtr0zU1BSugit0I2DGpIdPhvkNplopQhz5bogxpn1077eaamA==", | |
| 1243 | + "license": "MIT", | |
| 1244 | + "dependencies": { | |
| 1245 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1246 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1247 | + "asn1js": "^3.0.10", | |
| 1248 | + "tslib": "^2.8.1" | |
| 1249 | + }, | |
| 1250 | + "engines": { | |
| 1251 | + "node": ">=14" | |
| 1252 | + } | |
| 1253 | + }, | |
| 1254 | + "node_modules/@peculiar/asn1-pfx": { | |
| 1255 | + "version": "2.11.1", | |
| 1256 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.11.1.tgz", | |
| 1257 | + "integrity": "sha512-2SN2z8qkc2hk/GgTYA8RN54wtsCDZShg9gI2Mq1vLhdj1adcv5fhTbiEmExZUaAMqlizxiEpULQDfHM5iYtn1g==", | |
| 1258 | + "license": "MIT", | |
| 1259 | + "dependencies": { | |
| 1260 | + "@peculiar/asn1-cms": "^2.11.1", | |
| 1261 | + "@peculiar/asn1-pkcs8": "^2.11.1", | |
| 1262 | + "@peculiar/asn1-rsa": "^2.11.1", | |
| 1263 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1264 | + "asn1js": "^3.0.10", | |
| 1265 | + "tslib": "^2.8.1" | |
| 1266 | + }, | |
| 1267 | + "engines": { | |
| 1268 | + "node": ">=14" | |
| 1269 | + } | |
| 1270 | + }, | |
| 1271 | + "node_modules/@peculiar/asn1-pkcs8": { | |
| 1272 | + "version": "2.11.1", | |
| 1273 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.11.1.tgz", | |
| 1274 | + "integrity": "sha512-HqsSrnpQghRp9SM9QSmR6fa4z/BNktnKq7928+oq4qF0VAnuHZ4cyePKvcxh9fP4taBCP/WHNItlVNsYaQm2qw==", | |
| 1275 | + "license": "MIT", | |
| 1276 | + "dependencies": { | |
| 1277 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1278 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1279 | + "asn1js": "^3.0.10", | |
| 1280 | + "tslib": "^2.8.1" | |
| 1281 | + }, | |
| 1282 | + "engines": { | |
| 1283 | + "node": ">=14" | |
| 1284 | + } | |
| 1285 | + }, | |
| 1286 | + "node_modules/@peculiar/asn1-pkcs9": { | |
| 1287 | + "version": "2.11.1", | |
| 1288 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.11.1.tgz", | |
| 1289 | + "integrity": "sha512-OHFkTg8D2zYafILqFE4KPbqX8srpvd3diGDc2h2cduumawc765mOHGcuFMGvLWlL2bbCMWMmMSCtlXptsOuiPA==", | |
| 1290 | + "license": "MIT", | |
| 1291 | + "dependencies": { | |
| 1292 | + "@peculiar/asn1-cms": "^2.11.1", | |
| 1293 | + "@peculiar/asn1-pfx": "^2.11.1", | |
| 1294 | + "@peculiar/asn1-pkcs8": "^2.11.1", | |
| 1295 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1296 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1297 | + "@peculiar/asn1-x509-attr": "^2.11.1", | |
| 1298 | + "asn1js": "^3.0.10", | |
| 1299 | + "tslib": "^2.8.1" | |
| 1300 | + }, | |
| 1301 | + "engines": { | |
| 1302 | + "node": ">=14" | |
| 1303 | + } | |
| 1304 | + }, | |
| 1305 | + "node_modules/@peculiar/asn1-rsa": { | |
| 1306 | + "version": "2.11.1", | |
| 1307 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.11.1.tgz", | |
| 1308 | + "integrity": "sha512-6KwKGjulF489CpidZqkogNgLj6oGzgC4BL2FClM8PuJQ4t5NqT4q4a6A4vrSxBIBhMnL8hGYkLOpbVw0Vq38Tw==", | |
| 1309 | + "license": "MIT", | |
| 1310 | + "dependencies": { | |
| 1311 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1312 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1313 | + "asn1js": "^3.0.10", | |
| 1314 | + "tslib": "^2.8.1" | |
| 1315 | + }, | |
| 1316 | + "engines": { | |
| 1317 | + "node": ">=14" | |
| 1318 | + } | |
| 1319 | + }, | |
| 1320 | + "node_modules/@peculiar/asn1-schema": { | |
| 1321 | + "version": "2.11.1", | |
| 1322 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.11.1.tgz", | |
| 1323 | + "integrity": "sha512-jaU9OaCcbZUdyXx9hMETZB9xoNmxTGjOGFqd3cOwKFkpKnyKd9WxF3uqj4PvX4cyOMP9bSdHg5YyML2qtx/d/g==", | |
| 1324 | + "license": "MIT", | |
| 1325 | + "dependencies": { | |
| 1326 | + "@peculiar/utils": "^2.0.2", | |
| 1327 | + "asn1js": "^3.0.10", | |
| 1328 | + "tslib": "^2.8.1" | |
| 1329 | + }, | |
| 1330 | + "engines": { | |
| 1331 | + "node": ">=14" | |
| 1332 | + } | |
| 1333 | + }, | |
| 1334 | + "node_modules/@peculiar/asn1-x509": { | |
| 1335 | + "version": "2.11.1", | |
| 1336 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.11.1.tgz", | |
| 1337 | + "integrity": "sha512-SXU4/X6B3FquqQAN6ARI0bFDUV7+L1WlvPEPMKzEMkstd2D7UyM0r93fv241+OjdhqAKYGx5MvV3gzZMAp0APA==", | |
| 1338 | + "license": "MIT", | |
| 1339 | + "dependencies": { | |
| 1340 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1341 | + "@peculiar/utils": "^2.0.2", | |
| 1342 | + "asn1js": "^3.0.10", | |
| 1343 | + "tslib": "^2.8.1" | |
| 1344 | + }, | |
| 1345 | + "engines": { | |
| 1346 | + "node": ">=14" | |
| 1347 | + } | |
| 1348 | + }, | |
| 1349 | + "node_modules/@peculiar/asn1-x509-attr": { | |
| 1350 | + "version": "2.11.1", | |
| 1351 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.11.1.tgz", | |
| 1352 | + "integrity": "sha512-n7RKFrbTzt8pGBlZ90kmKEn1qsLTTyw7lrvHMK0xsA42kQugPk/GXYpNbEcl7DkkdVsU/one5UX7KQPfxLj8vQ==", | |
| 1353 | + "license": "MIT", | |
| 1354 | + "dependencies": { | |
| 1355 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1356 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1357 | + "asn1js": "^3.0.10", | |
| 1358 | + "tslib": "^2.8.1" | |
| 1359 | + }, | |
| 1360 | + "engines": { | |
| 1361 | + "node": ">=14" | |
| 1362 | + } | |
| 1363 | + }, | |
| 1364 | + "node_modules/@peculiar/utils": { | |
| 1365 | + "version": "2.0.3", | |
| 1366 | + "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz", | |
| 1367 | + "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==", | |
| 1368 | + "license": "MIT", | |
| 1369 | + "dependencies": { | |
| 1370 | + "tslib": "^2.8.1" | |
| 1371 | + } | |
| 1372 | + }, | |
| 1373 | + "node_modules/@peculiar/x509": { | |
| 1374 | + "version": "1.14.3", | |
| 1375 | + "resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.3.tgz", | |
| 1376 | + "integrity": "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA==", | |
| 1377 | + "license": "MIT", | |
| 1378 | + "dependencies": { | |
| 1379 | + "@peculiar/asn1-cms": "^2.6.0", | |
| 1380 | + "@peculiar/asn1-csr": "^2.6.0", | |
| 1381 | + "@peculiar/asn1-ecc": "^2.6.0", | |
| 1382 | + "@peculiar/asn1-pkcs9": "^2.6.0", | |
| 1383 | + "@peculiar/asn1-rsa": "^2.6.0", | |
| 1384 | + "@peculiar/asn1-schema": "^2.6.0", | |
| 1385 | + "@peculiar/asn1-x509": "^2.6.0", | |
| 1386 | + "pvtsutils": "^1.3.6", | |
| 1387 | + "reflect-metadata": "^0.2.2", | |
| 1388 | + "tslib": "^2.8.1", | |
| 1389 | + "tsyringe": "^4.10.0" | |
| 1390 | + }, | |
| 1391 | + "engines": { | |
| 1392 | + "node": ">=20.0.0" | |
| 1393 | + } | |
| 1394 | + }, | |
| 1395 | + "node_modules/@poppinss/colors": { | |
| 1396 | + "version": "4.1.6", | |
| 1397 | + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", | |
| 1398 | + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", | |
| 1399 | + "dev": true, | |
| 1400 | + "license": "MIT", | |
| 1401 | + "dependencies": { | |
| 1402 | + "kleur": "^4.1.5" | |
| 1403 | + } | |
| 1404 | + }, | |
| 1405 | + "node_modules/@poppinss/dumper": { | |
| 1406 | + "version": "0.6.5", | |
| 1407 | + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", | |
| 1408 | + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", | |
| 1409 | + "dev": true, | |
| 1410 | + "license": "MIT", | |
| 1411 | + "dependencies": { | |
| 1412 | + "@poppinss/colors": "^4.1.5", | |
| 1413 | + "@sindresorhus/is": "^7.0.2", | |
| 1414 | + "supports-color": "^10.0.0" | |
| 1415 | + } | |
| 1416 | + }, | |
| 1417 | + "node_modules/@poppinss/exception": { | |
| 1418 | + "version": "1.2.3", | |
| 1419 | + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", | |
| 1420 | + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", | |
| 1421 | + "dev": true, | |
| 1422 | + "license": "MIT" | |
| 1423 | + }, | |
| 1424 | + "node_modules/@simplewebauthn/server": { | |
| 1425 | + "version": "13.3.3", | |
| 1426 | + "resolved": "https://registry.npmjs.org/@simplewebauthn/server/-/server-13.3.3.tgz", | |
| 1427 | + "integrity": "sha512-LelX/lcy5cjc15A86i/aNxHhB5eU7dd20QsbP0VLAf9e38+SLlsnqCCyecx3xqfGofhmX05h1J9fKRYWxw+luA==", | |
| 1428 | + "license": "MIT", | |
| 1429 | + "dependencies": { | |
| 1430 | + "@hexagon/base64": "^1.1.27", | |
| 1431 | + "@levischuck/tiny-cbor": "^0.2.2", | |
| 1432 | + "@peculiar/asn1-android": "^2.6.0", | |
| 1433 | + "@peculiar/asn1-ecc": "^2.6.1", | |
| 1434 | + "@peculiar/asn1-rsa": "^2.6.1", | |
| 1435 | + "@peculiar/asn1-schema": "^2.6.0", | |
| 1436 | + "@peculiar/asn1-x509": "^2.6.1", | |
| 1437 | + "@peculiar/x509": "^1.14.3" | |
| 1438 | + }, | |
| 1439 | + "engines": { | |
| 1440 | + "node": ">=20.0.0" | |
| 1441 | + } | |
| 1442 | + }, | |
| 1443 | + "node_modules/@sindresorhus/is": { | |
| 1444 | + "version": "7.2.0", | |
| 1445 | + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", | |
| 1446 | + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", | |
| 1447 | + "dev": true, | |
| 1448 | + "license": "MIT", | |
| 1449 | + "engines": { | |
| 1450 | + "node": ">=18" | |
| 1451 | + }, | |
| 1452 | + "funding": { | |
| 1453 | + "url": "https://github.com/sindresorhus/is?sponsor=1" | |
| 1454 | + } | |
| 1455 | + }, | |
| 1456 | + "node_modules/@speed-highlight/core": { | |
| 1457 | + "version": "1.2.24", | |
| 1458 | + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz", | |
| 1459 | + "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==", | |
| 1460 | + "dev": true, | |
| 1461 | + "license": "CC0-1.0" | |
| 1462 | + }, | |
| 1463 | + "node_modules/@types/node": { | |
| 1464 | + "version": "18.19.130", | |
| 1465 | + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", | |
| 1466 | + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", | |
| 1467 | + "dev": true, | |
| 1468 | + "license": "MIT", | |
| 1469 | + "dependencies": { | |
| 1470 | + "undici-types": "~5.26.4" | |
| 1471 | + } | |
| 1472 | + }, | |
| 1473 | + "node_modules/@types/node-fetch": { | |
| 1474 | + "version": "2.6.13", | |
| 1475 | + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz", | |
| 1476 | + "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==", | |
| 1477 | + "dev": true, | |
| 1478 | + "license": "MIT", | |
| 1479 | + "dependencies": { | |
| 1480 | + "@types/node": "*", | |
| 1481 | + "form-data": "^4.0.4" | |
| 1482 | + } | |
| 1483 | + }, | |
| 1484 | + "node_modules/@types/pako": { | |
| 1485 | + "version": "2.0.4", | |
| 1486 | + "resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz", | |
| 1487 | + "integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==", | |
| 1488 | + "dev": true, | |
| 1489 | + "license": "MIT" | |
| 1490 | + }, | |
| 1491 | + "node_modules/@types/yargs": { | |
| 1492 | + "version": "17.0.24", | |
| 1493 | + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", | |
| 1494 | + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", | |
| 1495 | + "dev": true, | |
| 1496 | + "license": "MIT", | |
| 1497 | + "dependencies": { | |
| 1498 | + "@types/yargs-parser": "*" | |
| 1499 | + } | |
| 1500 | + }, | |
| 1501 | + "node_modules/@types/yargs-parser": { |
package.json added
| 1 | + { | |
| 2 | + "name": "branchwell", | |
| 3 | + "version": "1.0.0", | |
| 4 | + "description": "Branchwell: open Git hosting where votes decide", | |
| 5 | + "main": "src/index.ts", | |
| 6 | + "type": "module", | |
| 7 | + "scripts": { | |
| 8 | + "build": "node build-static.mjs", | |
| 9 | + "deploy": "node build-static.mjs && wrangler deploy", | |
| 10 | + "dev": "node build-static.mjs && wrangler dev", | |
| 11 | + "check": "tsc" | |
| 12 | + }, | |
| 13 | + "keywords": [], | |
| 14 | + "author": "", | |
| 15 | + "license": "CC0-1.0", | |
| 16 | + "dependencies": { | |
| 17 | + "@simplewebauthn/server": "^13.3.3", | |
| 18 | + "pako": "^2.2.0" | |
| 19 | + }, | |
| 20 | + "devDependencies": { | |
| 21 | + "@cloudflare/workers-types": "^5.20261201.1", | |
| 22 | + "@types/pako": "^2.0.4", | |
| 23 | + "typescript": "^7.0.2", | |
| 24 | + "wrangler": "^4.170.0" | |
| 25 | + } | |
| 26 | + } |
src/auth.ts added
| 1 | + // Passkey sign-in (WebAuthn) and push keys. No passwords, no email, no third-party sign-in. | |
| 2 | + import { | |
| 3 | + generateRegistrationOptions, verifyRegistrationResponse, generateAuthenticationOptions, verifyAuthenticationResponse, | |
| 4 | + } from '@simplewebauthn/server'; | |
| 5 | + import type { Env } from './env'; | |
| 6 | + | |
| 7 | + export const RP_NAME = 'Branchwell'; | |
| 8 | + export const VOTE_WAIT_MS = 24 * 3600 * 1000; | |
| 9 | + const SESSION_DAYS = 60; | |
| 10 | + export interface Account { id: string; handle: string; created_at: number } | |
| 11 | + | |
| 12 | + const b64u = (b: Uint8Array) => btoa(String.fromCharCode(...b)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); | |
| 13 | + const unb64u = (s: string) => Uint8Array.from(atob(s.replace(/-/g, '+').replace(/_/g, '/') + '==='.slice((s.length + 3) % 4)), (c) => c.charCodeAt(0)); | |
| 14 | + export const randomId = (n = 18) => b64u(crypto.getRandomValues(new Uint8Array(n))); | |
| 15 | + export async function sha256(s: string) { return b64u(new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(s)))); } | |
| 16 | + | |
| 17 | + function rp(req: Request) { const u = new URL(req.url); return { rpID: u.hostname, origin: u.origin }; } | |
| 18 | + export const HANDLE_RE = /^[a-z0-9](?:[a-z0-9-]{1,28}[a-z0-9])$/; | |
| 19 | + | |
| 20 | + export async function currentAccount(req: Request, env: Env): Promise<Account | null> { | |
| 21 | + const m = (req.headers.get('cookie') || '').match(/(?:^|;\s*)bw_s=([A-Za-z0-9_-]+)/); | |
| 22 | + if (!m) return null; | |
| 23 | + const row = await env.DB.prepare('SELECT a.id, a.handle, a.created_at FROM sessions s JOIN accounts a ON a.id = s.account_id WHERE s.id = ? AND s.expires_at > ?') | |
| 24 | + .bind(await sha256(m[1]), Date.now()).first<Account>(); | |
| 25 | + return row || null; | |
| 26 | + } | |
| 27 | + export const canVote = (a: Account) => Date.now() - a.created_at >= VOTE_WAIT_MS; | |
| 28 | + | |
| 29 | + async function startSession(env: Env, accountId: string): Promise<string> { | |
| 30 | + const token = randomId(32); | |
| 31 | + const now = Date.now(); | |
| 32 | + await env.DB.prepare('INSERT INTO sessions (id, account_id, created_at, expires_at) VALUES (?, ?, ?, ?)').bind(await sha256(token), accountId, now, now + SESSION_DAYS * 864e5).run(); | |
| 33 | + return `bw_s=${token}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${SESSION_DAYS * 86400}`; | |
| 34 | + } | |
| 35 | + export const clearCookie = 'bw_s=; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=0'; | |
| 36 | + | |
| 37 | + const json = (body: unknown, status = 200, headers: Record<string, string> = {}) => | |
| 38 | + new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json', 'cache-control': 'no-store', ...headers } }); | |
| 39 | + | |
| 40 | + async function saveChallenge(env: Env, kind: string, challenge: string, data: unknown) { | |
| 41 | + const id = randomId(); | |
| 42 | + await env.DB.prepare('DELETE FROM challenges WHERE created_at < ?').bind(Date.now() - 600_000).run(); | |
| 43 | + await env.DB.prepare('INSERT INTO challenges (id, challenge, kind, data, created_at) VALUES (?, ?, ?, ?, ?)').bind(id, challenge, kind, JSON.stringify(data ?? null), Date.now()).run(); | |
| 44 | + return id; | |
| 45 | + } | |
| 46 | + async function takeChallenge(env: Env, id: string, kind: string) { | |
| 47 | + const row = await env.DB.prepare('SELECT challenge, data, created_at FROM challenges WHERE id = ? AND kind = ?').bind(id, kind).first<{ challenge: string; data: string; created_at: number }>(); | |
| 48 | + await env.DB.prepare('DELETE FROM challenges WHERE id = ?').bind(id).run(); | |
| 49 | + if (!row || Date.now() - row.created_at > 600_000) return null; | |
| 50 | + return { challenge: row.challenge, data: JSON.parse(row.data) }; | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** /api/auth/* */ | |
| 54 | + export async function handleAuth(req: Request, env: Env, path: string): Promise<Response> { | |
| 55 | + const { rpID, origin } = rp(req); | |
| 56 | + if (req.method !== 'POST') return json({ error: 'POST only' }, 405); | |
| 57 | + if (req.headers.get('origin') !== origin) return json({ error: 'Bad origin.' }, 403); | |
| 58 | + const body = await req.json<Record<string, unknown>>().catch(() => ({} as Record<string, unknown>)); | |
| 59 | + const me = await currentAccount(req, env); | |
| 60 | + | |
| 61 | + if (path === 'register/options') { | |
| 62 | + // New account (pick a name) or, when signed in, add another passkey to your account. | |
| 63 | + let handle = me?.handle || String(body.handle || '').trim().toLowerCase(); | |
| 64 | + let userId = me?.id; | |
| 65 | + if (!me) { | |
| 66 | + if (!HANDLE_RE.test(handle)) return json({ error: 'Pick a name of 3 to 30 letters, numbers or dashes.' }, 400); | |
| 67 | + if (RESERVED.has(handle)) return json({ error: 'That name is taken. Try another.' }, 400); | |
| 68 | + if (await env.DB.prepare('SELECT 1 FROM accounts WHERE handle = ?').bind(handle).first()) return json({ error: 'That name is taken. Try another.' }, 400); | |
| 69 | + if (await env.DB.prepare('SELECT 1 FROM orgs WHERE handle = ?').bind(handle).first()) return json({ error: 'That name belongs to a company here. Try another.' }, 400); | |
| 70 | + const ipHash = await sha256((req.headers.get('cf-connecting-ip') || '') + (env.IP_SALT || '')); | |
| 71 | + const n = await env.DB.prepare('SELECT COUNT(*) AS n FROM accounts WHERE ip_hash = ? AND created_at > ?').bind(ipHash, Date.now() - 864e5).first<number>('n'); | |
| 72 | + if ((n || 0) >= 3) return json({ error: 'Too many new accounts from this network today. Try again tomorrow.' }, 429); | |
| 73 | + userId = crypto.randomUUID(); | |
| 74 | + } | |
| 75 | + const opts = await generateRegistrationOptions({ | |
| 76 | + rpName: RP_NAME, rpID, userName: handle!, userDisplayName: handle!, userID: new TextEncoder().encode(userId!) as Uint8Array<ArrayBuffer>, | |
| 77 | + attestationType: 'none', authenticatorSelection: { residentKey: 'required', userVerification: 'preferred' }, | |
| 78 | + }); | |
| 79 | + const cid = await saveChallenge(env, 'reg', opts.challenge, { handle, userId, existing: !!me }); | |
| 80 | + return json({ cid, options: opts }); | |
| 81 | + } | |
| 82 | + | |
| 83 | + if (path === 'register/verify') { | |
| 84 | + const ch = await takeChallenge(env, String(body.cid || ''), 'reg'); | |
| 85 | + if (!ch) return json({ error: 'That took too long. Try again.' }, 400); | |
| 86 | + let v; | |
| 87 | + try { v = await verifyRegistrationResponse({ response: body.response as never, expectedChallenge: ch.challenge, expectedOrigin: origin, expectedRPID: rpID, requireUserVerification: false }); } | |
| 88 | + catch (e) { return json({ error: 'Passkey not accepted: ' + (e as Error).message }, 400); } | |
| 89 | + if (!v.verified || !v.registrationInfo) return json({ error: 'Passkey not accepted.' }, 400); | |
| 90 | + const { handle, userId, existing } = ch.data as { handle: string; userId: string; existing: boolean }; | |
| 91 | + const now = Date.now(); | |
| 92 | + if (!existing) { | |
| 93 | + const ipHash = await sha256((req.headers.get('cf-connecting-ip') || '') + (env.IP_SALT || '')); | |
| 94 | + try { await env.DB.prepare('INSERT INTO accounts (id, handle, created_at, ip_hash) VALUES (?, ?, ?, ?)').bind(userId, handle, now, ipHash).run(); } | |
| 95 | + catch { return json({ error: 'That name was just taken. Try another.' }, 400); } | |
| 96 | + } else if (!me || me.id !== userId) return json({ error: 'Sign in again.' }, 401); | |
| 97 | + const cred = v.registrationInfo.credential; | |
| 98 | + await env.DB.prepare('INSERT INTO passkeys (id, account_id, public_key, counter, transports, created_at) VALUES (?, ?, ?, ?, ?, ?)') | |
| 99 | + .bind(cred.id, userId, b64u(cred.publicKey), cred.counter, JSON.stringify(cred.transports || []), now).run(); | |
| 100 | + const headers: Record<string, string> = existing ? {} : { 'set-cookie': await startSession(env, userId) }; | |
| 101 | + return json({ ok: true, handle }, 200, headers); | |
| 102 | + } | |
| 103 | + | |
| 104 | + if (path === 'login/options') { | |
| 105 | + const opts = await generateAuthenticationOptions({ rpID, userVerification: 'preferred', allowCredentials: [] }); | |
| 106 | + const cid = await saveChallenge(env, 'auth', opts.challenge, null); | |
| 107 | + return json({ cid, options: opts }); | |
| 108 | + } | |
| 109 | + | |
| 110 | + if (path === 'login/verify') { | |
| 111 | + const ch = await takeChallenge(env, String(body.cid || ''), 'auth'); | |
| 112 | + if (!ch) return json({ error: 'That took too long. Try again.' }, 400); | |
| 113 | + const resp = body.response as { id: string }; | |
| 114 | + const pk = await env.DB.prepare('SELECT id, account_id, public_key, counter, transports FROM passkeys WHERE id = ?').bind(resp?.id || '').first<{ id: string; account_id: string; public_key: string; counter: number; transports: string }>(); | |
| 115 | + if (!pk) return json({ error: 'We don\'t know that passkey. Make an account first.' }, 400); | |
| 116 | + let v; | |
| 117 | + try { | |
| 118 | + v = await verifyAuthenticationResponse({ response: body.response as never, expectedChallenge: ch.challenge, expectedOrigin: origin, expectedRPID: rpID, requireUserVerification: false, | |
| 119 | + credential: { id: pk.id, publicKey: unb64u(pk.public_key), counter: pk.counter, transports: JSON.parse(pk.transports || '[]') } }); | |
| 120 | + } catch (e) { return json({ error: 'Passkey not accepted: ' + (e as Error).message }, 400); } | |
| 121 | + if (!v.verified) return json({ error: 'Passkey not accepted.' }, 400); | |
| 122 | + await env.DB.prepare('UPDATE passkeys SET counter = ?, last_used = ? WHERE id = ?').bind(v.authenticationInfo.newCounter, Date.now(), pk.id).run(); | |
| 123 | + const acct = await env.DB.prepare('SELECT handle FROM accounts WHERE id = ?').bind(pk.account_id).first<string>('handle'); | |
| 124 | + return json({ ok: true, handle: acct }, 200, { 'set-cookie': await startSession(env, pk.account_id) }); | |
| 125 | + } | |
| 126 | + | |
| 127 | + if (path === 'logout') { | |
| 128 | + const m = (req.headers.get('cookie') || '').match(/(?:^|;\s*)bw_s=([A-Za-z0-9_-]+)/); | |
| 129 | + if (m) await env.DB.prepare('DELETE FROM sessions WHERE id = ?').bind(await sha256(m[1])).run(); | |
| 130 | + return json({ ok: true }, 200, { 'set-cookie': clearCookie }); | |
| 131 | + } | |
| 132 | + | |
| 133 | + if (path === 'push-keys/create') { | |
| 134 | + if (!me) return json({ error: 'Sign in first.' }, 401); | |
| 135 | + const count = await env.DB.prepare('SELECT COUNT(*) AS n FROM push_keys WHERE account_id = ?').bind(me.id).first<number>('n'); | |
| 136 | + if ((count || 0) >= 10) return json({ error: 'You have 10 push keys. Remove one first.' }, 400); | |
| 137 | + const name = String(body.name || 'My computer').slice(0, 60); | |
| 138 | + const key = 'bw_push_' + randomId(24).replace(/[-_]/g, 'x'); | |
| 139 | + await env.DB.prepare('INSERT INTO push_keys (id, account_id, name, hash, created_at) VALUES (?, ?, ?, ?, ?)').bind(randomId(9), me.id, name, await sha256(key), Date.now()).run(); | |
| 140 | + return json({ ok: true, key, handle: me.handle }); | |
| 141 | + } | |
| 142 | + if (path === 'push-keys/delete') { | |
| 143 | + if (!me) return json({ error: 'Sign in first.' }, 401); | |
| 144 | + await env.DB.prepare('DELETE FROM push_keys WHERE id = ? AND account_id = ?').bind(String(body.id || ''), me.id).run(); | |
| 145 | + return json({ ok: true }); | |
| 146 | + } | |
| 147 | + return json({ error: 'Not found' }, 404); | |
| 148 | + } | |
| 149 | + | |
| 150 | + /** Git over HTTPS sends "Basic name:push-key". */ | |
| 151 | + export async function pusherFromBasic(req: Request, env: Env): Promise<Account | null> { | |
| 152 | + const h = req.headers.get('authorization') || ''; | |
| 153 | + if (!h.startsWith('Basic ')) return null; | |
| 154 | + let decoded = ''; | |
| 155 | + try { decoded = atob(h.slice(6)); } catch { return null; } | |
| 156 | + const i = decoded.indexOf(':'); | |
| 157 | + const key = decoded.slice(i + 1); | |
| 158 | + if (!key.startsWith('bw_push_')) return null; | |
| 159 | + const row = await env.DB.prepare('SELECT a.id, a.handle, a.created_at, k.id AS kid FROM push_keys k JOIN accounts a ON a.id = k.account_id WHERE k.hash = ?') | |
| 160 | + .bind(await sha256(key)).first<Account & { kid: string }>(); | |
| 161 | + if (!row) return null; | |
| 162 | + await env.DB.prepare('UPDATE push_keys SET last_used = ? WHERE id = ?').bind(Date.now(), row.kid).run(); | |
| 163 | + return { id: row.id, handle: row.handle, created_at: row.created_at }; | |
| 164 | + } | |
| 165 | + | |
| 166 | + export const RESERVED = new Set(['api', 'assets', 'widget', 'signin', 'signout', 'account', 'new', 'repos', 'how-to-pull', 'how-to-contribute', 'rules', | |
| 167 | + 'features', 'feature-vote', 'careers', 'privacy', 'source', 'robots.txt', 'sitemap.xml', 'llms.txt', 'favicon.svg', 'admin', 'branchwell-votes', | |
| 168 | + 'about', 'help', 'login', 'logout', 'settings', 'u', 'static', 'www', 'git', 'root', 'system', 'votes', 'search', 'explore', 'companies', 'research', 'projects', 'orgs']); |
src/checks.ts added
| 1 | + // The checks every pushed file must pass before a commit lands ("tested, then merged"). | |
| 2 | + // Kept short and public so anyone can see exactly what is checked. | |
| 3 | + import { td } from './git/core'; | |
| 4 | + | |
| 5 | + export const MAX_FILE = 10 * 1024 * 1024; | |
| 6 | + const SECRETS: [RegExp, string][] = [ | |
| 7 | + [/-----BEGIN (?:RSA |EC |OPENSSH |DSA |PGP )?PRIVATE KEY-----/, 'a private key'], | |
| 8 | + [/\bAKIA[0-9A-Z]{16}\b/, 'an AWS access key'], | |
| 9 | + [/\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{32,}/, 'an API secret key'], | |
| 10 | + [/\bgh[pousr]_[A-Za-z0-9]{36,}\b/, 'a GitHub token'], | |
| 11 | + [/\bxox[abprs]-[A-Za-z0-9-]{10,}/, 'a Slack token'], | |
| 12 | + [/\bAIza[0-9A-Za-z_-]{35}\b/, 'a Google API key'], | |
| 13 | + [/\bbw_push_[A-Za-z0-9]{20,}/, 'a Branchwell push key'], | |
| 14 | + ]; | |
| 15 | + | |
| 16 | + /** Returns why a file fails, or null when it passes. */ | |
| 17 | + export function checkBlob(path: string, data: Uint8Array): string | null { | |
| 18 | + if (data.length > MAX_FILE) return `file is over 10 MB (${(data.length / 1048576).toFixed(1)} MB)`; | |
| 19 | + let bin = false; | |
| 20 | + for (let i = 0; i < Math.min(data.length, 8000); i++) if (data[i] === 0) { bin = true; break; } | |
| 21 | + if (bin) return null; | |
| 22 | + const text = td.decode(data); | |
| 23 | + for (const [re, what] of SECRETS) if (re.test(text)) return `looks like it contains ${what}. Never push secrets`; | |
| 24 | + if (/\.json$/i.test(path)) { try { JSON.parse(text); } catch (e) { return `is not valid JSON (${(e as Error).message.slice(0, 80)})`; } } | |
| 25 | + return null; | |
| 26 | + } | |
| 27 | + | |
| 28 | + export const CHECKS_TEXT = [ | |
| 29 | + 'No file over 10 MB.', | |
| 30 | + 'No secrets: private keys, API keys and access tokens are refused.', | |
| 31 | + 'Every .json file must be valid JSON.', | |
| 32 | + 'History is never rewritten: pushes must build on the branch as it is (no force-push).', | |
| 33 | + 'Branches are only removed by votes, never by push.', | |
| 34 | + ]; |
src/content.ts added
| 1 | + // The public pages: home, how to pull, how to contribute, how votes work, for apps, research, careers, privacy. | |
| 2 | + import { esc } from './html'; | |
| 3 | + import { CHECKS_TEXT } from './checks'; | |
| 4 | + | |
| 5 | + export const DIAGRAM = `<div class="diagram"><svg viewBox="0 0 520 330" role="img" aria-labelledby="dg-t dg-d" xmlns="http://www.w3.org/2000/svg"> | |
| 6 | + <title id="dg-t">How a branch grows on Branchwell</title><desc id="dg-d">Commits land on the main branch right away. Each one shows as new. Three votes up keep it for good. Three votes down take it back out. A side branch follows the same rule.</desc> | |
| 7 | + <style>.ln{stroke:currentColor;stroke-width:5;fill:none;stroke-linecap:round;opacity:.55}.t{font:600 14px system-ui,sans-serif;fill:currentColor}.s{font:13px system-ui,sans-serif;fill:currentColor;opacity:.75}</style> | |
| 8 | + <path class="ln" d="M40 70H480"/><path class="ln" d="M160 70c30 0 40 90 90 90h160"/> | |
| 9 | + <circle cx="70" cy="70" r="15" fill="#1f6b43"/><circle cx="160" cy="70" r="15" fill="#1f6b43"/><circle cx="300" cy="70" r="15" fill="#f2b84b"/> | |
| 10 | + <circle cx="400" cy="70" r="15" fill="none" stroke="#c4532d" stroke-width="4" stroke-dasharray="5 4"/><path d="M392 62l16 16M408 62l-16 16" stroke="#c4532d" stroke-width="4" stroke-linecap="round"/> | |
| 11 | + <circle cx="300" cy="160" r="15" fill="#f2b84b"/><circle cx="400" cy="160" r="15" fill="#f2b84b"/> | |
| 12 | + <text class="t" x="40" y="35">main</text><text class="t" x="250" y="200">your-idea</text> | |
| 13 | + <text class="s" x="40" y="112">3 up</text><text class="s" x="276" y="112">new</text><text class="s" x="366" y="112">3 down</text> | |
| 14 | + <g transform="translate(40 240)"><rect width="440" height="64" rx="18" fill="currentColor" opacity=".07"/> | |
| 15 | + <circle cx="30" cy="32" r="10" fill="#1f6b43"/><text class="s" x="48" y="37">kept for good</text> | |
| 16 | + <circle cx="170" cy="32" r="10" fill="#f2b84b"/><text class="s" x="188" y="37">new</text> | |
| 17 | + <circle cx="270" cy="32" r="10" fill="none" stroke="#c4532d" stroke-width="3" stroke-dasharray="4 3"/><text class="s" x="288" y="37">taken back out</text></g> | |
| 18 | + </svg></div>`; | |
| 19 | + | |
| 20 | + export function home(stats: { repos: number; companies: number }) { | |
| 21 | + return `<section class="hero"><div> | |
| 22 | + <div class="counter" data-visitor-odometer data-visitor-site="branchwell"></div> | |
| 23 | + <span class="eyebrow">Open Git hosting</span><h1>Every branch grows in the open.</h1> | |
| 24 | + <p class="lede">Branchwell hosts Git repositories that anyone can pull. Anyone signed in can push straight to a branch. There are no pull requests and no reviews. People vote on each commit instead.</p> | |
| 25 | + <div class="btns"><a class="btn" href="/research">Get the research</a><a class="btn ghost" href="/how-to-contribute">How to contribute</a></div> | |
| 26 | + </div>${DIAGRAM}</section> | |
| 27 | + <section class="sec"><h2>How it works</h2><p class="sub">Four steps, and nothing waits on a reviewer.</p> | |
| 28 | + <ol class="steps"> | |
| 29 | + <li><b>Pull</b><span>Clone any repository with plain Git. No account needed.</span></li> | |
| 30 | + <li><b>Push</b><span>Sign in with a passkey, make a push key, and push straight to a branch.</span></li> | |
| 31 | + <li><b>Checks</b><span>Every push is checked first: no secrets, no huge files, valid data. If it passes, it lands.</span></li> | |
| 32 | + <li><b>Vote</b><span>Each new commit is open to votes. 3 up keeps it for good. 3 down takes it back out.</span></li> | |
| 33 | + </ol></section> | |
| 34 | + <section class="sec grid2"><div><h2>Every company, in the open</h2> | |
| 35 | + <p class="sub">${stats.companies ? stats.companies + ' companies' : 'Each company'} ha${stats.companies === 1 ? 's' : 've'} an account here, with projects inside. Every one starts with its research: the full plan, and every public source summarized in plain words with a link to the original. It is all public domain. Pull it, read it, add to it.</p> | |
| 36 | + <div class="copy"><code id="clone-research">git clone https://branchwell.ai/sunlaid/research.git</code><button class="btn sm" type="button" data-copy="clone-research">Copy</button></div> | |
| 37 | + <p><a href="/companies">See every company</a> · <a href="/research">All the research</a></p></div> | |
| 38 | + <div class="cards"><div class="card"><h3>No pull requests</h3><p>Your commit goes in as soon as it passes the checks. The people who use a branch decide what stays.</p></div> | |
| 39 | + <div class="card"><h3>Passkeys only</h3><p>Sign in with your face, fingerprint or device PIN. No passwords to steal or forget.</p></div> | |
| 40 | + <div class="card"><h3>History stays honest</h3><p>Nothing is rewritten. A voted-down commit is taken back out with a new commit anyone can see.</p></div></div></section> | |
| 41 | + <section class="sec"><div class="band"><div><h2>New features, voted in</h2><p>Apps built on our platform mark every new feature with a small New badge and thumbs up and down. 3 thumbs up and the feature stays for good. 3 thumbs down and it goes away.</p></div> | |
| 42 | + <div><a class="btn" href="/features">Add it to an app</a></div></div></section> | |
| 43 | + <section class="sec" id="branch"><h2>Open your own branch</h2><p class="sub">Anyone can open a branch here without asking, under any name they like. Our code, designs and research are public domain and free to use.</p> | |
| 44 | + <div class="btns"><a class="btn ghost" href="/branchwell/source">See our source</a><a class="btn ghost" href="/repos">All projects (${stats.repos})</a></div></section>`; | |
| 45 | + } | |
| 46 | + | |
| 47 | + export const howToPull = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 48 | + <span class="eyebrow">How to pull</span><h1 class="sm">Get any repository in one line</h1> | |
| 49 | + <p class="lede">Every repository on Branchwell is public. You don't need an account to read or pull.</p> | |
| 50 | + <h2>1. Get Git</h2> | |
| 51 | + <p>Mac: open Terminal and type <code>git --version</code>. If it isn't there, your Mac offers to install it. Windows: install Git from <a href="https://git-scm.com/downloads" rel="noopener">git-scm.com</a>. Linux: use your package manager, for example <code>sudo apt install git</code>.</p> | |
| 52 | + <h2>2. Clone</h2> | |
| 53 | + <pre><code>git clone https://branchwell.ai/sunlaid/research.git | |
| 54 | + cd research</code></pre> | |
| 55 | + <p>Every project lives inside its owner, so the address is <code>branchwell.ai/owner/project.git</code>. Swap in any one you like. You'll find them all on the <a href="/companies">companies page</a> and the <a href="/repos">projects page</a>.</p> | |
| 56 | + <h2>3. Stay up to date</h2> | |
| 57 | + <pre><code>git pull</code></pre> | |
| 58 | + <p>Run it any time to get the newest commits, including any that votes have taken back out.</p> | |
| 59 | + <h2>Want just one branch?</h2> | |
| 60 | + <pre><code>git clone --branch your-idea --single-branch https://branchwell.ai/sunlaid/research.git</code></pre> | |
| 61 | + <h2>No Git?</h2> | |
| 62 | + <p>You can read every file right on the site. Open a repository, click through its folders, and use <b>Raw</b> on any file to download it.</p> | |
| 63 | + <p class="btns"><a class="btn" href="/how-to-contribute">Next: how to contribute</a></p> | |
| 64 | + </div></section>`; | |
| 65 | + | |
| 66 | + export const howToContribute = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 67 | + <span class="eyebrow">How to contribute</span><h1 class="sm">Push straight to a branch</h1> | |
| 68 | + <p class="lede">No pull requests and no waiting for a reviewer. If your commit passes the checks, it lands right away. Then people vote on it.</p> | |
| 69 | + <h2>1. Sign in with a passkey</h2> | |
| 70 | + <p>Go to <a href="/signin">Sign in</a>, pick a name, and make a passkey with your face, fingerprint or device PIN. There is no password and no email.</p> | |
| 71 | + <h2>2. Make a push key</h2> | |
| 72 | + <p>On <a href="/account">your account page</a>, make a push key for each computer. Git can't use passkeys, so this key is how Git proves the push is yours. We show it once. You can remove it any time.</p> | |
| 73 | + <h2>3. Let Git remember it</h2> | |
| 74 | + <pre><code># Mac | |
| 75 | + git config --global credential.helper osxkeychain | |
| 76 | + # Windows (Git for Windows) | |
| 77 | + git config --global credential.helper manager | |
| 78 | + # Linux | |
| 79 | + git config --global credential.helper store</code></pre> | |
| 80 | + <p>The first time you push, Git asks for a username and password. Type your Branchwell name and paste the push key as the password.</p> | |
| 81 | + <h2>4. Edit, commit, push</h2> | |
| 82 | + <pre><code>git clone https://branchwell.ai/stridewell/research.git | |
| 83 | + cd research | |
| 84 | + # edit a file, for example README.md | |
| 85 | + git add -A | |
| 86 | + git commit -m "Add a study on socket fit" | |
| 87 | + git push</code></pre> | |
| 88 | + <p>Git prints a link to the commits page, where people can vote on your work.</p> | |
| 89 | + <h2>Try something bigger on your own branch</h2> | |
| 90 | + <pre><code>git switch -c your-idea | |
| 91 | + git push -u origin your-idea</code></pre> | |
| 92 | + <p>Anyone can open a branch, under any name. Branches follow the same voting rule as commits.</p> | |
| 93 | + <h2>Start a new project</h2> | |
| 94 | + <p>Make one on the <a href="/new">new project page</a>, under your own name or a company you belong to. Or just push to a new name and it is made for you:</p> | |
| 95 | + <pre><code>git remote add origin https://branchwell.ai/your-name/my-project.git | |
| 96 | + git push -u origin main</code></pre> | |
| 97 | + <h2>What every push is checked for</h2> | |
| 98 | + <ul>${CHECKS_TEXT.map((t) => `<li>${esc(t)}</li>`).join('')}</ul> | |
| 99 | + <p>If a check fails, Git shows you why and nothing changes. Fix it and push again.</p> | |
| 100 | + <h2>Good research contributions</h2> | |
| 101 | + <ul><li>A real, public link anyone can open: a study, an official page, a dataset.</li><li>A short summary in your own words. No copied paragraphs.</li><li>No prices, no ads and no private personal details.</li></ul> | |
| 102 | + <p class="btns"><a class="btn" href="/rules">How votes work</a></p> | |
| 103 | + </div></section>`; | |
| 104 | + | |
| 105 | + export const rules = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 106 | + <span class="eyebrow">How votes work</span><h1 class="sm">The whole system fits on one page</h1> | |
| 107 | + <p class="lede">There are no pull requests and no reviews. Anyone signed in can push commits straight to a branch. People vote on commits and branches. That's it.</p> | |
| 108 | + <h2>Commits</h2> | |
| 109 | + <ul><li>A commit lands as soon as it passes the checks. It shows as <span class="tag new">new</span>.</li> | |
| 110 | + <li><b>3 votes down</b> and it is taken back out of the branch, automatically. We add a new commit that restores the files it changed, so history stays honest. It shows as <span class="tag removed">removed</span>.</li> | |
| 111 | + <li><b>3 votes up</b> and it stays for good. It shows as <span class="tag kept">kept</span> and can't be voted out later.</li> | |
| 112 | + <li>Everything else stays in the branch.</li></ul> | |
| 113 | + <p>If a later commit already changed the same file again, the removal leaves that newer work alone and says so in the removal commit.</p> | |
| 114 | + <h2>Branches</h2> | |
| 115 | + <ul><li>Anyone can open a branch, under any name, without asking.</li> | |
| 116 | + <li><b>3 votes down</b> on a branch removes the whole branch. That name can't be pushed again, so pick a new one.</li> | |
| 117 | + <li><b>3 votes up</b> keeps the branch for good.</li> | |
| 118 | + <li>Each repository's main branch always stays. Its commits are still voted on one by one.</li></ul> | |
| 119 | + <h2>Fair votes</h2> | |
| 120 | + <ul><li>One vote per account on each commit or branch. You can change or take back your vote until it is decided.</li> | |
| 121 | + <li>New accounts can vote 24 hours after they're made.</li> | |
| 122 | + <li>You can vote your own work down, but not up. Others decide what stays.</li> | |
| 123 | + <li>Each network can make up to 3 new accounts a day.</li> | |
| 124 | + <li>Votes are public: each commit page lists who voted which way.</li></ul> | |
| 125 | + <h2>Checks come first</h2> | |
| 126 | + <ul>${CHECKS_TEXT.map((t) => `<li>${esc(t)}</li>`).join('')}</ul> | |
| 127 | + </div></section>`; | |
| 128 | + | |
| 129 | + export const features = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 130 | + <span class="eyebrow">For apps</span><h1 class="sm">Let people vote on new features</h1> | |
| 131 | + <p class="lede">A new feature merges automatically once its checks pass. Then it shows a small <b>New</b> badge with thumbs up and thumbs down until people decide.</p> | |
| 132 | + <ul><li><b>3 thumbs up:</b> the feature stays for good and the badge goes away.</li> | |
| 133 | + <li><b>3 thumbs down:</b> the feature is switched off for everyone.</li> | |
| 134 | + <li>Until then it stays in the app, marked as new.</li></ul> | |
| 135 | + <h2>Add it to any app or site</h2> | |
| 136 | + <p>1. Load the widget once on every page. Pick a short id for your app.</p> | |
| 137 | + <pre><code><script src="https://branchwell.ai/widget/features.v1.js" data-app="yourapp" defer></script></code></pre> | |
| 138 | + <p>2. Mark each new feature with its own id. The badge appears next to it.</p> | |
| 139 | + <pre><code><button data-bw-feature="dark-mode">Dark mode</button> | |
| 140 | + <section data-bw-feature="weekly-summary"> | |
| 141 | + <h2 data-bw-badge>Weekly summary</h2> <!-- optional: where the badge goes --> | |
| 142 | + ... | |
| 143 | + </section></code></pre> | |
| 144 | + <p>That's all. The first time the widget sees an id, the feature starts as new. When people vote it down, the widget hides that element. When they vote it up, the badge stops showing.</p> | |
| 145 | + <h2>Voting</h2> | |
| 146 | + <p>Tapping a thumb opens a small Branchwell window where people sign in with their passkey and vote. One vote per person per feature. The same fair-vote rules apply as for commits.</p> | |
| 147 | + <h2>Reading the results yourself</h2> | |
| 148 | + <pre><code>GET https://branchwell.ai/api/features?app=yourapp</code></pre> | |
| 149 | + <p>It returns each feature's status (<code>new</code>, <code>kept</code> or <code>removed</code>) and its votes. Native apps can call it at launch and switch features on or off the same way.</p> | |
| 150 | + </div></section>`; | |
| 151 | + | |
| 152 | + export function research() { | |
| 153 | + const S: [string, string, string, string, string][] = [ | |
| 154 | + ['Git HTTP transfer protocols', 'Git project documentation', '', 'https://git-scm.com/docs/http-protocol', 'How Git talks to a server over plain HTTPS: the "smart" protocol Branchwell speaks for clone, pull and push.'], | |
| 155 | + ['Git on the Server: Smart HTTP', 'Pro Git, by Scott Chacon and Ben Straub', '2014', 'https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP', 'Why one HTTPS address can serve anonymous reads and signed-in writes at the same time.'], | |
| 156 | + ['Git pack format', 'Git project documentation', '', 'https://git-scm.com/docs/gitformat-pack', 'The file format Git uses to send many objects at once, with deltas. Branchwell reads and writes it directly.'], | |
| 157 | + ['Web Authentication: an API for accessing public key credentials, Level 2', 'W3C Recommendation', '2021', 'https://www.w3.org/TR/webauthn-2/', 'The web standard behind passkeys. The site keeps only a public key; the private key never leaves your device.'], | |
| 158 | + ['Passkeys', 'FIDO Alliance', '', 'https://fidoalliance.org/passkeys/', 'An overview of passkeys: sign-in with a face, fingerprint or PIN that resists phishing and replaces passwords.'], | |
| 159 | + ['The Sybil attack', 'John R. Douceur, Microsoft Research', '2002', 'https://www.microsoft.com/en-us/research/publication/the-sybil-attack/', 'Shows that any open voting system can be gamed by one person making many identities. It is why we limit new accounts and make new accounts wait a day before voting.'], | |
| 160 | + ['Be bold', 'Wikipedia', '', 'https://en.wikipedia.org/wiki/Wikipedia:Be_bold', 'The long-running example of open editing without approval first: changes go live, and the community keeps or reverts them.'], | |
| 161 | + ['CC0 1.0 Universal', 'Creative Commons', '', 'https://creativecommons.org/publicdomain/zero/1.0/', 'The public domain dedication we use for our summaries, plans and code, so anyone can copy them without asking.'], | |
| 162 | + ['Durable Objects', 'Cloudflare documentation', '', 'https://developers.cloudflare.com/durable-objects/', 'The storage model we use: each repository lives in its own small database, so pushes and votes never race each other.'], | |
| 163 | + ]; | |
| 164 | + return `<section class="sec"><div class="prose"> | |
| 165 | + <h2 id="plan">How Branchwell works</h2> | |
| 166 | + <p><b>Where we are:</b> Live. Clone, pull and push work today over HTTPS, with passkey sign-in and voting.</p> | |
| 167 | + <p>Branchwell is a simple home for Git repositories. Anyone can pull. Anyone signed in can push straight to a branch. Instead of pull requests and reviewers, people vote on each commit: 3 votes down takes it back out, 3 votes up keeps it for good.</p> | |
| 168 | + <h3>How it works</h3><ol><li><b>Pull.</b> Plain Git over HTTPS, no account.</li><li><b>Push.</b> A push key made after passkey sign-in.</li><li><b>Check.</b> Every pushed file is checked before it lands.</li><li><b>Vote.</b> Commits and branches are kept or removed by 3 votes.</li></ol> | |
| 169 | + <h3>How it keeps going</h3><p>Branchwell runs on small serverless databases that cost little to run, and we cover that cost ourselves. There are no ads and no paid plans. The code is public domain, so anyone can run their own copy.</p> | |
| 170 | + <h3>How we're organized</h3><ul><li>Branchwell<ul><li>Platform: the Git server, storage and sign-in</li><li>Research: keeping sources accurate and summaries plain</li><li>Community: helping new contributors find their way</li></ul></li></ul> | |
| 171 | + <p class="small muted">Everyone on the team grows through the same three levels: Explorer (starting out), Builder (growing) and Guide (on the way to mastery).</p> | |
| 172 | + <h3>What we've decided</h3><ul><li>No pull requests and no reviews.</li><li>3 votes decide: down removes, up keeps.</li><li>Passkeys only.</li><li>History is never rewritten.</li></ul> | |
| 173 | + <h3>What comes next</h3><ul><li>Download any branch as a zip.</li><li>Search across repositories.</li><li>Sites that rebuild straight from their research here.</li></ul> | |
| 174 | + <h3>Start your own</h3><ol><li><b>Clone our source.</b> <code>git clone https://branchwell.ai/branchwell/source.git</code></li><li><b>Deploy it.</b> It runs as one Cloudflare Worker with a D1 database and Durable Objects.</li><li><b>Pick your own rules.</b> Change the vote threshold or the checks in a few lines.</li></ol> | |
| 175 | + <h2 id="sources">The research</h2> | |
| 176 | + ${S.map(([t, s, y, u, sum]) => `<p><b><a href="${u}" rel="noopener">${esc(t)}</a></b><br><span class="small muted">${esc(s)}${y ? ', ' + y : ''}</span><br>${esc(sum)}</p>`).join('\n')} | |
| 177 | + <p class="small muted">Our summaries are public domain (CC0): copy and share them freely. Each original source belongs to its authors.</p> | |
| 178 | + </div></section>`; | |
| 179 | + } | |
| 180 | + | |
| 181 | + export const careers = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 182 | + <span class="eyebrow">Careers</span><h1 class="sm">Work with us</h1> | |
| 183 | + <p class="lede">Join our team. We're looking for software engineers, people who know Git and storage inside out, researchers who love a good source, writers and community guides. Tell us what you do and how we can reach you.</p> | |
| 184 | + <p><b>All our roles are part-time, up to 39 hours a week. Every team member earns a daily, automatic Bitcoin bonus based on performance, and get their health care through the holistic clinics we work with. Care outside those clinics is not covered.</b></p> | |
| 185 | + <form id="cr-form" novalidate style="max-width:640px"> | |
| 186 | + <label for="cr-name" style="font-weight:700;display:block;margin:0 0 8px">Name</label> | |
| 187 | + <input id="cr-name" name="name" required maxlength="120" autocomplete="name" style="width:100%;font:inherit;padding:14px;border-radius:999px;border:1.5px solid var(--line);background:var(--card);color:var(--fg);margin-bottom:14px"> | |
| 188 | + <label for="cr-email" style="font-weight:700;display:block;margin:0 0 8px">Email</label> | |
| 189 | + <input id="cr-email" name="email" type="email" required maxlength="200" autocomplete="email" style="width:100%;font:inherit;padding:14px;border-radius:999px;border:1.5px solid var(--line);background:var(--card);color:var(--fg);margin-bottom:14px"> | |
| 190 | + <label for="cr-request" style="font-weight:700;display:block;margin:0 0 8px">Message</label> | |
| 191 | + <textarea id="cr-request" name="request" required maxlength="4000" rows="6" style="width:100%;font:inherit;padding:14px;border-radius:16px;border:1.5px solid var(--line);background:var(--card);color:var(--fg)" placeholder="What work would you like to do with us?"></textarea> | |
| 192 | + <div style="position:absolute;left:-9999px" aria-hidden="true"><label>Leave this empty <input name="website" tabindex="-1" autocomplete="off"></label></div> | |
| 193 | + <p><button type="submit" class="btn">Join our team</button></p> | |
| 194 | + <p id="cr-msg" role="status" aria-live="polite"></p> | |
| 195 | + </form></div></section>`; | |
| 196 | + | |
| 197 | + export const privacy = `<section class="hero" style="grid-template-columns:1fr"><div class="prose"> | |
| 198 | + <span class="eyebrow">Privacy</span><h1 class="sm">Privacy</h1> | |
| 199 | + <p class="lede">We keep as little as we can, and we never sell or share it.</p> | |
| 200 | + <h2>What we keep</h2> | |
| 201 | + <ul><li><b>Your account name</b>, which is public, and when you made it.</li> | |
| 202 | + <li><b>Your passkey's public key.</b> Your face, fingerprint and PIN never leave your device and never reach us.</li> | |
| 203 | + <li><b>Push keys</b>, stored only as a one-way hash, with when each was last used.</li> | |
| 204 | + <li><b>What you push and how you vote.</b> Repositories, commits and votes are public, with your account name.</li> | |
| 205 | + <li><b>A salted hash of your network address</b> when you make an account, only to limit new accounts per network.</li> | |
| 206 | + <li><b>Careers requests</b> you send us, with the site name and time.</li></ul> | |
| 207 | + <h2>What we don't do</h2> | |
| 208 | + <ul><li>No passwords, no email sign-up, no ads and no ad trackers.</li><li>No third-party sign-in.</li><li>Our visitor counter counts visits without cookies or tracking you around the web.</li></ul> | |
| 209 | + <h2>Cookies</h2><p>One sign-in cookie, only after you sign in, so the site knows it's you. Nothing else.</p> | |
| 210 | + <h2>Hosting</h2><p>Branchwell is hosted on Cloudflare.</p> | |
| 211 | + <h2>Leaving</h2><p>You can remove your push keys at any time on your account page. Commits you pushed stay part of the public history, like any Git history.</p> | |
| 212 | + </div></section>`; |
src/env.ts added
| 1 | + import type { RepoDO } from './repo'; | |
| 2 | + export interface Env { | |
| 3 | + DB: D1Database; | |
| 4 | + REPO: DurableObjectNamespace<RepoDO>; | |
| 5 | + CAREERS?: Fetcher; | |
| 6 | + IP_SALT?: string; | |
| 7 | + } |
src/features.ts added
| 1 | + // "New feature" votes for any app built on our platform. An app marks new things with | |
| 2 | + // data-bw-feature="id"; the widget shows a New badge with thumbs up and down. | |
| 3 | + // 3 up: the feature stays for good and the badge goes away. 3 down: the feature is switched off. | |
| 4 | + import type { Env } from './env'; | |
| 5 | + import { currentAccount, canVote } from './auth'; | |
| 6 | + import { VOTES_TO_DECIDE } from './repo'; | |
| 7 | + | |
| 8 | + const ID_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/; | |
| 9 | + const CORS = { 'access-control-allow-origin': '*', 'access-control-allow-methods': 'GET, OPTIONS', 'access-control-allow-headers': 'content-type' }; | |
| 10 | + const json = (b: unknown, s = 200, h: Record<string, string> = {}) => new Response(JSON.stringify(b), { status: s, headers: { 'content-type': 'application/json', 'cache-control': 'no-store', ...h } }); | |
| 11 | + | |
| 12 | + export async function featuresApi(req: Request, env: Env, url: URL): Promise<Response> { | |
| 13 | + if (req.method === 'OPTIONS') return new Response(null, { status: 204, headers: CORS }); | |
| 14 | + const app = (url.searchParams.get('app') || '').toLowerCase(); | |
| 15 | + if (!ID_RE.test(app)) return json({ error: 'app must be a short id like "jotley"' }, 400, CORS); | |
| 16 | + if (req.method === 'GET') { | |
| 17 | + // ids=a,b,c registers features the app is showing (first sight starts them as "new"). | |
| 18 | + const ids = (url.searchParams.get('ids') || '').split(',').map((s) => s.trim().toLowerCase()).filter((s) => ID_RE.test(s)).slice(0, 50); | |
| 19 | + if (ids.length) { | |
| 20 | + const known = await env.DB.prepare('SELECT COUNT(*) AS n FROM features WHERE app = ?').bind(app).first<number>('n'); | |
| 21 | + if ((known || 0) < 500) { | |
| 22 | + await env.DB.batch(ids.map((id) => env.DB.prepare('INSERT INTO features (app, feature, created_at) VALUES (?, ?, ?) ON CONFLICT DO NOTHING').bind(app, id, Date.now()))); | |
| 23 | + } | |
| 24 | + } | |
| 25 | + const rows = (await env.DB.prepare('SELECT feature, status, up, down FROM features WHERE app = ? ORDER BY created_at DESC LIMIT 500').bind(app).all()).results; | |
| 26 | + return json({ app, votesToDecide: VOTES_TO_DECIDE, features: rows }, 200, { ...CORS, 'cache-control': 'public, max-age=15' }); | |
| 27 | + } | |
| 28 | + return json({ error: 'GET only' }, 405, CORS); | |
| 29 | + } | |
| 30 | + | |
| 31 | + /** POST /api/feature-vote {app, feature, value}. Signed-in, first-party only (the vote page). */ | |
| 32 | + export async function featureVote(req: Request, env: Env): Promise<Response> { | |
| 33 | + if (req.headers.get('origin') !== new URL(req.url).origin) return json({ error: 'Bad origin.' }, 403); | |
| 34 | + const me = await currentAccount(req, env); | |
| 35 | + if (!me) return json({ error: 'Sign in with your passkey to vote.' }, 401); | |
| 36 | + if (!canVote(me)) return json({ error: 'New accounts can vote 24 hours after they are made.' }, 403); | |
| 37 | + const b = await req.json<{ app: string; feature: string; value: number }>().catch(() => null); | |
| 38 | + if (!b || !ID_RE.test(b.app || '') || !ID_RE.test(b.feature || '')) return json({ error: 'Unknown feature.' }, 400); | |
| 39 | + const f = await env.DB.prepare('SELECT status FROM features WHERE app = ? AND feature = ?').bind(b.app, b.feature).first<string>('status'); | |
| 40 | + if (!f) return json({ error: 'Unknown feature.' }, 404); | |
| 41 | + if (f !== 'new') return json({ ok: false, status: f, message: f === 'kept' ? 'Already kept for good.' : 'Already switched off by votes.' }); | |
| 42 | + const v = b.value > 0 ? 1 : -1; | |
| 43 | + await env.DB.prepare('INSERT INTO feature_votes (app, feature, account_id, value, at) VALUES (?, ?, ?, ?, ?) ON CONFLICT (app, feature, account_id) DO UPDATE SET value = excluded.value, at = excluded.at') | |
| 44 | + .bind(b.app, b.feature, me.id, v, Date.now()).run(); | |
| 45 | + const t = await env.DB.prepare('SELECT SUM(value > 0) AS up, SUM(value < 0) AS down FROM feature_votes WHERE app = ? AND feature = ?').bind(b.app, b.feature).first<{ up: number; down: number }>(); | |
| 46 | + const up = t?.up || 0, down = t?.down || 0; | |
| 47 | + const status = down >= VOTES_TO_DECIDE ? 'removed' : up >= VOTES_TO_DECIDE ? 'kept' : 'new'; | |
| 48 | + await env.DB.prepare('UPDATE features SET up = ?, down = ?, status = ?, decided_at = CASE WHEN ? = \'new\' THEN NULL ELSE ? END WHERE app = ? AND feature = ?') | |
| 49 | + .bind(up, down, status, status, Date.now(), b.app, b.feature).run(); | |
| 50 | + return json({ ok: true, status, up, down }); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** The widget apps load: <script src="https://branchwell.ai/widget/features.v1.js" data-app="yourapp" defer></script> */ | |
| 54 | + export const WIDGET_JS = `(()=>{"use strict"; | |
| 55 | + const s=document.currentScript,app=(s&&s.dataset.app||"").toLowerCase(),base=new URL(s?s.src:location.href).origin; | |
| 56 | + if(!app)return; | |
| 57 | + const css=\`.bw-new{display:inline-flex;align-items:center;gap:.3em;margin-left:.4em;padding:.1em .5em;border-radius:999px;font:600 12px/1.6 system-ui,sans-serif;background:#e9f5ec;color:#1d5b34;border:1px solid #b9dcc4;vertical-align:middle} | |
| 58 | + .bw-new button{all:unset;cursor:pointer;padding:0 .2em;border-radius:999px}.bw-new button:hover,.bw-new button:focus-visible{background:#cfe9d8;outline:2px solid #1d5b34} | |
| 59 | + .bw-hl{outline:2px solid #3f9a5f;outline-offset:3px;border-radius:6px} | |
| 60 | + @media (prefers-color-scheme:dark){.bw-new{background:#16301f;color:#bfe6cb;border-color:#2c5c3c}.bw-new button:hover{background:#21452e}}\`; | |
| 61 | + const st=document.createElement("style");st.textContent=css;document.head.appendChild(st); | |
| 62 | + function run(){const els=[...document.querySelectorAll("[data-bw-feature]")];if(!els.length)return; | |
| 63 | + const ids=[...new Set(els.map(e=>e.dataset.bwFeature.toLowerCase()))].slice(0,50); | |
| 64 | + fetch(base+"/api/features?app="+encodeURIComponent(app)+"&ids="+encodeURIComponent(ids.join(","))).then(r=>r.json()).then(d=>{ | |
| 65 | + const by={};(d.features||[]).forEach(f=>by[f.feature]=f); | |
| 66 | + els.forEach(el=>{const f=by[el.dataset.bwFeature.toLowerCase()];if(!f)return; | |
| 67 | + if(f.status==="removed"){el.hidden=true;el.setAttribute("aria-hidden","true");el.style.display="none";return} | |
| 68 | + if(f.status!=="new"||el.querySelector(":scope > .bw-new"))return; | |
| 69 | + el.classList.add("bw-hl");const b=document.createElement("span");b.className="bw-new"; | |
| 70 | + const vote=v=>window.open(base+"/feature-vote?app="+encodeURIComponent(app)+"&feature="+encodeURIComponent(f.feature)+"&v="+v,"bwvote","width=440,height=560"); | |
| 71 | + b.innerHTML='New <button type="button" aria-label="Thumbs up for this new feature">👍 <span>'+f.up+'</span></button><button type="button" aria-label="Thumbs down for this new feature">👎 <span>'+f.down+'</span></button>'; | |
| 72 | + const [u,dn]=b.querySelectorAll("button");u.onclick=e=>{e.preventDefault();e.stopPropagation();vote("up")};dn.onclick=e=>{e.preventDefault();e.stopPropagation();vote("down")}; | |
| 73 | + (el.querySelector("[data-bw-badge]")||el).appendChild(b)})}).catch(()=>{})} | |
| 74 | + document.readyState==="loading"?document.addEventListener("DOMContentLoaded",run):run(); | |
| 75 | + window.addEventListener("message",e=>{if(e.origin===base&&e.data&&e.data.bwVoted){document.querySelectorAll(".bw-new").forEach(x=>x.remove());run()}}); | |
| 76 | + })();`; |
src/git/core.ts added
| 1 | + // Git building blocks: pkt-lines, object ids, commit/tree parsing, pack reading and writing. | |
| 2 | + import pako from 'pako'; | |
| 3 | + import { Sha1, hex } from './sha1'; | |
| 4 | + | |
| 5 | + export const te = new TextEncoder(); | |
| 6 | + export const td = new TextDecoder(); | |
| 7 | + export const ZERO = '0'.repeat(40); | |
| 8 | + export type ObjType = 'commit' | 'tree' | 'blob' | 'tag'; | |
| 9 | + export const TYPE_NUM: Record<ObjType, number> = { commit: 1, tree: 2, blob: 3, tag: 4 }; | |
| 10 | + export const NUM_TYPE: Record<number, ObjType> = { 1: 'commit', 2: 'tree', 3: 'blob', 4: 'tag' }; | |
| 11 | + | |
| 12 | + // ---------- pkt-line ---------- | |
| 13 | + export function pkt(s: string | Uint8Array): Uint8Array { | |
| 14 | + const body = typeof s === 'string' ? te.encode(s) : s; | |
| 15 | + const out = new Uint8Array(body.length + 4); | |
| 16 | + out.set(te.encode((body.length + 4).toString(16).padStart(4, '0')), 0); | |
| 17 | + out.set(body, 4); | |
| 18 | + return out; | |
| 19 | + } | |
| 20 | + export const FLUSH = te.encode('0000'); | |
| 21 | + | |
| 22 | + export function concat(parts: Uint8Array[]): Uint8Array { | |
| 23 | + let n = 0; for (const p of parts) n += p.length; | |
| 24 | + const out = new Uint8Array(n); let o = 0; | |
| 25 | + for (const p of parts) { out.set(p, o); o += p.length; } | |
| 26 | + return out; | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** Reads pkt-lines from a buffer. Returns lines (null = flush) and the offset after the last one read. */ | |
| 30 | + export function readPkts(buf: Uint8Array, start = 0, stopAtFlush = false): { lines: (Uint8Array | null)[]; end: number } { | |
| 31 | + const lines: (Uint8Array | null)[] = []; | |
| 32 | + let o = start; | |
| 33 | + while (o + 4 <= buf.length) { | |
| 34 | + const len = parseInt(td.decode(buf.subarray(o, o + 4)), 16); | |
| 35 | + if (Number.isNaN(len)) break; | |
| 36 | + if (len === 0) { lines.push(null); o += 4; if (stopAtFlush) break; continue; } | |
| 37 | + if (len < 4 || o + len > buf.length) break; | |
| 38 | + lines.push(buf.subarray(o + 4, o + len)); | |
| 39 | + o += len; | |
| 40 | + } | |
| 41 | + return { lines, end: o }; | |
| 42 | + } | |
| 43 | + | |
| 44 | + /** Side-band-64k framing: band 1 = data, 2 = progress, 3 = error. */ | |
| 45 | + export function* sideband(band: number, data: Uint8Array): Generator<Uint8Array> { | |
| 46 | + for (let i = 0; i < data.length; i += 65515) { | |
| 47 | + const chunk = data.subarray(i, Math.min(i + 65515, data.length)); | |
| 48 | + const b = new Uint8Array(chunk.length + 1); b[0] = band; b.set(chunk, 1); | |
| 49 | + yield pkt(b); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + // ---------- objects ---------- | |
| 54 | + export function objectId(type: ObjType, data: Uint8Array): string { | |
| 55 | + return hex(new Sha1().update(te.encode(`${type} ${data.length}\0`)).update(data).digest()); | |
| 56 | + } | |
| 57 | + | |
| 58 | + export interface TreeEntry { mode: string; name: string; sha: string } | |
| 59 | + export function parseTree(data: Uint8Array): TreeEntry[] { | |
| 60 | + const out: TreeEntry[] = []; | |
| 61 | + let o = 0; | |
| 62 | + while (o < data.length) { | |
| 63 | + const sp = data.indexOf(0x20, o); | |
| 64 | + const nul = data.indexOf(0, sp); | |
| 65 | + out.push({ mode: td.decode(data.subarray(o, sp)), name: td.decode(data.subarray(sp + 1, nul)), sha: hex(data.subarray(nul + 1, nul + 21)) }); | |
| 66 | + o = nul + 21; | |
| 67 | + } | |
| 68 | + return out; | |
| 69 | + } | |
| 70 | + export function writeTree(entries: TreeEntry[]): Uint8Array { | |
| 71 | + // Git sorts tree entries by name, with directories compared as if they end in '/'. | |
| 72 | + const key = (e: TreeEntry) => e.mode === '40000' ? e.name + '/' : e.name; | |
| 73 | + const sorted = [...entries].sort((a, b) => (key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0)); | |
| 74 | + const parts: Uint8Array[] = []; | |
| 75 | + for (const e of sorted) { | |
| 76 | + parts.push(te.encode(`${e.mode} ${e.name}\0`)); | |
| 77 | + const s = new Uint8Array(20); for (let i = 0; i < 20; i++) s[i] = parseInt(e.sha.substr(i * 2, 2), 16); | |
| 78 | + parts.push(s); | |
| 79 | + } | |
| 80 | + return concat(parts); | |
| 81 | + } | |
| 82 | + | |
| 83 | + export interface Commit { tree: string; parents: string[]; author: string; committer: string; message: string; time: number } | |
| 84 | + export function parseCommit(data: Uint8Array): Commit { | |
| 85 | + const text = td.decode(data); | |
| 86 | + const split = text.indexOf('\n\n'); | |
| 87 | + const head = text.slice(0, split < 0 ? text.length : split); | |
| 88 | + const c: Commit = { tree: '', parents: [], author: '', committer: '', message: split < 0 ? '' : text.slice(split + 2), time: 0 }; | |
| 89 | + for (const line of head.split('\n')) { | |
| 90 | + const sp = line.indexOf(' '); | |
| 91 | + const k = line.slice(0, sp), v = line.slice(sp + 1); | |
| 92 | + if (k === 'tree') c.tree = v; | |
| 93 | + else if (k === 'parent') c.parents.push(v); | |
| 94 | + else if (k === 'author') c.author = v; | |
| 95 | + else if (k === 'committer') { c.committer = v; const m = v.match(/ (\d+) [+-]\d{4}$/); if (m) c.time = +m[1]; } | |
| 96 | + } | |
| 97 | + return c; | |
| 98 | + } | |
| 99 | + /** "Name <email> 1700000000 +0000" -> name */ | |
| 100 | + export const personName = (s: string) => s.replace(/\s*<.*$/, '').trim(); | |
| 101 | + | |
| 102 | + // ---------- deltas ---------- | |
| 103 | + function readVar(d: Uint8Array, o: { i: number }) { let r = 0, s = 0, b; do { b = d[o.i++]; r |= (b & 0x7f) << s; s += 7; } while (b & 0x80); return r; } | |
| 104 | + export function applyDelta(base: Uint8Array, delta: Uint8Array): Uint8Array { | |
| 105 | + const o = { i: 0 }; | |
| 106 | + const baseLen = readVar(delta, o); | |
| 107 | + if (baseLen !== base.length) throw new Error('delta base size mismatch'); | |
| 108 | + const outLen = readVar(delta, o); | |
| 109 | + const out = new Uint8Array(outLen); let w = 0; | |
| 110 | + while (o.i < delta.length) { | |
| 111 | + const op = delta[o.i++]; | |
| 112 | + if (op & 0x80) { | |
| 113 | + let off = 0, size = 0; | |
| 114 | + if (op & 1) off |= delta[o.i++]; if (op & 2) off |= delta[o.i++] << 8; if (op & 4) off |= delta[o.i++] << 16; if (op & 8) off |= delta[o.i++] << 24; | |
| 115 | + if (op & 16) size |= delta[o.i++]; if (op & 32) size |= delta[o.i++] << 8; if (op & 64) size |= delta[o.i++] << 16; | |
| 116 | + if (size === 0) size = 0x10000; | |
| 117 | + out.set(base.subarray(off >>> 0, (off >>> 0) + size), w); w += size; | |
| 118 | + } else if (op) { out.set(delta.subarray(o.i, o.i + op), w); w += op; o.i += op; } | |
| 119 | + else throw new Error('bad delta op'); | |
| 120 | + } | |
| 121 | + if (w !== outLen) throw new Error('delta result size mismatch'); | |
| 122 | + return out; | |
| 123 | + } | |
| 124 | + | |
| 125 | + // ---------- pack reading ---------- | |
| 126 | + export interface RawObj { type: ObjType; data: Uint8Array; sha: string } | |
| 127 | + /** Parses a v2 pack. getBase looks up ref-delta bases that are already stored (thin packs). */ | |
| 128 | + export async function readPack(buf: Uint8Array, getBase: (sha: string) => Promise<RawObj | null>): Promise<RawObj[]> { | |
| 129 | + if (buf.length < 32 || td.decode(buf.subarray(0, 4)) !== 'PACK') throw new Error('not a pack'); | |
| 130 | + const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); | |
| 131 | + const count = dv.getUint32(8); | |
| 132 | + const want = hex(buf.subarray(buf.length - 20)); | |
| 133 | + const got = hex(new Sha1().update(buf.subarray(0, buf.length - 20)).digest()); | |
| 134 | + if (want !== got) throw new Error('pack checksum mismatch'); | |
| 135 | + let o = 12; | |
| 136 | + type Ent = { off: number; kind: number; data: Uint8Array; baseOff?: number; baseSha?: string }; | |
| 137 | + const ents: Ent[] = []; | |
| 138 | + for (let n = 0; n < count; n++) { | |
| 139 | + const off = o; | |
| 140 | + let b = buf[o++]; const kind = (b >> 4) & 7; let size = b & 15, shift = 4; | |
| 141 | + while (b & 0x80) { b = buf[o++]; size += (b & 0x7f) * 2 ** shift; shift += 7; } | |
| 142 | + const e: Ent = { off, kind, data: new Uint8Array() }; | |
| 143 | + if (kind === 6) { b = buf[o++]; let x = b & 0x7f; while (b & 0x80) { b = buf[o++]; x = ((x + 1) * 128) + (b & 0x7f); } e.baseOff = off - x; } | |
| 144 | + else if (kind === 7) { e.baseSha = hex(buf.subarray(o, o + 20)); o += 20; } | |
| 145 | + const inf = new pako.Inflate(); | |
| 146 | + inf.push(buf.subarray(o), true); | |
| 147 | + if (inf.err || !(inf.result instanceof Uint8Array)) throw new Error('bad zlib data in pack'); | |
| 148 | + e.data = inf.result; o += (inf as unknown as { strm: { next_in: number } }).strm.next_in; | |
| 149 | + if (e.data.length !== size) throw new Error('pack object size mismatch'); | |
| 150 | + ents.push(e); | |
| 151 | + } | |
| 152 | + const byOff = new Map<number, RawObj>(); | |
| 153 | + const bySha = new Map<string, RawObj>(); | |
| 154 | + const out: RawObj[] = []; | |
| 155 | + let pending = ents; | |
| 156 | + while (pending.length) { | |
| 157 | + const next: Ent[] = []; | |
| 158 | + for (const e of pending) { | |
| 159 | + let obj: RawObj | null = null; | |
| 160 | + if (e.kind >= 1 && e.kind <= 4) { const t = NUM_TYPE[e.kind]; obj = { type: t, data: e.data, sha: objectId(t, e.data) }; } | |
| 161 | + else { | |
| 162 | + const base = e.kind === 6 ? byOff.get(e.baseOff!) : (bySha.get(e.baseSha!) || null); | |
| 163 | + if (!base) { next.push(e); continue; } | |
| 164 | + const data = applyDelta(base.data, e.data); | |
| 165 | + obj = { type: base.type, data, sha: objectId(base.type, data) }; | |
| 166 | + } | |
| 167 | + byOff.set(e.off, obj); bySha.set(obj.sha, obj); out.push(obj); | |
| 168 | + } | |
| 169 | + if (next.length === pending.length) { | |
| 170 | + // Remaining bases must already be in the repository (thin pack). | |
| 171 | + let progressed = false; | |
| 172 | + for (const e of next) if (e.kind === 7 && !bySha.has(e.baseSha!)) { const b = await getBase(e.baseSha!); if (b) { bySha.set(b.sha, b); progressed = true; } } | |
| 173 | + if (!progressed) throw new Error('pack has a delta whose base is missing'); | |
| 174 | + } | |
| 175 | + pending = next; | |
| 176 | + } | |
| 177 | + return out; | |
| 178 | + } | |
| 179 | + | |
| 180 | + // ---------- pack writing ---------- | |
| 181 | + export function packObjHeader(type: number, size: number): Uint8Array { | |
| 182 | + const bytes: number[] = []; | |
| 183 | + let b = (type << 4) | (size & 15); size = Math.floor(size / 16); | |
| 184 | + while (size > 0) { bytes.push(b | 0x80); b = size & 0x7f; size = Math.floor(size / 128); } | |
| 185 | + bytes.push(b); | |
| 186 | + return new Uint8Array(bytes); | |
| 187 | + } | |
| 188 | + export function packHeader(count: number): Uint8Array { | |
| 189 | + const h = new Uint8Array(12); h.set(te.encode('PACK')); const dv = new DataView(h.buffer); dv.setUint32(4, 2); dv.setUint32(8, count); return h; | |
| 190 | + } | |
| 191 | + export const deflate = (d: Uint8Array) => pako.deflate(d); | |
| 192 | + export const inflate = (d: Uint8Array) => pako.inflate(d); |
src/git/sha1.ts added
| 1 | + // Incremental SHA-1 (Git object ids and pack trailers). WebCrypto is one-shot, packs stream. | |
| 2 | + export class Sha1 { | |
| 3 | + private h = new Uint32Array([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]); | |
| 4 | + private buf = new Uint8Array(64); | |
| 5 | + private bufLen = 0; | |
| 6 | + private total = 0; | |
| 7 | + private w = new Uint32Array(80); | |
| 8 | + | |
| 9 | + update(data: Uint8Array): this { | |
| 10 | + let i = 0; | |
| 11 | + this.total += data.length; | |
| 12 | + if (this.bufLen) { | |
| 13 | + const n = Math.min(64 - this.bufLen, data.length); | |
| 14 | + this.buf.set(data.subarray(0, n), this.bufLen); | |
| 15 | + this.bufLen += n; i = n; | |
| 16 | + if (this.bufLen === 64) { this.block(this.buf, 0); this.bufLen = 0; } | |
| 17 | + } | |
| 18 | + for (; i + 64 <= data.length; i += 64) this.block(data, i); | |
| 19 | + if (i < data.length) { this.buf.set(data.subarray(i), 0); this.bufLen = data.length - i; } | |
| 20 | + return this; | |
| 21 | + } | |
| 22 | + | |
| 23 | + digest(): Uint8Array { | |
| 24 | + const bits = this.total * 8; | |
| 25 | + const pad = new Uint8Array(((this.bufLen < 56 ? 56 : 120) - this.bufLen) + 8); | |
| 26 | + pad[0] = 0x80; | |
| 27 | + const dv = new DataView(pad.buffer); | |
| 28 | + dv.setUint32(pad.length - 8, Math.floor(bits / 0x100000000)); | |
| 29 | + dv.setUint32(pad.length - 4, bits >>> 0); | |
| 30 | + this.total -= pad.length; // padding is not message data | |
| 31 | + this.update(pad); | |
| 32 | + const out = new Uint8Array(20); | |
| 33 | + const o = new DataView(out.buffer); | |
| 34 | + for (let k = 0; k < 5; k++) o.setUint32(k * 4, this.h[k]); | |
| 35 | + return out; | |
| 36 | + } | |
| 37 | + | |
| 38 | + private block(d: Uint8Array, off: number) { | |
| 39 | + const w = this.w; | |
| 40 | + for (let t = 0; t < 16; t++) w[t] = (d[off + t * 4] << 24) | (d[off + t * 4 + 1] << 16) | (d[off + t * 4 + 2] << 8) | d[off + t * 4 + 3]; | |
| 41 | + for (let t = 16; t < 80; t++) { const x = w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]; w[t] = (x << 1) | (x >>> 31); } | |
| 42 | + let [a, b, c, dd, e] = this.h; | |
| 43 | + for (let t = 0; t < 80; t++) { | |
| 44 | + let f: number, k: number; | |
| 45 | + if (t < 20) { f = (b & c) | (~b & dd); k = 0x5a827999; } | |
| 46 | + else if (t < 40) { f = b ^ c ^ dd; k = 0x6ed9eba1; } | |
| 47 | + else if (t < 60) { f = (b & c) | (b & dd) | (c & dd); k = 0x8f1bbcdc; } | |
| 48 | + else { f = b ^ c ^ dd; k = 0xca62c1d6; } | |
| 49 | + const tmp = (((a << 5) | (a >>> 27)) + f + e + k + w[t]) >>> 0; | |
| 50 | + e = dd; dd = c; c = (b << 30) | (b >>> 2); b = a; a = tmp; | |
| 51 | + } | |
| 52 | + this.h[0] = (this.h[0] + a) >>> 0; this.h[1] = (this.h[1] + b) >>> 0; this.h[2] = (this.h[2] + c) >>> 0; | |
| 53 | + this.h[3] = (this.h[3] + dd) >>> 0; this.h[4] = (this.h[4] + e) >>> 0; | |
| 54 | + } | |
| 55 | + } | |
| 56 | + | |
| 57 | + export const hex = (b: Uint8Array) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join(''); | |
| 58 | + export const unhex = (s: string) => { const o = new Uint8Array(s.length / 2); for (let i = 0; i < o.length; i++) o[i] = parseInt(s.substr(i * 2, 2), 16); return o; }; |
src/html.ts added
| 1 | + // Site shell (header, nav, theme, footer) shared by every page, plus Markdown and diff rendering. | |
| 2 | + import { NO_ORPHANS } from './static'; | |
| 3 | + | |
| 4 | + export const esc = (s: unknown) => String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '''); | |
| 5 | + export const SITE = 'https://branchwell.ai'; | |
| 6 | + | |
| 7 | + export const LOGO = `<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><rect width="48" height="48" rx="13" fill="#1f6b43"/><path d="M17 39V9" fill="none" stroke="#f3f8f1" stroke-width="3.6" stroke-linecap="round"/><path d="M17 30c0-7 5-9 12-10" fill="none" stroke="#f3f8f1" stroke-width="3.6" stroke-linecap="round"/><circle cx="17" cy="11" r="4" fill="#f3f8f1"/><circle cx="31" cy="20" r="4.6" fill="#f2b84b"/></svg>`; | |
| 8 | + const FAVICON = 'data:image/svg+xml,' + encodeURIComponent(LOGO.replace(' aria-hidden="true"', '')); | |
| 9 | + | |
| 10 | + const CSS = `*{box-sizing:border-box}:root{--bg:#f7f8f3;--fg:#17221b;--mut:#536258;--card:#ffffff;--line:#dfe5dc;--a:#1f6b43;--aT:#ffffff;--soft:#e8f0e6;--warn:#9a3b1c;--ok:#1f6b43;--amber:#a86a0c;--code:#f0f3ee} | |
| 11 | + @media (prefers-color-scheme:dark){:root{--bg:#0e1511;--fg:#e7efe8;--mut:#a3b4a8;--card:#152019;--line:#26352c;--a:#71d39b;--aT:#0e1511;--soft:#1b2a21;--warn:#ff9d7a;--ok:#71d39b;--amber:#f2b84b;--code:#111a14}} | |
| 12 | + html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--fg);font:17px/1.6 system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased} | |
| 13 | + img{max-width:100%;height:auto}.wrap{max-width:1160px;margin:0 auto;padding:0 20px}a{color:inherit} | |
| 14 | + .skip{position:absolute;left:-999px}.skip:focus{left:12px;top:12px;background:var(--a);color:var(--aT);padding:10px 16px;border-radius:999px;z-index:9} | |
| 15 | + a:focus-visible,button:focus-visible,summary:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid var(--a);outline-offset:3px;border-radius:6px} | |
| 16 | + header{display:flex;align-items:center;justify-content:space-between;padding:18px 0;gap:16px;flex-wrap:wrap} | |
| 17 | + .brand{font-weight:800;font-size:22px;letter-spacing:-.02em;color:var(--fg);text-decoration:none;display:flex;align-items:center;gap:10px;min-height:48px}.brand svg{width:38px;height:38px} | |
| 18 | + nav{display:flex;gap:4px;flex-wrap:wrap;align-items:center}nav a{color:var(--mut);text-decoration:none;font-size:15px;font-weight:600;padding:12px 14px;border-radius:999px;min-height:48px;display:inline-flex;align-items:center}nav a:hover,nav a[aria-current]{color:var(--fg);background:var(--soft)} | |
| 19 | + nav a.me{border:1.5px solid var(--line);color:var(--fg)} | |
| 20 | + .hero{display:grid;grid-template-columns:1.1fr 1fr;gap:40px;align-items:center;padding:28px 0 56px} | |
| 21 | + .eyebrow{display:inline-block;font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--a);margin:0 0 14px} | |
| 22 | + h1{font-size:clamp(40px,6.2vw,70px);line-height:1.02;margin:0 0 20px;letter-spacing:-.04em}h1.sm{font-size:clamp(32px,4.6vw,52px)}h1.xs{font-size:clamp(26px,3.4vw,38px);margin:0 0 8px} | |
| 23 | + .lede{font-size:20px;color:var(--mut);max-width:620px;margin:0 0 28px} | |
| 24 | + .btns{display:flex;gap:12px;flex-wrap:wrap}.btn{display:inline-flex;align-items:center;gap:8px;min-height:48px;padding:12px 24px;border-radius:999px;background:var(--a);color:var(--aT);text-decoration:none;font-weight:700;border:0;cursor:pointer;font:inherit;font-weight:700} | |
| 25 | + .btn.ghost{background:transparent;color:var(--fg);border:1.5px solid var(--line)}.btn.sm{min-height:40px;padding:8px 16px;font-size:15px}.btn[disabled]{opacity:.5;cursor:default} | |
| 26 | + h2{font-size:clamp(28px,4vw,42px);letter-spacing:-.03em;line-height:1.1;margin:0 0 12px}h3{line-height:1.25} | |
| 27 | + .sec{padding:56px 0;border-top:1px solid var(--line)}p.sub{color:var(--mut);max-width:700px;margin:0 0 28px;font-size:18px} | |
| 28 | + .cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:16px} | |
| 29 | + .card{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:22px}.card h3{font-size:19px;margin:0 0 6px}.card p{margin:0;color:var(--mut)} | |
| 30 | + .steps{counter-reset:s;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;padding:0;margin:0;list-style:none} | |
| 31 | + .steps li{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:22px}.steps li:before{counter-increment:s;content:counter(s);display:inline-grid;place-items:center;width:36px;height:36px;border-radius:50%;background:var(--a);color:var(--aT);font-weight:700;margin-bottom:10px} | |
| 32 | + .steps b{display:block;font-size:19px;margin:0 0 6px}.steps span{color:var(--mut)} | |
| 33 | + .band{background:var(--a);color:var(--aT);border-radius:28px;padding:40px;display:grid;grid-template-columns:1.2fr 1fr;gap:28px;align-items:center} | |
| 34 | + .band h2{color:var(--aT)}.band p{opacity:.92;margin:0 0 14px;font-size:18px}.band .btn{background:var(--aT);color:var(--a)} | |
| 35 | + .prose{max-width:780px}.prose p,.prose li{color:var(--mut);font-size:18px}.prose h2{margin-top:44px}.prose h3{font-size:22px;margin:28px 0 6px;color:var(--fg)}.prose strong,.prose b{color:var(--fg)} | |
| 36 | + pre,code{font:14px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}code{background:var(--code);border:1px solid var(--line);border-radius:6px;padding:1px 6px} | |
| 37 | + pre{background:var(--code);border:1px solid var(--line);border-radius:14px;padding:14px 16px;overflow:auto;color:var(--fg)}pre code{background:none;border:0;padding:0} | |
| 38 | + .copy{display:flex;gap:8px;align-items:center;background:var(--card);border:1px solid var(--line);border-radius:999px;padding:6px 6px 6px 16px;max-width:560px}.copy code{border:0;background:none;padding:0;flex:1;min-width:0;overflow:auto;white-space:nowrap} | |
| 39 | + .notice{background:var(--soft);border-radius:18px;padding:16px 20px;font-size:16px;margin:0 0 24px;max-width:780px}.notice b{color:var(--a)} | |
| 40 | + .err{color:var(--warn);font-weight:600} | |
| 41 | + table.list{width:100%;border-collapse:collapse;background:var(--card);border:1px solid var(--line);border-radius:16px;overflow:hidden;font-size:15px} | |
| 42 | + table.list td,table.list th{padding:11px 14px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}table.list tr:last-child td{border-bottom:0}table.list th{font-size:13px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut)} | |
| 43 | + table.list a{text-decoration:none;font-weight:600}table.list a:hover{text-decoration:underline}table.list .m{color:var(--mut)}table.list .r{text-align:right;white-space:nowrap} | |
| 44 | + .crumbs{display:flex;flex-wrap:wrap;gap:6px;align-items:center;font-size:16px;margin:0 0 14px;color:var(--mut)}.crumbs a{font-weight:700;color:var(--fg)} | |
| 45 | + .bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;margin:0 0 16px} | |
| 46 | + .tabs{display:flex;gap:6px;flex-wrap:wrap}.tabs a{padding:8px 16px;border-radius:999px;text-decoration:none;font-weight:600;font-size:15px;color:var(--mut);border:1.5px solid var(--line)}.tabs a[aria-current]{background:var(--soft);color:var(--fg);border-color:transparent} | |
| 47 | + .tag{display:inline-block;padding:2px 10px;border-radius:999px;font-size:12px;font-weight:700;letter-spacing:.02em;background:var(--soft);color:var(--fg);white-space:nowrap} | |
| 48 | + .tag.new{background:#fff1d6;color:#7a4a00}.tag.kept{background:#dff3e6;color:#145232}.tag.removed{background:#fbe1d8;color:#8a2a0c}.tag.system{background:var(--soft);color:var(--mut)} | |
| 49 | + @media (prefers-color-scheme:dark){.tag.new{background:#3a2a0a;color:#f6cf86}.tag.kept{background:#163a26;color:#9fe3bb}.tag.removed{background:#3d1a10;color:#ffb39a}} | |
| 50 | + .votes{display:inline-flex;gap:6px;align-items:center}.votes form{display:inline}.votes button{min-height:36px;min-width:52px;padding:4px 12px;border-radius:999px;border:1.5px solid var(--line);background:var(--card);color:var(--fg);font:inherit;font-size:14px;font-weight:700;cursor:pointer} | |
| 51 | + .votes button[aria-pressed=true]{background:var(--a);color:var(--aT);border-color:var(--a)}.votes button:disabled{opacity:.55;cursor:default} | |
| 52 | + .md{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:8px 28px 20px;overflow-wrap:anywhere}.md img{max-width:100%;border-radius:12px}.md h1{font-size:34px;margin:18px 0 10px}.md h2{font-size:26px;margin:28px 0 8px}.md h3{font-size:20px;margin:22px 0 6px} | |
| 53 | + .md p,.md li{color:var(--fg);font-size:16px}.md table{border-collapse:collapse}.md td,.md th{border:1px solid var(--line);padding:6px 10px}.md blockquote{margin:0;padding:4px 16px;border-left:4px solid var(--line);color:var(--mut)} | |
| 54 | + .src{background:var(--card);border:1px solid var(--line);border-radius:18px;overflow:auto}.src table{border-collapse:collapse;width:100%}.src td{padding:0 12px;font:13px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;vertical-align:top}.src td.n{color:var(--mut);text-align:right;user-select:none;width:1%;border-right:1px solid var(--line)} | |
| 55 | + .diff .add{background:rgba(46,160,67,.14)}.diff .del{background:rgba(220,70,40,.14)}.diff .hunk td{color:var(--mut);background:var(--soft)} | |
| 56 | + .file{margin:0 0 18px}.file h3{font-size:15px;margin:0 0 8px;font-family:ui-monospace,Menlo,monospace;font-weight:600} | |
| 57 | + form.stack{display:grid;gap:12px;max-width:520px}form.stack label{font-weight:700}form.stack input,form.stack textarea{width:100%;font:inherit;padding:12px 14px;border-radius:14px;border:1.5px solid var(--line);background:var(--card);color:var(--fg)} | |
| 58 | + .grid2{display:grid;grid-template-columns:1fr 1fr;gap:28px}.muted{color:var(--mut)}.small{font-size:14px} | |
| 59 | + .diagram{background:var(--card);border:1px solid var(--line);border-radius:24px;padding:20px}.diagram svg{width:100%;height:auto;display:block} | |
| 60 | + main,.hero>*,.grid2>*,.band>*,.prose{min-width:0}pre{max-width:100%} | |
| 61 | + footer{border-top:1px solid var(--line);padding:24px 0 40px;color:var(--mut);font-size:14px;display:flex;gap:10px 18px;flex-wrap:wrap;align-items:center;margin-top:56px}footer a{padding:10px 0} | |
| 62 | + @media (max-width:860px){.hero,.band,.grid2{grid-template-columns:1fr}.hero{padding-top:8px}table.list .hide{display:none}.md{padding:4px 16px 16px}}`; | |
| 63 | + | |
| 64 | + export interface PageOpts { title: string; description?: string; path: string; body: string; me?: { handle: string } | null; head?: string; noindex?: boolean; current?: string; scripts?: string[] } | |
| 65 | + | |
| 66 | + const NAV: [string, string][] = [['/companies', 'Companies'], ['/repos', 'Projects'], ['/how-to-pull', 'How to pull'], ['/how-to-contribute', 'How to contribute'], ['/rules', 'How votes work'], ['/features', 'For apps'], ['/careers', 'Careers']]; | |
| 67 | + | |
| 68 | + export function page(o: PageOpts): Response { | |
| 69 | + const title = o.path === '/' ? o.title : `${o.title} | Branchwell`; | |
| 70 | + const desc = o.description || 'Branchwell hosts open Git repositories. Anyone can pull. Anyone signed in can push. People vote on each commit.'; | |
| 71 | + const url = SITE + o.path; | |
| 72 | + const nav = NAV.map(([h, t]) => `<a href="${h}"${o.current === h ? ' aria-current="page"' : ''}>${t}</a>`).join('') + | |
| 73 | + (o.me ? `<a class="me" href="/account">${esc(o.me.handle)}</a>` : `<a class="me" href="/signin">Sign in</a>`); | |
| 74 | + const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> | |
| 75 | + <title>${esc(title)}</title><meta name="description" content="${esc(desc)}"><link rel="canonical" href="${esc(url)}"> | |
| 76 | + <meta property="og:type" content="website"><meta property="og:site_name" content="Branchwell"><meta property="og:title" content="${esc(title)}"><meta property="og:description" content="${esc(desc)}"><meta property="og:url" content="${esc(url)}"> | |
| 77 | + <meta name="twitter:card" content="summary"><meta name="twitter:title" content="${esc(title)}"><meta name="twitter:description" content="${esc(desc)}"> | |
| 78 | + ${o.noindex ? '<meta name="robots" content="noindex">' : ''}<meta name="theme-color" content="#f7f8f3" media="(prefers-color-scheme: light)"><meta name="theme-color" content="#0e1511" media="(prefers-color-scheme: dark)"> | |
| 79 | + <link rel="icon" href="${FAVICON}"><style>${CSS}</style>${o.head || ''}${NO_ORPHANS}</head> | |
| 80 | + <body><a class="skip" href="#main">Skip to content</a><div class="wrap"> | |
| 81 | + <header><a class="brand" href="/" aria-label="Branchwell home">${LOGO}Branchwell</a><nav aria-label="Main">${nav}</nav></header> | |
| 82 | + <main id="main">${o.body}</main> | |
| 83 | + <footer><span>Branchwell</span><a href="/companies">Companies</a><a href="/branchwell/source">Source</a><a href="/research">Research</a><a href="/careers">Careers</a><a href="/privacy">Privacy</a></footer> | |
| 84 | + </div>${(o.scripts || []).map((s) => `<script src="${s}" defer></script>`).join('')}</body></html>`; | |
| 85 | + return new Response(html, { headers: { 'content-type': 'text/html; charset=utf-8', 'cache-control': o.me ? 'private, no-store' : 'no-cache', ...SECURITY } }); | |
| 86 | + } | |
| 87 | + | |
| 88 | + export const SECURITY = { | |
| 89 | + 'x-content-type-options': 'nosniff', 'referrer-policy': 'strict-origin-when-cross-origin', 'x-frame-options': 'DENY', | |
| 90 | + 'content-security-policy': "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; connect-src 'self' https://projectatom.ai; frame-ancestors 'none'; base-uri 'self'; form-action 'self'", | |
| 91 | + }; | |
| 92 | + | |
| 93 | + export function ago(ms: number): string { | |
| 94 | + const s = Math.max(1, Math.round((Date.now() - ms) / 1000)); | |
| 95 | + if (s < 60) return 'just now'; | |
| 96 | + const m = Math.round(s / 60); if (m < 60) return `${m} min ago`; | |
| 97 | + const h = Math.round(m / 60); if (h < 48) return `${h} hour${h === 1 ? '' : 's'} ago`; | |
| 98 | + const d = Math.round(h / 24); if (d < 60) return `${d} days ago`; | |
| 99 | + return new Date(ms).toISOString().slice(0, 10); | |
| 100 | + } | |
| 101 | + export const sizeText = (n: number) => n < 1024 ? `${n} B` : n < 1048576 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1048576).toFixed(1)} MB`; | |
| 102 | + | |
| 103 | + // ---------- Markdown (safe: everything is escaped first) ---------- | |
| 104 | + export function markdown(src: string, linkBase = '', rawBase = ''): string { | |
| 105 | + const fix = (u: string, raw: boolean) => { | |
| 106 | + if (/^(https?:|mailto:|#)/i.test(u)) return u; | |
| 107 | + if (/^javascript:/i.test(u)) return '#'; | |
| 108 | + if (u.startsWith('/')) return u; | |
| 109 | + return (raw ? rawBase : linkBase) + u.replace(/^\.\//, ''); | |
| 110 | + }; | |
| 111 | + const inline = (t: string) => { | |
| 112 | + const codes: string[] = []; | |
| 113 | + t = t.replace(/`([^`]+)`/g, (_, c) => { codes.push(`<code>${esc(c)}</code>`); return `\u0000${codes.length - 1}\u0000`; }); | |
| 114 | + t = esc(t); | |
| 115 | + t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (_, alt, u) => `<img src="${esc(fix(u.replace(/&/g, '&'), true))}" alt="${alt}" loading="lazy">`); | |
| 116 | + t = t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_, txt, u) => { const h = fix(u.replace(/&/g, '&'), false); return `<a href="${esc(h)}"${/^https?:/.test(h) ? ' rel="noopener nofollow ugc"' : ''}>${txt}</a>`; }); | |
| 117 | + t = t.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>').replace(/(^|[^*])\*([^*\s][^*]*)\*/g, '$1<em>$2</em>'); | |
| 118 | + t = t.replace(/(^|[\s(])(https?:\/\/[^\s<)]+)/g, (_, p, u) => `${p}<a href="${u}" rel="noopener nofollow ugc">${u}</a>`); | |
| 119 | + return t.replace(/\u0000(\d+)\u0000/g, (_, i) => codes[+i]); | |
| 120 | + }; | |
| 121 | + const lines = src.replace(/\r\n?/g, '\n').split('\n'); | |
| 122 | + const out: string[] = []; | |
| 123 | + let i = 0; | |
| 124 | + while (i < lines.length) { | |
| 125 | + const l = lines[i]; | |
| 126 | + if (/^```/.test(l)) { const buf: string[] = []; i++; while (i < lines.length && !/^```/.test(lines[i])) buf.push(lines[i++]); i++; out.push(`<pre><code>${esc(buf.join('\n'))}</code></pre>`); continue; } | |
| 127 | + const h = l.match(/^(#{1,6})\s+(.*)$/); if (h) { const n = h[1].length; const id = h[2].toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, ''); out.push(`<h${n} id="${id}">${inline(h[2])}</h${n}>`); i++; continue; } | |
| 128 | + if (/^\s*(---|\*\*\*)\s*$/.test(l)) { out.push('<hr>'); i++; continue; } | |
| 129 | + if (/^\s*$/.test(l)) { i++; continue; } | |
| 130 | + if (/^>/.test(l)) { const buf: string[] = []; while (i < lines.length && /^>/.test(lines[i])) buf.push(lines[i++].replace(/^>\s?/, '')); out.push(`<blockquote>${markdown(buf.join('\n'), linkBase, rawBase)}</blockquote>`); continue; } | |
| 131 | + if (/^\|/.test(l) && i + 1 < lines.length && /^\|?\s*:?-+/.test(lines[i + 1])) { | |
| 132 | + const row = (s: string) => s.replace(/^\||\|$/g, '').split('|').map((c) => c.trim()); | |
| 133 | + const head = row(l); i += 2; const rows: string[][] = []; | |
| 134 | + while (i < lines.length && /^\|/.test(lines[i])) rows.push(row(lines[i++])); | |
| 135 | + out.push(`<table><thead><tr>${head.map((c) => `<th>${inline(c)}</th>`).join('')}</tr></thead><tbody>${rows.map((r) => `<tr>${r.map((c) => `<td>${inline(c)}</td>`).join('')}</tr>`).join('')}</tbody></table>`); | |
| 136 | + continue; | |
| 137 | + } | |
| 138 | + if (/^\s*([-*+]|\d+\.)\s+/.test(l)) { | |
| 139 | + const ordered = /^\s*\d+\./.test(l); | |
| 140 | + const items: string[] = []; let cur: string[] | null = null; | |
| 141 | + const base = l.match(/^\s*/)![0].length; | |
| 142 | + while (i < lines.length) { | |
| 143 | + const x = lines[i]; | |
| 144 | + const m = x.match(/^(\s*)([-*+]|\d+\.)\s+(.*)$/); | |
| 145 | + if (m && m[1].length <= base) { if (cur) items.push(cur.join('\n')); cur = [m[3]]; i++; continue; } | |
| 146 | + if (/^\s*$/.test(x)) { | |
| 147 | + const nx = lines[i + 1]; | |
| 148 | + if (nx !== undefined && (/^\s+\S/.test(nx) || (/^\s*([-*+]|\d+\.)\s+/.test(nx) && ordered === /^\s*\d+\./.test(nx)))) { i++; continue; } | |
| 149 | + break; | |
| 150 | + } | |
| 151 | + if (cur && /^\s+\S/.test(x)) { cur.push(x.replace(/^\s{1,4}/, '')); i++; continue; } | |
| 152 | + break; | |
| 153 | + } | |
| 154 | + cur = cur || []; | |
| 155 | + if (cur.length) items.push(cur.join('\n')); | |
| 156 | + const tag = ordered ? 'ol' : 'ul'; | |
| 157 | + out.push(`<${tag}>${items.map((it) => { const [first, ...rest] = it.split('\n'); const sub = rest.join('\n').trim(); return `<li>${inline(first.replace(/ {2}$/, ''))}${sub ? (/^\s*([-*+]|\d+\.)\s/.test(sub) ? markdown(sub, linkBase, rawBase) : '<br>' + sub.split('\n').map((s) => inline(s.trim())).join('<br>')) : ''}</li>`; }).join('')}</${tag}>`); | |
| 158 | + continue; | |
| 159 | + } | |
| 160 | + const buf: string[] = []; | |
| 161 | + while (i < lines.length && !/^\s*$/.test(lines[i]) && !/^(#{1,6}\s|```|>|\|)/.test(lines[i]) && !/^\s*([-*+]|\d+\.)\s+/.test(lines[i])) buf.push(lines[i++]); | |
| 162 | + out.push(`<p>${buf.map((s, k) => inline(s.trimEnd()) + (k < buf.length - 1 ? (/ {2}$/.test(s) ? '<br>' : ' ') : '')).join('')}</p>`); | |
| 163 | + } | |
| 164 | + return out.join('\n'); | |
| 165 | + } | |
| 166 | + | |
| 167 | + // ---------- line diff ---------- | |
| 168 | + export function diffLines(a: string, b: string): { t: ' ' | '+' | '-'; s: string; na?: number; nb?: number }[] { | |
| 169 | + const A = a ? a.replace(/\n$/, '').split('\n') : [], B = b ? b.replace(/\n$/, '').split('\n') : []; | |
| 170 | + let p = 0; while (p < A.length && p < B.length && A[p] === B[p]) p++; | |
| 171 | + let sa = A.length, sb = B.length; while (sa > p && sb > p && A[sa - 1] === B[sb - 1]) { sa--; sb--; } | |
| 172 | + const a2 = A.slice(p, sa), b2 = B.slice(p, sb); | |
| 173 | + const mid: { t: ' ' | '+' | '-'; s: string }[] = []; | |
| 174 | + if (a2.length * b2.length > 4_000_000) { a2.forEach((s) => mid.push({ t: '-', s })); b2.forEach((s) => mid.push({ t: '+', s })); } | |
| 175 | + else { | |
| 176 | + const n = a2.length, m = b2.length; const L = Array.from({ length: n + 1 }, () => new Uint32Array(m + 1)); | |
| 177 | + for (let x = n - 1; x >= 0; x--) for (let y = m - 1; y >= 0; y--) L[x][y] = a2[x] === b2[y] ? L[x + 1][y + 1] + 1 : Math.max(L[x + 1][y], L[x][y + 1]); | |
| 178 | + let x = 0, y = 0; | |
| 179 | + while (x < n || y < m) { | |
| 180 | + if (x < n && y < m && a2[x] === b2[y]) { mid.push({ t: ' ', s: a2[x] }); x++; y++; } | |
| 181 | + else if (x < n && (y >= m || L[x + 1][y] >= L[x][y + 1])) mid.push({ t: '-', s: a2[x++] }); | |
| 182 | + else mid.push({ t: '+', s: b2[y++] }); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + const all = [...A.slice(0, p).map((s) => ({ t: ' ' as const, s })), ...mid, ...A.slice(sa).map((s) => ({ t: ' ' as const, s }))]; | |
| 186 | + let na = 1, nb = 1; | |
| 187 | + return all.map((r) => { const o = { ...r, na: r.t !== '+' ? na : undefined, nb: r.t !== '-' ? nb : undefined }; if (r.t !== '+') na++; if (r.t !== '-') nb++; return o; }); | |
| 188 | + } | |
| 189 | + | |
| 190 | + export function diffHtml(a: string, b: string): string { | |
| 191 | + const rows = diffLines(a, b); | |
| 192 | + const keep = new Array(rows.length).fill(false); | |
| 193 | + rows.forEach((r, i) => { if (r.t !== ' ') for (let k = Math.max(0, i - 3); k <= Math.min(rows.length - 1, i + 3); k++) keep[k] = true; }); | |
| 194 | + let out = ''; let gap = false; let shown = 0; | |
| 195 | + rows.forEach((r, i) => { | |
| 196 | + if (!keep[i]) { gap = true; return; } | |
| 197 | + if (gap && out) out += `<tr class="hunk"><td class="n"></td><td class="n"></td><td>⋯</td></tr>`; | |
| 198 | + gap = false; | |
| 199 | + if (shown++ > 1500) return; | |
| 200 | + out += `<tr class="${r.t === '+' ? 'add' : r.t === '-' ? 'del' : ''}"><td class="n">${r.na ?? ''}</td><td class="n">${r.nb ?? ''}</td><td>${r.t === ' ' ? ' ' : r.t} ${esc(r.s)}</td></tr>`; | |
| 201 | + }); | |
| 202 | + return out ? `<div class="src diff"><table>${out}</table></div>` : '<p class="muted">No text changes.</p>'; | |
| 203 | + } |
src/index.ts added
| 1 | + // Branchwell: open Git hosting. Clone, pull and push over HTTPS; passkey sign-in; commits and branches | |
| 2 | + // are kept or removed by votes. One Worker, one D1 database, one Durable Object per repository. | |
| 3 | + import type { Env } from './env'; | |
| 4 | + import { page, esc, ago, sizeText, markdown, diffHtml, SITE, SECURITY } from './html'; | |
| 5 | + import { handleAuth, currentAccount, canVote, pusherFromBasic, RESERVED, type Account } from './auth'; | |
| 6 | + import { featuresApi, featureVote, WIDGET_JS } from './features'; | |
| 7 | + import { ODOMETER_CSS, ODOMETER_JS, APP_JS } from './static'; | |
| 8 | + import * as C from './content'; | |
| 9 | + import { isText } from './repo'; | |
| 10 | + | |
| 11 | + export { RepoDO } from './repo'; | |
| 12 | + | |
| 13 | + // Every repository lives under an owner: a company account (org) or a person, as owner/project. | |
| 14 | + const OWNER_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/; | |
| 15 | + const PROJ_RE = /^[a-z0-9][a-z0-9._-]{0,62}$/; | |
| 16 | + const FULL_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?\/[a-z0-9][a-z0-9._-]{0,62}$/; | |
| 17 | + const VIEWS = new Set(['tree', 'blob', 'raw', 'commits', 'commit', 'branches']); | |
| 18 | + const GIT_RE = /^\/([a-z0-9][a-z0-9-]{0,39})\/([a-z0-9][a-z0-9._-]{0,62}?)(?:\.git)?\/(info\/refs|git-upload-pack|git-receive-pack)$/; | |
| 19 | + const OLD_GIT_RE = /^\/([a-z0-9][a-z0-9._-]{0,62}?)(?:\.git)?\/(info\/refs|git-upload-pack|git-receive-pack)$/; | |
| 20 | + const json = (b: unknown, s = 200, h: Record<string, string> = {}) => new Response(JSON.stringify(b), { status: s, headers: { 'content-type': 'application/json', 'cache-control': 'no-store', ...h } }); | |
| 21 | + // do_name is the storage key. Older repos keep the flat name they were first pushed under. | |
| 22 | + const stub = (env: Env, doName: string) => env.REPO.get(env.REPO.idFromName(doName.toLowerCase())); | |
| 23 | + type RepoRow = { name: string; owner: string; do_name: string; description: string; created_by: string; created_at: number; updated_at: number }; | |
| 24 | + type Org = { handle: string; name: string; domain: string | null; about: string | null; created_at: number }; | |
| 25 | + const asset = (body: string, type: string) => new Response(body, { headers: { 'content-type': type, 'cache-control': 'public, max-age=3600', 'access-control-allow-origin': '*' } }); | |
| 26 | + const APP = ['/assets/app.js']; | |
| 27 | + | |
| 28 | + async function repoRow(env: Env, name: string) { | |
| 29 | + return env.DB.prepare('SELECT name, owner, COALESCE(do_name, name) AS do_name, description, created_by, created_at, updated_at FROM repos WHERE name = ?').bind(name.toLowerCase()).first<RepoRow>(); | |
| 30 | + } | |
| 31 | + const orgRow = (env: Env, handle: string) => env.DB.prepare('SELECT handle, name, domain, about, created_at FROM orgs WHERE handle = ?').bind(handle.toLowerCase()).first<Org>(); | |
| 32 | + async function myOrgs(env: Env, me: Account) { | |
| 33 | + return (await env.DB.prepare('SELECT o.handle, o.name, o.domain, o.about, o.created_at FROM org_members m JOIN orgs o ON o.handle = m.org WHERE m.account_id = ? ORDER BY o.name').bind(me.id).all<Org>()).results; | |
| 34 | + } | |
| 35 | + async function canCreateUnder(env: Env, owner: string, by: Account) { | |
| 36 | + if (owner === by.handle.toLowerCase()) return true; | |
| 37 | + return !!(await env.DB.prepare('SELECT 1 AS x FROM org_members WHERE org = ? AND account_id = ?').bind(owner, by.id).first('x')); | |
| 38 | + } | |
| 39 | + async function createRepo(env: Env, owner: string, project: string, description: string, by: Account): Promise<string | null> { | |
| 40 | + owner = owner.toLowerCase(); project = project.toLowerCase().replace(/\.git$/, ''); | |
| 41 | + if (!PROJ_RE.test(project) || VIEWS.has(project)) return 'Use 1 to 63 lowercase letters, numbers, dots, dashes or underscores.'; | |
| 42 | + if (!(await canCreateUnder(env, owner, by))) return `You can start projects under your own name, or under a company you belong to. ${owner} isn't one of those.`; | |
| 43 | + const name = owner + '/' + project; | |
| 44 | + if (await repoRow(env, name)) return 'That name is taken.'; | |
| 45 | + if (owner === by.handle.toLowerCase()) { | |
| 46 | + const n = await env.DB.prepare('SELECT COUNT(*) AS n FROM repos WHERE created_by = ? AND owner = ? AND created_at > ?').bind(by.handle, owner, Date.now() - 864e5).first<number>('n'); | |
| 47 | + if ((n || 0) >= 5) return 'You can make 5 projects a day. Try again tomorrow.'; | |
| 48 | + } | |
| 49 | + await env.DB.prepare('INSERT INTO repos (name, owner, do_name, description, created_by, created_at) VALUES (?, ?, ?, ?, ?, ?)').bind(name, owner, name, description.slice(0, 300), by.handle, Date.now()).run(); | |
| 50 | + await stub(env, name).init(name); | |
| 51 | + return null; | |
| 52 | + } | |
| 53 | + | |
| 54 | + export default { | |
| 55 | + async fetch(req: Request, env: Env, ctx: ExecutionContext): Promise<Response> { | |
| 56 | + const url = new URL(req.url); | |
| 57 | + if (url.hostname === 'www.branchwell.ai') return Response.redirect(SITE + url.pathname + url.search, 301); | |
| 58 | + const path = decodeURIComponent(url.pathname); | |
| 59 | + try { | |
| 60 | + // ---------- Git over HTTPS ---------- | |
| 61 | + const g = url.pathname.match(GIT_RE); | |
| 62 | + if (g) return await git(req, env, ctx, g[1] + '/' + g[2], g[3], url); | |
| 63 | + const og = url.pathname.match(OLD_GIT_RE); | |
| 64 | + if (og) { | |
| 65 | + // Old one-part addresses (branchwell.ai/sunlaid.git) now live at the company's research project. | |
| 66 | + const to = await repoRow(env, og[1].toLowerCase() + '/research'); | |
| 67 | + if (to) return Response.redirect(`${SITE}/${to.name}.git/${og[2]}${url.search}`, 301); | |
| 68 | + return new Response(`Repositories now live under an owner, like https://branchwell.ai/sunlaid/research.git\n`, { status: 404, headers: { 'content-type': 'text/plain' } }); | |
| 69 | + } | |
| 70 | + | |
| 71 | + // ---------- assets and APIs ---------- | |
| 72 | + if (path === '/assets/app.js') return asset(APP_JS, 'text/javascript; charset=utf-8'); | |
| 73 | + if (path === '/assets/visitor-odometer.v1.js') return asset(ODOMETER_JS, 'text/javascript; charset=utf-8'); | |
| 74 | + if (path === '/assets/visitor-odometer.v1.css') return asset(ODOMETER_CSS, 'text/css; charset=utf-8'); | |
| 75 | + if (path === '/widget/features.v1.js') return asset(WIDGET_JS, 'text/javascript; charset=utf-8'); | |
| 76 | + if (path === '/robots.txt') return new Response(`User-agent: *\nAllow: /\nDisallow: /api/\nSitemap: ${SITE}/sitemap.xml\n`, { headers: { 'content-type': 'text/plain' } }); | |
| 77 | + if (path === '/sitemap.xml') return sitemap(env); | |
| 78 | + if (path === '/llms.txt') return new Response(LLMS, { headers: { 'content-type': 'text/plain; charset=utf-8' } }); | |
| 79 | + if (path === '/favicon.ico' || path === '/favicon.svg') return new Response(null, { status: 404 }); | |
| 80 | + if (path.startsWith('/api/auth/')) return await handleAuth(req, env, path.slice(10)); | |
| 81 | + if (path === '/api/features') return await featuresApi(req, env, url); | |
| 82 | + if (path === '/api/feature-vote' && req.method === 'POST') return await featureVote(req, env); | |
| 83 | + if (path === '/api/vote' && req.method === 'POST') return await vote(req, env); | |
| 84 | + if (path === '/api/repos' && req.method === 'POST') return await apiCreateRepo(req, env); | |
| 85 | + if (path === '/api/request') { | |
| 86 | + if (!env.CAREERS) return json({ ok: false, error: 'Unavailable' }, 503); | |
| 87 | + return await env.CAREERS.fetch(new Request('https://careers-intake/api/request', req)); | |
| 88 | + } | |
| 89 | + if (path.startsWith('/api/')) return json({ error: 'Not found' }, 404); | |
| 90 | + | |
| 91 | + // ---------- pages ---------- | |
| 92 | + const me = await currentAccount(req, env); | |
| 93 | + const P = (title: string, body: string, extra: Partial<Parameters<typeof page>[0]> = {}) => page({ title, body, path: url.pathname, me, scripts: APP, ...extra }); | |
| 94 | + switch (path.replace(/\/$/, '') || '/') { | |
| 95 | + case '/': { | |
| 96 | + const repos = await env.DB.prepare('SELECT COUNT(*) AS n FROM repos').first<number>('n'); | |
| 97 | + const companies = await env.DB.prepare('SELECT COUNT(*) AS n FROM orgs').first<number>('n'); | |
| 98 | + return P('Branchwell: open Git hosting where votes decide', C.home({ repos: repos || 0, companies: companies || 0 }), { | |
| 99 | + head: '<link rel="stylesheet" href="/assets/visitor-odometer.v1.css"><script src="/assets/visitor-odometer.v1.js" defer></script>' + ORG_LD, | |
| 100 | + description: 'Branchwell hosts open Git repositories. Anyone can pull, anyone signed in can push straight to a branch, and 3 votes keep or remove each commit.' }); | |
| 101 | + } | |
| 102 | + case '/how-to-pull': return P('How to pull', C.howToPull, { current: '/how-to-pull', description: 'Clone and pull any Branchwell repository with plain Git. No account needed.' }); | |
| 103 | + case '/how-to-contribute': return P('How to contribute', C.howToContribute, { current: '/how-to-contribute', description: 'Sign in with a passkey, make a push key and push straight to a branch. No pull requests.' }); | |
| 104 | + case '/rules': return P('How votes work', C.rules, { current: '/rules', description: '3 votes down removes a commit or branch. 3 votes up keeps it for good. Everything else stays.' }); | |
| 105 | + case '/features': return P('New features, voted in', C.features, { current: '/features', description: 'Add a New badge with thumbs up and down to any app. 3 up keeps a feature, 3 down switches it off.' }); | |
| 106 | + case '/careers': return P('Careers', C.careers, { current: '/careers', description: 'Careers at Branchwell. Send us a short request to work with us.' }); | |
| 107 | + case '/privacy': return P('Privacy', C.privacy, { description: 'What Branchwell keeps and what it never does.' }); | |
| 108 | + case '/source': return Response.redirect(SITE + '/branchwell/source', 302); | |
| 109 | + case '/repos': return reposPage(env, P); | |
| 110 | + case '/companies': return companiesPage(env, P); | |
| 111 | + case '/research': return researchPage(env, P); | |
| 112 | + case '/signin': return P('Sign in', signinBody(me), { noindex: true }); | |
| 113 | + case '/account': return me ? accountPage(env, me, P) : Response.redirect(SITE + '/signin?back=/account', 302); | |
| 114 | + case '/new': return P('New project', newRepoBody(me, me ? await myOrgs(env, me) : []), { noindex: true }); | |
| 115 | + case '/feature-vote': return featureVotePage(env, url, me, P); | |
| 116 | + } | |
| 117 | + | |
| 118 | + // ---------- repository pages ---------- | |
| 119 | + const o = url.pathname.match(/^\/([a-z0-9][a-z0-9-]{0,39})\/?$/); | |
| 120 | + if (o && !RESERVED.has(o[1])) { | |
| 121 | + const r = await ownerPage(env, o[1], me, P); | |
| 122 | + if (r) return r; | |
| 123 | + } | |
| 124 | + const m = url.pathname.match(/^\/([a-z0-9][a-z0-9-]{0,39})\/([a-z0-9][a-z0-9._-]{0,62}?)(?:\.git)?(?:\/(tree|blob|raw|commits|commit|branches)(?:\/(.*))?)?\/?$/); | |
| 125 | + if (m && !RESERVED.has(m[1])) { | |
| 126 | + const row = await repoRow(env, m[1] + '/' + m[2]); | |
| 127 | + if (row) return await repoPage(env, req, url, me, row, m[3] || '', m[4] ? decodeURIComponent(m[4]) : '', P); | |
| 128 | + } | |
| 129 | + return page({ title: 'Not found', path: url.pathname, me, noindex: true, body: '<section class="hero" style="grid-template-columns:1fr"><div class="prose"><h1 class="sm">We couldn\'t find that page</h1><p class="lede">It may have moved, or a vote may have removed it.</p><p class="btns"><a class="btn" href="/">Home</a><a class="btn ghost" href="/repos">All repositories</a></p></div></section>' }).then404(); | |
| 130 | + } catch (e) { | |
| 131 | + console.error(e); | |
| 132 | + return new Response('Something went wrong on our side. Please try again.', { status: 500 }); | |
| 133 | + } | |
| 134 | + }, | |
| 135 | + }; | |
| 136 | + | |
| 137 | + declare global { interface Response { then404(): Response } } | |
| 138 | + Response.prototype.then404 = function (this: Response) { return new Response(this.body, { status: 404, headers: this.headers }); }; | |
| 139 | + | |
| 140 | + // ---------------- Git ---------------- | |
| 141 | + async function git(req: Request, env: Env, ctx: ExecutionContext, name: string, op: string, url: URL): Promise<Response> { | |
| 142 | + name = name.toLowerCase(); | |
| 143 | + const service = op === 'info/refs' ? url.searchParams.get('service') : op; | |
| 144 | + const write = service === 'git-receive-pack'; | |
| 145 | + let pusher: Account | null = null; | |
| 146 | + if (write) { | |
| 147 | + pusher = await pusherFromBasic(req, env); | |
| 148 | + if (!pusher) return new Response('Sign in at https://branchwell.ai/account and make a push key. Use your Branchwell name as the username and the push key as the password.\n', { | |
| 149 | + status: 401, headers: { 'www-authenticate': 'Basic realm="Branchwell"', 'content-type': 'text/plain' } }); | |
| 150 | + } | |
| 151 | + let row = await repoRow(env, name); | |
| 152 | + if (!row) { | |
| 153 | + if (!write || !pusher) return new Response(`Repository ${name} not found on Branchwell.\n`, { status: 404, headers: { 'content-type': 'text/plain' } }); | |
| 154 | + const [owner, project] = name.split('/'); | |
| 155 | + const err = await createRepo(env, owner, project, '', pusher); | |
| 156 | + if (err) return new Response(err + '\n', { status: 403, headers: { 'content-type': 'text/plain' } }); | |
| 157 | + row = await repoRow(env, name); | |
| 158 | + } | |
| 159 | + if (!row) return new Response('Not found\n', { status: 404 }); | |
| 160 | + const target = new URL('https://repo/' + (op === 'info/refs' ? 'info/refs' : op) + url.search); | |
| 161 | + const headers = new Headers({ 'content-type': req.headers.get('content-type') || '' }); | |
| 162 | + headers.set('x-repo', row.name); | |
| 163 | + if (pusher) headers.set('x-pusher', JSON.stringify({ id: pusher.id, handle: pusher.handle })); | |
| 164 | + let body: BodyInit | null = null; | |
| 165 | + if (req.method === 'POST') { | |
| 166 | + let buf = new Uint8Array(await req.arrayBuffer()); | |
| 167 | + if ((req.headers.get('content-encoding') || '').includes('gzip')) buf = new Uint8Array(await new Response(new Blob([buf]).stream().pipeThrough(new DecompressionStream('gzip'))).arrayBuffer()); | |
| 168 | + body = buf; | |
| 169 | + } | |
| 170 | + const res = await stub(env, row.do_name).fetch(new Request(target, { method: req.method, headers, body })); | |
| 171 | + if (write && req.method === 'POST') ctx.waitUntil(env.DB.prepare('UPDATE repos SET updated_at = ? WHERE name = ?').bind(Date.now(), name).run()); | |
| 172 | + return res; | |
| 173 | + } | |
| 174 | + | |
| 175 | + // ---------------- APIs ---------------- | |
| 176 | + async function vote(req: Request, env: Env): Promise<Response> { | |
| 177 | + if (req.headers.get('origin') !== new URL(req.url).origin) return json({ error: 'Bad origin.' }, 403); | |
| 178 | + const me = await currentAccount(req, env); | |
| 179 | + if (!me) return json({ error: 'Sign in with your passkey to vote.' }, 401); | |
| 180 | + const b = await req.json<{ repo: string; kind: string; target: string; value: number }>().catch(() => null); | |
| 181 | + if (!b || !FULL_RE.test(b.repo || '') || (b.kind !== 'commit' && b.kind !== 'branch') || !b.target) return json({ error: 'Bad vote.' }, 400); | |
| 182 | + const row = await repoRow(env, b.repo); | |
| 183 | + if (!row) return json({ error: 'No such repository.' }, 404); | |
| 184 | + const r = await stub(env, row.do_name).vote(b.kind, String(b.target).slice(0, 120), { id: me.id, handle: me.handle, canVote: canVote(me) }, Number(b.value) || 0); | |
| 185 | + return json(r); | |
| 186 | + } | |
| 187 | + async function apiCreateRepo(req: Request, env: Env): Promise<Response> { | |
| 188 | + if (req.headers.get('origin') !== new URL(req.url).origin) return json({ error: 'Bad origin.' }, 403); | |
| 189 | + const me = await currentAccount(req, env); | |
| 190 | + if (!me) return json({ error: 'Sign in first.' }, 401); | |
| 191 | + const b = await req.json<{ owner: string; name: string; description: string }>().catch(() => ({ owner: '', name: '', description: '' })); | |
| 192 | + const owner = String(b.owner || me.handle).toLowerCase(), project = String(b.name || '').toLowerCase(); | |
| 193 | + if (!OWNER_RE.test(owner)) return json({ error: 'Pick who owns it.' }, 400); | |
| 194 | + const err = await createRepo(env, owner, project, String(b.description || ''), me); | |
| 195 | + if (err) return json({ error: err }, 400); | |
| 196 | + return json({ ok: true, name: owner + '/' + project }); | |
| 197 | + } | |
| 198 | + | |
| 199 | + // ---------------- pages ---------------- | |
| 200 | + type PFn = (title: string, body: string, extra?: Record<string, unknown>) => Response; | |
| 201 | + | |
| 202 | + async function reposPage(env: Env, P: PFn) { | |
| 203 | + const rows = (await env.DB.prepare('SELECT name, description, created_by, created_at, updated_at FROM repos ORDER BY COALESCE(updated_at, created_at) DESC LIMIT 1000').all<{ name: string; description: string; created_by: string; created_at: number; updated_at: number }>()).results; | |
| 204 | + const list = rows.length ? `<table class="list"><thead><tr><th>Repository</th><th class="hide">About</th><th class="r">Updated</th></tr></thead><tbody>${rows.map((r) => | |
| 205 | + `<tr><td><a href="/${esc(r.name)}">${esc(r.name)}</a></td><td class="m hide">${esc(r.description || '')}</td><td class="r m">${ago(r.updated_at || r.created_at)}</td></tr>`).join('')}</tbody></table>` : '<p class="muted">No repositories yet.</p>'; | |
| 206 | + return P('Repositories', `<section class="hero" style="grid-template-columns:1fr;padding-bottom:20px"><div><span class="eyebrow">Repositories</span><h1 class="sm">Everything here is open</h1> | |
| 207 | + <p class="lede">Pull any of these with plain Git. Sign in to push, vote, or start your own.</p><div class="btns"><a class="btn" href="/new">New project</a><a class="btn ghost" href="/companies">Companies</a></div></div></section>${list}`, { current: '/repos', description: 'Every repository on Branchwell. All public, all open to pull.' }); | |
| 208 | + } | |
| 209 | + | |
| 210 | + function signinBody(me: Account | null) { | |
| 211 | + if (me) return `<section class="hero" style="grid-template-columns:1fr"><div class="prose"><h1 class="sm">You're signed in as ${esc(me.handle)}</h1><p class="btns"><a class="btn" href="/account">Your account</a></p></div></section>`; | |
| 212 | + return `<section class="hero" style="grid-template-columns:1fr"><div class="grid2"> | |
| 213 | + <div class="prose"><span class="eyebrow">Sign in</span><h1 class="sm">Passkeys only</h1> | |
| 214 | + <p class="lede">Sign in with your face, fingerprint or device PIN. No passwords and no email.</p> | |
| 215 | + <p><button class="btn" id="signin" type="button">Sign in with a passkey</button></p><p id="signin-msg" role="status" aria-live="polite"></p></div> | |
| 216 | + <div class="card"><h2 style="font-size:26px">New here?</h2><p>Pick a public name. Your device makes a passkey for it.</p> | |
| 217 | + <form id="signup" class="stack" style="margin-top:14px"><label for="handle">Your name on Branchwell</label> | |
| 218 | + <input id="handle" name="handle" required minlength="3" maxlength="30" pattern="[a-z0-9][a-z0-9-]{1,28}[a-z0-9]" autocomplete="username webauthn" autocapitalize="none" spellcheck="false" placeholder="for example river-maple"> | |
| 219 | + <span class="small muted">3 to 30 lowercase letters, numbers or dashes.</span> | |
| 220 | + <button class="btn" type="submit">Make my passkey</button><p id="signup-msg" role="status" aria-live="polite"></p></form></div> | |
| 221 | + </div></section>`; | |
| 222 | + } | |
| 223 | + | |
| 224 | + async function accountPage(env: Env, me: Account, P: PFn) { | |
| 225 | + const keys = (await env.DB.prepare('SELECT id, name, created_at, last_used FROM push_keys WHERE account_id = ? ORDER BY created_at DESC').bind(me.id).all<{ id: string; name: string; created_at: number; last_used: number }>()).results; | |
| 226 | + const orgs = await myOrgs(env, me); | |
| 227 | + const pks = (await env.DB.prepare('SELECT created_at, last_used FROM passkeys WHERE account_id = ? ORDER BY created_at').bind(me.id).all<{ created_at: number; last_used: number }>()).results; | |
| 228 | + const wait = canVote(me) ? '<p class="muted">You can vote.</p>' : `<p class="muted">You can vote from ${new Date(me.created_at + 864e5).toUTCString().slice(0, 22)} UTC. New accounts wait a day so votes stay fair.</p>`; | |
| 229 | + return P('Your account', `<section class="hero" style="grid-template-columns:1fr;padding-bottom:12px"><div><span class="eyebrow">Your account</span><h1 class="sm">${esc(me.handle)}</h1>${wait}</div></section> | |
| 230 | + <div class="grid2"><div> | |
| 231 | + <h2 style="font-size:28px">Push keys</h2><p class="muted">Git can't use passkeys, so make a push key for each computer. Use your name as the username and the key as the password.</p> | |
| 232 | + <form id="make-key" class="stack"><label for="keyname">Name this key</label><input id="keyname" name="keyname" maxlength="60" value="My computer"><button class="btn" type="submit">Make a push key</button><p id="key-msg" role="status" aria-live="polite"></p></form> | |
| 233 | + <div id="new-key" class="card" hidden style="margin:12px 0"><p><b>Username:</b> <code id="new-key-user"></code></p><p><b>Push key:</b></p><div class="copy"><code id="new-key-value"></code><button class="btn sm" type="button" data-copy="new-key-value">Copy</button></div></div> | |
| 234 | + ${keys.length ? `<table class="list" style="margin-top:14px"><tbody>${keys.map((k) => `<tr><td>${esc(k.name)}<br><span class="small muted">made ${ago(k.created_at)}${k.last_used ? ', used ' + ago(k.last_used) : ', not used yet'}</span></td><td class="r"><button class="btn ghost sm" type="button" data-del-key="${esc(k.id)}">Remove</button></td></tr>`).join('')}</tbody></table>` : ''} | |
| 235 | + </div><div> | |
| 236 | + <h2 style="font-size:28px">Passkeys</h2><p class="muted">${pks.length} passkey${pks.length === 1 ? '' : 's'} on this account. Add one for each device you use.</p> | |
| 237 | + <p><button class="btn ghost" id="add-passkey" type="button">Add a passkey</button></p><p id="pk-msg" role="status" aria-live="polite"></p> | |
| 238 | + ${orgs.length ? `<h2 style="font-size:28px;margin-top:30px">Your companies</h2><p>${orgs.map((o) => `<a href="/${esc(o.handle)}">${esc(o.name)}</a>`).join(' · ')}</p>` : ''} | |
| 239 | + <h2 style="font-size:28px;margin-top:30px">Get started</h2><pre><code>git clone https://branchwell.ai/sunlaid/research.git</code></pre> | |
| 240 | + <p><a href="/how-to-contribute">How to contribute</a> · <a href="/new">New repository</a></p> | |
| 241 | + <p><button class="btn ghost sm" id="signout" type="button">Sign out</button></p></div></div>`, { noindex: true }); | |
| 242 | + } | |
| 243 | + | |
| 244 | + function newRepoBody(me: Account | null, orgs: Org[]) { | |
| 245 | + if (!me) return `<section class="hero" style="grid-template-columns:1fr"><div class="prose"><h1 class="sm">Start a project</h1><p class="lede">Sign in with your passkey first.</p><p class="btns"><a class="btn" href="/signin?back=/new">Sign in</a></p></div></section>`; | |
| 246 | + return `<section class="hero" style="grid-template-columns:1fr"><div class="prose"><span class="eyebrow">New project</span><h1 class="sm">Start a project</h1> | |
| 247 | + <p class="lede">Every project is public. Anyone can pull it and anyone signed in can push to it.</p> | |
| 248 | + <form id="new-repo" class="stack"><label for="owner">Owner</label><select id="owner" name="owner" style="font:inherit;border-radius:999px;padding:12px 16px;border:1.5px solid var(--line);background:var(--card);color:var(--fg)"><option value="${esc(me.handle)}">${esc(me.handle)} (you)</option>${orgs.map((o) => `<option value="${esc(o.handle)}">${esc(o.name)}</option>`).join('')}</select> | |
| 249 | + <label for="repo">Name</label><input id="repo" name="repo" required maxlength="63" pattern="[a-z0-9][a-z0-9._-]{0,62}" autocapitalize="none" spellcheck="false" placeholder="my-project"> | |
| 250 | + <label for="description">What it's for (optional)</label><input id="description" name="description" maxlength="300"> | |
| 251 | + <button class="btn" type="submit">Make it</button><p id="repo-msg" role="status" aria-live="polite"></p></form> | |
| 252 | + <p class="muted">Or just push to a new name: <code>git push https://branchwell.ai/${esc(me.handle)}/my-project.git main</code></p></div></section>`; | |
| 253 | + } | |
| 254 | + | |
| 255 | + async function featureVotePage(env: Env, url: URL, me: Account | null, P: PFn) { | |
| 256 | + const app = (url.searchParams.get('app') || '').toLowerCase(), feature = (url.searchParams.get('feature') || '').toLowerCase(); | |
| 257 | + const f = await env.DB.prepare('SELECT status, up, down FROM features WHERE app = ? AND feature = ?').bind(app, feature).first<{ status: string; up: number; down: number }>(); | |
| 258 | + if (!f) return P('Feature vote', '<section class="hero" style="grid-template-columns:1fr"><div class="prose"><h1 class="xs">We couldn\'t find that feature</h1></div></section>', { noindex: true }); | |
| 259 | + const back = encodeURIComponent(url.pathname + url.search); | |
| 260 | + const v = url.searchParams.get('v') === 'down' ? -1 : 1; | |
| 261 | + const body = !me ? `<p class="lede">Sign in with your passkey to vote.</p><p><a class="btn" href="/signin?back=${back}">Sign in</a></p>` | |
| 262 | + : f.status !== 'new' ? `<p class="lede">${f.status === 'kept' ? 'This feature already got 3 thumbs up. It stays for good.' : 'This feature got 3 thumbs down and is switched off.'}</p>` | |
| 263 | + : `<p class="lede">3 thumbs up keeps it for good. 3 thumbs down switches it off.</p><p class="btns"> | |
| 264 | + <button class="btn${v > 0 ? '' : ' ghost'}" type="button" data-fvote="1" data-app="${esc(app)}" data-feature="${esc(feature)}">👍 Keep it (${f.up})</button> | |
| 265 | + <button class="btn${v < 0 ? '' : ' ghost'}" type="button" data-fvote="-1" data-app="${esc(app)}" data-feature="${esc(feature)}">👎 Remove it (${f.down})</button></p><p id="fv-msg" role="status" aria-live="polite"></p>`; | |
| 266 | + return P('Vote on a new feature', `<section class="hero" style="grid-template-columns:1fr;padding-top:0"><div class="prose"><span class="eyebrow">New feature</span><h1 class="xs">${esc(feature.replace(/[-_.]/g, ' '))}</h1><p class="muted">in ${esc(app)}</p>${body}</div></section>`, { noindex: true }); | |
| 267 | + } | |
| 268 | + | |
| 269 | + // ---------------- owners and companies ---------------- | |
| 270 | + type ProjRow = { name: string; description: string; updated_at: number; created_at: number }; | |
| 271 | + const projTable = (rows: ProjRow[], showOwner = false) => rows.length ? `<table class="list"><tbody>${rows.map((r) => | |
| 272 | + `<tr><td><a href="/${esc(r.name)}">${esc(showOwner ? r.name : r.name.split('/')[1])}</a>${r.description ? `<br><span class="small muted">${esc(r.description)}</span>` : ''}</td><td class="r m">${ago(r.updated_at || r.created_at)}</td></tr>`).join('')}</tbody></table>` : '<p class="muted">No projects yet.</p>'; | |
| 273 | + | |
| 274 | + async function ownerPage(env: Env, handle: string, me: Account | null, P: PFn): Promise<Response | null> { | |
| 275 | + const org = await orgRow(env, handle); | |
| 276 | + const person = org ? null : await env.DB.prepare('SELECT handle, created_at FROM accounts WHERE handle = ?').bind(handle).first<{ handle: string; created_at: number }>(); | |
| 277 | + if (!org && !person) return null; | |
| 278 | + const rows = (await env.DB.prepare('SELECT name, description, updated_at, created_at FROM repos WHERE owner = ? ORDER BY name').bind(handle).all<ProjRow>()).results; | |
| 279 | + const member = !!(me && (await canCreateUnder(env, handle, me))); | |
| 280 | + const title = org ? org.name : handle; | |
| 281 | + const site = org?.domain ? `<p class="small"><a href="https://${esc(org.domain)}" rel="noopener">${esc(org.domain)}</a></p>` : ''; | |
| 282 | + return P(title, `<section class="hero" style="grid-template-columns:1fr;padding-bottom:20px"><div><span class="eyebrow">${org ? 'Company' : 'Person'}</span><h1 class="sm">${esc(title)}</h1> | |
| 283 | + ${org?.about ? `<p class="lede">${esc(org.about)}</p>` : ''}${site}<p class="small muted">${rows.length} project${rows.length === 1 ? '' : 's'}. Every one is public: pull it with plain Git, push to it once you sign in.</p> | |
| 284 | + ${member ? '<div class="btns"><a class="btn" href="/new">New project</a></div>' : ''}</div></section> | |
| 285 | + <h2 style="font-size:28px">Projects</h2>${projTable(rows)}`, { description: org ? `${org.name} on Branchwell: every project, open to pull and to push.` : `${handle} on Branchwell.` }); | |
| 286 | + } | |
| 287 | + | |
| 288 | + async function companiesPage(env: Env, P: PFn) { | |
| 289 | + const orgs = (await env.DB.prepare('SELECT o.handle, o.name, o.domain, o.about, (SELECT COUNT(*) FROM repos r WHERE r.owner = o.handle) AS n FROM orgs o ORDER BY o.name COLLATE NOCASE').all<Org & { n: number }>()).results; | |
| 290 | + const cards = orgs.map((o) => `<a class="card" href="/${esc(o.handle)}" style="text-decoration:none;color:inherit;display:block"><h3 style="font-size:20px;margin:0 0 4px">${esc(o.name)}</h3><p class="small muted" style="margin:0">${o.domain ? esc(o.domain) + ' · ' : ''}${o.n} project${o.n === 1 ? '' : 's'}</p></a>`).join(''); | |
| 291 | + return P('Companies', `<section class="hero" style="grid-template-columns:1fr;padding-bottom:20px"><div><span class="eyebrow">Companies</span><h1 class="sm">Every company, in the open</h1> | |
| 292 | + <p class="lede">Each company has its own account here, and its projects live inside it. Everything is public: pull any project, or sign in and push.</p></div></section> | |
| 293 | + <div class="cards" style="grid-template-columns:repeat(auto-fill,minmax(220px,1fr))">${cards}</div>`, { current: '/companies', description: 'Every company on Branchwell, each with its own account and open projects.' }); | |
| 294 | + } | |
| 295 | + | |
| 296 | + async function researchPage(env: Env, P: PFn) { | |
| 297 | + const rows = (await env.DB.prepare("SELECT r.name, o.name AS org, o.domain, r.updated_at, r.created_at FROM repos r JOIN orgs o ON o.handle = r.owner WHERE r.name LIKE '%/research' ORDER BY o.name COLLATE NOCASE").all<{ name: string; org: string; domain: string; updated_at: number; created_at: number }>()).results; | |
| 298 | + const list = `<table class="list"><thead><tr><th>Company</th><th>Clone</th></tr></thead><tbody>${rows.map((r) => `<tr><td><a href="/${esc(r.name)}">${esc(r.org)}</a>${r.domain ? `<br><span class="small muted">${esc(r.domain)}</span>` : ''}</td><td class="m"><code style="word-break:break-all">git clone https://branchwell.ai/${esc(r.name)}.git</code></td></tr>`).join('')}</tbody></table>`; | |
| 299 | + return P('Research', `<section class="hero" style="grid-template-columns:1fr;padding-bottom:20px"><div><span class="eyebrow">Research</span><h1 class="sm">Every company's research</h1> | |
| 300 | + <p class="lede">Each company keeps its research in its own project: the full plan behind it, and every public source summarized in plain words with a link to the original. It is all public domain. Pull it, read it, add to it.</p></div></section>${list}`, | |
| 301 | + { current: '/research', description: 'The research behind every company on Branchwell, one open project each. Public domain.' }); | |
| 302 | + } | |
| 303 | + | |
| 304 | + // ---------------- repository views ---------------- | |
| 305 | + const voteBox = (repo: string, kind: string, target: string, up: number, down: number, mine?: number) => | |
| 306 | + `<div class="votes" data-repo="${esc(repo)}" data-kind="${kind}" data-target="${esc(target)}"><button type="button" data-vote="1" aria-pressed="${mine === 1}" aria-label="Vote up">👍 <span>${up}</span></button><button type="button" data-vote="-1" aria-pressed="${mine === -1}" aria-label="Vote down">👎 <span>${down}</span></button></div>`; | |
| 307 | + const statusTag = (s?: string) => s ? `<span class="tag ${esc(s)}">${s === 'system' ? 'removal' : esc(s)}</span>` : ''; | |
| 308 | + const MIME: Record<string, string> = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', avif: 'image/avif', pdf: 'application/pdf', json: 'application/json; charset=utf-8', mp4: 'video/mp4', webm: 'video/webm', mp3: 'audio/mpeg', zip: 'application/zip' }; | |
| 309 | + | |
| 310 | + async function repoPage(env: Env, req: Request, url: URL, me: Account | null, row: RepoRow, view: string, rest: string, P: PFn): Promise<Response> { | |
| 311 | + const s = stub(env, row.do_name); | |
| 312 | + const ov = await s.overview(); | |
| 313 | + const branchNames = (ov.branches as { name: string; status: string }[]).filter((b) => b.status !== 'removed').map((b) => b.name); | |
| 314 | + // Split "<ref>/<path>" where ref may contain slashes. | |
| 315 | + const split = (x: string) => { | |
| 316 | + const parts = x.split('/').filter((p, i) => p || i === 0); | |
| 317 | + for (let i = parts.length; i > 0; i--) { const ref = parts.slice(0, i).join('/'); if (branchNames.includes(ref)) return { ref, path: parts.slice(i).join('/') }; } | |
| 318 | + return { ref: parts[0] || ov.defaultBranch, path: parts.slice(1).join('/') }; | |
| 319 | + }; | |
| 320 | + const R = esc(row.name); | |
| 321 | + const tabs = (cur: string, ref: string) => `<div class="tabs"><a href="/${R}/tree/${esc(ref)}"${cur === 'files' ? ' aria-current="page"' : ''}>Files</a><a href="/${R}/commits/${esc(ref)}"${cur === 'commits' ? ' aria-current="page"' : ''}>Commits</a><a href="/${R}/branches"${cur === 'branches' ? ' aria-current="page"' : ''}>Branches (${branchNames.length})</a></div>`; | |
| 322 | + const branchPicker = (ref: string, kind: string) => branchNames.length > 1 ? `<form method="get" onsubmit="location.href='/${R}/${kind}/'+this.b.value;return false" style="display:inline-flex;gap:6px"><label class="small muted" for="b">Branch</label><select id="b" name="b" onchange="this.form.onsubmit()" style="font:inherit;border-radius:999px;padding:6px 12px;border:1.5px solid var(--line);background:var(--card);color:var(--fg)">${branchNames.map((b) => `<option${b === ref ? ' selected' : ''}>${esc(b)}</option>`).join('')}</select></form>` : `<span class="tag">${esc(ref)}</span>`; | |
| 323 | + const ownerName = row.name.split('/')[0]; | |
| 324 | + const org = await orgRow(env, ownerName); | |
| 325 | + const head = (title: string) => `<p class="crumbs"><a href="/${esc(ownerName)}">${esc(org?.name || ownerName)}</a> / <a href="/${R}">${esc(row.name.split('/')[1])}</a>${title}</p>`; | |
| 326 | + const cloneBox = `<div class="copy"><code id="clone">git clone https://branchwell.ai/${R}.git</code><button class="btn sm" type="button" data-copy="clone">Copy</button></div>`; | |
| 327 | + | |
| 328 | + if (ov.empty) { | |
| 329 | + return P(row.name, `<section class="hero" style="grid-template-columns:1fr"><div class="prose">${head('')}<span class="eyebrow">Project</span><h1 class="sm">${esc(row.name.split('/')[1])}</h1><p class="lede">${esc(row.description || 'This repository is empty. Push the first commit.')}</p> | |
| 330 | + <pre><code>git clone https://branchwell.ai/${R}.git | |
| 331 | + cd ${esc(row.name.split('/')[1])} | |
| 332 | + echo "# ${R}" > README.md | |
| 333 | + git add README.md | |
| 334 | + git commit -m "First commit" | |
| 335 | + git push -u origin main</code></pre><p><a href="/how-to-contribute">How to contribute</a></p></div></section>`); | |
| 336 | + } | |
| 337 | + | |
| 338 | + if (view === '' || view === 'tree') { | |
| 339 | + const { ref, path } = view === '' ? { ref: ov.defaultBranch, path: '' } : split(rest); | |
| 340 | + const t = await s.listTree(ref, path); | |
| 341 | + if (!t) return P('Not found', `${head('')}<p>That folder isn't on <b>${esc(ref)}</b>. It may have been removed by a vote.</p>`, { noindex: true }).then404(); | |
| 342 | + if (t.kind === 'blob') return Response.redirect(`${SITE}/${row.name}/blob/${ref}/${path}`, 302); | |
| 343 | + const crumbs = path.split('/').filter(Boolean).map((p, i, a) => ` / <a href="/${R}/tree/${esc(ref)}/${esc(a.slice(0, i + 1).join('/'))}">${esc(p)}</a>`).join(''); | |
| 344 | + const rows = t.entries.map((e) => `<tr><td>${e.dir ? '📁' : '📄'} <a href="/${R}/${e.dir ? 'tree' : 'blob'}/${esc(ref)}/${esc((path ? path + '/' : '') + e.name)}">${esc(e.name)}</a></td><td class="r m">${e.dir ? '' : sizeText(e.size)}</td></tr>`).join(''); | |
| 345 | + const readme = t.entries.find((e) => !e.dir && /^readme(\.md|\.markdown|\.txt)?$/i.test(e.name)); | |
| 346 | + let readmeHtml = ''; | |
| 347 | + if (readme) { | |
| 348 | + const b = await s.readBlob(ref, (path ? path + '/' : '') + readme.name); | |
| 349 | + if (b && isText(b.data)) { | |
| 350 | + const dir = path ? path + '/' : ''; | |
| 351 | + const text = new TextDecoder().decode(b.data); | |
| 352 | + readmeHtml = `<div class="md" style="margin-top:22px">${/\.txt$/i.test(readme.name) ? `<pre>${esc(text)}</pre>` : markdown(text, `/${row.name}/blob/${ref}/${dir}`, `/${row.name}/raw/${ref}/${dir}`)}</div>`; | |
| 353 | + } | |
| 354 | + } | |
| 355 | + const top = view === '' ? `<section style="padding:8px 0 22px"><span class="eyebrow"><a href="/${esc(ownerName)}" style="color:inherit">${esc(org?.name || ownerName)}</a> project</span><h1 class="sm" style="margin-bottom:8px">${esc(row.name.split('/')[1])}</h1>${row.description ? `<p class="lede" style="margin-bottom:16px">${esc(row.description)}</p>` : ''}${cloneBox} | |
| 356 | + <p class="small muted" style="margin-top:10px">${(ov.commits as { n: number }).n || 0} commit${(ov.commits as { n: number }).n === 1 ? '' : 's'} pushed here · ${(ov.commits as { open: number }).open || 0} open to votes · ${(ov.commits as { removed: number }).removed || 0} removed by votes${ov.updatedAt ? ' · updated ' + ago(ov.updatedAt) : ''}</p></section>` : head(crumbs); | |
| 357 | + const last = t.last ? `<p class="small muted">Latest: <a href="/${R}/commit/${t.last.sha}">${esc(t.last.subject)}</a> by ${esc(t.last.author)}, ${ago(t.last.time * 1000)}</p>` : ''; | |
| 358 | + const extra = view === '' && row.name === 'branchwell/research' ? C.research() : ''; | |
| 359 | + return P(view === '' ? row.name : `${path || ref} · ${row.name}`, `${top}<div class="bar">${tabs('files', ref)}${branchPicker(ref, 'tree')}</div>${last}<table class="list"><tbody>${rows}</tbody></table>${readmeHtml}${extra}`, | |
| 360 | + { description: row.description || `The ${row.name} repository on Branchwell. Open to pull and to push.`, noindex: view !== '' }); | |
| 361 | + } | |
| 362 | + | |
| 363 | + if (view === 'blob' || view === 'raw') { | |
| 364 | + const { ref, path } = split(rest); | |
| 365 | + const b = await s.readBlob(ref, path); | |
| 366 | + if (!b) return P('Not found', `${head('')}<p>That file isn't on <b>${esc(ref)}</b>. It may have been removed by a vote.</p>`, { noindex: true }).then404(); | |
| 367 | + const ext = (path.split('.').pop() || '').toLowerCase(); | |
| 368 | + if (view === 'raw') { | |
| 369 | + const type = MIME[ext] || (isText(b.data) ? 'text/plain; charset=utf-8' : 'application/octet-stream'); | |
| 370 | + return new Response(b.data, { headers: { 'content-type': type, 'cache-control': 'public, max-age=300', 'content-security-policy': 'sandbox', 'x-content-type-options': 'nosniff', etag: `"${b.sha}"` } }); | |
| 371 | + } | |
| 372 | + const crumbs = path.split('/').map((p, i, a) => i === a.length - 1 ? ` / <b>${esc(p)}</b>` : ` / <a href="/${R}/tree/${esc(ref)}/${esc(a.slice(0, i + 1).join('/'))}">${esc(p)}</a>`).join(''); | |
| 373 | + const raw = `/${R}/raw/${esc(ref)}/${esc(path)}`; | |
| 374 | + let content: string; | |
| 375 | + if (/^(png|jpe?g|gif|webp|avif)$/.test(ext)) content = `<div class="md" style="padding:20px"><img src="${raw}" alt="${esc(path)}"></div>`; | |
| 376 | + else if (!isText(b.data)) content = `<p class="muted">This file isn't text (${sizeText(b.data.length)}). <a href="${raw}">Download it</a>.</p>`; | |
| 377 | + else { | |
| 378 | + const text = new TextDecoder().decode(b.data); | |
| 379 | + const dir = path.includes('/') ? path.slice(0, path.lastIndexOf('/') + 1) : ''; | |
| 380 | + if (/^(md|markdown)$/.test(ext) && url.searchParams.get('plain') === null) content = `<p class="small"><a href="?plain">Show the source</a></p><div class="md">${markdown(text, `/${row.name}/blob/${ref}/${dir}`, `/${row.name}/raw/${ref}/${dir}`)}</div>`; | |
| 381 | + else { const lines = text.replace(/\n$/, '').split('\n'); content = `<div class="src"><table>${lines.slice(0, 20000).map((l, i) => `<tr><td class="n">${i + 1}</td><td>${esc(l) || ' '}</td></tr>`).join('')}</table></div>`; } | |
| 382 | + } | |
| 383 | + return P(`${path} · ${row.name}`, `${head(crumbs)}<div class="bar">${tabs('files', ref)}<span><a class="btn ghost sm" href="${raw}">Raw</a> <span class="small muted">${sizeText(b.data.length)} on ${esc(ref)}</span></span></div>${content}`, { noindex: true }); | |
| 384 | + } | |
| 385 | + | |
| 386 | + if (view === 'commits') { | |
| 387 | + const { ref } = split(rest || ov.defaultBranch); | |
| 388 | + const pageN = Math.max(0, parseInt(url.searchParams.get('page') || '0', 10) || 0); | |
| 389 | + const lg = (await s.log(ref, pageN * 30, 30)) as { commits: unknown[]; more: boolean } | null; | |
| 390 | + if (!lg) return P('Not found', `${head('')}<p>There's no branch called <b>${esc(ref)}</b>. It may have been removed by a vote.</p>`, { noindex: true }).then404(); | |
| 391 | + type CRow = { sha: string; subject: string; author: string; time: number; meta: { status: string; up: number; down: number; pusher: string; pushed_at: number; note: string } | null }; | |
| 392 | + const commits = lg.commits as unknown as CRow[]; | |
| 393 | + const mine: Record<string, number> = me ? await s.myVotes(me.id, 'commit', commits.filter((c) => c.meta?.status === 'new').map((c) => c.sha)) : {}; | |
| 394 | + const rows = commits.map((c) => { | |
| 395 | + const m = c.meta; | |
| 396 | + const who = m && m.pusher && m.pusher !== 'branchwell' ? `pushed by ${esc(m.pusher)}` : esc(c.author); | |
| 397 | + const v = m && m.status === 'new' ? voteBox(row.name, 'commit', c.sha, m.up, m.down, mine[c.sha]) : m && (m.status === 'kept' || m.status === 'removed') ? `<span class="small muted">👍 ${m.up} 👎 ${m.down}</span>` : ''; | |
| 398 | + return `<tr><td><a href="/${R}/commit/${c.sha}">${esc(c.subject || '(no message)')}</a> ${statusTag(m?.status)}<br><span class="small muted"><code>${c.sha.slice(0, 8)}</code> ${who}, ${ago(c.time * 1000)}</span></td><td class="r">${v}</td></tr>`; | |
| 399 | + }).join(''); | |
| 400 | + const nav = `<p class="btns">${pageN > 0 ? `<a class="btn ghost sm" href="?page=${pageN - 1}">Newer</a>` : ''}${lg.more ? `<a class="btn ghost sm" href="?page=${pageN + 1}">Older</a>` : ''}</p>`; | |
| 401 | + return P(`Commits on ${ref} · ${row.name}`, `${head(' / commits')}<div class="bar">${tabs('commits', ref)}${branchPicker(ref, 'commits')}</div> | |
| 402 | + <p class="small muted">New commits are open to votes. 3 down takes one back out; 3 up keeps it for good. <a href="/rules">How votes work</a></p><p id="vote-msg" role="status" aria-live="polite"></p> | |
| 403 | + <table class="list"><tbody>${rows}</tbody></table>${nav}`, { noindex: true }); | |
| 404 | + } | |
| 405 | + | |
| 406 | + if (view === 'commit') { | |
| 407 | + const info = await s.commitInfo(rest); | |
| 408 | + if (!info) return P('Not found', `${head('')}<p>We couldn't find that commit.</p>`, { noindex: true }).then404(); | |
| 409 | + const m = info.meta as { status: string; up: number; down: number; pusher: string; pushed_at: number; note: string; branch: string } | null; | |
| 410 | + const mine = me && m?.status === 'new' ? (await s.myVotes(me.id, 'commit', [info.sha]))[info.sha] : undefined; | |
| 411 | + const voters = (info.voters as { handle: string; value: number }[]); | |
| 412 | + const c = info.commit; | |
| 413 | + const msgBody = c.message.split('\n').slice(1).join('\n').trim(); | |
| 414 | + const diffs = (info.diffs as { path: string; status: string; before: string | null; after: string | null }[]).map((d) => | |
| 415 | + `<div class="file"><h3>${esc(d.path)} <span class="tag">${d.status}</span></h3>${d.before === null || d.after === null ? '<p class="muted small">Not a text file.</p>' : diffHtml(d.before, d.after)}</div>`).join(''); | |
| 416 | + const more = info.files.length > info.diffs.length ? `<p class="muted">${info.files.length - info.diffs.length} more files changed.</p>` : ''; | |
| 417 | + const noteLine = m?.status === 'removed' ? `<div class="notice">This commit was voted down and taken back out of <b>${esc(m.branch)}</b>: ${esc(m.note || '')}.</div>` | |
| 418 | + : m?.status === 'system' ? `<div class="notice">Branchwell made this commit to take <a href="/${R}/commit/${esc(m.note)}">${esc((m.note || '').slice(0, 8))}</a> back out after 3 votes down.</div>` : ''; | |
| 419 | + return P(`${c.message.split('\n')[0]} · ${row.name}`, `${head(` / <a href="/${R}/commits/${esc(m?.branch || ov.defaultBranch)}">commits</a> / <code>${info.sha.slice(0, 8)}</code>`)} | |
| 420 | + <h1 class="xs">${esc(c.message.split('\n')[0] || '(no message)')} ${statusTag(m?.status)}</h1>${msgBody ? `<pre style="white-space:pre-wrap">${esc(msgBody)}</pre>` : ''} | |
| 421 | + <p class="small muted">${m && m.pusher !== 'branchwell' ? `Pushed by <b>${esc(m.pusher)}</b> to ${esc(m.branch)} ${ago(m.pushed_at)} · ` : ''}written by ${esc(c.author.replace(/\s*<.*$/, ''))} · <code>${info.sha}</code>${c.parents.length ? ` · parent <a href="/${R}/commit/${c.parents[0]}"><code>${c.parents[0].slice(0, 8)}</code></a>` : ''}</p> | |
| 422 | + ${noteLine}${m?.status === 'new' ? `<div style="margin:14px 0">${voteBox(row.name, 'commit', info.sha, m.up, m.down, mine)} <span class="vote-msg small muted" role="status" aria-live="polite"></span></div>` : ''} | |
| 423 | + ${voters.length ? `<p class="small muted">Votes: ${voters.map((v) => `${esc(v.handle)} ${v.value > 0 ? '👍' : '👎'}`).join(', ')}</p>` : ''} | |
| 424 | + <h2 style="font-size:24px;margin-top:24px">${info.files.length} file${info.files.length === 1 ? '' : 's'} changed</h2>${diffs}${more} | |
| 425 | + <p><a class="btn ghost sm" href="/${R}/tree/${info.sha}">Browse files at this commit</a></p>`, { noindex: true }); | |
| 426 | + } | |
| 427 | + | |
| 428 | + if (view === 'branches') { | |
| 429 | + type BRow = { name: string; status: string; up: number; down: number; created_by: string; created_at: number; removed_at: number; last_sha: string }; | |
| 430 | + const all = ov.branches as unknown as BRow[]; | |
| 431 | + const mine: Record<string, number> = me ? await s.myVotes(me.id, 'branch', all.filter((b) => b.status === 'new').map((b) => b.name)) : {}; | |
| 432 | + const rows = all.map((b) => `<tr><td>${b.status === 'removed' ? `<s>${esc(b.name)}</s>` : `<a href="/${R}/tree/${esc(b.name)}">${esc(b.name)}</a>`} ${b.name === ov.defaultBranch ? '<span class="tag">main branch</span>' : statusTag(b.status)}<br> | |
| 433 | + <span class="small muted">opened by ${esc(b.created_by || 'unknown')} ${ago(b.created_at)}${b.removed_at ? ', removed ' + ago(b.removed_at) : ''}</span></td> | |
| 434 | + <td class="r">${b.status === 'new' && b.name !== ov.defaultBranch ? voteBox(row.name, 'branch', b.name, b.up, b.down, mine[b.name]) : b.status === 'removed' || b.name === ov.defaultBranch ? '' : `<span class="small muted">👍 ${b.up} 👎 ${b.down}</span>`}</td></tr>`).join(''); | |
| 435 | + return P(`Branches · ${row.name}`, `${head(' / branches')}<div class="bar">${tabs('branches', ov.defaultBranch)}</div> | |
| 436 | + <p class="small muted">Anyone can open a branch: <code>git push origin HEAD:your-idea</code>. 3 votes down removes a branch; 3 up keeps it. The main branch always stays.</p><p id="vote-msg" role="status" aria-live="polite"></p> | |
| 437 | + <table class="list"><tbody>${rows}</tbody></table>`, { noindex: true }); | |
| 438 | + } | |
| 439 | + return new Response('Not found', { status: 404 }); | |
| 440 | + } | |
| 441 | + | |
| 442 | + async function sitemap(env: Env) { | |
| 443 | + const rows = (await env.DB.prepare('SELECT name FROM repos ORDER BY name LIMIT 5000').all<{ name: string }>()).results; | |
| 444 | + const orgs = (await env.DB.prepare('SELECT handle FROM orgs ORDER BY handle').all<{ handle: string }>()).results; | |
| 445 | + const urls = ['/', '/companies', '/research', '/repos', '/how-to-pull', '/how-to-contribute', '/rules', '/features', '/careers', '/privacy', ...orgs.map((o) => '/' + o.handle), ...rows.map((r) => '/' + r.name)]; | |
| 446 | + return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls.map((u) => `<url><loc>${SITE}${u}</loc></url>`).join('')}</urlset>`, { headers: { 'content-type': 'application/xml' } }); | |
| 447 | + } | |
| 448 | + | |
| 449 | + const ORG_LD = `<script type="application/ld+json">${JSON.stringify({ '@context': 'https://schema.org', '@type': 'Organization', name: 'Branchwell', url: SITE, description: 'Open Git hosting where anyone can pull, anyone signed in can push, and votes decide what stays.' })}</script>`; | |
| 450 | + const LLMS = `# Branchwell | |
| 451 | + | |
| 452 | + > Open Git hosting. Anyone can pull. Anyone signed in (passkeys only) can push straight to a branch. No pull requests, no reviews. 3 votes down removes a commit or branch; 3 votes up keeps it for good. | |
| 453 | + | |
| 454 | + - Clone: git clone https://branchwell.ai/<owner>/<project>.git | |
| 455 | + - Companies (each has its own account and projects): ${SITE}/companies | |
| 456 | + - Research, one project per company (public domain sources): ${SITE}/research | |
| 457 | + - How to pull: ${SITE}/how-to-pull | |
| 458 | + - How to contribute: ${SITE}/how-to-contribute | |
| 459 | + - How votes work: ${SITE}/rules | |
| 460 | + - New-feature votes for apps: ${SITE}/features | |
| 461 | + - Source code: ${SITE}/branchwell/source | |
| 462 | + `; | |
| 463 | + void SECURITY; |
src/repo.ts added
| 1 | + // One Durable Object per repository. It holds every Git object, the branches, the commit records | |
| 2 | + // and the votes in its own SQLite database, so a push, a vote and a removal never race each other. | |
| 3 | + import { DurableObject } from 'cloudflare:workers'; | |
| 4 | + import { | |
| 5 | + ZERO, FLUSH, te, td, pkt, concat, readPkts, sideband, objectId, parseTree, writeTree, parseCommit, personName, | |
| 6 | + readPack, packHeader, packObjHeader, deflate, inflate, TYPE_NUM, NUM_TYPE, type ObjType, type RawObj, type TreeEntry, | |
| 7 | + } from './git/core'; | |
| 8 | + import { Sha1 } from './git/sha1'; | |
| 9 | + import { checkBlob } from './checks'; | |
| 10 | + | |
| 11 | + const PART = 1_000_000; // bytes per stored row (SQLite rows cap at 2 MB) | |
| 12 | + export const VOTES_TO_DECIDE = 3; | |
| 13 | + const BRANCH_RE = /^(?!\/|.*\/\/|.*\.\.|.*\.lock$|.*[\s~^:?*[\\\x00-\x1f\x7f]|.*@\{|\.|.*\/\.)[A-Za-z0-9._\/-]{1,100}(?<!\/|\.)$/; | |
| 14 | + | |
| 15 | + export interface Voter { id: string; handle: string; canVote: boolean } | |
| 16 | + export interface Pusher { id: string; handle: string } | |
| 17 | + | |
| 18 | + export class RepoDO extends DurableObject { | |
| 19 | + sql: SqlStorage; | |
| 20 | + constructor(ctx: DurableObjectState, env: unknown) { | |
| 21 | + super(ctx, env as never); | |
| 22 | + this.sql = ctx.storage.sql; | |
| 23 | + this.sql.exec(` | |
| 24 | + CREATE TABLE IF NOT EXISTS meta (k TEXT PRIMARY KEY, v TEXT); | |
| 25 | + CREATE TABLE IF NOT EXISTS objects (sha TEXT PRIMARY KEY, type INTEGER NOT NULL, size INTEGER NOT NULL, parts INTEGER NOT NULL, z BLOB); | |
| 26 | + CREATE TABLE IF NOT EXISTS object_parts (sha TEXT NOT NULL, idx INTEGER NOT NULL, z BLOB NOT NULL, PRIMARY KEY (sha, idx)); | |
| 27 | + CREATE TABLE IF NOT EXISTS refs (name TEXT PRIMARY KEY, sha TEXT NOT NULL); | |
| 28 | + CREATE TABLE IF NOT EXISTS branches (name TEXT PRIMARY KEY, status TEXT NOT NULL, up INTEGER NOT NULL DEFAULT 0, down INTEGER NOT NULL DEFAULT 0, | |
| 29 | + created_by TEXT, created_at INTEGER NOT NULL, removed_at INTEGER, last_sha TEXT); | |
| 30 | + CREATE TABLE IF NOT EXISTS commits (sha TEXT PRIMARY KEY, branch TEXT NOT NULL, status TEXT NOT NULL, up INTEGER NOT NULL DEFAULT 0, down INTEGER NOT NULL DEFAULT 0, | |
| 31 | + pusher TEXT, pushed_at INTEGER NOT NULL, subject TEXT, author TEXT, note TEXT); | |
| 32 | + CREATE INDEX IF NOT EXISTS commits_branch ON commits (branch, pushed_at); | |
| 33 | + CREATE TABLE IF NOT EXISTS votes (kind TEXT NOT NULL, target TEXT NOT NULL, account TEXT NOT NULL, handle TEXT, value INTEGER NOT NULL, at INTEGER NOT NULL, | |
| 34 | + PRIMARY KEY (kind, target, account)); | |
| 35 | + `); | |
| 36 | + } | |
| 37 | + | |
| 38 | + // ---------------- storage ---------------- | |
| 39 | + meta(k: string): string | null { const r = this.sql.exec('SELECT v FROM meta WHERE k = ?', k).toArray()[0]; return r ? (r.v as string) : null; } | |
| 40 | + setMeta(k: string, v: string) { this.sql.exec('INSERT INTO meta (k, v) VALUES (?, ?) ON CONFLICT (k) DO UPDATE SET v = excluded.v', k, v); } | |
| 41 | + defaultBranch() { return this.meta('default_branch') || 'main'; } | |
| 42 | + | |
| 43 | + has(sha: string) { return this.sql.exec('SELECT 1 FROM objects WHERE sha = ?', sha).toArray().length > 0; } | |
| 44 | + zOf(sha: string): { type: number; size: number; z: Uint8Array } | null { | |
| 45 | + const r = this.sql.exec('SELECT type, size, parts, z FROM objects WHERE sha = ?', sha).toArray()[0]; | |
| 46 | + if (!r) return null; | |
| 47 | + let z: Uint8Array; | |
| 48 | + if ((r.parts as number) === 0) z = new Uint8Array(r.z as ArrayBuffer); | |
| 49 | + else z = concat(this.sql.exec('SELECT z FROM object_parts WHERE sha = ? ORDER BY idx', sha).toArray().map((p) => new Uint8Array(p.z as ArrayBuffer))); | |
| 50 | + return { type: r.type as number, size: r.size as number, z }; | |
| 51 | + } | |
| 52 | + get(sha: string, overlay?: Map<string, RawObj>): RawObj | null { | |
| 53 | + const o = overlay?.get(sha); if (o) return o; | |
| 54 | + const z = this.zOf(sha); if (!z) return null; | |
| 55 | + return { type: NUM_TYPE[z.type], data: inflate(z.z), sha }; | |
| 56 | + } | |
| 57 | + put(o: RawObj) { | |
| 58 | + if (this.has(o.sha)) return; | |
| 59 | + const z = deflate(o.data); | |
| 60 | + if (z.length <= PART) { this.sql.exec('INSERT INTO objects (sha, type, size, parts, z) VALUES (?, ?, ?, 0, ?)', o.sha, TYPE_NUM[o.type], o.data.length, z); return; } | |
| 61 | + const n = Math.ceil(z.length / PART); | |
| 62 | + for (let i = 0; i < n; i++) this.sql.exec('INSERT INTO object_parts (sha, idx, z) VALUES (?, ?, ?)', o.sha, i, z.subarray(i * PART, (i + 1) * PART)); | |
| 63 | + this.sql.exec('INSERT INTO objects (sha, type, size, parts, z) VALUES (?, ?, ?, ?, NULL)', o.sha, TYPE_NUM[o.type], o.data.length, n); | |
| 64 | + } | |
| 65 | + make(type: ObjType, data: Uint8Array): string { const sha = objectId(type, data); this.put({ type, data, sha }); return sha; } | |
| 66 | + | |
| 67 | + refs(): Map<string, string> { return new Map(this.sql.exec('SELECT name, sha FROM refs ORDER BY name').toArray().map((r) => [r.name as string, r.sha as string])); } | |
| 68 | + setRef(branch: string, sha: string) { this.sql.exec('INSERT INTO refs (name, sha) VALUES (?, ?) ON CONFLICT (name) DO UPDATE SET sha = excluded.sha', 'refs/heads/' + branch, sha); this.sql.exec('UPDATE branches SET last_sha = ? WHERE name = ?', sha, branch); } | |
| 69 | + | |
| 70 | + commit(sha: string, overlay?: Map<string, RawObj>) { const o = this.get(sha, overlay); if (!o || o.type !== 'commit') throw new Error('missing commit ' + sha); return parseCommit(o.data); } | |
| 71 | + tree(sha: string, overlay?: Map<string, RawObj>): TreeEntry[] { const o = this.get(sha, overlay); if (!o || o.type !== 'tree') throw new Error('missing tree ' + sha); return parseTree(o.data); } | |
| 72 | + | |
| 73 | + /** Every commit reachable from the given tips. */ | |
| 74 | + reachable(tips: string[], overlay?: Map<string, RawObj>, stop?: Set<string>, limit = 100000): Set<string> { | |
| 75 | + const seen = new Set<string>(); const q = tips.filter((t) => t && t !== ZERO); | |
| 76 | + while (q.length && seen.size < limit) { | |
| 77 | + const s = q.pop()!; if (seen.has(s) || stop?.has(s)) continue; seen.add(s); | |
| 78 | + for (const p of this.commit(s, overlay).parents) if (!seen.has(p)) q.push(p); | |
| 79 | + } | |
| 80 | + return seen; | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** path -> {mode, sha} for every file under a tree (submodules kept as entries). */ | |
| 84 | + flatten(treeSha: string | null, overlay?: Map<string, RawObj>, prefix = '', out = new Map<string, { mode: string; sha: string }>()) { | |
| 85 | + if (!treeSha) return out; | |
| 86 | + for (const e of this.tree(treeSha, overlay)) { | |
| 87 | + if (e.mode === '40000') this.flatten(e.sha, overlay, prefix + e.name + '/', out); | |
| 88 | + else out.set(prefix + e.name, { mode: e.mode, sha: e.sha }); | |
| 89 | + } | |
| 90 | + return out; | |
| 91 | + } | |
| 92 | + buildTree(flat: Map<string, { mode: string; sha: string }>): string { | |
| 93 | + type Dir = { files: TreeEntry[]; dirs: Map<string, Dir> }; | |
| 94 | + const root: Dir = { files: [], dirs: new Map() }; | |
| 95 | + for (const [path, v] of flat) { | |
| 96 | + const parts = path.split('/'); let d = root; | |
| 97 | + for (const p of parts.slice(0, -1)) { if (!d.dirs.has(p)) d.dirs.set(p, { files: [], dirs: new Map() }); d = d.dirs.get(p)!; } | |
| 98 | + d.files.push({ mode: v.mode, name: parts[parts.length - 1], sha: v.sha }); | |
| 99 | + } | |
| 100 | + const write = (d: Dir): string => this.make('tree', writeTree([...d.files, ...[...d.dirs].map(([name, sub]) => ({ mode: '40000', name, sha: write(sub) }))])); | |
| 101 | + return write(root); | |
| 102 | + } | |
| 103 | + changes(sha: string, overlay?: Map<string, RawObj>) { | |
| 104 | + const c = this.commit(sha, overlay); | |
| 105 | + const after = this.flatten(c.tree, overlay); | |
| 106 | + const before = c.parents[0] ? this.flatten(this.commit(c.parents[0], overlay).tree, overlay) : new Map(); | |
| 107 | + const out: { path: string; status: 'added' | 'changed' | 'deleted'; before?: { mode: string; sha: string }; after?: { mode: string; sha: string } }[] = []; | |
| 108 | + for (const [p, v] of after) { const b = before.get(p); if (!b) out.push({ path: p, status: 'added', after: v }); else if (b.sha !== v.sha || b.mode !== v.mode) out.push({ path: p, status: 'changed', before: b, after: v }); } | |
| 109 | + for (const [p, v] of before) if (!after.has(p)) out.push({ path: p, status: 'deleted', before: v }); | |
| 110 | + return { commit: c, files: out.sort((a, b) => (a.path < b.path ? -1 : 1)) }; | |
| 111 | + } | |
| 112 | + | |
| 113 | + // ---------------- Git smart HTTP ---------------- | |
| 114 | + async fetch(req: Request): Promise<Response> { | |
| 115 | + const url = new URL(req.url); | |
| 116 | + const rn = req.headers.get('x-repo'); if (rn && !this.meta('name')) this.setMeta('name', rn); | |
| 117 | + try { | |
| 118 | + if (url.pathname === '/info/refs') return this.advertise(url.searchParams.get('service') || ''); | |
| 119 | + if (url.pathname === '/git-upload-pack') return this.uploadPack(new Uint8Array(await req.arrayBuffer())); | |
| 120 | + if (url.pathname === '/git-receive-pack') { | |
| 121 | + const pusher = JSON.parse(req.headers.get('x-pusher') || 'null') as Pusher | null; | |
| 122 | + if (!pusher) return new Response('sign in to push', { status: 401 }); | |
| 123 | + return this.receivePack(new Uint8Array(await req.arrayBuffer()), pusher); | |
| 124 | + } | |
| 125 | + } catch (e) { | |
| 126 | + return new Response('error: ' + (e as Error).message, { status: 500 }); | |
| 127 | + } | |
| 128 | + return new Response('not found', { status: 404 }); | |
| 129 | + } | |
| 130 | + | |
| 131 | + advertise(service: string): Response { | |
| 132 | + if (service !== 'git-upload-pack' && service !== 'git-receive-pack') return new Response('dumb HTTP is not supported; use git 1.7 or newer', { status: 403 }); | |
| 133 | + const refs = this.refs(); | |
| 134 | + const def = this.defaultBranch(); | |
| 135 | + const caps = service === 'git-upload-pack' | |
| 136 | + ? `side-band-64k no-progress symref=HEAD:refs/heads/${def} agent=branchwell/1` | |
| 137 | + : 'report-status side-band-64k quiet ofs-delta agent=branchwell/1'; | |
| 138 | + const lines: Uint8Array[] = [pkt(`# service=${service}\n`), FLUSH]; | |
| 139 | + const list: [string, string][] = []; | |
| 140 | + const head = refs.get('refs/heads/' + def); | |
| 141 | + if (head && service === 'git-upload-pack') list.push(['HEAD', head]); | |
| 142 | + for (const [n, s] of refs) list.push([n, s]); | |
| 143 | + if (!list.length) lines.push(pkt(`${ZERO} capabilities^{}\0${caps}\n`)); | |
| 144 | + list.forEach(([n, s], i) => lines.push(pkt(i === 0 ? `${s} ${n}\0${caps}\n` : `${s} ${n}\n`))); | |
| 145 | + lines.push(FLUSH); | |
| 146 | + return new Response(concat(lines), { headers: { 'content-type': `application/x-${service}-advertisement`, 'cache-control': 'no-cache' } }); | |
| 147 | + } | |
| 148 | + | |
| 149 | + uploadPack(body: Uint8Array): Response { | |
| 150 | + const { lines } = readPkts(body); | |
| 151 | + const wants: string[] = []; const haves: string[] = []; let done = false; let caps = ''; | |
| 152 | + for (const l of lines) { | |
| 153 | + if (!l) continue; | |
| 154 | + const s = td.decode(l).replace(/\n$/, ''); | |
| 155 | + if (s.startsWith('want ')) { wants.push(s.slice(5, 45)); if (!caps) caps = s.slice(46); } | |
| 156 | + else if (s.startsWith('have ')) haves.push(s.slice(5, 45)); | |
| 157 | + else if (s === 'done') done = true; | |
| 158 | + } | |
| 159 | + const common = haves.filter((h) => this.has(h)); | |
| 160 | + const ack = pkt(common.length ? `ACK ${common[0]}\n` : 'NAK\n'); | |
| 161 | + const type = 'application/x-git-upload-pack-result'; | |
| 162 | + if (!done && !wants.length) return new Response(ack, { headers: { 'content-type': type } }); | |
| 163 | + if (!done) return new Response(ack, { headers: { 'content-type': type } }); | |
| 164 | + for (const w of wants) if (!this.has(w)) return new Response(concat([pkt(`ERR upload-pack: not our ref ${w}\n`)]), { headers: { 'content-type': type } }); | |
| 165 | + | |
| 166 | + // Objects the client already has. | |
| 167 | + const have = new Set<string>(); | |
| 168 | + const commitsHave = this.reachable(common); | |
| 169 | + const addTree = (t: string, set: Set<string>) => { if (set.has(t)) return; set.add(t); for (const e of this.tree(t)) { if (e.mode === '40000') addTree(e.sha, set); else if (e.mode !== '160000') set.add(e.sha); } }; | |
| 170 | + for (const c of commitsHave) { have.add(c); addTree(this.commit(c).tree, have); } | |
| 171 | + // Objects to send, in commit, tree, blob order. | |
| 172 | + const send: string[] = []; const seen = new Set<string>(); | |
| 173 | + const q = [...wants]; | |
| 174 | + while (q.length) { | |
| 175 | + const s = q.pop()!; if (seen.has(s) || have.has(s)) continue; seen.add(s); | |
| 176 | + const z = this.sql.exec('SELECT type FROM objects WHERE sha = ?', s).toArray()[0]; | |
| 177 | + if (!z) continue; | |
| 178 | + send.push(s); | |
| 179 | + if (z.type === 1) { const c = this.commit(s); q.push(...c.parents); this.collectTree(c.tree, have, seen, send); } | |
| 180 | + else if (z.type === 4) { const t = td.decode(this.get(s)!.data).match(/^object ([0-9a-f]{40})/m); if (t) q.push(t[1]); } | |
| 181 | + } | |
| 182 | + const band = /\bside-band-64k\b/.test(caps); | |
| 183 | + const { readable, writable } = new TransformStream<Uint8Array, Uint8Array>(); | |
| 184 | + const w = writable.getWriter(); | |
| 185 | + const self = this; | |
| 186 | + (async () => { | |
| 187 | + const out = async (d: Uint8Array) => { if (band) { for (const p of sideband(1, d)) await w.write(p); } else await w.write(d); }; | |
| 188 | + try { | |
| 189 | + await w.write(ack); | |
| 190 | + const sha = new Sha1(); | |
| 191 | + const emit = async (d: Uint8Array) => { sha.update(d); await out(d); }; | |
| 192 | + await emit(packHeader(send.length)); | |
| 193 | + let batch: Uint8Array[] = []; let n = 0; | |
| 194 | + for (const s of send) { | |
| 195 | + const z = self.zOf(s)!; | |
| 196 | + batch.push(packObjHeader(z.type, z.size), z.z); n += z.z.length; | |
| 197 | + if (n > 256 * 1024) { await emit(concat(batch)); batch = []; n = 0; } | |
| 198 | + } | |
| 199 | + if (batch.length) await emit(concat(batch)); | |
| 200 | + await out(sha.digest()); | |
| 201 | + if (band) await w.write(FLUSH); | |
| 202 | + await w.close(); | |
| 203 | + } catch (e) { await w.abort(e); } | |
| 204 | + })(); | |
| 205 | + return new Response(readable, { headers: { 'content-type': type, 'cache-control': 'no-cache' } }); | |
| 206 | + } | |
| 207 | + collectTree(t: string, have: Set<string>, seen: Set<string>, send: string[]) { | |
| 208 | + if (seen.has(t) || have.has(t)) return; seen.add(t); send.push(t); | |
| 209 | + for (const e of this.tree(t)) { | |
| 210 | + if (e.mode === '40000') this.collectTree(e.sha, have, seen, send); | |
| 211 | + else if (e.mode !== '160000' && !seen.has(e.sha) && !have.has(e.sha)) { seen.add(e.sha); send.push(e.sha); } | |
| 212 | + } | |
| 213 | + } | |
| 214 | + | |
| 215 | + async receivePack(body: Uint8Array, pusher: Pusher): Promise<Response> { | |
| 216 | + const { lines, end } = readPkts(body, 0, true); | |
| 217 | + const cmds: { old: string; neu: string; ref: string }[] = []; let caps = ''; | |
| 218 | + for (const l of lines) { | |
| 219 | + if (!l) break; | |
| 220 | + let s = td.decode(l).replace(/\n$/, ''); | |
| 221 | + const nul = s.indexOf('\0'); if (nul >= 0) { caps = s.slice(nul + 1); s = s.slice(0, nul); } | |
| 222 | + const [old, neu, ref] = s.split(' '); | |
| 223 | + cmds.push({ old, neu, ref }); | |
| 224 | + } | |
| 225 | + const band = /\bside-band-64k\b/.test(caps); | |
| 226 | + const progress: string[] = []; | |
| 227 | + const results = new Map<string, string>(); // ref -> '' (ok) or reason | |
| 228 | + let unpack = 'ok'; | |
| 229 | + const overlay = new Map<string, RawObj>(); | |
| 230 | + try { | |
| 231 | + if (end < body.length && cmds.some((c) => c.neu !== ZERO)) { | |
| 232 | + const objs = await readPack(body.subarray(end), async (sha) => this.get(sha)); | |
| 233 | + for (const o of objs) overlay.set(o.sha, o); | |
| 234 | + } | |
| 235 | + } catch (e) { unpack = (e as Error).message; } | |
| 236 | + | |
| 237 | + const refsNow = this.refs(); | |
| 238 | + const known = unpack === 'ok' ? this.reachable([...refsNow.values()]) : new Set<string>(); | |
| 239 | + const newCommits = new Map<string, string[]>(); // ref -> new commit shas (oldest first) | |
| 240 | + if (unpack === 'ok') for (const c of cmds) { | |
| 241 | + const branch = c.ref.replace(/^refs\/heads\//, ''); | |
| 242 | + if (!c.ref.startsWith('refs/heads/') || !BRANCH_RE.test(branch)) { results.set(c.ref, 'only branches (refs/heads/...) with plain names can be pushed'); continue; } | |
| 243 | + if (c.neu === ZERO) { results.set(c.ref, 'branches are removed by votes, not by push'); continue; } | |
| 244 | + const cur = refsNow.get(c.ref) || ZERO; | |
| 245 | + if (cur !== c.old) { results.set(c.ref, 'fetch first: the branch moved. Run git pull, then push again'); continue; } | |
| 246 | + const removed = this.sql.exec("SELECT 1 FROM branches WHERE name = ? AND status = 'removed'", branch).toArray().length; | |
| 247 | + if (removed && cur === ZERO) { results.set(c.ref, 'this branch name was voted out. Push under a new name'); continue; } | |
| 248 | + let mine: Set<string>; | |
| 249 | + try { mine = this.reachable([c.neu], overlay, known); } catch (e) { results.set(c.ref, 'missing objects: ' + (e as Error).message); continue; } | |
| 250 | + if (cur !== ZERO && !mine.has(cur) && !this.reachable([c.neu], overlay).has(cur)) { results.set(c.ref, 'not a fast-forward. Run git pull, then push again (history is never rewritten here)'); continue; } | |
| 251 | + if (mine.size > 2000) { results.set(c.ref, 'too many new commits in one push (limit 2000)'); continue; } | |
| 252 | + // Checks ("tests"): every changed file in every new commit. | |
| 253 | + const problems: string[] = []; | |
| 254 | + const checked = new Set<string>(); | |
| 255 | + for (const sha of mine) { | |
| 256 | + for (const f of this.changes(sha, overlay).files) { | |
| 257 | + if (!f.after || f.after.mode === '160000' || checked.has(f.after.sha + f.path)) continue; | |
| 258 | + checked.add(f.after.sha + f.path); | |
| 259 | + const blob = this.get(f.after.sha, overlay); | |
| 260 | + const why = blob ? checkBlob(f.path, blob.data) : 'missing file data'; | |
| 261 | + if (why) problems.push(`${f.path}: ${why}`); | |
| 262 | + if (problems.length >= 5) break; | |
| 263 | + } | |
| 264 | + if (problems.length >= 5) break; | |
| 265 | + } | |
| 266 | + if (problems.length) { results.set(c.ref, 'checks failed: ' + problems.join('; ')); continue; } | |
| 267 | + const order = [...mine].map((s) => ({ s, t: this.commit(s, overlay).time })).sort((a, b) => a.t - b.t).map((x) => x.s); | |
| 268 | + newCommits.set(c.ref, order); | |
| 269 | + results.set(c.ref, ''); | |
| 270 | + } | |
| 271 | + | |
| 272 | + const okRefs = cmds.filter((c) => results.get(c.ref) === ''); | |
| 273 | + if (okRefs.length) { | |
| 274 | + for (const o of overlay.values()) this.put(o); | |
| 275 | + const now = Date.now(); | |
| 276 | + for (const c of okRefs) { | |
| 277 | + const branch = c.ref.replace(/^refs\/heads\//, ''); | |
| 278 | + const first = !this.refs().size; | |
| 279 | + if (first) this.setMeta('default_branch', branch); | |
| 280 | + const isDefault = branch === this.defaultBranch(); | |
| 281 | + this.sql.exec(`INSERT INTO branches (name, status, created_by, created_at) VALUES (?, ?, ?, ?) ON CONFLICT (name) DO NOTHING`, branch, isDefault ? 'kept' : 'new', pusher.handle, now); | |
| 282 | + this.setRef(branch, c.neu); | |
| 283 | + const list = newCommits.get(c.ref) || []; | |
| 284 | + for (const s of list) { | |
| 285 | + const cm = this.commit(s); | |
| 286 | + this.sql.exec(`INSERT INTO commits (sha, branch, status, pusher, pushed_at, subject, author) VALUES (?, ?, 'new', ?, ?, ?, ?) ON CONFLICT (sha) DO NOTHING`, | |
| 287 | + s, branch, pusher.handle, now, cm.message.split('\n')[0].slice(0, 200), personName(cm.author)); | |
| 288 | + } | |
| 289 | + const repo = this.meta('name') || ''; | |
| 290 | + progress.push(`Branchwell: ${branch} updated${list.length ? ` with ${list.length} new commit${list.length === 1 ? '' : 's'}` : ''}. Vote at https://branchwell.ai/${repo}/commits/${encodeURIComponent(branch)}\n`); | |
| 291 | + } | |
| 292 | + this.setMeta('updated_at', String(now)); | |
| 293 | + } | |
| 294 | + for (const c of cmds) { const r = results.get(c.ref); if (r) progress.push(`Branchwell: ${c.ref.replace('refs/heads/', '')} not updated: ${r}\n`); } | |
| 295 | + | |
| 296 | + const report = [pkt(`unpack ${unpack === 'ok' ? 'ok' : unpack.replace(/\n/g, ' ')}\n`)]; | |
| 297 | + for (const c of cmds) { const r = results.get(c.ref); report.push(pkt(r === '' ? `ok ${c.ref}\n` : `ng ${c.ref} ${(r || unpack).replace(/\n/g, ' ')}\n`)); } | |
| 298 | + report.push(FLUSH); | |
| 299 | + const outParts: Uint8Array[] = []; | |
| 300 | + if (band) { | |
| 301 | + for (const p of progress) outParts.push(...sideband(2, te.encode(p))); | |
| 302 | + outParts.push(...sideband(1, concat(report))); | |
| 303 | + outParts.push(FLUSH); | |
| 304 | + } else outParts.push(...report); | |
| 305 | + return new Response(concat(outParts), { headers: { 'content-type': 'application/x-git-receive-pack-result', 'cache-control': 'no-cache' } }); | |
| 306 | + } | |
| 307 | + | |
| 308 | + // ---------------- votes ---------------- | |
| 309 | + async vote(kind: 'commit' | 'branch', target: string, voter: Voter, value: number): Promise<{ ok: boolean; message: string; status?: string; up?: number; down?: number }> { | |
| 310 | + if (!voter.canVote) return { ok: false, message: 'New accounts can vote 24 hours after they are made. This keeps votes fair.' }; | |
| 311 | + value = value > 0 ? 1 : value < 0 ? -1 : 0; | |
| 312 | + const table = kind === 'commit' ? 'commits' : 'branches'; | |
| 313 | + const key = kind === 'commit' ? 'sha' : 'name'; | |
| 314 | + const row = this.sql.exec(`SELECT * FROM ${table} WHERE ${key} = ?`, target).toArray()[0]; | |
| 315 | + if (!row) return { ok: false, message: `That ${kind} isn't open for votes.` }; | |
| 316 | + if (row.status === 'removed') return { ok: false, message: `That ${kind} was already removed by votes.` }; | |
| 317 | + if (row.status === 'system') return { ok: false, message: 'Removals made by votes are not voted on.' }; | |
| 318 | + if (row.status === 'kept') return { ok: false, message: `That ${kind} already got ${VOTES_TO_DECIDE} votes up and stays for good.`, status: 'kept' }; | |
| 319 | + const owner = kind === 'commit' ? row.pusher : row.created_by; | |
| 320 | + if (owner === voter.handle && value > 0) return { ok: false, message: 'You can vote down your own work, but not up. Others decide what stays.' }; | |
| 321 | + if (value === 0) this.sql.exec('DELETE FROM votes WHERE kind = ? AND target = ? AND account = ?', kind, target, voter.id); | |
| 322 | + else this.sql.exec('INSERT INTO votes (kind, target, account, handle, value, at) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (kind, target, account) DO UPDATE SET value = excluded.value, at = excluded.at', | |
| 323 | + kind, target, voter.id, voter.handle, value, Date.now()); | |
| 324 | + const t = this.sql.exec('SELECT SUM(value > 0) AS up, SUM(value < 0) AS down FROM votes WHERE kind = ? AND target = ?', kind, target).toArray()[0]; | |
| 325 | + const up = (t.up as number) || 0, down = (t.down as number) || 0; | |
| 326 | + this.sql.exec(`UPDATE ${table} SET up = ?, down = ? WHERE ${key} = ?`, up, down, target); | |
| 327 | + if (down >= VOTES_TO_DECIDE) { | |
| 328 | + const msg = kind === 'commit' ? this.removeCommit(target) : this.removeBranch(target); | |
| 329 | + return { ok: true, message: msg, status: 'removed', up, down }; | |
| 330 | + } | |
| 331 | + if (up >= VOTES_TO_DECIDE) { | |
| 332 | + this.sql.exec(`UPDATE ${table} SET status = 'kept' WHERE ${key} = ?`, target); | |
| 333 | + return { ok: true, message: `${VOTES_TO_DECIDE} votes up: it stays for good.`, status: 'kept', up, down }; | |
| 334 | + } | |
| 335 | + return { ok: true, message: 'Vote counted.', status: row.status as string, up, down }; | |
| 336 | + } | |
| 337 | + | |
| 338 | + removeBranch(name: string): string { | |
| 339 | + if (name === this.defaultBranch()) { this.sql.exec("UPDATE branches SET status = 'kept' WHERE name = ?", name); return 'The main branch always stays.'; } | |
| 340 | + this.sql.exec("UPDATE branches SET status = 'removed', removed_at = ? WHERE name = ?", Date.now(), name); | |
| 341 | + this.sql.exec('DELETE FROM refs WHERE name = ?', 'refs/heads/' + name); | |
| 342 | + return `${VOTES_TO_DECIDE} votes down: the branch ${name} was removed.`; | |
| 343 | + } | |
| 344 | + | |
| 345 | + /** Takes a commit's changes back out of its branch with a new commit, file by file. History is never rewritten. */ | |
| 346 | + removeCommit(sha: string): string { | |
| 347 | + const row = this.sql.exec('SELECT * FROM commits WHERE sha = ?', sha).toArray()[0]; | |
| 348 | + const branch = row.branch as string; | |
| 349 | + const tip = this.refs().get('refs/heads/' + branch); | |
| 350 | + if (!tip) { this.sql.exec("UPDATE commits SET status = 'removed', note = ? WHERE sha = ?", 'branch already removed', sha); return 'Removed.'; } | |
| 351 | + const { commit: c, files } = this.changes(sha); | |
| 352 | + const cur = this.flatten(this.commit(tip).tree); | |
| 353 | + let undone = 0, skipped = 0; | |
| 354 | + for (const f of files) { | |
| 355 | + const now = cur.get(f.path); | |
| 356 | + const same = (a?: { mode: string; sha: string }, b?: { mode: string; sha: string }) => (!a && !b) || (!!a && !!b && a.sha === b.sha && a.mode === b.mode); | |
| 357 | + if (!same(now, f.after)) { skipped++; continue; } // changed again later: leave the newer work alone | |
| 358 | + if (f.before) cur.set(f.path, f.before); else cur.delete(f.path); | |
| 359 | + undone++; | |
| 360 | + } | |
| 361 | + let note = `${undone} file${undone === 1 ? '' : 's'} restored`; | |
| 362 | + if (skipped) note += `, ${skipped} left alone because later commits changed them`; | |
| 363 | + if (undone) { | |
| 364 | + const tree = this.buildTree(cur); | |
| 365 | + const ts = Math.floor(Date.now() / 1000); | |
| 366 | + const who = `Branchwell votes <votes@branchwell.ai> ${ts} +0000`; | |
| 367 | + const subject = c.message.split('\n')[0].slice(0, 120); | |
| 368 | + const msg = `Remove "${subject}" (voted down)\n\n${VOTES_TO_DECIDE} people voted down commit ${sha.slice(0, 10)}, so its changes were taken back out.\n${note}.\n`; | |
| 369 | + const neu = this.make('commit', te.encode(`tree ${tree}\nparent ${tip}\nauthor ${who}\ncommitter ${who}\n\n${msg}`)); | |
| 370 | + this.setRef(branch, neu); | |
| 371 | + this.sql.exec(`INSERT INTO commits (sha, branch, status, pusher, pushed_at, subject, author, note) VALUES (?, ?, 'system', 'branchwell', ?, ?, 'Branchwell votes', ?)`, | |
| 372 | + neu, branch, Date.now(), `Remove "${subject}" (voted down)`, sha); | |
| 373 | + } | |
| 374 | + this.sql.exec("UPDATE commits SET status = 'removed', note = ? WHERE sha = ?", note, sha); | |
| 375 | + return `${VOTES_TO_DECIDE} votes down: the commit was removed from ${branch} (${note}).`; | |
| 376 | + } | |
| 377 | + | |
| 378 | + // ---------------- reads for the web pages ---------------- | |
| 379 | + async init(name: string) { if (!this.meta('name')) { this.setMeta('name', name); this.setMeta('created_at', String(Date.now())); } return true; } | |
| 380 | + | |
| 381 | + resolve(ref: string): string | null { | |
| 382 | + const refs = this.refs(); | |
| 383 | + if (refs.has('refs/heads/' + ref)) return refs.get('refs/heads/' + ref)!; | |
| 384 | + if (/^[0-9a-f]{40}$/.test(ref) && this.has(ref)) return ref; | |
| 385 | + if (/^[0-9a-f]{7,39}$/.test(ref)) { const r = this.sql.exec("SELECT sha FROM objects WHERE sha LIKE ? || '%' AND type = 1 LIMIT 2", ref).toArray(); if (r.length === 1) return r[0].sha as string; } | |
| 386 | + return null; | |
| 387 | + } | |
| 388 | + | |
| 389 | + async overview() { | |
| 390 | + const branches = this.sql.exec('SELECT name, status, up, down, created_by, created_at, removed_at, last_sha FROM branches ORDER BY (name = ?) DESC, created_at DESC', this.defaultBranch()).toArray(); | |
| 391 | + const counts = this.sql.exec("SELECT COUNT(*) AS n, SUM(status = 'new') AS open, SUM(status = 'removed') AS removed FROM commits").toArray()[0]; | |
| 392 | + return { name: this.meta('name'), defaultBranch: this.defaultBranch(), empty: this.refs().size === 0, branches, commits: counts, updatedAt: Number(this.meta('updated_at') || 0) }; | |
| 393 | + } | |
| 394 | + | |
| 395 | + async listTree(ref: string, path: string) { | |
| 396 | + const sha = this.resolve(ref); if (!sha) return null; | |
| 397 | + const c = this.commit(sha); | |
| 398 | + let t = c.tree; | |
| 399 | + for (const part of path.split('/').filter(Boolean)) { | |
| 400 | + const e = this.tree(t).find((x) => x.name === part); | |
| 401 | + if (!e) return null; | |
| 402 | + if (e.mode !== '40000') return { kind: 'blob' as const, commit: sha }; | |
| 403 | + t = e.sha; | |
| 404 | + } | |
| 405 | + const entries = this.tree(t).map((e) => ({ name: e.name, dir: e.mode === '40000', sha: e.sha, size: e.mode === '40000' ? 0 : ((this.sql.exec('SELECT size FROM objects WHERE sha = ?', e.sha).toArray()[0]?.size as number) || 0) })) | |
| 406 | + .sort((a, b) => (a.dir === b.dir ? a.name.localeCompare(b.name) : a.dir ? -1 : 1)); | |
| 407 | + return { kind: 'tree' as const, commit: sha, entries, last: { sha, subject: c.message.split('\n')[0], author: personName(c.author), time: c.time } }; | |
| 408 | + } | |
| 409 | + | |
| 410 | + async readBlob(ref: string, path: string): Promise<{ data: Uint8Array; sha: string; commit: string } | null> { | |
| 411 | + const sha = this.resolve(ref); if (!sha) return null; | |
| 412 | + let t = this.commit(sha).tree; | |
| 413 | + const parts = path.split('/').filter(Boolean); | |
| 414 | + for (let i = 0; i < parts.length; i++) { | |
| 415 | + const e = this.tree(t).find((x) => x.name === parts[i]); | |
| 416 | + if (!e) return null; | |
| 417 | + if (i === parts.length - 1) { if (e.mode === '40000') return null; const o = this.get(e.sha); return o ? { data: o.data, sha: e.sha, commit: sha } : null; } | |
| 418 | + if (e.mode !== '40000') return null; | |
| 419 | + t = e.sha; | |
| 420 | + } | |
| 421 | + return null; | |
| 422 | + } | |
| 423 | + | |
| 424 | + async log(ref: string, skip = 0, limit = 30) { | |
| 425 | + const tip = this.resolve(ref); if (!tip) return null; | |
| 426 | + const out: Record<string, unknown>[] = []; | |
| 427 | + const seen = new Set<string>(); const heap: { sha: string; time: number }[] = [{ sha: tip, time: this.commit(tip).time }]; | |
| 428 | + let i = 0; | |
| 429 | + while (heap.length && out.length < limit) { | |
| 430 | + heap.sort((a, b) => b.time - a.time); | |
| 431 | + const { sha } = heap.shift()!; if (seen.has(sha)) continue; seen.add(sha); | |
| 432 | + const c = this.commit(sha); | |
| 433 | + for (const p of c.parents) if (!seen.has(p)) heap.push({ sha: p, time: this.commit(p).time }); | |
| 434 | + if (i++ < skip) continue; | |
| 435 | + const m = this.sql.exec('SELECT branch, status, up, down, pusher, pushed_at, note FROM commits WHERE sha = ?', sha).toArray()[0] || null; | |
| 436 | + out.push({ sha, subject: c.message.split('\n')[0], author: personName(c.author), time: c.time, parents: c.parents, meta: m }); | |
| 437 | + } | |
| 438 | + return { tip, commits: out, more: heap.length > 0 }; | |
| 439 | + } | |
| 440 | + | |
| 441 | + async commitInfo(ref: string) { | |
| 442 | + const sha = this.resolve(ref); if (!sha) return null; | |
| 443 | + const { commit: c, files } = this.changes(sha); | |
| 444 | + const meta = this.sql.exec('SELECT branch, status, up, down, pusher, pushed_at, note FROM commits WHERE sha = ?', sha).toArray()[0] || null; | |
| 445 | + const voters = this.sql.exec("SELECT handle, value FROM votes WHERE kind = 'commit' AND target = ? ORDER BY at", sha).toArray(); | |
| 446 | + const diffs = files.slice(0, 50).map((f) => { | |
| 447 | + const a = f.before ? this.get(f.before.sha) : null, b = f.after ? this.get(f.after.sha) : null; | |
| 448 | + return { path: f.path, status: f.status, before: a && isText(a.data) && a.data.length < 200_000 ? td.decode(a.data) : a ? null : '', after: b && isText(b.data) && b.data.length < 200_000 ? td.decode(b.data) : b ? null : '' }; | |
| 449 | + }); | |
| 450 | + return { sha, commit: c, meta, voters, files: files.map((f) => ({ path: f.path, status: f.status })), diffs }; | |
| 451 | + } | |
| 452 | + | |
| 453 | + async myVotes(account: string, kind: string, targets: string[]): Promise<Record<string, number>> { | |
| 454 | + const out: Record<string, number> = {}; | |
| 455 | + for (const t of targets.slice(0, 200)) { const r = this.sql.exec('SELECT value FROM votes WHERE kind = ? AND target = ? AND account = ?', kind, t, account).toArray()[0]; if (r) out[t] = r.value as number; } | |
| 456 | + return out; | |
| 457 | + } | |
| 458 | + | |
| 459 | + async branchVotes(name: string) { | |
| 460 | + return this.sql.exec("SELECT handle, value FROM votes WHERE kind = 'branch' AND target = ? ORDER BY at", name).toArray(); | |
| 461 | + } | |
| 462 | + } | |
| 463 | + | |
| 464 | + export function isText(d: Uint8Array): boolean { | |
| 465 | + const n = Math.min(d.length, 8000); | |
| 466 | + for (let i = 0; i < n; i++) if (d[i] === 0) return false; | |
| 467 | + return true; | |
| 468 | + } |
src/static.ts added
| 1 | + // Generated by build-static.mjs from static/. Do not edit. | |
| 2 | + export const NO_ORPHANS: string = "<!-- no-orphans --><style id=\"no-orphans\">h1,h2,h3,h4,h5,h6,summary,legend,caption,blockquote{text-wrap:balance}p,li,dd,dt,figcaption,td,th,label,small{text-wrap:pretty}</style><script id=\"no-orphans-js\">(function () {\nif (window.__noOrphans) return;\nwindow.__noOrphans = 1;\nvar SKIP = /^(SCRIPT|STYLE|PRE|CODE|TEXTAREA|INPUT|SELECT|OPTION|SVG|MATH|KBD|SAMP|NOSCRIPT|TEMPLATE|IFRAME|CANVAS|TITLE)$/;\nvar NB = ' ';\nvar WS = /[ \\t\\n\\r]/;\nfunction skipped(el) {\nfor (var n = el; n && n.nodeType === 1; n = n.parentNode) {\nif (SKIP.test(n.nodeName.toUpperCase()) || n.isContentEditable || n.hasAttribute('data-orphans-ok')) return true;\n}\nreturn false;\n}\nfunction blockOf(node, cache) {\nfor (var el = node.parentNode; el && el.nodeType === 1; el = el.parentNode) {\nvar d = cache.get(el);\nif (d === undefined) { d = getComputedStyle(el).display; cache.set(el, d); }\nif (d !== 'inline' && d !== 'contents') return el;\n}\nreturn null;\n}\nfunction fix(block, nodes) {\nvar text = '';\nfor (var i = 0; i < nodes.length; i++) text += nodes[i].nodeValue;\nvar words = text.trim().split(/\\s+/);\nif (words.length < 3) return;\nvar last = words[words.length - 1], prev = words[words.length - 2];\nif (last.indexOf(NB) >= 0 || last.length + prev.length > 30) return;\nvar seenWord = false;\nfor (i = nodes.length - 1; i >= 0; i--) {\nvar s = nodes[i].nodeValue;\nfor (var j = s.length - 1; j >= 0; j--) {\nvar c = s.charAt(j);\nif (c === NB) { if (seenWord) return; continue; }\nif (WS.test(c)) {\nif (!seenWord) continue;\nvar k = j;\nwhile (k > 0 && WS.test(s.charAt(k - 1))) k--;\nvar node = nodes[i], before = s;\nnode.nodeValue = s.slice(0, k) + NB + s.slice(j + 1);\nif (last.length + prev.length > 14) {\nvar de = document.documentElement;\nif (block.scrollWidth > block.clientWidth + 1 || de.scrollWidth > de.clientWidth + 1) node.nodeValue = before;\n}\nreturn;\n}\nseenWord = true;\n}\n}\n}\nfunction run(root) {\nif (!root || root.nodeType !== 1 || skipped(root)) return;\nvar cache = new Map(), blocks = [], groups = new Map();\nvar w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {\nacceptNode: function (t) { return t.nodeValue.trim() && !skipped(t.parentNode) ? 1 : 3; }\n});\nfor (var t = w.nextNode(); t; t = w.nextNode()) {\nvar b = blockOf(t, cache);\nif (!b) continue;\nvar g = groups.get(b);\nif (!g) { g = []; groups.set(b, g); blocks.push(b); }\ng.push(t);\n}\nfor (var i = 0; i < blocks.length; i++) {\nvar blk = blocks[i];\nif (!root.contains(blk) || blk === root.parentNode) continue;\nfix(blk, groups.get(blk));\n}\n}\nvar queued = [], timer = 0;\nfunction flush() {\ntimer = 0;\nvar q = queued; queued = [];\nvar cache = new Map(), seen = new Set();\nfor (var i = 0; i < q.length; i++) {\nvar n = q[i];\nif (!n || !n.isConnected) continue;\nvar b = n.nodeType === 3 ? blockOf(n, cache) : (n.nodeType === 1 ? (getComputedStyle(n).display === 'inline' ? blockOf(n, cache) : n) : null);\nif (b && !seen.has(b)) { seen.add(b); run(b); }\n}\n}\nfunction start() {\nrun(document.body);\nif (!window.MutationObserver) return;\nnew MutationObserver(function (muts) {\nfor (var i = 0; i < muts.length; i++) {\nvar m = muts[i];\nif (m.type === 'characterData') queued.push(m.target);\nfor (var j = 0; j < m.addedNodes.length; j++) queued.push(m.addedNodes[j]);\n}\nif (queued.length && !timer) timer = setTimeout(flush, 60);\n}).observe(document.body, { childList: true, subtree: true, characterData: true });\n}\nif (document.readyState === 'complete') setTimeout(start, 0);\nelse window.addEventListener('load', function () { setTimeout(start, 0); });\n})();</script><!-- /no-orphans -->\n"; | |
| 3 | + export const ODOMETER_CSS: string = "/* Self-host with visitor-odometer.v1.js. No fonts, images, or other requests. */\n.visitor-odometer {\n --visitor-accent: #ffad64;\n display: flex; flex-wrap: wrap; align-items: center; gap: 8px 13px;\n margin-block: 1rem; font: inherit;\n}\n.visitor-odometer-label {\n font: 600 .72rem/1.25 ui-monospace, monospace;\n letter-spacing: .16em; text-transform: uppercase;\n}\n.visitor-odometer-tiles {\n display: inline-flex; gap: clamp(2px, 1vw, 4px); max-width: 100%; padding: 5px;\n border: 1px solid #ffffff20; border-radius: 9px; background: linear-gradient(#18191c, #070708);\n box-shadow: 0 8px 25px -12px #0009;\n}\n.visitor-odometer-tile {\n position: relative; display: grid; overflow: hidden; place-items: center;\n min-width: 0; width: clamp(13px, 7vw, 29px); height: clamp(26px, 9vw, 39px);\n border-radius: 4px; background: linear-gradient(#24252a 0%, #17181b 49%, #0b0c0d 51%, #18191c);\n box-shadow: inset 0 0 0 1px #ffffff12, inset 0 -6px 10px #0007;\n}\n.visitor-odometer-tile::after {\n position: absolute; inset-inline: 0; top: 50%; height: 1px; content: \"\"; background: #0009;\n}\n.visitor-odometer-face {\n color: var(--visitor-accent); font: 600 clamp(14px, 5vw, 24px)/1 ui-monospace, monospace;\n font-variant-numeric: tabular-nums; text-shadow: 0 0 7px #f580256e;\n animation: visitor-odometer-roll .6s cubic-bezier(.2, .8, .2, 1) both;\n}\n.visitor-odometer-note { font-size: .875rem; }\n.visitor-odometer-number { font-weight: 650; }\n.visitor-odometer-sr {\n position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;\n clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%);\n}\n@keyframes visitor-odometer-roll {\n from { transform: translateY(-90%); opacity: 0; }\n to { transform: none; opacity: 1; }\n}\n@media (prefers-reduced-motion: reduce) { .visitor-odometer-face { animation: none; } }\n"; | |
| 4 | + export const ODOMETER_JS: string = "// Aggregate-only visitor odometer: no cookies, referrer, identifiers or beacons.\n(() => {\n 'use strict';\n const endpoint = 'https://projectatom.ai/api/visits';\n const selector = '[data-visitor-odometer][data-visitor-site]';\n const siteIDs = new Set(['projectatom', 'protomota', 'airesourcepro', 'skillfarm', 'portfolio', 'opentalon', 'inkspring', 'jotley',\n 'glimmer', 'pulsecanvas', 'graphley', 'bucksley', 'jobley', 'voxley', 'textley', 'moontrace', 'sunlaid', 'cypress', 'lightwell', 'lumengesso', 'clearwake', 'krahn', 'chewandrinse', 'sidestreetmakers', 'carryspan', 'commonwakemarine', 'rootwardgardens', 'evenharbor', 'clearmeadow', 'fieldofwhy',\n 'watchencyclopedia', 'paywell', 'makeaclip', 'groundroom', 'brightpatchstories', 'calendarley', 'champagnedamage',\n 'neverwastv', 'noctvrne', 'otherworldvision', 'quillflow', 'tradenook', 'trendii', 'vexley', 'laceless', 'kindpaw', 'petgrove',\n 'homegrove', 'cyclical', 'commongrocer', 'brightiris', 'homeandroad', 'clothworks', 'jotkey', 'stridewell', 'branchwell']);\n const pending = new Map();\n const minimumDigits = 7;\n const ordinal = n => Number.isSafeInteger(n) && n > 0;\n const keyFor = site => site === 'projectatom' ? 'atom-visitor-no' : `visitor-odometer-v1:${site}`;\n function element(tag, name, text = '') {\n const node = document.createElement(tag);\n node.className = name;\n node.textContent = text;\n return node;\n }\n function paint(node, count, mine, unavailable = false) {\n const numeral = count == null ? (unavailable ? '–' : '·').repeat(minimumDigits) : String(count).padStart(minimumDigits, '0');\n const description = count == null ? (unavailable ? 'Visitor count unavailable' : 'Loading visitor count') : `${count.toLocaleString()} visitors`;\n const accessibleTotal = element('span', 'visitor-odometer-sr', description);\n accessibleTotal.setAttribute('role', 'status');\n const label = element('span', 'visitor-odometer-label', 'Visitors');\n label.setAttribute('aria-hidden', 'true');\n const digits = element('span', 'visitor-odometer-tiles');\n digits.setAttribute('aria-hidden', 'true');\n for (const character of numeral) {\n const digit = element('span', 'visitor-odometer-tile');\n digit.append(element('span', 'visitor-odometer-face', character));\n digits.append(digit);\n }\n const note = element('span', 'visitor-odometer-note', ordinal(mine) ? 'You’re visitor ' : 'Thank you for being here.');\n if (ordinal(mine)) {\n note.append(element('strong', 'visitor-odometer-number', `No. ${mine.toLocaleString()}`), '. Thank you for being here.');\n }\n node.classList.add('visitor-odometer');\n node.setAttribute('role', 'group');\n node.setAttribute('aria-label', 'Visitor counter');\n node.replaceChildren(label, digits, accessibleTotal, note);\n }\n function browserNumber(site) {\n try {\n const n = Number(window.localStorage.getItem(keyFor(site)));\n return ordinal(n) ? n : null;\n } catch { return null; }\n }\n async function request(site, method) {\n const response = await fetch(site === 'projectatom' ? '/api/visits' : `${endpoint}?site=${encodeURIComponent(site)}`, {\n method,\n signal: typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(4500) : undefined,\n mode: 'cors',\n credentials: 'omit',\n referrerPolicy: 'no-referrer',\n cache: 'no-store',\n redirect: 'error',\n });\n if (!response.ok) throw new Error('Counter unavailable');\n const result = await response.json();\n if (!Number.isSafeInteger(result?.count) || result.count < 0) throw new Error('Counter unavailable');\n return result;\n }\n async function load(site, mine) {\n const read = () => request(site, 'GET').catch(async () => {\n await new Promise(resolve => setTimeout(resolve, 400));\n return request(site, 'GET');\n });\n const run = async () => {\n mine = browserNumber(site) ?? mine;\n const data = await (mine ? read() : request(site, 'POST').catch(read));\n if (ordinal(data.you) && data.you <= data.count) {\n try { window.localStorage.setItem(keyFor(site), String(data.you)); } catch { /* storage disabled */ }\n }\n return data;\n };\n const locks = site === 'projectatom' ? window.navigator?.locks : null;\n const result = await (locks ? locks.request(keyFor(site), run) : run());\n if (ordinal(result.you) && result.you <= result.count) {\n mine = result.you;\n // Keep the number only on this browser, for the current site. It is\n // never placed in the URL or otherwise sent back to the counter.\n try { window.localStorage.setItem(keyFor(site), String(mine)); } catch { /* storage disabled */ }\n }\n return { count: result.count, mine };\n }\n function mount(widget) {\n if (!widget.isConnected || widget.firstElementChild) return;\n const site = widget.getAttribute('data-visitor-site');\n if (!siteIDs.has(site)) return;\n const mine = browserNumber(site);\n paint(widget, null, mine);\n if (!pending.has(site)) pending.set(site, load(site, mine));\n pending.get(site).then(result => { if (widget.isConnected) paint(widget, result.count, result.mine); })\n .catch(() => { if (widget.isConnected) paint(widget, null, mine, true); });\n }\n\n // Hydrating or navigating an SPA can replace server-rendered placeholders.\n // Reuse the previous request: remounting must not count a second visit.\n document.querySelectorAll(selector).forEach(mount);\n new MutationObserver(records => {\n for (const record of records) {\n if (record.target.matches?.(selector)) mount(record.target);\n for (const node of record.addedNodes) {\n if (node.matches?.(selector)) mount(node);\n node.querySelectorAll?.(selector).forEach(mount);\n }\n }\n }).observe(document.body, { childList: true, subtree: true });\n})();\n"; | |
| 5 | + export const APP_JS: string = "// Branchwell client: passkey sign-in, push keys, votes, careers form. No trackers.\n(function () {\n 'use strict';\n var b2u = function (buf) { var s = ''; new Uint8Array(buf).forEach(function (b) { s += String.fromCharCode(b); }); return btoa(s).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, ''); };\n var u2b = function (s) { s = s.replace(/-/g, '+').replace(/_/g, '/'); while (s.length % 4) s += '='; var bin = atob(s), out = new Uint8Array(bin.length); for (var i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); return out.buffer; };\n function post(url, body) {\n return fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body || {}), credentials: 'same-origin' })\n .then(function (r) { return r.json().then(function (j) { if (!r.ok || j.error) throw new Error(j.error || j.message || 'Something went wrong.'); return j; }); });\n }\n function say(el, text, bad) { if (!el) return; el.textContent = text; el.className = bad ? 'err' : 'muted'; }\n var back = function () { var p = new URLSearchParams(location.search).get('back'); return p && p.charAt(0) === '/' && p.charAt(1) !== '/' ? p : '/account'; };\n\n function register(handle, msg) {\n if (!window.PublicKeyCredential) { say(msg, 'This browser does not support passkeys. Try a recent Safari, Chrome, Edge or Firefox.', true); return Promise.resolve(); }\n say(msg, 'Follow your device to make a passkey…');\n return post('/api/auth/register/options', { handle: handle }).then(function (r) {\n var o = r.options;\n var pk = { challenge: u2b(o.challenge), rp: o.rp, user: { id: u2b(o.user.id), name: o.user.name, displayName: o.user.displayName },\n pubKeyCredParams: o.pubKeyCredParams, timeout: o.timeout, attestation: o.attestation, authenticatorSelection: o.authenticatorSelection,\n excludeCredentials: (o.excludeCredentials || []).map(function (c) { return { id: u2b(c.id), type: c.type, transports: c.transports }; }) };\n return navigator.credentials.create({ publicKey: pk }).then(function (c) {\n return post('/api/auth/register/verify', { cid: r.cid, response: { id: c.id, rawId: b2u(c.rawId), type: c.type,\n response: { clientDataJSON: b2u(c.response.clientDataJSON), attestationObject: b2u(c.response.attestationObject), transports: c.response.getTransports ? c.response.getTransports() : [] },\n clientExtensionResults: c.getClientExtensionResults ? c.getClientExtensionResults() : {}, authenticatorAttachment: c.authenticatorAttachment } });\n });\n });\n }\n function login(msg) {\n if (!window.PublicKeyCredential) { say(msg, 'This browser does not support passkeys.', true); return Promise.resolve(); }\n say(msg, 'Follow your device to use your passkey…');\n return post('/api/auth/login/options').then(function (r) {\n var o = r.options;\n return navigator.credentials.get({ publicKey: { challenge: u2b(o.challenge), rpId: o.rpId, timeout: o.timeout, userVerification: o.userVerification, allowCredentials: [] } }).then(function (c) {\n return post('/api/auth/login/verify', { cid: r.cid, response: { id: c.id, rawId: b2u(c.rawId), type: c.type,\n response: { clientDataJSON: b2u(c.response.clientDataJSON), authenticatorData: b2u(c.response.authenticatorData), signature: b2u(c.response.signature), userHandle: c.response.userHandle ? b2u(c.response.userHandle) : undefined },\n clientExtensionResults: {}, authenticatorAttachment: c.authenticatorAttachment } });\n });\n });\n }\n var fail = function (msg) { return function (e) { say(msg, e && e.name === 'NotAllowedError' ? 'Cancelled. Try again when you are ready.' : (e.message || 'Something went wrong.'), true); }; };\n\n var signup = document.getElementById('signup');\n if (signup) signup.addEventListener('submit', function (e) {\n e.preventDefault(); var msg = document.getElementById('signup-msg');\n register(signup.handle.value.trim().toLowerCase(), msg).then(function (r) { if (r && r.ok) location.href = back(); }).catch(fail(msg));\n });\n var signin = document.getElementById('signin');\n if (signin) signin.addEventListener('click', function () {\n var msg = document.getElementById('signin-msg');\n login(msg).then(function (r) { if (r && r.ok) location.href = back(); }).catch(fail(msg));\n });\n var addpk = document.getElementById('add-passkey');\n if (addpk) addpk.addEventListener('click', function () {\n var msg = document.getElementById('pk-msg');\n register('', msg).then(function (r) { if (r && r.ok) location.reload(); }).catch(fail(msg));\n });\n var out = document.getElementById('signout');\n if (out) out.addEventListener('click', function () { post('/api/auth/logout').then(function () { location.href = '/'; }); });\n var mk = document.getElementById('make-key');\n if (mk) mk.addEventListener('submit', function (e) {\n e.preventDefault(); var msg = document.getElementById('key-msg');\n post('/api/auth/push-keys/create', { name: mk.keyname.value }).then(function (r) {\n var box = document.getElementById('new-key'); box.hidden = false;\n document.getElementById('new-key-value').textContent = r.key;\n document.getElementById('new-key-user').textContent = r.handle;\n say(msg, 'Copy it now. We only show it once.');\n }).catch(fail(msg));\n });\n document.querySelectorAll('[data-del-key]').forEach(function (b) {\n b.addEventListener('click', function () { post('/api/auth/push-keys/delete', { id: b.getAttribute('data-del-key') }).then(function () { location.reload(); }); });\n });\n document.querySelectorAll('[data-copy]').forEach(function (b) {\n b.addEventListener('click', function () {\n var t = document.getElementById(b.getAttribute('data-copy')).textContent;\n (navigator.clipboard ? navigator.clipboard.writeText(t) : Promise.reject()).then(function () { b.textContent = 'Copied'; setTimeout(function () { b.textContent = 'Copy'; }, 1500); }).catch(function () {});\n });\n });\n // Votes on commits and branches\n document.querySelectorAll('.votes button[data-vote]').forEach(function (b) {\n b.addEventListener('click', function () {\n var box = b.closest('.votes'); var msg = box.parentNode.querySelector('.vote-msg') || document.getElementById('vote-msg');\n var pressed = b.getAttribute('aria-pressed') === 'true';\n post('/api/vote', { repo: box.dataset.repo, kind: box.dataset.kind, target: box.dataset.target, value: pressed ? 0 : +b.dataset.vote })\n .then(function (r) {\n if (r.ok === false) { say(msg, r.message, true); return; }\n box.querySelector('[data-vote=\"1\"] span').textContent = r.up; box.querySelector('[data-vote=\"-1\"] span').textContent = r.down;\n box.querySelectorAll('button').forEach(function (x) { x.setAttribute('aria-pressed', 'false'); });\n if (!pressed) b.setAttribute('aria-pressed', 'true');\n say(msg, r.message);\n if (r.status === 'removed' || r.status === 'kept') setTimeout(function () { location.reload(); }, 1200);\n }).catch(function (e) { if (/Sign in/i.test(e.message)) location.href = '/signin?back=' + encodeURIComponent(location.pathname); else say(msg, e.message, true); });\n });\n });\n // Feature vote page (opened from an app's New badge)\n document.querySelectorAll('[data-fvote]').forEach(function (b) {\n b.addEventListener('click', function () {\n var msg = document.getElementById('fv-msg');\n post('/api/feature-vote', { app: b.dataset.app, feature: b.dataset.feature, value: +b.dataset.fvote }).then(function (r) {\n say(msg, r.ok ? (r.status === 'kept' ? 'Thanks. 3 thumbs up: it stays for good.' : r.status === 'removed' ? 'Thanks. 3 thumbs down: it is switched off.' : 'Thanks. Your vote counts.') : r.message);\n try { if (window.opener) window.opener.postMessage({ bwVoted: true }, '*'); } catch (_) {}\n }).catch(function (e) { say(msg, e.message, true); });\n });\n });\n // New repo\n var nr = document.getElementById('new-repo');\n if (nr) nr.addEventListener('submit', function (e) {\n e.preventDefault(); var msg = document.getElementById('repo-msg');\n post('/api/repos', { owner: nr.owner.value, name: nr.repo.value.trim(), description: nr.description.value }).then(function (r) { location.href = '/' + r.name; }).catch(fail(msg));\n });\n // Careers\n var f = document.getElementById('cr-form');\n if (f) f.addEventListener('submit', function (e) {\n e.preventDefault(); var m = document.getElementById('cr-msg'); var nm = f.name.value.trim(), em = f.email.value.trim(), msg = f.request.value.trim();\n if (!nm || !em || !msg) { m.textContent = 'Please fill in your name, email and message.'; return; }\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(em)) { m.textContent = 'Please check your email address.'; return; }\n var t = 'Name: ' + nm + '\\nEmail: ' + em + '\\n\\n' + msg;\n var b = f.querySelector('button'); b.disabled = true; m.textContent = 'Sending…';\n fetch('/api/request', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ request: t, site: location.hostname, website: f.website.value }) })\n .then(function (r) { if (!r.ok) throw 0; f.reset(); m.textContent = 'Thanks. We got your request.'; })\n .catch(function () { m.textContent = 'That didn’t go through. Please try again in a minute.'; })\n .then(function () { b.disabled = false; });\n });\n})();\n"; |
static/app.js added
| 1 | + // Branchwell client: passkey sign-in, push keys, votes, careers form. No trackers. | |
| 2 | + (function () { | |
| 3 | + 'use strict'; | |
| 4 | + var b2u = function (buf) { var s = ''; new Uint8Array(buf).forEach(function (b) { s += String.fromCharCode(b); }); return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); }; | |
| 5 | + var u2b = function (s) { s = s.replace(/-/g, '+').replace(/_/g, '/'); while (s.length % 4) s += '='; var bin = atob(s), out = new Uint8Array(bin.length); for (var i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); return out.buffer; }; | |
| 6 | + function post(url, body) { | |
| 7 | + return fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body || {}), credentials: 'same-origin' }) | |
| 8 | + .then(function (r) { return r.json().then(function (j) { if (!r.ok || j.error) throw new Error(j.error || j.message || 'Something went wrong.'); return j; }); }); | |
| 9 | + } | |
| 10 | + function say(el, text, bad) { if (!el) return; el.textContent = text; el.className = bad ? 'err' : 'muted'; } | |
| 11 | + var back = function () { var p = new URLSearchParams(location.search).get('back'); return p && p.charAt(0) === '/' && p.charAt(1) !== '/' ? p : '/account'; }; | |
| 12 | + | |
| 13 | + function register(handle, msg) { | |
| 14 | + if (!window.PublicKeyCredential) { say(msg, 'This browser does not support passkeys. Try a recent Safari, Chrome, Edge or Firefox.', true); return Promise.resolve(); } | |
| 15 | + say(msg, 'Follow your device to make a passkey…'); | |
| 16 | + return post('/api/auth/register/options', { handle: handle }).then(function (r) { | |
| 17 | + var o = r.options; | |
| 18 | + var pk = { challenge: u2b(o.challenge), rp: o.rp, user: { id: u2b(o.user.id), name: o.user.name, displayName: o.user.displayName }, | |
| 19 | + pubKeyCredParams: o.pubKeyCredParams, timeout: o.timeout, attestation: o.attestation, authenticatorSelection: o.authenticatorSelection, | |
| 20 | + excludeCredentials: (o.excludeCredentials || []).map(function (c) { return { id: u2b(c.id), type: c.type, transports: c.transports }; }) }; | |
| 21 | + return navigator.credentials.create({ publicKey: pk }).then(function (c) { | |
| 22 | + return post('/api/auth/register/verify', { cid: r.cid, response: { id: c.id, rawId: b2u(c.rawId), type: c.type, | |
| 23 | + response: { clientDataJSON: b2u(c.response.clientDataJSON), attestationObject: b2u(c.response.attestationObject), transports: c.response.getTransports ? c.response.getTransports() : [] }, | |
| 24 | + clientExtensionResults: c.getClientExtensionResults ? c.getClientExtensionResults() : {}, authenticatorAttachment: c.authenticatorAttachment } }); | |
| 25 | + }); | |
| 26 | + }); | |
| 27 | + } | |
| 28 | + function login(msg) { | |
| 29 | + if (!window.PublicKeyCredential) { say(msg, 'This browser does not support passkeys.', true); return Promise.resolve(); } | |
| 30 | + say(msg, 'Follow your device to use your passkey…'); | |
| 31 | + return post('/api/auth/login/options').then(function (r) { | |
| 32 | + var o = r.options; | |
| 33 | + return navigator.credentials.get({ publicKey: { challenge: u2b(o.challenge), rpId: o.rpId, timeout: o.timeout, userVerification: o.userVerification, allowCredentials: [] } }).then(function (c) { | |
| 34 | + return post('/api/auth/login/verify', { cid: r.cid, response: { id: c.id, rawId: b2u(c.rawId), type: c.type, | |
| 35 | + response: { clientDataJSON: b2u(c.response.clientDataJSON), authenticatorData: b2u(c.response.authenticatorData), signature: b2u(c.response.signature), userHandle: c.response.userHandle ? b2u(c.response.userHandle) : undefined }, | |
| 36 | + clientExtensionResults: {}, authenticatorAttachment: c.authenticatorAttachment } }); | |
| 37 | + }); | |
| 38 | + }); | |
| 39 | + } | |
| 40 | + var fail = function (msg) { return function (e) { say(msg, e && e.name === 'NotAllowedError' ? 'Cancelled. Try again when you are ready.' : (e.message || 'Something went wrong.'), true); }; }; | |
| 41 | + | |
| 42 | + var signup = document.getElementById('signup'); | |
| 43 | + if (signup) signup.addEventListener('submit', function (e) { | |
| 44 | + e.preventDefault(); var msg = document.getElementById('signup-msg'); | |
| 45 | + register(signup.handle.value.trim().toLowerCase(), msg).then(function (r) { if (r && r.ok) location.href = back(); }).catch(fail(msg)); | |
| 46 | + }); | |
| 47 | + var signin = document.getElementById('signin'); | |
| 48 | + if (signin) signin.addEventListener('click', function () { | |
| 49 | + var msg = document.getElementById('signin-msg'); | |
| 50 | + login(msg).then(function (r) { if (r && r.ok) location.href = back(); }).catch(fail(msg)); | |
| 51 | + }); | |
| 52 | + var addpk = document.getElementById('add-passkey'); | |
| 53 | + if (addpk) addpk.addEventListener('click', function () { | |
| 54 | + var msg = document.getElementById('pk-msg'); | |
| 55 | + register('', msg).then(function (r) { if (r && r.ok) location.reload(); }).catch(fail(msg)); | |
| 56 | + }); | |
| 57 | + var out = document.getElementById('signout'); | |
| 58 | + if (out) out.addEventListener('click', function () { post('/api/auth/logout').then(function () { location.href = '/'; }); }); | |
| 59 | + var mk = document.getElementById('make-key'); | |
| 60 | + if (mk) mk.addEventListener('submit', function (e) { | |
| 61 | + e.preventDefault(); var msg = document.getElementById('key-msg'); | |
| 62 | + post('/api/auth/push-keys/create', { name: mk.keyname.value }).then(function (r) { | |
| 63 | + var box = document.getElementById('new-key'); box.hidden = false; | |
| 64 | + document.getElementById('new-key-value').textContent = r.key; | |
| 65 | + document.getElementById('new-key-user').textContent = r.handle; | |
| 66 | + say(msg, 'Copy it now. We only show it once.'); | |
| 67 | + }).catch(fail(msg)); | |
| 68 | + }); | |
| 69 | + document.querySelectorAll('[data-del-key]').forEach(function (b) { | |
| 70 | + b.addEventListener('click', function () { post('/api/auth/push-keys/delete', { id: b.getAttribute('data-del-key') }).then(function () { location.reload(); }); }); | |
| 71 | + }); | |
| 72 | + document.querySelectorAll('[data-copy]').forEach(function (b) { | |
| 73 | + b.addEventListener('click', function () { | |
| 74 | + var t = document.getElementById(b.getAttribute('data-copy')).textContent; | |
| 75 | + (navigator.clipboard ? navigator.clipboard.writeText(t) : Promise.reject()).then(function () { b.textContent = 'Copied'; setTimeout(function () { b.textContent = 'Copy'; }, 1500); }).catch(function () {}); | |
| 76 | + }); | |
| 77 | + }); | |
| 78 | + // Votes on commits and branches | |
| 79 | + document.querySelectorAll('.votes button[data-vote]').forEach(function (b) { | |
| 80 | + b.addEventListener('click', function () { | |
| 81 | + var box = b.closest('.votes'); var msg = box.parentNode.querySelector('.vote-msg') || document.getElementById('vote-msg'); | |
| 82 | + var pressed = b.getAttribute('aria-pressed') === 'true'; | |
| 83 | + post('/api/vote', { repo: box.dataset.repo, kind: box.dataset.kind, target: box.dataset.target, value: pressed ? 0 : +b.dataset.vote }) | |
| 84 | + .then(function (r) { | |
| 85 | + if (r.ok === false) { say(msg, r.message, true); return; } | |
| 86 | + box.querySelector('[data-vote="1"] span').textContent = r.up; box.querySelector('[data-vote="-1"] span').textContent = r.down; | |
| 87 | + box.querySelectorAll('button').forEach(function (x) { x.setAttribute('aria-pressed', 'false'); }); | |
| 88 | + if (!pressed) b.setAttribute('aria-pressed', 'true'); | |
| 89 | + say(msg, r.message); | |
| 90 | + if (r.status === 'removed' || r.status === 'kept') setTimeout(function () { location.reload(); }, 1200); | |
| 91 | + }).catch(function (e) { if (/Sign in/i.test(e.message)) location.href = '/signin?back=' + encodeURIComponent(location.pathname); else say(msg, e.message, true); }); | |
| 92 | + }); | |
| 93 | + }); | |
| 94 | + // Feature vote page (opened from an app's New badge) | |
| 95 | + document.querySelectorAll('[data-fvote]').forEach(function (b) { | |
| 96 | + b.addEventListener('click', function () { | |
| 97 | + var msg = document.getElementById('fv-msg'); | |
| 98 | + post('/api/feature-vote', { app: b.dataset.app, feature: b.dataset.feature, value: +b.dataset.fvote }).then(function (r) { | |
| 99 | + say(msg, r.ok ? (r.status === 'kept' ? 'Thanks. 3 thumbs up: it stays for good.' : r.status === 'removed' ? 'Thanks. 3 thumbs down: it is switched off.' : 'Thanks. Your vote counts.') : r.message); | |
| 100 | + try { if (window.opener) window.opener.postMessage({ bwVoted: true }, '*'); } catch (_) {} | |
| 101 | + }).catch(function (e) { say(msg, e.message, true); }); | |
| 102 | + }); | |
| 103 | + }); | |
| 104 | + // New repo | |
| 105 | + var nr = document.getElementById('new-repo'); | |
| 106 | + if (nr) nr.addEventListener('submit', function (e) { | |
| 107 | + e.preventDefault(); var msg = document.getElementById('repo-msg'); | |
| 108 | + post('/api/repos', { owner: nr.owner.value, name: nr.repo.value.trim(), description: nr.description.value }).then(function (r) { location.href = '/' + r.name; }).catch(fail(msg)); | |
| 109 | + }); | |
| 110 | + // Careers | |
| 111 | + var f = document.getElementById('cr-form'); | |
| 112 | + if (f) f.addEventListener('submit', function (e) { | |
| 113 | + e.preventDefault(); var m = document.getElementById('cr-msg'); var nm = f.name.value.trim(), em = f.email.value.trim(), msg = f.request.value.trim(); | |
| 114 | + if (!nm || !em || !msg) { m.textContent = 'Please fill in your name, email and message.'; return; } | |
| 115 | + if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(em)) { m.textContent = 'Please check your email address.'; return; } | |
| 116 | + var t = 'Name: ' + nm + '\nEmail: ' + em + '\n\n' + msg; | |
| 117 | + var b = f.querySelector('button'); b.disabled = true; m.textContent = 'Sending…'; | |
| 118 | + fetch('/api/request', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ request: t, site: location.hostname, website: f.website.value }) }) | |
| 119 | + .then(function (r) { if (!r.ok) throw 0; f.reset(); m.textContent = 'Thanks. We got your request.'; }) | |
| 120 | + .catch(function () { m.textContent = 'That didn’t go through. Please try again in a minute.'; }) | |
| 121 | + .then(function () { b.disabled = false; }); | |
| 122 | + }); | |
| 123 | + })(); |
static/no-orphans.html added
| 1 | + <!-- no-orphans --><style id="no-orphans">h1,h2,h3,h4,h5,h6,summary,legend,caption,blockquote{text-wrap:balance}p,li,dd,dt,figcaption,td,th,label,small{text-wrap:pretty}</style><script id="no-orphans-js">(function () { | |
| 2 | + if (window.__noOrphans) return; | |
| 3 | + window.__noOrphans = 1; | |
| 4 | + var SKIP = /^(SCRIPT|STYLE|PRE|CODE|TEXTAREA|INPUT|SELECT|OPTION|SVG|MATH|KBD|SAMP|NOSCRIPT|TEMPLATE|IFRAME|CANVAS|TITLE)$/; | |
| 5 | + var NB = ' '; | |
| 6 | + var WS = /[ \t\n\r]/; | |
| 7 | + function skipped(el) { | |
| 8 | + for (var n = el; n && n.nodeType === 1; n = n.parentNode) { | |
| 9 | + if (SKIP.test(n.nodeName.toUpperCase()) || n.isContentEditable || n.hasAttribute('data-orphans-ok')) return true; | |
| 10 | + } | |
| 11 | + return false; | |
| 12 | + } | |
| 13 | + function blockOf(node, cache) { | |
| 14 | + for (var el = node.parentNode; el && el.nodeType === 1; el = el.parentNode) { | |
| 15 | + var d = cache.get(el); | |
| 16 | + if (d === undefined) { d = getComputedStyle(el).display; cache.set(el, d); } | |
| 17 | + if (d !== 'inline' && d !== 'contents') return el; | |
| 18 | + } | |
| 19 | + return null; | |
| 20 | + } | |
| 21 | + function fix(block, nodes) { | |
| 22 | + var text = ''; | |
| 23 | + for (var i = 0; i < nodes.length; i++) text += nodes[i].nodeValue; | |
| 24 | + var words = text.trim().split(/\s+/); | |
| 25 | + if (words.length < 3) return; | |
| 26 | + var last = words[words.length - 1], prev = words[words.length - 2]; | |
| 27 | + if (last.indexOf(NB) >= 0 || last.length + prev.length > 30) return; | |
| 28 | + var seenWord = false; | |
| 29 | + for (i = nodes.length - 1; i >= 0; i--) { | |
| 30 | + var s = nodes[i].nodeValue; | |
| 31 | + for (var j = s.length - 1; j >= 0; j--) { | |
| 32 | + var c = s.charAt(j); | |
| 33 | + if (c === NB) { if (seenWord) return; continue; } | |
| 34 | + if (WS.test(c)) { | |
| 35 | + if (!seenWord) continue; | |
| 36 | + var k = j; | |
| 37 | + while (k > 0 && WS.test(s.charAt(k - 1))) k--; | |
| 38 | + var node = nodes[i], before = s; | |
| 39 | + node.nodeValue = s.slice(0, k) + NB + s.slice(j + 1); | |
| 40 | + if (last.length + prev.length > 14) { | |
| 41 | + var de = document.documentElement; | |
| 42 | + if (block.scrollWidth > block.clientWidth + 1 || de.scrollWidth > de.clientWidth + 1) node.nodeValue = before; | |
| 43 | + } | |
| 44 | + return; | |
| 45 | + } | |
| 46 | + seenWord = true; | |
| 47 | + } | |
| 48 | + } | |
| 49 | + } | |
| 50 | + function run(root) { | |
| 51 | + if (!root || root.nodeType !== 1 || skipped(root)) return; | |
| 52 | + var cache = new Map(), blocks = [], groups = new Map(); | |
| 53 | + var w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { | |
| 54 | + acceptNode: function (t) { return t.nodeValue.trim() && !skipped(t.parentNode) ? 1 : 3; } | |
| 55 | + }); | |
| 56 | + for (var t = w.nextNode(); t; t = w.nextNode()) { | |
| 57 | + var b = blockOf(t, cache); | |
| 58 | + if (!b) continue; | |
| 59 | + var g = groups.get(b); | |
| 60 | + if (!g) { g = []; groups.set(b, g); blocks.push(b); } | |
| 61 | + g.push(t); | |
| 62 | + } | |
| 63 | + for (var i = 0; i < blocks.length; i++) { | |
| 64 | + var blk = blocks[i]; | |
| 65 | + if (!root.contains(blk) || blk === root.parentNode) continue; | |
| 66 | + fix(blk, groups.get(blk)); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + var queued = [], timer = 0; | |
| 70 | + function flush() { | |
| 71 | + timer = 0; | |
| 72 | + var q = queued; queued = []; | |
| 73 | + var cache = new Map(), seen = new Set(); | |
| 74 | + for (var i = 0; i < q.length; i++) { | |
| 75 | + var n = q[i]; | |
| 76 | + if (!n || !n.isConnected) continue; | |
| 77 | + var b = n.nodeType === 3 ? blockOf(n, cache) : (n.nodeType === 1 ? (getComputedStyle(n).display === 'inline' ? blockOf(n, cache) : n) : null); | |
| 78 | + if (b && !seen.has(b)) { seen.add(b); run(b); } | |
| 79 | + } | |
| 80 | + } | |
| 81 | + function start() { | |
| 82 | + run(document.body); | |
| 83 | + if (!window.MutationObserver) return; | |
| 84 | + new MutationObserver(function (muts) { | |
| 85 | + for (var i = 0; i < muts.length; i++) { | |
| 86 | + var m = muts[i]; | |
| 87 | + if (m.type === 'characterData') queued.push(m.target); | |
| 88 | + for (var j = 0; j < m.addedNodes.length; j++) queued.push(m.addedNodes[j]); | |
| 89 | + } | |
| 90 | + if (queued.length && !timer) timer = setTimeout(flush, 60); | |
| 91 | + }).observe(document.body, { childList: true, subtree: true, characterData: true }); | |
| 92 | + } | |
| 93 | + if (document.readyState === 'complete') setTimeout(start, 0); | |
| 94 | + else window.addEventListener('load', function () { setTimeout(start, 0); }); | |
| 95 | + })();</script><!-- /no-orphans --> |
static/visitor-odometer.v1.css added
| 1 | + /* Self-host with visitor-odometer.v1.js. No fonts, images, or other requests. */ | |
| 2 | + .visitor-odometer { | |
| 3 | + --visitor-accent: #ffad64; | |
| 4 | + display: flex; flex-wrap: wrap; align-items: center; gap: 8px 13px; | |
| 5 | + margin-block: 1rem; font: inherit; | |
| 6 | + } | |
| 7 | + .visitor-odometer-label { | |
| 8 | + font: 600 .72rem/1.25 ui-monospace, monospace; | |
| 9 | + letter-spacing: .16em; text-transform: uppercase; | |
| 10 | + } | |
| 11 | + .visitor-odometer-tiles { | |
| 12 | + display: inline-flex; gap: clamp(2px, 1vw, 4px); max-width: 100%; padding: 5px; | |
| 13 | + border: 1px solid #ffffff20; border-radius: 9px; background: linear-gradient(#18191c, #070708); | |
| 14 | + box-shadow: 0 8px 25px -12px #0009; | |
| 15 | + } | |
| 16 | + .visitor-odometer-tile { | |
| 17 | + position: relative; display: grid; overflow: hidden; place-items: center; | |
| 18 | + min-width: 0; width: clamp(13px, 7vw, 29px); height: clamp(26px, 9vw, 39px); | |
| 19 | + border-radius: 4px; background: linear-gradient(#24252a 0%, #17181b 49%, #0b0c0d 51%, #18191c); | |
| 20 | + box-shadow: inset 0 0 0 1px #ffffff12, inset 0 -6px 10px #0007; | |
| 21 | + } | |
| 22 | + .visitor-odometer-tile::after { | |
| 23 | + position: absolute; inset-inline: 0; top: 50%; height: 1px; content: ""; background: #0009; | |
| 24 | + } | |
| 25 | + .visitor-odometer-face { | |
| 26 | + color: var(--visitor-accent); font: 600 clamp(14px, 5vw, 24px)/1 ui-monospace, monospace; | |
| 27 | + font-variant-numeric: tabular-nums; text-shadow: 0 0 7px #f580256e; | |
| 28 | + animation: visitor-odometer-roll .6s cubic-bezier(.2, .8, .2, 1) both; | |
| 29 | + } | |
| 30 | + .visitor-odometer-note { font-size: .875rem; } | |
| 31 | + .visitor-odometer-number { font-weight: 650; } | |
| 32 | + .visitor-odometer-sr { | |
| 33 | + position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; | |
| 34 | + clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); | |
| 35 | + } | |
| 36 | + @keyframes visitor-odometer-roll { | |
| 37 | + from { transform: translateY(-90%); opacity: 0; } | |
| 38 | + to { transform: none; opacity: 1; } | |
| 39 | + } | |
| 40 | + @media (prefers-reduced-motion: reduce) { .visitor-odometer-face { animation: none; } } |
static/visitor-odometer.v1.js added
| 1 | + // Aggregate-only visitor odometer: no cookies, referrer, identifiers or beacons. | |
| 2 | + (() => { | |
| 3 | + 'use strict'; | |
| 4 | + const endpoint = 'https://projectatom.ai/api/visits'; | |
| 5 | + const selector = '[data-visitor-odometer][data-visitor-site]'; | |
| 6 | + const siteIDs = new Set(['projectatom', 'protomota', 'airesourcepro', 'skillfarm', 'portfolio', 'opentalon', 'inkspring', 'jotley', | |
| 7 | + 'glimmer', 'pulsecanvas', 'graphley', 'bucksley', 'jobley', 'voxley', 'textley', 'moontrace', 'sunlaid', 'cypress', 'lightwell', 'lumengesso', 'clearwake', 'krahn', 'chewandrinse', 'sidestreetmakers', 'carryspan', 'commonwakemarine', 'rootwardgardens', 'evenharbor', 'clearmeadow', 'fieldofwhy', | |
| 8 | + 'watchencyclopedia', 'paywell', 'makeaclip', 'groundroom', 'brightpatchstories', 'calendarley', 'champagnedamage', | |
| 9 | + 'neverwastv', 'noctvrne', 'otherworldvision', 'quillflow', 'tradenook', 'trendii', 'vexley', 'laceless', 'kindpaw', 'petgrove', | |
| 10 | + 'homegrove', 'cyclical', 'commongrocer', 'brightiris', 'homeandroad', 'clothworks', 'jotkey', 'stridewell', 'branchwell']); | |
| 11 | + const pending = new Map(); | |
| 12 | + const minimumDigits = 7; | |
| 13 | + const ordinal = n => Number.isSafeInteger(n) && n > 0; | |
| 14 | + const keyFor = site => site === 'projectatom' ? 'atom-visitor-no' : `visitor-odometer-v1:${site}`; | |
| 15 | + function element(tag, name, text = '') { | |
| 16 | + const node = document.createElement(tag); | |
| 17 | + node.className = name; | |
| 18 | + node.textContent = text; | |
| 19 | + return node; | |
| 20 | + } | |
| 21 | + function paint(node, count, mine, unavailable = false) { | |
| 22 | + const numeral = count == null ? (unavailable ? '–' : '·').repeat(minimumDigits) : String(count).padStart(minimumDigits, '0'); | |
| 23 | + const description = count == null ? (unavailable ? 'Visitor count unavailable' : 'Loading visitor count') : `${count.toLocaleString()} visitors`; | |
| 24 | + const accessibleTotal = element('span', 'visitor-odometer-sr', description); | |
| 25 | + accessibleTotal.setAttribute('role', 'status'); | |
| 26 | + const label = element('span', 'visitor-odometer-label', 'Visitors'); | |
| 27 | + label.setAttribute('aria-hidden', 'true'); | |
| 28 | + const digits = element('span', 'visitor-odometer-tiles'); | |
| 29 | + digits.setAttribute('aria-hidden', 'true'); | |
| 30 | + for (const character of numeral) { | |
| 31 | + const digit = element('span', 'visitor-odometer-tile'); | |
| 32 | + digit.append(element('span', 'visitor-odometer-face', character)); | |
| 33 | + digits.append(digit); | |
| 34 | + } | |
| 35 | + const note = element('span', 'visitor-odometer-note', ordinal(mine) ? 'You’re visitor ' : 'Thank you for being here.'); | |
| 36 | + if (ordinal(mine)) { | |
| 37 | + note.append(element('strong', 'visitor-odometer-number', `No. ${mine.toLocaleString()}`), '. Thank you for being here.'); | |
| 38 | + } | |
| 39 | + node.classList.add('visitor-odometer'); | |
| 40 | + node.setAttribute('role', 'group'); | |
| 41 | + node.setAttribute('aria-label', 'Visitor counter'); | |
| 42 | + node.replaceChildren(label, digits, accessibleTotal, note); | |
| 43 | + } | |
| 44 | + function browserNumber(site) { | |
| 45 | + try { | |
| 46 | + const n = Number(window.localStorage.getItem(keyFor(site))); | |
| 47 | + return ordinal(n) ? n : null; | |
| 48 | + } catch { return null; } | |
| 49 | + } | |
| 50 | + async function request(site, method) { | |
| 51 | + const response = await fetch(site === 'projectatom' ? '/api/visits' : `${endpoint}?site=${encodeURIComponent(site)}`, { | |
| 52 | + method, | |
| 53 | + signal: typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(4500) : undefined, | |
| 54 | + mode: 'cors', | |
| 55 | + credentials: 'omit', | |
| 56 | + referrerPolicy: 'no-referrer', | |
| 57 | + cache: 'no-store', | |
| 58 | + redirect: 'error', | |
| 59 | + }); | |
| 60 | + if (!response.ok) throw new Error('Counter unavailable'); | |
| 61 | + const result = await response.json(); | |
| 62 | + if (!Number.isSafeInteger(result?.count) || result.count < 0) throw new Error('Counter unavailable'); | |
| 63 | + return result; | |
| 64 | + } | |
| 65 | + async function load(site, mine) { | |
| 66 | + const read = () => request(site, 'GET').catch(async () => { | |
| 67 | + await new Promise(resolve => setTimeout(resolve, 400)); | |
| 68 | + return request(site, 'GET'); | |
| 69 | + }); | |
| 70 | + const run = async () => { | |
| 71 | + mine = browserNumber(site) ?? mine; | |
| 72 | + const data = await (mine ? read() : request(site, 'POST').catch(read)); | |
| 73 | + if (ordinal(data.you) && data.you <= data.count) { | |
| 74 | + try { window.localStorage.setItem(keyFor(site), String(data.you)); } catch { /* storage disabled */ } | |
| 75 | + } | |
| 76 | + return data; | |
| 77 | + }; | |
| 78 | + const locks = site === 'projectatom' ? window.navigator?.locks : null; | |
| 79 | + const result = await (locks ? locks.request(keyFor(site), run) : run()); | |
| 80 | + if (ordinal(result.you) && result.you <= result.count) { | |
| 81 | + mine = result.you; | |
| 82 | + // Keep the number only on this browser, for the current site. It is | |
| 83 | + // never placed in the URL or otherwise sent back to the counter. | |
| 84 | + try { window.localStorage.setItem(keyFor(site), String(mine)); } catch { /* storage disabled */ } | |
| 85 | + } | |
| 86 | + return { count: result.count, mine }; | |
| 87 | + } | |
| 88 | + function mount(widget) { | |
| 89 | + if (!widget.isConnected || widget.firstElementChild) return; | |
| 90 | + const site = widget.getAttribute('data-visitor-site'); | |
| 91 | + if (!siteIDs.has(site)) return; | |
| 92 | + const mine = browserNumber(site); | |
| 93 | + paint(widget, null, mine); | |
| 94 | + if (!pending.has(site)) pending.set(site, load(site, mine)); | |
| 95 | + pending.get(site).then(result => { if (widget.isConnected) paint(widget, result.count, result.mine); }) | |
| 96 | + .catch(() => { if (widget.isConnected) paint(widget, null, mine, true); }); | |
| 97 | + } | |
| 98 | + | |
| 99 | + // Hydrating or navigating an SPA can replace server-rendered placeholders. | |
| 100 | + // Reuse the previous request: remounting must not count a second visit. | |
| 101 | + document.querySelectorAll(selector).forEach(mount); | |
| 102 | + new MutationObserver(records => { | |
| 103 | + for (const record of records) { | |
| 104 | + if (record.target.matches?.(selector)) mount(record.target); | |
| 105 | + for (const node of record.addedNodes) { | |
| 106 | + if (node.matches?.(selector)) mount(node); | |
| 107 | + node.querySelectorAll?.(selector).forEach(mount); | |
| 108 | + } | |
| 109 | + } | |
| 110 | + }).observe(document.body, { childList: true, subtree: true }); | |
| 111 | + })(); |
tsconfig.json added
| 1 | + { "compilerOptions": { "target": "es2022", "module": "es2022", "moduleResolution": "bundler", "strict": true, "lib": ["es2022"], "types": ["@cloudflare/workers-types"], "noEmit": true, "skipLibCheck": true }, "include": ["src"] } |
wrangler.jsonc added
| 1 | + { | |
| 2 | + // Branchwell (branchwell.ai): open Git hosting with passkey sign-in and voting. | |
| 3 | + // Deploy: npm run deploy (builds src/static.ts, then wrangler deploy). | |
| 4 | + "$schema": "node_modules/wrangler/config-schema.json", | |
| 5 | + "name": "branchwell", | |
| 6 | + "main": "src/index.ts", | |
| 7 | + "compatibility_date": "2026-11-01", | |
| 8 | + "compatibility_flags": ["nodejs_compat"], | |
| 9 | + "workers_dev": false, | |
| 10 | + "routes": [ | |
| 11 | + { "pattern": "branchwell.ai", "custom_domain": true }, | |
| 12 | + { "pattern": "www.branchwell.ai", "custom_domain": true } | |
| 13 | + ], | |
| 14 | + "d1_databases": [ | |
| 15 | + { "binding": "DB", "database_name": "branchwell", "database_id": "f80a0186-f65c-4ca2-af32-528cd5996208", "migrations_dir": "migrations" } | |
| 16 | + ], | |
| 17 | + "durable_objects": { "bindings": [{ "name": "REPO", "class_name": "RepoDO" }] }, | |
| 18 | + "migrations": [{ "tag": "v1", "new_sqlite_classes": ["RepoDO"] }], | |
| 19 | + // Careers form posts to the shared careers-intake Worker. | |
| 20 | + "services": [{ "binding": "CAREERS", "service": "careers-intake" }], | |
| 21 | + "limits": { "cpu_ms": 120000 }, | |
| 22 | + "observability": { "enabled": true } | |
| 23 | + } |