/** * rNetwork applet definitions — Contact Card. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const contactCard: AppletDefinition = { id: "contact-card", label: "Contact Card", icon: "👤", accentColor: "#4f46e5", ports: [ { name: "did-in", type: "string", direction: "input" }, { name: "contact-out", type: "json", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const name = (snapshot.name as string) || "Unknown"; const did = (snapshot.did as string) || ""; const shortDid = did ? `${did.slice(0, 16)}…` : "No DID"; const trustScore = (snapshot.trustScore as number) || 0; const trustColor = trustScore >= 0.7 ? "#22c55e" : trustScore >= 0.4 ? "#f59e0b" : "#94a3b8"; return `
👤
${name}
${shortDid}
Trust: ${Math.round(trustScore * 100)}%
`; }, onInputReceived(portName, value, ctx) { if (portName === "did-in" && typeof value === "string") { ctx.emitOutput("contact-out", { did: value, name: "", trustScore: 0 }); } }, }; export const networkApplets: AppletDefinition[] = [contactCard];