/** * rSocials applet definitions — Post Draft. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const postDraft: AppletDefinition = { id: "post-draft", label: "Post Draft", icon: "✏️", accentColor: "#db2777", ports: [ { name: "content-in", type: "text", direction: "input" }, { name: "post-out", type: "json", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const platform = (snapshot.platform as string) || "social"; const content = (snapshot.content as string) || ""; const charCount = content.length; const maxChars = (snapshot.maxChars as number) || 280; const pct = Math.min(100, Math.round((charCount / maxChars) * 100)); const countColor = pct > 90 ? "#ef4444" : pct > 70 ? "#f59e0b" : "#94a3b8"; return `
${platform}
${content || "Empty draft"}
${charCount}/${maxChars}
`; }, onInputReceived(portName, value, ctx) { if (portName === "content-in" && typeof value === "string") { ctx.emitOutput("post-out", { content: value, platform: "social", timestamp: Date.now() }); } }, }; export const socialsApplets: AppletDefinition[] = [postDraft];