@nodii/dev 0.6.194 → 0.6.196

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/README.md CHANGED
@@ -1315,6 +1315,38 @@ product-page catalog names the Surface by its published component-set key
1315
1315
  That map is keyed by variant node id, so `--fetch` joins it while it reads
1316
1316
  and the tree keeps only each variant's state name; no node id is committed
1317
1317
  (MW8-20). A tree that still holds one is refused with `SURFACE_TREE_STALE`.
1318
+ - **Loading flows down (NODII-DEV-CLI-260, MW6-29).** Every Surface takes an
1319
+ optional `loading?: boolean`, and every view passes it to each DS part that
1320
+ draws its own skeleton, whether or not its template draws the prop: `status`
1321
+ on a part on the DS async contract (`DataTable`, `Timeline`, `MetricCard`,
1322
+ `Chart`, `ActivityFeedBlock`, `CommentThreadBlock`, `TenantPickerCardBlock`),
1323
+ else its own `loading` (`PageMetricsBarBlock`, `QrDisplay`) or `isLoading`
1324
+ (`DataTableToolbarBlock`, `ChartWithRange`). A Table whose rows are lifted draws
1325
+ `{loading ? <TableSkeletonRows … /> : rows.map(…)}` under its real header, a
1326
+ skeleton row per drawn row. A part that already draws the prop keeps it. So a
1327
+ route passes `loading` and never hand-builds a loading page.
1328
+ - **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
1329
+ `<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
1330
+ `state` with only the props its view reads (`{ state: "read-error" } &
1331
+ Partial<Props> & Pick<Props, "error" | "onRetry">`). So a route whose read
1332
+ failed renders `<XSurface state="read-error" error={e} onRetry={retry} />`
1333
+ without the other views' data. Each view takes `Pick<Props, …>` of what it reads.
1334
+ - **The route's wrapper (NODII-DEV-CLI-260).** Where the catalog's `sourcePath`
1335
+ names no page yet, `--write` also writes it: a thin `export function <Id>(props:
1336
+ <Id>SurfaceInput) { return <<Id>Surface {...props} />; }` that re-exports the
1337
+ Surface's types and states, with no Legacy branch. A page that exists is the
1338
+ route's own and is never rewritten; `--check` doesn't compare it. `--json`
1339
+ names a written wrapper in `data.surfaces[].wrapper` (else `null`).
1340
+ - **`data-surface` (NODII-DEV-CLI-260).** Every view's root element carries
1341
+ `data-surface="<catalog id>"`, so a route test asserts `[data-surface]` in any
1342
+ state.
1343
+ - **Loading variants are warned about (NODII-DEV-CLI-260, MW6-29).** A Surface
1344
+ draws no Loading variant: its DS parts draw their own skeleton from `loading`.
1345
+ A Surface whose set still has one (a state named `loading`, `initial-loading`,
1346
+ `loading-…`) is still generated, and `generate` prints one `MW6-29:` line with
1347
+ the count and the Surfaces hit. `--json` lists them in
1348
+ `data.surfaces[].loadingVariants`. The exit code is unchanged for now; it is
1349
+ refused later.
1318
1350
  - **`--check`** writes nothing and exits 1 when a generated file differs from
1319
1351
  the generator's output. The design system's `surface-gen-equal` CI gate runs
1320
1352
  `surface generate --all --check` with a pinned `@nodii/dev`; `--all`
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
4
4
  import { homedir, platform } from "node:os";
5
5
  import { basename, dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.194";
7
+ export const VERSION = "0.6.196";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/surface.js CHANGED
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
34
34
  import { createRenderer } from "./vendor/render-templates.mjs";
35
35
 
36
36
  /** Bumped whenever the emitted code changes shape for the same inputs. */
37
- export const GENERATOR_FORMAT = 47;
37
+ export const GENERATOR_FORMAT = 49;
38
38
  /**
39
39
  * DS parts that are an item of their parent's own list or grid, so they take no sizing
40
40
  * wrapper: a Detail Section / Row's facts are the section grid's cells, a Right Pane / Row
@@ -614,6 +614,21 @@ export const textUtility = (styleName, textStyles) => (styleName ? (textStyles.g
614
614
  * Emit one Surface's generated file. Returns { code, unmapped, states }:
615
615
  * `unmapped` lists every layer that has no Code Connect mapping (U08-14).
616
616
  */
617
+ /** A state drawn as the whole Surface loading (`loading`, `initial-loading`, `loading-pages-1-2`). */
618
+ const isLoadingState = (state) => /(^|-)loading(-|$)/.test(state);
619
+
620
+ /**
621
+ * MW6-29: a Surface draws no Loading variant. Its DS parts draw their own skeleton
622
+ * from `loading`, which the route passes (NODII-DEV-CLI-260). A Surface whose set
623
+ * still has one is warned about now, with a count, and refused later, so
624
+ * `generate` doesn't fail on release day. Null when none is hit.
625
+ */
626
+ export function loadingVariantWarning(results) {
627
+ const hit = results.filter((r) => r.loadingVariants?.length);
628
+ if (!hit.length) return null;
629
+ return `MW6-29: ${hit.length} Surface${hit.length === 1 ? " still draws" : "s still draw"} a Loading variant; its DS parts draw their own skeleton from \`loading\`, so remove the variant in Figma (warned now, refused later): ${hit.map((r) => `${r.row.id} (${r.loadingVariants.join(", ")})`).join(", ")}`;
630
+ }
631
+
617
632
  export function emitSurface(tree, row, ds) {
618
633
  const imports = [];
619
634
  const unmapped = [];
@@ -641,11 +656,15 @@ export function emitSurface(tree, row, ds) {
641
656
  if (emitted.trimStart().startsWith("{/*")) {
642
657
  throw new CliError("SURFACE_VIEW_NOT_LAID_OUT", `${row.id}: view ${JSON.stringify(variant.name)} has no auto layout, so it would generate as an empty page; give the variant (or the App Frame's mainContent) auto layout in Figma, publish, and refetch`, 1);
643
658
  }
644
- return { state, fn, body: emitted, variant: variant.name };
659
+ // The view's root names its Surface, so a route test finds it in any state (NODII-DEV-CLI-260).
660
+ const body = passLoading(emitted).replace(/^(\s*)<div\b/, `$1<div data-surface=${JSON.stringify(row.id)}`);
661
+ return { state, fn, body, variant: variant.name };
645
662
  });
646
663
  const component = `${pascal(row.id)}Surface`;
647
664
  const stateType = `${component}State`;
648
665
  const propsType = `${component}Props`;
666
+ const inputType = `${component}Input`;
667
+ const viewProps = (v) => `Pick<${propsType}, ${[...v.uses].sort().map((name) => JSON.stringify(name)).join(" | ")}>`;
649
668
  const named = resolveScopes(views, scopes, layers);
650
669
  settlePiiColumns(views, unmapped);
651
670
  const data = dataProps(views, propsType);
@@ -682,16 +701,52 @@ export function emitSurface(tree, row, ds) {
682
701
  "",
683
702
  ]
684
703
  : []),
704
+ // Each state takes the props its own view reads, so a route draws the Error or Empty view
705
+ // from what it has; the full props stay accepted for every state (NODII-DEV-CLI-260).
706
+ "/** What the Surface takes: a state and the props its view reads, or the full props for any state. */",
707
+ `export type ${inputType} =`,
708
+ ` | ({ state: ${stateType} } & ${propsType})`,
709
+ ...views.map((v, i) => ` | ({ state: ${JSON.stringify(v.state)} } & Partial<${propsType}>${v.uses.size ? ` & ${viewProps(v)}` : ""})${i === views.length - 1 ? ";" : ""}`),
710
+ "",
685
711
  `/** ${row.title}: the Surface's ${views.length} variant${views.length === 1 ? "" : "s"}, drawn as Figma composes them. */`,
686
- data.size ? `export function ${component}({ state, ...data }: { state: ${stateType} } & ${propsType}) {` : `export function ${component}({ state }: { state: ${stateType} }) {`,
687
- " switch (state) {",
688
- ...views.flatMap((v) => [` case ${JSON.stringify(v.state)}:`, ` return <${v.fn}${v.uses.size ? " {...data}" : ""} />;`]),
712
+ `export function ${component}(props: ${inputType}) {`,
713
+ " switch (props.state) {",
714
+ ...views.flatMap((v) => [` case ${JSON.stringify(v.state)}:`, ` return <${v.fn}${v.uses.size ? " {...props}" : ""} />;`]),
689
715
  " }",
690
716
  "}",
691
- ...views.flatMap((v) => ["", v.uses.size ? `function ${v.fn}({ ${[...v.uses].sort().join(", ")} }: ${propsType}) {` : `function ${v.fn}() {`, " return (", v.body, " );", "}"]),
717
+ ...views.flatMap((v) => ["", v.uses.size ? `function ${v.fn}({ ${[...v.uses].sort().join(", ")} }: ${viewProps(v)}) {` : `function ${v.fn}() {`, " return (", v.body, " );", "}"]),
692
718
  "",
693
719
  ];
694
- return { code: lines.join("\n"), unmapped, states: views.map((v) => v.state) };
720
+ return {
721
+ code: lines.join("\n"),
722
+ unmapped,
723
+ states: views.map((v) => v.state),
724
+ loadingVariants: views.map((v) => v.state).filter(isLoadingState),
725
+ wrapper: row.sourcePath ? wrapperCode(row, { component, inputType }) : null,
726
+ };
727
+ }
728
+
729
+ /**
730
+ * The route's wrapper over the generated Surface: a thin `return <XSurface {...props} />`
731
+ * (NODII-DEV-CLI-260). `--write` writes it at the catalog's sourcePath only when no page
732
+ * is there yet, and never rewrites one: a page that exists is the route's own.
733
+ */
734
+ export function wrapperCode(row, { component, inputType }) {
735
+ const module = `./${basename(row.sourcePath).replace(/\.tsx$/, "")}${GENERATED_SUFFIX.replace(/\.tsx$/, "")}`;
736
+ const states = `${pascal(row.id).replace(/^./, (c) => c.toLowerCase())}SurfaceStates`;
737
+ return [
738
+ "// The route's wrapper over its generated Surface, written once by `nodii-dev surface generate --write`",
739
+ "// because no product page was here (NODII-DEV-CLI-260). The generator never rewrites it.",
740
+ `import { ${component}, type ${inputType} } from "${module}";`,
741
+ "",
742
+ `export { ${states}, type ${inputType}, type ${component}Props, type ${component}State } from "${module}";`,
743
+ "",
744
+ `/** ${row.title}: the generated Surface; the route passes its state, its data and \`loading\`. */`,
745
+ `export function ${pascal(row.id)}(props: ${inputType}) {`,
746
+ ` return <${component} {...props} />;`,
747
+ "}",
748
+ "",
749
+ ].join("\n");
695
750
  }
696
751
 
697
752
  /**
@@ -734,8 +789,12 @@ const JS_LITERALS = new Set(["true", "false", "null", "undefined", "this"]);
734
789
  /** Strings blanked to spaces of the same length, so a position still points into `code`. */
735
790
  const maskStrings = (code) => code.replace(/"(?:[^"\\\n]|\\.)*"|`[^`]*`/g, (s) => `"${" ".repeat(s.length - 2)}"`);
736
791
 
737
- /** A list the generator lifts opens `{rows.map((row) => (`: [{ at, list, param }] in order. */
738
- const LIST_OPEN = /\{([A-Za-z_][A-Za-z0-9_]*)\.map\(\(([a-z][A-Za-z0-9]*)\) => \(/g;
792
+ /**
793
+ * A list the generator lifts opens `{rows.map((row) => (`, or, in a Table that
794
+ * draws its skeleton rows while the Surface loads, `{loading ? <TableSkeletonRows … /> : rows.map((row) => (`:
795
+ * [{ at, list, param }] in order.
796
+ */
797
+ const LIST_OPEN = /\{(?:loading \? <TableSkeletonRows\b[^\n]*? \/> : )?([A-Za-z_][A-Za-z0-9_]*)\.map\(\(([a-z][A-Za-z0-9]*)\) => \(/g;
739
798
  const listOpeners = (code) => [...code.matchAll(LIST_OPEN)].map((m) => ({ at: m.index, list: m[1], param: m[2] }));
740
799
  /** The list whose item `param` names at position `at`: the nearest opener before it that binds it. */
741
800
  const listAt = (openers, at, param) => openers.filter((o) => o.at < at && o.param === param).at(-1)?.list ?? null;
@@ -1215,6 +1274,9 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1215
1274
  if (!ctx.inTable) {
1216
1275
  out = out.replace(/^<Chip\b((?:[^>{"]|"(?:[^"\\\n]|\\.)*"|\{[^{}]*\})*)>\s*([^<>{}\n]*[A-Za-z0-9][^<>{}\n]*?)\s*<\/Chip>$/, (all, attrs) => `<Chip${attrs}>{${lift(place(), joinName(place(), "label"))}}</Chip>`);
1217
1276
  }
1277
+ // MetricStatus draws its chip in place of the caption, so a card whose frame shows the
1278
+ // caption hides the chip: it has no chip at all, not an empty one (NODII-DEV-CLI-244).
1279
+ out = rewriteTags(out, "MetricStatus", (attrs) => (/\bcaption=/.test(attrs) ? attrs.replace(/\n?[ \t]*\bchip=\{\{[^{}]*\}\}/, "") : attrs));
1218
1280
  out = rewriteTags(out, String.raw`Metric(?!CardGroup\b)[A-Za-z]*`, (attrs, tag) => {
1219
1281
  const name = new RegExp(String.raw`\b(?:title|label)=(${LITERAL})`).exec(attrs);
1220
1282
  const at = name && nameText(literalText(name[1])) ? nameOf(literalText(name[1])) : scope;
@@ -2021,6 +2083,11 @@ function dataProps(views, propsType) {
2021
2083
  for (const view of views) {
2022
2084
  view.uses = new Set();
2023
2085
  const body = view.body;
2086
+ // The Surface's one loading flag, which its skeleton parts read (passLoading; NODII-DEV-CLI-260).
2087
+ if (LOADING_READ.test(maskStrings(body))) {
2088
+ own("loading", "boolean");
2089
+ view.uses.add("loading");
2090
+ }
2024
2091
  // A lifted list (`{rows.map((row) => (`): its item's reads are the list's members.
2025
2092
  const openers = listOpeners(body);
2026
2093
  for (const o of openers) {
@@ -2136,6 +2203,8 @@ function dataProps(views, propsType) {
2136
2203
  view.uses.add(m[2]);
2137
2204
  }
2138
2205
  }
2206
+ // Every Surface takes loading, so a route passes it alike to each (NODII-DEV-CLI-260).
2207
+ if (!data.has("loading")) own("loading", "boolean");
2139
2208
  for (const d of data.values()) if (d.tabValues) Object.assign(d, { optional: true, raw: `readonly (${union(d.tabValues)})[]` });
2140
2209
  for (const d of data.values()) {
2141
2210
  if (!d.sortKeys) continue;
@@ -2205,6 +2274,56 @@ function drawnRef({ tag, attr, keys, literals, raw }) {
2205
2274
  return `Drawn<${props}, ${keys.size ? [...keys].sort().map((k) => JSON.stringify(k)).join(" | ") : "never"}${lit}>[${JSON.stringify(attr)}]`;
2206
2275
  }
2207
2276
 
2277
+ /**
2278
+ * The DS parts that draw their own loading skeleton, and the prop each takes it
2279
+ * through (MW6-29; NODII-DEV-CLI-260): a part on the DS async contract
2280
+ * (DS-ASYNC-STATES-1, `status`), else its own `loading` or `isLoading`. The
2281
+ * Surface's one `loading` prop reaches each of them in every view, whether or
2282
+ * not its template draws the prop, so a route never hand-builds a loading page.
2283
+ * A part whose loading is a busy control (Button) or a picker's option list
2284
+ * (Combobox, PeopleSelector) is not here: its loading is not the page's. A lifted
2285
+ * Table body takes the Table's own TableSkeletonRows (tableOf).
2286
+ */
2287
+ const LOADING_PARTS = new Map([
2288
+ ["DataTable", "status"],
2289
+ ["Timeline", "status"],
2290
+ ["MetricCard", "status"],
2291
+ ["Chart", "status"],
2292
+ ["ActivityFeedBlock", "status"],
2293
+ ["CommentThreadBlock", "status"],
2294
+ ["TenantPickerCardBlock", "status"],
2295
+ ["PageMetricsBarBlock", "loading"],
2296
+ ["QrDisplay", "loading"],
2297
+ ["DataTableToolbarBlock", "isLoading"],
2298
+ ["ChartWithRange", "isLoading"],
2299
+ ]);
2300
+ const LOADING_ATTR = { status: 'status={loading ? "loading" : undefined}', loading: "loading={loading}", isLoading: "isLoading={loading}" };
2301
+ /** A read of the Surface's loading prop in a view's code (strings masked): never an attribute's name. */
2302
+ const LOADING_READ = /(?<![\w.$-])loading(?![\w$=-])/;
2303
+
2304
+ /**
2305
+ * Pass the Surface's `loading` to every LOADING_PARTS tag in a view's code, as
2306
+ * that tag's first attribute. A tag that already draws the prop (a Loading
2307
+ * variant's literal `isLoading`) keeps what it draws, and one whose attributes
2308
+ * can't be read (a spread) is left as the template gives it.
2309
+ */
2310
+ function passLoading(code) {
2311
+ const masked = maskStrings(code);
2312
+ let out = "";
2313
+ let last = 0;
2314
+ for (const m of masked.matchAll(/<([A-Z][\w.]*)(?=[\s/>])/g)) {
2315
+ const prop = LOADING_PARTS.get(m[1]);
2316
+ if (!prop) continue;
2317
+ const at = m.index + m[0].length;
2318
+ const attrs = tagAttributes(code, at);
2319
+ if (!attrs || attrs.names.includes(prop)) continue;
2320
+ const line = /^\n([ \t]*)/.exec(code.slice(at));
2321
+ out += code.slice(last, at) + (line ? `\n${line[1]}${LOADING_ATTR[prop]}` : ` ${LOADING_ATTR[prop]}`);
2322
+ last = at;
2323
+ }
2324
+ return out + code.slice(last);
2325
+ }
2326
+
2208
2327
  /** The type the generated file declares for drawnProps (see there). */
2209
2328
  const DRAWN_TYPE = [
2210
2329
  "/** A DS component's props, narrowed to the member of their union this call draws: every required prop passed, every literal one fitting. */",
@@ -3252,13 +3371,15 @@ function treeTableOf(node, ctx) {
3252
3371
  };
3253
3372
  const branch = emit(branches[0]);
3254
3373
  const leaf = emit(leaves[0]);
3255
- ctx.imports.push(`import { Table, TableBody, TableHeader, TableRow } from "${module}";`);
3374
+ ctx.imports.push(`import { Table, TableBody, TableHeader, TableRow, ${SKELETON_ROWS} } from "${module}";`);
3256
3375
  ctx.note(ctx.path, LIFTED, "published branch and leaf rows lifted as visible preorder data (hub-492)");
3376
+ // While the Surface loads, the body is the Table's own skeleton rows, as many as Figma draws (NODII-DEV-CLI-260).
3377
+ const skeleton = `<${SKELETON_ROWS} columns={${bodyColumns[0]}} rows={${branches.length + leaves.length}} />`;
3257
3378
  return indent([
3258
3379
  '<Table role="treegrid">',
3259
3380
  ...(heads.length ? [' <TableHeader>', ...heads.map((h) => indent(h, 2)), ' </TableHeader>'] : []),
3260
3381
  ' <TableBody>',
3261
- ` {${rows}.map((row) => (`,
3382
+ ` {loading ? ${skeleton} : ${rows}.map((row) => (`,
3262
3383
  ' row.kind === "branch" ? (', indent(branch, 4),
3263
3384
  ' ) : (', indent(leaf, 4), ' )',
3264
3385
  ' ))}', ' </TableBody>', '</Table>',
@@ -3398,7 +3519,8 @@ function tableOf(node, ctx) {
3398
3519
  ASSEMBLED,
3399
3520
  `${rows.length} row${rows.length === 1 ? "" : "s"} of Table parts${plain ? ` (${plain} of them frame cells only)` : ""} assembled into one DS Table${skeleton ? ` (its ${loadingRows.length} row${loadingRows.length === 1 ? "" : "s"} of loading cells as one ${SKELETON_ROWS})` : ""} (MW8-17.3)`,
3400
3521
  );
3401
- ctx.imports.push(...imports, `import { Table, TableBody, TableCell, TableHeader, TableRow${skeleton ? `, ${SKELETON_ROWS}` : ""} } from "${module}";`);
3522
+ // TableSkeletonRows draws the loading state, drawn or the lifted rows' own; an unused name is dropped.
3523
+ ctx.imports.push(...imports, `import { Table, TableBody, TableCell, TableHeader, TableRow, ${SKELETON_ROWS} } from "${module}";`);
3402
3524
  const { depth } = ctx;
3403
3525
  // A cell the generator wraps has no template to say its density, so it takes the one
3404
3526
  // its row's template cells declare, or the table's: a row is one height in Figma.
@@ -3485,6 +3607,20 @@ function tableOf(node, ctx) {
3485
3607
  // from the drawing. Existing consumers keep the drawn label (hub-507).
3486
3608
  return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (_, open, label) => `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`);
3487
3609
  };
3610
+ // The lifted rows' loading state: as many skeleton rows as Figma draws body rows, each
3611
+ // column as wide as the header's (else the first row's) cell and aligned as its head.
3612
+ const liftedSkeleton = (count) => {
3613
+ const declared = (code) => /\bwidth=(?:\{(\d+)\}|"(\w+)")/.exec(/^[^>]*/.exec(code ?? "")?.[0] ?? "");
3614
+ const props = Array.from({ length: count }, (_, i) => {
3615
+ const cell = headRow?.cells[i] ?? dataRows[0].cells[i];
3616
+ const d = cell?.code ? declared(cell.code) : null;
3617
+ const w = d ? (d[1] ? Number(d[1]) : d[2]) : cell ? columnWidth(cell.cell) : null;
3618
+ const align = headAlign(i);
3619
+ return [w === null ? null : `width: ${JSON.stringify(w)}`, align ? `colAlign: ${JSON.stringify(align)}` : null, tableDensity ? `density: ${JSON.stringify(tableDensity)}` : null].filter(Boolean);
3620
+ });
3621
+ const cellProps = props.some((p) => p.length) ? ` cellProps={[${props.map((p) => (p.length ? `{ ${p.join(", ")} }` : "{}")).join(", ")}]}` : "";
3622
+ return `<${SKELETON_ROWS} columns={${count}} rows={${dataRows.length}}${cellProps} />`;
3623
+ };
3488
3624
  const liftable = !skeleton && dataRows.length > 0 && dataRows.every((p) => !p.unrecognised && !p.framesOnly && p.cells.length === dataRows[0].cells.length) && (!headRow || headRow.cells.length === dataRows[0].cells.length);
3489
3625
  const liftedRows = () => {
3490
3626
  const first = dataRows[0];
@@ -3589,7 +3725,9 @@ function tableOf(node, ctx) {
3589
3725
  ...cells,
3590
3726
  indent("</TableRow>", depth + 3),
3591
3727
  ];
3592
- if (!groupRows.length) return [indent(`{${rowsName}.map((row) => (`, depth + 2), ...dataRow, indent("))}", depth + 2)];
3728
+ // While the Surface loads, the body is the Table's own skeleton rows, never the page's (NODII-DEV-CLI-260).
3729
+ const open = `{loading ? ${liftedSkeleton(keys.length)} : ${rowsName}.map((row) => (`;
3730
+ if (!groupRows.length) return [indent(open, depth + 2), ...dataRow, indent("))}", depth + 2)];
3593
3731
  // The groups are rows of the same list, in drawn order: `{ kind: "group", label }` heads
3594
3732
  // the rows after it, drawn as its band's own head across every column (NODII-DEV-CLI-222).
3595
3733
  let labelKey = "label";
@@ -3600,7 +3738,7 @@ function tableOf(node, ctx) {
3600
3738
  const bandTag = /^<([A-Za-z]+)/.exec(bandCode)[1];
3601
3739
  ctx.note(ctx.path, LIFTED, `${groupRows.length} group band${groupRows.length === 1 ? "" : "s"} lifted with the rows: { kind: "group", ${labelKey} } (NODII-DEV-CLI-222)`);
3602
3740
  return [
3603
- indent(`{${rowsName}.map((row) => (`, depth + 2),
3741
+ indent(open, depth + 2),
3604
3742
  indent('row.kind === "group" ? (', depth + 3),
3605
3743
  indent("<TableRow key={row.id}>", depth + 4),
3606
3744
  indent(`${bandOpen}{row.${labelKey}}</${bandTag}>`, depth + 5),
@@ -3889,8 +4027,15 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3889
4027
  for (const r of results) {
3890
4028
  const out = generatedPath(root, r.row);
3891
4029
  r.file = relative(root, out);
4030
+ r.wrapperFile = null;
3892
4031
  if (f.write) {
3893
4032
  writeFileSync(out, r.code);
4033
+ // The route's wrapper, only where no page is yet (wrapperCode).
4034
+ const page = r.wrapper ? join(root, r.row.sourcePath) : null;
4035
+ if (page && !existsSync(page)) {
4036
+ writeFileSync(page, r.wrapper);
4037
+ r.wrapperFile = relative(root, page);
4038
+ }
3894
4039
  } else if (f.check) {
3895
4040
  const current = existsSync(out) ? readFileSync(out, "utf8") : null;
3896
4041
  if (current !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
@@ -3924,7 +4069,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3924
4069
  const payload = {
3925
4070
  data: {
3926
4071
  mode,
3927
- surfaces: results.map((r) => ({ id: r.row.id, componentSetKey: r.row.componentSetKey, file: r.file, states: r.states, unmapped: counted(r.unmapped).length })),
4072
+ surfaces: results.map((r) => ({ id: r.row.id, componentSetKey: r.row.componentSetKey, file: r.file, wrapper: r.wrapperFile, states: r.states, loadingVariants: r.loadingVariants ?? [], unmapped: counted(r.unmapped).length })),
3928
4073
  differences,
3929
4074
  notGeneratedYet: notYet,
3930
4075
  generatedWithoutCatalogRow: withoutRow,
@@ -3940,9 +4085,12 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3940
4085
  const lines = results.map(
3941
4086
  (r) => `${f.write ? "wrote" : f.check ? (differences.some((d) => d.id === r.row.id) ? "DIFFERS" : "equal") : "generated"}\t${r.file}\t${r.states.length} state${r.states.length === 1 ? "" : "s"}\t${counted(r.unmapped).length} unmapped layer${counted(r.unmapped).length === 1 ? "" : "s"}`,
3942
4087
  );
4088
+ for (const r of results) if (r.wrapperFile) lines.push(`wrote wrapper\t${r.wrapperFile}`);
3943
4089
  if (notYet.length) lines.push(`not generated yet: ${notYet.length} catalog Surface${notYet.length === 1 ? "" : "s"} (no committed tree); generate one with \`nodii-dev surface generate <componentSetKey> --fetch --write\``);
3944
4090
  if (withoutRow.length)
3945
4091
  lines.push(`no catalog row: ${withoutRow.length} generated page${withoutRow.length === 1 ? "" : "s"} not regenerated or compared, because the product-page catalog has no row for ${withoutRow.length === 1 ? "it" : "them"} (MW8-17.1):`, ...withoutRow.map((x) => ` ${x.file}`));
4092
+ const loadingVariants = loadingVariantWarning(results);
4093
+ if (loadingVariants) lines.push(loadingVariants);
3946
4094
  if (unpublished.length) lines.push(`not published: ${unpublished.length} Surface${unpublished.length === 1 ? "" : "s"} skipped, not generated or scored: ${unpublished.map((row) => row.id).join(", ")}`);
3947
4095
  if (f.check && differences.length)
3948
4096
  lines.push(`SURFACE_GEN_DIFFERS: ${differences.length} product page${differences.length === 1 ? " differs" : "s differ"} from the generator's output; run \`nodii-dev surface generate --all --write\` and commit, never hand-edit a generated file`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.194",
3
+ "version": "0.6.196",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {