@nodii/dev 0.6.156 → 0.6.157
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 +21 -4
- 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.157";
|
|
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 = 23;
|
|
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). */
|
|
@@ -2944,10 +2944,16 @@ function tableOf(node, ctx) {
|
|
|
2944
2944
|
// the report names it.
|
|
2945
2945
|
const invalidPii = new Map();
|
|
2946
2946
|
const nullablePii = new Map();
|
|
2947
|
+
const personSamples = new Map();
|
|
2947
2948
|
const piiColumn = keys.map((key, i) => {
|
|
2948
2949
|
const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
|
|
2949
|
-
|
|
2950
|
-
|
|
2950
|
+
// "You" in a name column is the viewer's person, not an empty value.
|
|
2951
|
+
// Keep relation supplied by the data binding: self must remain revealed.
|
|
2952
|
+
const selfCells = people.length && people.every(p => piiTreeKind(p.cells[i].cell) === "name")
|
|
2953
|
+
? dataRows.filter(p => /^<TableCell\b[^>]*>\s*\{"You"\}\s*<\/TableCell>$/.test(p.cells[i].code ?? "")) : [];
|
|
2954
|
+
const drawn = people.length + selfCells.length;
|
|
2955
|
+
if (selfCells.length) personSamples.set(i, people[0].cells[i]);
|
|
2956
|
+
const others = dataRows.filter((p) => piiCellAttrs(p.cells[i]) === null && !selfCells.includes(p));
|
|
2951
2957
|
const empties = others.map(p => emptyPiiCell(p.cells[i]));
|
|
2952
2958
|
const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
|
|
2953
2959
|
if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
|
|
@@ -2965,6 +2971,7 @@ function tableOf(node, ctx) {
|
|
|
2965
2971
|
}
|
|
2966
2972
|
return drawn === dataRows.length || nullable;
|
|
2967
2973
|
});
|
|
2974
|
+
const secondaryKeys = new Set(keys);
|
|
2968
2975
|
const cells = first.cells.map((c, i) => {
|
|
2969
2976
|
const w = columnWidth(c.cell);
|
|
2970
2977
|
let open = `<TableCell${wrapperAttrs(w, first.row)}>`;
|
|
@@ -2976,11 +2983,21 @@ function tableOf(node, ctx) {
|
|
|
2976
2983
|
open = own.slice(0, end + 1).replace(/\s*\/>$/, ">");
|
|
2977
2984
|
close = `</${tag}>`;
|
|
2978
2985
|
}
|
|
2986
|
+
// Two-line templates own the presentation; both lines belong to each row.
|
|
2987
|
+
// Reserve every header key before naming secondary fields, so a column
|
|
2988
|
+
// called "Environment secondary" cannot alias Environment's second line.
|
|
2989
|
+
if (/^<TableCell\b/.test(open) && /\bsecondary=/.test(open)) {
|
|
2990
|
+
const base = `${keys[i]}Secondary`;
|
|
2991
|
+
let secondary = base;
|
|
2992
|
+
for (let n = 2; secondaryKeys.has(secondary); n++) secondary = `${base}${n}`;
|
|
2993
|
+
secondaryKeys.add(secondary);
|
|
2994
|
+
open = open.replace(new RegExp(`\\bsecondary=(${LITERAL})`), `secondary={row.${secondary}}`);
|
|
2995
|
+
}
|
|
2979
2996
|
if (invalidPii.has(i)) return indent(`${open}${comment(`unmapped: ${invalidPii.get(i)}`)}${close}`, depth + 4);
|
|
2980
2997
|
if (piiColumn[i]) {
|
|
2981
2998
|
const nullable = nullablePii.get(i);
|
|
2982
2999
|
const ref = `row.${keys[i]}`;
|
|
2983
|
-
const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(c, ref);
|
|
3000
|
+
const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(personSamples.get(i) ?? c, ref);
|
|
2984
3001
|
return indent(`${open}\n ${content}\n${close}`, depth + 4);
|
|
2985
3002
|
}
|
|
2986
3003
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|