@nodii/dev 0.6.194 → 0.6.195

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.195";
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 = 48;
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;
@@ -2021,6 +2080,11 @@ function dataProps(views, propsType) {
2021
2080
  for (const view of views) {
2022
2081
  view.uses = new Set();
2023
2082
  const body = view.body;
2083
+ // The Surface's one loading flag, which its skeleton parts read (passLoading; NODII-DEV-CLI-260).
2084
+ if (LOADING_READ.test(maskStrings(body))) {
2085
+ own("loading", "boolean");
2086
+ view.uses.add("loading");
2087
+ }
2024
2088
  // A lifted list (`{rows.map((row) => (`): its item's reads are the list's members.
2025
2089
  const openers = listOpeners(body);
2026
2090
  for (const o of openers) {
@@ -2136,6 +2200,8 @@ function dataProps(views, propsType) {
2136
2200
  view.uses.add(m[2]);
2137
2201
  }
2138
2202
  }
2203
+ // Every Surface takes loading, so a route passes it alike to each (NODII-DEV-CLI-260).
2204
+ if (!data.has("loading")) own("loading", "boolean");
2139
2205
  for (const d of data.values()) if (d.tabValues) Object.assign(d, { optional: true, raw: `readonly (${union(d.tabValues)})[]` });
2140
2206
  for (const d of data.values()) {
2141
2207
  if (!d.sortKeys) continue;
@@ -2205,6 +2271,56 @@ function drawnRef({ tag, attr, keys, literals, raw }) {
2205
2271
  return `Drawn<${props}, ${keys.size ? [...keys].sort().map((k) => JSON.stringify(k)).join(" | ") : "never"}${lit}>[${JSON.stringify(attr)}]`;
2206
2272
  }
2207
2273
 
2274
+ /**
2275
+ * The DS parts that draw their own loading skeleton, and the prop each takes it
2276
+ * through (MW6-29; NODII-DEV-CLI-260): a part on the DS async contract
2277
+ * (DS-ASYNC-STATES-1, `status`), else its own `loading` or `isLoading`. The
2278
+ * Surface's one `loading` prop reaches each of them in every view, whether or
2279
+ * not its template draws the prop, so a route never hand-builds a loading page.
2280
+ * A part whose loading is a busy control (Button) or a picker's option list
2281
+ * (Combobox, PeopleSelector) is not here: its loading is not the page's. A lifted
2282
+ * Table body takes the Table's own TableSkeletonRows (tableOf).
2283
+ */
2284
+ const LOADING_PARTS = new Map([
2285
+ ["DataTable", "status"],
2286
+ ["Timeline", "status"],
2287
+ ["MetricCard", "status"],
2288
+ ["Chart", "status"],
2289
+ ["ActivityFeedBlock", "status"],
2290
+ ["CommentThreadBlock", "status"],
2291
+ ["TenantPickerCardBlock", "status"],
2292
+ ["PageMetricsBarBlock", "loading"],
2293
+ ["QrDisplay", "loading"],
2294
+ ["DataTableToolbarBlock", "isLoading"],
2295
+ ["ChartWithRange", "isLoading"],
2296
+ ]);
2297
+ const LOADING_ATTR = { status: 'status={loading ? "loading" : undefined}', loading: "loading={loading}", isLoading: "isLoading={loading}" };
2298
+ /** A read of the Surface's loading prop in a view's code (strings masked): never an attribute's name. */
2299
+ const LOADING_READ = /(?<![\w.$-])loading(?![\w$=-])/;
2300
+
2301
+ /**
2302
+ * Pass the Surface's `loading` to every LOADING_PARTS tag in a view's code, as
2303
+ * that tag's first attribute. A tag that already draws the prop (a Loading
2304
+ * variant's literal `isLoading`) keeps what it draws, and one whose attributes
2305
+ * can't be read (a spread) is left as the template gives it.
2306
+ */
2307
+ function passLoading(code) {
2308
+ const masked = maskStrings(code);
2309
+ let out = "";
2310
+ let last = 0;
2311
+ for (const m of masked.matchAll(/<([A-Z][\w.]*)(?=[\s/>])/g)) {
2312
+ const prop = LOADING_PARTS.get(m[1]);
2313
+ if (!prop) continue;
2314
+ const at = m.index + m[0].length;
2315
+ const attrs = tagAttributes(code, at);
2316
+ if (!attrs || attrs.names.includes(prop)) continue;
2317
+ const line = /^\n([ \t]*)/.exec(code.slice(at));
2318
+ out += code.slice(last, at) + (line ? `\n${line[1]}${LOADING_ATTR[prop]}` : ` ${LOADING_ATTR[prop]}`);
2319
+ last = at;
2320
+ }
2321
+ return out + code.slice(last);
2322
+ }
2323
+
2208
2324
  /** The type the generated file declares for drawnProps (see there). */
2209
2325
  const DRAWN_TYPE = [
2210
2326
  "/** 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 +3368,15 @@ function treeTableOf(node, ctx) {
3252
3368
  };
3253
3369
  const branch = emit(branches[0]);
3254
3370
  const leaf = emit(leaves[0]);
3255
- ctx.imports.push(`import { Table, TableBody, TableHeader, TableRow } from "${module}";`);
3371
+ ctx.imports.push(`import { Table, TableBody, TableHeader, TableRow, ${SKELETON_ROWS} } from "${module}";`);
3256
3372
  ctx.note(ctx.path, LIFTED, "published branch and leaf rows lifted as visible preorder data (hub-492)");
3373
+ // While the Surface loads, the body is the Table's own skeleton rows, as many as Figma draws (NODII-DEV-CLI-260).
3374
+ const skeleton = `<${SKELETON_ROWS} columns={${bodyColumns[0]}} rows={${branches.length + leaves.length}} />`;
3257
3375
  return indent([
3258
3376
  '<Table role="treegrid">',
3259
3377
  ...(heads.length ? [' <TableHeader>', ...heads.map((h) => indent(h, 2)), ' </TableHeader>'] : []),
3260
3378
  ' <TableBody>',
3261
- ` {${rows}.map((row) => (`,
3379
+ ` {loading ? ${skeleton} : ${rows}.map((row) => (`,
3262
3380
  ' row.kind === "branch" ? (', indent(branch, 4),
3263
3381
  ' ) : (', indent(leaf, 4), ' )',
3264
3382
  ' ))}', ' </TableBody>', '</Table>',
@@ -3398,7 +3516,8 @@ function tableOf(node, ctx) {
3398
3516
  ASSEMBLED,
3399
3517
  `${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
3518
  );
3401
- ctx.imports.push(...imports, `import { Table, TableBody, TableCell, TableHeader, TableRow${skeleton ? `, ${SKELETON_ROWS}` : ""} } from "${module}";`);
3519
+ // TableSkeletonRows draws the loading state, drawn or the lifted rows' own; an unused name is dropped.
3520
+ ctx.imports.push(...imports, `import { Table, TableBody, TableCell, TableHeader, TableRow, ${SKELETON_ROWS} } from "${module}";`);
3402
3521
  const { depth } = ctx;
3403
3522
  // A cell the generator wraps has no template to say its density, so it takes the one
3404
3523
  // its row's template cells declare, or the table's: a row is one height in Figma.
@@ -3485,6 +3604,20 @@ function tableOf(node, ctx) {
3485
3604
  // from the drawing. Existing consumers keep the drawn label (hub-507).
3486
3605
  return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (_, open, label) => `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`);
3487
3606
  };
3607
+ // The lifted rows' loading state: as many skeleton rows as Figma draws body rows, each
3608
+ // column as wide as the header's (else the first row's) cell and aligned as its head.
3609
+ const liftedSkeleton = (count) => {
3610
+ const declared = (code) => /\bwidth=(?:\{(\d+)\}|"(\w+)")/.exec(/^[^>]*/.exec(code ?? "")?.[0] ?? "");
3611
+ const props = Array.from({ length: count }, (_, i) => {
3612
+ const cell = headRow?.cells[i] ?? dataRows[0].cells[i];
3613
+ const d = cell?.code ? declared(cell.code) : null;
3614
+ const w = d ? (d[1] ? Number(d[1]) : d[2]) : cell ? columnWidth(cell.cell) : null;
3615
+ const align = headAlign(i);
3616
+ return [w === null ? null : `width: ${JSON.stringify(w)}`, align ? `colAlign: ${JSON.stringify(align)}` : null, tableDensity ? `density: ${JSON.stringify(tableDensity)}` : null].filter(Boolean);
3617
+ });
3618
+ const cellProps = props.some((p) => p.length) ? ` cellProps={[${props.map((p) => (p.length ? `{ ${p.join(", ")} }` : "{}")).join(", ")}]}` : "";
3619
+ return `<${SKELETON_ROWS} columns={${count}} rows={${dataRows.length}}${cellProps} />`;
3620
+ };
3488
3621
  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
3622
  const liftedRows = () => {
3490
3623
  const first = dataRows[0];
@@ -3589,7 +3722,9 @@ function tableOf(node, ctx) {
3589
3722
  ...cells,
3590
3723
  indent("</TableRow>", depth + 3),
3591
3724
  ];
3592
- if (!groupRows.length) return [indent(`{${rowsName}.map((row) => (`, depth + 2), ...dataRow, indent("))}", depth + 2)];
3725
+ // While the Surface loads, the body is the Table's own skeleton rows, never the page's (NODII-DEV-CLI-260).
3726
+ const open = `{loading ? ${liftedSkeleton(keys.length)} : ${rowsName}.map((row) => (`;
3727
+ if (!groupRows.length) return [indent(open, depth + 2), ...dataRow, indent("))}", depth + 2)];
3593
3728
  // The groups are rows of the same list, in drawn order: `{ kind: "group", label }` heads
3594
3729
  // the rows after it, drawn as its band's own head across every column (NODII-DEV-CLI-222).
3595
3730
  let labelKey = "label";
@@ -3600,7 +3735,7 @@ function tableOf(node, ctx) {
3600
3735
  const bandTag = /^<([A-Za-z]+)/.exec(bandCode)[1];
3601
3736
  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
3737
  return [
3603
- indent(`{${rowsName}.map((row) => (`, depth + 2),
3738
+ indent(open, depth + 2),
3604
3739
  indent('row.kind === "group" ? (', depth + 3),
3605
3740
  indent("<TableRow key={row.id}>", depth + 4),
3606
3741
  indent(`${bandOpen}{row.${labelKey}}</${bandTag}>`, depth + 5),
@@ -3889,8 +4024,15 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3889
4024
  for (const r of results) {
3890
4025
  const out = generatedPath(root, r.row);
3891
4026
  r.file = relative(root, out);
4027
+ r.wrapperFile = null;
3892
4028
  if (f.write) {
3893
4029
  writeFileSync(out, r.code);
4030
+ // The route's wrapper, only where no page is yet (wrapperCode).
4031
+ const page = r.wrapper ? join(root, r.row.sourcePath) : null;
4032
+ if (page && !existsSync(page)) {
4033
+ writeFileSync(page, r.wrapper);
4034
+ r.wrapperFile = relative(root, page);
4035
+ }
3894
4036
  } else if (f.check) {
3895
4037
  const current = existsSync(out) ? readFileSync(out, "utf8") : null;
3896
4038
  if (current !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
@@ -3924,7 +4066,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3924
4066
  const payload = {
3925
4067
  data: {
3926
4068
  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 })),
4069
+ 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
4070
  differences,
3929
4071
  notGeneratedYet: notYet,
3930
4072
  generatedWithoutCatalogRow: withoutRow,
@@ -3940,9 +4082,12 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3940
4082
  const lines = results.map(
3941
4083
  (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
4084
  );
4085
+ for (const r of results) if (r.wrapperFile) lines.push(`wrote wrapper\t${r.wrapperFile}`);
3943
4086
  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
4087
  if (withoutRow.length)
3945
4088
  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}`));
4089
+ const loadingVariants = loadingVariantWarning(results);
4090
+ if (loadingVariants) lines.push(loadingVariants);
3946
4091
  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
4092
  if (f.check && differences.length)
3948
4093
  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.195",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {