@nodii/dev 0.6.91 → 0.6.92

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
@@ -925,6 +925,14 @@ product-page catalog names the Surface by its published component-set key
925
925
  so a stopped or killed run keeps its reads. Add `--resume` to carry on: it keeps
926
926
  a saved tree and reads only the rest. With `--figma-version V`, it keeps only
927
927
  trees read at `V`.
928
+ - **Table assembly.** A table drawn as frames goes in the DS `Table`'s anatomy. A
929
+ cell that is no Table part is held in a `TableCell`, and a wrapped cell takes its
930
+ row's density.
931
+ - **Exposed instances and text.** A tree keeps a remote instance's exposed nested
932
+ instances by layer name, for a template's `findInstance`. Text bound to a DS text
933
+ style and a DS colour role is listed as kind `bound-text` and doesn't count against
934
+ a Surface being clean. Text missing either binding is unmapped, and so is text in a
935
+ part that should own it as a property.
928
936
  - **Scoreboard.** Every run returns `data.scoreboard`, one row per module, and
929
937
  `--all` also prints it: Surfaces clean out of total, not published, not
930
938
  generated yet, and unmapped layers by kind. A Surface is clean when it has no
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.91";
7
+ export const VERSION = "0.6.92";
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
@@ -31,7 +31,7 @@ import { CliError, VERSION, devRequest, readConfig } from "./core.js";
31
31
  import { createRenderer } from "./vendor/render-templates.mjs";
32
32
 
33
33
  /** Bumped whenever the emitted code changes shape for the same inputs. */
34
- export const GENERATOR_FORMAT = 5;
34
+ export const GENERATOR_FORMAT = 6;
35
35
  export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
36
36
  export const GENERATED_SUFFIX = ".surface.generated.tsx";
37
37
  const CATALOG_PATH = "packages/blocks/src/product-pages/catalog.ts";
@@ -255,17 +255,32 @@ export function trimTree(entry, { row, version }) {
255
255
 
256
256
  if (node.type === "INSTANCE") {
257
257
  const main = components[node.componentId] ?? {};
258
+ const propsOf = (instance) =>
259
+ Object.fromEntries(
260
+ Object.entries(instance.componentProperties ?? {})
261
+ .filter(([, p]) => p.type !== "SLOT")
262
+ .map(([name, p]) => [stripPropId(name), p.type === "INSTANCE_SWAP" ? { swap: keyOf(p.value) } : p.value]),
263
+ );
258
264
  out.instance = {
259
265
  key: main.key ?? null,
260
266
  component: main.name ?? null,
261
267
  set: sets[main.componentSetId]?.name ?? null,
262
268
  remote: Boolean(main.remote),
263
- props: Object.fromEntries(
264
- Object.entries(node.componentProperties ?? {})
265
- .filter(([, p]) => p.type !== "SLOT")
266
- .map(([name, p]) => [stripPropId(name), p.type === "INSTANCE_SWAP" ? { swap: keyOf(p.value) } : p.value]),
267
- ),
269
+ props: propsOf(node),
268
270
  };
271
+ // An exposed nested instance is set on the Surface, and only a template's
272
+ // findInstance can read it, so its properties are kept by layer name.
273
+ if (main.remote && node.exposedInstances?.length) {
274
+ const exposed = {};
275
+ const walk = (parent) => {
276
+ for (const child of parent.children ?? []) {
277
+ if (child.isExposedInstance && !exposed[child.name]) exposed[child.name] = { key: keyOf(child.componentId), props: propsOf(child) };
278
+ walk(child);
279
+ }
280
+ };
281
+ walk(node);
282
+ if (Object.keys(exposed).length) out.instance.exposed = exposed;
283
+ }
269
284
  // A library instance is the template's to draw: only its slots' content is the Surface's.
270
285
  const children = main.remote ? (node.children ?? []).filter((c) => c.type === "SLOT") : (node.children ?? []);
271
286
  if (children.length) out.children = children.map((c) => trim(c, box));
@@ -389,7 +404,9 @@ export function emitSurface(tree, row, ds) {
389
404
  used.add(state);
390
405
  const fn = `${pascal(state)}View`;
391
406
  const note = (path, kind, detail) => unmapped.push({ variant: variant.name, path, kind, detail });
392
- const body = emitNode(variant.root, { depth: 2, parent: null, path: variant.name, ds, imports, note, root: true });
407
+ const emitted = emitNode(variant.root, { depth: 2, parent: null, path: variant.name, ds, imports, note, root: true }) ?? "";
408
+ // A refused root is only a comment, and `return ({/* … */})` is an object, not JSX.
409
+ const body = emitted.trimStart().startsWith("{/*") ? [" <>", indent(emitted.trim(), 3), " </>"].join("\n") : emitted;
393
410
  return { state, fn, body };
394
411
  });
395
412
  const component = `${pascal(row.id)}Surface`;
@@ -572,6 +589,12 @@ function colour(prefix, paint, scope, ds, report) {
572
589
  return null;
573
590
  }
574
591
 
592
+ /** Text with both DS bindings: listed, but not counted against a Surface being clean. */
593
+ const BOUND_TEXT = "bound-text";
594
+ const counted = (unmapped) => unmapped.filter((u) => u.kind !== BOUND_TEXT);
595
+
596
+ /** DS parts whose text should be a component property, not slot content (the Q-211 Lock-Change). */
597
+ const TEXT_PROPERTY_PARTS = new Set(["Table cell", "Table Header", "File Viewer"]);
575
598
  const SHAPES = new Set(["RECTANGLE", "ELLIPSE", "LINE", "VECTOR", "BOOLEAN_OPERATION", "STAR", "REGULAR_POLYGON"]);
576
599
  const cls = (list) => [...new Set(list.filter(Boolean))].join(" ");
577
600
  const describe = (node) => (node.instance ? `${node.instance.set ?? node.instance.component ?? "component"}${node.instance.set ? ` [${node.instance.component}]` : ""}` : node.type);
@@ -587,8 +610,13 @@ function emitNode(node, ctx) {
587
610
  // A DS library instance: exactly what its Code Connect template emits for this instance's properties.
588
611
  if (node.instance?.remote) {
589
612
  const dsNode = node.instance.key ? ds.byKey.get(node.instance.key) : null;
590
- const values = Object.fromEntries(
591
- Object.entries(node.instance.props).map(([name, value]) => [name, value && typeof value === "object" && "swap" in value ? (ds.byKey.get(value.swap) ?? value.swap) : value]),
613
+ const valuesOf = (props) =>
614
+ Object.fromEntries(Object.entries(props).map(([name, value]) => [name, value && typeof value === "object" && "swap" in value ? (ds.byKey.get(value.swap) ?? value.swap) : value]));
615
+ const values = valuesOf(node.instance.props);
616
+ const nested = Object.fromEntries(
617
+ Object.entries(node.instance.exposed ?? {})
618
+ .filter(([, e]) => ds.byKey.has(e.key))
619
+ .map(([layer, e]) => [layer, { nodeId: ds.byKey.get(e.key), values: valuesOf(e.props) }]),
592
620
  );
593
621
  const slotContent = (prop) => {
594
622
  const slotNode = (node.children ?? []).find((c) => c.type === "SLOT" && c.slot === prop);
@@ -596,10 +624,11 @@ function emitNode(node, ctx) {
596
624
  note(`${path} › ${prop}`, "layout", `slot ${prop} has no auto layout`);
597
625
  return comment(`unmapped: slot ${JSON.stringify(prop)} has no auto layout`);
598
626
  }
599
- const inner = (slotNode?.children ?? []).map((c) => emitNode(c, { ...ctx, depth: 0, parent: slotNode, path: `${path} › ${prop}`, root: false })).filter((x) => x !== null);
627
+ const textOwner = TEXT_PROPERTY_PARTS.has(node.instance.set) ? node.instance.set : ctx.textOwner;
628
+ const inner = (slotNode?.children ?? []).map((c) => emitNode(c, { ...ctx, depth: 0, parent: slotNode, path: `${path} › ${prop}`, root: false, textOwner })).filter((x) => x !== null);
600
629
  return inner.length === 0 ? "<></>" : inner.length === 1 ? inner[0] : `<>\n${inner.map((x) => indent(x, 1)).join("\n")}\n</>`;
601
630
  };
602
- const rendered = dsNode ? ds.renderer.renderInstance(ds.dsFileKey, dsNode, values, { slot: slotContent }) : null;
631
+ const rendered = dsNode ? ds.renderer.renderInstance(ds.dsFileKey, dsNode, values, { slot: slotContent, nested }) : null;
603
632
  if (!rendered || rendered.error || !rendered.code?.trim()) {
604
633
  const why = !dsNode ? "not a published DS library component" : !rendered ? "no Code Connect template" : rendered.error ? `template error: ${rendered.error}` : "the template emits no code";
605
634
  note(path, "instance", `${describe(node)}: ${why}`);
@@ -615,11 +644,19 @@ function emitNode(node, ctx) {
615
644
 
616
645
  if (node.type === "TEXT") {
617
646
  const utility = textUtility(node.textStyle, ds.textStyles);
618
- note(path, "text", `loose text ${JSON.stringify(node.text.length > 60 ? `${node.text.slice(0, 57)}…` : node.text)}${utility ? "" : ` (style ${node.textStyle ?? "none"} has no DS text utility)`}`);
647
+ const role = node.color ? colour("text", node.color, "TEXT_FILL", ds, report) : null;
648
+ // Text bound to a DS text style and a DS colour role is still listed, as its own kind
649
+ // (U08-14), but doesn't count against "clean": its code is that utility and that role,
650
+ // the same "clean" as Dev's Surfaces check. Text missing a binding is unmapped, and so
651
+ // is text that should be a property of the part holding it.
652
+ const shown = JSON.stringify(node.text.length > 60 ? `${node.text.slice(0, 57)}…` : node.text);
653
+ if (ctx.textOwner) note(path, "text", `text ${shown} in a ${ctx.textOwner} slot: it should be a property of ${ctx.textOwner} (DS blocker)`);
654
+ else if (!utility || !role) note(path, "text", `loose text ${shown}${utility ? "" : ` (style ${node.textStyle ?? "none"} has no DS text utility)`}${role ? "" : " (no DS colour role)"}`);
655
+ else note(path, BOUND_TEXT, `text ${shown} bound to ${node.textStyle} and ${role}, with no Code Connect mapping`);
619
656
  const classes = cls([
620
657
  ...sizeClasses(node, parent, false).filter((c) => !c.startsWith("h-")),
621
658
  utility,
622
- node.color ? colour("text", node.color, "TEXT_FILL", ds, report) : null,
659
+ role,
623
660
  { CENTER: "text-center", RIGHT: "text-right", JUSTIFIED: "text-justify" }[node.align],
624
661
  node.maxLines === 1 ? "truncate" : node.maxLines ? `line-clamp-${node.maxLines}` : null,
625
662
  ]);
@@ -698,7 +735,14 @@ function tableOf(node, ctx) {
698
735
  const local = [];
699
736
  const code = emitNode(cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, imports: local, note: () => {} });
700
737
  const part = tablePart(/^<([A-Za-z]+)/.exec(code ?? "")?.[1]);
701
- if (!part || (kind && kind !== part)) return null;
738
+ // A cell that is no Table part (a component with no template, or a DS part drawn
739
+ // in a row) is held in a TableCell: one such cell must not undo the whole table.
740
+ if (!part) {
741
+ imports.push(...local);
742
+ cells.push({ cell, code, held: true });
743
+ continue;
744
+ }
745
+ if (kind && kind !== part) return null;
702
746
  kind = part;
703
747
  imports.push(...local);
704
748
  cells.push({ cell, code });
@@ -713,15 +757,27 @@ function tableOf(node, ctx) {
713
757
  ctx.note(ctx.path, "table", `table drawn as frames (${rows.length} row${rows.length === 1 ? "" : "s"}); assembled into the DS Table's parts`);
714
758
  ctx.imports.push(...imports, `import { Table, TableBody, TableHeader, TableRow } from "${module}";`);
715
759
  const { depth } = ctx;
716
- const cellCode = ({ cell, code }, row, d) => {
760
+ // A cell the generator wraps has no template to say its density, so it takes the one
761
+ // its row's template cells declare, or the table's: a row is one height in Figma.
762
+ const declaredDensity = (cells) => cells.map((c) => (c.held ? null : /\bdensity="(\w+)"/.exec(c.code ?? "")?.[1])).find(Boolean);
763
+ const tableDensity = declaredDensity(parsed.flatMap((p) => p.cells));
764
+ const wrapperAttrs = (w, row) => {
765
+ const density = declaredDensity(parsed.find((p) => p.row === row)?.cells ?? []) ?? tableDensity;
766
+ return `${widthAttr(w)}${density ? ` density="${density}"` : ""}`;
767
+ };
768
+ const cellCode = ({ cell, code, held }, row, d) => {
717
769
  const w = columnWidth(cell);
770
+ if (held) {
771
+ const inner = emitNode(cell, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true });
772
+ return [indent(`<TableCell${wrapperAttrs(w, row)}>`, d), inner, indent("</TableCell>", d)].join("\n");
773
+ }
718
774
  if (code) {
719
775
  // Re-emit for real, so the cell's own unmapped layers are reported.
720
776
  return withWidth(emitNode(cell, { ...ctx, depth: d, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true }), w);
721
777
  }
722
778
  // The frame stood in for the cell: its size and padding are the TableCell's now.
723
779
  const inner = emitNode({ ...cell, sizing: ["HUG", "HUG"], x: undefined, fills: undefined, strokes: undefined, radius: undefined, ...(cell.layout ? { layout: { ...cell.layout, padding: [0, 0, 0, 0] } } : {}) }, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false });
724
- return [indent(`<TableCell${widthAttr(w)}>`, d), inner, indent("</TableCell>", d)].join("\n");
780
+ return [indent(`<TableCell${wrapperAttrs(w, row)}>`, d), inner, indent("</TableCell>", d)].join("\n");
725
781
  };
726
782
  // Every column held at px or fill is a fixed table layout; a hug column needs the browser's auto layout.
727
783
  const widths = parsed.flatMap((p) => p.cells.map((c) => columnWidth(c.cell)));
@@ -776,7 +832,7 @@ export function unmappedMarkdown(files) {
776
832
  const lines = [
777
833
  "# Surface layers with no Code Connect mapping (U08-14)",
778
834
  "",
779
- "Generated by `nodii-dev surface generate --report`. Kinds: `instance` (a library instance the generator cannot emit through a template), `text` (loose text, drawn with the DS type utility and colour role), `frame` (a frame that paints its own fill, stroke, radius or effect: only its layout is generated), `table` (a table drawn as frames, assembled into the DS Table's parts), `layout` (a frame or slot with no auto layout), `shape` (a rectangle, ellipse or vector: marked, not drawn), `token` (a text colour that matches no colour v2 role: left out).",
835
+ "Generated by `nodii-dev surface generate --report`. Kinds: `instance` (a library instance the generator cannot emit through a template), `text` (text missing a DS text style or colour role, or text in a part that should own it as a property), `frame` (a frame that paints its own fill, stroke, radius or effect: only its layout is generated), `table` (a table drawn as frames, assembled into the DS Table's parts), `layout` (a frame or slot with no auto layout), `shape` (a rectangle, ellipse or vector: marked, not drawn), `token` (a text colour that matches no colour v2 role: left out), `bound-text` (text bound to a DS text style and colour role, with no Code Connect mapping: listed, not counted against a Surface being clean).",
780
836
  "",
781
837
  ];
782
838
  for (const [fileKey, file] of Object.entries(files)) {
@@ -802,7 +858,7 @@ export function surfaceScoreboard(selected, results, { unpublished = [], notGene
802
858
  const modules = new Map();
803
859
  const of = (row) => {
804
860
  const name = moduleOf(row);
805
- if (!modules.has(name)) modules.set(name, { module: name, total: 0, clean: 0, unmapped: 0, byKind: {}, unpublished: [], notGeneratedYet: [] });
861
+ if (!modules.has(name)) modules.set(name, { module: name, total: 0, clean: 0, unmapped: 0, boundText: 0, byKind: {}, unpublished: [], notGeneratedYet: [] });
806
862
  return modules.get(name);
807
863
  };
808
864
  for (const row of selected) of(row).total += 1;
@@ -810,9 +866,11 @@ export function surfaceScoreboard(selected, results, { unpublished = [], notGene
810
866
  for (const row of notGeneratedYet) of(row).notGeneratedYet.push(row.id);
811
867
  for (const r of results) {
812
868
  const entry = of(r.row);
813
- if (!r.unmapped.length) entry.clean += 1;
814
- entry.unmapped += r.unmapped.length;
815
- for (const u of r.unmapped) entry.byKind[u.kind] = (entry.byKind[u.kind] ?? 0) + 1;
869
+ const real = counted(r.unmapped);
870
+ if (!real.length) entry.clean += 1;
871
+ entry.unmapped += real.length;
872
+ entry.boundText += r.unmapped.length - real.length;
873
+ for (const u of real) entry.byKind[u.kind] = (entry.byKind[u.kind] ?? 0) + 1;
816
874
  }
817
875
  return [...modules.values()];
818
876
  }
@@ -836,7 +894,7 @@ export function scoreboardMarkdown(board, { mode, source, stopped = null }) {
836
894
  `**Surface scoreboard** (\`surface generate\`, ${mode} run, \`@nodii/dev\` ${VERSION}, ${source}).`,
837
895
  "",
838
896
  ...(stopped ? [`**Partial: Figma answered 429 at \`${stopped.at}\`, so the run stopped with ${stopped.notRead.length} Surface${stopped.notRead.length === 1 ? "" : "s"} not read.** They count as not generated yet.`, ""] : []),
839
- "A Surface is clean when it has no unmapped layer. Total counts every selected Surface, including those not published or not generated yet.",
897
+ "A Surface is clean when it has no unmapped layer. Text bound to a DS text style and colour role is listed in the report, and is not counted here. Total counts every selected Surface, including those not published or not generated yet.",
840
898
  "",
841
899
  "| Module | Clean / total | Not published | Not generated yet | Unmapped | By kind |",
842
900
  "|---|---:|---:|---:|---:|---|",
@@ -981,7 +1039,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
981
1039
  const payload = {
982
1040
  data: {
983
1041
  mode,
984
- surfaces: results.map((r) => ({ id: r.row.id, componentSetKey: r.row.componentSetKey, file: r.file, states: r.states, unmapped: r.unmapped.length })),
1042
+ surfaces: results.map((r) => ({ id: r.row.id, componentSetKey: r.row.componentSetKey, file: r.file, states: r.states, unmapped: counted(r.unmapped).length })),
985
1043
  differences,
986
1044
  notGeneratedYet: notYet,
987
1045
  unpublished: unpublished.map((row) => ({ id: row.id, componentSetKey: row.componentSetKey, fileKey: row.fileKey })),
@@ -994,7 +1052,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
994
1052
  const human = () => {
995
1053
  if (!f.write && !f.check && !f.all && results.length === 1) return results[0].code;
996
1054
  const lines = results.map(
997
- (r) => `${f.write ? "wrote" : f.check ? (differences.some((d) => d.id === r.row.id) ? "DIFFERS" : "equal") : "generated"}\t${r.file}\t${r.states.length} state${r.states.length === 1 ? "" : "s"}\t${r.unmapped.length} unmapped layer${r.unmapped.length === 1 ? "" : "s"}`,
1055
+ (r) => `${f.write ? "wrote" : f.check ? (differences.some((d) => d.id === r.row.id) ? "DIFFERS" : "equal") : "generated"}\t${r.file}\t${r.states.length} state${r.states.length === 1 ? "" : "s"}\t${counted(r.unmapped).length} unmapped layer${counted(r.unmapped).length === 1 ? "" : "s"}`,
998
1056
  );
999
1057
  if (notYet.length) lines.push(`not generated yet: ${notYet.length} catalog Surface${notYet.length === 1 ? "" : "s"} (no committed tree); generate one with \`nodii-dev surface generate <componentSetKey> --fetch --write\``);
1000
1058
  if (unpublished.length) lines.push(`not published: ${unpublished.length} Surface${unpublished.length === 1 ? "" : "s"} skipped, not generated or scored: ${unpublished.map((row) => row.id).join(", ")}`);
@@ -279,7 +279,7 @@ export function createRenderer(root, docs, options = {}) {
279
279
  return props;
280
280
  }
281
281
 
282
- function makeInstance(context, setNode, props, depth, label, reads = null) {
282
+ function makeInstance(context, setNode, props, depth, label, reads = null, exposed = null) {
283
283
  const need = (name, type) => {
284
284
  reads?.add(name);
285
285
  const prop = props.get(name);
@@ -328,6 +328,17 @@ export function createRenderer(root, docs, options = {}) {
328
328
  return slot;
329
329
  },
330
330
  getPropertyValue: (name) => need(name).value,
331
+ // The snapshot holds component properties, not the layer tree, so a
332
+ // layer lookup answers as Figma does for a layer it cannot find: an
333
+ // error handle. Templates that read exposed nested instances
334
+ // (DEC-0432) fall back to their placeholders here, unless the caller
335
+ // has the instance's exposed layers (renderInstance's `nested`).
336
+ findInstance: (layerName) =>
337
+ exposed?.(layerName) ?? { type: "ERROR", layerName },
338
+ findText: (layerName) => ({ type: "ERROR", layerName }),
339
+ findConnectedInstance: (layerName) => ({ type: "ERROR", layerName }),
340
+ findConnectedInstances: () => [],
341
+ findLayers: () => [],
331
342
  hasCodeConnect: () => true,
332
343
  codeConnectId: () => null,
333
344
  };
@@ -591,7 +602,7 @@ export function createRenderer(root, docs, options = {}) {
591
602
  * instances this way. Returns { code, imports } | { error } | null (no
592
603
  * template maps the component).
593
604
  */
594
- function renderInstance(fileKey, nodeId, values = {}, { slot } = {}) {
605
+ function renderInstance(fileKey, nodeId, values = {}, { slot, nested } = {}) {
595
606
  const context = contexts.get(fileKey);
596
607
  const found = context ? docForComponent(context, nodeId) : null;
597
608
  if (!found?.node) return null;
@@ -600,6 +611,37 @@ export function createRenderer(root, docs, options = {}) {
600
611
  ? context.byId.get(found.node.parentId)
601
612
  : found.node;
602
613
  const label = `${setNode.name} instance`;
614
+ // `nested` is this instance's exposed layers, { layerName: { nodeId, values } }.
615
+ const exposed = (layerName) => {
616
+ const entry = nested?.[layerName];
617
+ const target = entry ? docForComponent(context, entry.nodeId) : null;
618
+ if (!target?.node) return null;
619
+ const targetSet =
620
+ target.node.parentType === "COMPONENT_SET"
621
+ ? context.byId.get(target.node.parentId)
622
+ : target.node;
623
+ const handle = makeInstance(
624
+ context,
625
+ targetSet,
626
+ propsFor(targetSet, target.node, entry.values),
627
+ 1,
628
+ `${label} > ${layerName}`
629
+ );
630
+ return {
631
+ ...handle,
632
+ executeTemplate: () => {
633
+ const result = runTemplate(target.doc, handle);
634
+ return {
635
+ example: result.example.sections.map((section, index) =>
636
+ index === 0
637
+ ? { ...section, nestedImports: result.imports ?? [] }
638
+ : section
639
+ ),
640
+ metadata: result.metadata,
641
+ };
642
+ },
643
+ };
644
+ };
603
645
  try {
604
646
  const result = runTemplate(
605
647
  found.doc,
@@ -608,7 +650,9 @@ export function createRenderer(root, docs, options = {}) {
608
650
  setNode,
609
651
  propsFor(setNode, found.node, values),
610
652
  0,
611
- label
653
+ label,
654
+ null,
655
+ exposed
612
656
  )
613
657
  );
614
658
  const imports = new Set(result.imports ?? []);
@@ -736,5 +780,51 @@ export function createRenderer(root, docs, options = {}) {
736
780
  };
737
781
  }
738
782
 
739
- return { renderDoc, renderVariants, renderInstance, fidelityOf };
783
+ /**
784
+ * Which of its Figma component's properties does a template read, in any
785
+ * case it can be rendered in? (The `code-connect-complete` gate,
786
+ * DESIGN-SYSTEM-252.) Every case `renderDoc` renders (every real variant,
787
+ * booleans at default / all on / all off / each flipped, hostile TEXT) plus
788
+ * every probe of `fidelityOf`, so a property read only behind a toggle
789
+ * counts. Returns { definitions: [{ name, type, options }], read: [name] }
790
+ * or null when the node is not in a snapshot.
791
+ */
792
+ function readsOf(doc) {
793
+ const nodeId = nodeIdFromUrl(doc.figmaNode);
794
+ const context = [...contexts.entries()].find(([fileKey]) =>
795
+ doc.figmaNode.includes(`/design/${fileKey}/`)
796
+ )?.[1];
797
+ const setNode = context?.byId.get(nodeId);
798
+ if (!setNode) return null;
799
+ const reads = new Set();
800
+ for (const entry of casesFor(context, nodeId)) {
801
+ try {
802
+ runTemplate(
803
+ doc,
804
+ makeInstance(
805
+ context,
806
+ entry.setNode,
807
+ propsFor(entry.setNode, entry.variant, entry.overrides),
808
+ 0,
809
+ entry.label,
810
+ reads
811
+ )
812
+ );
813
+ } catch {
814
+ // A render error is the compile gate's to report; the reads made
815
+ // before it still count.
816
+ }
817
+ }
818
+ for (const name of fidelityOf(doc)?.read ?? []) reads.add(name);
819
+ const definitions = Object.entries(setNode.propertyDefinitions ?? {}).map(
820
+ ([key, def]) => ({
821
+ name: stripSuffix(key),
822
+ type: def.type,
823
+ options: def.variantOptions ?? null,
824
+ })
825
+ );
826
+ return { definitions, read: [...reads].sort() };
827
+ }
828
+
829
+ return { renderDoc, renderVariants, renderInstance, fidelityOf, readsOf };
740
830
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.91",
3
+ "version": "0.6.92",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {