@nuvler/cli 0.4.0 → 0.4.2

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.
Files changed (51) hide show
  1. package/README.md +25 -2
  2. package/dist/commands/theme/create.js +2 -2
  3. package/dist/commands/theme/validate.js +21 -0
  4. package/dist/commands/theme/validate.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/migrate/generator.js +49 -8
  7. package/dist/migrate/generator.js.map +1 -1
  8. package/dist/migrate/transformer.js +20 -4
  9. package/dist/migrate/transformer.js.map +1 -1
  10. package/dist/nuvler.js +279 -47
  11. package/dist/nuvler.js.map +1 -1
  12. package/dist/templates/nuvler-atelier/nuvler.theme.json +10 -3
  13. package/dist/templates/nuvler-atelier/package.json +3 -3
  14. package/dist/templates/nuvler-atelier/src/definition.tsx +11 -1
  15. package/dist/templates/nuvler-atelier/src/theme.css +26 -26
  16. package/dist/templates/nuvler-atelier/src/theme.tsx +12 -1
  17. package/dist/templates/nuvler-default/README.md +50 -4
  18. package/dist/templates/nuvler-default/nuvler.theme.json +10 -3
  19. package/dist/templates/nuvler-default/package.json +36 -4
  20. package/dist/templates/nuvler-default/src/banner-carousel.tsx +42 -12
  21. package/dist/templates/nuvler-default/src/carousel-frame.tsx +58 -0
  22. package/dist/templates/nuvler-default/src/definition.ts +9 -48
  23. package/dist/templates/nuvler-default/src/footer.tsx +7 -2
  24. package/dist/templates/nuvler-default/src/header-interactions.tsx +1 -1
  25. package/dist/templates/nuvler-default/src/header.tsx +3 -3
  26. package/dist/templates/nuvler-default/src/home.tsx +41 -17
  27. package/dist/templates/nuvler-default/src/index.ts +1 -0
  28. package/dist/templates/nuvler-default/src/product-carousel.tsx +13 -7
  29. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +230 -0
  30. package/dist/templates/nuvler-default/src/product-detail.tsx +80 -55
  31. package/dist/templates/nuvler-default/src/products.tsx +6 -5
  32. package/dist/templates/nuvler-default/src/server-shell.tsx +88 -0
  33. package/dist/templates/nuvler-default/src/shared.tsx +25 -9
  34. package/dist/templates/nuvler-default/src/theme-component.tsx +11 -0
  35. package/dist/templates/nuvler-default/src/theme-config.ts +63 -0
  36. package/dist/templates/nuvler-default/src/theme.css +48 -17
  37. package/dist/templates/starter/nuvler.theme.json +9 -2
  38. package/dist/templates/starter/package.json +2 -2
  39. package/dist/templates/starter/src/definition.tsx +8 -1
  40. package/dist/templates/starter/src/theme.css +10 -10
  41. package/dist/templates/starter/src/theme.tsx +11 -0
  42. package/dist/theme/performance.js +126 -0
  43. package/dist/theme/performance.js.map +1 -0
  44. package/package.json +3 -3
  45. package/preview-host/index.html +1 -0
  46. package/preview-host/package.json +1 -1
  47. package/preview-host/public/nuvler-icon.ico +0 -0
  48. package/preview-host/public/nuvler-logo-white.png +0 -0
  49. package/preview-host/src/app/globals.css +28 -0
  50. package/preview-host/src/main.tsx +11 -1
  51. package/preview-host/vendor/theme-runtime/default-theme.tsx +24 -2
@@ -1,15 +1,16 @@
1
1
  import type { ProductGridProps, ThemeProduct } from "@nuvler/theme-sdk";
2
- import { plainText, ThemeImageView } from "./shared.js";
2
+ import { plainText, ThemeImageView, type ThemeImageComponent } from "./shared.js";
3
3
 
4
- export function ProductCard({ product, showCategory = true, showDescription = true }: {
4
+ export function ProductCard({ product, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: {
5
5
  product: ThemeProduct;
6
6
  showCategory?: boolean;
7
7
  showDescription?: boolean;
8
+ ImageComponent?: ThemeImageComponent;
8
9
  }) {
9
- return <article className="product-card"><a className="product-card-image" href={`/produto/${product.slug}`}><ThemeImageView image={product.image} fallbackAlt={product.title} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a href={`/produto/${product.slug}`}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<a className="button button-secondary button-block" href={`/produto/${product.slug}`}>Ver detalhes e orçar</a></div></article>;
10
+ return <article className="product-card"><a className="product-card-image" href={`/produto/${product.slug}`}><ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a href={`/produto/${product.slug}`}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<a className="button button-secondary button-block" href={`/produto/${product.slug}`}>Ver detalhes e orçar</a></div></article>;
10
11
  }
11
12
 
12
- export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true }: ProductGridProps) {
13
+ export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
13
14
  if (!products.length) return <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Novos itens aparecerão aqui assim que forem publicados.</p></div>;
14
- return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showCategory={showCategory} showDescription={showDescription} />)}</div>;
15
+ return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />)}</div>;
15
16
  }
@@ -0,0 +1,88 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { ThemeCategory, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
3
+
4
+ import { Footer } from "./footer.js";
5
+ import { Header } from "./header.js";
6
+ import {
7
+ manifest,
8
+ nuvlerDefaultTemplate,
9
+ nuvlerDefaultTokens,
10
+ } from "./theme-config.js";
11
+ import type { ThemeImageComponent } from "./shared.js";
12
+
13
+ export interface NuvlerDefaultShellProps {
14
+ site: ThemeSite;
15
+ categories: ThemeCategory[];
16
+ pages: ThemePageSummary[];
17
+ children: ReactNode;
18
+ cart?: ReactNode;
19
+ platformBrand?: ReactNode;
20
+ suggestionsEndpoint?: string;
21
+ suggestionsQueryParam?: string;
22
+ ImageComponent?: ThemeImageComponent;
23
+ }
24
+
25
+ export function NuvlerDefaultShell({
26
+ site,
27
+ categories,
28
+ pages,
29
+ children,
30
+ cart,
31
+ platformBrand,
32
+ suggestionsEndpoint,
33
+ suggestionsQueryParam,
34
+ ImageComponent,
35
+ }: NuvlerDefaultShellProps) {
36
+ const configured = site.settings?.theme;
37
+ const tokens = {
38
+ colors: { ...nuvlerDefaultTokens.colors, ...configured?.colors },
39
+ layout: { ...nuvlerDefaultTokens.layout, ...configured?.layout },
40
+ };
41
+ const style = {
42
+ "--color-primary": tokens.colors.primary,
43
+ "--color-primary-text": tokens.colors.primaryText,
44
+ "--color-secondary": tokens.colors.secondary,
45
+ "--color-secondary-text": tokens.colors.secondaryText,
46
+ "--color-accent": tokens.colors.accent,
47
+ "--store-background": tokens.colors.background,
48
+ "--store-surface": tokens.colors.surface,
49
+ "--store-surface-alt": tokens.colors.surfaceAlt,
50
+ "--store-text": tokens.colors.text,
51
+ "--store-muted": tokens.colors.textMuted,
52
+ "--store-line": tokens.colors.border,
53
+ "--store-header-background": tokens.colors.headerBackground,
54
+ "--store-header-text": tokens.colors.headerText,
55
+ "--store-footer-background": tokens.colors.footerBackground,
56
+ "--store-footer-text": tokens.colors.footerText,
57
+ "--container-width": `${tokens.layout.containerWidth}px`,
58
+ "--border-radius": `${tokens.layout.borderRadius}px`,
59
+ } as CSSProperties;
60
+
61
+ return (
62
+ <div
63
+ className="store-shell nuvler-default-theme"
64
+ data-theme-id={manifest.id}
65
+ data-theme-version={manifest.version}
66
+ data-nuvler-renderer="server"
67
+ style={style}
68
+ >
69
+ <Header
70
+ site={site}
71
+ categories={categories}
72
+ pages={pages}
73
+ template={nuvlerDefaultTemplate}
74
+ cart={cart}
75
+ suggestionsEndpoint={suggestionsEndpoint}
76
+ suggestionsQueryParam={suggestionsQueryParam}
77
+ ImageComponent={ImageComponent}
78
+ />
79
+ <div className="store-page">{children}</div>
80
+ <Footer
81
+ site={site}
82
+ pages={pages}
83
+ template={nuvlerDefaultTemplate}
84
+ platformBrand={platformBrand}
85
+ />
86
+ </div>
87
+ );
88
+ }
@@ -1,26 +1,42 @@
1
+ import type { ComponentType } from "react";
1
2
  import type { ThemeImage, ThemeProduct } from "@nuvler/theme-sdk";
2
3
 
4
+ export interface ThemeImageViewProps {
5
+ image: ThemeImage | null | undefined;
6
+ fallbackAlt: string;
7
+ className?: string;
8
+ priority?: boolean;
9
+ loading?: "eager" | "lazy";
10
+ sizes?: string;
11
+ fallbackWidth?: number;
12
+ fallbackHeight?: number;
13
+ }
14
+
15
+ export type ThemeImageComponent = ComponentType<ThemeImageViewProps>;
16
+
3
17
  export function ThemeImageView({
4
18
  image,
5
19
  fallbackAlt,
6
20
  className,
7
21
  priority = false,
8
- }: {
9
- image: ThemeImage | null | undefined;
10
- fallbackAlt: string;
11
- className?: string;
12
- priority?: boolean;
13
- }) {
22
+ loading = "lazy",
23
+ sizes,
24
+ fallbackWidth = 900,
25
+ fallbackHeight = 900,
26
+ }: ThemeImageViewProps) {
14
27
  if (!image?.url) {
15
28
  return <span className={`store-image-placeholder ${className ?? ""}`} aria-hidden="true"><span>7</span></span>;
16
29
  }
17
30
  return <img
18
31
  src={image.url}
19
32
  alt={image.alt || fallbackAlt}
20
- width={image.width || 900}
21
- height={image.height || 900}
33
+ width={image.width || fallbackWidth}
34
+ height={image.height || fallbackHeight}
22
35
  className={className}
23
- loading={priority ? "eager" : "lazy"}
36
+ loading={priority ? "eager" : loading}
37
+ fetchPriority={priority ? "high" : "auto"}
38
+ decoding="async"
39
+ sizes={sizes}
24
40
  />;
25
41
  }
26
42
 
@@ -58,9 +58,20 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
58
58
  };
59
59
  const style = {
60
60
  "--color-primary": tokens.colors.primary,
61
+ "--color-primary-text": tokens.colors.primaryText,
61
62
  "--color-secondary": tokens.colors.secondary,
63
+ "--color-secondary-text": tokens.colors.secondaryText,
64
+ "--color-accent": tokens.colors.accent,
62
65
  "--store-background": tokens.colors.background,
66
+ "--store-surface": tokens.colors.surface,
67
+ "--store-surface-alt": tokens.colors.surfaceAlt,
63
68
  "--store-text": tokens.colors.text,
69
+ "--store-muted": tokens.colors.textMuted,
70
+ "--store-line": tokens.colors.border,
71
+ "--store-header-background": tokens.colors.headerBackground,
72
+ "--store-header-text": tokens.colors.headerText,
73
+ "--store-footer-background": tokens.colors.footerBackground,
74
+ "--store-footer-text": tokens.colors.footerText,
64
75
  "--container-width": `${tokens.layout.containerWidth}px`,
65
76
  "--border-radius": `${tokens.layout.borderRadius}px`,
66
77
  } as CSSProperties;
@@ -0,0 +1,63 @@
1
+ import manifestData from "../nuvler.theme.json" with { type: "json" };
2
+ import type {
3
+ SiteTemplate,
4
+ ThemeHomeSection,
5
+ ThemeManifest,
6
+ NuvlerStoreThemeDefinition,
7
+ } from "@nuvler/theme-sdk";
8
+
9
+ function section(id: string, type: ThemeHomeSection["type"], order: number): ThemeHomeSection {
10
+ return { id, type, enabled: true, order, data: {} };
11
+ }
12
+
13
+ export const manifest = manifestData as ThemeManifest;
14
+
15
+ export const nuvlerDefaultTokens = {
16
+ colors: {
17
+ primary: "#176b3a",
18
+ primaryText: "#ffffff",
19
+ secondary: "#d99b31",
20
+ secondaryText: "#18221b",
21
+ accent: "#b45309",
22
+ background: "#f7f7f2",
23
+ surface: "#ffffff",
24
+ surfaceAlt: "#eef2e9",
25
+ text: "#18221b",
26
+ textMuted: "#657068",
27
+ border: "#dfe4dd",
28
+ headerBackground: "#ffffff",
29
+ headerText: "#18221b",
30
+ footerBackground: "#14251a",
31
+ footerText: "#f7f7f2",
32
+ },
33
+ layout: { containerWidth: 1280, borderRadius: 18 },
34
+ } satisfies NuvlerStoreThemeDefinition["tokens"];
35
+
36
+ export const nuvlerDefaultTemplate = {
37
+ announcement: "Soluções, conteúdo e atendimento para o seu negócio",
38
+ footerTagline: "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
39
+ footerNavigationLabel: "Navegação",
40
+ footerNote: "Conteúdo e atendimento que geram confiança",
41
+ socialLabel: "Acompanhe a empresa",
42
+ benefits: [
43
+ { title: "Soluções sob medida", description: "Serviços pensados para o seu momento" },
44
+ { title: "Conteúdo relevante", description: "Informação para ajudar nas decisões" },
45
+ { title: "Atendimento próximo", description: "Fale diretamente com a empresa" },
46
+ ],
47
+ fallbackSections(modules) {
48
+ const sections = [section("default-hero", "hero", 0)];
49
+ let order = 1;
50
+ if (modules.includes("SERVICES")) sections.push(section("default-services", "services-grid", order++));
51
+ if (modules.includes("CASES")) sections.push(section("default-cases", "cases-grid", order++));
52
+ if (modules.includes("PRODUCTS")) sections.push(section("default-products", "products-carousel", order++));
53
+ if (modules.includes("BLOG")) sections.push(section("default-blog", "blog-grid", order));
54
+ return sections;
55
+ },
56
+ primaryAction(modules) {
57
+ if (modules.includes("SERVICES")) return { label: "Conheça nossos serviços", href: "/servicos" };
58
+ if (modules.includes("PRODUCTS")) return { label: "Ver produtos", href: "/produtos" };
59
+ if (modules.includes("CASES")) return { label: "Conheça nossos cases", href: "/cases" };
60
+ if (modules.includes("BLOG")) return { label: "Ver conteúdos", href: "/blog" };
61
+ return { label: "Conheça a empresa", href: "/" };
62
+ },
63
+ } satisfies SiteTemplate;
@@ -1,6 +1,9 @@
1
1
  :root {
2
2
  --color-primary: #176b3a;
3
+ --color-primary-text: #ffffff;
3
4
  --color-secondary: #d99b31;
5
+ --color-secondary-text: #18221b;
6
+ --color-accent: #b45309;
4
7
  --store-background: #f7f7f2;
5
8
  --store-text: #18221b;
6
9
  --container-width: 1280px;
@@ -8,6 +11,11 @@
8
11
  --store-muted: #657068;
9
12
  --store-line: #dfe4dd;
10
13
  --store-surface: #ffffff;
14
+ --store-surface-alt: #eef2e9;
15
+ --store-header-background: #ffffff;
16
+ --store-header-text: #18221b;
17
+ --store-footer-background: #14251a;
18
+ --store-footer-text: #f7f7f2;
11
19
  }
12
20
 
13
21
  * {
@@ -36,7 +44,6 @@ body {
36
44
  margin: 0;
37
45
  background: var(--store-background);
38
46
  color: var(--store-text);
39
- font-family: Arial, Helvetica, sans-serif;
40
47
  -webkit-font-smoothing: antialiased;
41
48
  }
42
49
 
@@ -44,6 +51,17 @@ body {
44
51
  min-height: 100vh;
45
52
  background: var(--store-background);
46
53
  color: var(--store-text);
54
+ font-family: var(
55
+ --nuvler-font-sans,
56
+ ui-sans-serif,
57
+ system-ui,
58
+ -apple-system,
59
+ BlinkMacSystemFont,
60
+ "Segoe UI",
61
+ Arial,
62
+ Helvetica,
63
+ sans-serif
64
+ );
47
65
  }
48
66
 
49
67
  .floating-whatsapp {
@@ -218,8 +236,8 @@ select {
218
236
  }
219
237
 
220
238
  .announcement {
221
- background: var(--store-text);
222
- color: #fff;
239
+ background: var(--color-primary);
240
+ color: var(--color-primary-text);
223
241
  font-size: 12px;
224
242
  letter-spacing: 0.02em;
225
243
  }
@@ -237,7 +255,8 @@ select {
237
255
  z-index: 30;
238
256
  top: 0;
239
257
  border-bottom: 1px solid color-mix(in srgb, var(--store-line), transparent 20%);
240
- background: color-mix(in srgb, var(--store-background), transparent 4%);
258
+ background: color-mix(in srgb, var(--store-header-background), transparent 4%);
259
+ color: var(--store-header-text);
241
260
  backdrop-filter: blur(18px);
242
261
  }
243
262
 
@@ -530,7 +549,8 @@ select {
530
549
 
531
550
  .primary-nav-shell {
532
551
  border-top: 1px solid var(--store-line);
533
- background: var(--store-surface);
552
+ background: var(--store-header-background);
553
+ color: var(--store-header-text);
534
554
  }
535
555
 
536
556
  .brand {
@@ -1033,7 +1053,7 @@ select {
1033
1053
 
1034
1054
  .button-primary {
1035
1055
  background: var(--color-primary);
1036
- color: #fff;
1056
+ color: var(--color-primary-text);
1037
1057
  box-shadow: 0 9px 24px color-mix(in srgb, var(--color-primary), transparent 76%);
1038
1058
  }
1039
1059
 
@@ -1043,13 +1063,14 @@ select {
1043
1063
 
1044
1064
  .button-secondary {
1045
1065
  border-color: var(--store-line);
1046
- background: var(--store-surface);
1047
- color: var(--store-text);
1066
+ background: var(--color-secondary);
1067
+ color: var(--color-secondary-text);
1048
1068
  }
1049
1069
 
1050
1070
  .button-secondary:hover {
1051
1071
  border-color: var(--color-secondary);
1052
- color: var(--color-secondary);
1072
+ background: color-mix(in srgb, var(--color-secondary), #000 7%);
1073
+ color: var(--color-secondary-text);
1053
1074
  }
1054
1075
 
1055
1076
  .button-block {
@@ -1689,7 +1710,7 @@ select {
1689
1710
  display: block;
1690
1711
  overflow: hidden;
1691
1712
  aspect-ratio: 1 / 1;
1692
- background: #eef0ea;
1713
+ background: var(--store-surface-alt);
1693
1714
  }
1694
1715
 
1695
1716
  .product-card-image img,
@@ -1728,7 +1749,7 @@ select {
1728
1749
  .product-category {
1729
1750
  display: block;
1730
1751
  margin-bottom: 8px;
1731
- color: var(--color-secondary);
1752
+ color: var(--color-accent);
1732
1753
  font-size: 10px;
1733
1754
  font-weight: 900;
1734
1755
  letter-spacing: 0.12em;
@@ -2210,6 +2231,16 @@ select {
2210
2231
  object-fit: contain;
2211
2232
  }
2212
2233
 
2234
+ .product-main-image > [data-product-main-image] {
2235
+ display: block;
2236
+ width: 100%;
2237
+ height: 100%;
2238
+ }
2239
+
2240
+ .product-main-image > [data-product-main-image][hidden] {
2241
+ display: none;
2242
+ }
2243
+
2213
2244
  .product-thumbnails {
2214
2245
  display: grid;
2215
2246
  grid-template-columns: repeat(5, 1fr);
@@ -2478,8 +2509,8 @@ select {
2478
2509
  }
2479
2510
 
2480
2511
  .store-footer {
2481
- background: var(--store-text);
2482
- color: #fff;
2512
+ background: var(--store-footer-background);
2513
+ color: var(--store-footer-text);
2483
2514
  padding: 64px 0 22px;
2484
2515
  }
2485
2516
 
@@ -2511,13 +2542,13 @@ select {
2511
2542
  .footer-grid span {
2512
2543
  max-width: 480px;
2513
2544
  margin: 0;
2514
- color: rgba(255, 255, 255, 0.62);
2545
+ color: color-mix(in srgb, var(--store-footer-text), transparent 38%);
2515
2546
  font-size: 13px;
2516
2547
  line-height: 1.65;
2517
2548
  }
2518
2549
 
2519
2550
  .footer-grid a:hover {
2520
- color: #fff;
2551
+ color: var(--store-footer-text);
2521
2552
  }
2522
2553
 
2523
2554
  .footer-bottom {
@@ -2525,9 +2556,9 @@ select {
2525
2556
  justify-content: space-between;
2526
2557
  gap: 20px;
2527
2558
  margin-top: 48px;
2528
- border-top: 1px solid rgba(255, 255, 255, 0.12);
2559
+ border-top: 1px solid color-mix(in srgb, var(--store-footer-text), transparent 88%);
2529
2560
  padding-top: 22px;
2530
- color: rgba(255, 255, 255, 0.46);
2561
+ color: color-mix(in srgb, var(--store-footer-text), transparent 54%);
2531
2562
  font-size: 11px;
2532
2563
  }
2533
2564
 
@@ -4,13 +4,20 @@
4
4
  "name": "__NUVLER_THEME_NAME__",
5
5
  "version": "0.1.0",
6
6
  "runtimeVersion": "1",
7
- "sdkVersion": "^1.1.0",
7
+ "sdkVersion": "^1.2.0",
8
8
  "entry": "src/theme.tsx",
9
9
  "styles": ["src/theme.css"],
10
10
  "presentation": {
11
11
  "description": "Base enxuta para construir um tema Nuvler.",
12
12
  "templateId": "starter",
13
- "colors": { "primary": "#1d4ed8", "secondary": "#f59e0b", "background": "#f8fafc", "text": "#0f172a" },
13
+ "colors": {
14
+ "primary": "#1d4ed8", "primaryText": "#ffffff",
15
+ "secondary": "#f59e0b", "secondaryText": "#0f172a", "accent": "#d97706",
16
+ "background": "#f8fafc", "surface": "#ffffff", "surfaceAlt": "#f1f5f9",
17
+ "text": "#0f172a", "textMuted": "#64748b", "border": "#e2e8f0",
18
+ "headerBackground": "#ffffff", "headerText": "#0f172a",
19
+ "footerBackground": "#0f172a", "footerText": "#f8fafc"
20
+ },
14
21
  "layout": { "containerWidth": 1200, "borderRadius": 16 }
15
22
  }
16
23
  }
@@ -12,13 +12,13 @@
12
12
  "typecheck": "tsc -p tsconfig.json --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@nuvler/theme-sdk": "^1.1.0"
15
+ "@nuvler/theme-sdk": "^1.2.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": "^19.0.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@nuvler/cli": "^0.4.0",
21
+ "@nuvler/cli": "^0.4.2",
22
22
  "@types/react": "^19.0.0",
23
23
  "react": "^19.0.0",
24
24
  "typescript": "^5.9.0"
@@ -37,7 +37,14 @@ export const manifest = manifestData as ThemeManifest;
37
37
  export const themeDefinition = defineTheme({
38
38
  manifest,
39
39
  tokens: {
40
- colors: { primary: "#1d4ed8", secondary: "#f59e0b", background: "#f8fafc", text: "#0f172a" },
40
+ colors: {
41
+ primary: "#1d4ed8", primaryText: "#ffffff",
42
+ secondary: "#f59e0b", secondaryText: "#0f172a", accent: "#d97706",
43
+ background: "#f8fafc", surface: "#ffffff", surfaceAlt: "#f1f5f9",
44
+ text: "#0f172a", textMuted: "#64748b", border: "#e2e8f0",
45
+ headerBackground: "#ffffff", headerText: "#0f172a",
46
+ footerBackground: "#0f172a", footerText: "#f8fafc",
47
+ },
41
48
  layout: { containerWidth: 1200, borderRadius: 16 },
42
49
  },
43
50
  template: {
@@ -2,20 +2,20 @@
2
2
  body { margin: 0; }
3
3
  .nuvler-starter-theme { min-height: 100vh; background: var(--theme-background); color: var(--theme-text); font-family: Inter, system-ui, sans-serif; }
4
4
  .theme-header, .theme-footer, .theme-section, .theme-hero { width: min(calc(100% - 32px), var(--theme-container)); margin-inline: auto; }
5
- .theme-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
5
+ .theme-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--theme-header-background); color: var(--theme-header-text); }
6
6
  .theme-brand { color: var(--theme-primary); font-size: 20px; font-weight: 800; text-decoration: none; }
7
7
  .theme-header form { display: flex; gap: 8px; }
8
- .theme-header input { min-width: 260px; border: 1px solid #cbd5e1; border-radius: var(--theme-radius); padding: 11px 14px; }
9
- .theme-header button, .theme-product-detail button { border: 0; border-radius: var(--theme-radius); background: var(--theme-primary); color: white; padding: 12px 18px; font-weight: 700; }
10
- .theme-hero { margin-block: 32px; border-radius: calc(var(--theme-radius) * 1.5); background: var(--theme-primary); color: white; padding: clamp(40px, 8vw, 96px); }
11
- .theme-hero span { color: var(--theme-secondary); font-size: 12px; font-weight: 800; text-transform: uppercase; }
8
+ .theme-header input { min-width: 260px; border: 1px solid var(--theme-border); border-radius: var(--theme-radius); background: var(--theme-surface); color: var(--theme-header-text); padding: 11px 14px; }
9
+ .theme-header button, .theme-product-detail button { border: 0; border-radius: var(--theme-radius); background: var(--theme-primary); color: var(--theme-primary-text); padding: 12px 18px; font-weight: 700; }
10
+ .theme-hero { margin-block: 32px; border-radius: calc(var(--theme-radius) * 1.5); background: var(--theme-primary); color: var(--theme-primary-text); padding: clamp(40px, 8vw, 96px); }
11
+ .theme-hero span { color: var(--theme-accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }
12
12
  .theme-hero h1 { max-width: 760px; margin: 12px 0; font-size: clamp(40px, 7vw, 80px); line-height: .95; }
13
- .theme-hero a { display: inline-block; margin-top: 16px; border-radius: var(--theme-radius); background: var(--theme-secondary); color: var(--theme-text); padding: 13px 18px; font-weight: 800; text-decoration: none; }
13
+ .theme-hero a { display: inline-block; margin-top: 16px; border-radius: var(--theme-radius); background: var(--theme-secondary); color: var(--theme-secondary-text); padding: 13px 18px; font-weight: 800; text-decoration: none; }
14
14
  .theme-section { padding-block: 48px; }
15
15
  .theme-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
16
- .theme-products article { min-height: 180px; border: 1px solid #e2e8f0; border-radius: var(--theme-radius); background: white; padding: 20px; }
16
+ .theme-products article { min-height: 180px; border: 1px solid var(--theme-border); border-radius: var(--theme-radius); background: var(--theme-surface); padding: 20px; }
17
17
  .theme-products a { display: flex; height: 100%; flex-direction: column; justify-content: flex-end; color: inherit; text-decoration: none; }
18
- .theme-products span { margin-top: 8px; color: #64748b; font-size: 13px; }
19
- .theme-product-detail { display: grid; gap: 32px; grid-template-columns: 1fr auto; align-items: end; border-radius: var(--theme-radius); background: white; padding: clamp(24px, 5vw, 56px); }
20
- .theme-footer { display: flex; justify-content: space-between; border-top: 1px solid #e2e8f0; padding-block: 32px; }
18
+ .theme-products span { margin-top: 8px; color: var(--theme-text-muted); font-size: 13px; }
19
+ .theme-product-detail { display: grid; gap: 32px; grid-template-columns: 1fr auto; align-items: end; border-radius: var(--theme-radius); background: var(--theme-surface); padding: clamp(24px, 5vw, 56px); }
20
+ .theme-footer { display: flex; justify-content: space-between; border-top: 1px solid var(--theme-border); background: var(--theme-footer-background); color: var(--theme-footer-text); padding: 32px 20px; }
21
21
  @media (max-width: 700px) { .theme-header { align-items: stretch; flex-direction: column; padding-block: 16px; } .theme-header form, .theme-header input { width: 100%; min-width: 0; } .theme-product-detail { grid-template-columns: 1fr; } }
@@ -15,9 +15,20 @@ export default function Theme({ context, route = { type: "home" }, sdk }: Nuvler
15
15
  };
16
16
  const style = {
17
17
  "--theme-primary": tokens.colors.primary,
18
+ "--theme-primary-text": tokens.colors.primaryText,
18
19
  "--theme-secondary": tokens.colors.secondary,
20
+ "--theme-secondary-text": tokens.colors.secondaryText,
21
+ "--theme-accent": tokens.colors.accent,
19
22
  "--theme-background": tokens.colors.background,
23
+ "--theme-surface": tokens.colors.surface,
24
+ "--theme-surface-alt": tokens.colors.surfaceAlt,
20
25
  "--theme-text": tokens.colors.text,
26
+ "--theme-text-muted": tokens.colors.textMuted,
27
+ "--theme-border": tokens.colors.border,
28
+ "--theme-header-background": tokens.colors.headerBackground,
29
+ "--theme-header-text": tokens.colors.headerText,
30
+ "--theme-footer-background": tokens.colors.footerBackground,
31
+ "--theme-footer-text": tokens.colors.footerText,
21
32
  "--theme-radius": `${tokens.layout.borderRadius}px`,
22
33
  "--theme-container": `${tokens.layout.containerWidth}px`,
23
34
  } as CSSProperties;
@@ -0,0 +1,126 @@
1
+ import { readFile, readdir, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { gzipSync } from "node:zlib";
4
+ import ts from "typescript";
5
+ const SOURCE_EXTENSIONS = new Set([".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]);
6
+ const IMAGE_EXTENSIONS = new Set([".avif", ".gif", ".jpeg", ".jpg", ".png", ".svg", ".webp"]);
7
+ const FONT_EXTENSIONS = new Set([".eot", ".otf", ".ttf", ".woff", ".woff2"]);
8
+ const IGNORED_DIRECTORIES = new Set([
9
+ ".git",
10
+ ".nuvler",
11
+ ".next",
12
+ ".vite",
13
+ "artifacts",
14
+ "dist",
15
+ "node_modules",
16
+ ]);
17
+ export const DEFAULT_THEME_PERFORMANCE_BUDGET = {
18
+ cssGzipBytes: 50 * 1024,
19
+ clientJavaScriptGzipBytes: 120 * 1024,
20
+ imageTotalBytes: 5 * 1024 * 1024,
21
+ imageMaxBytes: 512 * 1024,
22
+ fontTotalBytes: 400 * 1024,
23
+ fontFiles: 4,
24
+ clientComponents: 8,
25
+ };
26
+ async function listProjectFiles(directory) {
27
+ const files = [];
28
+ async function visit(currentDirectory) {
29
+ const entries = await readdir(currentDirectory, { withFileTypes: true });
30
+ await Promise.all(entries.map(async (entry) => {
31
+ if (entry.isSymbolicLink())
32
+ return;
33
+ const absolutePath = path.join(currentDirectory, entry.name);
34
+ if (entry.isDirectory()) {
35
+ if (!IGNORED_DIRECTORIES.has(entry.name))
36
+ await visit(absolutePath);
37
+ return;
38
+ }
39
+ if (entry.isFile())
40
+ files.push(absolutePath);
41
+ }));
42
+ }
43
+ await visit(directory);
44
+ return files.sort();
45
+ }
46
+ function hasUseClientDirective(source, filePath) {
47
+ const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, false, filePath.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
48
+ for (const statement of sourceFile.statements) {
49
+ if (ts.isExpressionStatement(statement)
50
+ && ts.isStringLiteral(statement.expression)) {
51
+ if (statement.expression.text === "use client")
52
+ return true;
53
+ continue;
54
+ }
55
+ break;
56
+ }
57
+ return false;
58
+ }
59
+ async function totalSize(files) {
60
+ const sizes = await Promise.all(files.map(async (file) => (await stat(file)).size));
61
+ return sizes.reduce((total, size) => total + size, 0);
62
+ }
63
+ async function gzipFiles(files) {
64
+ if (!files.length)
65
+ return 0;
66
+ const contents = await Promise.all(files.map((file) => readFile(file)));
67
+ return gzipSync(Buffer.concat(contents), { level: 9 }).byteLength;
68
+ }
69
+ function metric(key, label, value, unit, available = true, detail) {
70
+ return {
71
+ key,
72
+ label,
73
+ value,
74
+ limit: DEFAULT_THEME_PERFORMANCE_BUDGET[key],
75
+ unit,
76
+ available,
77
+ detail,
78
+ };
79
+ }
80
+ export async function analyzeThemePerformance(project) {
81
+ const projectFiles = await listProjectFiles(project.directory);
82
+ const css = projectFiles.filter((file) => path.extname(file).toLowerCase() === ".css");
83
+ const images = projectFiles.filter((file) => IMAGE_EXTENSIONS.has(path.extname(file).toLowerCase()));
84
+ const fonts = projectFiles.filter((file) => FONT_EXTENSIONS.has(path.extname(file).toLowerCase()));
85
+ const sourceFiles = projectFiles.filter((file) => SOURCE_EXTENSIONS.has(path.extname(file).toLowerCase()));
86
+ const clientComponents = (await Promise.all(sourceFiles.map(async (file) => ({
87
+ file,
88
+ client: hasUseClientDirective(await readFile(file, "utf8"), file),
89
+ })))).filter(({ client }) => client).map(({ file }) => file);
90
+ const imageSizes = await Promise.all(images.map(async (file) => (await stat(file)).size));
91
+ const clientBundle = path.join(project.directory, "dist", "theme.js");
92
+ const hasClientBundle = await stat(clientBundle).then((details) => details.isFile()).catch(() => false);
93
+ const clientJavaScriptGzipBytes = hasClientBundle
94
+ ? gzipSync(await readFile(clientBundle), { level: 9 }).byteLength
95
+ : 0;
96
+ const metrics = [
97
+ metric("cssGzipBytes", "CSS gzip", await gzipFiles(css), "bytes", true, `${css.length} arquivo(s)`),
98
+ metric("clientJavaScriptGzipBytes", "JS client gzip", clientJavaScriptGzipBytes, "bytes", hasClientBundle, hasClientBundle ? "dist/theme.js" : "execute nuvler theme build para medir"),
99
+ metric("imageTotalBytes", "Imagens (total)", imageSizes.reduce((total, size) => total + size, 0), "bytes", true, `${images.length} arquivo(s)`),
100
+ metric("imageMaxBytes", "Maior imagem", Math.max(0, ...imageSizes), "bytes"),
101
+ metric("fontTotalBytes", "Fontes (total)", await totalSize(fonts), "bytes", true, `${fonts.length} arquivo(s)`),
102
+ metric("fontFiles", "Arquivos de fonte", fonts.length, "count"),
103
+ metric("clientComponents", "Client Components", clientComponents.length, "count"),
104
+ ];
105
+ return {
106
+ metrics,
107
+ files: {
108
+ css: css.map((file) => path.relative(project.directory, file)),
109
+ images: images.map((file) => path.relative(project.directory, file)),
110
+ fonts: fonts.map((file) => path.relative(project.directory, file)),
111
+ clientComponents: clientComponents.map((file) => path.relative(project.directory, file)),
112
+ clientBundle: hasClientBundle ? path.relative(project.directory, clientBundle) : undefined,
113
+ },
114
+ warnings: metrics.filter(({ available, value, limit }) => available && value > limit),
115
+ };
116
+ }
117
+ export function formatPerformanceValue(metric) {
118
+ if (metric.unit === "count")
119
+ return String(metric.value);
120
+ if (metric.value < 1024)
121
+ return `${metric.value} B`;
122
+ if (metric.value < 1024 * 1024)
123
+ return `${(metric.value / 1024).toFixed(1)} KiB`;
124
+ return `${(metric.value / 1024 / 1024).toFixed(2)} MiB`;
125
+ }
126
+ //# sourceMappingURL=performance.js.map