@nodii/dev 0.6.154 → 0.6.156
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/dist/core.js +1 -1
- package/dist/surface.js +137 -20
- package/package.json +1 -1
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.
|
|
7
|
+
export const VERSION = "0.6.156";
|
|
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
|
@@ -32,7 +32,7 @@ import { CliError, VERSION, devRequest, readConfig } from "./core.js";
|
|
|
32
32
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
33
33
|
|
|
34
34
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
35
|
-
export const GENERATOR_FORMAT =
|
|
35
|
+
export const GENERATOR_FORMAT = 22;
|
|
36
36
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
37
37
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
38
38
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -263,20 +263,20 @@ export async function lastPublishedVersion(figmaGet, fileKey, { library } = {})
|
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
/**
|
|
266
|
-
* Read one Surface set at a file version and trim it to what the generator reads.
|
|
266
|
+
* Read one Surface component or set at a file version and trim it to what the generator reads.
|
|
267
267
|
* `node` locates a set new to its file, not yet in its published listing (cli-144):
|
|
268
|
-
* the read is refused unless that
|
|
268
|
+
* the read is refused unless that component or set has the catalog row's key, which stays
|
|
269
269
|
* the reference (MW8-20); the node id is not kept.
|
|
270
270
|
*/
|
|
271
271
|
export async function fetchSurfaceTree(figmaGet, row, { index, version, node }) {
|
|
272
272
|
const nodeId = node ?? index.get(row.componentSetKey);
|
|
273
|
-
if (!nodeId) throw new CliError("SURFACE_NOT_PUBLISHED", `${row.componentSetName ?? row.id}: component set ${row.componentSetKey} is not among ${row.fileKey}'s published component sets`, 1);
|
|
273
|
+
if (!nodeId) throw new CliError("SURFACE_NOT_PUBLISHED", `${row.componentSetName ?? row.id}: component set ${row.componentSetKey} is not among ${row.fileKey}'s published components or component sets`, 1);
|
|
274
274
|
const body = await figmaGet(`/files/${encodeURIComponent(row.fileKey)}/nodes?ids=${encodeURIComponent(nodeId)}${version ? `&version=${encodeURIComponent(version)}` : ""}`);
|
|
275
275
|
const entry = body.nodes?.[nodeId];
|
|
276
276
|
if (!entry?.document) throw new CliError("FIGMA_NOT_FOUND", `Figma returned no document for ${row.componentSetName ?? row.id}`, 1);
|
|
277
|
-
const found = node ? (entry.document.type === "COMPONENT_SET" ? (entry.componentSets?.[nodeId]?.key ?? null) : null) : row.componentSetKey;
|
|
277
|
+
const found = node ? (entry.document.type === "COMPONENT_SET" ? (entry.componentSets?.[nodeId]?.key ?? null) : entry.document.type === "COMPONENT" ? (entry.components?.[nodeId]?.key ?? null) : null) : row.componentSetKey;
|
|
278
278
|
if (found !== row.componentSetKey)
|
|
279
|
-
throw new CliError("SURFACE_NODE_KEY_MISMATCH", `${row.componentSetName ?? row.id}: node ${nodeId} at version ${version} is ${found ? `component set ${found}` : "not a component set"}, not the catalog's ${row.componentSetKey}; --node only locates the catalog row's own set (cli-144, MW8-20)`, 1);
|
|
279
|
+
throw new CliError("SURFACE_NODE_KEY_MISMATCH", `${row.componentSetName ?? row.id}: node ${nodeId} at version ${version} is ${found ? `component set ${found}` : "not a published component or component set"}, not the catalog's ${row.componentSetKey}; --node only locates the catalog row's own set (cli-144, MW8-20)`, 1);
|
|
280
280
|
return trimTree(entry, { row, version: version ?? body.version ?? null });
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -306,7 +306,7 @@ export function trimTree(entry, { row, version }) {
|
|
|
306
306
|
const styles = entry.styles ?? {};
|
|
307
307
|
const keyOf = (componentId) => components[componentId]?.key ?? null;
|
|
308
308
|
|
|
309
|
-
const trim = (node, parentBox) => {
|
|
309
|
+
const trim = (node, parentBox, slotOwner = null) => {
|
|
310
310
|
const out = { type: node.type, name: node.name };
|
|
311
311
|
if (node.visible === false) return { ...out, visible: false };
|
|
312
312
|
const box = node.absoluteBoundingBox;
|
|
@@ -360,6 +360,19 @@ export function trimTree(entry, { row, version }) {
|
|
|
360
360
|
const effects = (node.effects ?? []).filter((e) => e.visible !== false);
|
|
361
361
|
if (effects.length) out.effects = styles[node.styles?.effect]?.name ?? effects.map((e) => e.type).join(",");
|
|
362
362
|
|
|
363
|
+
// A remote component owns its slot container's unmodified paint. Keep the
|
|
364
|
+
// observed values, but distinguish them from Surface-owned overrides. Missing
|
|
365
|
+
// REST provenance stays conservative; the exemption never reaches slot content.
|
|
366
|
+
if (node.type === "SLOT" && Array.isArray(slotOwner?.overrides)) {
|
|
367
|
+
const fields = new Set(slotOwner.overrides.filter(o => o.id === node.id).flatMap(o => o.overriddenFields ?? []));
|
|
368
|
+
if (!fields.has("boundVariables") && !fields.has("styles")) {
|
|
369
|
+
const inherited = Object.entries({ fills: ["fills", "fillStyleId"], strokes: ["strokes", "strokeStyleId", "strokeWeight", "individualStrokeWeights"], radius: ["cornerRadius", "rectangleCornerRadii"], effects: ["effects", "effectStyleId"] })
|
|
370
|
+
.filter(([key, sources]) => out[key] && !sources.some(field => fields.has(field)))
|
|
371
|
+
.map(([key]) => key);
|
|
372
|
+
if (inherited.length) out.inheritedPaint = inherited;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
363
376
|
if (node.type === "INSTANCE") {
|
|
364
377
|
const main = components[node.componentId] ?? {};
|
|
365
378
|
// An instance's own layers, down to (not into) its slots, which are the Surface's.
|
|
@@ -422,7 +435,7 @@ export function trimTree(entry, { row, version }) {
|
|
|
422
435
|
}
|
|
423
436
|
};
|
|
424
437
|
const children = main.remote ? [...slotsOf(node)] : (node.children ?? []);
|
|
425
|
-
if (children.length) out.children = children.map((c) => trim(c, box));
|
|
438
|
+
if (children.length) out.children = children.map((c) => trim(c, box, main.remote ? node : null));
|
|
426
439
|
return out;
|
|
427
440
|
}
|
|
428
441
|
if (node.type === "SLOT") {
|
|
@@ -930,6 +943,24 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
930
943
|
const lifted = [];
|
|
931
944
|
const lift = (at, name) => (lifted.push(name), mark(ctx, at, name));
|
|
932
945
|
let out = liftFieldControls(code, node, ctx, lift, scope);
|
|
946
|
+
// A Tabs Group renders its triggers directly, without tabStrip's sibling assembly.
|
|
947
|
+
// Generic values use the drawn label for a useful name, but keep their routing value.
|
|
948
|
+
// Probes must retain the template's sample until tabStrip assigns each tab its value.
|
|
949
|
+
if (!ctx.tabProbe) {
|
|
950
|
+
out = rewriteTags(out, "TabsTrigger", (attrs, _tag, end) => {
|
|
951
|
+
const value = /\bvalue="([^"]*)"/.exec(attrs)?.[1];
|
|
952
|
+
const body = /\/\s*$/.test(attrs) ? "" : out.slice(end + 1, out.indexOf("</TabsTrigger>", end));
|
|
953
|
+
const label = /\{("(?:[^"\\\n]|\\.)*")\}/.exec(body);
|
|
954
|
+
const name = value && !/^tab(?:-\d+)?$/.test(value) ? camelName(value) : nameOf(label ? JSON.parse(label[1]) : "", value || "tab");
|
|
955
|
+
const own = (prop) => {
|
|
956
|
+
lifted.push(prop);
|
|
957
|
+
return `${prop}={${optionalMark(ctx, `${scope} ${value || name}`, joinName(name, prop))}}`;
|
|
958
|
+
};
|
|
959
|
+
return attrs
|
|
960
|
+
.replace(/\bactionableCount=\{(?:\d+|actionableCount)\}/, () => own("actionableCount"))
|
|
961
|
+
.replace(/\bcountIsFloor(?:=\{(?:true|false|countIsFloor)\})?(?=\s|\/|$)/, () => own("countIsFloor"));
|
|
962
|
+
});
|
|
963
|
+
}
|
|
933
964
|
// An Alert's title or description that names a record's value: a date, an amount, a code,
|
|
934
965
|
// or any figure ("running at 4.2% this period", "3 lines still carry a flag"; hub-468).
|
|
935
966
|
out = out.replace(/<(Alert(Title|Description))>(\{"(?:[^"\\\n]|\\.)*"\})<\/\1>/g, (all, tag, part, lit) =>
|
|
@@ -1813,7 +1844,11 @@ function dataProps(views, propsType) {
|
|
|
1813
1844
|
// A lifted row's PII column is PiiText's served pair (cli-140).
|
|
1814
1845
|
for (const m of body.matchAll(PII_ROW_READ)) {
|
|
1815
1846
|
const list = itemList(m.index, m[1]);
|
|
1816
|
-
if (list)
|
|
1847
|
+
if (list) {
|
|
1848
|
+
const field = member(entry(list), m[2]);
|
|
1849
|
+
const nullable = / == null \? \("(?:[^"\\]|\\.)*"\) : \($/.test(body.slice(0, m.index)) || field.get("\u0000pii")?.raw.endsWith(" | null");
|
|
1850
|
+
field.set("\u0000pii", { raw: PII_ROW_FIELD + (nullable ? " | null" : "") });
|
|
1851
|
+
}
|
|
1817
1852
|
}
|
|
1818
1853
|
for (const m of body.matchAll(/(^|>)\s*\{([a-z][A-Za-z0-9]*)\}/gm)) {
|
|
1819
1854
|
if (JS_LITERALS.has(m[2])) continue;
|
|
@@ -2187,6 +2222,22 @@ function emitNode(node, ctx) {
|
|
|
2187
2222
|
const sizing = ctx.bare ? [] : sizeClasses(node, parent, false);
|
|
2188
2223
|
// A data slot passed straight to a prop is that prop (`trailing={<>{trailing}</>}` → `trailing={trailing}`).
|
|
2189
2224
|
let own = rendered.code.trim().replace(/=\{<>\{([a-z][A-Za-z0-9]*)\}<\/>\}/g, "={$1}");
|
|
2225
|
+
// The toolbar builds rows itself, so its template never renders the table slot.
|
|
2226
|
+
// Preserve the published error component drawn there as its errorState contract.
|
|
2227
|
+
if (node.instance.set === "Data Table Toolbar" && /^<DataTableToolbarBlock\b/.test(own) && !/\berrorState=/.test(own)) {
|
|
2228
|
+
const tableSlot = (node.children ?? []).find(c => c.type === "SLOT" && c.slot === "table" && c.visible !== false);
|
|
2229
|
+
const errors = [];
|
|
2230
|
+
const collect = (current) => {
|
|
2231
|
+
if (current.visible === false) return;
|
|
2232
|
+
if (current.instance?.remote && current.instance.set === "Error State Page") errors.push(current);
|
|
2233
|
+
else for (const child of current.children ?? []) collect(child);
|
|
2234
|
+
};
|
|
2235
|
+
if (tableSlot) collect(tableSlot);
|
|
2236
|
+
if (errors.length === 1) {
|
|
2237
|
+
const errorCode = emitNode(errors[0], { ...ctx, depth: 0, parent: tableSlot, grand: node, path: `${path} › table`, root: false, inTable: false, inSlot: true, chain: [...chain, tableSlot] });
|
|
2238
|
+
if (errorCode) own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock errorState={${errorCode}}`);
|
|
2239
|
+
} else if (errors.length > 1) note(`${path} › table`, "slot", "multiple Error State Page instances in one toolbar table slot: choose one error state");
|
|
2240
|
+
}
|
|
2190
2241
|
// A tab strip the page controls (tabOf reads the template's own strip first, to gather a run).
|
|
2191
2242
|
if (!ctx.tabProbe) own = own.replace(/<Tabs panelless(?: defaultValue="[^"]*")?>/g, CONTROLLED_TABS("tab", "onTabChange"));
|
|
2192
2243
|
// An Alert that shows its actions with nothing in the slot draws no AlertAction, never an
|
|
@@ -2275,9 +2326,10 @@ function emitNode(node, ctx) {
|
|
|
2275
2326
|
// A frame, group, local component instance or slot: its layout only. A fill,
|
|
2276
2327
|
// stroke, radius or effect it paints itself is not drawn, which would be a
|
|
2277
2328
|
// look-alike of a DS part (MW2-37.2); it is reported as a missing DS part.
|
|
2278
|
-
const
|
|
2329
|
+
const ownPaint = key => !node.inheritedPaint?.includes(key) && node[key];
|
|
2330
|
+
const painted = Boolean(ownPaint("fills")?.length || ownPaint("strokes")?.length || ownPaint("radius") || ownPaint("effects"));
|
|
2279
2331
|
if (painted)
|
|
2280
|
-
note(path, "frame", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} draws its own ${[
|
|
2332
|
+
note(path, "frame", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} draws its own ${[ownPaint("fills")?.length && "fill", ownPaint("strokes")?.length && "stroke", ownPaint("radius") && "radius", ownPaint("effects") && `effect ${node.effects}`].filter(Boolean).join(", ")}`);
|
|
2281
2333
|
// A frame that holds layers without auto layout has no flex or grid to
|
|
2282
2334
|
// become: it is refused and reported, never drawn by absolute positions.
|
|
2283
2335
|
if (!node.layout && (node.children ?? []).some((c) => c.visible !== false && !c.absolute)) {
|
|
@@ -2471,17 +2523,36 @@ function settlePiiColumns(views, unmapped) {
|
|
|
2471
2523
|
const id = `${list}.${key}`;
|
|
2472
2524
|
const r = reads.get(id) ?? reads.set(id, { list, key, pii: 0, node: 0, variant: view.variant }).get(id);
|
|
2473
2525
|
r[how]++;
|
|
2526
|
+
return r;
|
|
2474
2527
|
};
|
|
2475
2528
|
for (const view of views) {
|
|
2476
2529
|
const openers = listOpeners(view.body);
|
|
2477
|
-
for (const m of view.body.matchAll(PII_ROW_READ))
|
|
2530
|
+
for (const m of view.body.matchAll(PII_ROW_READ)) {
|
|
2531
|
+
const r = count(view, openers, m.index, m[1], m[2], "pii");
|
|
2532
|
+
const empty = / == null \? \(("(?:[^"\\]|\\.)*")\) : \($/.exec(view.body.slice(0, m.index));
|
|
2533
|
+
if (r && empty) r.empty = empty[1];
|
|
2534
|
+
}
|
|
2478
2535
|
for (const m of view.body.matchAll(NODE_READ)) count(view, openers, m.index, m[2], m[3], "node");
|
|
2479
2536
|
}
|
|
2480
2537
|
const mixed = new Map([...reads].filter(([, r]) => r.pii && r.node));
|
|
2538
|
+
// All views share the row type. Once nullable, every view must guard its read.
|
|
2539
|
+
for (const view of views) {
|
|
2540
|
+
const openers = listOpeners(view.body);
|
|
2541
|
+
view.body = view.body.replace(PII_CELL, (all, param, key, at) => {
|
|
2542
|
+
const r = reads.get(`${listAt(openers, at, param)}.${key}`);
|
|
2543
|
+
if (r?.empty === undefined || r.node) return all;
|
|
2544
|
+
const pii = /<PiiText[^\n]*\/>/.exec(all)[0];
|
|
2545
|
+
return all.replace(pii, `{${param}.${key} == null ? (${r.empty}) : (${pii})}`);
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2481
2548
|
if (!mixed.size) return;
|
|
2482
2549
|
for (const view of views) {
|
|
2483
2550
|
const openers = listOpeners(view.body);
|
|
2484
2551
|
view.body = view.body.replace(PII_CELL, (all, param, key, at) => (mixed.has(`${listAt(openers, at, param)}.${key}`) ? `>{${param}.${key}}</TableCell>` : all));
|
|
2552
|
+
// Nullable cells also participate in the cross-view contract. A genuinely
|
|
2553
|
+
// different cell kind must not leave an object read behind a ReactNode type.
|
|
2554
|
+
const nullableOpeners = listOpeners(view.body);
|
|
2555
|
+
view.body = view.body.replace(/>\n[ \t]*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*) == null \? \("(?:[^"\\]|\\.)*"\) : \(<PiiText[^\n]*\/>\)\}\n[ \t]*<\/TableCell>/g, (all, param, key, at) => (mixed.has(`${listAt(nullableOpeners, at, param)}.${key}`) ? `>{${param}.${key}}</TableCell>` : all));
|
|
2485
2556
|
}
|
|
2486
2557
|
for (const r of mixed.values()) {
|
|
2487
2558
|
unmapped.push({ variant: r.variant, path: r.list, kind: LIFTED, detail: `column ${r.key} of ${r.list} is PiiText in ${r.pii} of the ${r.pii + r.node} tables that share its rows: it stays a ReactNode, and the page must draw its people through PiiText itself (U05; cli-140)` });
|
|
@@ -2497,6 +2568,24 @@ function piiCellAttrs({ code, held }) {
|
|
|
2497
2568
|
}
|
|
2498
2569
|
|
|
2499
2570
|
function piiTreeKind(cell) {
|
|
2571
|
+
// Rich cells render the Surface-owned content slot, not an exposed instance.
|
|
2572
|
+
// Resolve only that slot's visible PiiText; unrelated slots and hidden samples
|
|
2573
|
+
// must not supply a missing kind, and ambiguous content stays unmapped.
|
|
2574
|
+
if (cell.instance?.set === "Table Rich Cell") {
|
|
2575
|
+
const kinds = [];
|
|
2576
|
+
const visit = (node) => {
|
|
2577
|
+
if (node.visible === false || node.absolute) return;
|
|
2578
|
+
if (node.instance) {
|
|
2579
|
+
if (node.instance.remote && node.instance.set === "PiiText") kinds.push(node.instance.props?.kind);
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
for (const child of node.children ?? []) visit(child);
|
|
2583
|
+
};
|
|
2584
|
+
for (const slot of cell.children ?? []) {
|
|
2585
|
+
if (slot.type === "SLOT" && slot.slot === "content") visit(slot);
|
|
2586
|
+
}
|
|
2587
|
+
return kinds.length === 1 ? kinds[0] : undefined;
|
|
2588
|
+
}
|
|
2500
2589
|
const exposed = Object.entries(cell.instance?.exposed ?? {}).find(([name]) => name.toLowerCase() === "piitext")?.[1];
|
|
2501
2590
|
return exposed?.props?.kind;
|
|
2502
2591
|
}
|
|
@@ -2509,6 +2598,16 @@ function piiCellText({ cell, code }, ref) {
|
|
|
2509
2598
|
return `<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint}${size} />`;
|
|
2510
2599
|
}
|
|
2511
2600
|
|
|
2601
|
+
/** Only a plain literal empty cell is compatible with a nullable person. */
|
|
2602
|
+
function emptyPiiCell(part) {
|
|
2603
|
+
if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
|
|
2604
|
+
const inner = part.code.slice(openTagEnd(part.code) + 1).replace(/<\/TableCell>$/, "").trim();
|
|
2605
|
+
const literal = /^\{("(?:[^"\\]|\\.)*")\}$/.exec(inner);
|
|
2606
|
+
if (!literal) return null;
|
|
2607
|
+
const value = JSON.parse(literal[1]);
|
|
2608
|
+
return /^(?:\s*|\s*[-–—]\s*|\s*(?:unassigned|none|no one|no reviewer|not needed|not found|system)\s*)$/i.test(value) ? literal[1] : null;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2512
2611
|
/**
|
|
2513
2612
|
* A table a Surface draws as frames: rows of Table-part instances (what the
|
|
2514
2613
|
* templates emit as TableHead or TableCell). Those parts are valid only inside
|
|
@@ -2844,11 +2943,17 @@ function tableOf(node, ctx) {
|
|
|
2844
2943
|
// raw name (U05; cli-140). A column that is PiiText in only some rows stays a node, and
|
|
2845
2944
|
// the report names it.
|
|
2846
2945
|
const invalidPii = new Map();
|
|
2946
|
+
const nullablePii = new Map();
|
|
2847
2947
|
const piiColumn = keys.map((key, i) => {
|
|
2848
|
-
const
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2948
|
+
const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
|
|
2949
|
+
const drawn = people.length;
|
|
2950
|
+
const others = dataRows.filter((p) => piiCellAttrs(p.cells[i]) === null);
|
|
2951
|
+
const empties = others.map(p => emptyPiiCell(p.cells[i]));
|
|
2952
|
+
const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
|
|
2953
|
+
if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
|
|
2954
|
+
if (drawn > 0 && drawn < dataRows.length && !nullable) ctx.note(ctx.path, LIFTED, `column ${key} is PiiText in ${drawn} of ${dataRows.length} body rows: it stays a ReactNode, and the page must draw its people through PiiText itself (U05; cli-140)`);
|
|
2955
|
+
if (drawn === dataRows.length || nullable) {
|
|
2956
|
+
const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
|
|
2852
2957
|
const why = kinds.some((kind) => !PII_KINDS.has(kind))
|
|
2853
2958
|
? `column ${key} has no recognised PiiText kind in one or more body rows`
|
|
2854
2959
|
: new Set(kinds).size !== 1 ? `column ${key} has incompatible PiiText kinds` : null;
|
|
@@ -2858,7 +2963,7 @@ function tableOf(node, ctx) {
|
|
|
2858
2963
|
return false;
|
|
2859
2964
|
}
|
|
2860
2965
|
}
|
|
2861
|
-
return drawn === dataRows.length;
|
|
2966
|
+
return drawn === dataRows.length || nullable;
|
|
2862
2967
|
});
|
|
2863
2968
|
const cells = first.cells.map((c, i) => {
|
|
2864
2969
|
const w = columnWidth(c.cell);
|
|
@@ -2872,7 +2977,12 @@ function tableOf(node, ctx) {
|
|
|
2872
2977
|
close = `</${tag}>`;
|
|
2873
2978
|
}
|
|
2874
2979
|
if (invalidPii.has(i)) return indent(`${open}${comment(`unmapped: ${invalidPii.get(i)}`)}${close}`, depth + 4);
|
|
2875
|
-
if (piiColumn[i])
|
|
2980
|
+
if (piiColumn[i]) {
|
|
2981
|
+
const nullable = nullablePii.get(i);
|
|
2982
|
+
const ref = `row.${keys[i]}`;
|
|
2983
|
+
const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(c, ref);
|
|
2984
|
+
return indent(`${open}\n ${content}\n${close}`, depth + 4);
|
|
2985
|
+
}
|
|
2876
2986
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|
|
2877
2987
|
});
|
|
2878
2988
|
return [
|
|
@@ -3071,11 +3181,13 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
3071
3181
|
// --figma-version names a version outright; otherwise each file is read at its last library publish.
|
|
3072
3182
|
// The library read that finds the publish also gives the set index, so it is one read per file.
|
|
3073
3183
|
const versions = new Map();
|
|
3184
|
+
const componentIndexes = new Set();
|
|
3074
3185
|
const versionFor = async (fileKey) => {
|
|
3075
3186
|
if (figmaVersion) return figmaVersion;
|
|
3076
3187
|
if (!versions.has(fileKey)) {
|
|
3077
3188
|
const library = await fetchLibrary(figmaGet, fileKey);
|
|
3078
|
-
indexes.set(fileKey, new Map(library.component_sets.map((x) => [x.key, x.node_id])));
|
|
3189
|
+
indexes.set(fileKey, new Map([...library.components, ...library.component_sets].map((x) => [x.key, x.node_id])));
|
|
3190
|
+
componentIndexes.add(fileKey);
|
|
3079
3191
|
const pin = await lastPublishedVersion(figmaGet, fileKey, { library });
|
|
3080
3192
|
log(`${fileKey}: last library publish ${pin.publishedAt} closed version ${pin.version} at ${pin.closedAt}${pin.label ? ` ("${pin.label}")` : " (unlabelled)"}`);
|
|
3081
3193
|
versions.set(fileKey, pin.version);
|
|
@@ -3101,10 +3213,15 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
3101
3213
|
}
|
|
3102
3214
|
}
|
|
3103
3215
|
if (!node && !indexes.has(row.fileKey)) indexes.set(row.fileKey, await setIndex(figmaGet, row.fileKey));
|
|
3216
|
+
if (!node && !indexes.get(row.fileKey).has(row.componentSetKey) && !componentIndexes.has(row.fileKey)) {
|
|
3217
|
+
const published = await figmaGet(`/files/${encodeURIComponent(row.fileKey)}/components`);
|
|
3218
|
+
for (const component of published.meta?.components ?? []) indexes.get(row.fileKey).set(component.key, component.node_id);
|
|
3219
|
+
componentIndexes.add(row.fileKey);
|
|
3220
|
+
}
|
|
3104
3221
|
// --all covers a module: one unpublished Surface is reported, and the rest still generate.
|
|
3105
3222
|
// A Surface named on its own stays a refusal, because the run has nothing else to do.
|
|
3106
3223
|
if (f.all && !indexes.get(row.fileKey).has(row.componentSetKey)) {
|
|
3107
|
-
log(`skipping ${row.componentSetName ?? row.id}: not among ${row.fileKey}'s published component sets`);
|
|
3224
|
+
log(`skipping ${row.componentSetName ?? row.id}: not among ${row.fileKey}'s published components or component sets`);
|
|
3108
3225
|
unpublished.push(row);
|
|
3109
3226
|
continue;
|
|
3110
3227
|
}
|