wirepulse 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +183 -2
- package/dist/browser-core.d.ts +8 -0
- package/dist/browser-core.js +8 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +285 -0
- package/dist/icons.d.ts +7 -0
- package/dist/icons.js +41 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +29 -0
- package/dist/layout.d.ts +6 -0
- package/dist/layout.js +387 -0
- package/dist/mermaid.d.ts +11 -0
- package/dist/mermaid.js +278 -0
- package/dist/parser.d.ts +10 -0
- package/dist/parser.js +401 -0
- package/dist/renderer.d.ts +6 -0
- package/dist/renderer.js +330 -0
- package/dist/studio-html.d.ts +10 -0
- package/dist/studio-html.js +1028 -0
- package/dist/studio.d.ts +14 -0
- package/dist/studio.js +170 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +167 -0
- package/dist/themes.d.ts +47 -0
- package/dist/themes.js +208 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.js +1 -0
- package/dist/validator.d.ts +10 -0
- package/dist/validator.js +84 -0
- package/package.json +59 -4
package/dist/studio.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
export interface StudioServerOptions {
|
|
3
|
+
port: number;
|
|
4
|
+
host?: string;
|
|
5
|
+
filePath?: string;
|
|
6
|
+
outSvgPath?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RunningStudio {
|
|
10
|
+
server: http.Server;
|
|
11
|
+
url: string;
|
|
12
|
+
close: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function startStudioServer(opts: StudioServerOptions): Promise<RunningStudio>;
|
package/dist/studio.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { convertMermaidToWirepulse } from "./mermaid.js";
|
|
5
|
+
import { parseDiagram, updateNodeGridInSource } from "./parser.js";
|
|
6
|
+
import { renderSvg } from "./renderer.js";
|
|
7
|
+
import { buildStudioHtml } from "./studio-html.js";
|
|
8
|
+
import { TEMPLATES } from "./templates.js";
|
|
9
|
+
import { validateSvg } from "./validator.js";
|
|
10
|
+
function readJsonBody(req) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
let raw = "";
|
|
13
|
+
req.on("data", (chunk) => {
|
|
14
|
+
raw += chunk.toString("utf8");
|
|
15
|
+
if (raw.length > 2_000_000) {
|
|
16
|
+
reject(new Error("Request payload too large"));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
req.on("end", () => {
|
|
20
|
+
try {
|
|
21
|
+
resolve(raw ? JSON.parse(raw) : {});
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
reject(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
req.on("error", reject);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function startStudioServer(opts) {
|
|
31
|
+
const host = opts.host ?? "127.0.0.1";
|
|
32
|
+
const resolvedFile = opts.filePath ? path.resolve(opts.filePath) : undefined;
|
|
33
|
+
const initialSource = resolvedFile && fs.existsSync(resolvedFile)
|
|
34
|
+
? fs.readFileSync(resolvedFile, "utf8")
|
|
35
|
+
: TEMPLATES[0].source;
|
|
36
|
+
const html = buildStudioHtml({
|
|
37
|
+
initialSource,
|
|
38
|
+
fileName: resolvedFile ? path.basename(resolvedFile) : undefined,
|
|
39
|
+
canSaveToDisk: Boolean(resolvedFile),
|
|
40
|
+
version: opts.version,
|
|
41
|
+
});
|
|
42
|
+
const server = http.createServer(async (req, res) => {
|
|
43
|
+
const reqUrl = new URL(req.url ?? "/", `http://${host}:${opts.port}`);
|
|
44
|
+
if (req.method === "GET" && (reqUrl.pathname === "/" || reqUrl.pathname === "/index.html")) {
|
|
45
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
46
|
+
res.end(html);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (req.method === "GET" && reqUrl.pathname === "/api/health") {
|
|
50
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
51
|
+
res.end(JSON.stringify({ ok: true, version: opts.version }));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (req.method === "POST" && reqUrl.pathname === "/api/render") {
|
|
55
|
+
try {
|
|
56
|
+
const body = await readJsonBody(req);
|
|
57
|
+
const source = typeof body.source === "string" ? body.source : "";
|
|
58
|
+
const themeOverride = typeof body.theme === "string" && body.theme.length > 0
|
|
59
|
+
? body.theme
|
|
60
|
+
: undefined;
|
|
61
|
+
const speedMultiplier = typeof body.speedMultiplier === "number" ? body.speedMultiplier : 1;
|
|
62
|
+
const paused = Boolean(body.paused);
|
|
63
|
+
const previewMode = body.previewMode === "light" ? "light" : "dark";
|
|
64
|
+
const { spec, errors } = parseDiagram(source);
|
|
65
|
+
const effectiveTheme = themeOverride ?? spec.theme;
|
|
66
|
+
// Pure export SVG (preserves `auto` media query!)
|
|
67
|
+
const svg = renderSvg(spec, {
|
|
68
|
+
theme: effectiveTheme,
|
|
69
|
+
speedMultiplier,
|
|
70
|
+
paused,
|
|
71
|
+
});
|
|
72
|
+
// For the interactive GitHub Light/Dark preview toggle, force light/dark when theme === 'auto'
|
|
73
|
+
const previewSvg = effectiveTheme === "auto"
|
|
74
|
+
? renderSvg(spec, {
|
|
75
|
+
theme: previewMode === "light" ? "paper" : "midnight",
|
|
76
|
+
speedMultiplier,
|
|
77
|
+
paused,
|
|
78
|
+
})
|
|
79
|
+
: svg;
|
|
80
|
+
const validation = validateSvg(svg);
|
|
81
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
82
|
+
res.end(JSON.stringify({
|
|
83
|
+
svg,
|
|
84
|
+
previewSvg,
|
|
85
|
+
errors,
|
|
86
|
+
validation,
|
|
87
|
+
nodeCount: spec.nodes.length,
|
|
88
|
+
edgeCount: spec.edges.length,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
93
|
+
res.end(JSON.stringify({
|
|
94
|
+
error: err instanceof Error ? err.message : String(err),
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (req.method === "POST" && reqUrl.pathname === "/api/move-node") {
|
|
100
|
+
try {
|
|
101
|
+
const body = await readJsonBody(req);
|
|
102
|
+
const source = typeof body.source === "string" ? body.source : "";
|
|
103
|
+
const nodeId = typeof body.nodeId === "string" ? body.nodeId : "";
|
|
104
|
+
const col = typeof body.col === "number" ? Math.max(0, Math.round(body.col)) : 0;
|
|
105
|
+
const row = typeof body.row === "number" ? Math.max(0, Math.round(body.row)) : 0;
|
|
106
|
+
const updatedSource = updateNodeGridInSource(source, nodeId, col, row);
|
|
107
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
108
|
+
res.end(JSON.stringify({ source: updatedSource }));
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
112
|
+
res.end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (req.method === "POST" && reqUrl.pathname === "/api/import-mermaid") {
|
|
117
|
+
try {
|
|
118
|
+
const body = await readJsonBody(req);
|
|
119
|
+
const mermaid = typeof body.mermaid === "string" ? body.mermaid : "";
|
|
120
|
+
const converted = convertMermaidToWirepulse(mermaid);
|
|
121
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
122
|
+
res.end(JSON.stringify({ source: converted }));
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
126
|
+
res.end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (req.method === "POST" && reqUrl.pathname === "/api/save") {
|
|
131
|
+
if (!resolvedFile) {
|
|
132
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
133
|
+
res.end(JSON.stringify({ error: "No file attached to studio session." }));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const body = await readJsonBody(req);
|
|
138
|
+
if (typeof body.source === "string") {
|
|
139
|
+
fs.writeFileSync(resolvedFile, body.source, "utf8");
|
|
140
|
+
}
|
|
141
|
+
if (opts.outSvgPath && typeof body.svg === "string") {
|
|
142
|
+
fs.writeFileSync(path.resolve(opts.outSvgPath), body.svg, "utf8");
|
|
143
|
+
}
|
|
144
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
145
|
+
res.end(JSON.stringify({ ok: true }));
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
149
|
+
res.end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
154
|
+
res.end("Not Found");
|
|
155
|
+
});
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
server.once("error", reject);
|
|
158
|
+
server.listen(opts.port, host, () => {
|
|
159
|
+
const addr = server.address();
|
|
160
|
+
const actualPort = addr && typeof addr === "object" ? addr.port : opts.port;
|
|
161
|
+
resolve({
|
|
162
|
+
server,
|
|
163
|
+
url: `http://${host}:${actualPort}`,
|
|
164
|
+
close: () => new Promise((resClose) => {
|
|
165
|
+
server.close(() => resClose());
|
|
166
|
+
}),
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export const TEMPLATES = [
|
|
2
|
+
{
|
|
3
|
+
id: "ai-agent-mcp",
|
|
4
|
+
name: "AI Coding Agent + MCP",
|
|
5
|
+
description: "Autonomous coding agent routing JSON-RPC tool calls across Git, Vector DB, and Web Search",
|
|
6
|
+
source: `title: AI Coding Agent & MCP Runtime
|
|
7
|
+
subtitle: Pure zero-JS animated SVG — auto-adapts to GitHub Light & Dark mode
|
|
8
|
+
theme: auto
|
|
9
|
+
direction: LR
|
|
10
|
+
speed: normal
|
|
11
|
+
|
|
12
|
+
group client "Developer" color=cyan
|
|
13
|
+
group runtime "Agent Harness" color=violet
|
|
14
|
+
group tools "MCP Servers" color=emerald
|
|
15
|
+
|
|
16
|
+
node ide "IDE / Terminal" sub="Claude Code · Cursor" icon=terminal color=cyan group=client pulse=true
|
|
17
|
+
node agent "Agent Loop" sub="200k Context" icon=sparkles color=violet badge="LLM" group=runtime pulse=true
|
|
18
|
+
node router "MCP Router" sub="JSON-RPC 2.0" icon=cpu color=blue group=runtime
|
|
19
|
+
node repo "Codebase" sub="AST + Git Diffs" icon=git color=emerald group=tools
|
|
20
|
+
node vec "Vector Index" sub="pgvector" icon=database color=amber group=tools
|
|
21
|
+
node web "Web Grounding" sub="Live Docs" icon=globe color=rose group=tools
|
|
22
|
+
|
|
23
|
+
ide -> agent "prompt" flow=packet color=cyan speed=fast
|
|
24
|
+
agent <-> router "tools/call" flow=packet color=violet packets=2
|
|
25
|
+
router <-> repo "read / edit" flow=dash color=emerald
|
|
26
|
+
router -> vec "semantic search" flow=packet color=amber
|
|
27
|
+
router -> web "fetch url" flow=pulse color=rose
|
|
28
|
+
`,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "microservices-kafka",
|
|
32
|
+
name: "Microservices + Kafka",
|
|
33
|
+
description: "High-throughput API gateway with Redis cache, PostgreSQL primary, and Kafka event consumers",
|
|
34
|
+
source: `title: High-Throughput Order Architecture
|
|
35
|
+
subtitle: Edge gateway, read-through Redis cache, PostgreSQL, and async Kafka workers
|
|
36
|
+
theme: midnight
|
|
37
|
+
direction: LR
|
|
38
|
+
speed: normal
|
|
39
|
+
|
|
40
|
+
group edge "Edge" color=cyan
|
|
41
|
+
group core "API Tier" color=violet
|
|
42
|
+
group async "Storage & Events" color=emerald
|
|
43
|
+
|
|
44
|
+
node web "Web & Mobile" sub="Next.js · iOS" icon=browser color=cyan group=edge pulse=true
|
|
45
|
+
node gw "API Gateway" sub="Rate Limit + Auth" icon=shield color=violet badge="p99 4ms" group=core pulse=true
|
|
46
|
+
node svc "Order Service" sub="Node.js · 6 pods" icon=server color=blue group=core
|
|
47
|
+
node redis "Redis Cluster" sub="Hot Read Cache" icon=bolt color=amber badge="96% hit" group=async
|
|
48
|
+
node pg "PostgreSQL" sub="Primary + Replicas" icon=database color=emerald group=async
|
|
49
|
+
node kafka "Kafka Bus" sub="orders.created" icon=queue color=rose group=async
|
|
50
|
+
node worker "Billing Worker" sub="Stripe + Webhooks" icon=lambda color=orange
|
|
51
|
+
|
|
52
|
+
web -> gw "HTTPS / TLS" flow=packet color=cyan speed=fast packets=2
|
|
53
|
+
gw -> svc "gRPC" flow=packet color=violet
|
|
54
|
+
svc <-> redis "cache lookup" flow=dash color=amber speed=fast
|
|
55
|
+
svc -> pg "ACID write" flow=packet color=emerald
|
|
56
|
+
svc -> kafka "publish event" flow=packet color=rose packets=2
|
|
57
|
+
kafka -> worker "consume" flow=pulse color=orange
|
|
58
|
+
`,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "gitops-cicd",
|
|
62
|
+
name: "GitOps CI/CD Pipeline",
|
|
63
|
+
description: "Pull request to production deployment with automated tests, container registry, and canary rollout",
|
|
64
|
+
source: `title: Zero-Downtime GitOps Pipeline
|
|
65
|
+
subtitle: Automated checks, signed container builds, and progressive canary rollout
|
|
66
|
+
theme: linear
|
|
67
|
+
direction: LR
|
|
68
|
+
speed: normal
|
|
69
|
+
|
|
70
|
+
group ci "GitHub Actions" color=blue
|
|
71
|
+
group cd "Production Cluster" color=emerald
|
|
72
|
+
|
|
73
|
+
node git "Git Push" sub="main branch" icon=git color=cyan pulse=true
|
|
74
|
+
node test "Test Matrix" sub="Lint · Unit · E2E" icon=check color=violet badge="42s" group=ci
|
|
75
|
+
node build "Docker Build" sub="SLSA Provenance" icon=box color=blue group=ci
|
|
76
|
+
node reg "Registry" sub="ghcr.io" icon=storage color=amber
|
|
77
|
+
node argo "Argo CD" sub="Drift Sync" icon=layers color=emerald group=cd pulse=true
|
|
78
|
+
node prod "Canary Pods" sub="10% → 100%" icon=cloud color=emerald badge="99.99%" group=cd
|
|
79
|
+
|
|
80
|
+
git -> test "PR / push" flow=packet color=cyan speed=fast
|
|
81
|
+
test -> build "all green" flow=packet color=violet
|
|
82
|
+
build -> reg "push image" flow=packet color=amber
|
|
83
|
+
reg -> argo "digest update" flow=dash color=blue
|
|
84
|
+
argo -> prod "rollout" flow=pulse color=emerald
|
|
85
|
+
`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "rag-pipeline",
|
|
89
|
+
name: "RAG & Hybrid Search",
|
|
90
|
+
description: "Document ingestion, chunking, hybrid BM25 + vector retrieval, and reranked LLM generation",
|
|
91
|
+
source: `title: Hybrid RAG Retrieval Engine
|
|
92
|
+
subtitle: Dual-path semantic + lexical search with cross-encoder reranking
|
|
93
|
+
theme: blueprint
|
|
94
|
+
direction: LR
|
|
95
|
+
speed: normal
|
|
96
|
+
|
|
97
|
+
group retrieval "Hybrid Retrieval" color=cyan
|
|
98
|
+
group synth "Synthesis" color=violet
|
|
99
|
+
|
|
100
|
+
node user "User Query" sub="Web / API" icon=user color=cyan pulse=true
|
|
101
|
+
node embed "Embedder" sub="1536-dim" icon=cpu color=blue
|
|
102
|
+
node vec "Qdrant Vector" sub="Cosine Top-20" icon=database color=cyan group=retrieval
|
|
103
|
+
node bm25 "BM25 Index" sub="Exact Keywords" icon=search color=amber group=retrieval
|
|
104
|
+
node rerank "Reranker" sub="Cross-Encoder" icon=layers color=violet badge="Top-5" group=synth
|
|
105
|
+
node llm "LLM Answer" sub="Grounded Citations" icon=sparkles color=emerald group=synth pulse=true
|
|
106
|
+
|
|
107
|
+
user -> embed "question" flow=packet color=cyan speed=fast
|
|
108
|
+
embed -> vec "dense vector" flow=packet color=cyan
|
|
109
|
+
embed -> bm25 "sparse tokens" flow=dash color=amber
|
|
110
|
+
vec -> rerank "candidates" flow=packet color=blue
|
|
111
|
+
bm25 -> rerank "candidates" flow=packet color=amber
|
|
112
|
+
rerank -> llm "ranked context" flow=packet color=violet packets=2
|
|
113
|
+
`,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "oauth-edge",
|
|
117
|
+
name: "Zero-Trust Auth & Edge",
|
|
118
|
+
description: "Global CDN edge verification, short-lived JWT issuance, and RBAC policy enforcement",
|
|
119
|
+
source: `title: Zero-Trust Edge Authentication
|
|
120
|
+
subtitle: OAuth2 PKCE flow with edge JWT verification and rotating refresh tokens
|
|
121
|
+
theme: terminal
|
|
122
|
+
direction: LR
|
|
123
|
+
speed: normal
|
|
124
|
+
|
|
125
|
+
group edge "Edge Network" color=emerald
|
|
126
|
+
group auth "Identity Core" color=cyan
|
|
127
|
+
|
|
128
|
+
node app "Client App" sub="SPA / Mobile" icon=mobile color=cyan pulse=true
|
|
129
|
+
node cdn "Edge Middleware" sub="JWKS Verify" icon=globe color=emerald badge="<2ms" group=edge pulse=true
|
|
130
|
+
node idp "OAuth2 IdP" sub="PKCE + Passkeys" icon=key color=amber group=auth
|
|
131
|
+
node rbac "Policy Engine" sub="RBAC / ABAC" icon=lock color=violet group=auth
|
|
132
|
+
node api "Protected API" sub="Tenant Scoped" icon=api color=emerald
|
|
133
|
+
|
|
134
|
+
app <-> idp "PKCE login" flow=dash color=amber
|
|
135
|
+
app -> cdn "Bearer JWT" flow=packet color=cyan speed=fast packets=2
|
|
136
|
+
cdn -> rbac "check claims" flow=packet color=violet
|
|
137
|
+
rbac -> api "allow" flow=pulse color=emerald
|
|
138
|
+
`,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: "realtime-payments",
|
|
142
|
+
name: "Realtime Payments Ledger",
|
|
143
|
+
description: "Idempotent checkout flow with fraud scoring, double-entry ledger, and webhook delivery",
|
|
144
|
+
source: `title: Idempotent Payments Engine
|
|
145
|
+
subtitle: Sub-100ms fraud scoring, double-entry ledger, and guaranteed webhook fan-out
|
|
146
|
+
theme: paper
|
|
147
|
+
direction: LR
|
|
148
|
+
speed: normal
|
|
149
|
+
|
|
150
|
+
group checks "Risk & Ledger" color=violet
|
|
151
|
+
|
|
152
|
+
node checkout "Checkout UI" sub="Idempotency Key" icon=browser color=blue pulse=true
|
|
153
|
+
node api "Payments API" sub="PCI Isolated" icon=shield color=violet badge="TLS 1.3" pulse=true
|
|
154
|
+
node fraud "Fraud Model" sub="Velocity + ML" icon=chart color=rose badge="12ms" group=checks
|
|
155
|
+
node ledger "Ledger DB" sub="Double-Entry" icon=database color=emerald group=checks
|
|
156
|
+
node hooks "Webhook Queue" sub="Exponential Retry" icon=plug color=amber
|
|
157
|
+
|
|
158
|
+
checkout -> api "charge req" flow=packet color=blue speed=fast
|
|
159
|
+
api <-> fraud "risk score" flow=dash color=rose speed=fast
|
|
160
|
+
api -> ledger "commit tx" flow=packet color=emerald
|
|
161
|
+
ledger -> hooks "tx.settled" flow=packet color=amber packets=2
|
|
162
|
+
`,
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
export function getTemplateById(id) {
|
|
166
|
+
return TEMPLATES.find((t) => t.id === id.toLowerCase());
|
|
167
|
+
}
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AccentColor, ThemeName } from "./types.js";
|
|
2
|
+
export interface ThemePalette {
|
|
3
|
+
bg: string;
|
|
4
|
+
bgSecondary: string;
|
|
5
|
+
gridDot: string;
|
|
6
|
+
cardBg: string;
|
|
7
|
+
cardBorder: string;
|
|
8
|
+
textPrimary: string;
|
|
9
|
+
textSecondary: string;
|
|
10
|
+
textMuted: string;
|
|
11
|
+
edgeBase: string;
|
|
12
|
+
labelBg: string;
|
|
13
|
+
labelBorder: string;
|
|
14
|
+
groupBg: string;
|
|
15
|
+
groupBorder: string;
|
|
16
|
+
badgeBg: string;
|
|
17
|
+
shadowColor: string;
|
|
18
|
+
fontFamily: string;
|
|
19
|
+
monoFamily: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AccentSpec {
|
|
22
|
+
dark: {
|
|
23
|
+
stroke: string;
|
|
24
|
+
glow: string;
|
|
25
|
+
softBg: string;
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
light: {
|
|
29
|
+
stroke: string;
|
|
30
|
+
glow: string;
|
|
31
|
+
softBg: string;
|
|
32
|
+
text: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare const ACCENTS: Record<AccentColor, AccentSpec>;
|
|
36
|
+
export declare const ACCENT_NAMES: AccentColor[];
|
|
37
|
+
export declare const THEMES: Record<Exclude<ThemeName, "auto">, {
|
|
38
|
+
mode: "dark" | "light";
|
|
39
|
+
palette: ThemePalette;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const THEME_NAMES: ThemeName[];
|
|
42
|
+
/**
|
|
43
|
+
* Generates CSS variables block inside `<style>`.
|
|
44
|
+
* For `theme: "auto"`, defaults to clean GitHub Light and switches seamlessly
|
|
45
|
+
* to GitHub Midnight Dark via `@media (prefers-color-scheme: dark)`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildThemeCss(theme: ThemeName): string;
|
package/dist/themes.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export const ACCENTS = {
|
|
2
|
+
cyan: {
|
|
3
|
+
dark: { stroke: "#22d3ee", glow: "#06b6d4", softBg: "rgba(34,211,238,0.13)", text: "#67e8f9" },
|
|
4
|
+
light: { stroke: "#0891b2", glow: "#06b6d4", softBg: "rgba(8,145,178,0.10)", text: "#0e7490" },
|
|
5
|
+
},
|
|
6
|
+
violet: {
|
|
7
|
+
dark: { stroke: "#a78bfa", glow: "#8b5cf6", softBg: "rgba(167,139,250,0.14)", text: "#c4b5fd" },
|
|
8
|
+
light: { stroke: "#7c3aed", glow: "#8b5cf6", softBg: "rgba(124,58,237,0.10)", text: "#6d28d9" },
|
|
9
|
+
},
|
|
10
|
+
emerald: {
|
|
11
|
+
dark: { stroke: "#34d399", glow: "#10b981", softBg: "rgba(52,211,153,0.13)", text: "#6ee7b7" },
|
|
12
|
+
light: { stroke: "#059669", glow: "#10b981", softBg: "rgba(5,150,105,0.10)", text: "#047857" },
|
|
13
|
+
},
|
|
14
|
+
amber: {
|
|
15
|
+
dark: { stroke: "#fbbf24", glow: "#f59e0b", softBg: "rgba(251,191,36,0.13)", text: "#fde68a" },
|
|
16
|
+
light: { stroke: "#d97706", glow: "#f59e0b", softBg: "rgba(217,119,6,0.10)", text: "#b45309" },
|
|
17
|
+
},
|
|
18
|
+
rose: {
|
|
19
|
+
dark: { stroke: "#fb7185", glow: "#f43f5e", softBg: "rgba(251,113,133,0.14)", text: "#fda4af" },
|
|
20
|
+
light: { stroke: "#e11d48", glow: "#f43f5e", softBg: "rgba(225,29,72,0.10)", text: "#be123c" },
|
|
21
|
+
},
|
|
22
|
+
blue: {
|
|
23
|
+
dark: { stroke: "#60a5fa", glow: "#3b82f6", softBg: "rgba(96,165,250,0.14)", text: "#93c5fd" },
|
|
24
|
+
light: { stroke: "#2563eb", glow: "#3b82f6", softBg: "rgba(37,99,235,0.10)", text: "#1d4ed8" },
|
|
25
|
+
},
|
|
26
|
+
orange: {
|
|
27
|
+
dark: { stroke: "#fb923c", glow: "#f97316", softBg: "rgba(251,146,60,0.14)", text: "#fdba74" },
|
|
28
|
+
light: { stroke: "#ea580c", glow: "#f97316", softBg: "rgba(234,88,12,0.10)", text: "#c2410c" },
|
|
29
|
+
},
|
|
30
|
+
slate: {
|
|
31
|
+
dark: { stroke: "#94a3b8", glow: "#64748b", softBg: "rgba(148,163,184,0.14)", text: "#cbd5e1" },
|
|
32
|
+
light: { stroke: "#475569", glow: "#64748b", softBg: "rgba(71,85,105,0.10)", text: "#334155" },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const ACCENT_NAMES = Object.keys(ACCENTS);
|
|
36
|
+
const SANS = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif";
|
|
37
|
+
const MONO = "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace";
|
|
38
|
+
export const THEMES = {
|
|
39
|
+
midnight: {
|
|
40
|
+
mode: "dark",
|
|
41
|
+
palette: {
|
|
42
|
+
bg: "#0b1120",
|
|
43
|
+
bgSecondary: "#0f172a",
|
|
44
|
+
gridDot: "rgba(148, 163, 184, 0.16)",
|
|
45
|
+
cardBg: "#111827",
|
|
46
|
+
cardBorder: "#1e293b",
|
|
47
|
+
textPrimary: "#f1f5f9",
|
|
48
|
+
textSecondary: "#94a3b8",
|
|
49
|
+
textMuted: "#64748b",
|
|
50
|
+
edgeBase: "#334155",
|
|
51
|
+
labelBg: "#0f172a",
|
|
52
|
+
labelBorder: "#1e293b",
|
|
53
|
+
groupBg: "rgba(30, 41, 59, 0.28)",
|
|
54
|
+
groupBorder: "rgba(148, 163, 184, 0.26)",
|
|
55
|
+
badgeBg: "rgba(15, 23, 42, 0.85)",
|
|
56
|
+
shadowColor: "rgba(0, 0, 0, 0.45)",
|
|
57
|
+
fontFamily: SANS,
|
|
58
|
+
monoFamily: MONO,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
linear: {
|
|
62
|
+
mode: "dark",
|
|
63
|
+
palette: {
|
|
64
|
+
bg: "#09090b",
|
|
65
|
+
bgSecondary: "#121215",
|
|
66
|
+
gridDot: "rgba(161, 161, 170, 0.14)",
|
|
67
|
+
cardBg: "#141418",
|
|
68
|
+
cardBorder: "#27272a",
|
|
69
|
+
textPrimary: "#fafafa",
|
|
70
|
+
textSecondary: "#a1a1aa",
|
|
71
|
+
textMuted: "#71717a",
|
|
72
|
+
edgeBase: "#3f3f46",
|
|
73
|
+
labelBg: "#18181b",
|
|
74
|
+
labelBorder: "#27272a",
|
|
75
|
+
groupBg: "rgba(39, 39, 42, 0.24)",
|
|
76
|
+
groupBorder: "rgba(161, 161, 170, 0.22)",
|
|
77
|
+
badgeBg: "#1f1f24",
|
|
78
|
+
shadowColor: "rgba(0, 0, 0, 0.55)",
|
|
79
|
+
fontFamily: SANS,
|
|
80
|
+
monoFamily: MONO,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
blueprint: {
|
|
84
|
+
mode: "dark",
|
|
85
|
+
palette: {
|
|
86
|
+
bg: "#071a33",
|
|
87
|
+
bgSecondary: "#0a2242",
|
|
88
|
+
gridDot: "rgba(96, 165, 250, 0.24)",
|
|
89
|
+
cardBg: "#0b2547",
|
|
90
|
+
cardBorder: "#1e4b82",
|
|
91
|
+
textPrimary: "#eff6ff",
|
|
92
|
+
textSecondary: "#93c5fd",
|
|
93
|
+
textMuted: "#60a5fa",
|
|
94
|
+
edgeBase: "#2563eb",
|
|
95
|
+
labelBg: "#081f3d",
|
|
96
|
+
labelBorder: "#1d4ed8",
|
|
97
|
+
groupBg: "rgba(37, 99, 235, 0.12)",
|
|
98
|
+
groupBorder: "rgba(147, 197, 253, 0.35)",
|
|
99
|
+
badgeBg: "rgba(7, 26, 51, 0.9)",
|
|
100
|
+
shadowColor: "rgba(2, 10, 24, 0.55)",
|
|
101
|
+
fontFamily: MONO,
|
|
102
|
+
monoFamily: MONO,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
terminal: {
|
|
106
|
+
mode: "dark",
|
|
107
|
+
palette: {
|
|
108
|
+
bg: "#050a07",
|
|
109
|
+
bgSecondary: "#09130d",
|
|
110
|
+
gridDot: "rgba(52, 211, 153, 0.18)",
|
|
111
|
+
cardBg: "#0a160f",
|
|
112
|
+
cardBorder: "#14532d",
|
|
113
|
+
textPrimary: "#dcfce7",
|
|
114
|
+
textSecondary: "#86efac",
|
|
115
|
+
textMuted: "#4ade80",
|
|
116
|
+
edgeBase: "#166534",
|
|
117
|
+
labelBg: "#07110b",
|
|
118
|
+
labelBorder: "#15803d",
|
|
119
|
+
groupBg: "rgba(20, 83, 45, 0.18)",
|
|
120
|
+
groupBorder: "rgba(74, 222, 128, 0.30)",
|
|
121
|
+
badgeBg: "#052e16",
|
|
122
|
+
shadowColor: "rgba(0, 0, 0, 0.6)",
|
|
123
|
+
fontFamily: MONO,
|
|
124
|
+
monoFamily: MONO,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
paper: {
|
|
128
|
+
mode: "light",
|
|
129
|
+
palette: {
|
|
130
|
+
bg: "#ffffff",
|
|
131
|
+
bgSecondary: "#f8fafc",
|
|
132
|
+
gridDot: "rgba(100, 116, 139, 0.20)",
|
|
133
|
+
cardBg: "#ffffff",
|
|
134
|
+
cardBorder: "#cbd5e1",
|
|
135
|
+
textPrimary: "#0f172a",
|
|
136
|
+
textSecondary: "#475569",
|
|
137
|
+
textMuted: "#64748b",
|
|
138
|
+
edgeBase: "#94a3b8",
|
|
139
|
+
labelBg: "#ffffff",
|
|
140
|
+
labelBorder: "#cbd5e1",
|
|
141
|
+
groupBg: "rgba(241, 245, 249, 0.72)",
|
|
142
|
+
groupBorder: "rgba(100, 116, 139, 0.36)",
|
|
143
|
+
badgeBg: "#f1f5f9",
|
|
144
|
+
shadowColor: "rgba(15, 23, 42, 0.08)",
|
|
145
|
+
fontFamily: SANS,
|
|
146
|
+
monoFamily: MONO,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
export const THEME_NAMES = [
|
|
151
|
+
"auto",
|
|
152
|
+
"midnight",
|
|
153
|
+
"linear",
|
|
154
|
+
"blueprint",
|
|
155
|
+
"terminal",
|
|
156
|
+
"paper",
|
|
157
|
+
];
|
|
158
|
+
function paletteToCssVars(p, mode) {
|
|
159
|
+
const lines = [
|
|
160
|
+
`--wp-bg: ${p.bg};`,
|
|
161
|
+
`--wp-bg-2: ${p.bgSecondary};`,
|
|
162
|
+
`--wp-grid: ${p.gridDot};`,
|
|
163
|
+
`--wp-card: ${p.cardBg};`,
|
|
164
|
+
`--wp-border: ${p.cardBorder};`,
|
|
165
|
+
`--wp-text: ${p.textPrimary};`,
|
|
166
|
+
`--wp-sub: ${p.textSecondary};`,
|
|
167
|
+
`--wp-muted: ${p.textMuted};`,
|
|
168
|
+
`--wp-edge: ${p.edgeBase};`,
|
|
169
|
+
`--wp-label-bg: ${p.labelBg};`,
|
|
170
|
+
`--wp-label-border: ${p.labelBorder};`,
|
|
171
|
+
`--wp-group-bg: ${p.groupBg};`,
|
|
172
|
+
`--wp-group-border: ${p.groupBorder};`,
|
|
173
|
+
`--wp-badge-bg: ${p.badgeBg};`,
|
|
174
|
+
`--wp-shadow: ${p.shadowColor};`,
|
|
175
|
+
`--wp-font: ${p.fontFamily};`,
|
|
176
|
+
`--wp-mono: ${p.monoFamily};`,
|
|
177
|
+
];
|
|
178
|
+
for (const name of ACCENT_NAMES) {
|
|
179
|
+
const a = ACCENTS[name][mode];
|
|
180
|
+
lines.push(`--wp-${name}: ${a.stroke};`, `--wp-${name}-glow: ${a.glow};`, `--wp-${name}-soft: ${a.softBg};`, `--wp-${name}-text: ${a.text};`);
|
|
181
|
+
}
|
|
182
|
+
return lines.join("\n ");
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Generates CSS variables block inside `<style>`.
|
|
186
|
+
* For `theme: "auto"`, defaults to clean GitHub Light and switches seamlessly
|
|
187
|
+
* to GitHub Midnight Dark via `@media (prefers-color-scheme: dark)`.
|
|
188
|
+
*/
|
|
189
|
+
export function buildThemeCss(theme) {
|
|
190
|
+
if (theme === "auto") {
|
|
191
|
+
return `
|
|
192
|
+
svg {
|
|
193
|
+
color-scheme: light dark;
|
|
194
|
+
${paletteToCssVars(THEMES.paper.palette, "light")}
|
|
195
|
+
}
|
|
196
|
+
@media (prefers-color-scheme: dark) {
|
|
197
|
+
svg {
|
|
198
|
+
${paletteToCssVars(THEMES.midnight.palette, "dark")}
|
|
199
|
+
}
|
|
200
|
+
}`;
|
|
201
|
+
}
|
|
202
|
+
const chosen = THEMES[theme] ?? THEMES.midnight;
|
|
203
|
+
return `
|
|
204
|
+
svg {
|
|
205
|
+
color-scheme: ${chosen.mode};
|
|
206
|
+
${paletteToCssVars(chosen.palette, chosen.mode)}
|
|
207
|
+
}`;
|
|
208
|
+
}
|