@nuvler/cli 0.5.0 → 0.5.1

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.
package/dist/nuvler.js CHANGED
@@ -30,8 +30,8 @@ var __exportAll = (all, no_symbols) => {
30
30
  //#region src/commands/theme/create.ts
31
31
  var THEME_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
32
32
  var NEW_THEME_VERSION = "0.1.0";
33
- var CLI_VERSION_RANGE = "^0.5.0";
34
- var SDK_VERSION_RANGE = "^1.3.0";
33
+ var CLI_VERSION_RANGE = "^0.5.1";
34
+ var SDK_VERSION_RANGE = "^1.3.1";
35
35
  var THEME_TEMPLATES = [
36
36
  {
37
37
  id: "starter",
@@ -5288,7 +5288,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
5288
5288
  preprocess: () => preprocess,
5289
5289
  promise: () => promise,
5290
5290
  readonly: () => readonly,
5291
- record: () => record$1,
5291
+ record: () => record,
5292
5292
  refine: () => refine,
5293
5293
  set: () => set,
5294
5294
  strictObject: () => strictObject,
@@ -6147,7 +6147,7 @@ var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
6147
6147
  inst.keyType = def.keyType;
6148
6148
  inst.valueType = def.valueType;
6149
6149
  });
6150
- function record$1(keyType, valueType, params) {
6150
+ function record(keyType, valueType, params) {
6151
6151
  if (!valueType || !valueType._zod) return new ZodRecord({
6152
6152
  type: "record",
6153
6153
  keyType: string$1(),
@@ -6600,7 +6600,7 @@ function json(params) {
6600
6600
  boolean$1(),
6601
6601
  _null(),
6602
6602
  array(jsonSchema),
6603
- record$1(string$1(), jsonSchema)
6603
+ record(string$1(), jsonSchema)
6604
6604
  ]);
6605
6605
  });
6606
6606
  return jsonSchema;
@@ -6877,7 +6877,7 @@ var ThemeSiteSchema = object({
6877
6877
  var ThemeComponentSectionDataSchema = object({
6878
6878
  componentKey: componentKeySchema,
6879
6879
  schemaVersion: number$1().int().positive().max(1e3),
6880
- props: record$1(string$1(), unknown())
6880
+ props: record(string$1(), unknown())
6881
6881
  }).strict();
6882
6882
  var ThemeHomeSectionSchema = object({
6883
6883
  id: string$1().optional(),
@@ -6896,7 +6896,7 @@ var ThemeHomeSectionSchema = object({
6896
6896
  ]),
6897
6897
  enabled: boolean$1(),
6898
6898
  order: number$1().int().nonnegative(),
6899
- data: record$1(string$1(), unknown())
6899
+ data: record(string$1(), unknown())
6900
6900
  }).strict().superRefine((section, context) => {
6901
6901
  if (section.type !== "theme-component") return;
6902
6902
  const parsed = ThemeComponentSectionDataSchema.safeParse(section.data);
@@ -7735,94 +7735,6 @@ async function loadThemeContext({ store, apiUrl }) {
7735
7735
  }
7736
7736
  //#endregion
7737
7737
  //#region src/preview/prepare.ts
7738
- function record(value) {
7739
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
7740
- }
7741
- function meaningful(value) {
7742
- if (typeof value === "string") return Boolean(value.trim());
7743
- if (Array.isArray(value)) return value.length > 0;
7744
- return value !== null && value !== void 0;
7745
- }
7746
- async function migrationSeedContext(directory, context) {
7747
- let parsed;
7748
- try {
7749
- parsed = JSON.parse(await readFile(path.join(directory, "migration-content-seed.json"), "utf8"));
7750
- } catch (error) {
7751
- if (error.code === "ENOENT") return {
7752
- context,
7753
- sections: 0
7754
- };
7755
- throw new Error("migration-content-seed.json inválido; regenere o tema migrado.", { cause: error });
7756
- }
7757
- const seed = record(parsed);
7758
- const rawSections = Array.isArray(seed?.sections) ? seed.sections : [];
7759
- const supported = /* @__PURE__ */ new Set([
7760
- "hero",
7761
- "banner-carousel",
7762
- "image-text",
7763
- "rich-text",
7764
- "cta",
7765
- "services-grid",
7766
- "blog-grid",
7767
- "cases-grid",
7768
- "products-grid",
7769
- "products-carousel"
7770
- ]);
7771
- const seeds = rawSections.flatMap((candidate) => {
7772
- const section = record(candidate);
7773
- const data = record(section?.data);
7774
- if (!section || !data || typeof section.id !== "string" || typeof section.type !== "string" || !supported.has(section.type)) return [];
7775
- return [{
7776
- id: section.id,
7777
- type: section.type,
7778
- enabled: true,
7779
- order: typeof section.order === "number" ? section.order : 0,
7780
- data
7781
- }];
7782
- });
7783
- if (!seeds.length) return {
7784
- context,
7785
- sections: 0
7786
- };
7787
- const merged = context.home.content.sections.map((section) => ({
7788
- ...section,
7789
- data: { ...section.data }
7790
- }));
7791
- const claimed = /* @__PURE__ */ new Set();
7792
- for (const seedSection of seeds) {
7793
- const exact = merged.findIndex(({ id }) => id === seedSection.id);
7794
- const compatible = exact >= 0 ? exact : merged.findIndex((section, index) => !claimed.has(index) && section.type === seedSection.type);
7795
- if (compatible < 0) {
7796
- merged.push(seedSection);
7797
- continue;
7798
- }
7799
- claimed.add(compatible);
7800
- const configured = merged[compatible];
7801
- const configuredValues = Object.fromEntries(Object.entries(configured.data).filter(([, value]) => meaningful(value)));
7802
- merged[compatible] = {
7803
- ...configured,
7804
- id: seedSection.id,
7805
- data: {
7806
- ...seedSection.data,
7807
- ...configuredValues
7808
- }
7809
- };
7810
- }
7811
- merged.sort((left, right) => left.order - right.order);
7812
- return {
7813
- context: ThemeContextSchema.parse({
7814
- ...context,
7815
- home: {
7816
- ...context.home,
7817
- content: {
7818
- ...context.home.content,
7819
- sections: merged
7820
- }
7821
- }
7822
- }),
7823
- sections: seeds.length
7824
- };
7825
- }
7826
7738
  async function prepareThemePreview(options) {
7827
7739
  const project = await loadThemeProject(options.themeDirectory);
7828
7740
  const configured = await readThemeProjectConfig(project.directory);
@@ -7834,13 +7746,12 @@ async function prepareThemePreview(options) {
7834
7746
  apiUrl: session.apiUrl
7835
7747
  });
7836
7748
  if (context.store.slug !== tenant.slug) throw new Error(`A API retornou contexto do tenant "${context.store.slug}" para "${tenant.slug}".`);
7837
- const preview = await migrationSeedContext(project.directory, context);
7838
7749
  return {
7839
7750
  project,
7840
- context: preview.context,
7751
+ context: ThemeContextSchema.parse(context),
7841
7752
  apiUrl: session.apiUrl,
7842
7753
  tenant,
7843
- migrationSeedSections: preview.sections
7754
+ migrationSeedSections: 0
7844
7755
  };
7845
7756
  }
7846
7757
  //#endregion
@@ -8748,6 +8659,16 @@ function jsxAttributes(node) {
8748
8659
  function analyzeJsx(root) {
8749
8660
  const result = [];
8750
8661
  function visit(node, depth) {
8662
+ if (ts.isJsxExpression(node) && !node.expression) {
8663
+ const commentedComponent = node.getText().match(/<([A-Z][A-Za-z0-9_$]*)\b[^>]*\/>/);
8664
+ if (commentedComponent) result.push({
8665
+ tag: commentedComponent[1],
8666
+ depth,
8667
+ classes: [],
8668
+ text: [],
8669
+ attributes: []
8670
+ });
8671
+ }
8751
8672
  if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
8752
8673
  const attributes = jsxAttributes(node);
8753
8674
  const text = [];
@@ -8782,6 +8703,74 @@ function containsJsx(node) {
8782
8703
  visit(node);
8783
8704
  return found;
8784
8705
  }
8706
+ var PRESENTATION_FIELD = /^(?:icon|icons|color|colour|class|className|style|variant|layout|position|align|alignment|size|dot|shape|theme)$/i;
8707
+ function componentContentLists(node, source) {
8708
+ const declarations = /* @__PURE__ */ new Map();
8709
+ const candidates = [];
8710
+ const seenArrays = /* @__PURE__ */ new Set();
8711
+ function unwrap(expression) {
8712
+ if (ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression) || ts.isParenthesizedExpression(expression)) return unwrap(expression.expression);
8713
+ return expression;
8714
+ }
8715
+ function propertyName(name) {
8716
+ return ts.isIdentifier(name) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name) ? name.text : null;
8717
+ }
8718
+ function collect(child) {
8719
+ if (ts.isVariableDeclaration(child) && ts.isIdentifier(child.name) && child.initializer) {
8720
+ const initializer = unwrap(child.initializer);
8721
+ if (ts.isArrayLiteralExpression(initializer)) declarations.set(child.name.text, initializer);
8722
+ }
8723
+ ts.forEachChild(child, collect);
8724
+ }
8725
+ collect(source);
8726
+ function findMaps(child) {
8727
+ if (ts.isCallExpression(child) && ts.isPropertyAccessExpression(child.expression) && child.expression.name.text === "map") {
8728
+ const receiver = unwrap(child.expression.expression);
8729
+ const sourceName = ts.isIdentifier(receiver) ? receiver.text : null;
8730
+ const array = ts.isArrayLiteralExpression(receiver) ? receiver : sourceName ? declarations.get(sourceName) : void 0;
8731
+ if (array && !seenArrays.has(array.pos)) {
8732
+ seenArrays.add(array.pos);
8733
+ candidates.push({
8734
+ sourceName,
8735
+ array
8736
+ });
8737
+ }
8738
+ }
8739
+ ts.forEachChild(child, findMaps);
8740
+ }
8741
+ if (node.body) findMaps(node.body);
8742
+ let inlineIndex = 0;
8743
+ return candidates.flatMap(({ sourceName, array }) => {
8744
+ const fields = /* @__PURE__ */ new Set();
8745
+ const presentationFields = /* @__PURE__ */ new Set();
8746
+ let primitive = false;
8747
+ for (const element of array.elements) {
8748
+ const value = ts.isExpression(element) ? unwrap(element) : null;
8749
+ if (!value) continue;
8750
+ if (ts.isStringLiteralLike(value) || ts.isNoSubstitutionTemplateLiteral(value) || ts.isNumericLiteral(value)) {
8751
+ primitive = true;
8752
+ continue;
8753
+ }
8754
+ if (!ts.isObjectLiteralExpression(value)) continue;
8755
+ for (const property of value.properties) {
8756
+ if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) continue;
8757
+ const name = propertyName(property.name);
8758
+ if (!name) continue;
8759
+ if (PRESENTATION_FIELD.test(name)) presentationFields.add(name);
8760
+ else fields.add(name);
8761
+ }
8762
+ }
8763
+ if (!primitive && !fields.size) return [];
8764
+ const fallbackKey = inlineIndex++ === 0 ? "items" : `items${inlineIndex}`;
8765
+ return [{
8766
+ sourceName,
8767
+ fieldKey: sourceName && /^[a-z][a-zA-Z0-9-]{0,63}$/.test(sourceName) ? sourceName : fallbackKey,
8768
+ itemFields: primitive ? ["title"] : [...fields].slice(0, 30),
8769
+ primitive,
8770
+ presentationFields: [...presentationFields]
8771
+ }];
8772
+ });
8773
+ }
8785
8774
  function componentNodes(source) {
8786
8775
  const result = [];
8787
8776
  const defaultNames = /* @__PURE__ */ new Set();
@@ -8948,6 +8937,7 @@ async function analyzeComponentFile(absoluteFile, sourceDirectory, framework) {
8948
8937
  jsx,
8949
8938
  rootClasses: jsx.find(({ depth }) => depth === 0)?.classes ?? jsx[0]?.classes ?? [],
8950
8939
  text: [...new Set(jsx.flatMap((item) => item.text))].slice(0, 30),
8940
+ contentLists: componentContentLists(node, source),
8951
8941
  businessSignals: signals,
8952
8942
  roles: []
8953
8943
  };
@@ -9415,9 +9405,32 @@ function transformMigratedSource(module, content, graph, destinationFile, destin
9415
9405
  }
9416
9406
  function adaptFunction(node, adaptation) {
9417
9407
  if (!node.body || !ts.isBlock(node.body)) return;
9418
- const { bindingId, componentKey } = adaptation;
9408
+ const { bindingId, componentKey, contentLists = [] } = adaptation;
9419
9409
  const hookName = "__nuvlerSection";
9420
9410
  const mapped = /* @__PURE__ */ new Set();
9411
+ const adaptedItemArrays = /* @__PURE__ */ new Set();
9412
+ function presentationItems(expression) {
9413
+ const array = unwrappedExpression$1(expression);
9414
+ if (!ts.isArrayLiteralExpression(array)) return null;
9415
+ let hasPresentation = false;
9416
+ const items = array.elements.map((element) => {
9417
+ const item = unwrappedExpression$1(element);
9418
+ if (!ts.isObjectLiteralExpression(item)) return "{}";
9419
+ return `{ ${item.properties.flatMap((property) => {
9420
+ if (ts.isShorthandPropertyAssignment(property)) {
9421
+ if (!/^(?:icon|icons|color|colour|class|className|style|variant|layout|position|align|alignment|size|dot|shape|theme)$/i.test(property.name.text)) return [];
9422
+ hasPresentation = true;
9423
+ return [property.getText(source)];
9424
+ }
9425
+ if (!ts.isPropertyAssignment(property)) return [];
9426
+ const name = property.name.getText(source).replace(/^["']|["']$/g, "");
9427
+ if (!/^(?:icon|icons|color|colour|class|className|style|variant|layout|position|align|alignment|size|dot|shape|theme)$/i.test(name)) return [];
9428
+ hasPresentation = true;
9429
+ return [property.getText(source)];
9430
+ }).join(", ")} }`;
9431
+ });
9432
+ return hasPresentation ? `[${items.join(", ")}]` : null;
9433
+ }
9421
9434
  function findMapped(child) {
9422
9435
  if (ts.isCallExpression(child) && ts.isIdentifier(child.expression) && child.expression.text === "t" && child.arguments[0] && ts.isStringLiteralLike(child.arguments[0])) {
9423
9436
  const field = mappedField(child.arguments[0].text);
@@ -9466,27 +9479,56 @@ function transformMigratedSource(module, content, graph, destinationFile, destin
9466
9479
  });
9467
9480
  return;
9468
9481
  }
9469
- if (ts.isVariableDeclaration(child) && ts.isIdentifier(child.name) && child.initializer && ts.isArrayLiteralExpression(unwrappedExpression$1(child.initializer)) && (/(?:items?|faqs?|questions?|benefits?|features?|stats?|metrics?|numbers?|audiences?|profiles?|steps?)/i.test(child.name.text) || componentKey === "contacts" && /contacts?/i.test(child.name.text))) {
9482
+ if (ts.isVariableDeclaration(child) && ts.isIdentifier(child.name) && child.initializer && ts.isArrayLiteralExpression(unwrappedExpression$1(child.initializer))) {
9483
+ const sourceName = child.name.text;
9484
+ const list = contentLists.find((candidate) => candidate.sourceName === sourceName);
9485
+ if (!list) {
9486
+ ts.forEachChild(child, adapt);
9487
+ return;
9488
+ }
9489
+ const presentation = presentationItems(child.initializer);
9490
+ adaptedItemArrays.add(sourceName);
9491
+ const configured = presentation ? `migratedItems(${hookName}, ${JSON.stringify(list.fieldKey)}, ${presentation})` : `migratedItems(${hookName}, ${JSON.stringify(list.fieldKey)})`;
9470
9492
  edits.push({
9471
9493
  start: child.initializer.getStart(source),
9472
9494
  end: child.initializer.getEnd(),
9473
- text: `migratedItems(${hookName})`
9495
+ text: list.primitive ? `${configured}.map((item) => migratedText(item, "title"))` : configured
9474
9496
  });
9475
9497
  return;
9476
9498
  }
9477
- if (ts.isPropertyAccessExpression(child) && child.name.text === "map" && ts.isIdentifier(child.expression) && (/(?:items?|faqs?|questions?|benefits?|features?|stats?|metrics?|numbers?|audiences?|profiles?|steps?)/i.test(child.expression.text) || componentKey === "contacts" && /contacts?/i.test(child.expression.text))) {
9499
+ if (ts.isPropertyAccessExpression(child) && child.name.text === "map" && ts.isIdentifier(child.expression)) {
9500
+ const sourceName = child.expression.text;
9501
+ const list = contentLists.find((candidate) => candidate.sourceName === sourceName);
9502
+ if (!list) {
9503
+ ts.forEachChild(child, adapt);
9504
+ return;
9505
+ }
9506
+ if (adaptedItemArrays.has(sourceName)) return;
9507
+ const configured = `migratedItems(${hookName}, ${JSON.stringify(list.fieldKey)})`;
9478
9508
  edits.push({
9479
9509
  start: child.expression.getStart(source),
9480
9510
  end: child.expression.getEnd(),
9481
- text: `migratedItems(${hookName})`
9511
+ text: list.primitive ? `${configured}.map((item) => migratedText(item, "title"))` : configured
9482
9512
  });
9483
9513
  return;
9484
9514
  }
9485
- if (componentKey === "feature-list" && ts.isPropertyAccessExpression(child) && child.name.text === "map" && ts.isArrayLiteralExpression(unwrappedExpression$1(child.expression))) {
9515
+ if (ts.isPropertyAccessExpression(child) && child.name.text === "map" && ts.isArrayLiteralExpression(unwrappedExpression$1(child.expression))) {
9516
+ const directLists = contentLists.filter((list) => list.sourceName === null);
9517
+ const directIndex = directLists.findIndex((_list, index) => {
9518
+ return directLists[index] && !adaptedItemArrays.has(`__direct_${index}`);
9519
+ });
9520
+ const list = directIndex >= 0 ? directLists[directIndex] : void 0;
9521
+ if (!list) {
9522
+ ts.forEachChild(child, adapt);
9523
+ return;
9524
+ }
9525
+ adaptedItemArrays.add(`__direct_${directIndex}`);
9526
+ const presentation = presentationItems(child.expression);
9527
+ const configured = presentation ? `migratedItems(${hookName}, ${JSON.stringify(list.fieldKey)}, ${presentation})` : `migratedItems(${hookName}, ${JSON.stringify(list.fieldKey)})`;
9486
9528
  edits.push({
9487
9529
  start: child.expression.getStart(source),
9488
9530
  end: child.expression.getEnd(),
9489
- text: `migratedItems(${hookName}).map((item) => migratedText(item, "title"))`
9531
+ text: list.primitive ? `${configured}.map((item) => migratedText(item, "title"))` : configured
9490
9532
  });
9491
9533
  return;
9492
9534
  }
@@ -9561,6 +9603,19 @@ function transformMigratedSource(module, content, graph, destinationFile, destin
9561
9603
  });
9562
9604
  return;
9563
9605
  }
9606
+ if (child.initializer && [
9607
+ "aria-label",
9608
+ "aria-description",
9609
+ "placeholder",
9610
+ "title"
9611
+ ].includes(name) && (ts.isStringLiteral(child.initializer) || ts.isJsxExpression(child.initializer) && child.initializer.expression && ts.isStringLiteralLike(child.initializer.expression))) {
9612
+ edits.push({
9613
+ start: child.initializer.getStart(source),
9614
+ end: child.initializer.getEnd(),
9615
+ text: "{undefined}"
9616
+ });
9617
+ return;
9618
+ }
9564
9619
  }
9565
9620
  ts.forEachChild(child, adapt);
9566
9621
  }
@@ -9653,7 +9708,13 @@ function transformMigratedSource(module, content, graph, destinationFile, destin
9653
9708
  text: `import { MigratedContactFields, migratedImage, migratedItems, migratedLink, migratedText, migratedVideo, useMigratedContactForm, useMigratedSection } from ${JSON.stringify(adapterImport)};\n`
9654
9709
  });
9655
9710
  }
9656
- return applyEdits(content, edits);
9711
+ let transformed = applyEdits(content, edits);
9712
+ for (const adaptation of options.content ?? []) {
9713
+ const escaped = adaptation.componentName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9714
+ const commentedSection = new RegExp(`\\{\\s*\\/\\*\\s*(<${escaped}\\s*\\/>)\\s*\\*\\/\\s*\\}`, "g");
9715
+ transformed = transformed.replace(commentedSection, "$1");
9716
+ }
9717
+ return transformed;
9657
9718
  }
9658
9719
  function exportedNames(source) {
9659
9720
  const values = /* @__PURE__ */ new Set();
@@ -9720,7 +9781,11 @@ function contentAdaptations(plan) {
9720
9781
  binding: {
9721
9782
  id: "__header",
9722
9783
  file: plan.selected.HEADER.component.file,
9723
- component: plan.selected.HEADER.component.name
9784
+ component: plan.selected.HEADER.component.name,
9785
+ contentLists: plan.selected.HEADER.component.contentLists.map((list, index) => ({
9786
+ ...list,
9787
+ fieldKey: index === 0 ? "items" : `items${index + 1}`
9788
+ }))
9724
9789
  },
9725
9790
  special: true
9726
9791
  });
@@ -9728,7 +9793,11 @@ function contentAdaptations(plan) {
9728
9793
  binding: {
9729
9794
  id: "__footer",
9730
9795
  file: plan.selected.FOOTER.component.file,
9731
- component: plan.selected.FOOTER.component.name
9796
+ component: plan.selected.FOOTER.component.name,
9797
+ contentLists: plan.selected.FOOTER.component.contentLists.map((list, index) => ({
9798
+ ...list,
9799
+ fieldKey: index === 0 ? "items" : `items${index + 1}`
9800
+ }))
9732
9801
  },
9733
9802
  special: true
9734
9803
  });
@@ -9740,7 +9809,8 @@ function contentAdaptations(plan) {
9740
9809
  current.push({
9741
9810
  componentName: binding.component,
9742
9811
  bindingId: binding.id,
9743
- componentKey: binding.componentKey
9812
+ componentKey: binding.componentKey,
9813
+ contentLists: binding.contentLists
9744
9814
  });
9745
9815
  result.set(binding.file, current);
9746
9816
  }
@@ -9838,7 +9908,7 @@ async function runFidelityPass(plan, directory) {
9838
9908
  nextImageAdapterFile: path.join(directory, "src", "migrated-next-image.tsx"),
9839
9909
  content: adaptations.get(module.file),
9840
9910
  unwrapDocumentTags,
9841
- removeComponents: module.file === graph.entrypoint?.pageFile ? plan.analysis.components.filter((component) => /(whatsapp|floating|float|chat|popup)/i.test(component.name)).map((component) => component.name) : []
9911
+ removeComponents: plan.analysis.components.filter((component) => /(whatsapp|floating|float|chat|popup)/i.test(component.name)).map((component) => component.name)
9842
9912
  });
9843
9913
  if (module.business && !module.visual) adaptedBusinessFiles.push(module.file);
9844
9914
  await writeFile(destination, module.business && !module.visual ? transformed : `// @ts-nocheck -- código preservado pela Nuvler Fidelity Pass\n${transformed}`, "utf8");
@@ -9947,16 +10017,10 @@ export function Header({ site, categories, pages }: HeaderProps) {
9947
10017
  <a className=${classes("nuvler-migrated-brand", style.brand)} href="/">
9948
10018
  {site.settings?.logo?.url ? <img src={site.settings.logo.url} alt={site.settings.logo.alt || name} /> : <span>{name}</span>}
9949
10019
  </a>
9950
- <nav className=${classes("nuvler-migrated-nav", style.navigation)} aria-label="Navegação principal">
9951
- <a href="/">Início</a>
9952
- {site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}
10020
+ <nav className=${classes("nuvler-migrated-nav", style.navigation)}>
9953
10021
  {categories.slice(0, 6).map((category) => <a href={\`/\${category.slug}\`} key={category.slug}>{category.name}</a>)}
9954
10022
  {pages.slice(0, 4).map((page) => <a href={\`/\${page.slug}\`} key={page.slug}>{page.title}</a>)}
9955
10023
  </nav>
9956
- {site.modules.includes("PRODUCTS") && <form className="nuvler-migrated-search" action="/produtos">
9957
- <input name="busca" type="search" placeholder="Buscar produtos" />
9958
- <button className=${classes("nuvler-migrated-action", style.action)} type="submit">Buscar</button>
9959
- </form>}
9960
10024
  </div>
9961
10025
  </header>;
9962
10026
  }
@@ -9972,8 +10036,6 @@ export function Footer({ site, pages, template }: FooterProps) {
9972
10036
  <div className=${classes("nuvler-migrated-footer-inner", style.content)}>
9973
10037
  <div><strong className=${classes("nuvler-migrated-footer-brand", style.brand)}>{name}</strong>{site.settings?.description && <p className=${classes("nuvler-migrated-copy", style.text)}>{site.settings.description}</p>}</div>
9974
10038
  <nav className=${classes("nuvler-migrated-footer-nav", style.navigation)} aria-label={template.footerNavigationLabel}>
9975
- <a href="/">Início</a>
9976
- {site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}
9977
10039
  {pages.map((page) => <a href={\`/\${page.slug}\`} key={page.slug}>{page.title}</a>)}
9978
10040
  </nav>
9979
10041
  <div className="nuvler-migrated-contact">
@@ -10202,7 +10264,7 @@ function ThemeComponent({ section, binding, submitContact }: { section: ThemeHom
10202
10264
  if (type === "checkbox") return <label className="nuvler-migrated-form-wide nuvler-migrated-checkbox" key={key}><input name={key} required={required} type="checkbox" value="true" /><span>{label}</span></label>;
10203
10265
  if (type === "select") { const options = Array.isArray(field.options) ? field.options.map(record).filter((item): item is Record<string, unknown> => Boolean(item)) : []; return <label key={key}><span>{label}</span><select name={key} required={required}>{options.map((option) => <option key={value(option, "value")} value={value(option, "value")}>{value(option, "label") || value(option, "value")}</option>)}</select></label>; }
10204
10266
  return <label className={type === "textarea" ? "nuvler-migrated-form-wide" : ""} key={key}><span>{label}</span>{type === "textarea" ? <textarea name={key} placeholder={value(field, "placeholder")} required={required} rows={5} /> : <input name={key} placeholder={value(field, "placeholder")} required={required} type={["email", "tel", "url", "number"].includes(type) ? type : "text"} />}</label>;
10205
- })}<div className="nuvler-migrated-form-wide"><button className="nuvler-migrated-action" disabled={status === "sending"} type="submit">{status === "sending" ? "Enviando…" : value(props, "submitLabel") || "Enviar contato"}</button>{status === "success" && <p role="status">{value(props, "successMessage") || "Contato enviado com sucesso."}</p>}{status === "error" && <p role="alert">{error}</p>}</div></form>
10267
+ })}<div className="nuvler-migrated-form-wide"><button className="nuvler-migrated-action" disabled={status === "sending"} type="submit">{status === "sending" ? "" : value(props, "submitLabel")}</button>{status === "success" && value(props, "successMessage") && <p role="status">{value(props, "successMessage")}</p>}{status === "error" && <p role="alert">{error}</p>}</div></form>
10206
10268
  </section>;
10207
10269
  }
10208
10270
 
@@ -10293,7 +10355,7 @@ function configuredSection(id: string, sections: ThemeHomeSection[]): ThemeHomeS
10293
10355
  const custom = sections.find((section) => section.enabled
10294
10356
  && section.type === "theme-component"
10295
10357
  && section.data.componentKey === binding.componentKey);
10296
- if (custom) return custom;
10358
+ return custom;
10297
10359
  }
10298
10360
  const occurrence = bindingMetadata.filter((candidate) => candidate.type === binding.type && candidate.order < binding.order).length;
10299
10361
  return sections.filter((section) => section.enabled && section.type === binding.type).sort((left, right) => left.order - right.order)[occurrence];
@@ -10304,6 +10366,7 @@ export function useMigratedSection(id: string): Record<string, unknown> {
10304
10366
  if (!context) return {};
10305
10367
  if (id === "__header" || id === "__footer") {
10306
10368
  const name = context.site.settings?.siteName || context.site.tenant.name;
10369
+ const items = (context.menu ?? []).map((item) => ({ label: item.label, title: item.label, href: item.href, url: item.href }));
10307
10370
  return {
10308
10371
  title: name,
10309
10372
  description: context.site.settings?.description || "",
@@ -10312,6 +10375,7 @@ export function useMigratedSection(id: string): Record<string, unknown> {
10312
10375
  imageAlt: context.site.settings?.logo?.alt || name,
10313
10376
  buttonLabel: "",
10314
10377
  buttonUrl: "",
10378
+ items,
10315
10379
  };
10316
10380
  }
10317
10381
  const section = configuredSection(id, context.sections);
@@ -10368,21 +10432,37 @@ export function useMigratedContactForm(id: string) {
10368
10432
  };
10369
10433
  }
10370
10434
 
10371
- export function migratedItems(data: Record<string, unknown>, field = "items"): Record<string, unknown>[] {
10435
+ export function migratedItems(
10436
+ data: Record<string, unknown>,
10437
+ field = "items",
10438
+ presentation: Record<string, unknown>[] = [],
10439
+ ): Record<string, unknown>[] {
10372
10440
  const value = data[field];
10373
10441
  return Array.isArray(value)
10374
- ? value.filter((item): item is Record<string, unknown> => Boolean(item) && typeof item === "object" && !Array.isArray(item))
10442
+ ? value
10443
+ .filter((item): item is Record<string, unknown> => Boolean(item) && typeof item === "object" && !Array.isArray(item))
10444
+ .map((item, index) => {
10445
+ const title = item.title ?? item.label ?? item.name;
10446
+ const description = item.description ?? item.desc ?? item.text ?? item.sub;
10447
+ const normalized = {
10448
+ ...item,
10449
+ ...(title === undefined ? {} : { title, label: item.label ?? title }),
10450
+ ...(description === undefined ? {} : {
10451
+ description,
10452
+ desc: item.desc ?? description,
10453
+ sub: item.sub ?? description,
10454
+ }),
10455
+ };
10456
+ return presentation.length
10457
+ ? { ...presentation[index % presentation.length], ...normalized }
10458
+ : normalized;
10459
+ })
10375
10460
  : [];
10376
10461
  }
10377
10462
 
10378
10463
  export function MigratedContactFields({ data }: { data: Record<string, unknown> }) {
10379
10464
  const configured = migratedItems(data, "fields");
10380
- const fields = configured.length ? configured : [
10381
- { key: "name", label: "Nome", type: "text", required: true },
10382
- { key: "email", label: "E-mail", type: "email", required: true },
10383
- { key: "phone", label: "Telefone", type: "tel", required: false },
10384
- { key: "message", label: "Mensagem", type: "textarea", required: true },
10385
- ];
10465
+ const fields = configured;
10386
10466
  return <>
10387
10467
  {fields.map((field) => {
10388
10468
  const key = stringValue(field, "key");
@@ -10403,7 +10483,7 @@ export function MigratedContactFields({ data }: { data: Record<string, unknown>
10403
10483
  : <input name={key} placeholder={stringValue(field, "placeholder")} required={field.required === true} type={["email", "tel", "url", "number"].includes(type) ? type : "text"} />}
10404
10484
  </label>;
10405
10485
  })}
10406
- <button type="submit">{stringValue(data, "submitLabel") || "Enviar contato"}</button>
10486
+ <button type="submit">{stringValue(data, "submitLabel")}</button>
10407
10487
  </>;
10408
10488
  }
10409
10489
 
@@ -10613,7 +10693,7 @@ export default function Theme({ context, route = { type: "home" }, sdk }: Nuvler
10613
10693
  ? context.home.content.sections
10614
10694
  : themeDefinition.template.fallbackSections();
10615
10695
  let content;
10616
- if (route.type === "home") content = <Home sections={homeSections} products={context.catalog.products} posts={context.editorial.posts} services={context.editorial.services} cases={context.editorial.cases} site={site} submitContact={sdk?.contact?.submit} template={themeDefinition.template} />;
10696
+ if (route.type === "home") content = <Home sections={homeSections} products={context.catalog.products} posts={context.editorial.posts} services={context.editorial.services} cases={context.editorial.cases} site={site} menu={context.navigation.menu} pages={context.navigation.pages} submitContact={sdk?.contact?.submit} template={themeDefinition.template} />;
10617
10697
  else if (route.type === "catalog") content = <CatalogPage route={route} site={site} />;
10618
10698
  else if (route.type === "product") content = <ProductPage route={route} site={site} cart={sdk?.cart} />;
10619
10699
  else if (route.type === "editorial-list" || route.type === "editorial-detail") content = <EditorialPage route={route} />;
@@ -10683,32 +10763,7 @@ function blankBindingData(binding) {
10683
10763
  const props = {};
10684
10764
  for (const field of binding.componentDefinition.fields) if (field.defaultValue !== void 0) props[field.key] = field.defaultValue;
10685
10765
  else if (field.control === "repeater") props[field.key] = [];
10686
- else if (field.control === "contact-fields") props[field.key] = [
10687
- {
10688
- key: "name",
10689
- label: "Nome",
10690
- type: "text",
10691
- required: true
10692
- },
10693
- {
10694
- key: "email",
10695
- label: "E-mail",
10696
- type: "email",
10697
- required: true
10698
- },
10699
- {
10700
- key: "phone",
10701
- label: "Telefone",
10702
- type: "tel",
10703
- required: false
10704
- },
10705
- {
10706
- key: "message",
10707
- label: "Mensagem",
10708
- type: "textarea",
10709
- required: true
10710
- }
10711
- ];
10766
+ else if (field.control === "contact-fields") props[field.key] = [];
10712
10767
  else if (field.control === "boolean") props[field.key] = false;
10713
10768
  else if (field.control === "number") props[field.key] = field.min ?? 0;
10714
10769
  else props[field.key] = "";
@@ -11145,7 +11200,9 @@ async function extractContentCatalog(plan) {
11145
11200
  }
11146
11201
  const sections = plan.contentBindings.map((binding) => {
11147
11202
  const parsed = sources.get(binding.file);
11203
+ const componentAnalysis = plan.analysis.components.find((component) => component.file === binding.file && component.name === binding.component);
11148
11204
  const values = [];
11205
+ const extractedRepeaters = /* @__PURE__ */ new Map();
11149
11206
  const formFields = [];
11150
11207
  const seen = /* @__PURE__ */ new Set();
11151
11208
  const counters = /* @__PURE__ */ new Map();
@@ -11291,6 +11348,54 @@ async function extractContentCatalog(plan) {
11291
11348
  const parent = node.parent;
11292
11349
  return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name.text : null;
11293
11350
  }
11351
+ function extractRepeaters(body) {
11352
+ const contentLists = binding.contentLists ?? componentAnalysis?.contentLists ?? [];
11353
+ if (!contentLists.length) return;
11354
+ const declarations = /* @__PURE__ */ new Map();
11355
+ function collectDeclarations(candidate) {
11356
+ if (ts.isVariableDeclaration(candidate) && ts.isIdentifier(candidate.name) && candidate.initializer) {
11357
+ const initializer = unwrappedExpression(candidate.initializer);
11358
+ if (ts.isArrayLiteralExpression(initializer)) declarations.set(candidate.name.text, initializer);
11359
+ }
11360
+ ts.forEachChild(candidate, collectDeclarations);
11361
+ }
11362
+ collectDeclarations(source);
11363
+ const directArrays = [];
11364
+ function collectDirectArrays(candidate) {
11365
+ if (ts.isCallExpression(candidate) && ts.isPropertyAccessExpression(candidate.expression) && candidate.expression.name.text === "map") {
11366
+ const receiver = unwrappedExpression(candidate.expression.expression);
11367
+ if (ts.isArrayLiteralExpression(receiver)) directArrays.push(receiver);
11368
+ }
11369
+ ts.forEachChild(candidate, collectDirectArrays);
11370
+ }
11371
+ collectDirectArrays(body);
11372
+ let directIndex = 0;
11373
+ for (const list of contentLists) {
11374
+ const array = list.sourceName ? declarations.get(list.sourceName) : directArrays[directIndex++];
11375
+ if (!array) continue;
11376
+ const items = [];
11377
+ for (const element of array.elements) {
11378
+ if (!ts.isExpression(element)) continue;
11379
+ const value = unwrappedExpression(element);
11380
+ if (list.primitive) {
11381
+ const item = resolvedString(value) ?? (ts.isNumericLiteral(value) ? value.text : null);
11382
+ if (item !== null) items.push({ title: item });
11383
+ continue;
11384
+ }
11385
+ if (!ts.isObjectLiteralExpression(value)) continue;
11386
+ const item = {};
11387
+ for (const property of value.properties) {
11388
+ if (!ts.isPropertyAssignment(property)) continue;
11389
+ const key = propertyKey(property);
11390
+ if (!key || !list.itemFields.includes(key)) continue;
11391
+ const itemValue = resolvedString(property.initializer) ?? (ts.isNumericLiteral(unwrappedExpression(property.initializer)) ? unwrappedExpression(property.initializer).getText(source) : null);
11392
+ if (itemValue !== null) item[key] = itemValue;
11393
+ }
11394
+ if (Object.keys(item).length) items.push(item);
11395
+ }
11396
+ extractedRepeaters.set(list.fieldKey, items);
11397
+ }
11398
+ }
11294
11399
  function visitContent(node) {
11295
11400
  if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) collectFormField(node);
11296
11401
  if (binding.componentKey === "feature-list" && ts.isArrayLiteralExpression(node)) for (const element of node.elements) {
@@ -11374,6 +11479,7 @@ async function extractContentCatalog(plan) {
11374
11479
  }
11375
11480
  function findComponent(node) {
11376
11481
  if ((ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node)) && componentName(node) === binding.component && node.body) {
11482
+ extractRepeaters(node.body);
11377
11483
  visitContent(node.body);
11378
11484
  return;
11379
11485
  }
@@ -11410,6 +11516,7 @@ async function extractContentCatalog(plan) {
11410
11516
  assign("videoUrl", ranked("videoUrl"));
11411
11517
  assign("posterImageUrl", ranked("posterImageUrl"));
11412
11518
  if (binding.componentKey === "contact-form" && formFields.length && availableFields.has("fields")) data.fields = formFields;
11519
+ for (const [field, items] of extractedRepeaters) if (availableFields.has(field)) data[field] = items;
11413
11520
  const media = ranked("imageUrl");
11414
11521
  if (media && availableFields.has("imageUrl")) selected.add(media.key);
11415
11522
  if (availableFields.has("text") && !data.text) data.text = values.filter(({ kind, key }) => kind === "text" && !selected.has(key) && !key.includes("tradução não localizada")).map(({ value }) => value).join("\n\n");
@@ -12495,13 +12602,12 @@ function customComponentDefinition(kind) {
12495
12602
  key: "submitLabel",
12496
12603
  label: "Texto do botão",
12497
12604
  control: "text",
12498
- defaultValue: "Enviar contato"
12605
+ required: true
12499
12606
  },
12500
12607
  {
12501
12608
  key: "successMessage",
12502
12609
  label: "Mensagem de sucesso",
12503
- control: "text",
12504
- defaultValue: "Contato enviado com sucesso."
12610
+ control: "text"
12505
12611
  }
12506
12612
  ],
12507
12613
  action: {
@@ -12547,6 +12653,79 @@ function customComponentDefinition(kind) {
12547
12653
  };
12548
12654
  return listComponentDefinition(kind);
12549
12655
  }
12656
+ function generatedListComponentDefinition(component) {
12657
+ const hasImage = component.jsx.some(({ tag }) => [
12658
+ "img",
12659
+ "image",
12660
+ "picture"
12661
+ ].includes(tag.toLowerCase()));
12662
+ const hasVideo = component.jsx.some(({ tag }) => [
12663
+ "video",
12664
+ "source",
12665
+ "iframe"
12666
+ ].includes(tag.toLowerCase()));
12667
+ const hasAction = component.jsx.some(({ tag }) => ["a", "button"].includes(tag.toLowerCase()));
12668
+ const label = component.name.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim();
12669
+ const fields = [
12670
+ {
12671
+ key: "eyebrow",
12672
+ label: "Chamada pequena",
12673
+ control: "text"
12674
+ },
12675
+ {
12676
+ key: "title",
12677
+ label: "Título da seção",
12678
+ control: "text"
12679
+ },
12680
+ {
12681
+ key: "description",
12682
+ label: "Descrição",
12683
+ control: "textarea"
12684
+ }
12685
+ ];
12686
+ if (hasImage) fields.push({
12687
+ key: "imageId",
12688
+ label: "Imagem",
12689
+ control: "image"
12690
+ }, {
12691
+ key: "imageAlt",
12692
+ label: "Texto alternativo da imagem",
12693
+ control: "text"
12694
+ });
12695
+ if (hasVideo) fields.push({
12696
+ key: "videoUrl",
12697
+ label: "Vídeo",
12698
+ control: "video"
12699
+ });
12700
+ if (hasAction) fields.push({
12701
+ key: "buttonLabel",
12702
+ label: "Texto do botão",
12703
+ control: "text"
12704
+ }, {
12705
+ key: "buttonUrl",
12706
+ label: "Link do botão",
12707
+ control: "url"
12708
+ });
12709
+ for (const list of component.contentLists) fields.push({
12710
+ key: list.fieldKey,
12711
+ label: list.sourceName ? `Itens de ${list.sourceName}` : "Itens",
12712
+ control: "repeater",
12713
+ maxItems: 100,
12714
+ itemFields: list.itemFields.map((key) => ({
12715
+ key,
12716
+ label: key.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " "),
12717
+ control: /(?:url|href|link)$/i.test(key) ? "url" : /(?:description|desc|text|sub|answer|content)$/i.test(key) ? "textarea" : "text"
12718
+ }))
12719
+ });
12720
+ return {
12721
+ key: `migrated-${safeThemeId(component.name)}`,
12722
+ name: label || component.name,
12723
+ description: "Componente visual migrado; todo o conteúdo é configurado pelo painel.",
12724
+ category: "Listas",
12725
+ schemaVersion: 1,
12726
+ fields
12727
+ };
12728
+ }
12550
12729
  function contentType(component) {
12551
12730
  const name = normalized(component.name);
12552
12731
  const hasRole = (role) => component.roles.some((candidate) => candidate.role === role);
@@ -12561,6 +12740,7 @@ function contentType(component) {
12561
12740
  if (/(blog|post|article|artigo)/.test(name)) return "blog-grid";
12562
12741
  if (/(case|project|projeto|portfolio|testimonial|depoimento)/.test(name)) return "cases-grid";
12563
12742
  if (name.includes("banner") && /(carousel|slider|slide)/.test(name)) return "banner-carousel";
12743
+ if (component.contentLists.length) return "theme-component";
12564
12744
  if (/(hero|banner|masthead)/.test(name)) return "hero";
12565
12745
  if (customComponentKind(component)) return "theme-component";
12566
12746
  if (/(cta|calltoaction|contact|contato|newsletter|final)/.test(name)) return "cta";
@@ -12620,7 +12800,11 @@ function contentBindings(analysis, selected) {
12620
12800
  const type = contentType(component);
12621
12801
  const slug = safeThemeId(component.name);
12622
12802
  const customKind = type === "theme-component" ? customComponentKind(component) : null;
12623
- const componentDefinition = customKind ? customComponentDefinition(customKind) : void 0;
12803
+ const contentLists = customKind ? component.contentLists.map((list, index) => ({
12804
+ ...list,
12805
+ fieldKey: index === 0 ? "items" : `items${index + 1}`
12806
+ })) : component.contentLists;
12807
+ const componentDefinition = type !== "theme-component" ? void 0 : customKind ? customComponentDefinition(customKind) : component.contentLists.length ? generatedListComponentDefinition(component) : void 0;
12624
12808
  return {
12625
12809
  id: `migrated-${slug}-${order + 1}`,
12626
12810
  component: component.name,
@@ -12630,7 +12814,8 @@ function contentBindings(analysis, selected) {
12630
12814
  fields: componentDefinition?.fields.map(({ key }) => key) ?? CONTENT_FIELDS[type],
12631
12815
  classes: classProfile(component),
12632
12816
  componentKey: componentDefinition?.key,
12633
- componentDefinition
12817
+ componentDefinition,
12818
+ contentLists
12634
12819
  };
12635
12820
  });
12636
12821
  }
@@ -13127,7 +13312,7 @@ async function authLogout() {
13127
13312
  //#endregion
13128
13313
  //#region src/index.ts
13129
13314
  var program = new Command();
13130
- program.name("nuvler").description("Nuvler Theme Development CLI").version("0.5.0");
13315
+ program.name("nuvler").description("Nuvler Theme Development CLI").version("0.5.1");
13131
13316
  var theme = program.command("theme").description("Manage Nuvler themes");
13132
13317
  var auth = program.command("auth").description("Manage developer authentication");
13133
13318
  auth.command("login").requiredOption("--token <token>", "Developer token").option("--api-url <url>", "Nuvler API base URL (or use NUVLER_API_URL)").action(async (options) => {