@nuvler/cli 0.5.14 → 0.5.15

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.
@@ -1,12 +1,17 @@
1
1
  {
2
+ "capabilities": {
3
+ "pageListings": 1
4
+ },
2
5
  "schemaVersion": 1,
3
6
  "id": "nuvler-default",
4
7
  "name": "Nuvler Default",
5
- "version": "1.1.13",
8
+ "version": "1.1.14",
6
9
  "runtimeVersion": "1",
7
10
  "sdkVersion": "^1.3.3",
8
11
  "entry": "src/theme.tsx",
9
- "styles": ["src/theme.css"],
12
+ "styles": [
13
+ "src/theme.css"
14
+ ],
10
15
  "presentation": {
11
16
  "description": "Tema oficial completo, indicado para produção e usado como base confiável.",
12
17
  "templateId": "nuvler-default",
@@ -104,8 +109,14 @@
104
109
  "control": "select",
105
110
  "defaultValue": "grid",
106
111
  "options": [
107
- { "label": "Grid", "value": "grid" },
108
- { "label": "Carrossel", "value": "carousel" }
112
+ {
113
+ "label": "Grid",
114
+ "value": "grid"
115
+ },
116
+ {
117
+ "label": "Carrossel",
118
+ "value": "carousel"
119
+ }
109
120
  ],
110
121
  "help": "Escolha como as marcas serão exibidas."
111
122
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/theme-default",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "Tema padrão oficial da Nuvler",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -65,7 +65,7 @@
65
65
  "react": "^19.0.0"
66
66
  },
67
67
  "dependencies": {
68
- "@nuvler/theme-sdk": "^1.4.3"
68
+ "@nuvler/theme-sdk": "^1.4.5"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/react": "^19.0.0",
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+
5
+ /** API-sanitized editorial HTML; the shadow root keeps imported CSS inside this block. */
6
+ export function CustomHtmlContent({ html, css = "" }: { html: string; css?: string }) {
7
+ const host = useRef<HTMLDivElement>(null);
8
+ useEffect(() => {
9
+ if (!host.current) return;
10
+ const shadow = host.current.shadowRoot ?? host.current.attachShadow({ mode: "open" });
11
+ const style = document.createElement("style");
12
+ style.textContent = ':host{display:block;contain:layout paint}img{max-width:100%}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-justify{text-align:justify}\n' + css;
13
+ const content = document.createElement("div");
14
+ content.innerHTML = html;
15
+ // Defense for older stored documents that predate the current API policy.
16
+ content.querySelectorAll("script,style,iframe,object,embed,link,meta,base,form").forEach(element => element.remove());
17
+ content.querySelectorAll("*").forEach(element => {
18
+ for (const attribute of Array.from(element.attributes)) {
19
+ if (/^on/i.test(attribute.name) || attribute.name === "style"
20
+ || (["href", "src"].includes(attribute.name) && !/^(?:https?:|mailto:|tel:|\/|#)/i.test(attribute.value.trim()))) element.removeAttribute(attribute.name);
21
+ }
22
+ });
23
+ shadow.replaceChildren(style, content);
24
+ }, [html, css]);
25
+ return <div ref={host} data-editorial-html style={{ display: "block", contain: "layout paint" }} />;
26
+ }
@@ -1,6 +1,12 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useMemo, useRef, useState, type CSSProperties } from "react";
3
+ import {
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ useState,
8
+ type CSSProperties,
9
+ } from "react";
4
10
  import {
5
11
  productUrl,
6
12
  type NuvlerStoreThemeDefinition,
@@ -20,6 +26,7 @@ import {
20
26
  import { nuvlerDefaultTheme } from "./definition.js";
21
27
  import { ThemeInteractionProvider } from "./product-detail-interactive.js";
22
28
  import { plainText, ThemeImageView } from "./shared.js";
29
+ import { CustomHtmlContent } from "./custom-html-content.js";
23
30
 
24
31
  interface PreviewContext {
25
32
  store: { name: string; slug: string };
@@ -40,6 +47,11 @@ interface PreviewContext {
40
47
  };
41
48
  }
42
49
 
50
+ // SDK 1.4.4 predates the optional editorial body already supported by this theme.
51
+ type PreviewEditorialItem = ThemeEditorialItem & {
52
+ content?: ThemePageContent | string | null;
53
+ };
54
+
43
55
  type PreviewRoute =
44
56
  | { type: "home" | "loading" | "not-found"; title?: string }
45
57
  | { type: "page"; title: string; slug: string; content: ThemePageContent }
@@ -65,47 +77,134 @@ type PreviewRoute =
65
77
  | { type: "product"; product: ThemeProduct }
66
78
  | {
67
79
  type: "editorial-list";
80
+ description?: string;
81
+ content?: ThemePageContent;
68
82
  title: string;
69
83
  basePath: string;
70
84
  items: ThemeEditorialItem[];
71
85
  }
72
- | { type: "editorial-detail"; basePath: string; item: ThemeEditorialItem };
86
+ | { type: "editorial-detail"; basePath: string; item: PreviewEditorialItem };
73
87
 
74
88
  function PageBlocks({ content }: { content: ThemePageContent }) {
75
- const text = (value: unknown): string => typeof value === "string" ? plainText(value) : "";
76
- return <div className="article-content content-renderer">{content.blocks.map((block, index) => {
77
- const data = block.data;
78
- const key = block.id || `${block.type}-${index}`;
79
- if (block.type === "header") {
80
- const heading = text(data.text);
81
- return Number(data.level) === 3 ? <h3 key={key}>{heading}</h3> : <h2 key={key}>{heading}</h2>;
82
- }
83
- if (block.type === "paragraph") return <p key={key}>{text(data.text)}</p>;
84
- if (block.type === "delimiter") return <hr key={key} />;
85
- if (block.type === "quote") return <blockquote key={key}><p>{text(data.text)}</p>{text(data.caption) && <cite>{text(data.caption)}</cite>}</blockquote>;
86
- if (block.type === "list") {
87
- const items = Array.isArray(data.items) ? data.items : [];
88
- const List = data.style === "ordered" ? "ol" : "ul";
89
- return <List key={key}>{items.map((item, itemIndex) => <li key={itemIndex}>{text(item && typeof item === "object" && "content" in item ? (item as { content: unknown }).content : item)}</li>)}</List>;
90
- }
91
- if (block.type === "image") {
92
- const file = data.file && typeof data.file === "object" ? data.file as Record<string, unknown> : {};
93
- const url = typeof file.url === "string" ? file.url : "";
94
- const image: ThemeImage | null = url ? { url, alt: text(data.caption), width: null, height: null } : null;
95
- return image ? <figure key={key}><ThemeImageView image={image} fallbackAlt={text(data.caption) || "Imagem do conteúdo"} />{text(data.caption) && <figcaption>{text(data.caption)}</figcaption>}</figure> : null;
96
- }
97
- if (block.type === "imageText") {
98
- const rawImage = data.image && typeof data.image === "object" ? data.image as Record<string, unknown> : {};
99
- const url = typeof rawImage.url === "string" ? rawImage.url : "";
100
- const image: ThemeImage | null = url ? { url, alt: text(rawImage.alt), width: null, height: null } : null;
101
- return <section className="content-image-text" key={key}>{image && <ThemeImageView image={image} fallbackAlt="Imagem do conteúdo" />}<div>{text(data.title) && <h2>{text(data.title)}</h2>}{text(data.text) && <p>{text(data.text)}</p>}</div></section>;
102
- }
103
- if (block.type === "table") {
104
- const rows = Array.isArray(data.content) ? data.content : [];
105
- return <div className="content-table" key={key}><table><tbody>{rows.map((row, rowIndex) => <tr key={rowIndex}>{Array.isArray(row) ? row.map((cell, cellIndex) => <td key={cellIndex}>{text(cell)}</td>) : null}</tr>)}</tbody></table></div>;
106
- }
107
- return null;
108
- })}</div>;
89
+ const text = (value: unknown): string =>
90
+ typeof value === "string" ? plainText(value) : "";
91
+ return (
92
+ <div className="article-content content-renderer">
93
+ {content.blocks.map((block, index) => {
94
+ const data = block.data;
95
+ const key = block.id || `${block.type}-${index}`;
96
+ if (block.type === "customHtml")
97
+ return (
98
+ <CustomHtmlContent
99
+ key={key}
100
+ html={typeof data.html === "string" ? data.html : ""}
101
+ css={typeof data.css === "string" ? data.css : ""}
102
+ />
103
+ );
104
+ if (block.type === "header") {
105
+ const heading = text(data.text);
106
+ return Number(data.level) === 3 ? (
107
+ <h3 key={key}>{heading}</h3>
108
+ ) : (
109
+ <h2 key={key}>{heading}</h2>
110
+ );
111
+ }
112
+ if (block.type === "paragraph")
113
+ return <p key={key}>{text(data.text)}</p>;
114
+ if (block.type === "delimiter") return <hr key={key} />;
115
+ if (block.type === "quote")
116
+ return (
117
+ <blockquote key={key}>
118
+ <p>{text(data.text)}</p>
119
+ {text(data.caption) && <cite>{text(data.caption)}</cite>}
120
+ </blockquote>
121
+ );
122
+ if (block.type === "list") {
123
+ const items = Array.isArray(data.items) ? data.items : [];
124
+ const List = data.style === "ordered" ? "ol" : "ul";
125
+ return (
126
+ <List key={key}>
127
+ {items.map((item, itemIndex) => (
128
+ <li key={itemIndex}>
129
+ {text(
130
+ item && typeof item === "object" && "content" in item
131
+ ? (item as { content: unknown }).content
132
+ : item,
133
+ )}
134
+ </li>
135
+ ))}
136
+ </List>
137
+ );
138
+ }
139
+ if (block.type === "image") {
140
+ const file =
141
+ data.file && typeof data.file === "object"
142
+ ? (data.file as Record<string, unknown>)
143
+ : {};
144
+ const url = typeof file.url === "string" ? file.url : "";
145
+ const image: ThemeImage | null = url
146
+ ? { url, alt: text(data.caption), width: null, height: null }
147
+ : null;
148
+ return image ? (
149
+ <figure key={key}>
150
+ <ThemeImageView
151
+ image={image}
152
+ fallbackAlt={text(data.caption) || "Imagem do conteúdo"}
153
+ />
154
+ {text(data.caption) && (
155
+ <figcaption>{text(data.caption)}</figcaption>
156
+ )}
157
+ </figure>
158
+ ) : null;
159
+ }
160
+ if (block.type === "imageText") {
161
+ const rawImage =
162
+ data.image && typeof data.image === "object"
163
+ ? (data.image as Record<string, unknown>)
164
+ : {};
165
+ const url = typeof rawImage.url === "string" ? rawImage.url : "";
166
+ const image: ThemeImage | null = url
167
+ ? { url, alt: text(rawImage.alt), width: null, height: null }
168
+ : null;
169
+ return (
170
+ <section className="content-image-text" key={key}>
171
+ {image && (
172
+ <ThemeImageView
173
+ image={image}
174
+ fallbackAlt="Imagem do conteúdo"
175
+ />
176
+ )}
177
+ <div>
178
+ {text(data.title) && <h2>{text(data.title)}</h2>}
179
+ {text(data.text) && <p>{text(data.text)}</p>}
180
+ </div>
181
+ </section>
182
+ );
183
+ }
184
+ if (block.type === "table") {
185
+ const rows = Array.isArray(data.content) ? data.content : [];
186
+ return (
187
+ <div className="content-table" key={key}>
188
+ <table>
189
+ <tbody>
190
+ {rows.map((row, rowIndex) => (
191
+ <tr key={rowIndex}>
192
+ {Array.isArray(row)
193
+ ? row.map((cell, cellIndex) => (
194
+ <td key={cellIndex}>{text(cell)}</td>
195
+ ))
196
+ : null}
197
+ </tr>
198
+ ))}
199
+ </tbody>
200
+ </table>
201
+ </div>
202
+ );
203
+ }
204
+ return null;
205
+ })}
206
+ </div>
207
+ );
109
208
  }
110
209
 
111
210
  export interface NuvlerDefaultThemeProps {
@@ -127,32 +226,34 @@ function readStoredCart(storageKey: string): PreviewCartItem[] {
127
226
  const parsed: unknown = JSON.parse(stored);
128
227
  if (!Array.isArray(parsed)) return [];
129
228
 
130
- return parsed.flatMap((candidate) => {
131
- if (
132
- !candidate ||
133
- typeof candidate !== "object" ||
134
- !("productSlug" in candidate) ||
135
- typeof candidate.productSlug !== "string" ||
136
- !("title" in candidate) ||
137
- typeof candidate.title !== "string" ||
138
- !("sku" in candidate) ||
139
- typeof candidate.sku !== "string"
140
- ) {
141
- return [];
142
- }
229
+ return parsed
230
+ .flatMap((candidate) => {
231
+ if (
232
+ !candidate ||
233
+ typeof candidate !== "object" ||
234
+ !("productSlug" in candidate) ||
235
+ typeof candidate.productSlug !== "string" ||
236
+ !("title" in candidate) ||
237
+ typeof candidate.title !== "string" ||
238
+ !("sku" in candidate) ||
239
+ typeof candidate.sku !== "string"
240
+ ) {
241
+ return [];
242
+ }
143
243
 
144
- const item = candidate as ThemeCartItem & {
145
- key?: unknown;
146
- quantity?: unknown;
147
- };
148
- const key = `${item.productSlug}::${item.variantId || "parent"}`;
149
- const quantity =
150
- typeof item.quantity === "number" && Number.isFinite(item.quantity)
151
- ? Math.min(99, Math.max(1, Math.trunc(item.quantity)))
152
- : 1;
244
+ const item = candidate as ThemeCartItem & {
245
+ key?: unknown;
246
+ quantity?: unknown;
247
+ };
248
+ const key = `${item.productSlug}::${item.variantId || "parent"}`;
249
+ const quantity =
250
+ typeof item.quantity === "number" && Number.isFinite(item.quantity)
251
+ ? Math.min(99, Math.max(1, Math.trunc(item.quantity)))
252
+ : 1;
153
253
 
154
- return [{ ...item, key, quantity }];
155
- }).slice(-30);
254
+ return [{ ...item, key, quantity }];
255
+ })
256
+ .slice(-30);
156
257
  }
157
258
 
158
259
  function money(value: number): string {
@@ -177,6 +278,12 @@ function catalogHref(
177
278
  }
178
279
 
179
280
  function editorialMeta(basePath: string) {
281
+ if (basePath === "")
282
+ return {
283
+ eyebrow: "Páginas",
284
+ action: "Saiba mais",
285
+ empty: "Nenhuma página publicada",
286
+ };
180
287
  if (basePath === "/servicos")
181
288
  return {
182
289
  eyebrow: "Soluções",
@@ -224,7 +331,14 @@ function EditorialPreview({
224
331
  <div className="editorial-grid editorial-list-grid">
225
332
  {items.map((item) => (
226
333
  <article className="editorial-card" key={item.slug}>
227
- <a className="editorial-card-image" href={`${basePath}/${item.slug}`}>
334
+ <a
335
+ className="editorial-card-image"
336
+ href={
337
+ "href" in item && typeof item.href === "string"
338
+ ? item.href
339
+ : `${basePath}/${item.slug}`
340
+ }
341
+ >
228
342
  <ThemeImageView
229
343
  image={item.image || item.thumbnail || item.coverImage}
230
344
  fallbackAlt={item.title}
@@ -238,7 +352,15 @@ function EditorialPreview({
238
352
  <span>{item.category.title || item.category.name}</span>
239
353
  )}
240
354
  <h2>
241
- <a href={`${basePath}/${item.slug}`}>{item.title}</a>
355
+ <a
356
+ href={
357
+ "href" in item && typeof item.href === "string"
358
+ ? item.href
359
+ : `${basePath}/${item.slug}`
360
+ }
361
+ >
362
+ {item.title}
363
+ </a>
242
364
  </h2>
243
365
  {publishedDate(item.publishedAt) && (
244
366
  <small className="editorial-card-date">
@@ -246,7 +368,14 @@ function EditorialPreview({
246
368
  </small>
247
369
  )}
248
370
  <p>{item.description}</p>
249
- <a className="text-link" href={`${basePath}/${item.slug}`}>
371
+ <a
372
+ className="text-link"
373
+ href={
374
+ "href" in item && typeof item.href === "string"
375
+ ? item.href
376
+ : `${basePath}/${item.slug}`
377
+ }
378
+ >
250
379
  {meta.action} <span>→</span>
251
380
  </a>
252
381
  </div>
@@ -268,9 +397,13 @@ export function createNuvlerDefaultRuntime(
268
397
  const [cartItems, setCartItems] = useState<PreviewCartItem[]>([]);
269
398
  const [cartOpen, setCartOpen] = useState(false);
270
399
  const [cartToast, setCartToast] = useState<string | null>(null);
271
- const [cartViewportHeight, setCartViewportHeight] = useState<number | null>(null);
400
+ const [cartViewportHeight, setCartViewportHeight] = useState<number | null>(
401
+ null,
402
+ );
272
403
  const [hydratedCartKey, setHydratedCartKey] = useState<string | null>(null);
273
- const cartToastTimeout = useRef<ReturnType<typeof window.setTimeout> | null>(null);
404
+ const cartToastTimeout = useRef<ReturnType<
405
+ typeof window.setTimeout
406
+ > | null>(null);
274
407
  const cartStorageKey = `nuvler:cart:${context.store.slug}`;
275
408
 
276
409
  useEffect(() => {
@@ -288,16 +421,22 @@ export function createNuvlerDefaultRuntime(
288
421
  window.localStorage.setItem(cartStorageKey, JSON.stringify(cartItems));
289
422
  }, [cartItems, cartStorageKey, hydratedCartKey]);
290
423
 
291
- useEffect(() => () => {
292
- if (cartToastTimeout.current) window.clearTimeout(cartToastTimeout.current);
293
- }, []);
424
+ useEffect(
425
+ () => () => {
426
+ if (cartToastTimeout.current)
427
+ window.clearTimeout(cartToastTimeout.current);
428
+ },
429
+ [],
430
+ );
294
431
 
295
432
  useEffect(() => {
296
433
  if (!cartOpen) return;
297
434
 
298
435
  const viewport = window.visualViewport;
299
436
  const syncCartViewportHeight = () =>
300
- setCartViewportHeight(Math.round(viewport?.height ?? window.innerHeight));
437
+ setCartViewportHeight(
438
+ Math.round(viewport?.height ?? window.innerHeight),
439
+ );
301
440
 
302
441
  syncCartViewportHeight();
303
442
  window.addEventListener("resize", syncCartViewportHeight);
@@ -394,7 +533,8 @@ export function createNuvlerDefaultRuntime(
394
533
  return [...current, { ...item, key, quantity: 1 }];
395
534
  });
396
535
  setCartToast(`“${item.title}” foi adicionado ao carrinho.`);
397
- if (cartToastTimeout.current) window.clearTimeout(cartToastTimeout.current);
536
+ if (cartToastTimeout.current)
537
+ window.clearTimeout(cartToastTimeout.current);
398
538
  cartToastTimeout.current = window.setTimeout(() => {
399
539
  setCartToast(null);
400
540
  cartToastTimeout.current = null;
@@ -591,8 +731,16 @@ export function createNuvlerDefaultRuntime(
591
731
  <div className="store-container">
592
732
  <span className="page-kicker">{meta.eyebrow}</span>
593
733
  <h1>{route.title}</h1>
734
+ {route.description && <p>{route.description}</p>}
594
735
  </div>
595
736
  </section>
737
+ {route.content?.blocks.length ? (
738
+ <section className="store-section">
739
+ <div className="store-container">
740
+ <PageBlocks content={route.content} />
741
+ </div>
742
+ </section>
743
+ ) : null}
596
744
  <section className="store-section">
597
745
  <div className="store-container">
598
746
  <EditorialPreview items={route.items} basePath={route.basePath} />
@@ -645,6 +793,13 @@ export function createNuvlerDefaultRuntime(
645
793
  fallbackHeight={900}
646
794
  />
647
795
  )}
796
+ {typeof route.item.content === "string" ? (
797
+ <div className="article-content legacy-content">
798
+ {plainText(route.item.content)}
799
+ </div>
800
+ ) : route.item.content?.blocks?.length ? (
801
+ <PageBlocks content={route.item.content} />
802
+ ) : null}
648
803
  <div className="article-content">
649
804
  <a className="text-link" href={route.basePath}>
650
805
  ← Voltar para{" "}
@@ -726,7 +881,13 @@ export function createNuvlerDefaultRuntime(
726
881
  <div className="cart-toast" role="status" aria-live="polite">
727
882
  <span aria-hidden="true">✓</span>
728
883
  <p>{cartToast}</p>
729
- <button type="button" onClick={() => setCartToast(null)} aria-label="Fechar aviso">×</button>
884
+ <button
885
+ type="button"
886
+ onClick={() => setCartToast(null)}
887
+ aria-label="Fechar aviso"
888
+ >
889
+ ×
890
+ </button>
730
891
  </div>
731
892
  )}
732
893
  {cartOpen && (
@@ -796,7 +957,9 @@ export function createNuvlerDefaultRuntime(
796
957
  <div className="cart-quantity">
797
958
  <button
798
959
  type="button"
799
- className={item.quantity === 1 ? "cart-delete" : undefined}
960
+ className={
961
+ item.quantity === 1 ? "cart-delete" : undefined
962
+ }
800
963
  aria-label={
801
964
  item.quantity === 1
802
965
  ? `Remover ${item.title} do carrinho`
@@ -4441,7 +4441,7 @@ a.mini-banner-card:focus-visible {
4441
4441
  .header-inner {
4442
4442
  position: relative;
4443
4443
  display: grid;
4444
- grid-template-columns: minmax(150px, 1fr) minmax(0, 760px) minmax(150px, 1fr);
4444
+ grid-template-columns: auto minmax(0, 1fr) auto;
4445
4445
  min-height: 68px;
4446
4446
  gap: 24px;
4447
4447
  transition:
@@ -4592,7 +4592,25 @@ a.mini-banner-card:focus-visible {
4592
4592
 
4593
4593
  .main-nav.main-nav-inline {
4594
4594
  justify-content: flex-start;
4595
- padding-left: clamp(32px, 5vw, 72px);
4595
+ /* O menu deve respeitar o espaço entre a marca e as ações, inclusive com zoom. */
4596
+ flex-wrap: wrap;
4597
+ gap: 0 22px;
4598
+ padding: 8px 0;
4599
+ }
4600
+
4601
+ .main-nav-inline > a,
4602
+ .main-nav-inline > .main-nav-group {
4603
+ min-width: 0;
4604
+ max-width: 100%;
4605
+ overflow-wrap: anywhere;
4606
+ }
4607
+
4608
+ .main-nav-inline > .main-nav-group > a {
4609
+ min-width: 0;
4610
+ }
4611
+
4612
+ .main-nav-inline .category-item-chevron {
4613
+ flex-shrink: 0;
4596
4614
  }
4597
4615
 
4598
4616
  .main-nav-group {
@@ -0,0 +1,47 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { createElement } from "react";
4
+ import { renderToStaticMarkup } from "react-dom/server";
5
+ import { Theme } from "../dist/src/theme-component.js";
6
+ import { ThemeEditorialItemSchema } from "@nuvler/theme-schema";
7
+
8
+ const context = {
9
+ store: { name: "Loja", slug: "loja" }, site: { modules: ["SERVICES"], settings: null },
10
+ navigation: { pages: [], categories: [] }, home: { content: { sections: [] } },
11
+ catalog: { products: [] }, editorial: { posts: [], services: [], cases: [] },
12
+ };
13
+ const item = { title: "Instalação", slug: "instalacao", description: "Resumo", image: null, category: null, publishedAt: null };
14
+ const content = { schemaVersion: 1, blocks: [
15
+ { type: "paragraph", data: { text: "Conteúdo completo do serviço" } },
16
+ { type: "header", data: { text: "Etapas do trabalho", level: 2 } },
17
+ { type: "list", data: { style: "ordered", items: ["Planejamento", { content: "Execução" }] } },
18
+ { type: "image", data: { file: { url: "https://example.com/etapas.png" }, caption: "Etapas ilustradas" } },
19
+ { type: "table", data: { content: [["Prazo", "Dois dias"]] } },
20
+ ] };
21
+ function render(body, basePath = "/servicos") {
22
+ return renderToStaticMarkup(createElement(Theme, { context, route: { type: "editorial-detail", basePath, item: { ...item, content: body } } }));
23
+ }
24
+
25
+ test("theme schema keeps published content and accepts legacy contexts", () => {
26
+ assert.deepEqual(ThemeEditorialItemSchema.parse({ ...item, content }).content, content);
27
+ assert.ok(ThemeEditorialItemSchema.safeParse(item).success);
28
+ assert.ok(ThemeEditorialItemSchema.safeParse({ ...item, content: null }).success);
29
+ assert.ok(ThemeEditorialItemSchema.safeParse({ ...item, content: "Texto antigo" }).success);
30
+ });
31
+
32
+ test("default theme renders full services, blog and cases rather than only summaries", () => {
33
+ for (const path of ["/servicos", "/blog", "/cases"]) {
34
+ const html = render(content, path);
35
+ for (const text of ["Conteúdo completo do serviço", "Etapas do trabalho", "Planejamento", "Execução", "Etapas ilustradas", "Dois dias"]) assert.ok(html.includes(text), text);
36
+ assert.ok(html.includes("<ol>"));
37
+ assert.ok(html.includes("https://example.com/etapas.png"));
38
+ assert.ok(html.includes("<table>"));
39
+ }
40
+ });
41
+
42
+ test("old plain HTML content is displayed as safe text; missing bodies still render", () => {
43
+ const html = render("<p>Texto antigo</p><img src=x onerror=alert(1)>");
44
+ assert.ok(html.includes("Texto antigo"));
45
+ assert.ok(!html.includes("onerror="));
46
+ for (const body of [undefined, null, { schemaVersion: 1, blocks: [] }]) assert.ok(render(body).includes("Instalação"));
47
+ });
@@ -15,13 +15,13 @@ export async function loadThemeBuild(project) {
15
15
  const directory = path.join(project.directory, THEME_BUILD_DIRECTORY);
16
16
  const entryPath = path.join(directory, THEME_BUILD_ENTRY);
17
17
  const styleCandidate = path.join(directory, THEME_BUILD_STYLE);
18
- if (!await isFile(entryPath)) {
18
+ if (!(await isFile(entryPath))) {
19
19
  throw new Error(`Build do tema não encontrado em ${entryPath}. Execute "nuvler theme build".`);
20
20
  }
21
21
  return {
22
22
  directory,
23
23
  entryPath,
24
- stylePath: await isFile(styleCandidate) ? styleCandidate : null,
24
+ stylePath: (await isFile(styleCandidate)) ? styleCandidate : null,
25
25
  };
26
26
  }
27
27
  export function createArtifactManifest(project, build) {
@@ -34,6 +34,7 @@ export function createArtifactManifest(project, build) {
34
34
  sdkVersion: project.manifest.sdkVersion,
35
35
  entry: "./theme.js",
36
36
  style: build.stylePath ? "./theme.css" : undefined,
37
+ capabilities: project.manifest.capabilities,
37
38
  presentation: project.manifest.presentation,
38
39
  };
39
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/theme/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAQ7C,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB;IACxD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB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QAClD,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY;QAC3C,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY;KAC5C,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/cli",
3
- "version": "0.5.14",
3
+ "version": "0.5.15",
4
4
  "description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,8 +20,8 @@
20
20
  "typecheck": "tsc -p tsconfig.json --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@nuvler/theme-schema": "^1.4.1",
24
- "@nuvler/theme-sdk": "^1.4.3",
23
+ "@nuvler/theme-schema": "^1.4.3",
24
+ "@nuvler/theme-sdk": "^1.4.5",
25
25
  "@vitejs/plugin-react": "^6.0.5",
26
26
  "commander": "^15.0.0",
27
27
  "react": "19.2.8",