~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0

site: /install.sh, white pages, build-time highlighting, lexicon and XRPC reference

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:phase-2
site/build.ts+77−8
@@ -1,5 +1,7 @@
import { Marked } from "marked";
import puppeteer from "puppeteer-core";
import { createHighlighter } from "shiki";
import { lexiconOut, loadLexicons, nsidLookup, referencePages } from "./lexref.ts";
const REPO = "https://knotless.dev/socialweb.computer/socialweb-computer-kcp";
const REF = "main";
@@ -60,6 +62,49 @@ const OUT_OF = new Map(PAGES.map((p) => [p.as, p.out]));
const root = new URL("..", import.meta.url).pathname.replace(/\/$/, "");
const out = `${root}/site/out`;
const LEXICONS = await loadLexicons(root);
for (const lex of LEXICONS.values()) OUT_OF.set(lex.file, lexiconOut(lex.id));
OUT_OF.set("lexicons", "docs/lexicons/index.html");
const findNsid = nsidLookup(LEXICONS);
const LANGS: Record<string, string> = {
sh: "bash", bash: "bash", shell: "bash", console: "bash", zsh: "bash",
json: "json", jsonc: "json", yaml: "yaml", yml: "yaml", go: "go", ts: "typescript", typescript: "typescript",
js: "javascript", javascript: "javascript", toml: "toml", rust: "rust", rs: "rust", sql: "sql", diff: "diff",
dockerfile: "dockerfile", ini: "ini", caddyfile: "nginx",
};
const HIGHLIGHTER = await createHighlighter({ themes: ["tokyo-night"], langs: [...new Set(Object.values(LANGS))] });
const CODE_BG = "#070a10";
const readable = new Map<string, string>();
function luminance(hex: string): number {
const c = hex.slice(1, 7).match(/../g)!.map((x) => parseInt(x, 16) / 255).map((v) => v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
}
function readableOn(hex: string): string {
const key = hex.toLowerCase();
if (readable.has(key)) return readable.get(key)!;
let rgb = key.slice(1, 7).match(/../g)!.map((x) => parseInt(x, 16));
const bg = luminance(CODE_BG);
const ratio = (c: number[]) => (luminance(`#${c.map((v) => v.toString(16).padStart(2, "0")).join("")}`) + 0.05) / (bg + 0.05);
while (ratio(rgb) < 4.5) rgb = rgb.map((v) => Math.min(255, Math.round(v + (255 - v) * 0.08)));
const fixed = `#${rgb.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
readable.set(key, fixed);
return fixed;
}
function highlight(code: string, info: string): string {
const word = (info ?? "").trim().split(/\s+/)[0].toLowerCase();
const lang = LANGS[word];
const cls = word ? ` class="language-${escape(word)}"` : "";
if (!lang) return `<pre class="code" tabindex="0"><code${cls}>${escape(code.replace(/\n$/, ""))}</code></pre>\n`;
const html = HIGHLIGHTER.codeToHtml(code.replace(/\n$/, ""), { lang, theme: "tokyo-night" });
return html
.replace(/^<pre[^>]*><code>/, `<pre class="code shiki" tabindex="0"><code${cls}>`)
.replace(/color:(#[0-9a-fA-F]{6})/g, (_, c) => `color:${readableOn(c)}`) + "\n";
}
function dirname(p: string): string {
const i = p.lastIndexOf("/");
return i < 0 ? "" : p.slice(0, i);
@@ -164,7 +209,7 @@ function semicolons(code: string): string {
}).join("\n");
}
type Rendered = { page: Page; title: string; body: string };
type Rendered = { page: Page; title: string; body: string; aside?: string };
const diagrams: string[] = [];
async function render(page: Page): Promise<Rendered> {
@@ -198,7 +243,13 @@ async function render(page: Page): Promise<Rendered> {
diagrams.push(semicolons(text));
return `<!--diagram:${diagrams.length - 1}-->\n`;
}
return false;
return highlight(text, lang ?? "");
},
codespan({ text }) {
if (page.src !== "docs/protocol/glossary.md") return false;
const nsid = findNsid(text.replace(/&amp;/g, "&"));
if (!nsid) return false;
return `<a class="nsid-link" href="${escape(relative(page.out, lexiconOut(nsid)))}"><code>${text}</code></a>`;
},
blockquote({ tokens }) {
const body = this.parser.parse(tokens);
@@ -335,6 +386,7 @@ function shell(r: Rendered, commit: string, tagline: string): string {
const nav = [
...(landing ? [] : [{ href: relative(here, "index.html"), text: "home" }]),
{ href: relative(here, "docs/index.html"), text: "docs" },
{ href: relative(here, "docs/lexicons/index.html"), text: "lexicons" },
{ href: relative(here, "fancy/index.html"), text: "compute contracts" },
...(landing ? [] : [{ href: REPO, text: "source" }]),
];
@@ -356,14 +408,26 @@ function shell(r: Rendered, commit: string, tagline: string): string {
<link rel="icon" href="data:,">
<link rel="stylesheet" href="${relative(here, "style.css")}">
</head>
<body class="${landing ? "paper" : "console"}">
<body class="paper">
<header class="bar">
<p class="name"><a href="${relative(here, "index.html")}">${SITE}</a></p>
<p class="meta">${escape(tagline)}</p>
<nav>${nav.map(a).join("\n")}</nav>
</header>
${sub}<main>
${r.body}</main>
${sub}${r.aside === undefined ? `<main>
${r.body}</main>` : `<main class="ref">
<details class="refnav-phone"><summary>lexicons and xrpc</summary>
${r.aside}
</details>
<div class="ref-grid">
<aside class="refnav" aria-label="Lexicon reference">
${r.aside}
</aside>
<div class="ref-body">
${r.body}
</div>
</div>
</main>`}
<footer>
<p>Built from commit <code>${escape(commit.slice(0, 12))}${commit.endsWith("-dirty") ? "-dirty" : ""}</code>. Unlicense (public domain).</p>
</footer>
@@ -381,7 +445,7 @@ function anchorsOk(pages: Map<string, string>): string[] {
if (u.host !== SITE) continue;
let path = u.pathname.slice(1);
if (path === "" || path.endsWith("/")) path += "index.html";
if (!ids.has(path) && path !== "style.css") bad.push(`${p}: ${m[1]}: no page`);
if (!ids.has(path) && path !== "style.css" && path !== "install.sh") bad.push(`${p}: ${m[1]}: no page`);
else if (u.hash && !ids.get(path)?.has(decodeURIComponent(u.hash.slice(1)))) bad.push(`${p}: ${m[1]}: no anchor`);
}
}
@@ -389,7 +453,7 @@ function anchorsOk(pages: Map<string, string>): string[] {
}
const head = await git("rev-parse", "HEAD");
const dirty = (await git("status", "--porcelain", "--", "README.md", ...PAGES.map((p) => p.src), "site")) !== "";
const dirty = (await git("status", "--porcelain", "--", "README.md", "scripts/install.sh", "lexicons", ...PAGES.map((p) => p.src), "site")) !== "";
const commit = dirty ? `${head}-dirty` : head;
const readme = await Deno.readTextFile(`${root}/README.md`);
const tagline = (readme.split(/\n\s*\n/).find((p) => p.trim() && !p.startsWith("#")) ?? "")
@@ -397,6 +461,10 @@ const tagline = (readme.split(/\n\s*\n/).find((p) => p.trim() && !p.startsWith("
const rendered: Rendered[] = [];
for (const page of PAGES) rendered.push(await render(page));
for (const ref of referencePages(LEXICONS, { esc: escape, rel: relative, hl: highlight })) {
const src = ref.out;
rendered.push({ page: { src, as: src, out: ref.out, raw: false, section: "docs" }, title: ref.title, body: ref.body, aside: ref.aside });
}
const svgs = await renderDiagrams(diagrams);
const html = new Map<string, string>();
for (const r of rendered) {
@@ -411,9 +479,10 @@ if (bad.length) throw new Error(`dangling links:\n${bad.join("\n")}`);
await Deno.remove(out, { recursive: true }).catch(() => {});
await Deno.mkdir(out, { recursive: true });
await Deno.copyFile(`${root}/site/style.css`, `${out}/style.css`);
await Deno.copyFile(`${root}/scripts/install.sh`, `${out}/install.sh`);
for (const [p, h] of html) {
await Deno.mkdir(`${out}/${dirname(p)}`, { recursive: true });
await Deno.writeTextFile(`${out}/${p}`, h);
}
await Deno.writeTextFile(`${out}/COMMIT`, `${commit}\n`);
console.log(`built ${out} from ${commit}: ${html.size} pages, ${svgs.length} diagrams`);
console.log(`built ${out} from ${commit}: ${html.size} pages (${LEXICONS.size} lexicon pages), ${svgs.length} diagrams, install.sh`);
site/deno.json+2−1
@@ -2,7 +2,8 @@
"imports": {
"marked": "npm:marked@18.0.5",
"mermaid": "npm:mermaid@11.17.2",
"puppeteer-core": "npm:puppeteer-core@23.11.1"
"puppeteer-core": "npm:puppeteer-core@23.11.1",
"shiki": "npm:shiki@4.5.0"
},
"lock": {
"path": "deno.lock",
site/deno.lock+266−2
@@ -3,7 +3,8 @@
"specifiers": {
"npm:marked@18.0.5": "18.0.5",
"npm:mermaid@11.17.2": "11.17.2",
"npm:puppeteer-core@23.11.1": "23.11.1"
"npm:puppeteer-core@23.11.1": "23.11.1",
"npm:shiki@4.5.0": "4.5.0"
},
"npm": {
"@antfu/install-pkg@2.1.0": {
@@ -50,6 +51,61 @@
],
"bin": true
},
"@shikijs/core@4.5.0": {
"integrity": "sha512-6CIgwq+bt2JZ3OSjb/nBkkwEf/CfpHcbam+Mg5Pllco7HAGRQ2/EFhZrrJtbyNTgKwknfVS+llsXGygiDGwJWw==",
"dependencies": [
"@shikijs/primitive",
"@shikijs/types",
"@shikijs/vscode-textmate",
"@types/hast",
"hast-util-to-html"
]
},
"@shikijs/engine-javascript@4.5.0": {
"integrity": "sha512-Ed6UdEj84LyYkwnxM5CvSMWAD+id9ExTYri0/+x41U9zrgNifPSS9lZm0JqBP0VfYI8yr8tY5nbNq9+p9R0kFA==",
"dependencies": [
"@shikijs/types",
"@shikijs/vscode-textmate",
"oniguruma-to-es"
]
},
"@shikijs/engine-oniguruma@4.5.0": {
"integrity": "sha512-dKVmbJecVdB9recl8a/CU4jdpNXyjJQrIcesIkpS70s5HS02ohpnCSpMUbotPnEUzbAcLQ+S4hwZYbkBBiTcJw==",
"dependencies": [
"@shikijs/types",
"@shikijs/vscode-textmate"
]
},
"@shikijs/langs@4.5.0": {
"integrity": "sha512-wwBTqwduXSz0X4v9Qa2EWeFaYJEw1clCncWjoRNQRbVDu3SPRTRWucnouYapKj3b8Q+sk/41Vbc4B5c8nuYzLA==",
"dependencies": [
"@shikijs/types"
]
},
"@shikijs/primitive@4.5.0": {
"integrity": "sha512-UM7ShlA8oz0OWxLLO8BmO9Ip6fVqdkt8yF0EH7nOCqHfrx1eEAzF0ZUVK7L+I8NEgeu1PEWSRlxaiPPeCb4iDg==",
"dependencies": [
"@shikijs/types",
"@shikijs/vscode-textmate",
"@types/hast"
]
},
"@shikijs/themes@4.5.0": {
"integrity": "sha512-zGb87H3UBbpuI4yoh5UguB1XbU+2BDU3kflM7UfZ+Cy2hWo9lBtqjSVK20gmLY6ukYl040hAypGXMgud9vul8Q==",
"dependencies": [
"@shikijs/types"
]
},
"@shikijs/types@4.5.0": {
"integrity": "sha512-drtPrtD8N0DENyD2cyt6Ajy+IWsiCLgMxODwLTpvH1UsN6a9jf90tNTPjqwHvA+0Lzu9e0txk8DjfqH1p9UJRw==",
"dependencies": [
"@shikijs/vscode-textmate",
"@types/hast"
]
},
"@shikijs/vscode-textmate@10.1.0": {
"integrity": "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ=="
},
"@tootallnate/quickjs-emscripten@0.23.0": {
"integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA=="
},
@@ -216,6 +272,18 @@
"@types/geojson@7946.0.16": {
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg=="
},
"@types/hast@3.0.5": {
"integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==",
"dependencies": [
"@types/unist"
]
},
"@types/mdast@4.0.4": {
"integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",
"dependencies": [
"@types/unist"
]
},
"@types/node@26.6.5": {
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
"dependencies": [
@@ -225,12 +293,18 @@
"@types/trusted-types@2.0.7": {
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
},
"@types/unist@3.0.3": {
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="
},
"@types/yauzl@2.10.3": {
"integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==",
"dependencies": [
"@types/node"
]
},
"@ungap/structured-clone@1.4.0": {
"integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ=="
},
"@upsetjs/venn.js@2.0.0": {
"integrity": "sha512-WbBhLrooyePuQ1VZxrJjtLvTc4NVfpOyKx0sKqioq9bX1C1m7Jgykkn8gLrtwumBioXIqam8DLxp88Adbue6Hw==",
"optionalDependencies": [
@@ -309,6 +383,15 @@
"ieee754"
]
},
"ccount@2.0.1": {
"integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="
},
"character-entities-html4@2.1.0": {
"integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="
},
"character-entities-legacy@3.0.0": {
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="
},
"chromium-bidi@0.11.0_devtools-protocol@0.0.1367902": {
"integrity": "sha512-6CJWHkNRoyZyjV9Rwv2lYONZf1Xm0IuDyNq97nwSsxxP3wf5Bwy15K5rOvVKMtJ127jJBmxFUanSAOjgFRxgrA==",
"dependencies": [
@@ -334,6 +417,9 @@
"color-name@1.1.4": {
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"comma-separated-tokens@2.0.3": {
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="
},
"commander@7.2.0": {
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw=="
},
@@ -628,6 +714,15 @@
"robust-predicates"
]
},
"dequal@2.0.3": {
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="
},
"devlop@1.1.0": {
"integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",
"dependencies": [
"dequal"
]
},
"devtools-protocol@0.0.1367902": {
"integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg=="
},
@@ -727,6 +822,31 @@
"hachure-fill@0.5.2": {
"integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg=="
},
"hast-util-to-html@9.0.7": {
"integrity": "sha512-HYNDA3qdnzUPitY/LcQm1nWs8z0cWFNH1Nz09jdI/tXifAqF7h3+jrLl4S/b9Mi4VSjn0Dsn54ctuTV6zhBthA==",
"dependencies": [
"@types/hast",
"@types/unist",
"ccount",
"comma-separated-tokens",
"hast-util-whitespace",
"html-void-elements",
"mdast-util-to-hast",
"property-information",
"space-separated-tokens",
"stringify-entities",
"zwitch"
]
},
"hast-util-whitespace@3.0.0": {
"integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==",
"dependencies": [
"@types/hast"
]
},
"html-void-elements@3.0.0": {
"integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="
},
"http-proxy-agent@7.0.2": {
"integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
"dependencies": [
@@ -792,6 +912,20 @@
"integrity": "sha512-S6GcvALHg6K4ohtu4E7x0a1AqhAjp6cV8KhLSyN9qVapnzJkusVBxZRcIU9AeYsbe6P1hKDusSbEOzGyyuce6w==",
"bin": true
},
"mdast-util-to-hast@13.2.2": {
"integrity": "sha512-l2pnmOuqs+SGLVpTVXnRLQu5v1AzvDe181404fbXzzqObVxrAnnVxapAP27pUwzLBL/ABIkgUhGlPVU7QSvIFg==",
"dependencies": [
"@types/hast",
"@types/mdast",
"@ungap/structured-clone",
"devlop",
"micromark-util-sanitize-uri",
"trim-lines",
"unist-util-position",
"unist-util-visit",
"vfile"
]
},
"mermaid@11.17.2": {
"integrity": "sha512-V6K3C8EBdEsPFZXSKMJe6ppQOENxuHARr9GvHX4hh47lAbhMRD9qf4oEK7LoaRQxULMa80/qt5gHO73aCleBBg==",
"dependencies": [
@@ -819,6 +953,30 @@
"uuid"
]
},
"micromark-util-character@2.1.1": {
"integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==",
"dependencies": [
"micromark-util-symbol",
"micromark-util-types"
]
},
"micromark-util-encode@2.0.1": {
"integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw=="
},
"micromark-util-sanitize-uri@2.0.1": {
"integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==",
"dependencies": [
"micromark-util-character",
"micromark-util-encode",
"micromark-util-symbol"
]
},
"micromark-util-symbol@2.0.1": {
"integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q=="
},
"micromark-util-types@2.0.3": {
"integrity": "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg=="
},
"mitt@3.0.1": {
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw=="
},
@@ -834,6 +992,17 @@
"wrappy"
]
},
"oniguruma-parser@0.12.2": {
"integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw=="
},
"oniguruma-to-es@4.3.6": {
"integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==",
"dependencies": [
"oniguruma-parser",
"regex",
"regex-recursion"
]
},
"pac-proxy-agent@7.2.0": {
"integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==",
"dependencies": [
@@ -876,6 +1045,9 @@
"progress@2.0.3": {
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA=="
},
"property-information@7.2.0": {
"integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg=="
},
"proxy-agent@6.5.0": {
"integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==",
"dependencies": [
@@ -910,6 +1082,21 @@
"ws"
]
},
"regex-recursion@6.0.2": {
"integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",
"dependencies": [
"regex-utilities"
]
},
"regex-utilities@2.3.0": {
"integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng=="
},
"regex@6.1.0": {
"integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",
"dependencies": [
"regex-utilities"
]
},
"require-directory@2.1.1": {
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="
},
@@ -935,6 +1122,19 @@
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
"bin": true
},
"shiki@4.5.0": {
"integrity": "sha512-OcRW72ngQvc+MSVWBRIovC/BTW589iUE/Vxav7VeM4RcY9MUjqB+IR6ILG1k9nuW6LiG/nct9uma4/MBtnZbmQ==",
"dependencies": [
"@shikijs/core",
"@shikijs/engine-javascript",
"@shikijs/engine-oniguruma",
"@shikijs/langs",
"@shikijs/themes",
"@shikijs/types",
"@shikijs/vscode-textmate",
"@types/hast"
]
},
"smart-buffer@4.2.0": {
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg=="
},
@@ -956,6 +1156,9 @@
"source-map@0.6.1": {
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"space-separated-tokens@2.0.2": {
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="
},
"streamx@2.28.1": {
"integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==",
"dependencies": [
@@ -975,6 +1178,13 @@
"strip-ansi"
]
},
"stringify-entities@4.0.4": {
"integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==",
"dependencies": [
"character-entities-html4",
"character-entities-legacy"
]
},
"strip-ansi@6.0.1": {
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": [
@@ -1022,6 +1232,9 @@
"tinyexec@1.3.1": {
"integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA=="
},
"trim-lines@3.0.1": {
"integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="
},
"ts-dedent@2.3.0": {
"integrity": "sha512-JfJeIHke7y2egdGGgRAvpCwYFUsHlM2gPcrVOxFkznt/4uzQ7HFmvE63iFHVLBJNDuyDOQgijDK/tXH/f6Msjg=="
},
@@ -1041,10 +1254,57 @@
"undici-types@8.9.0": {
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="
},
"unist-util-is@6.0.1": {
"integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==",
"dependencies": [
"@types/unist"
]
},
"unist-util-position@5.0.0": {
"integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==",
"dependencies": [
"@types/unist"
]
},
"unist-util-stringify-position@4.0.0": {
"integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
"dependencies": [
"@types/unist"
]
},
"unist-util-visit-parents@6.1.0": {
"integrity": "sha512-vKXxz6O38sKDj1mtx/k2cWvkkFBuYGx6uGrlzBkVeWCRF/F8sdI0j3Wbkz/5rVNRRuVc8UrgRdbCxNhmYXgP3w==",
"dependencies": [
"@types/unist",
"unist-util-is"
]
},
"unist-util-visit@5.2.0": {
"integrity": "sha512-fpsYs/VVoZxfGY9/j3FQpZmN8wdLJaV1Pt38AaJNZu9uKIHcFU3halCdBveEq1HGKO1OEfJY65w1zvoFV1b3qQ==",
"dependencies": [
"@types/unist",
"unist-util-is",
"unist-util-visit-parents"
]
},
"uuid@14.0.3": {
"integrity": "sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==",
"bin": true
},
"vfile-message@4.0.4": {
"integrity": "sha512-66ycRswIkNmHH9PHku7ADtv5RVwgIrOcuv3J8Svz6h4qgGRrKVa+9/neuKyJZUXyOpYwLTvS+whZ4R2urHHgQg==",
"dependencies": [
"@types/unist",
"unist-util-stringify-position"
]
},
"vfile@6.0.3": {
"integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
"dependencies": [
"@types/unist",
"vfile-message"
]
},
"wrap-ansi@7.0.0": {
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dependencies": [
@@ -1086,13 +1346,17 @@
},
"zod@3.23.8": {
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g=="
},
"zwitch@2.0.4": {
"integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="
}
},
"workspace": {
"dependencies": [
"npm:marked@18.0.5",
"npm:mermaid@11.17.2",
"npm:puppeteer-core@23.11.1"
"npm:puppeteer-core@23.11.1",
"npm:shiki@4.5.0"
]
}
}
site/deploy.sh+1−1
@@ -21,7 +21,7 @@ ssh="ssh -p $SSH_PORT -o BatchMode=yes $SSH_TARGET"
out=site/out
site/build.sh
bad=$(cd "$out" && find . -mindepth 1 \( -name '.*' -o \( ! -type d ! -type f \) -o \( -type f ! -name '*.html' ! -name '*.css' ! -name '*.svg' ! -name '*.png' ! -name '*.ico' ! -name '*.txt' ! -name COMMIT \) \) -print)
bad=$(cd "$out" && find . -mindepth 1 \( -name '.*' -o \( ! -type d ! -type f \) -o \( -type f ! -name '*.html' ! -name '*.css' ! -name '*.svg' ! -name '*.png' ! -name '*.ico' ! -name '*.txt' ! -name COMMIT ! -path ./install.sh \) \) -print)
if [ -n "$bad" ]; then
echo "deploy: refusing: $out holds files that are not site files:" >&2
echo "$bad" >&2
site/index.md+2−1
@@ -331,4 +331,5 @@ receipt:
The protocol, record by record: [overview](docs/protocol/README.md), [one contract step by step](docs/protocol/flow.md),
[identity](docs/protocol/identity.md), [market](docs/protocol/market.md), [policy](docs/protocol/policy.md),
[guest events](docs/protocol/guest-events.md), [releases](docs/protocol/release.md),
[glossary](docs/protocol/glossary.md).
[glossary](docs/protocol/glossary.md). Every record and XRPC method, generated from the lexicons:
[lexicon and XRPC reference](lexicons/).
site/lexref.tsnew+331−0
@@ -0,0 +1,331 @@
type Json = Record<string, unknown>;
type Def = Json & { type: string; description?: string };
export type Lexicon = { id: string; file: string; description?: string; defs: Record<string, Def> };
export type RefPage = { out: string; title: string; body: string; aside: string };
export type Helpers = {
esc: (s: string) => string;
rel: (from: string, to: string) => string;
hl: (code: string, lang: string) => string;
};
const FAMILIES = [
"com.publicdomainrelay.temp",
"com.fedfork.exec",
"computer.socialweb",
"software.release",
"link.ident",
"network.attested",
"com.atproto",
];
const XRPC = new Set(["query", "procedure", "subscription"]);
export const lexiconOut = (nsid: string) => `docs/lexicons/${nsid}.html`;
const LEX_INDEX = "docs/lexicons/index.html";
const XRPC_INDEX = "docs/xrpc/index.html";
export async function loadLexicons(root: string): Promise<Map<string, Lexicon>> {
const lexs = new Map<string, Lexicon>();
const problems: string[] = [];
async function walk(rel: string) {
for await (const e of Deno.readDir(`${root}/${rel}`)) {
const p = `${rel}/${e.name}`;
if (e.isDirectory) await walk(p);
else if (p.endsWith(".json")) {
let j: Json;
try {
j = JSON.parse(await Deno.readTextFile(`${root}/${p}`));
} catch (err) {
problems.push(`${p}: not JSON: ${err}`);
continue;
}
const want = p.replace(/^lexicons\//, "").replace(/\.json$/, "").split("/").join(".");
if (j.lexicon !== 1) problems.push(`${p}: lexicon is not 1`);
if (j.id !== want) problems.push(`${p}: id ${j.id} is not ${want}`);
if (!j.defs || typeof j.defs !== "object") problems.push(`${p}: no defs`);
else lexs.set(want, { id: want, file: p, description: j.description as string | undefined, defs: j.defs as Record<string, Def> });
}
}
}
await walk("lexicons");
for (const lex of lexs.values()) {
for (const [name, def] of Object.entries(lex.defs)) {
if (typeof def?.type !== "string") problems.push(`${lex.file}: #${name} has no type`);
walkRefs(def, (ref) => {
const [nsid, frag] = splitRef(lex.id, ref);
const target = lexs.get(nsid);
if (!target) problems.push(`${lex.file}: #${name} refers to ${ref}: no lexicon ${nsid}`);
else if (!target.defs[frag]) problems.push(`${lex.file}: #${name} refers to ${ref}: ${nsid} has no #${frag}`);
});
}
}
if (problems.length) throw new Error(`lexicons:\n${problems.join("\n")}`);
return lexs;
}
function walkRefs(v: unknown, f: (ref: string) => void) {
if (Array.isArray(v)) return v.forEach((x) => walkRefs(x, f));
if (!v || typeof v !== "object") return;
const o = v as Json;
if (o.type === "ref" && typeof o.ref === "string") f(o.ref);
if (o.type === "union" && Array.isArray(o.refs)) (o.refs as string[]).forEach(f);
for (const x of Object.values(o)) walkRefs(x, f);
}
function splitRef(from: string, ref: string): [string, string] {
const [nsid, frag] = ref.split("#");
return [nsid || from, frag || "main"];
}
function family(nsid: string): string {
return FAMILIES.find((f) => nsid.startsWith(`${f}.`)) ?? nsid.split(".").slice(0, 2).join(".");
}
function group(nsid: string): string {
return nsid.split(".").slice(0, -1).join(".");
}
function firstSentence(s = ""): string {
const m = s.match(/^(.+?[.])(\s|$)/);
return (m ? m[1] : s).trim();
}
function mainType(lex: Lexicon): string {
return lex.defs.main?.type ?? "defs";
}
function sorted(lexs: Map<string, Lexicon>): Lexicon[] {
const rank = (n: string) => {
const i = FAMILIES.indexOf(family(n));
return i < 0 ? FAMILIES.length : i;
};
return [...lexs.values()].sort((a, b) => rank(a.id) - rank(b.id) || a.id.localeCompare(b.id));
}
function groups(list: Lexicon[]): Map<string, Map<string, Lexicon[]>> {
const fams = new Map<string, Map<string, Lexicon[]>>();
for (const lex of list) {
const fam = family(lex.id);
const g = group(lex.id);
if (!fams.has(fam)) fams.set(fam, new Map());
const gs = fams.get(fam)!;
if (!gs.has(g)) gs.set(g, []);
gs.get(g)!.push(lex);
}
return fams;
}
export function referencePages(lexs: Map<string, Lexicon>, h: Helpers): RefPage[] {
const { esc, rel } = h;
const list = sorted(lexs);
const fams = groups(list);
const badge = (t: string) => `<span class="badge t-${esc(t)}">${esc(t)}</span>`;
const nsidHtml = (nsid: string) => {
const i = nsid.lastIndexOf(".");
return `<span class="ns">${esc(nsid.slice(0, i + 1))}</span><span class="nm">${esc(nsid.slice(i + 1))}</span>`;
};
function aside(here: string, mode: "lexicons" | "xrpc"): string {
const parts: string[] = [
`<p class="nav-top"><a href="${esc(rel(here, LEX_INDEX))}"${here === LEX_INDEX ? ' aria-current="page"' : ""}>lexicons</a>` +
` <a href="${esc(rel(here, XRPC_INDEX))}"${here === XRPC_INDEX ? ' aria-current="page"' : ""}>xrpc</a></p>`,
];
for (const [fam, gs] of fams) {
const famShown = [...gs.values()].flat().filter((l) => mode !== "xrpc" || XRPC.has(mainType(l)));
if (!famShown.length) continue;
parts.push(`<p class="nav-fam">${esc(fam)}.*</p>`);
for (const [g, items] of gs) {
const shown = mode === "xrpc" ? items.filter((l) => XRPC.has(mainType(l))) : items;
if (!shown.length) continue;
const label = g === fam ? fam.split(".").pop()! : g.slice(fam.length + 1);
parts.push(`<p class="nav-group"><span>${esc(label)}</span><span class="count">${shown.length}</span></p><ul>`);
for (const l of shown) {
const target = lexiconOut(l.id);
const cur = target === here ? ' aria-current="page"' : "";
parts.push(`<li><a href="${esc(rel(here, target))}"${cur}>${esc(l.id.slice(g.length + 1))}</a></li>`);
}
parts.push("</ul>");
}
}
return parts.join("\n");
}
function refLink(here: string, from: string, ref: string): string {
const [nsid, frag] = splitRef(from, ref);
const href = rel(here, lexiconOut(nsid)) + (frag === "main" ? "" : `#${frag}`);
const text = ref.startsWith("#") ? ref : ref;
return `<a class="ref" href="${esc(href)}"><code>${esc(text)}</code></a>`;
}
function typeHtml(here: string, from: string, f: Json): string {
const t = String(f.type);
if (t === "ref") return refLink(here, from, String(f.ref));
if (t === "union") {
const refs = (f.refs as string[] ?? []).map((r) => refLink(here, from, r)).join(" | ");
return `<span class="ty">union</span>${f.closed ? " (closed)" : ""} ${refs}`;
}
if (t === "array") return `<span class="ty">array</span> of ${typeHtml(here, from, f.items as Json)}`;
const fmt = f.format ? ` <span class="fmt">${esc(String(f.format))}</span>` : "";
return `<span class="ty">${esc(t)}</span>${fmt}`;
}
function constraints(f: Json): string {
const out: string[] = [];
const show = (k: string, v: unknown) => out.push(`<span class="c"><span class="ck">${esc(k)}</span> <code>${esc(typeof v === "string" ? v : JSON.stringify(v))}</code></span>`);
for (const k of ["const", "default", "enum", "knownValues", "minimum", "maximum", "minLength", "maxLength", "minGraphemes", "maxGraphemes", "maxSize", "accept"]) {
if (f[k] !== undefined) show(k, f[k]);
}
if (f.type === "array") {
for (const k of ["minLength", "maxLength"]) if (f[k] !== undefined && !out.length) show(k, f[k]);
const it = f.items as Json | undefined;
if (it) for (const k of ["knownValues", "enum", "maxLength", "format"]) if (it[k] !== undefined) show(`items.${k}`, it[k]);
}
return out.join(" ");
}
function table(here: string, from: string, obj: Json, label: string, id: string): string {
const props = (obj.properties ?? {}) as Record<string, Json>;
const req = new Set((obj.required ?? []) as string[]);
const nullable = new Set((obj.nullable ?? []) as string[]);
const names = Object.keys(props);
if (!names.length) return `<p class="empty">${esc(label)}: none.</p>`;
const rows = names.map((n) => {
const f = props[n];
const mark = req.has(n) ? ' <span class="req" title="required">*</span>' : "";
const nul = nullable.has(n) ? ' <span class="fmt">nullable</span>' : "";
const desc = f.description ? `<div class="desc">${esc(String(f.description))}</div>` : "";
const c = constraints(f);
return `<tr id="${esc(id)}-${esc(n)}"><td class="pn"><code>${esc(n)}</code>${mark}</td><td>${typeHtml(here, from, f)}${nul}</td><td>${desc}${c ? `<div class="cons">${c}</div>` : ""}</td></tr>`;
}).join("\n");
return `<div class="table"><table class="props"><thead><tr><th>${esc(label)}</th><th>type</th><th>description</th></tr></thead><tbody>${rows}</tbody></table></div>`;
}
function body(here: string, from: string, schema: Json | undefined, label: string, id: string): string {
if (!schema) return "";
const enc = schema.encoding ? `<p class="meta">encoding <code>${esc(String(schema.encoding))}</code></p>` : "";
const s = schema.schema as Json | undefined;
const desc = schema.description ? `<p>${esc(String(schema.description))}</p>` : "";
let inner = "";
if (s) {
if (s.type === "object") inner = table(here, from, s, "field", id);
else inner = `<p>${typeHtml(here, from, s)}</p>`;
}
return `<h3 id="${esc(id)}">${esc(label)}</h3>${enc}${desc}${inner}`;
}
function errors(def: Def): string {
const errs = (def.errors ?? []) as Json[];
if (!errs.length) return "";
const rows = errs.map((e) => `<tr><td class="pn"><code>${esc(String(e.name))}</code></td><td>${esc(String(e.description ?? ""))}</td></tr>`).join("\n");
return `<h3 id="s-errors">errors</h3><div class="table"><table class="props"><thead><tr><th>error</th><th>description</th></tr></thead><tbody>${rows}</tbody></table></div>`;
}
function defSection(here: string, lex: Lexicon, name: string, def: Def): string {
const parts: string[] = [];
const isMain = name === "main";
if (!isMain) {
parts.push(`<h2 id="${esc(name)}" class="def"><a class="anchor" href="#${esc(name)}"><code>#${esc(name)}</code></a> ${badge(def.type)}</h2>`);
if (def.description) parts.push(`<p>${esc(def.description)}</p>`);
}
const t = def.type;
if (t === "record") {
parts.push(`<h3 id="s-record">record</h3>`);
const rec = def.record as Json;
if (rec?.description) parts.push(`<p>${esc(String(rec.description))}</p>`);
parts.push(table(here, lex.id, rec ?? {}, "field", "s-record"));
} else if (t === "query" || t === "procedure" || t === "subscription") {
const params = def.parameters as Json | undefined;
if (params) parts.push(`<h3 id="s-parameters">parameters</h3>${table(here, lex.id, params, "parameter", "s-parameters")}`);
parts.push(body(here, lex.id, def.input as Json | undefined, "input", "s-input"));
parts.push(body(here, lex.id, def.output as Json | undefined, "output", "s-output"));
parts.push(body(here, lex.id, def.message as Json | undefined, "message", "s-message"));
parts.push(errors(def));
} else if (t === "object") {
parts.push(table(here, lex.id, def, "field", isMain ? "s-fields" : name));
} else if (t === "array") {
parts.push(`<p>${typeHtml(here, lex.id, def)}</p>`);
} else {
const c = constraints(def);
parts.push(`<p>${typeHtml(here, lex.id, def)}${c ? ` <span class="cons">${c}</span>` : ""}</p>`);
}
return parts.join("\n");
}
const pages: RefPage[] = [];
for (const lex of list) {
const here = lexiconOut(lex.id);
const main = lex.defs.main;
const t = mainType(lex);
const meta: string[] = [badge(t)];
if (main?.key) meta.push(`<span class="kv">key <code>${esc(String(main.key))}</code></span>`);
if (main?.type === "query") meta.push(`<span class="kv">HTTP <code>GET /xrpc/${esc(lex.id)}</code></span>`);
if (main?.type === "procedure") meta.push(`<span class="kv">HTTP <code>POST /xrpc/${esc(lex.id)}</code></span>`);
if (main?.type === "subscription") meta.push(`<span class="kv">WebSocket <code>/xrpc/${esc(lex.id)}</code></span>`);
const others = Object.keys(lex.defs).filter((n) => n !== "main");
const toc = others.length
? `<p class="toc">definitions: ${others.map((n) => `<a href="#${esc(n)}"><code>#${esc(n)}</code></a>`).join(" ")}</p>`
: "";
const desc = main?.description ?? lex.description;
const sections = [main ? defSection(here, lex, "main", main) : "", ...others.map((n) => defSection(here, lex, n, lex.defs[n]))];
const raw = h.hl(JSON.stringify({ lexicon: 1, id: lex.id, ...(lex.description ? { description: lex.description } : {}), defs: lex.defs }, null, 2), "json");
const body = [
`<p class="kicker">lexicon</p>`,
`<h1 class="nsid">${nsidHtml(lex.id)}</h1>`,
`<p class="meta">${meta.join(" ")}</p>`,
desc ? `<p class="lede">${esc(desc)}</p>` : "",
toc,
...sections,
`<details id="raw" class="raw"><summary>raw schema: <code>${esc(lex.file)}</code></summary>${raw}</details>`,
].join("\n");
pages.push({ out: here, title: lex.id, body, aside: aside(here, XRPC.has(t) ? "xrpc" : "lexicons") });
}
const index: string[] = [
`<p class="kicker">reference</p>`,
`<h1 class="nsid"><span class="nm">Lexicons</span></h1>`,
`<p class="lede">Every record, object and XRPC method of the socialweb.computer market, generated from the repository's <code>lexicons/</code> (${list.length} lexicons). XRPC methods only: <a href="${esc(rel(LEX_INDEX, XRPC_INDEX))}">xrpc</a>.</p>`,
];
for (const [fam, gs] of fams) {
const n = [...gs.values()].reduce((a, b) => a + b.length, 0);
index.push(`<h2 id="${esc(fam)}">${esc(fam)}.* <span class="count">${n}</span></h2>`);
for (const [g, items] of gs) {
index.push(`<h3 id="${esc(g)}">${esc(g)}</h3><div class="table"><table class="props"><tbody>`);
for (const l of items) {
index.push(`<tr><td class="pn"><a href="${esc(rel(LEX_INDEX, lexiconOut(l.id)))}"><code>${esc(l.id.slice(g.length + 1))}</code></a></td><td>${badge(mainType(l))}</td><td>${esc(firstSentence(l.defs.main?.description ?? l.description))}</td></tr>`);
}
index.push(`</tbody></table></div>`);
}
}
pages.push({ out: LEX_INDEX, title: "Lexicons", body: index.join("\n"), aside: aside(LEX_INDEX, "lexicons") });
const methods = list.filter((l) => XRPC.has(mainType(l)));
const xi: string[] = [
`<p class="kicker">reference</p>`,
`<h1 class="nsid"><span class="nm">XRPC</span></h1>`,
`<p class="lede">The ${methods.length} XRPC methods (queries, procedures, subscriptions) the market's services serve at <code>/xrpc/&lt;nsid&gt;</code>, generated from <code>lexicons/</code>. Records and objects: <a href="${esc(rel(XRPC_INDEX, LEX_INDEX))}">lexicons</a>.</p>`,
];
for (const [, gs] of fams) {
for (const [g, items] of gs) {
const ms = items.filter((l) => XRPC.has(mainType(l)));
if (!ms.length) continue;
xi.push(`<h2 id="${esc(g)}">${esc(g)} <span class="count">${ms.length}</span></h2><div class="table"><table class="props"><tbody>`);
for (const l of ms) {
xi.push(`<tr><td class="pn"><a href="${esc(rel(XRPC_INDEX, lexiconOut(l.id)))}"><code>${esc(l.id.slice(g.length + 1))}</code></a></td><td>${badge(mainType(l))}</td><td>${esc(firstSentence(l.defs.main?.description))}</td></tr>`);
}
xi.push(`</tbody></table></div>`);
}
}
pages.push({ out: XRPC_INDEX, title: "XRPC", body: xi.join("\n"), aside: aside(XRPC_INDEX, "xrpc") });
return pages;
}
export function nsidLookup(lexs: Map<string, Lexicon>): (text: string) => string | undefined {
const ids = [...lexs.keys()];
return (text: string) => {
const t = text.trim();
if (!/^[a-zA-Z][\w.]*[a-zA-Z0-9]$/.test(t) || !t.includes(".")) return undefined;
if (lexs.has(t)) return t;
if (lexs.has(`com.publicdomainrelay.temp.${t}`)) return `com.publicdomainrelay.temp.${t}`;
const hits = ids.filter((id) => id.endsWith(`.${t}`));
return hits.length === 1 ? hits[0] : undefined;
};
}
site/README.md+12−8
@@ -6,16 +6,20 @@ The source of https://socialweb.computer/. The landing page is [index.md](index.
section's body. `build.ts` renders it to `out/index.html`, the user docs and the protocol docs (its `DOCS` list) to
`out/docs/`, and [fancy/](fancy/) (the owner's Compute Contracts pages, first written as the multi-page site of
github.com/publicdomainrelay/social-web-computer, updated for today) to `out/fancy/`. The look is the one of
https://console.socialweb.computer (`style.css`): the landing page on white, the docs and `fancy/` pages in the
console's dark theme, monospace type, code blocks and framed panels like the console's terminal and panels. A link to a rendered doc (or to README.md) goes to its page; any other repository link goes to the file on
https://knotless.dev/socialweb.computer/socialweb-computer-kcp (main); the build fails on a link to a missing page or
anchor. A ```` ```mermaid ```` block becomes an inline SVG at build time (no script on the page). The footer and
`out/COMMIT` name the commit.
https://console.socialweb.computer (`style.css`) on white pages: monospace type, the console's header bar, and code
blocks and framed panels like its terminal. A link to a rendered doc (or to README.md) goes to its page; any other
repository link goes to the file on https://knotless.dev/socialweb.computer/socialweb-computer-kcp (main); the build
fails on a link to a missing page or anchor. A ```` ```mermaid ```` block becomes an inline SVG at build time, and a
fenced block with a language is highlighted at build time (shiki, theme tokyo-night, colours raised to WCAG AA on
the dark block); no script on any page. `lexref.ts` generates the lexicon and XRPC reference from `lexicons/**/*.json`
(`out/docs/lexicons/<nsid>.html`, `out/docs/lexicons/index.html`, `out/docs/xrpc/index.html`); a malformed lexicon or a
ref to a missing def fails the build. `out/install.sh` is `scripts/install.sh` of the commit, byte for byte
(`curl -sfL https://socialweb.computer/install.sh | bash -e`). The footer and `out/COMMIT` name the commit.
Dependencies, all pinned: jq, git; deno and Chrome as pinned in `tests/compositions/staging/page-tools.json` (`deno.sh`
and `build.sh` use PATH's `deno` and `google-chrome` when they are those versions, else fetch them with
`tests/compositions/staging/tools.sh`, which checks their sha256; Chrome for Testing is linux/amd64 only); marked,
mermaid and puppeteer-core in `deno.json`, locked in `deno.lock`.
mermaid, puppeteer-core and shiki in `deno.json`, locked in `deno.lock`.
Build, then look at `site/out/index.html`:
@@ -24,8 +28,8 @@ site/build.sh
```
Deploy (ssh as root to the gateway, port 1997; `--dry-run` prints what would change and stops). It refuses a tree with
uncommitted changes or a commit on no `swc` branch, and anything in `out/` but html, css, svg, png, ico, txt and
`COMMIT`; it saves the tree it replaces to `/var/backups/socialweb.computer-<UTC time>.tgz` on the gateway, swaps in
uncommitted changes or a commit on no `swc` branch, and anything in `out/` but html, css, svg, png, ico, txt,
`COMMIT` and `install.sh`; it saves the tree it replaces to `/var/backups/socialweb.computer-<UTC time>.tgz` on the gateway, swaps in
the new one and checks every file against what https://socialweb.computer/ serves. Caddy is not touched: its site
block for socialweb.computer is in the gateway's `/etc/caddy/Caddyfile`.
site/style.css+263−52
@@ -1,39 +1,21 @@
:root {
color-scheme: light;
--term-bg: #0b0e14;
--term-panel: #11151f;
--term-border: #1f2633;
--term-fg: #d5dbe5;
--term-muted: #7c869a;
--term-muted: #8b95a8;
--term-accent: #7aa2f7;
--term-ok: #9ece6a;
--term-warn: #e0af68;
--term-critical: #ef8b8b;
--term-deep: #070a10;
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
body.console {
color-scheme: dark;
--bg: var(--term-bg);
--fg: var(--term-fg);
--muted: #8b95a8;
--link: var(--term-accent);
--mark: var(--term-ok);
--rule: var(--term-border);
--inline-bg: #151a25;
--inline-fg: #e3e8f0;
}
body.paper {
color-scheme: light;
--bg: #ffffff;
--fg: #1b1f24;
--muted: #57606a;
--link: #2a56c6;
--mark: #2f7d32;
--rule: #d0d7de;
--soft: #f6f8fa;
--inline-bg: #eef1f5;
--inline-fg: #1b1f24;
}
* {
@@ -81,7 +63,7 @@ header.bar .name a {
}
header.bar .meta {
color: #8b95a8;
color: var(--term-muted);
}
header.bar nav {
@@ -108,7 +90,7 @@ nav.subnav {
}
nav.subnav a {
color: #8b95a8;
color: var(--term-muted);
text-decoration: none;
}
@@ -164,7 +146,7 @@ code {
font-family: var(--mono);
font-size: 0.92em;
background: var(--inline-bg);
color: var(--inline-fg);
color: var(--fg);
border-radius: 4px;
padding: 0.08em 0.32em;
}
@@ -203,7 +185,7 @@ pre code {
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.08em;
color: #8b95a8;
color: var(--term-muted);
}
.panel iframe {
@@ -228,6 +210,7 @@ pre code {
border: 1px solid var(--rule);
border-left: 4px solid var(--link);
border-radius: 6px;
background: var(--soft);
}
.callout-title {
@@ -238,32 +221,15 @@ pre code {
font-size: 0.85em;
}
body.console .callout.caution, body.console .callout.warning {
border-left-color: var(--term-critical);
background: #1d1416;
}
body.console .callout.caution .callout-title, body.console .callout.warning .callout-title {
color: var(--term-critical);
}
body.console .callout.note, body.console .callout.tip, body.console .callout.important {
background: var(--term-panel);
}
body.paper .callout.caution, body.paper .callout.warning {
.callout.caution, .callout.warning {
border-left-color: #b42318;
background: #fff5f5;
}
body.paper .callout.caution .callout-title, body.paper .callout.warning .callout-title {
.callout.caution .callout-title, .callout.warning .callout-title {
color: #b42318;
}
body.paper .callout.note, body.paper .callout.tip, body.paper .callout.important {
background: #f6f8fa;
}
blockquote {
margin: 1em 0;
padding: 0 1em;
@@ -290,14 +256,7 @@ th, td {
th {
font-weight: 600;
}
body.console th {
background: var(--term-panel);
}
body.paper th {
background: #f6f8fa;
background: var(--soft);
}
ul, ol {
@@ -325,6 +284,258 @@ footer code {
font-size: 1em;
}
main.ref {
max-width: 1240px;
}
.ref-grid {
display: grid;
grid-template-columns: 250px minmax(0, 1fr);
gap: 32px;
}
aside.refnav {
position: sticky;
top: 0;
align-self: start;
max-height: 100vh;
overflow-y: auto;
padding: 16px 0 24px;
font-size: 13px;
border-right: 1px solid var(--rule);
}
aside.refnav ul, .refnav-phone ul {
list-style: none;
margin: 0 0 10px;
padding: 0;
}
aside.refnav li a, .refnav-phone li a {
display: block;
padding: 1px 10px;
color: var(--fg);
text-decoration: none;
border-left: 2px solid transparent;
}
aside.refnav li a:hover, .refnav-phone li a:hover {
color: var(--link);
}
aside.refnav a[aria-current="page"], .refnav-phone a[aria-current="page"] {
border-left-color: var(--mark);
font-weight: 700;
}
.nav-top {
display: flex;
gap: 14px;
margin: 0 0 12px;
padding: 0 10px;
font-weight: 700;
}
.nav-top a[aria-current="page"] {
color: var(--fg);
text-decoration: none;
}
.nav-group {
display: flex;
justify-content: space-between;
gap: 8px;
margin: 14px 10px 4px 0;
padding-left: 10px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.06em;
color: var(--muted);
word-break: break-all;
}
.count {
color: var(--muted);
font-weight: 400;
font-size: 0.85em;
white-space: nowrap;
}
.nav-fam {
margin: 18px 0 2px;
padding: 2px 10px;
font-size: 11px;
font-weight: 700;
color: var(--fg);
background: var(--soft);
border-radius: 4px;
word-break: break-all;
}
.refnav-phone {
display: none;
margin: 12px 0;
padding: 6px 10px;
border: 1px solid var(--rule);
border-radius: 6px;
font-size: 13px;
}
.refnav-phone summary {
cursor: pointer;
font-weight: 700;
}
.ref-body {
min-width: 0;
padding-top: 8px;
}
.ref-body h1::before, .ref-body h2::before, .ref-body h3::before {
content: none;
}
.kicker {
margin: 1.4em 0 0;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--muted);
}
h1.nsid {
margin-top: 0.2em;
font-size: 1.45em;
word-break: break-all;
}
h1.nsid .ns {
color: var(--muted);
font-weight: 400;
}
.meta {
display: flex;
flex-wrap: wrap;
gap: 6px 14px;
align-items: center;
color: var(--muted);
font-size: 0.92em;
}
.meta .kv {
min-width: 0;
overflow-wrap: anywhere;
}
.lede {
font-size: 1.02em;
}
.ref-body p {
overflow-wrap: anywhere;
}
.toc {
font-size: 0.92em;
color: var(--muted);
}
.badge {
display: inline-block;
padding: 1px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
border: 1px solid currentColor;
}
.badge.t-record { color: #1f6f2b; background: #eaf6ec; }
.badge.t-query { color: #1c5aa8; background: #e8f0fb; }
.badge.t-procedure { color: #8a4b00; background: #fdf1e2; }
.badge.t-subscription { color: #6b3fa0; background: #f3ecfb; }
.badge.t-object, .badge.t-token, .badge.t-string, .badge.t-array, .badge.t-defs { color: #4b5563; background: var(--soft); }
h2.def {
font-size: 1.1em;
margin-top: 2em;
}
h2.def code {
font-size: 1em;
}
table.props {
width: 100%;
}
table.props td.pn {
white-space: nowrap;
}
table.props .desc {
margin-bottom: 2px;
}
.req {
color: #b42318;
font-weight: 700;
}
.ty {
color: var(--mark);
font-weight: 600;
}
.fmt {
color: var(--muted);
font-size: 0.9em;
}
.cons {
color: var(--muted);
font-size: 0.9em;
}
.cons .c {
display: inline-block;
margin-right: 10px;
}
.empty {
color: var(--muted);
}
details.raw {
margin: 2em 0 1em;
}
details.raw summary {
cursor: pointer;
color: var(--muted);
}
@media (max-width: 860px) {
.ref-grid {
display: block;
}
aside.refnav {
display: none;
}
.refnav-phone {
display: block;
}
table.props td.pn {
white-space: normal;
}
}
@media (max-width: 600px) {
body {
font-size: 14px;
AGENTS.md+1−2
@@ -56,8 +56,7 @@ TypeScript:
| `scripts/*.ts` | one-off operator scripts (`oauth-signin.ts`, `associate-bidder.ts`, `publish-spaces.ts`), run with `deno run` |
| `internal/policyengine/bundled-actions/tangy/<action>/` | one policy action: `index.ts` and its built `dist/index.js`, embedded by the policy engine |
There is no deno workspace and no vendored TypeScript repository here any more; the one lockfile is `site/deno.lock` (the markdown renderer, mermaid and puppeteer-core for the site build)
(the site's markdown renderer).
There is no deno workspace and no vendored TypeScript repository here any more; the one lockfile is `site/deno.lock` (the site build: the markdown renderer, shiki, mermaid and puppeteer-core).
## The TypeScript that is left
README.md+8−1
@@ -5,7 +5,14 @@ bidder, a bidder sells its host's VMs, and both are atproto accounts that vouch
## Install
Linux amd64 or arm64, the current release of channel `stable` (`rc` for the release candidate), from a clone:
Linux amd64 or arm64, the current release of channel `stable`:
```sh
curl -sfL https://socialweb.computer/install.sh | bash -e
echo 'export PATH="$HOME/.local/bin:$PATH"' | tee -a ~/.bashrc ~/.bash_profile
```
Or from a clone (`rc` for the release candidate):
```sh
git clone --depth 1 https://knotless.dev/socialweb.computer/socialweb-computer-kcp