sonance-brand-mcp 1.3.6 → 1.3.8
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.
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useState,
|
|
7
|
+
useEffect,
|
|
8
|
+
useCallback,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { BrandId, brandPresets, applyThemeToDOM } from "./brand-system";
|
|
12
|
+
|
|
13
|
+
// ============================================
|
|
14
|
+
// BRAND CONTEXT
|
|
15
|
+
// Global state for the currently selected brand
|
|
16
|
+
// ============================================
|
|
17
|
+
|
|
18
|
+
const STORAGE_KEY = "sonance-devtools-brand";
|
|
19
|
+
|
|
20
|
+
interface BrandContextValue {
|
|
21
|
+
currentBrand: BrandId;
|
|
22
|
+
setBrand: (brand: BrandId) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const BrandContext = createContext<BrandContextValue | null>(null);
|
|
26
|
+
|
|
27
|
+
export function BrandProvider({ children }: { children: ReactNode }) {
|
|
28
|
+
const [currentBrand, setCurrentBrand] = useState<BrandId>("sonance");
|
|
29
|
+
const [mounted, setMounted] = useState(false);
|
|
30
|
+
|
|
31
|
+
// Load persisted brand from localStorage on mount
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setMounted(true);
|
|
34
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
35
|
+
if (stored && (stored === "sonance" || stored === "iport" || stored === "blaze")) {
|
|
36
|
+
setCurrentBrand(stored as BrandId);
|
|
37
|
+
// Apply the theme when restoring from localStorage
|
|
38
|
+
const preset = brandPresets.find((p) => p.id === stored);
|
|
39
|
+
if (preset) {
|
|
40
|
+
applyThemeToDOM(preset.config);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
const setBrand = useCallback((brand: BrandId) => {
|
|
46
|
+
setCurrentBrand(brand);
|
|
47
|
+
localStorage.setItem(STORAGE_KEY, brand);
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
// Don't render children until mounted to prevent hydration mismatch
|
|
51
|
+
if (!mounted) {
|
|
52
|
+
return <>{children}</>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<BrandContext.Provider value={{ currentBrand, setBrand }}>
|
|
57
|
+
{children}
|
|
58
|
+
</BrandContext.Provider>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function useBrand(): BrandContextValue {
|
|
63
|
+
const context = useContext(BrandContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
// Return default values if not within provider (for SSR/initial render)
|
|
66
|
+
return {
|
|
67
|
+
currentBrand: "sonance",
|
|
68
|
+
setBrand: () => {},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return context;
|
|
72
|
+
}
|
|
@@ -4,7 +4,7 @@ import { useState, useEffect, useCallback, useRef } from "react";
|
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { Palette, X, Copy, Check, RotateCcw, ChevronDown, Save, Loader2, AlertCircle, CheckCircle, Sun, Moon, Eye, EyeOff, Zap, Image as ImageIcon, Wand2, Scan, FileCode, Tag, Type, MousePointer, FormInput, Box } from "lucide-react";
|
|
6
6
|
import { useTheme } from "next-themes";
|
|
7
|
-
import { cn } from "
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
8
|
import {
|
|
9
9
|
ThemeConfig,
|
|
10
10
|
BrandId,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
generateThemeCSS,
|
|
18
18
|
componentSnippets,
|
|
19
19
|
isLightColor,
|
|
20
|
-
} from "
|
|
21
|
-
import { useBrand } from "
|
|
20
|
+
} from "../../lib/brand-system";
|
|
21
|
+
import { useBrand } from "../../lib/brand-context";
|
|
22
22
|
|
|
23
23
|
// ============================================
|
|
24
24
|
// SONANCE DEVTOOLS
|
package/dist/index.js
CHANGED
|
@@ -313,6 +313,8 @@ function runDevToolsInstaller() {
|
|
|
313
313
|
const themeDir = path.join(targetDir, "src/theme");
|
|
314
314
|
// Source resolution
|
|
315
315
|
let sourceBrandSystem;
|
|
316
|
+
let sourceBrandContext;
|
|
317
|
+
let sourceUtils;
|
|
316
318
|
let sourceDevTools;
|
|
317
319
|
let sourceBrandOverridesCss;
|
|
318
320
|
let sourceApiTheme;
|
|
@@ -323,6 +325,8 @@ function runDevToolsInstaller() {
|
|
|
323
325
|
let sourceApiAnalyze;
|
|
324
326
|
if (IS_BUNDLED) {
|
|
325
327
|
sourceBrandSystem = path.join(BUNDLED_ASSETS, "brand-system.ts");
|
|
328
|
+
sourceBrandContext = path.join(BUNDLED_ASSETS, "brand-context.tsx");
|
|
329
|
+
sourceUtils = path.join(BUNDLED_ASSETS, "utils.ts");
|
|
326
330
|
sourceDevTools = path.join(BUNDLED_ASSETS, "dev-tools");
|
|
327
331
|
sourceBrandOverridesCss = path.join(BUNDLED_ASSETS, "styles/brand-overrides.css");
|
|
328
332
|
sourceApiTheme = path.join(BUNDLED_ASSETS, "api/sonance-theme/route.ts");
|
|
@@ -334,6 +338,8 @@ function runDevToolsInstaller() {
|
|
|
334
338
|
}
|
|
335
339
|
else {
|
|
336
340
|
sourceBrandSystem = path.join(DEV_PROJECT_ROOT, "src/lib/brand-system.ts");
|
|
341
|
+
sourceBrandContext = path.join(DEV_PROJECT_ROOT, "src/lib/brand-context.tsx");
|
|
342
|
+
sourceUtils = path.join(DEV_PROJECT_ROOT, "src/lib/utils.ts");
|
|
337
343
|
sourceDevTools = path.join(DEV_PROJECT_ROOT, "src/components/dev-tools");
|
|
338
344
|
sourceBrandOverridesCss = path.join(DEV_PROJECT_ROOT, "src/styles/brand-overrides.css");
|
|
339
345
|
sourceApiTheme = path.join(DEV_PROJECT_ROOT, "src/app/api/sonance-theme/route.ts");
|
|
@@ -349,6 +355,16 @@ function runDevToolsInstaller() {
|
|
|
349
355
|
console.error(` Path: ${sourceBrandSystem}`);
|
|
350
356
|
process.exit(1);
|
|
351
357
|
}
|
|
358
|
+
if (!fs.existsSync(sourceBrandContext)) {
|
|
359
|
+
console.error(" ❌ Error: Could not find brand-context.tsx source file.");
|
|
360
|
+
console.error(` Path: ${sourceBrandContext}`);
|
|
361
|
+
process.exit(1);
|
|
362
|
+
}
|
|
363
|
+
if (!fs.existsSync(sourceUtils)) {
|
|
364
|
+
console.error(" ❌ Error: Could not find utils.ts source file.");
|
|
365
|
+
console.error(` Path: ${sourceUtils}`);
|
|
366
|
+
process.exit(1);
|
|
367
|
+
}
|
|
352
368
|
if (!fs.existsSync(sourceDevTools)) {
|
|
353
369
|
console.error(" ❌ Error: Could not find dev-tools source directory.");
|
|
354
370
|
console.error(` Path: ${sourceDevTools}`);
|
|
@@ -390,12 +406,16 @@ function runDevToolsInstaller() {
|
|
|
390
406
|
process.exit(1);
|
|
391
407
|
}
|
|
392
408
|
console.log(" 📂 Installing files...");
|
|
393
|
-
// 1. Install brand-system.ts
|
|
409
|
+
// 1. Install lib files (brand-system.ts, brand-context.tsx, utils.ts)
|
|
394
410
|
if (!fs.existsSync(libDir)) {
|
|
395
411
|
fs.mkdirSync(libDir, { recursive: true });
|
|
396
412
|
}
|
|
397
413
|
fs.copyFileSync(sourceBrandSystem, path.join(libDir, "brand-system.ts"));
|
|
398
414
|
console.log(" ✓ Created src/lib/brand-system.ts");
|
|
415
|
+
fs.copyFileSync(sourceBrandContext, path.join(libDir, "brand-context.tsx"));
|
|
416
|
+
console.log(" ✓ Created src/lib/brand-context.tsx");
|
|
417
|
+
fs.copyFileSync(sourceUtils, path.join(libDir, "utils.ts"));
|
|
418
|
+
console.log(" ✓ Created src/lib/utils.ts");
|
|
399
419
|
// 2. Install DevTools components
|
|
400
420
|
if (!fs.existsSync(devToolsDir)) {
|
|
401
421
|
fs.mkdirSync(devToolsDir, { recursive: true });
|
|
@@ -702,7 +722,9 @@ function runDevToolsUninstaller() {
|
|
|
702
722
|
"src/app/api/sonance-assets",
|
|
703
723
|
"src/app/api/sonance-inject-id",
|
|
704
724
|
"src/app/api/sonance-analyze",
|
|
705
|
-
"src/lib/brand-system.ts"
|
|
725
|
+
"src/lib/brand-system.ts",
|
|
726
|
+
"src/lib/brand-context.tsx",
|
|
727
|
+
"src/lib/utils.ts"
|
|
706
728
|
];
|
|
707
729
|
for (const item of itemsToDelete) {
|
|
708
730
|
const fullPath = path.join(targetDir, item);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonance-brand-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "MCP Server for Sonance Brand Guidelines and Component Library - gives Claude instant access to brand colors, typography, and UI components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|