@litfamily/litclaude 1.0.64 → 1.0.65
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 +17 -0
- package/README.md +9 -9
- package/README_ko-KR.md +9 -9
- package/bin/install-ui.mjs +43 -23
- package/bin/litclaude-ai.js +38 -6
- package/docs/assets/cover-motion-still.webp +0 -0
- package/docs/assets/cover-motion.webp +0 -0
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/hooks.md +32 -9
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hud.js +6 -14
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/hooks/lit-mod.mjs +32 -4
- package/plugins/litclaude/lib/mod/backdrop.mjs +95 -29
- package/plugins/litclaude/lib/mod/frame.mjs +7 -4
- package/plugins/litclaude/lib/mod/round.mjs +61 -0
- package/plugins/litclaude/lib/mod/settings.mjs +3 -6
- package/plugins/litclaude/lib/mod/svg-card.mjs +66 -26
- package/plugins/litclaude/lib/mod/svg-sunset.mjs +154 -0
- package/plugins/litclaude/lib/round-caps.mjs +60 -0
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
// brand pill and the border breathe (full and subtle), a light crosses the current stage and this
|
|
13
13
|
// request's chips, a bright head runs along the rail leaving the current stage, the count bar's
|
|
14
14
|
// head shimmers, the step spinner turns and a comet runs around the border (full only). Idle, it is
|
|
15
|
-
// still. The
|
|
15
|
+
// still. The sunset (svg-sunset.mjs) stands where no word does: it runs with the full motion and holds
|
|
16
|
+
// still otherwise. The drawing carries no step clock and no loop countdown: the surface loads each new
|
|
16
17
|
// drawing afresh, restarting every animation, so a figure that moves with time alone would make the
|
|
17
18
|
// card blink on every poll. Each loop opens where the session clock has it (see `loop`), so a fresh
|
|
18
19
|
// load carries on from the frame the last one showed rather than opening on a dim border and a
|
|
@@ -24,10 +25,10 @@
|
|
|
24
25
|
import { gauge, knownFacts } from "../rewind/gauge.mjs";
|
|
25
26
|
import { textWidth, truncateToWidth } from "./layout.mjs";
|
|
26
27
|
import { CLUB_GLINT, CLUB_GOLD, CLUB_PILL, CLUB_STOPS, LOOKS, lookOf } from "./looks.mjs";
|
|
27
|
-
import {
|
|
28
|
+
import { BAR_STOPS, TIMINGS, gradientAt, lerpColor, rainbowAt } from "./motion.mjs";
|
|
29
|
+
import { BRAND_STOPS, SKY, neonStops, shoreSvg, stopsOf, sunsetSvg } from "./svg-sunset.mjs";
|
|
28
30
|
|
|
29
31
|
const C = Object.freeze({
|
|
30
|
-
bg: "#0d1117",
|
|
31
32
|
pink: "#ff2d95",
|
|
32
33
|
orange: "#ff6337",
|
|
33
34
|
green: "#6bdb8f",
|
|
@@ -79,12 +80,18 @@ const esc = (text) => String(text).replace(/&/g, "&").replace(/</g, "<").
|
|
|
79
80
|
const widthOf = (text) => textWidth(text) * SVG_CARD.cell;
|
|
80
81
|
const levelColor = (percent) => (percent >= 90 ? C.hudRed : percent >= 70 ? C.hudYellow : C.hudGreen);
|
|
81
82
|
|
|
83
|
+
// The rectangles the card's words and pills take, collected while its rows are composed, so the
|
|
84
|
+
// sunset can keep clear of them.
|
|
85
|
+
let taken = [];
|
|
86
|
+
|
|
82
87
|
// Edge spaces become offsets: an SVG text element drops leading and trailing whitespace.
|
|
83
88
|
const text = (x, y, body, { fill = C.white, bold = false, anchor = "start" } = {}) => {
|
|
84
89
|
const lead = String(body).length - String(body).trimStart().length;
|
|
85
90
|
const trimmed = String(body).trim();
|
|
86
91
|
if (!trimmed) return "";
|
|
87
92
|
const at = anchor === "start" ? x + lead * SVG_CARD.cell : x;
|
|
93
|
+
const from = anchor === "start" ? at : at - widthOf(trimmed);
|
|
94
|
+
taken.push({ x0: from, y0: y - 11, x1: from + widthOf(trimmed), y1: y + 4 });
|
|
88
95
|
return `<text x="${at.toFixed(1)}" y="${y}" fill="${fill}"${bold ? ' font-weight="700"' : ""}${anchor === "start" ? "" : ` text-anchor="${anchor}"`}>${esc(trimmed)}</text>`;
|
|
89
96
|
};
|
|
90
97
|
|
|
@@ -104,6 +111,7 @@ const run = (x, y, pieces) => {
|
|
|
104
111
|
const pill = (x, y, label, { fill, ink, bold = true, sweep = false, breath = null, breathPeak = 0.85, veil = false }) => {
|
|
105
112
|
const w = widthOf(label) + 16;
|
|
106
113
|
const top = y - PILL_H + 6;
|
|
114
|
+
taken.push({ x0: x, y0: top, x1: x + w, y1: top + PILL_H });
|
|
107
115
|
const parts = [`<rect x="${x.toFixed(1)}" y="${top}" width="${w.toFixed(1)}" height="${PILL_H}" rx="${PILL_H / 2}" fill="${fill}"/>`];
|
|
108
116
|
if (veil) parts.push(`<rect x="${x.toFixed(1)}" y="${top}" width="${w.toFixed(1)}" height="${PILL_H}" rx="${PILL_H / 2}" fill="#ffffff" opacity="0.3"/>`);
|
|
109
117
|
if (breath) parts.push(`<rect x="${x.toFixed(1)}" y="${top}" width="${w.toFixed(1)}" height="${PILL_H}" rx="${PILL_H / 2}" fill="${breath}" opacity="0"><animate attributeName="opacity" values="0;${breathPeak};0" ${loop(TIMINGS.breath, BREATH_PHASE, 3)}/></rect>`);
|
|
@@ -112,6 +120,12 @@ const pill = (x, y, label, { fill, ink, bold = true, sweep = false, breath = nul
|
|
|
112
120
|
return { markup: parts.join(""), end: x + w };
|
|
113
121
|
};
|
|
114
122
|
|
|
123
|
+
// A round-ended gauge filled to `fraction`; an empty one draws its track alone.
|
|
124
|
+
const gaugeSvg = (x, y, w, h, fraction, fill) => {
|
|
125
|
+
const bar = (width, color) => `<rect x="${x.toFixed(1)}" y="${y}" width="${width.toFixed(1)}" height="${h}" rx="${h / 2}" fill="${color}"/>`;
|
|
126
|
+
return bar(w, C.empty) + (fraction > 0 ? bar(Math.max(h, w * Math.min(1, fraction)), fill) : "");
|
|
127
|
+
};
|
|
128
|
+
|
|
115
129
|
const indicatorOf = (model, accent) => {
|
|
116
130
|
if (model.completion) return { label: "DONE ✓", fill: C.green };
|
|
117
131
|
if (model.look === "turn") return { label: LOOKS.turn.label, fill: C.amber };
|
|
@@ -138,7 +152,7 @@ const topRow = (model, accent, animate, rewind = false) => {
|
|
|
138
152
|
const from = club ? pad + widthOf("✧ ") : pad;
|
|
139
153
|
const brand = rewind
|
|
140
154
|
? pill(from, y, "🔥 LIT", { fill: "url(#lit-rainbow)", ink: C.ink, veil: true })
|
|
141
|
-
: pill(from, y, "🔥 LIT", { fill: club ? CLUB_GOLD :
|
|
155
|
+
: pill(from, y, "🔥 LIT", { fill: club ? CLUB_GOLD : "url(#lit-brand)", ink: C.ink, breath: animate.breath ? "url(#lit-brand-hot)" : null });
|
|
142
156
|
const indicator = rewind && !model.completion ? { label: "REWIND <<", fill: "url(#lit-rainbow)" } : indicatorOf(model, accent);
|
|
143
157
|
// The club pill is 16 wider than the bare indicator text; it ends where the text would.
|
|
144
158
|
const pillWide = club ? 16 : 0;
|
|
@@ -186,7 +200,7 @@ const phaseRow = (model, accent, animate) => {
|
|
|
186
200
|
}
|
|
187
201
|
if (state === "now") {
|
|
188
202
|
const fill = model.idle ? C.muted : model.ctxWarning && id === "work" ? C.amber : accent;
|
|
189
|
-
const drawn = pill(x, y, LABELS[id], { fill, ink: model.idle ? C.mutedText : C.ink, sweep: animate.sweep });
|
|
203
|
+
const drawn = pill(x, y, LABELS[id], { fill: stageFill(model, accent, fill), ink: model.idle ? C.mutedText : C.ink, sweep: animate.sweep });
|
|
190
204
|
out.push(drawn.markup);
|
|
191
205
|
x = drawn.end;
|
|
192
206
|
} else {
|
|
@@ -206,6 +220,9 @@ const phaseRow = (model, accent, animate) => {
|
|
|
206
220
|
};
|
|
207
221
|
|
|
208
222
|
const mapColor = (accent, position) => gradientAt([C.orange, C.pink, accent], position);
|
|
223
|
+
// The current stage's pill: violet into the accent, as on the terminal card; a look, a context
|
|
224
|
+
// warning and the resting card keep their own fill.
|
|
225
|
+
const stageFill = (model, accent, plain) => ((model.look ?? null) === null && plain === accent ? "url(#lit-stage)" : plain);
|
|
209
226
|
const shortLabel = (label) => label.replace(/^[A-Za-z]+/u, (word) => word.slice(0, 3));
|
|
210
227
|
|
|
211
228
|
// Right-aligned groups after `x`, the leftmost dropped first when the row is short of room.
|
|
@@ -258,7 +275,7 @@ const mapRowSvg = (model, accent, animate) => {
|
|
|
258
275
|
x = drawn.end;
|
|
259
276
|
} else if (stage.state === "now") {
|
|
260
277
|
const fill = model.idle ? C.muted : model.ctxWarning ? C.amber : accent;
|
|
261
|
-
const drawn = pill(x, y, label, { fill, ink: model.idle ? C.mutedText : C.ink, sweep: animate.sweep, breath: animate.breath ? "#ffffff" : null, breathPeak: 0.2 });
|
|
278
|
+
const drawn = pill(x, y, label, { fill: stageFill(model, accent, fill), ink: model.idle ? C.mutedText : C.ink, sweep: animate.sweep, breath: animate.breath ? "#ffffff" : null, breathPeak: 0.2 });
|
|
262
279
|
out.push(drawn.markup);
|
|
263
280
|
x = drawn.end;
|
|
264
281
|
} else {
|
|
@@ -301,10 +318,12 @@ const detailRowSvg = (model, accent, animate) => {
|
|
|
301
318
|
const drawn = run(x, y, [[`${unit} `, { fill: C.dim }], [String(done), { fill: C.white, bold: true }], [`/${total} `, { fill: C.dim }]]);
|
|
302
319
|
out.push(drawn.markup);
|
|
303
320
|
x = drawn.end;
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
321
|
+
const fraction = total > 0 ? Math.min(1, done / total) : 0;
|
|
322
|
+
const bar = { w: 70, h: 10 };
|
|
323
|
+
out.push(`<defs><linearGradient id="lit-bar" x1="0" x2="1" y1="0" y2="0">${stopsOf([[0, BAR_STOPS[0]], [1, gradientAt(BAR_STOPS, fraction)]])}</linearGradient></defs>`
|
|
324
|
+
+ gaugeSvg(x, y - 10, bar.w, bar.h, fraction, "url(#lit-bar)"));
|
|
325
|
+
taken.push({ x0: x, y0: y - 10, x1: x + bar.w, y1: y });
|
|
326
|
+
if (fraction > 0 && animate.sweep) out.push(`<circle cx="${(x + Math.max(bar.h, bar.w * fraction) - bar.h / 2).toFixed(1)}" cy="${y - 10 + bar.h / 2}" r="${bar.h / 2 - 1}" fill="#ffffff" opacity="0"><animate attributeName="opacity" values="0;0.6;0" ${loop(TIMINGS.breath, BREATH_PHASE, 3)}/></circle>`);
|
|
308
327
|
x += 8 * 9 + 4;
|
|
309
328
|
}
|
|
310
329
|
const pieces = [];
|
|
@@ -429,8 +448,8 @@ const bottomRow = (model, accent, shift = 0) => {
|
|
|
429
448
|
out.push(drawn.markup);
|
|
430
449
|
x = drawn.end;
|
|
431
450
|
if (group.bar !== undefined) {
|
|
432
|
-
|
|
433
|
-
|
|
451
|
+
out.push(gaugeSvg(x + 8, y - 9, 47, 8, group.bar / 100, accent));
|
|
452
|
+
taken.push({ x0: x + 8, y0: y - 9, x1: x + 55, y1: y });
|
|
434
453
|
x += 60;
|
|
435
454
|
}
|
|
436
455
|
});
|
|
@@ -493,9 +512,10 @@ const threadRowsSvg = (model, { animate = false, rewind = false } = {}) => {
|
|
|
493
512
|
const mark = thread.task ? TASK_MARK[thread.task] ?? "$" : stateMark;
|
|
494
513
|
const name = truncateToWidth(thread.name, nameCells);
|
|
495
514
|
const drawn = gauge(thread.done, thread.total);
|
|
515
|
+
const [cells, count] = drawn ? drawn.split(" ") : [];
|
|
496
516
|
const facts = drawn ? null : threadFacts(thread);
|
|
497
517
|
const progress = drawn
|
|
498
|
-
? [[` ${
|
|
518
|
+
? [[" ", {}], [" ".repeat(textWidth(cells)), { gauge: thread.done / thread.total, color: rewind ? "url(#lit-rainbow)" : color }], [` ${count}`, { fill: C.white }], [` ${thread.state}`, { fill: color }]]
|
|
499
519
|
: [[" ", {}], [PULSE, { fill: rewind ? "url(#lit-rainbow)" : C.rail, pulse: true }], [" ", {}],
|
|
500
520
|
...(facts.startsWith(thread.state) ? [[facts, { fill: color }]] : [[thread.state, { fill: color }], [` · ${facts}`, { fill: C.dim }]])];
|
|
501
521
|
const pieces = [
|
|
@@ -519,17 +539,20 @@ const threadRowsSvg = (model, { animate = false, rewind = false } = {}) => {
|
|
|
519
539
|
used += cells;
|
|
520
540
|
}
|
|
521
541
|
out.push(run(pad, y, kept).markup);
|
|
542
|
+
const gaugeAt = kept.findIndex(([, style]) => style.gauge !== undefined);
|
|
543
|
+
if (gaugeAt >= 0) {
|
|
544
|
+
const x = pad + kept.slice(0, gaugeAt).reduce((sum, [body]) => sum + widthOf(body), 0);
|
|
545
|
+
out.push(gaugeSvg(x, y - 9, widthOf(kept[gaugeAt][0]), 9, kept[gaugeAt][1].gauge, kept[gaugeAt][1].color));
|
|
546
|
+
taken.push({ x0: x, y0: y - 9, x1: x + widthOf(kept[gaugeAt][0]), y1: y });
|
|
547
|
+
}
|
|
522
548
|
const before = kept.findIndex(([, style]) => style.pulse);
|
|
523
549
|
if (before >= 0) out.push(pulseSvg(pad + kept.slice(0, before).reduce((sum, [body]) => sum + widthOf(body), 0), y, animate, rewind ? "#ffffff" : C.white));
|
|
524
550
|
});
|
|
525
551
|
return out.join("");
|
|
526
552
|
};
|
|
527
553
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (model.warnings.length) return C.amber;
|
|
531
|
-
return model.idle ? C.faint : accent;
|
|
532
|
-
};
|
|
554
|
+
// A warning's border; otherwise the border is neon from pink through violet to the accent.
|
|
555
|
+
const borderColor = (model) => (model.warnings.some(({ tone }) => tone === "red") ? C.red : C.amber);
|
|
533
556
|
|
|
534
557
|
// The rewind look's border (plans/lit-adhd.md D7): a rainbow gradient whose stops each walk the hue
|
|
535
558
|
// wheel over TIMINGS.hue while the card moves, so the colours cycle; with motion off it stands still.
|
|
@@ -547,7 +570,7 @@ const rainbowDefs = (animate) => {
|
|
|
547
570
|
// The club look's ring: gold on the left side through rose to violet on the right, so the top edge
|
|
548
571
|
// and the bottom edge each carry the whole velvet and the ring closes gold on gold at the left, as
|
|
549
572
|
// the terminal card lays it clockwise. The pill gradient fills `CLUB ✦`.
|
|
550
|
-
const gradientStops = (
|
|
573
|
+
const gradientStops = (colors) => stopsOf(colors.map((color, i) => [(i / (colors.length - 1)).toFixed(3), color]));
|
|
551
574
|
const clubDefs = () => `<defs><linearGradient id="lit-club" x1="0" x2="1" y1="0" y2="0">${gradientStops(CLUB_STOPS.slice(0, 3))}</linearGradient>`
|
|
552
575
|
+ `<linearGradient id="lit-club-pill" x1="0" x2="1" y1="0" y2="0">${gradientStops(CLUB_PILL)}</linearGradient></defs>`;
|
|
553
576
|
|
|
@@ -593,10 +616,12 @@ export const svgCardAlt = (model) => {
|
|
|
593
616
|
*/
|
|
594
617
|
export const composeSvgCard = (model, { motion = "full", accent = "#5fd7ff", clock = 0 } = {}) => {
|
|
595
618
|
clockMs = clock;
|
|
619
|
+
taken = [];
|
|
596
620
|
try {
|
|
597
621
|
return composeCard(model, motion, accent);
|
|
598
622
|
} finally {
|
|
599
623
|
clockMs = 0;
|
|
624
|
+
taken = [];
|
|
600
625
|
}
|
|
601
626
|
};
|
|
602
627
|
|
|
@@ -609,17 +634,26 @@ const composeCard = (model, motion, accent) => {
|
|
|
609
634
|
const working = (!model.idle || rewind) && motion !== "off";
|
|
610
635
|
const animate = { breath: working, sweep: working && motion === "full", comet: working && motion === "full" };
|
|
611
636
|
const club = model.look === "club" && model.warnings.length === 0;
|
|
612
|
-
const
|
|
637
|
+
const calm = model.idle && !rewind && !club && model.look !== "turn";
|
|
638
|
+
const edge = rewind ? "url(#lit-rainbow)" : club ? "url(#lit-club)" : model.warnings.length ? borderColor(model) : "url(#lit-neon)";
|
|
613
639
|
const perimeter = 1000;
|
|
614
|
-
const
|
|
640
|
+
const across = (id, stops) => `<linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="0" x2="${width}" y1="0" y2="0">${stopsOf(stops)}</linearGradient>`;
|
|
641
|
+
const turn = model.look === "turn" ? ["#ff9a3c", "#ffc95a", C.amber].map((color, i) => [i / 2, color]) : null;
|
|
642
|
+
const defs = `<defs>${across("lit-sky", SKY.map((color, i) => [i / 2, color]))}${edge === "url(#lit-neon)" ? across("lit-neon", turn ?? neonStops(accent, calm)) : ""}`
|
|
643
|
+
+ `<linearGradient id="lit-brand" x1="0" x2="1" y1="0" y2="0">${gradientStops(BRAND_STOPS)}</linearGradient>`
|
|
644
|
+
+ (animate.breath ? `<linearGradient id="lit-brand-hot" x1="0" x2="1" y1="0" y2="0">${gradientStops(BRAND_STOPS.map((color) => lerpColor(color, "#ffffff", 0.32)))}</linearGradient>` : "")
|
|
645
|
+
+ (model.idle ? "" : `<linearGradient id="lit-stage" x1="0" x2="1" y1="0" y2="0">${gradientStops([lerpColor(accent, C.violet, 0.75), accent])}</linearGradient>`) + "</defs>"
|
|
646
|
+
+ (rewind ? rainbowDefs(animate.breath) : club ? clubDefs() : "")
|
|
647
|
+
+ (animate.sweep
|
|
615
648
|
? `<defs><linearGradient id="lit-sweep" x1="0" x2="1" y1="0" y2="0"><stop offset="0" stop-color="#fff" stop-opacity="0"/><stop offset="0.5" stop-color="#fff" stop-opacity="0.55"/><stop offset="1" stop-color="#fff" stop-opacity="0"/><animateTransform attributeName="gradientTransform" type="translate" values="-1.2 0;1.2 0" ${loop(TIMINGS.sweep, 0.5, 2)}/></linearGradient></defs>`
|
|
616
649
|
: "");
|
|
617
|
-
const frame = `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="
|
|
650
|
+
const frame = `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="url(#lit-sky)" stroke="${edge}" stroke-width="${calm ? "1.5" : "2.5"}"${calm ? ' stroke-opacity="0.8"' : ""}>`
|
|
618
651
|
+ (animate.breath && !model.warnings.length ? `<animate attributeName="stroke-opacity" values="0.85;1;0.85" ${loop(TIMINGS.breath, BREATH_PHASE, 3)}/>` : "")
|
|
619
|
-
+ "</rect>"
|
|
652
|
+
+ "</rect>"
|
|
653
|
+
// The neon's own light on the card, just inside the border.
|
|
654
|
+
+ (calm ? "" : [[2.5, 2, 0.16], [5.5, 5, 0.06]].map(([inset, w, alpha]) => `<rect x="${inset}" y="${inset}" width="${width - inset * 2}" height="${height - inset * 2}" rx="${15 - inset}" fill="none" stroke="${edge}" stroke-width="${w}" stroke-opacity="${alpha}"/>`).join(""));
|
|
620
655
|
const comet = animate.comet
|
|
621
|
-
? `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="none" stroke="
|
|
622
|
-
+ `<defs><linearGradient id="lit-comet" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="${C.orange}"/><stop offset="0.6" stop-color="${C.pink}"/><stop offset="1" stop-color="#ffffff"/></linearGradient></defs>`
|
|
656
|
+
? `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="none" stroke="#fff0d8" stroke-width="2.5" stroke-linecap="round" pathLength="${perimeter}" stroke-dasharray="46 ${perimeter - 46}"><animate attributeName="stroke-dashoffset" values="0;-${perimeter}" ${loop(TIMINGS.comet * 2, 0.5)}/></rect>`
|
|
623
657
|
: "";
|
|
624
658
|
const body = [
|
|
625
659
|
topRow(model, accent, animate, rewind),
|
|
@@ -629,7 +663,13 @@ const composeCard = (model, motion, accent) => {
|
|
|
629
663
|
middleRow(model, accent, animate, shift, rewind),
|
|
630
664
|
bottomRow(model, accent, shift),
|
|
631
665
|
].join("");
|
|
666
|
+
// The scene is composed after the rows, whose words it keeps clear of; a card that only breathes or
|
|
667
|
+
// rests holds it still.
|
|
668
|
+
const look = rewind ? "rewind" : model.look === "club" || model.look === "turn" ? model.look : "sunset";
|
|
669
|
+
const dim = model.idle && look === "sunset" && !model.completion;
|
|
670
|
+
const scene = sunsetSvg({ taken, width, height, look, dim, move: animate.sweep, loop });
|
|
671
|
+
const shore = scene && !model.warnings.length ? shoreSvg({ taken, width, height, look, dim }) : "";
|
|
632
672
|
const glint = club && motion === "full" ? clubGlintSvg(width) : "";
|
|
633
|
-
const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" font-family="${FONT}" font-size="${SVG_CARD.font}">${defs}${frame}${comet}${glint}${body}</svg>`;
|
|
673
|
+
const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" font-family="${FONT}" font-size="${SVG_CARD.font}">${defs}${frame}${shore}${comet}${glint}${body}${scene}</svg>`;
|
|
634
674
|
return { source, alt: svgCardAlt(model), animated: working || glint !== "" };
|
|
635
675
|
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// The sunset on the SVG card (svg-card.mjs): the terminal card's scene (sunset.mjs) drawn as vector
|
|
2
|
+
// art. A half-sunk sun in slices, its glow, a layered sea that runs outward from it with the sun's
|
|
3
|
+
// reflection on it, stars and a shooting star. Text always wins: each part is placed against the
|
|
4
|
+
// rectangles the card's words, pills and gauges take (`taken`) and left out where it has no room.
|
|
5
|
+
// Light is gradients only, with no filter, so a moving card has nothing expensive to redraw.
|
|
6
|
+
|
|
7
|
+
import { lerpColor, rainbowAt } from "./motion.mjs";
|
|
8
|
+
|
|
9
|
+
const FAINT = "#30363d";
|
|
10
|
+
// What the resting card's scene fades towards.
|
|
11
|
+
const DUSK = "#33203f";
|
|
12
|
+
const LOOK = Object.freeze({
|
|
13
|
+
sunset: { sun: ["#ffe27a", "#ff9a3c", "#ff2d8a"], sea: ["#ffdc73", "#ff9a4a", "#ff4f8b", "#b457d6", "#5a46a8"] },
|
|
14
|
+
club: { sun: ["#fff0b0", "#ffb38a", "#ff8fbf"], sea: ["#ffd75f", "#ffb38a", "#ff8fbf", "#b48cff", "#6a5aa8"] },
|
|
15
|
+
turn: { sun: ["#fff0b8", "#ffc95a", "#e08a1e"], sea: ["#ffd98a", "#ffaf3c", "#e08a1e", "#9a6420", "#5a4020"] },
|
|
16
|
+
rewind: { sun: [0.14, 0.02, 0.85].map((at) => lerpColor(rainbowAt(at), "#ffffff", 0.25)), sea: [0.14, 0.05, 0.9, 0.76, 0.62].map(rainbowAt) },
|
|
17
|
+
});
|
|
18
|
+
// The border's neon, left to right; the accent follows as the last stop.
|
|
19
|
+
export const NEON = Object.freeze(["#ff2d95", "#b48cff"]);
|
|
20
|
+
export const BRAND_STOPS = Object.freeze(["#ffa033", "#ff2d95"]);
|
|
21
|
+
// The card's own sky behind everything: dark enough that every ink on it keeps its contrast.
|
|
22
|
+
export const SKY = Object.freeze(["#0d1117", "#100f20", "#191031"]);
|
|
23
|
+
|
|
24
|
+
// Where the sun may stand, `[x, radius, how far it is sunk]`: its place on the card first, full size
|
|
25
|
+
// then small, then further right; under crowded rows only its rim shows above the sea.
|
|
26
|
+
export const SUN_SPOTS = Object.freeze([[624, 58, 0], [624, 40, 0], [776, 40, 0], [624, 64, 54], [776, 64, 54]]);
|
|
27
|
+
export const HORIZON = 24;
|
|
28
|
+
const EDGE = 2;
|
|
29
|
+
// The slices of the dome, as heights above the horizon in radii; the gaps between them widen downwards.
|
|
30
|
+
const SLICES = Object.freeze([[1, 0.6], [0.55, 0.39], [0.32, 0.205], [0.12, 0]]);
|
|
31
|
+
// Star fields: a twinkle period, a size, and where each star stands (x, y up from the horizon).
|
|
32
|
+
const STARS = Object.freeze([
|
|
33
|
+
[2900, 2, [[446, 96], [498, 58], [556, 104], [586, 70], [668, 92], [718, 34], [744, 98], [806, 60], [846, 22]]],
|
|
34
|
+
[3700, 1.6, [[430, 52], [474, 20], [520, 86], [546, 40], [702, 76], [732, 14], [768, 70], [820, 100], [852, 78]]],
|
|
35
|
+
[4300, 2.5, [[462, 74], [536, 18], [690, 52], [760, 40], [792, 88], [834, 44]]],
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const n3 = (value) => +value.toFixed(3);
|
|
39
|
+
const n1 = (value) => +value.toFixed(1);
|
|
40
|
+
// The words of a row that stand close together read as one block: no art goes in their gaps.
|
|
41
|
+
const blocks = (taken) => {
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const rect of [...taken].sort((a, b) => a.y0 - b.y0 || a.x0 - b.x0)) {
|
|
44
|
+
const last = out.at(-1);
|
|
45
|
+
if (last && rect.y0 < last.y1 && rect.y1 > last.y0 && rect.x0 - last.x1 < 100 && rect.x0 >= last.x0) {
|
|
46
|
+
last.x1 = Math.max(last.x1, rect.x1);
|
|
47
|
+
last.y0 = Math.min(last.y0, rect.y0);
|
|
48
|
+
last.y1 = Math.max(last.y1, rect.y1);
|
|
49
|
+
} else out.push({ ...rect });
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
};
|
|
53
|
+
const clear = (rects, x0, y0, x1, y1) => rects.every((r) => r.x1 <= x0 || r.x0 >= x1 || r.y1 <= y0 || r.y0 >= y1);
|
|
54
|
+
const distance = (rect, x, y) => Math.hypot(Math.max(rect.x0 - x, 0, x - rect.x1), Math.max(rect.y0 - y, 0, y - rect.y1));
|
|
55
|
+
const stops = (list) => list.map(([at, color, alpha = 1]) => `<stop offset="${at}" stop-color="${color}"${alpha === 1 ? "" : ` stop-opacity="${alpha}"`}/>`).join("");
|
|
56
|
+
|
|
57
|
+
const dome = ({ cx, cy, r, sink }) => SLICES.filter(([top]) => top * r > sink).map(([top, low]) => {
|
|
58
|
+
const foot = Math.max(low, sink / r);
|
|
59
|
+
const [w0, w1] = [top, foot].map((d) => n1(r * Math.sqrt(1 - d * d)));
|
|
60
|
+
const [y0, y1] = [n1(cy + sink - r * top), n1(cy + sink - r * foot)];
|
|
61
|
+
return `M${n1(cx - w1)} ${y1}A${r} ${r} 0 0 1 ${n1(cx - w0)} ${y0}H${n1(cx + w0)}A${r} ${r} 0 0 1 ${n1(cx + w1)} ${y1}Z`;
|
|
62
|
+
}).join("");
|
|
63
|
+
|
|
64
|
+
/** Where the sun stands on a card `height` tall, `{ cx, cy, r, sink, half }` (`half` its half-width at the sea), or null when words take its place. */
|
|
65
|
+
export const sunSpot = (taken, width, height) => {
|
|
66
|
+
const cy = height - HORIZON;
|
|
67
|
+
const rects = blocks(taken);
|
|
68
|
+
const spots = SUN_SPOTS.map(([cx, r, sink]) => ({ cx, cy, r, sink, half: Math.round(Math.sqrt(r * r - sink * sink)) }));
|
|
69
|
+
return spots.find(({ cx, r, sink, half }) => clear(rects, cx - half - 8, cy - r + sink - 2, cx + half + 8, cy) && clear(rects, cx - half - 24, cy, width, height)) ?? null;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The scene's markup. `move` runs its loops (`loop` is the card's timing helper); `dim` is the
|
|
74
|
+
* resting card's quieter colour. Returns "" when the sun has no room.
|
|
75
|
+
*/
|
|
76
|
+
export const sunsetSvg = ({ taken, width, height, look = "sunset", dim = false, move = false, loop }) => {
|
|
77
|
+
const spot = sunSpot(taken, width, height);
|
|
78
|
+
if (!spot) return "";
|
|
79
|
+
const { cx, cy, r, sink, half } = spot;
|
|
80
|
+
const rects = blocks(taken);
|
|
81
|
+
const ink = LOOK[look] ?? LOOK.sunset;
|
|
82
|
+
const shade = (color) => (dim ? lerpColor(color, DUSK, 0.45) : color);
|
|
83
|
+
const sun = ink.sun.map(shade);
|
|
84
|
+
const sea = ink.sea.map(shade);
|
|
85
|
+
const live = (markup) => (move ? markup : "");
|
|
86
|
+
const left = Math.max(EDGE, ...rects.filter((rect) => rect.y1 > cy - 2).map((rect) => rect.x1 + 24));
|
|
87
|
+
const reach = Math.max(150, Math.min(340, cx - left));
|
|
88
|
+
const glow = Math.floor(Math.min(128, ...rects.map((rect) => distance(rect, cx, cy))));
|
|
89
|
+
const parts = [];
|
|
90
|
+
const defs = [
|
|
91
|
+
`<clipPath id="lit-sea"><path d="M${left} ${cy}H${width - EDGE}V${height - 15}a13 13 0 0 1 -13 13H${left}Z"/></clipPath>`,
|
|
92
|
+
`<clipPath id="lit-out"><rect width="${width}" height="${HORIZON}"/></clipPath>`,
|
|
93
|
+
`<linearGradient id="lit-sun" x1="0" x2="0" y1="0" y2="1">${stops([[0, sun[0]], [0.5, sun[1]], [1, sun[2]]])}</linearGradient>`,
|
|
94
|
+
`<radialGradient id="lit-water" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="${reach}">${stops([[0, sea[0]], [0.22, sea[1]], [0.48, sea[2], 0.9], [0.74, sea[3], 0.5], [0.92, sea[4], 0.12], [1, sea[4], 0]])}</radialGradient>`,
|
|
95
|
+
`<radialGradient id="lit-deep" gradientUnits="userSpaceOnUse" cx="${cx}" cy="${cy}" r="${reach}">${stops([[0, sea[2], 0.42], [0.4, sea[3], 0.2], [1, sea[4], 0]])}</radialGradient>`,
|
|
96
|
+
`<linearGradient id="lit-path" x1="0" x2="1" y1="0" y2="0">${stops([[0, sun[2], 0], [0.25, sun[2]], [0.5, sun[0]], [0.75, sun[2]], [1, sun[2], 0]])}</linearGradient>`,
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
// The sky: stars wherever no word stands within a few pixels, and a shooting star that crosses in
|
|
100
|
+
// the free strip between the map and the detail row.
|
|
101
|
+
for (const [period, size, list] of STARS) {
|
|
102
|
+
const d = list.filter(([x, up]) => clear(rects, x - 9, cy - up - 8, x + 9, cy - up + 8) && Math.hypot(x - cx, up + sink) > r + 9).map(([x, up]) => `M${x} ${cy - up}h0`).join("");
|
|
103
|
+
if (d) parts.push(`<path class="lit-star" d="${d}" stroke="${shade(period === 3700 ? "#ff9ad5" : "#b9adff")}" stroke-width="${size}" stroke-linecap="round" opacity="${dim ? 0.55 : 0.85}">${live(`<animate attributeName="opacity" values="0.35;1;0.35" ${loop(period, 0.3, 3)}/>`)}</path>`);
|
|
104
|
+
}
|
|
105
|
+
if (move && clear(rects, 470, 65, width - 18, 74)) {
|
|
106
|
+
defs.push(`<linearGradient id="lit-shoot" x1="0" x2="1" y1="0" y2="0">${stops([[0, "#fff4e0"], [1, "#b457d6", 0]])}</linearGradient>`);
|
|
107
|
+
parts.push(`<rect class="lit-shoot" x="${width}" y="66" width="44" height="1.6" rx="0.8" fill="url(#lit-shoot)"><animateTransform attributeName="transform" type="translate" values="0 0;-396 6;0 0;0 0" keyTimes="0;0.1;0.1;1" ${loop(9000, 0.5)}/><animate attributeName="opacity" values="0;0.95;0;0" keyTimes="0;0.03;0.1;1" ${loop(9000, 0.5)}/></rect>`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The sun: its glow reaches as far as the nearest word, never under one.
|
|
111
|
+
if (!sink && glow > r + 6) {
|
|
112
|
+
const rim = r / glow;
|
|
113
|
+
const fall = (k, alpha) => [n3(rim + (1 - rim) * k), sun[2], alpha];
|
|
114
|
+
defs.push(`<radialGradient id="lit-glow" gradientUnits="userSpaceOnUse" cx="${cx}" cy="${cy}" r="${glow}">${stops([[n3(rim * 0.94), sun[2], 0], [n3(rim), sun[2], 0.6], fall(0.12, 0.36), fall(0.35, 0.17), fall(0.62, 0.06), fall(1, 0)])}</radialGradient>`);
|
|
115
|
+
parts.push(`<path class="lit-glow" d="M${cx - glow} ${cy}a${glow} ${glow} 0 0 1 ${glow * 2} 0Z" fill="url(#lit-glow)" opacity="${dim ? 0.5 : 0.95}">${live(`<animate attributeName="opacity" values="0.7;1;0.7" ${loop(4800, 0.25, 3)}/>`)}</path>`);
|
|
116
|
+
}
|
|
117
|
+
const shape = dome(spot);
|
|
118
|
+
parts.push(`<path class="lit-sun" d="${shape}" fill="url(#lit-sun)"/>`);
|
|
119
|
+
// Heat: a soft light climbs the sun again and again.
|
|
120
|
+
if (move) {
|
|
121
|
+
defs.push(`<linearGradient id="lit-heat" x1="0" x2="0" y1="1" y2="0">${stops([[0, "#fff6d6", 0], [0.5, "#fff6d6", 0.5], [1, "#fff6d6", 0]])}<animateTransform attributeName="gradientTransform" type="translate" values="0 1;0 -1" ${loop(3400, 0.5)}/></linearGradient>`);
|
|
122
|
+
parts.push(`<path d="${shape}" fill="url(#lit-heat)"/>`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The sea: deep light, three layers of waves drawn to the right of the sun and mirrored to its
|
|
126
|
+
// left, so both sides run outward, the sun's broken reflection, and a bright horizon. A wave takes its
|
|
127
|
+
// paint along as it runs, so its colour is carried back as far: the light stays with the sun.
|
|
128
|
+
const wave = (i, y, half, rise, weight, period, phase) => {
|
|
129
|
+
const turns = Math.ceil((reach + half * 2) / half);
|
|
130
|
+
if (move) defs.push(`<radialGradient id="lit-water-${i}" href="#lit-water"><animateTransform attributeName="gradientTransform" type="translate" values="0 0;${-half * 2} 0" ${loop(period, phase)}/></radialGradient>`);
|
|
131
|
+
return `<path d="M${-half * 2} ${y}q${half / 2} ${-rise} ${half} 0${`t${half} 0`.repeat(turns)}" stroke="url(#lit-water${move ? `-${i}` : ""})" stroke-width="${weight}">${live(`<animateTransform attributeName="transform" type="translate" values="0 0;${half * 2} 0" ${loop(period, phase)}/>`)}</path>`;
|
|
132
|
+
};
|
|
133
|
+
parts.push(
|
|
134
|
+
`<g clip-path="url(#lit-sea)"${dim ? ' opacity="0.7"' : ""}><rect x="${left}" y="${cy}" width="${width - left}" height="${HORIZON}" fill="url(#lit-deep)"/>`
|
|
135
|
+
+ `<g transform="translate(${cx} ${cy})" fill="none" stroke-linecap="round"><g id="lit-waves" clip-path="url(#lit-out)">${wave(0, 5, 13, 2.6, 1.1, 2200, 0.4)}${wave(1, 11, 19, 3.6, 1.4, 3100, 0.2)}${wave(2, 18, 27, 4.6, 1.7, 4700, 0.6)}</g><use href="#lit-waves" transform="scale(-1 1)"/></g>`
|
|
136
|
+
+ [[[3, 1.85], [13.8, 1.1]], [[8.4, 1.5], [19, 0.66]]].map((bars, i) => `<g transform="translate(${cx} ${cy})"><g fill="url(#lit-path)">${bars.map(([dy, k]) => `<rect x="${n1(-half * k)}" y="${dy}" width="${n1(half * k * 2)}" height="2.5" rx="1.2" opacity="${n1(1 - dy / 32)}"/>`).join("")}${live(`<animateTransform attributeName="transform" type="scale" values="1 1;0.8 1;1 1" ${loop(2300 + i * 500, 0.25, 3)}/>`)}</g></g>`).join("")
|
|
137
|
+
+ `</g><rect x="${cx - reach}" y="${cy - 0.8}" width="${reach * 2}" height="1.6" fill="url(#lit-path)" clip-path="url(#lit-sea-line)"/>`,
|
|
138
|
+
);
|
|
139
|
+
defs.push(`<clipPath id="lit-sea-line"><rect x="${left}" y="${cy - 1}" width="${width - EDGE - left}" height="2"/></clipPath>`);
|
|
140
|
+
return `<g class="lit-scene"><defs>${defs.join("")}</defs>${parts.join("")}</g>`;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** The sun's light on the card's bottom edge, or "" with no sun. */
|
|
144
|
+
export const shoreSvg = ({ taken, width, height, look = "sunset", dim = false }) => {
|
|
145
|
+
const spot = sunSpot(taken, width, height);
|
|
146
|
+
if (!spot) return "";
|
|
147
|
+
const [gold, orange] = (LOOK[look] ?? LOOK.sunset).sun.map((color) => (dim ? lerpColor(color, FAINT, 0.45) : color));
|
|
148
|
+
const [x0, x1] = [spot.cx - 170, Math.min(width - 15, spot.cx + 170)];
|
|
149
|
+
return `<defs><linearGradient id="lit-shore" gradientUnits="userSpaceOnUse" x1="${spot.cx - 170}" x2="${spot.cx + 170}" y1="0" y2="0">${stops([[0, orange, 0], [0.3, orange, 0.8], [0.5, gold], [0.7, orange, 0.8], [1, orange, 0]])}</linearGradient></defs><rect class="lit-shore" x="${x0}" y="${height - 2.25}" width="${x1 - x0}" height="2.5" fill="url(#lit-shore)"/>`;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** The neon border's stops across a card, dimmed at rest. */
|
|
153
|
+
export const neonStops = (accent, dim) => [...NEON, accent].map((color, i) => [i / 2, dim ? lerpColor(color, FAINT, 0.45) : color]);
|
|
154
|
+
export const stopsOf = stops;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// lib/mod/round.mjs's rule for the processes that run on Node: the status line and the installer.
|
|
2
|
+
|
|
3
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { ignitionStateRoot } from "./hud-ignition.mjs";
|
|
7
|
+
import { findNerdFont, fontFolders, glyphSetting, roundCaps } from "./mod/round.mjs";
|
|
8
|
+
|
|
9
|
+
const DAY_MS = 86_400_000;
|
|
10
|
+
const withHome = (env) => ({ ...env, HOME: env.HOME?.trim() || homedir() });
|
|
11
|
+
const listFolder = (path) => readdirSync(path, { withFileTypes: true })
|
|
12
|
+
.map((entry) => ({ name: entry.name, kind: entry.isFile() ? "file" : entry.isDirectory() ? "dir" : "other", isLink: !entry.isFile() && !entry.isDirectory() }));
|
|
13
|
+
|
|
14
|
+
export const nerdFontInstalled = (env = process.env) => findNerdFont(listFolder, fontFolders(withHome(env)));
|
|
15
|
+
|
|
16
|
+
/** The status line draws often, so its answer is kept for a day, or until a font folder changes. */
|
|
17
|
+
export const nerdFontInstalledCached = async (env = process.env, now = Date.now()) => {
|
|
18
|
+
const key = fontFolders(withHome(env)).map((path) => {
|
|
19
|
+
try {
|
|
20
|
+
return `${path}:${statSync(path).mtimeMs}`;
|
|
21
|
+
} catch {
|
|
22
|
+
return `${path}:`;
|
|
23
|
+
}
|
|
24
|
+
}).join("|");
|
|
25
|
+
const root = ignitionStateRoot(env);
|
|
26
|
+
const file = join(root, "nerd-font.json");
|
|
27
|
+
try {
|
|
28
|
+
const saved = JSON.parse(readFileSync(file, "utf8"));
|
|
29
|
+
if (saved.key === key && now >= saved.at && now - saved.at < DAY_MS && typeof saved.found === "boolean") return saved.found;
|
|
30
|
+
} catch {
|
|
31
|
+
// No answer saved yet, or an unreadable one: look again.
|
|
32
|
+
}
|
|
33
|
+
const found = await nerdFontInstalled(env);
|
|
34
|
+
try {
|
|
35
|
+
mkdirSync(root, { recursive: true });
|
|
36
|
+
const staging = `${file}.${process.pid}.tmp`;
|
|
37
|
+
writeFileSync(staging, JSON.stringify({ key, at: now, found }));
|
|
38
|
+
renameSync(staging, file);
|
|
39
|
+
} catch {
|
|
40
|
+
// Without a place to keep it the next draw looks again.
|
|
41
|
+
}
|
|
42
|
+
return found;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** The card's stored `glyphs` option, whichever marketplace LitClaude came from. */
|
|
46
|
+
export const storedGlyphs = (settings) => Object.entries(settings?.pluginConfigs ?? {}).find(([key]) => key.startsWith("litclaude@"))?.[1]?.options?.glyphs;
|
|
47
|
+
|
|
48
|
+
const readSettings = (env) => {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(readFileSync(join(env.CLAUDE_CONFIG_DIR || env.CLAUDE_HOME || join(withHome(env).HOME, ".claude"), "settings.json"), "utf8"));
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const roundCapsHere = ({ env = process.env, cached = false, settings = readSettings(env) } = {}) => roundCaps({
|
|
57
|
+
env,
|
|
58
|
+
setting: glyphSetting(env, storedGlyphs(settings)),
|
|
59
|
+
hasFont: () => (cached ? nerdFontInstalledCached(env) : nerdFontInstalled(env)),
|
|
60
|
+
});
|