@nodii/dev 0.6.203 → 0.6.205

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
@@ -1355,6 +1355,21 @@ product-page catalog names the Surface by its published component-set key
1355
1355
  whole, `value={loading ? <Skeleton shape="text" /> : <PiiText value={emailValue} … />}`,
1356
1356
  so PiiText's `value` stays `string | null`. A value that reads nothing (fixed
1357
1357
  copy) is left as it is.
1358
+ - **A person in a fact row is the served pair (DESIGN-SYSTEM-993).** A PiiText in
1359
+ a fact row's value slot (a Description List's `value`, a Right Pane / Row's or
1360
+ a Detail Section / Row's `valueSlot`) takes `value`, `model` and `relation`
1361
+ from its template and also the server's `maskHint` and `disposition`, both
1362
+ optional, as a lifted table's person cell takes `{ value, model, relation,
1363
+ maskHint? }`. The page passes them through as served: the relation keeps a
1364
+ self value revealed, and the generator never sets a mask (P-10).
1365
+ - **A record page's title and body are its data (NODII-DEV-CLI-293).** On a
1366
+ page whose route ends in a record (`/app/me/forum/policies/$id`, or a tab of it
1367
+ with `?tab=`; with no route, a set named `… .$id …`), the first title-sized
1368
+ loose heading (heading/lg and up) directly in the page's content frame, and
1369
+ the body-sized paragraphs (body/md, body/lg) directly after it up to the next
1370
+ heading, are lifted into props whatever Figma's sample says. Section headings
1371
+ (heading/sm, heading/md), labels, captions (body/sm) and text inside a card,
1372
+ a row or a DS part are kept as before.
1358
1373
  - **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
1359
1374
  `<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
1360
1375
  `state` with only the props its view reads (`{ state: "read-error" } &
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.203";
7
+ export const VERSION = "0.6.205";
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 = 56;
37
+ export const GENERATOR_FORMAT = 58;
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
@@ -696,7 +696,9 @@ export function emitSurface(tree, row, ds) {
696
696
  used.add(state);
697
697
  const fn = `${pascal(state)}View`;
698
698
  const note = (path, kind, detail) => unmapped.push({ variant: variant.name, path, kind, detail });
699
- const emitted = emitNode(pageBody(variant, row), { depth: 2, parent: null, path: variant.name, row, ds, imports, note, root: true, scopes, layers, layer: "", state, lists: new Map(), shapes, handlers: new Map(), shown: new Map(), optionals, items, factTexts }) ?? "";
699
+ const page = pageBody(variant, row);
700
+ const recordTexts = recordPageTexts(page, row, tree.componentSetName);
701
+ const emitted = emitNode(page, { depth: 2, parent: null, path: variant.name, row, ds, imports, note, root: true, scopes, layers, layer: "", state, lists: new Map(), shapes, handlers: new Map(), shown: new Map(), optionals, items, factTexts, recordTexts }) ?? "";
700
702
  // A view the generator can't lay out is no page at all: generation fails rather than ship
701
703
  // an empty view (NODII-DEV-CLI-81).
702
704
  if (emitted.trimStart().startsWith("{/*")) {
@@ -1183,6 +1185,13 @@ const literalText = (lit) => JSON.parse(lit.startsWith("{") ? lit.slice(1, -1) :
1183
1185
  * A run of sibling DescriptionLists and a table's body rows are lifted as lists
1184
1186
  * (liftedDescriptionList, tableOf). Real copy (headings, labels, buttons) stays.
1185
1187
  */
1188
+ /**
1189
+ * The fact rows whose value is a slot, by Figma set, and that slot: a PiiText there takes the
1190
+ * server's `maskHint` and `disposition` as optional props (DESIGN-SYSTEM-993). A Detail Section /
1191
+ * Row's facts are its exposed Detail Section / Fact parts, read through the Row's own slots.
1192
+ */
1193
+ const FACT_VALUE_SLOTS = new Map([["Description List", "value"], ["Right Pane / Row", "valueSlot"], ["Detail Section / Row", "valueSlot"]]);
1194
+ const FACT_PII_PROPS = ["maskHint", "disposition"];
1186
1195
  function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1187
1196
  const lifted = [];
1188
1197
  const lift = (at, name) => (lifted.push(name), mark(ctx, at, name));
@@ -1418,7 +1427,23 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1418
1427
  });
1419
1428
  out = rewriteTags(out, "PiiText", (attrs) => {
1420
1429
  const hint = new RegExp(String.raw`\bmaskHint=${LITERAL}`).exec(attrs);
1421
- return hint ? attrs.replace(hint[0], `maskHint={${lift(scope, "maskHint")}}`) : attrs;
1430
+ // A person in a fact row's value is the served pair, as a table's person cell is: the page
1431
+ // passes the server's hint and disposition with its value, model and relation, so a
1432
+ // colleague HR withholds reads HR's hint, not "Restricted". Both are optional, the hint
1433
+ // too where Figma drew one (the server may send none), and the relation still decides
1434
+ // self, so nothing here can force a mask (P-10; DESIGN-SYSTEM-993).
1435
+ const hintProp = () => (ctx.factValue ? (lifted.push("maskHint"), optionalMark(ctx, scope, "maskHint")) : lift(scope, "maskHint"));
1436
+ let next = hint ? attrs.replace(hint[0], `maskHint={${hintProp()}}`) : attrs;
1437
+ if (ctx.factValue) {
1438
+ for (const prop of FACT_PII_PROPS) {
1439
+ if (new RegExp(String.raw`\b${prop}=`).test(next)) continue;
1440
+ lifted.push(prop);
1441
+ const attr = ` ${prop}={${optionalMark(ctx, scope, prop)}}`;
1442
+ const after = topLevelAttr(next, prop === "disposition" ? "maskHint" : "relation") ?? topLevelAttr(next, "relation");
1443
+ next = after ? `${next.slice(0, after.to)}${attr}${next.slice(after.to)}` : next.replace(/(\s*\/?\s*)$/, `${attr}$1`);
1444
+ }
1445
+ }
1446
+ return next;
1422
1447
  });
1423
1448
  // A title or label that dates or counts a record ("Headcount over time · 27 May 2026 to
1424
1449
  // 25 Aug 2026", "Q3 2026 Performance Review", "Pay events 2027") is the record's; fixed copy
@@ -1460,6 +1485,46 @@ export const SAMPLE_VALUE = /₹\s?\d|\b\d{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|A
1460
1485
  const RELATIVE_PERIOD = /^(?:(?:this|last|previous|current|next) (?:day|week|month|quarter|year)|today|yesterday|tomorrow)$/i;
1461
1486
  const RECORD_TEXT = (text) => SAMPLE_VALUE.test(text) || /\d/.test(text) || RELATIVE_PERIOD.test(text.trim());
1462
1487
 
1488
+ /**
1489
+ * A record page's own title and body (NODII-DEV-CLI-293): on a page whose route
1490
+ * ends in a record (`/app/me/forum/policies/$id`, a tab of it with `?tab=`), the
1491
+ * page's title is the record's name and the paragraph under it the record's
1492
+ * text, whatever Figma's sample says ("Remote work policy" has no figure, so
1493
+ * RECORD_TEXT alone kept it as copy). Only loose text directly in the page's
1494
+ * content frame counts: its first title-sized heading (heading/lg and up) and
1495
+ * the body-sized paragraphs (body/md, body/lg) after it, up to the next heading.
1496
+ * A section's own heading (heading/sm, heading/md), a label, a caption
1497
+ * (body/sm) and any text inside a card, a row or a DS part stay as they are.
1498
+ * The set of those TEXT nodes, empty on any other Surface.
1499
+ */
1500
+ const RECORD_ROUTE = /\/\$[A-Za-z_]\w*\/?(?:[?#]|$)/;
1501
+ const RECORD_SET = /\.\$[A-Za-z_]\w*(?:\.[A-Za-z][\w-]*)?\s*(?:·|$)/;
1502
+ const TITLE_STYLE = /\b(?:heading|title|display)\/(?:lg|\d*xl)\b/i;
1503
+ const BODY_STYLE = /\bbody\/(?:md|lg)\b/i;
1504
+ export function isRecordPage(row, setName) {
1505
+ if (row?.surfaceType && row.surfaceType !== "page") return false;
1506
+ if (row?.frontendRoute) return RECORD_ROUTE.test(row.frontendRoute);
1507
+ return [row?.componentSetName, setName].some((name) => RECORD_SET.test(name ?? ""));
1508
+ }
1509
+ export function recordPageTexts(body, row, setName) {
1510
+ const found = new Set();
1511
+ if (!body || !isRecordPage(row, setName)) return found;
1512
+ const shown = (n) => (n.children ?? []).filter((c) => c.visible !== false);
1513
+ // The page's content frame: through any lone wrapper frame ("Page") under mainContent.
1514
+ let page = body;
1515
+ for (let kids = shown(page); kids.length === 1 && kids[0].type === "FRAME" && !kids[0].instance; kids = shown(page)) page = kids[0];
1516
+ const kids = shown(page);
1517
+ const at = kids.findIndex((c) => c.type === "TEXT" && TITLE_STYLE.test(c.textStyle ?? "") && /[A-Za-z0-9]/.test(c.text ?? ""));
1518
+ if (at === -1) return found;
1519
+ found.add(kids[at]);
1520
+ for (const c of kids.slice(at + 1)) {
1521
+ if (c.type !== "TEXT") continue;
1522
+ if (HEADING_STYLE.test(c.textStyle ?? "")) break;
1523
+ if (BODY_STYLE.test(c.textStyle ?? "") && /[A-Za-z0-9]/.test(c.text ?? "")) found.add(c);
1524
+ }
1525
+ return found;
1526
+ }
1527
+
1463
1528
  // A named fact or field frame is a label/value pair even when its value has no digits
1464
1529
  // (for example Status / Active). Keep the label and lift only the value.
1465
1530
  function isFactValue(node, parent) {
@@ -2842,7 +2907,8 @@ function emitNode(node, ctx) {
2842
2907
  return comment(`unmapped: slot ${JSON.stringify(prop)} has no auto layout`);
2843
2908
  }
2844
2909
  const textOwner = TEXT_PROPERTY_PARTS.has(node.instance.set) ? node.instance.set : ctx.textOwner;
2845
- const slotCtx = { ...ctx, depth: 0, parent: slotNode, grand: null, path: `${path} › ${prop}`, root: false, textOwner, slotOwner: owner, inTable: false, inSlot: true, chain: slotNode ? [...chain, slotNode] : chain, layer: `${ctx.layer}${nestedPath.map(part => ` › ${part}`).join("")} › ${prop}` };
2910
+ const factValue = FACT_VALUE_SLOTS.get(node.instance.set) === prop;
2911
+ const slotCtx = { ...ctx, depth: 0, parent: slotNode, grand: null, path: `${path} › ${prop}`, root: false, textOwner, slotOwner: owner, factValue, inTable: false, inSlot: true, chain: slotNode ? [...chain, slotNode] : chain, layer: `${ctx.layer}${nestedPath.map(part => ` › ${part}`).join("")} › ${prop}` };
2846
2912
  const inner = emitChildren(slotNode?.children ?? [], (c) => emitNode(c, slotCtx), slotCtx);
2847
2913
  return inner.length === 0 ? "<></>" : inner.length === 1 ? inner[0] : `<>\n${inner.map((x) => indent(x, 1)).join("\n")}\n</>`;
2848
2914
  };
@@ -2969,7 +3035,7 @@ function emitNode(node, ctx) {
2969
3035
  ]);
2970
3036
  // Text naming a record's value (a date, an amount, a code) is Figma's sample: the page's own (NODII-DEV-CLI-82).
2971
3037
  let content = JSON.stringify(node.text);
2972
- if ((RECORD_TEXT(node.text) || isFactValue(node, parent)) && !ctx.textOwner) {
3038
+ if ((RECORD_TEXT(node.text) || isFactValue(node, parent) || ctx.recordTexts?.has(node)) && !ctx.textOwner) {
2973
3039
  const scope = positionScope(node, ctx, "text");
2974
3040
  const name = mark(ctx, scope, scope);
2975
3041
  note(path, LIFTED, `text ${shown} names a record's value: lifted from Figma's sample into the page's props (NODII-DEV-CLI-82)`);
@@ -3028,7 +3094,7 @@ function sectionCondition(node, ctx, path) {
3028
3094
  // A head of only text (a title and its subtitle) is not the section: its body sits beside it.
3029
3095
  const [first, ...rest] = (node.children ?? []).filter((c) => c.visible !== false);
3030
3096
  const body = rest.some((c) => c.type !== "TEXT");
3031
- const heading = body && first?.type === "TEXT" && HEADING_STYLE.test(first.textStyle ?? "") && !RECORD_TEXT(first.text ?? "") ? first.text : null;
3097
+ const heading = body && first?.type === "TEXT" && HEADING_STYLE.test(first.textStyle ?? "") && !RECORD_TEXT(first.text ?? "") && !ctx.recordTexts?.has(first) ? first.text : null;
3032
3098
  const words = m ? (TABLE_ANATOMY.has(m[1].trim().toLowerCase()) ? null : handlerWords(m[2])) : handlerWords(heading);
3033
3099
  if (!words) return null;
3034
3100
  const { scope, name } = handlerScope(node, { ...ctx, handlers: ctx.shown }, path, null, words, 0);
@@ -30,7 +30,7 @@
30
30
  // it until it returns [] (each round can reveal instances inside slot
31
31
  // content).
32
32
 
33
- export const VERSION = "1.0.16";
33
+ export const VERSION = "1.0.18";
34
34
 
35
35
  /** @typedef {{ nodeId: string, check: string, detail: string }} Finding */
36
36
  /**
@@ -167,6 +167,12 @@ const SELF_COMPONENT_SET_KEYS = new Set([
167
167
  "8499452873bccfe5d2f29b5322fc1ca18cb103cc", // Profile Name Card
168
168
  "6c1e074dcf69aee388e0300584da09735e314cc3", // Delete Account Card
169
169
  ]);
170
+ // The published Editable Fields block (by key). On a self route's Surface
171
+ // (Surface / home.me.* or me.*) its rows edit the viewer's own record, so
172
+ // the viewer's email and phone there are revealed (P-10; NODII-DEV-CLI-215).
173
+ const EDITABLE_FIELDS_COMPONENT_SET_KEY =
174
+ "454c48893f60d6d55fe783a1c16d0001d3ae859b";
175
+ const SELF_SURFACE = /^Surface \/ (home\.)?me[.!@ ]/;
170
176
  const NOT_A_PERSON = /^(you|the team)$/i;
171
177
  const MASKED = /[*•●]/;
172
178
  const EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
@@ -1013,7 +1019,18 @@ export function checkConformance({
1013
1019
  const chain = (stop === -1 ? up : up.slice(0, stop + 1)).filter(
1014
1020
  (x) => x.type === "INSTANCE",
1015
1021
  );
1016
- if (!chain.some((inst) => matchesRole(a, inst, role, library)))
1022
+ // The role's own component is the role, not a drawing of it: the
1023
+ // label of a Decision Button variant is the Decision Button's own
1024
+ // (drift ccac666c, operator, 21 Nov; PLANNING-HUB-623).
1025
+ const ownComponent = up.some(
1026
+ (x) =>
1027
+ (x.type === "COMPONENT_SET" || x.type === "COMPONENT") &&
1028
+ (x.name === role.componentName || x.id === role.nodeId),
1029
+ );
1030
+ if (
1031
+ !ownComponent &&
1032
+ !chain.some((inst) => matchesRole(a, inst, role, library))
1033
+ )
1017
1034
  push(
1018
1035
  findings,
1019
1036
  holder.id,
@@ -1445,6 +1462,17 @@ function isSelf(a, n) {
1445
1462
  if (selfField(a, n) || markedYou(a, n)) return true;
1446
1463
  if (up.some((x) => SELF_COMPONENT_SET_KEYS.has(drawnSet(a, x)?.key)))
1447
1464
  return true;
1465
+ if (
1466
+ up.some(
1467
+ (x) => drawnSet(a, x)?.key === EDITABLE_FIELDS_COMPONENT_SET_KEY,
1468
+ ) &&
1469
+ up.some((x) =>
1470
+ SELF_SURFACE.test(
1471
+ x.type === "COMPONENT_SET" ? x.name ?? "" : drawnSet(a, x)?.name ?? "",
1472
+ ),
1473
+ )
1474
+ )
1475
+ return true;
1448
1476
 
1449
1477
  // INTERIM: identify a Table row from its direct Table-cell children, or a
1450
1478
  // list row from its Item instance. Switch to the published Table Row key
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.203",
3
+ "version": "0.6.205",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {