@nodii/dev 0.6.119 → 0.6.120

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
@@ -945,12 +945,24 @@ product-page catalog names the Surface by its published component-set key
945
945
  any head part is a header row, and a body part in it (a select-all Rich Cell)
946
946
  keeps its own code. What follows the rows (an Empty or Error State, bare, in
947
947
  its own frame, or as a last row holding one DS instance) follows the Table.
948
+ - **A Table's loading state (U07-34.15.3).** The Table cell template emits
949
+ `TableSkeletonRows` for `State=Loading`. When every body row is a row of
950
+ loading cells, as many as the real header has columns, the body becomes one
951
+ `<TableSkeletonRows columns={M} rows={N} cellProps={[…]} />` under the real
952
+ `TableHeader`. Each column's `cellProps` carry its width as the header's column
953
+ carries it (the head template's own `width`, else the head cell's Figma
954
+ sizing), `colAlign: "end"` when the loading cell is right-aligned, and the
955
+ table's density. A row that mixes loading and other cells, a row of loading
956
+ cells beside body rows that are not loading, one with a different number of
957
+ cells than the header, or loading rows with no header row, is marked in the
958
+ code and reported as kind `table`, never guessed.
948
959
  - **Tabs.** The Tab template draws one tab as a whole strip, so two or more
949
960
  sibling Tabs are gathered into one `Tabs panelless` › `TabsList`, values
950
961
  `tab-1`, `tab-2`, …, with the selected tab as `defaultValue`. A lone Tab
951
962
  stays as its template gives it. This rule goes when DESIGN-SYSTEM-271 lands.
952
- - **What isn't recognised stays unmapped.** A Table part outside any table the
953
- generator recognises is reported as kind `table`, never passed off as mapped.
963
+ - **What isn't recognised stays unmapped.** A Table part (a loading cell's
964
+ `TableSkeletonRows` included) outside any table the generator recognises is
965
+ reported as kind `table`, never passed off as mapped.
954
966
  - **Exposed instances and text.** A tree keeps a remote instance's exposed nested
955
967
  instances by layer name, for a template's `findInstance`. Text bound to a DS text
956
968
  style and a DS colour role is listed as kind `bound-text` and doesn't count against
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.119";
7
+ export const VERSION = "0.6.120";
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
@@ -716,7 +716,8 @@ function emitNode(node, ctx) {
716
716
  const code = rendered.code.trim();
717
717
  // A Table part is valid only inside the DS Table. One the generator could not assemble
718
718
  // into a Table stays reported, never passed off as mapped (MW8-17.3).
719
- if (!ctx.inTable && tablePart(/^<([A-Za-z]+)/.exec(code)?.[1])) note(path, "table", `${describe(node)} is a Table part outside any table the generator recognises`);
719
+ const tag = /^<([A-Za-z]+)/.exec(code)?.[1];
720
+ if (!ctx.inTable && (tablePart(tag) || tag === SKELETON_ROWS)) note(path, "table", `${describe(node)} is a Table part outside any table the generator recognises`);
720
721
  if (!sizing.length) return indent(code, depth);
721
722
  // Layout around a DS component is the page's; the component itself takes no className (U07-19).
722
723
  return [indent(`<div className="${cls(["flex", "flex-col", ...sizing])}">`, depth), indent(code, depth + 1), indent("</div>", depth)].join("\n");
@@ -837,6 +838,17 @@ function tabStrip(run, ctx) {
837
838
  * row) becomes a TableCell holding that content. Returns null for anything else.
838
839
  */
839
840
  const tablePart = (tag) => (/^Table[A-Za-z]*Head$/.test(tag ?? "") ? "head" : /^Table[A-Za-z]*Cell$/.test(tag ?? "") ? "body" : null);
841
+ /**
842
+ * What the Table cell template emits for `State=Loading` (U07-34.15.3, DEC-0457):
843
+ * one column of the Table's loading state. A body of them becomes one
844
+ * TableSkeletonRows under the real TableHeader (MW8-17.3), never a Skeleton
845
+ * inside a TableCell (A-065 #3).
846
+ */
847
+ const SKELETON_ROWS = "TableSkeletonRows";
848
+ /** Row kinds while a table is parsed: every cell loading, or loading cells mixed with others. */
849
+ const LOADING = "loading";
850
+ const MIXED = "mixed";
851
+ const isSkeleton = (code) => new RegExp(`^<${SKELETON_ROWS}\\b`).test(code ?? "");
840
852
  /**
841
853
  * A column's width as Figma sizes the cell (DESIGN-SYSTEM-177; the DS
842
854
  * `TableColumnWidth`): px for FIXED, "fill" for FILL, "hug" for HUG. A template
@@ -878,6 +890,11 @@ function tableOf(node, ctx) {
878
890
  if (cell.instance?.remote) {
879
891
  const local = [];
880
892
  const code = emitNode(cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, imports: local, note: () => {} });
893
+ if (isSkeleton(code?.trim())) {
894
+ imports.push(...local);
895
+ cells.push({ cell, code: code.trim(), loading: true });
896
+ continue;
897
+ }
881
898
  const part = tablePart(/^<([A-Za-z]+)/.exec(code ?? "")?.[1]);
882
899
  // A cell that is no Table part (a component with no template, or a DS part drawn
883
900
  // in a row) is held in a TableCell: one such cell must not undo the whole table.
@@ -894,6 +911,13 @@ function tableOf(node, ctx) {
894
911
  } else if (cell.layout || cell.type === "TEXT") cells.push({ cell, code: null });
895
912
  else return null;
896
913
  }
914
+ // A row of loading cells is one body row of the Table's loading state; a row that
915
+ // mixes loading cells with others is no row the generator recognises (checked below).
916
+ const loading = cells.filter((c) => c.loading).length;
917
+ if (loading) {
918
+ parsed.push({ row, kind: loading === cells.length && kind !== "head" ? LOADING : MIXED, cells, spanning: false, inHeader: kind === "head" });
919
+ continue;
920
+ }
897
921
  // A row with no Table part (a loading row of frame cells) is a body row only beside
898
922
  // rows of Table parts, and only with as many cells as they have; checked below.
899
923
  const spanning = !kind && cells.length === 1 && cells[0].held;
@@ -917,9 +941,39 @@ function tableOf(node, ctx) {
917
941
  }
918
942
  const module = imports.map((s) => /\{[^}]*\bTable[A-Za-z]*(Cell|Head)\b[^}]*\}\s+from\s+["']([^"']+)["']/.exec(s)?.[2]).find(Boolean);
919
943
  if (!module) return null;
944
+ // The loading state: every body row a row of loading cells, as many as the real header
945
+ // has columns, becomes one TableSkeletonRows (U07-34.15.3). Any other row of loading
946
+ // cells (mixed with other cells, beside rows that are not loading, or not spanning the
947
+ // header) is reported and marked, never guessed (MW8-17.3).
948
+ const headRow = parsed.filter((p) => p.kind === "head").at(-1) ?? null;
949
+ const loadingRows = parsed.filter((p) => p.kind === LOADING);
950
+ const bodyRows = parsed.filter((p) => p.kind !== "head");
951
+ // The column count is the real header's: with no header row there is none to take.
952
+ const columnCount = headRow?.cells.length ?? 0;
953
+ const skeleton = headRow !== null && loadingRows.length > 0 && loadingRows.length === bodyRows.length && loadingRows.every((p) => p.cells.length === columnCount);
954
+ for (const p of parsed) {
955
+ if (p.kind !== MIXED && (p.kind !== LOADING || skeleton)) continue;
956
+ const loadingCells = p.cells.filter((c) => c.loading).length;
957
+ const why =
958
+ p.kind === MIXED
959
+ ? `row ${JSON.stringify(p.row.name)} mixes ${loadingCells} loading Table cell${loadingCells === 1 ? "" : "s"} with ${p.cells.length - loadingCells} other${p.cells.length - loadingCells === 1 ? "" : "s"}`
960
+ : !headRow
961
+ ? `row ${JSON.stringify(p.row.name)} of loading Table cells has no header row to take its columns from`
962
+ : p.cells.length !== columnCount
963
+ ? `row ${JSON.stringify(p.row.name)} has ${p.cells.length} loading Table cells under a header of ${columnCount} columns`
964
+ : `row ${JSON.stringify(p.row.name)} of loading Table cells sits beside body rows that are not loading`;
965
+ ctx.note(`${ctx.path} › ${p.row.name}`, "table", `${why}: no Table loading state the generator recognises (U07-34.15.3, MW8-17.3)`);
966
+ p.unrecognised = `unmapped: ${why}`;
967
+ if (p.kind === MIXED) p.kind = p.inHeader ? "head" : "body";
968
+ }
969
+ for (const p of parsed) if (p.kind === LOADING) p.kind = "body";
920
970
  const plain = parsed.length - partRows.length;
921
- ctx.note(ctx.path, ASSEMBLED, `${rows.length} row${rows.length === 1 ? "" : "s"} of Table parts${plain ? ` (${plain} of them frame cells only)` : ""} assembled into one DS Table (MW8-17.3)`);
922
- ctx.imports.push(...imports, `import { Table, TableBody, TableHeader, TableRow } from "${module}";`);
971
+ ctx.note(
972
+ ctx.path,
973
+ ASSEMBLED,
974
+ `${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)`,
975
+ );
976
+ ctx.imports.push(...imports, `import { Table, TableBody, TableHeader, TableRow${skeleton ? `, ${SKELETON_ROWS}` : ""} } from "${module}";`);
923
977
  const { depth } = ctx;
924
978
  // A cell the generator wraps has no template to say its density, so it takes the one
925
979
  // its row's template cells declare, or the table's: a row is one height in Figma.
@@ -946,12 +1000,28 @@ function tableOf(node, ctx) {
946
1000
  // Every column held at px or fill is a fixed table layout; a hug column needs the browser's auto layout.
947
1001
  const widths = parsed.flatMap((p) => p.cells.map((c) => columnWidth(c.cell)));
948
1002
  const fixed = widths.length > 0 && widths.every((w) => w !== null && w !== "hug");
1003
+ // Each column's width as the header's column carries it (the head template's own
1004
+ // `width`, else the head cell's sizing); its alignment as the loading cell draws it.
1005
+ const skeletonRows = () => {
1006
+ const declared = (code) => /\bwidth=(?:\{(\d+)\}|"(\w+)")/.exec(/^[^>]*/.exec(code ?? "")?.[0] ?? "");
1007
+ const props = Array.from({ length: columnCount }, (_, i) => {
1008
+ const head = headRow.cells[i];
1009
+ const d = head?.code ? declared(head.code) : null;
1010
+ const w = d ? (d[1] ? Number(d[1]) : d[2]) : columnWidth(head.cell);
1011
+ const end = loadingRows.some((p) => /\bcolAlign:\s*"end"/.test(p.cells[i].code));
1012
+ return [w === null ? null : `width: ${JSON.stringify(w)}`, end ? 'colAlign: "end"' : null, tableDensity ? `density: ${JSON.stringify(tableDensity)}` : null].filter(Boolean);
1013
+ });
1014
+ const cellProps = props.some((p) => p.length) ? ` cellProps={[${props.map((p) => (p.length ? `{ ${p.join(", ")} }` : "{}")).join(", ")}]}` : "";
1015
+ return indent(`<${SKELETON_ROWS} columns={${columnCount}} rows={${loadingRows.length}}${cellProps} />`, depth + 2);
1016
+ };
949
1017
  const section = (kind, tag) => {
950
1018
  const list = parsed.filter((p) => p.kind === kind);
951
1019
  if (!list.length) return [];
952
1020
  return [
953
1021
  indent(`<${tag}>`, depth + 1),
954
- ...list.flatMap((p) => [indent("<TableRow>", depth + 2), ...p.cells.map((c) => cellCode(c, p.row, depth + 3)), indent("</TableRow>", depth + 2)]),
1022
+ ...(kind === "body" && skeleton
1023
+ ? [skeletonRows()]
1024
+ : list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c) => cellCode(c, p.row, depth + 3)), indent("</TableRow>", depth + 2)]))),
955
1025
  indent(`</${tag}>`, depth + 1),
956
1026
  ];
957
1027
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.119",
3
+ "version": "0.6.120",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {