@nodii/dev 0.6.200 → 0.6.202

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,13 @@ 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
+ Each page it writes carries the version stamp `// Generator: @nodii/dev X`
1319
+ (the running CLI's version) on line 4, after the `// Surface:` line, exactly
1320
+ as design-system's `surface-gen.mjs stamp --version X` writes it, so no
1321
+ separate stamp step is needed (NODII-DEV-CLI-276). A page already stamped is
1322
+ rewritten with one stamp, the running version's. Only the written file is
1323
+ stamped: print mode, the corpus gate and a stamped version's replay see the
1324
+ generator's output, and `--check` ignores the stamp line.
1318
1325
  - **Loading flows down (NODII-DEV-CLI-260, MW6-29).** Every Surface takes an
1319
1326
  optional `loading?: boolean`, and every view passes it to each DS part that
1320
1327
  draws its own skeleton, whether or not its template draws the prop: `status`
@@ -1342,7 +1349,12 @@ product-page catalog names the Surface by its published component-set key
1342
1349
  Item hidden while its value is missing still draws while loading
1343
1350
  (`{(loading || fromValue != null) && (…)}`). Each value keeps the type of the
1344
1351
  part that draws it. `Skeleton` is imported from the module the page's DS parts
1345
- come from; a view with no fact is unchanged.
1352
+ come from; a view with no fact is unchanged. The skeleton only takes the
1353
+ fact's own ReactNode `value`, never a typed prop of a DS part inside it
1354
+ (hub-642): a value that is a DS part reading the page's data is replaced
1355
+ whole, `value={loading ? <Skeleton shape="text" /> : <PiiText value={emailValue} … />}`,
1356
+ so PiiText's `value` stays `string | null`. A value that reads nothing (fixed
1357
+ copy) is left as it is.
1346
1358
  - **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
1347
1359
  `<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
1348
1360
  `state` with only the props its view reads (`{ state: "read-error" } &
package/dist/cli.js CHANGED
@@ -217,7 +217,8 @@ Usage: nodii-dev <command> [options] [--json]
217
217
  # a Surface -> its product page's presentational code, from Code Connect
218
218
  # (MW8-17), in a design-system checkout. --fetch reads Figma (FIGMA_PAT, one
219
219
  # call per 8 s); --write writes <page>.surface.generated.tsx (and, with --fetch,
220
- # the committed tree); --check refuses a difference (the surface-gen-equal gate);
220
+ # the committed tree), stamped "// Generator: @nodii/dev X" on line 4;
221
+ # --check refuses a difference (the surface-gen-equal gate; the stamp is none);
221
222
  # --report writes the unmapped layers per file (U08-14), .md or .json;
222
223
  # --all --fetch skips and reports a Surface that is not published;
223
224
  # --post-scoreboard comments the per-module scoreboard on the issue;
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.200";
7
+ export const VERSION = "0.6.202";
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 = 54;
37
+ export const GENERATOR_FORMAT = 55;
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
@@ -48,6 +48,22 @@ export const GENERATED_PAGE_GLOB = `packages/blocks/src/product-pages/**/*${GENE
48
48
  const PAGE_STAMP = /^\/\/ GENERATED by `nodii-dev surface generate` [^\n]*\n\/\/ regenerate with [^\n]*\n\/\/ Surface: [^\n]+ · Figma file \S+ @ version \S+ · format \d+\n/;
49
49
  /** True when a product page's text opens with the stamp `surface generate` writes (the header below). */
50
50
  export const hasGeneratedPageStamp = (text) => PAGE_STAMP.test(text);
51
+ /**
52
+ * The version stamp `--write` puts on every page it writes (NODII-DEV-CLI-276), byte-for-byte
53
+ * design-system's `infra/code-connect/surface-gen.mjs` (its STAMP_RE, stripStamp, applyStamp):
54
+ * the line after `// Surface:`, naming the running @nodii/dev. Only the written file carries it;
55
+ * the generator's output (print mode, the corpus gate, a stamped version's replay) never does.
56
+ */
57
+ const GENERATOR_STAMP = /^\/\/ Generator: @nodii\/dev (\d+\.\d+\.\d+)\r?\n/m;
58
+ /** The page without its stamp line: what the generator emitted. */
59
+ export const stripGeneratorStamp = (text) => text.replace(GENERATOR_STAMP, "");
60
+ /** The page stamped with `version`, replacing any stamp it had, so a page carries one. */
61
+ export function applyGeneratorStamp(text, version = VERSION) {
62
+ const lines = stripGeneratorStamp(text).split("\n");
63
+ const at = lines.findIndex((line) => line.startsWith("// Surface:"));
64
+ lines.splice(at === -1 ? 1 : at + 1, 0, `// Generator: @nodii/dev ${version}`);
65
+ return lines.join("\n");
66
+ }
51
67
  const CATALOG_PATH = "packages/blocks/src/product-pages/catalog.ts";
52
68
  const DS_FILE_META = "infra/figma/figma-file.json";
53
69
  const ONE_TO_ONE_SNAPSHOT = "docs/figma-ux-ds/figma/1to1/figma-file.snapshot.json";
@@ -2440,10 +2456,24 @@ function passLoading(code) {
2440
2456
  * draws its skeleton while loading. Run after the props are typed, so each value keeps
2441
2457
  * the type of the part that draws it. Skeleton comes from the DS module the page's DS
2442
2458
  * parts come from; a page with no such import is left as it is.
2459
+ *
2460
+ * The skeleton only ever takes a ReactNode slot: the fact part's own top-level `value`
2461
+ * (or a pair's value span). A fact whose value is a DS part reading the page's data
2462
+ * (`value={<PiiText value={emailValue} … />}`) draws the skeleton in place of that whole
2463
+ * part, never inside one of its typed props, so PiiText's `value` stays `string | null`
2464
+ * (hub-642). A value that is fixed copy, or any other expression, is left as it is.
2443
2465
  */
2444
2466
  const FACT_SKELETON = '<Skeleton shape="text" />';
2445
2467
  const FACT_PARTS = /<(?:DescriptionItem|DetailFact|RightPaneRow)(?=[\s/>])/g;
2446
- const FACT_VALUE = /(\svalue=\{)([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\}/;
2468
+ const FACT_READ = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
2469
+ /** One JSX element (self-closing, or closed by its own tag) that reads the page's data: `{ident}` somewhere in it. */
2470
+ const factElement = (expr) => {
2471
+ const tag = /^<([A-Z][\w.]*)(?=[\s/>])/.exec(expr)?.[1];
2472
+ if (!tag) return false;
2473
+ const end = openTagEnd(expr);
2474
+ const whole = expr[end - 1] === "/" ? end === expr.length - 1 : expr.endsWith(`</${tag}>`) && expr.indexOf(`<${tag}`, 1) === -1;
2475
+ return whole && /\{[A-Za-z_$][\w$.]*\}/.test(expr);
2476
+ };
2447
2477
  const SKELETON_HOST = /\b(?:DescriptionItem|DescriptionList|DetailFact|DetailSection|Card|Badge|PiiText|Tabs|Field|Alert|EmptyState|Button|TableCell|TableHead)\b/;
2448
2478
  const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2449
2479
  function skeletonFacts(views, imports, factTexts) {
@@ -2457,14 +2487,20 @@ function skeletonFacts(views, imports, factTexts) {
2457
2487
  const masked = maskStrings(body);
2458
2488
  const edits = [];
2459
2489
  for (const m of masked.matchAll(FACT_PARTS)) {
2460
- const open = masked.slice(m.index, m.index + openTagEnd(masked.slice(m.index)) + 1);
2461
- const value = FACT_VALUE.exec(open);
2462
- if (value) edits.push({ at: m.index + value.index + value[1].length, read: value[2] });
2490
+ const at = m.index + m[0].length;
2491
+ const open = masked.slice(at, m.index + openTagEnd(masked.slice(m.index)) + 1);
2492
+ // The part's own value, never a `value` inside a DS part it draws (hub-642).
2493
+ const value = topLevelAttr(open, "value");
2494
+ if (!value) continue;
2495
+ const from = at + value.from + "value={".length;
2496
+ const expr = body.slice(from, at + value.to - 1);
2497
+ if (FACT_READ.test(expr)) edits.push({ at: from, read: expr });
2498
+ else if (factElement(expr)) edits.push({ at: from, read: null });
2463
2499
  }
2464
2500
  const gated = new Set();
2465
2501
  for (const { at, read } of edits.reverse()) {
2466
2502
  body = `${body.slice(0, at)}loading ? ${FACT_SKELETON} : ${body.slice(at)}`;
2467
- if (!read.includes(".")) gated.add(read);
2503
+ if (read && !read.includes(".")) gated.add(read);
2468
2504
  }
2469
2505
  for (const read of gated) body = body.replace(new RegExp(String.raw`\{${escapeRegExp(read)} != null && \(`, "g"), `{(loading || ${read} != null) && (`);
2470
2506
  for (const name of factTexts) body = body.replace(new RegExp(String.raw`(<span\b[^>\n]*>)\{${escapeRegExp(name)}\}(</span>)`, "g"), `$1{loading ? ${FACT_SKELETON} : ${name}}$2`);
@@ -4384,7 +4420,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
4384
4420
  r.file = relative(root, out);
4385
4421
  r.wrapperFile = null;
4386
4422
  if (f.write) {
4387
- writeFileSync(out, r.code);
4423
+ writeFileSync(out, applyGeneratorStamp(r.code));
4388
4424
  // The route's wrapper, only where no page is yet (wrapperCode).
4389
4425
  const page = r.wrapper ? join(root, r.row.sourcePath) : null;
4390
4426
  if (page && !existsSync(page)) {
@@ -4393,7 +4429,8 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
4393
4429
  }
4394
4430
  } else if (f.check) {
4395
4431
  const current = existsSync(out) ? readFileSync(out, "utf8") : null;
4396
- if (current !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
4432
+ // The stamp names the version that wrote the page; it is no difference in the generator's output.
4433
+ if (current === null || stripGeneratorStamp(current) !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
4397
4434
  }
4398
4435
  }
4399
4436
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.200",
3
+ "version": "0.6.202",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {