804 lines
33 KiB
HTML
804 lines
33 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<link rel="canonical" href="https://daochi.net/nodes.html">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Daochi Nodes</title>
|
|
<meta name="description" content="Known Daochi nodes and the apps registered with each node.">
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:url" content="https://daochi.net/nodes.html">
|
|
<meta property="og:title" content="Daochi Nodes">
|
|
<meta property="og:description" content="Known Daochi nodes, storage usage, apps, peers, readiness, and protocol bounds.">
|
|
<meta property="og:image" content="https://daochi.net/assets/editorial/connected-islands.png">
|
|
<meta property="og:image:secure_url" content="https://daochi.net/assets/editorial/connected-islands.png">
|
|
<meta property="og:image:alt" content="Quiet islands joined by small bridges, illustrated in ink and sage watercolor.">
|
|
<meta property="og:image:width" content="1536">
|
|
<meta property="og:image:height" content="1024">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:title" content="Daochi Nodes">
|
|
<meta name="twitter:description" content="Known Daochi nodes, storage usage, apps, peers, readiness, and protocol bounds.">
|
|
<meta name="twitter:image" content="https://daochi.net/assets/editorial/connected-islands.png">
|
|
<meta name="twitter:image:alt" content="Quiet islands joined by small bridges, illustrated in ink and sage watercolor.">
|
|
<meta name="theme-color" content="#f7f3eb">
|
|
<link rel="icon" href="/favicon.ico" sizes="any">
|
|
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
|
|
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
|
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
<link rel="manifest" href="/manifest.json">
|
|
<link rel="stylesheet" href="/styles.css?v=editorial-20260919">
|
|
</head>
|
|
<body>
|
|
<a class="skip-link" href="#main">Skip to content</a>
|
|
<header class="topbar">
|
|
<a class="brand" href="/">Daochi</a>
|
|
<nav class="nav" aria-label="Primary">
|
|
<a href="/protocol.html">Protocol</a>
|
|
<a href="/mesh.html">Mesh</a>
|
|
<a href="/apps.html">Apps</a>
|
|
<a href="/nodes.html" aria-current="page">Nodes</a>
|
|
<a href="/tokens.html">Tokens</a>
|
|
<a href="https://api.waozi.xyz/openapi.json">API</a>
|
|
</nav>
|
|
</header>
|
|
|
|
<main id="main">
|
|
<section class="page-hero">
|
|
<p class="eyebrow">Nodes</p>
|
|
<h1>Meet the nodes.</h1>
|
|
<p class="lead">Each Daochi node publishes its peer nodes, accepted tokens, app manifests, node-level capabilities, readiness checks, and protocol bounds.</p>
|
|
</section>
|
|
|
|
<section class="node-browser" aria-label="Daochi node map">
|
|
<div class="node-map-card">
|
|
<div class="node-map-heading">
|
|
<div>
|
|
<p class="section-label">Node Canvas</p>
|
|
<h2>Network view</h2>
|
|
</div>
|
|
<div id="node-map-count" class="node-map-count">loading</div>
|
|
</div>
|
|
<div class="node-canvas-wrap">
|
|
<canvas id="node-canvas" width="920" height="520" aria-label="Daochi node connection canvas"></canvas>
|
|
</div>
|
|
<div id="node-rail" class="node-rail" aria-label="Node selector"></div>
|
|
</div>
|
|
|
|
<aside class="node-detail-shell">
|
|
<div id="node-detail" class="node-detail" aria-live="polite">
|
|
<article class="node-card">
|
|
<h3>Loading nodes</h3>
|
|
<p>Checking configured Daochi nodes.</p>
|
|
</article>
|
|
</div>
|
|
</aside>
|
|
</section>
|
|
</main>
|
|
|
|
<footer class="footer">
|
|
<span>Daochi · A <a href="https://kryonlabs.com">Kryon Labs</a> project</span>
|
|
<a href="https://waozi.xyz/#labs">More from Waozi ↗</a>
|
|
<span>Post-quantum account authority for app-owned sync.</span>
|
|
</footer>
|
|
|
|
<script>
|
|
const canvas = document.getElementById("node-canvas");
|
|
const ctx = canvas.getContext("2d");
|
|
const detail = document.getElementById("node-detail");
|
|
const rail = document.getElementById("node-rail");
|
|
const count = document.getElementById("node-map-count");
|
|
|
|
const state = {
|
|
nodes: [],
|
|
edges: [],
|
|
selected: 0,
|
|
hover: -1,
|
|
tab: "overview",
|
|
hitAreas: [],
|
|
dpr: 1
|
|
};
|
|
|
|
const MAX_DISCOVERED_NODES = 24;
|
|
const MAX_CANVAS_DPR = 4;
|
|
|
|
function plain(value, fallback = "") {
|
|
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
}
|
|
|
|
function escapeHTML(value) {
|
|
return String(value)
|
|
.replaceAll("&", "&")
|
|
.replaceAll("<", "<")
|
|
.replaceAll(">", ">")
|
|
.replaceAll('"', """)
|
|
.replaceAll("'", "'");
|
|
}
|
|
|
|
function text(value, fallback = "") {
|
|
return escapeHTML(plain(value, fallback));
|
|
}
|
|
|
|
function attr(value) {
|
|
return escapeHTML(plain(value));
|
|
}
|
|
|
|
function normalizeURL(value) {
|
|
return plain(value).replace(/\/+$/, "");
|
|
}
|
|
|
|
function join(items) {
|
|
return Array.isArray(items) && items.length ? items.map((item) => text(item)).join(", ") : "none declared";
|
|
}
|
|
|
|
function itemList(items, renderItem, fallback = "none declared") {
|
|
if (!Array.isArray(items) || !items.length) return `<p>${text(fallback)}</p>`;
|
|
return `<ul class="detail-list">${items.map(renderItem).join("")}</ul>`;
|
|
}
|
|
|
|
function dateTime(value) {
|
|
if (!value) return "";
|
|
if (typeof value === "number") return escapeHTML(new Date(value * 1000).toISOString());
|
|
return text(value);
|
|
}
|
|
|
|
function formatBytes(value) {
|
|
const bytes = Number(value || 0);
|
|
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
|
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
let n = bytes;
|
|
let unit = 0;
|
|
while (n >= 1024 && unit < units.length - 1) {
|
|
n /= 1024;
|
|
unit++;
|
|
}
|
|
const precision = unit === 0 || n >= 100 ? 0 : n >= 10 ? 1 : 2;
|
|
return `${n.toFixed(precision)} ${units[unit]}`;
|
|
}
|
|
|
|
function resultLabel(result) {
|
|
if (!result) return "not checked";
|
|
if (result.ok) return `${result.status} ok`;
|
|
return result.status ? `${result.status} unavailable` : "unavailable";
|
|
}
|
|
|
|
function detailRows(rows) {
|
|
if (!Array.isArray(rows) || !rows.length) return "<p>none</p>";
|
|
return `<dl class="detail-grid">${rows.map(([label, value]) => `
|
|
<div><dt>${text(label)}</dt><dd>${value || "none"}</dd></div>
|
|
`).join("")}</dl>`;
|
|
}
|
|
|
|
function disclosure(title, body, options = {}) {
|
|
const open = options.open ? " open" : "";
|
|
const meta = options.meta ? `<span>${text(options.meta)}</span>` : "";
|
|
return `
|
|
<details class="detail-section"${open}>
|
|
<summary><strong>${text(title)}</strong>${meta}</summary>
|
|
<div class="detail-section-body">${body}</div>
|
|
</details>
|
|
`;
|
|
}
|
|
|
|
async function fetchJSON(url) {
|
|
try {
|
|
const response = await fetch(url, { cache: "no-store" });
|
|
let data = {};
|
|
try {
|
|
data = await response.json();
|
|
} catch (error) {
|
|
data = {};
|
|
}
|
|
return { ok: response.ok, status: response.status, data };
|
|
} catch (error) {
|
|
return { ok: false, status: 0, data: {}, error: String(error) };
|
|
}
|
|
}
|
|
|
|
function link(url, label) {
|
|
const href = plain(url);
|
|
if (!href) return "";
|
|
return `<a href="${attr(href)}">${text(label)}</a>`;
|
|
}
|
|
|
|
function peerList(value) {
|
|
if (!Array.isArray(value)) return [];
|
|
const peers = [];
|
|
const seen = new Set();
|
|
for (const item of value) {
|
|
const peer = typeof item === "string" ? { url: item } : item || {};
|
|
const url = normalizeURL(peer.url || peer.base_url);
|
|
if (!url || seen.has(url)) continue;
|
|
seen.add(url);
|
|
peers.push({ name: plain(peer.name, url), url, sync: peer.sync || null });
|
|
}
|
|
return peers;
|
|
}
|
|
|
|
function syncPolicyText(policy) {
|
|
if (!policy) return "sync policy not declared";
|
|
const parts = [];
|
|
if (policy.direction) parts.push(text(policy.direction));
|
|
if (Array.isArray(policy.apps) && policy.apps.length) parts.push(`apps ${policy.apps.map((item) => text(item)).join(", ")}`);
|
|
if (Array.isArray(policy.collections) && policy.collections.length) parts.push(`collections ${policy.collections.map((item) => text(item)).join(", ")}`);
|
|
if (Array.isArray(policy.data) && policy.data.length) parts.push(`data ${policy.data.map((item) => text(item)).join(", ")}`);
|
|
return parts.length ? parts.join(" / ") : "sync policy not declared";
|
|
}
|
|
|
|
function mergePeers(...lists) {
|
|
const merged = [];
|
|
const seen = new Set();
|
|
for (const list of lists) {
|
|
for (const peer of list) {
|
|
const url = normalizeURL(peer.url);
|
|
if (!url || seen.has(url)) continue;
|
|
seen.add(url);
|
|
merged.push({ name: plain(peer.name, url), url });
|
|
}
|
|
}
|
|
return merged;
|
|
}
|
|
|
|
function appMarkup(app) {
|
|
const collections = Array.isArray(app.collections) ? app.collections : [];
|
|
const features = Array.isArray(app.features) ? app.features : [];
|
|
const legacy = Array.isArray(app.legacy_protocols) ? app.legacy_protocols : [];
|
|
const links = [link(app.homepage_url, "homepage"), link(app.source_url, "source")].filter(Boolean).join(" / ");
|
|
const keys = Array.isArray(app.keys) ? app.keys : [];
|
|
const tokenPolicies = Array.isArray(app.token_policies) ? app.token_policies : [];
|
|
return `
|
|
<details class="app-card app-disclosure">
|
|
<summary>
|
|
<span>
|
|
<strong>${text(app.display_name, app.app_id)}</strong>
|
|
<em><code>${text(app.app_id)}</code> / ${text(app.status, "unknown")} / ${features.length} features / ${collections.length} collections</em>
|
|
</span>
|
|
</summary>
|
|
<p><code>${text(app.app_id)}</code> ${links ? " / " + links : ""}</p>
|
|
<div class="tag-row">
|
|
<span>${text(app.status, "unknown")}</span>
|
|
<span>schema v${Number(app.app_schema_version || 0)}</span>
|
|
${app.min_supported_client_version ? `<span>min client ${text(app.min_supported_client_version)}</span>` : ""}
|
|
${app.current_client_version ? `<span>client ${text(app.current_client_version)}</span>` : ""}
|
|
${app.compatibility_until ? `<span>compat until ${text(app.compatibility_until)}</span>` : ""}
|
|
${app.manifest_hash ? `<span>signed manifest</span>` : ""}
|
|
</div>
|
|
<p>${text(app.description, "No description provided.")}</p>
|
|
<p><strong>Capabilities</strong> ${join(app.capabilities)}</p>
|
|
${disclosure("Registration", detailRows([
|
|
["App ID", `<code>${text(app.app_id)}</code>`],
|
|
["Created", text(app.created_at)],
|
|
["Updated", text(app.updated_at)],
|
|
["Manifest version", app.manifest_version ? `v${Number(app.manifest_version)}` : ""],
|
|
["Manifest expires", dateTime(app.manifest_expires_at)],
|
|
["Public key", app.public_key ? `<code>${text(app.public_key)}</code>` : ""],
|
|
["Manifest hash", app.manifest_hash ? `<code>${text(app.manifest_hash)}</code>` : ""],
|
|
["Manifest signature", app.manifest_signature ? `<code>${text(app.manifest_signature)}</code>` : ""],
|
|
["Approval signature", app.approval_signature ? `<code>${text(app.approval_signature)}</code>` : ""]
|
|
]), { open: true })}
|
|
${disclosure("Features", itemList(features, (item) => `
|
|
<li>
|
|
<code>${text(item.id)}</code>
|
|
${item.requires_signed_tx ? `<span>signed transaction required</span>` : `<span>read/public</span>`}
|
|
${Array.isArray(item.collections) && item.collections.length ? `<em>${item.collections.map((collection) => text(collection)).join(", ")}</em>` : ""}
|
|
</li>`), { meta: `${features.length} declared` })}
|
|
${disclosure("Collections", itemList(collections, (item) => `
|
|
<li>
|
|
<code>${text(item.collection_prefix)}</code>
|
|
<span>${text(item.visibility, "private")}${item.schema_version ? ` schema v${Number(item.schema_version)}` : ""}${item.created_at ? ` created ${text(item.created_at)}` : ""}</span>
|
|
${item.description ? `<em>${text(item.description)}</em>` : ""}
|
|
</li>`), { meta: `${collections.length} prefixes` })}
|
|
${disclosure("Legacy Protocols", itemList(legacy, (item) => `
|
|
<li>
|
|
<code>${text(item.name)}</code>
|
|
<span>${text(item.status, "compatibility")}${item.version ? ` v${Number(item.version)}` : ""} until ${text(item.valid_until, "unspecified")}</span>
|
|
</li>`, "none"), { meta: `${legacy.length} policies` })}
|
|
${disclosure("Keys", itemList(keys, (item) => `
|
|
<li>
|
|
<code>${text(item.key_id)}</code>
|
|
<span>${text(item.algorithm)} ${text(item.purpose)} ${text(item.status, "active")}</span>
|
|
${item.expires_at ? `<em>expires ${dateTime(item.expires_at)}</em>` : ""}
|
|
</li>`, "none"), { meta: `${keys.length} keys` })}
|
|
${disclosure("Token Policies", itemList(tokenPolicies, (item) => `
|
|
<li>
|
|
<code>${text(item.asset_id)}</code>
|
|
<span>${text(item.permission)} ${text(item.status, "active")}</span>
|
|
</li>`, "none"), { meta: `${tokenPolicies.length} policies` })}
|
|
</details>
|
|
`;
|
|
}
|
|
|
|
function storageAppMarkup(app) {
|
|
const collections = Array.isArray(app.collections) ? app.collections : [];
|
|
return `
|
|
<details class="app-card app-disclosure">
|
|
<summary>
|
|
<span>
|
|
<strong>${text(app.display_name, app.app_id)}</strong>
|
|
<em><code>${text(app.app_id)}</code> / ${formatBytes(app.logical_bytes)} / ${Number(app.record_count || 0)} records</em>
|
|
</span>
|
|
</summary>
|
|
${detailRows([
|
|
["Logical bytes", formatBytes(app.logical_bytes)],
|
|
["Encrypted record bytes", formatBytes(app.record_bytes)],
|
|
["Encrypted records", String(Number(app.record_count || 0))]
|
|
])}
|
|
${disclosure("Collections", itemList(collections, (item) => `
|
|
<li>
|
|
<code>${text(item.collection)}</code>
|
|
<span>${formatBytes(item.logical_bytes)} / ${Number(item.record_count || 0)} records</span>
|
|
${item.collection_prefix ? `<em>matched ${text(item.collection_prefix)}</em>` : ""}
|
|
</li>`, "No stored records."), { meta: `${collections.length} stored` })}
|
|
</details>
|
|
`;
|
|
}
|
|
|
|
function tokenMarkup(asset, issuer) {
|
|
return `
|
|
<article class="token-card">
|
|
<div>
|
|
<h4>${text(asset.display_name, asset.asset_id)}</h4>
|
|
<p><code>${text(asset.asset_id)}</code></p>
|
|
</div>
|
|
<div class="tag-row">
|
|
<span>${text(asset.status, "unknown")}</span>
|
|
<span>issuer ${text(asset.issuer_id, "unknown")}</span>
|
|
<span>${Number(asset.decimals || 0)} decimals</span>
|
|
</div>
|
|
${issuer && issuer.issuer_id === asset.issuer_id ? detailRows([
|
|
["Issuer status", text(issuer.status)],
|
|
["Issuer algorithm", text(issuer.algorithm)],
|
|
["Issuer public key", issuer.public_key ? `<code>${text(issuer.public_key)}</code>` : ""]
|
|
]) : ""}
|
|
</article>
|
|
`;
|
|
}
|
|
|
|
function productMarkup(product) {
|
|
return `
|
|
<li>
|
|
<code>${text(product.product_id)}</code>
|
|
<span>${Number(product.token_units || 0)} token units${product.monero_atomic_amount ? ` / ${Number(product.monero_atomic_amount)} atomic XMR` : ""}</span>
|
|
</li>
|
|
`;
|
|
}
|
|
|
|
async function appDetail(nodeUrl, app) {
|
|
const appID = plain(app.app_id);
|
|
if (!appID) return app;
|
|
try {
|
|
const response = await fetch(`${nodeUrl}/api/v1/apps/${encodeURIComponent(appID)}`, { cache: "no-store" });
|
|
if (!response.ok) return app;
|
|
return await response.json();
|
|
} catch (error) {
|
|
return app;
|
|
}
|
|
}
|
|
|
|
async function loadNode(node, index) {
|
|
const nodeUrl = normalizeURL(node.url);
|
|
const declaredPeers = peerList(node.peers);
|
|
const [nodeInfo, health, ready, appsResult, tokenResult, issuerResult, productResult] = await Promise.all([
|
|
fetchJSON(`${nodeUrl}/api/v1/node`),
|
|
fetchJSON(`${nodeUrl}/healthz`),
|
|
fetchJSON(`${nodeUrl}/readyz`),
|
|
fetchJSON(`${nodeUrl}/api/v1/apps`),
|
|
fetchJSON(`${nodeUrl}/api/v1/tokens/assets`),
|
|
fetchJSON(`${nodeUrl}/api/v1/tokens/issuer`),
|
|
fetchJSON(`${nodeUrl}/api/v1/tokens/products`)
|
|
]);
|
|
const readiness = ready.data && ready.data.checks ? ready.data.checks : {};
|
|
const tokens = Array.isArray(tokenResult.data.assets) ? tokenResult.data.assets : [];
|
|
const products = Array.isArray(productResult.data.products) ? productResult.data.products : [];
|
|
const apps = Array.isArray(appsResult.data.apps) ? appsResult.data.apps : [];
|
|
const registrations = await Promise.all(apps.map((app) => appDetail(nodeUrl, app)));
|
|
const publishedPeers = peerList(nodeInfo.data.known_nodes);
|
|
const peers = mergePeers(declaredPeers, publishedPeers);
|
|
const online = health.ok && appsResult.ok && tokenResult.ok;
|
|
return {
|
|
index,
|
|
name: plain(node.name, nodeUrl),
|
|
url: nodeUrl,
|
|
online,
|
|
status: online ? "online" : "degraded",
|
|
nodeInfo,
|
|
health,
|
|
ready,
|
|
appsResult,
|
|
tokenResult,
|
|
issuerResult,
|
|
productResult,
|
|
readiness,
|
|
peers,
|
|
tokens,
|
|
products,
|
|
apps: registrations
|
|
};
|
|
}
|
|
|
|
function overviewMarkup(node) {
|
|
const protocol = node.nodeInfo.data && node.nodeInfo.data.protocol ? node.nodeInfo.data.protocol : {};
|
|
const capabilities = Array.isArray(node.nodeInfo.data.capabilities) ? node.nodeInfo.data.capabilities : [];
|
|
const usage = usageFor(node);
|
|
const storage = storageFor(node);
|
|
return `
|
|
${disclosure("Node Info", detailRows([
|
|
["Node URL", `<a href="${attr(node.url)}">${text(node.url)}</a>`],
|
|
["Configured name", text(node.name)],
|
|
["Health", resultLabel(node.health)],
|
|
["Readiness", resultLabel(node.ready)],
|
|
["Node metadata endpoint", resultLabel(node.nodeInfo)],
|
|
["Apps endpoint", resultLabel(node.appsResult)],
|
|
["Token assets endpoint", resultLabel(node.tokenResult)],
|
|
["Token issuer endpoint", resultLabel(node.issuerResult)],
|
|
["Token products endpoint", resultLabel(node.productResult)],
|
|
["Base URL", text(node.nodeInfo.data.base_url)],
|
|
["Known peer nodes", String(node.peers.length)],
|
|
["Min protocol", protocol.min_supported ? String(Number(protocol.min_supported)) : ""],
|
|
["Latest protocol", protocol.latest ? String(Number(protocol.latest)) : ""],
|
|
["Registered apps", String(node.apps.length)],
|
|
["Accepted token assets", String(node.tokens.length)],
|
|
["Registered users", String(Number(usage.registered_users || 0))],
|
|
["Active users 30d", String(Number(usage.active_users_30d || 0))],
|
|
["Registered clients", String(Number(usage.registered_clients || 0))],
|
|
["Active clients 30d", String(Number(usage.active_clients_30d || 0))],
|
|
["Connected users", String(Number(usage.connected_users || 0))],
|
|
["Connected WebSocket clients", String(Number(usage.connected_websocket_clients || 0))],
|
|
["Database size", formatBytes(storage.database_total_bytes)],
|
|
["Logical data size", formatBytes(storage.logical_bytes)]
|
|
]), { open: true, meta: `${node.status} / protocol ${Number(protocol.latest || 0)}` })}
|
|
${disclosure("Node Capabilities", itemList(capabilities, (capability) => `<li><code>${text(capability)}</code></li>`, "none declared"), { meta: `${capabilities.length} declared` })}
|
|
${disclosure("Known Node Peers", itemList(node.peers, (peer) => `<li><a href="${attr(peer.url)}">${text(peer.name)}</a><span>${text(peer.url)}</span><em>${syncPolicyText(peer.sync)}</em></li>`, "none declared"), { meta: `${node.peers.length} peers` })}
|
|
${disclosure("Readiness Checks", detailRows(Object.entries(node.readiness).map(([key, value]) => [key, text(value)])), { meta: `${Object.keys(node.readiness).length} checks` })}
|
|
`;
|
|
}
|
|
|
|
function storageMarkup(node) {
|
|
const storage = storageFor(node);
|
|
const apps = Array.isArray(storage.apps) ? storage.apps : [];
|
|
return `
|
|
${disclosure("Node Storage", detailRows([
|
|
["Database file", formatBytes(storage.database_file_bytes)],
|
|
["SQLite WAL", formatBytes(storage.database_wal_bytes)],
|
|
["SQLite SHM", formatBytes(storage.database_shm_bytes)],
|
|
["Database total", formatBytes(storage.database_total_bytes)],
|
|
["SQLite page bytes", formatBytes(storage.sqlite_page_bytes)],
|
|
["Logical bytes", formatBytes(storage.logical_bytes)],
|
|
["Encrypted record bytes", formatBytes(storage.encrypted_record_bytes)],
|
|
["Opaque payload bytes", formatBytes(storage.encrypted_payload_bytes)],
|
|
["Unassigned bytes", formatBytes(storage.unassigned_bytes)]
|
|
]), { open: true, meta: formatBytes(storage.database_total_bytes) })}
|
|
${disclosure("App Storage", `<div class="app-list">${apps.length ? apps.map(storageAppMarkup).join("") : "<p>No app storage reported.</p>"}</div>`, { open: true, meta: `${apps.length} apps` })}
|
|
`;
|
|
}
|
|
|
|
function tokensMarkup(node) {
|
|
return `
|
|
${disclosure("Accepted Tokens", `<div class="token-list">${node.tokens.length ? node.tokens.map((asset) => tokenMarkup(asset, node.issuerResult.data)).join("") : "<p>No accepted tokens published.</p>"}</div>`, { open: true, meta: `${node.tokens.length} assets` })}
|
|
${disclosure("Purchase Products", itemList(node.products, productMarkup, "No direct purchase products published."), { meta: `${node.products.length} products` })}
|
|
`;
|
|
}
|
|
|
|
function appsMarkup(node) {
|
|
return `
|
|
${disclosure("Registered Apps", `<div class="app-list">${node.apps.length ? node.apps.map(appMarkup).join("") : "<p>No apps registered.</p>"}</div>`, { open: true, meta: `${node.apps.length} apps` })}
|
|
`;
|
|
}
|
|
|
|
function usageFor(node) {
|
|
return node.nodeInfo.data && node.nodeInfo.data.usage ? node.nodeInfo.data.usage : {};
|
|
}
|
|
|
|
function storageFor(node) {
|
|
return node.nodeInfo.data && node.nodeInfo.data.storage ? node.nodeInfo.data.storage : {};
|
|
}
|
|
|
|
function renderDetail() {
|
|
const node = state.nodes[state.selected];
|
|
if (!node) {
|
|
detail.innerHTML = `<article class="node-card"><h3>No node selected</h3><p>No configured nodes are available.</p></article>`;
|
|
return;
|
|
}
|
|
const panels = {
|
|
overview: overviewMarkup,
|
|
storage: storageMarkup,
|
|
tokens: tokensMarkup,
|
|
apps: appsMarkup
|
|
};
|
|
const tab = panels[state.tab] ? state.tab : "overview";
|
|
detail.innerHTML = `
|
|
<article class="node-card selected-node-card">
|
|
<div class="node-heading">
|
|
<div>
|
|
<h3>${text(node.name)}</h3>
|
|
<p><a href="${attr(node.url)}">${text(node.url)}</a></p>
|
|
</div>
|
|
<span class="status-pill${node.online ? "" : " offline"}">${text(node.status)}</span>
|
|
</div>
|
|
<div class="node-tabs" role="tablist" aria-label="${text(node.name)} details">
|
|
${["overview", "storage", "tokens", "apps"].map((id) => `
|
|
<button type="button" class="${tab === id ? "active" : ""}" data-tab="${id}" role="tab" aria-selected="${tab === id ? "true" : "false"}">${text(id)}</button>
|
|
`).join("")}
|
|
</div>
|
|
<div class="node-tab-panel" role="tabpanel">
|
|
${panels[tab](node)}
|
|
</div>
|
|
</article>
|
|
`;
|
|
}
|
|
|
|
function railMeta(node) {
|
|
const usage = usageFor(node);
|
|
return `${node.status} / ${Number(usage.active_users_30d || 0)} active users / ${Number(usage.connected_websocket_clients || 0)} connected`;
|
|
}
|
|
|
|
function renderRail() {
|
|
rail.innerHTML = state.nodes.map((node, index) => `
|
|
<button type="button" class="${index === state.selected ? "active" : ""}" data-node-index="${index}">
|
|
<span>${text(node.name)}</span>
|
|
<em>${text(railMeta(node))}</em>
|
|
</button>
|
|
`).join("");
|
|
count.textContent = `${state.nodes.length} nodes / ${state.edges.length} connections`;
|
|
}
|
|
|
|
function nodePoint(index, total, width, height) {
|
|
if (total <= 1) return { x: width * 0.5, y: height * 0.48 };
|
|
const radius = Math.min(width, height) * 0.34;
|
|
const angle = -Math.PI / 2 + (Math.PI * 2 * index) / total;
|
|
return {
|
|
x: width * 0.5 + Math.cos(angle) * radius,
|
|
y: height * 0.52 + Math.sin(angle) * radius
|
|
};
|
|
}
|
|
|
|
function drawLabel(label, x, y, maxWidth, align = "center") {
|
|
ctx.textAlign = align;
|
|
ctx.textBaseline = "top";
|
|
ctx.fillStyle = "#202c29";
|
|
ctx.font = "700 12px 'Noto Sans Mono', monospace";
|
|
const clipped = label.length > 30 ? label.slice(0, 27) + "..." : label;
|
|
ctx.fillText(clipped, x, y, maxWidth);
|
|
}
|
|
|
|
function drawArrow(from, to, active) {
|
|
const dx = to.x - from.x;
|
|
const dy = to.y - from.y;
|
|
const distance = Math.max(1, Math.sqrt(dx * dx + dy * dy));
|
|
const unitX = dx / distance;
|
|
const unitY = dy / distance;
|
|
const start = { x: Math.round(from.x + unitX * 32), y: Math.round(from.y + unitY * 32) };
|
|
const end = { x: Math.round(to.x - unitX * 32), y: Math.round(to.y - unitY * 32) };
|
|
ctx.strokeStyle = active ? "rgba(166, 78, 50, .9)" : "rgba(49, 94, 72, .38)";
|
|
ctx.fillStyle = active ? "rgba(166, 78, 50, .9)" : "rgba(49, 94, 72, .5)";
|
|
ctx.lineWidth = active ? 3 : 2;
|
|
ctx.beginPath();
|
|
ctx.moveTo(start.x, start.y);
|
|
ctx.lineTo(end.x, end.y);
|
|
ctx.stroke();
|
|
|
|
const head = active ? 11 : 9;
|
|
ctx.beginPath();
|
|
ctx.moveTo(end.x, end.y);
|
|
ctx.lineTo(end.x - unitX * head - unitY * head * .55, end.y - unitY * head + unitX * head * .55);
|
|
ctx.lineTo(end.x - unitX * head + unitY * head * .55, end.y - unitY * head - unitX * head * .55);
|
|
ctx.closePath();
|
|
ctx.fill();
|
|
}
|
|
|
|
function renderCanvas() {
|
|
if (!ctx) return;
|
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
const width = Math.max(320, Math.floor(rect.width));
|
|
const height = Math.max(300, Math.floor(rect.height));
|
|
state.dpr = Math.min(Math.max(window.devicePixelRatio || 1, 1), MAX_CANVAS_DPR);
|
|
canvas.width = Math.round(width * state.dpr);
|
|
canvas.height = Math.round(height * state.dpr);
|
|
canvas.style.width = `${width}px`;
|
|
canvas.style.height = `${height}px`;
|
|
ctx.setTransform(state.dpr, 0, 0, state.dpr, 0, 0);
|
|
ctx.imageSmoothingEnabled = false;
|
|
ctx.clearRect(0, 0, width, height);
|
|
|
|
const gradient = ctx.createLinearGradient(0, 0, width, height);
|
|
gradient.addColorStop(0, "#f7f3eb");
|
|
gradient.addColorStop(1, "#f7f3eb");
|
|
ctx.fillStyle = gradient;
|
|
ctx.fillRect(0, 0, width, height);
|
|
|
|
ctx.strokeStyle = "rgba(49, 94, 72, .1)";
|
|
ctx.lineWidth = 1;
|
|
for (let x = 34; x < width; x += 34) {
|
|
const crispX = Math.round(x) + .5;
|
|
ctx.beginPath();
|
|
ctx.moveTo(crispX, 0);
|
|
ctx.lineTo(crispX, height);
|
|
ctx.stroke();
|
|
}
|
|
for (let y = 34; y < height; y += 34) {
|
|
const crispY = Math.round(y) + .5;
|
|
ctx.beginPath();
|
|
ctx.moveTo(0, crispY);
|
|
ctx.lineTo(width, crispY);
|
|
ctx.stroke();
|
|
}
|
|
|
|
state.hitAreas = [];
|
|
|
|
state.nodes.forEach((node, index) => {
|
|
const point = nodePoint(index, state.nodes.length, width, height);
|
|
node.canvasPoint = { x: Math.round(point.x), y: Math.round(point.y) };
|
|
});
|
|
|
|
state.edges.forEach((edge) => {
|
|
const source = state.nodes[edge.from];
|
|
const target = state.nodes[edge.to];
|
|
if (!source || !target || !source.canvasPoint || !target.canvasPoint) return;
|
|
drawArrow(source.canvasPoint, target.canvasPoint, edge.from === state.selected || edge.to === state.selected);
|
|
});
|
|
|
|
if (!state.edges.length) {
|
|
ctx.fillStyle = "rgba(32, 44, 41, .68)";
|
|
ctx.font = "700 12px 'Noto Sans Mono', monospace";
|
|
ctx.textAlign = "center";
|
|
ctx.textBaseline = "top";
|
|
ctx.fillText("no published peer connections yet", width * 0.5, height - 36, width - 40);
|
|
}
|
|
|
|
state.nodes.forEach((node, index) => {
|
|
const point = node.canvasPoint;
|
|
const selected = index === state.selected;
|
|
const hover = index === state.hover;
|
|
const radius = selected ? 29 : hover ? 27 : 24;
|
|
const fill = node.online ? "#315e48" : "#a64e32";
|
|
const ring = selected ? "#a64e32" : "rgba(32, 44, 41, .65)";
|
|
|
|
ctx.fillStyle = "rgba(32, 44, 41, .08)";
|
|
ctx.beginPath();
|
|
ctx.arc(point.x + 4, point.y + 7, radius + 2, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
|
|
ctx.fillStyle = fill;
|
|
ctx.beginPath();
|
|
ctx.arc(point.x, point.y, radius, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
ctx.strokeStyle = ring;
|
|
ctx.lineWidth = selected ? 5 : 4;
|
|
ctx.stroke();
|
|
|
|
ctx.fillStyle = "#f7f3eb";
|
|
ctx.font = "800 12px 'Noto Sans Mono', monospace";
|
|
ctx.textAlign = "center";
|
|
ctx.textBaseline = "middle";
|
|
ctx.fillText(String(node.peers.length), point.x, point.y - 5);
|
|
ctx.font = "700 9px 'Noto Sans Mono', monospace";
|
|
ctx.fillText("peers", point.x, point.y + 8);
|
|
drawLabel(node.name, point.x, point.y + radius + 12, 180);
|
|
|
|
state.hitAreas.push({ index, x: point.x, y: point.y, r: radius + 12 });
|
|
});
|
|
}
|
|
|
|
function selectNode(index) {
|
|
if (!state.nodes[index]) return;
|
|
state.selected = index;
|
|
renderRail();
|
|
renderDetail();
|
|
renderCanvas();
|
|
}
|
|
|
|
async function loadGraph(seedNodes) {
|
|
const nodes = [];
|
|
const byURL = new Map();
|
|
|
|
function enqueue(rawNode) {
|
|
const url = normalizeURL(rawNode && rawNode.url);
|
|
if (!url || byURL.has(url) || nodes.length >= MAX_DISCOVERED_NODES) return;
|
|
byURL.set(url, nodes.length);
|
|
nodes.push({
|
|
name: plain(rawNode.name, url),
|
|
url,
|
|
peers: peerList(rawNode.peers)
|
|
});
|
|
}
|
|
|
|
seedNodes.forEach(enqueue);
|
|
for (let index = 0; index < nodes.length; index++) {
|
|
const loaded = await loadNode(nodes[index], index);
|
|
nodes[index] = loaded;
|
|
byURL.set(loaded.url, index);
|
|
loaded.peers.forEach((peer) => enqueue(peer));
|
|
}
|
|
|
|
const edges = [];
|
|
const seenEdges = new Set();
|
|
nodes.forEach((node, from) => {
|
|
node.index = from;
|
|
node.peers.forEach((peer) => {
|
|
const to = byURL.get(normalizeURL(peer.url));
|
|
if (to === undefined || to === from) return;
|
|
const key = `${from}->${to}`;
|
|
if (seenEdges.has(key)) return;
|
|
seenEdges.add(key);
|
|
edges.push({ from, to });
|
|
});
|
|
});
|
|
return { nodes, edges };
|
|
}
|
|
|
|
function pointFromEvent(event) {
|
|
const rect = canvas.getBoundingClientRect();
|
|
const source = event.touches && event.touches.length ? event.touches[0] : event;
|
|
return {
|
|
x: source.clientX - rect.left,
|
|
y: source.clientY - rect.top
|
|
};
|
|
}
|
|
|
|
function hitTest(point) {
|
|
for (const hit of state.hitAreas) {
|
|
const dx = point.x - hit.x;
|
|
const dy = point.y - hit.y;
|
|
if (Math.sqrt(dx * dx + dy * dy) <= hit.r) return hit.index;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
canvas.addEventListener("pointermove", (event) => {
|
|
const hit = hitTest(pointFromEvent(event));
|
|
if (hit !== state.hover) {
|
|
state.hover = hit;
|
|
canvas.style.cursor = hit >= 0 ? "pointer" : "default";
|
|
renderCanvas();
|
|
}
|
|
});
|
|
|
|
canvas.addEventListener("pointerleave", () => {
|
|
state.hover = -1;
|
|
canvas.style.cursor = "default";
|
|
renderCanvas();
|
|
});
|
|
|
|
canvas.addEventListener("click", (event) => {
|
|
const hit = hitTest(pointFromEvent(event));
|
|
if (hit >= 0) selectNode(hit);
|
|
});
|
|
|
|
detail.addEventListener("click", (event) => {
|
|
const tab = event.target.closest("[data-tab]");
|
|
if (!tab) return;
|
|
state.tab = tab.getAttribute("data-tab") || "overview";
|
|
renderDetail();
|
|
});
|
|
|
|
rail.addEventListener("click", (event) => {
|
|
const nodeButton = event.target.closest("[data-node-index]");
|
|
if (!nodeButton) return;
|
|
selectNode(Number(nodeButton.getAttribute("data-node-index")));
|
|
});
|
|
|
|
window.addEventListener("resize", () => renderCanvas());
|
|
|
|
async function main() {
|
|
try {
|
|
const response = await fetch("/nodes.json", { cache: "no-store" });
|
|
const config = await response.json();
|
|
const nodes = Array.isArray(config.nodes) ? config.nodes : [];
|
|
const graph = await loadGraph(nodes);
|
|
state.nodes = graph.nodes;
|
|
state.edges = graph.edges;
|
|
state.selected = 0;
|
|
renderRail();
|
|
renderDetail();
|
|
renderCanvas();
|
|
} catch (error) {
|
|
count.textContent = "unavailable";
|
|
detail.innerHTML = `<article class="node-card"><h3>Node list unavailable</h3><p>Could not load the checked-in node configuration.</p></article>`;
|
|
renderCanvas();
|
|
}
|
|
}
|
|
|
|
main();
|
|
</script>
|
|
</body>
|
|
</html>
|