@nodii/dev 0.6.204 → 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
@@ -1362,6 +1362,14 @@ product-page catalog names the Surface by its published component-set key
1362
1362
  optional, as a lifted table's person cell takes `{ value, model, relation,
1363
1363
  maskHint? }`. The page passes them through as served: the relation keeps a
1364
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.
1365
1373
  - **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
1366
1374
  `<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
1367
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.204";
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 = 57;
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("{/*")) {
@@ -1483,6 +1485,46 @@ export const SAMPLE_VALUE = /₹\s?\d|\b\d{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|A
1483
1485
  const RELATIVE_PERIOD = /^(?:(?:this|last|previous|current|next) (?:day|week|month|quarter|year)|today|yesterday|tomorrow)$/i;
1484
1486
  const RECORD_TEXT = (text) => SAMPLE_VALUE.test(text) || /\d/.test(text) || RELATIVE_PERIOD.test(text.trim());
1485
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
+
1486
1528
  // A named fact or field frame is a label/value pair even when its value has no digits
1487
1529
  // (for example Status / Active). Keep the label and lift only the value.
1488
1530
  function isFactValue(node, parent) {
@@ -2993,7 +3035,7 @@ function emitNode(node, ctx) {
2993
3035
  ]);
2994
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).
2995
3037
  let content = JSON.stringify(node.text);
2996
- 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) {
2997
3039
  const scope = positionScope(node, ctx, "text");
2998
3040
  const name = mark(ctx, scope, scope);
2999
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)`);
@@ -3052,7 +3094,7 @@ function sectionCondition(node, ctx, path) {
3052
3094
  // A head of only text (a title and its subtitle) is not the section: its body sits beside it.
3053
3095
  const [first, ...rest] = (node.children ?? []).filter((c) => c.visible !== false);
3054
3096
  const body = rest.some((c) => c.type !== "TEXT");
3055
- 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;
3056
3098
  const words = m ? (TABLE_ANATOMY.has(m[1].trim().toLowerCase()) ? null : handlerWords(m[2])) : handlerWords(heading);
3057
3099
  if (!words) return null;
3058
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.204",
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": {