mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 07:19:19 +01:00
* design: every mark is one file, replaced with one command
pnpm run brand:import <slug> <file.svg>
converts any SVG (Figma, Illustrator, Inkscape, an icon set) into
src/config/marks/<slug>.ts, rebuilds the registry, and for this app's own
slug regenerates every static icon. Nothing else changes: the header,
hero, auth page, share cards, studio tiles, pillars and project banners
all render from the registry through one generic <Mark>, and know nothing
about which drawing they show.
- src/config/marks/: one data file per mark (viewBox + stroked/filled
shapes + motion), a generated index (MARKS, markFor), and generators/
for the marks drawn by code (OrangeCat's cat coil, Loki's coil). Solon's
scales were imported through the new command from lucide's SVG.
- <Mark>, <ProjectMark slug> (mark from the registry, else the initial),
BrandMarkIcon and the share-card mark all render any MarkDefinition.
PillarMark and sibling-marks.ts are gone.
- Giving any studio project a face is the same command with its fleet
slug; its tile and banner pick it up.
- The importer keeps geometry and how each shape is painted, drops colours
and a full-size background, and refuses transforms, clip paths, masks,
<use>, <text> and <image> with a message saying what to do, rather than
producing a mark that is quietly wrong.
- The brand test is written against any mark: registry matches the folder,
every mark is drawable, static icons equal exactly what the generator
writes. Replacing the drawing never means rewriting the test.
- Brand scripts run with plain node: a dependency-free resolve hook maps @/
and extensionless imports so they load the app's TypeScript directly.
Verified by swapping in a throwaway SVG end to end (icons regenerated,
background dropped, holes kept, gate green) and restoring the coil.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(home): the badge fits a phone, the headline breaks at its tone, Loki's banner opens Loki
Found reviewing the live site after #1314 deployed:
- the three-part hero badge ran off a 390px screen; on phones it now
carries the lead phrase alone
- the two-tone headline wrapped mid-phrase on desktop, so the dim tone
started partway through a line; the tail now takes its own line from sm
- StudioProjectBanner reused the tile's link for its door, which for a
project funded here is the page itself — Loki's banner had no way to
open Loki. FleetTile now carries liveUrl, tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(brand): the importer strips to a fixed point and refuses non-path data
CodeQL (3 high, incomplete multi-character sanitization): one pass of the
comment/<style> stripping over '<!<!--x-->-- … -->' leaves a fresh '<!--'
behind, and what it hid was then read as markup. The path is narrow — a
crafted SVG given to brand:import — but a mark's path data is written
verbatim into public files (favicon.svg), so it is closed twice:
- stripping repeats until nothing changes;
- every shape's path data must be pure path syntax (commands, numbers,
separators), or the import is refused with a message. A quote or angle
bracket can never reach a file, whatever the input looked like.
Tested both: a hidden shape behind a nested comment is not imported (a
single-pass strip imports it), and markup smuggled through a single-quoted
d is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(brand): read SVG comments and ignored blocks in one forward scan
CodeQL still flagged the comment/<style> stripping after a3e2b25: it does
not credit a repeat-until-stable loop, and rightly so in spirit — regex
removal is the wrong tool. withoutIgnoredMarkup() now walks the input once,
skipping comments, CDATA, processing instructions, doctypes and the
never-drawn blocks (defs, title, desc, metadata, style) by position. It
never re-reads what it emitted, so no removal can leave a new opener behind.
The CSS CDATA unwrap is split/join, not a regex replace.
Safety still rests on PATH_DATA: nothing but path syntax reaches a file.
Tests: contents of comments and never-drawn blocks are not imported; tangled
comments yield only path data; the scanner's skips are pinned. Re-importing
Solon's scales gives a byte-identical mark file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
---------
Co-authored-by: Claude <noreply@anthropic.com>
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
/**
|
|
* Module resolve hooks that let a plain `node` script import the app's
|
|
* TypeScript the way the app writes it: `@/…` for src/, and imports without
|
|
* a file extension. Node strips the types itself; this only finds the file.
|
|
*
|
|
* Registered by scripts/lib/register-ts.mjs. No dependency, on purpose: the
|
|
* brand scripts run where the repo's node_modules may not be installed.
|
|
*/
|
|
|
|
import { existsSync, statSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const SRC = new URL('../../src/', import.meta.url);
|
|
const CANDIDATES = ['.ts', '.tsx', '/index.ts'];
|
|
|
|
const isFile = url => {
|
|
try {
|
|
const path = fileURLToPath(url);
|
|
return existsSync(path) && statSync(path).isFile();
|
|
} catch {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
export async function resolve(specifier, context, nextResolve) {
|
|
const mapped = specifier.startsWith('@/') ? new URL(specifier.slice(2), SRC).href : specifier;
|
|
const isPathLike =
|
|
mapped.startsWith('file:') || mapped.startsWith('./') || mapped.startsWith('../');
|
|
if (isPathLike) {
|
|
const base = mapped.startsWith('file:') ? mapped : new URL(mapped, context.parentURL).href;
|
|
if (!isFile(base)) {
|
|
for (const ext of CANDIDATES) {
|
|
if (isFile(base + ext)) {
|
|
return nextResolve(base + ext, context);
|
|
}
|
|
}
|
|
}
|
|
return nextResolve(base, context);
|
|
}
|
|
return nextResolve(mapped, context);
|
|
}
|