/**
* Design module — collaborative design workspace via Affine.
*
* Wraps the Affine instance as an external app embedded in the rSpace shell.
*/
import { Hono } from "hono";
import { renderShell, renderExternalAppShell } from "../../server/shell";
import { getModuleInfoList } from "../../shared/module";
import type { RSpaceModule } from "../../shared/module";
const routes = new Hono();
const AFFINE_URL = "https://affine.cosmolocal.world";
routes.get("/api/health", (c) => {
return c.json({ ok: true, module: "rdesign" });
});
routes.get("/", (c) => {
const space = c.req.param("space") || "demo";
const view = c.req.query("view");
if (view === "demo") {
return c.html(renderShell({
title: `${space} — Design | rSpace`,
moduleId: "rdesign",
spaceSlug: space,
modules: getModuleInfoList(),
theme: "dark",
body: `
🎯
rDesign
Collaborative design workspace powered by Affine. Whiteboard, docs, and kanban — all in one tool for your community.
Open Affine
`,
}));
}
// Default: show the external app directly
return c.html(renderExternalAppShell({
title: `${space} — Affine | rSpace`,
moduleId: "rdesign",
spaceSlug: space,
modules: getModuleInfoList(),
appUrl: AFFINE_URL,
appName: "Affine",
theme: "dark",
}));
});
function renderDesignLanding(): string {
return `
🎯
rDesign
Collaborative design workspace powered by Affine. Whiteboard, docs, and kanban — all in one tool for your community.
`;
}
export const designModule: RSpaceModule = {
id: "rdesign",
name: "rDesign",
icon: "🎯",
description: "Collaborative design workspace with whiteboard and docs",
scoping: { defaultScope: 'global', userConfigurable: false },
routes,
landingPage: renderDesignLanding,
standaloneDomain: "rdesign.online",
externalApp: { url: AFFINE_URL, name: "Affine" },
feeds: [
{ id: "design-assets", name: "Design Assets", kind: "resource", description: "Design files, mockups, and whiteboard exports" },
],
acceptsFeeds: ["data", "resource"],
outputPaths: [
{ path: "designs", name: "Designs", icon: "🎯", description: "Design files and mockups" },
{ path: "templates", name: "Templates", icon: "📐", description: "Reusable design templates" },
],
};