@nodii/dev 0.6.201 → 0.6.203
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 +10 -1
- package/dist/cli.js +2 -1
- package/dist/core.js +1 -1
- package/dist/surface.js +46 -7
- package/package.json +1 -1
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`
|
|
@@ -1403,7 +1410,9 @@ product-page catalog names the Surface by its published component-set key
|
|
|
1403
1410
|
only (a loading row) is a body row of that table when it has as many cells as
|
|
1404
1411
|
the rows of Table parts; rows of frames alone are never a table. A row with
|
|
1405
1412
|
any head part is a header row, and a body part in it (a select-all Rich Cell)
|
|
1406
|
-
keeps its own code.
|
|
1413
|
+
keeps its own code. A bare `Checkbox` in a header row, which has no text to
|
|
1414
|
+
name it, takes `aria-label="Select all rows"`, the name the DS gives its own
|
|
1415
|
+
header `TableSelectionCell`; a name the frame gives it stays. What follows the rows (an Empty or Error State, bare, in
|
|
1407
1416
|
its own frame, or as a last row holding one DS instance) follows the Table.
|
|
1408
1417
|
- **A Table's loading state (U07-34.15.3).** The Table cell template emits
|
|
1409
1418
|
`TableSkeletonRows` for `State=Loading`. When every body row is a row of
|
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)
|
|
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.
|
|
7
|
+
export const VERSION = "0.6.203";
|
|
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 =
|
|
37
|
+
export const GENERATOR_FORMAT = 56;
|
|
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";
|
|
@@ -1313,9 +1329,17 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1313
1329
|
if (!ctx.inTable) {
|
|
1314
1330
|
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>`);
|
|
1315
1331
|
}
|
|
1316
|
-
//
|
|
1317
|
-
//
|
|
1318
|
-
|
|
1332
|
+
// Figma's Metric Card preset=status draws its description row as the chip, an exposed Badge
|
|
1333
|
+
// with its own label, and has no caption layer at all: `showCaption` shows or hides that chip,
|
|
1334
|
+
// and the set's `caption` text rides on the instance unseen. MetricStatus draws its chip in
|
|
1335
|
+
// place of the caption too. So a card whose frame shows the row keeps its chip and drops the
|
|
1336
|
+
// caption, and one whose frame hides it (showCaption off) draws neither, never an empty chip
|
|
1337
|
+
// (cli-282; NODII-DEV-CLI-244 had read the hidden caption as the drawn line).
|
|
1338
|
+
out = rewriteTags(out, "MetricStatus", (attrs) => {
|
|
1339
|
+
const chip = /\n?[ \t]*\bchip=\{\{[^{}]*\}\}/;
|
|
1340
|
+
if (node.instance?.props?.showCaption === false) return attrs.replace(chip, "");
|
|
1341
|
+
return chip.test(attrs) ? attrs.replace(/\n?[ \t]*\bcaption=(?:"(?:[^"\\\n]|\\.)*"|\{[^{}]*\})/, "") : attrs;
|
|
1342
|
+
});
|
|
1319
1343
|
out = rewriteTags(out, String.raw`Metric(?!CardGroup\b)[A-Za-z]*`, (attrs, tag) => {
|
|
1320
1344
|
const name = new RegExp(String.raw`\b(?:title|label)=(${LITERAL})`).exec(attrs);
|
|
1321
1345
|
const at = name && nameText(literalText(name[1])) ? nameOf(literalText(name[1])) : scope;
|
|
@@ -1329,6 +1353,9 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1329
1353
|
// the frame's green (NODII-DEV-CLI-239).
|
|
1330
1354
|
const chipTone = /(\bchip=\{\{[^{}]*?\btone:\s*)"(?:[^"\\\n]|\\.)*"/.exec(next);
|
|
1331
1355
|
if (chipTone) next = next.replace(chipTone[0], `${chipTone[1]}${lift(at, "chipTone")}`);
|
|
1356
|
+
// Its label too, named by the card as its tone is, never by its place (`metricCard1ChipLabel`; cli-282).
|
|
1357
|
+
const chipLabel = /(\bchip=\{\{\s*label:\s*)chipLabel\b/.exec(next);
|
|
1358
|
+
if (chipLabel) next = next.replace(chipLabel[0], `${chipLabel[1]}${lift(at, "chipLabel")}`);
|
|
1332
1359
|
if (tag !== "MetricFilterCard") return next;
|
|
1333
1360
|
// A card already lifted (content two slots deep passes through here twice) keeps its
|
|
1334
1361
|
// one selected: a second would fail jsx-no-duplicate-props (tic-page-queues-c, 19 Nov).
|
|
@@ -4124,6 +4151,17 @@ function tableOf(node, ctx) {
|
|
|
4124
4151
|
indent("))}", depth + 2),
|
|
4125
4152
|
];
|
|
4126
4153
|
};
|
|
4154
|
+
// A header's select-all drawn as a bare Checkbox (a Table Rich Cell holding one, where the DS's
|
|
4155
|
+
// header selection cell is TableSelectionCell) has no text beside it to name it, so axe fails
|
|
4156
|
+
// button-name on every list state. It takes the name the DS gives its own header selection
|
|
4157
|
+
// cell, through the Checkbox's own aria-label; a name the frame gives it stays (cli-282).
|
|
4158
|
+
const nameSelectAll = (code) =>
|
|
4159
|
+
/<Checkbox\b/.test(code ?? "")
|
|
4160
|
+
? rewriteTags(code, "Checkbox", (attrs) => {
|
|
4161
|
+
const parsed = tagAttributes(`${attrs}>`, 0);
|
|
4162
|
+
return !parsed || parsed.names.some((name) => name === "aria-label" || name === "aria-labelledby") ? attrs : ` aria-label="Select all rows"${attrs}`;
|
|
4163
|
+
})
|
|
4164
|
+
: code;
|
|
4127
4165
|
const section = (kind, tag) => {
|
|
4128
4166
|
const list = parsed.filter((p) => p.kind === kind || (kind === "body" && p.kind === GROUP));
|
|
4129
4167
|
if (!list.length) return [];
|
|
@@ -4133,7 +4171,7 @@ function tableOf(node, ctx) {
|
|
|
4133
4171
|
? [skeletonRows()]
|
|
4134
4172
|
: kind === "body" && liftable
|
|
4135
4173
|
? liftedRows()
|
|
4136
|
-
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i]) : p.kind === GROUP && columnCount ? cellCode(c, p.row, depth + 3, null).replace(/^(\s*<\w+)(?:\s+width=(?:\{[^}]*\}|"[^"]*"))?/, `$1 colSpan={${columnCount}} scope="colgroup"`) : withAlign(cellCode(c, p.row, depth + 3, null), i))), indent("</TableRow>", depth + 2)]))),
|
|
4174
|
+
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? nameSelectAll(liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i])) : p.kind === GROUP && columnCount ? cellCode(c, p.row, depth + 3, null).replace(/^(\s*<\w+)(?:\s+width=(?:\{[^}]*\}|"[^"]*"))?/, `$1 colSpan={${columnCount}} scope="colgroup"`) : withAlign(cellCode(c, p.row, depth + 3, null), i))), indent("</TableRow>", depth + 2)]))),
|
|
4137
4175
|
indent(`</${tag}>`, depth + 1),
|
|
4138
4176
|
];
|
|
4139
4177
|
};
|
|
@@ -4404,7 +4442,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
4404
4442
|
r.file = relative(root, out);
|
|
4405
4443
|
r.wrapperFile = null;
|
|
4406
4444
|
if (f.write) {
|
|
4407
|
-
writeFileSync(out, r.code);
|
|
4445
|
+
writeFileSync(out, applyGeneratorStamp(r.code));
|
|
4408
4446
|
// The route's wrapper, only where no page is yet (wrapperCode).
|
|
4409
4447
|
const page = r.wrapper ? join(root, r.row.sourcePath) : null;
|
|
4410
4448
|
if (page && !existsSync(page)) {
|
|
@@ -4413,7 +4451,8 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
4413
4451
|
}
|
|
4414
4452
|
} else if (f.check) {
|
|
4415
4453
|
const current = existsSync(out) ? readFileSync(out, "utf8") : null;
|
|
4416
|
-
|
|
4454
|
+
// The stamp names the version that wrote the page; it is no difference in the generator's output.
|
|
4455
|
+
if (current === null || stripGeneratorStamp(current) !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
|
|
4417
4456
|
}
|
|
4418
4457
|
}
|
|
4419
4458
|
|