mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
refactor(shared-tailwind): rewrite themes.css to single-layer shadcn convention
Pre-launch theme system audit found multiple parallel layers in themes.css
(--theme-X full hsl strings, --X partial shadcn aliases, --color-X populated
by runtime store with raw channels) plus dead-code companion files. The
inconsistency caused light-mode regressions when scoped-CSS consumers
wrote `var(--color-X)` standalone — the variable holds raw HSL channels
which is invalid as a color value, browser fell back to inherited (white).
Rewrite to one consistent layer:
- Source of truth: --color-X defined as raw HSL channels (e.g.
`0 0% 17%`) in :root, .dark, and all variant [data-theme="..."]
blocks. Matches the format the runtime store
(@mana/shared-theme/src/utils.ts) writes, eliminating the
static-fallback-vs-runtime mismatch and the corresponding flash
of unstyled content on hydration.
- @theme inline uses self-reference + Tailwind v4 <alpha-value>
placeholder so utility classes generate correctly AND opacity
modifiers work: `text-foreground/50` → `hsl(var(--color-foreground) / 0.5)`.
- @layer components (.btn-primary, .card, .badge, etc.) wraps
var(--color-X) refs with hsl() — they were broken in light mode
too for the same reason.
Convention going forward (also documented in the file header):
1. Markup: use Tailwind utility classes (text-foreground, bg-card, …)
2. Scoped CSS: hsl(var(--color-X)) — always wrap with hsl()
3. NEVER raw var(--color-X) in CSS — that's the bug pattern
Net file: 692 → 580 LOC. Single source layer, no indirection.
Also delete dead companion files (zero imports anywhere):
- tailwind-v4.css (had broken self-reference, never imported)
- theme-variables.css (legacy hex-based palette)
- components.css (legacy component utilities)
- index.js / preset.js / colors.js (Tailwind v3 preset format,
irrelevant under Tailwind v4)
package.json exports map shrinks accordingly to just `./themes.css`.
Consumers using `hsl(var(--color-X))` (~379 files across mana-web,
manavoxel-web, arcade-web) keep working unchanged — the public API
name `--color-X` is preserved. Only the broken pattern `var(--color-X)`
(~61 files) needs a follow-up sweep, handled in a separate commit.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3a3cd126cf
commit
919fcca4b7
63 changed files with 1072 additions and 5398 deletions
|
|
@ -9,10 +9,11 @@
|
|||
import { Hono } from 'hono';
|
||||
import { streamSSE } from 'hono/streaming';
|
||||
import { consumeCredits, validateCredits } from '@mana/shared-hono/credits';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const LLM_URL = process.env.MANA_LLM_URL || 'http://localhost:3025';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Chat Completion (sync) ──────────────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const ALLOWED_AVATAR_TYPES = new Set([
|
||||
'image/jpeg',
|
||||
|
|
@ -13,7 +14,7 @@ const ALLOWED_AVATAR_TYPES = new Set([
|
|||
'image/svg+xml',
|
||||
]);
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Avatar Upload (S3) ─────────────────────────────────────
|
||||
|
||||
|
|
@ -33,9 +34,7 @@ routes.post('/:id/avatar', async (c) => {
|
|||
|
||||
if (file.type === 'image/svg+xml') {
|
||||
// SVGs stay on shared-storage (Sharp can't process SVG)
|
||||
const { createContactsStorage, generateUserFileKey } = await import(
|
||||
'@mana/shared-storage'
|
||||
);
|
||||
const { createContactsStorage, generateUserFileKey } = await import('@mana/shared-storage');
|
||||
const storage = createContactsStorage();
|
||||
const key = generateUserFileKey(userId, `avatar-${c.req.param('id')}.svg`);
|
||||
const result = await storage.upload(key, Buffer.from(buffer), {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@
|
|||
|
||||
import { Hono } from 'hono';
|
||||
import { consumeCredits, validateCredits } from '@mana/shared-hono/credits';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const LLM_URL = process.env.MANA_LLM_URL || 'http://localhost:3025';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── AI Generation (server-only: mana-llm) ──────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
* This module handles web import via mana-search + mana-llm, and share links.
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { Hono, type Context } from 'hono';
|
||||
import { logger } from '@mana/shared-hono';
|
||||
|
||||
const MANA_SEARCH_URL = process.env.MANA_SEARCH_URL ?? 'http://localhost:3021';
|
||||
const MANA_LLM_URL = process.env.MANA_LLM_URL ?? 'http://localhost:3030';
|
||||
|
|
@ -35,7 +36,7 @@ routes.post('/import/url', async (c) => {
|
|||
extracted = await res.json();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('mana-search extract failed:', e);
|
||||
logger.error('guides.extract_failed', { error: e instanceof Error ? e.message : String(e) });
|
||||
}
|
||||
|
||||
const content = extracted.markdown ?? extracted.content ?? '';
|
||||
|
|
@ -128,7 +129,7 @@ routes.get('/share/:token', (c) => {
|
|||
// ─── Shared: LLM guide generation ──────────────────────────
|
||||
|
||||
async function generateGuideFromText(
|
||||
c: Parameters<Parameters<typeof Hono.prototype.post>[1]>[0],
|
||||
c: Context,
|
||||
opts: { text: string; title?: string; sourceUrl?: string; isAiPrompt?: boolean }
|
||||
) {
|
||||
const systemPrompt = `Du bist ein Experte für das Erstellen strukturierter Schritt-für-Schritt-Anleitungen.
|
||||
|
|
@ -189,7 +190,7 @@ Regeln:
|
|||
throw new Error(`LLM error: ${llmRes.status}`);
|
||||
}
|
||||
|
||||
const llmData = await llmRes.json<{ content: string }>();
|
||||
const llmData = (await llmRes.json()) as { content: string };
|
||||
const rawJson = llmData.content.trim();
|
||||
|
||||
// Extract JSON from potential markdown code fences
|
||||
|
|
@ -209,7 +210,7 @@ Regeln:
|
|||
sections: parsed.sections ?? [],
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Guide generation failed:', e);
|
||||
logger.error('guides.generate_failed', { error: e instanceof Error ? e.message : String(e) });
|
||||
return c.json({ error: 'Guide-Generierung fehlgeschlagen', details: String(e) }, 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Song Upload (presigned URL) ────────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { logger, type AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const LLM_URL = process.env.MANA_LLM_URL || 'http://localhost:3025';
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ const ANALYSIS_PROMPT = `Du bist ein Ernährungsexperte. Analysiere die Mahlzeit
|
|||
"suggestions": []
|
||||
}`;
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Photo Analysis (server-only: Gemini Vision) ────────────
|
||||
|
||||
|
|
@ -81,7 +82,9 @@ routes.post('/analysis/photo', async (c) => {
|
|||
|
||||
return c.json(analysis);
|
||||
} catch (err) {
|
||||
console.error('Photo analysis failed:', err);
|
||||
logger.error('nutriphi.photo_analysis_failed', {
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
return c.json({ error: 'Analysis failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
|
@ -115,7 +118,9 @@ routes.post('/analysis/text', async (c) => {
|
|||
|
||||
return c.json(analysis);
|
||||
} catch (err) {
|
||||
console.error('Text analysis failed:', err);
|
||||
logger.error('nutriphi.text_analysis_failed', {
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
return c.json({ error: 'Analysis failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@
|
|||
|
||||
import { Hono } from 'hono';
|
||||
import { consumeCredits, validateCredits } from '@mana/shared-hono/credits';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const REPLICATE_TOKEN = process.env.REPLICATE_API_TOKEN || '';
|
||||
const IMAGE_GEN_URL = process.env.MANA_IMAGE_GEN_URL || '';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── AI Image Generation (server-only: Replicate/local) ─────
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { logger, type AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const LLM_URL = process.env.MANA_LLM_URL || 'http://localhost:3025';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Photo Upload (server-only: S3 storage) ─────────────────
|
||||
|
||||
|
|
@ -38,7 +39,9 @@ routes.post('/photos/upload', async (c) => {
|
|||
201
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Upload failed:', err);
|
||||
logger.error('planta.upload_failed', {
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
return c.json({ error: 'Upload failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
|
@ -81,7 +84,9 @@ routes.post('/analysis/identify', async (c) => {
|
|||
|
||||
return c.json(analysis);
|
||||
} catch (err) {
|
||||
console.error('Analysis failed:', err);
|
||||
logger.error('planta.analysis_failed', {
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
return c.json({ error: 'Analysis failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Hono } from 'hono';
|
|||
import { eq, and, gt, or, isNull, asc } from 'drizzle-orm';
|
||||
import { HTTPException } from 'hono/http-exception';
|
||||
import { authMiddleware } from '@mana/shared-hono/auth';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import {
|
||||
|
|
@ -112,7 +113,7 @@ function generateShareCode(): string {
|
|||
|
||||
// ─── Routes ─────────────────────────────────────────────────
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Public endpoint (no auth) ──────────────────────────────
|
||||
|
||||
|
|
@ -187,7 +188,9 @@ routes.post('/share/deck/:deckId', async (c) => {
|
|||
}
|
||||
|
||||
// Parse optional expiry
|
||||
const body = await c.req.json<{ expiresAt?: string }>().catch(() => ({}));
|
||||
const body = (await c.req.json<{ expiresAt?: string }>().catch(() => ({}))) as {
|
||||
expiresAt?: string;
|
||||
};
|
||||
|
||||
const [share] = await db
|
||||
.insert(sharedDecks)
|
||||
|
|
@ -223,6 +226,7 @@ routes.get('/share/deck/:deckId/links', async (c) => {
|
|||
routes.delete('/share/:shareId', authMiddleware(), async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const shareId = c.req.param('shareId');
|
||||
if (!shareId) throw new HTTPException(400, { message: 'shareId required' });
|
||||
|
||||
const share = await db.query.sharedDecks.findFirst({
|
||||
where: eq(sharedDecks.id, shareId),
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { AuthVariables } from '@mana/shared-hono';
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── File Upload (server-only: S3) ──────────────────────────
|
||||
|
||||
|
|
@ -46,9 +47,8 @@ routes.post('/files/upload', async (c) => {
|
|||
}
|
||||
|
||||
// Non-images -> shared-storage as before
|
||||
const { createStorageStorage, generateUserFileKey, getContentType } = await import(
|
||||
'@mana/shared-storage'
|
||||
);
|
||||
const { createStorageStorage, generateUserFileKey, getContentType } =
|
||||
await import('@mana/shared-storage');
|
||||
const storage = createStorageStorage();
|
||||
const key = generateUserFileKey(userId, file.name);
|
||||
|
||||
|
|
@ -91,10 +91,13 @@ routes.get('/files/:id/download', async (c) => {
|
|||
return c.json({ url });
|
||||
}
|
||||
|
||||
const data = await storage.download(storagePath);
|
||||
return new Response(data.body, {
|
||||
const [buffer, metadata] = await Promise.all([
|
||||
storage.download(storagePath),
|
||||
storage.getMetadata(storagePath).catch(() => null),
|
||||
]);
|
||||
return new Response(new Uint8Array(buffer), {
|
||||
headers: {
|
||||
'Content-Type': data.contentType || 'application/octet-stream',
|
||||
'Content-Type': metadata?.contentType || 'application/octet-stream',
|
||||
'Content-Disposition': `attachment; filename="${storagePath.split('/').pop()}"`,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { z } from 'zod';
|
|||
import { eq, and, asc, sql } from 'drizzle-orm';
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import { serviceAuthMiddleware } from '@mana/shared-hono';
|
||||
import { serviceAuthMiddleware, type AuthVariables } from '@mana/shared-hono';
|
||||
import {
|
||||
pgSchema,
|
||||
uuid,
|
||||
|
|
@ -93,7 +93,7 @@ const db = drizzle(connection, { schema: { tasks, projects, reminders } });
|
|||
|
||||
// ─── Routes ────────────────────────────────────────────────
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── RRULE Compute ─────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { logger, type AuthVariables } from '@mana/shared-hono';
|
||||
import { eq, and } from 'drizzle-orm';
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
|
|
@ -120,7 +121,7 @@ const db = drizzle(connection, { schema: { locations, cities, pois, guides, guid
|
|||
|
||||
// ─── Routes ─────────────────────────────────────────────────
|
||||
|
||||
const routes = new Hono();
|
||||
const routes = new Hono<{ Variables: AuthVariables }>();
|
||||
|
||||
// ─── Guide Generation (server-only: AI + search) ────────────
|
||||
|
||||
|
|
@ -152,7 +153,11 @@ routes.post('/guides/generate', async (c) => {
|
|||
// Fire-and-forget async pipeline
|
||||
runGuidePipeline(guide.id, userId, city, params.language || 'de', params.maxPois || 10).catch(
|
||||
(err) => {
|
||||
console.error('Guide generation failed:', err);
|
||||
logger.error('traces.guide_generation_failed', {
|
||||
guideId: guide.id,
|
||||
cityId: city.id,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
db.update(guides)
|
||||
.set({ status: 'error' })
|
||||
.where(eq(guides.id, guide.id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue