@nodii/dev 0.6.156 → 0.6.158
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 +26 -5
- 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.158";
|
|
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 = 24;
|
|
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). */
|
|
@@ -1126,7 +1126,11 @@ export const SAMPLE_VALUE = /₹\s?\d|\b\d{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|A
|
|
|
1126
1126
|
* in it ("3 waiting on you", "v2 · published", "Showing 1 - 10 of 46"), which is a
|
|
1127
1127
|
* count, a version or a date, never fixed copy (NODII-DEV-CLI-82).
|
|
1128
1128
|
*/
|
|
1129
|
-
|
|
1129
|
+
// A standalone relative period is the selected record's period, not permanent
|
|
1130
|
+
// copy: a past usage record must not keep Figma's "This month" heading.
|
|
1131
|
+
// Keep sentences mentioning periods (instructions and help text) unchanged.
|
|
1132
|
+
const RELATIVE_PERIOD = /^(?:(?:this|last|previous|current|next) (?:day|week|month|quarter|year)|today|yesterday|tomorrow)$/i;
|
|
1133
|
+
const RECORD_TEXT = (text) => SAMPLE_VALUE.test(text) || /\d/.test(text) || RELATIVE_PERIOD.test(text.trim());
|
|
1130
1134
|
|
|
1131
1135
|
/** A part named by where it sits: its parent's name, numbered when the parent holds several of the same set. */
|
|
1132
1136
|
function positionScope(node, ctx, kind) {
|
|
@@ -2944,10 +2948,16 @@ function tableOf(node, ctx) {
|
|
|
2944
2948
|
// the report names it.
|
|
2945
2949
|
const invalidPii = new Map();
|
|
2946
2950
|
const nullablePii = new Map();
|
|
2951
|
+
const personSamples = new Map();
|
|
2947
2952
|
const piiColumn = keys.map((key, i) => {
|
|
2948
2953
|
const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
|
|
2949
|
-
|
|
2950
|
-
|
|
2954
|
+
// "You" in a name column is the viewer's person, not an empty value.
|
|
2955
|
+
// Keep relation supplied by the data binding: self must remain revealed.
|
|
2956
|
+
const selfCells = people.length && people.every(p => piiTreeKind(p.cells[i].cell) === "name")
|
|
2957
|
+
? dataRows.filter(p => /^<TableCell\b[^>]*>\s*\{"You"\}\s*<\/TableCell>$/.test(p.cells[i].code ?? "")) : [];
|
|
2958
|
+
const drawn = people.length + selfCells.length;
|
|
2959
|
+
if (selfCells.length) personSamples.set(i, people[0].cells[i]);
|
|
2960
|
+
const others = dataRows.filter((p) => piiCellAttrs(p.cells[i]) === null && !selfCells.includes(p));
|
|
2951
2961
|
const empties = others.map(p => emptyPiiCell(p.cells[i]));
|
|
2952
2962
|
const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
|
|
2953
2963
|
if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
|
|
@@ -2965,6 +2975,7 @@ function tableOf(node, ctx) {
|
|
|
2965
2975
|
}
|
|
2966
2976
|
return drawn === dataRows.length || nullable;
|
|
2967
2977
|
});
|
|
2978
|
+
const secondaryKeys = new Set(keys);
|
|
2968
2979
|
const cells = first.cells.map((c, i) => {
|
|
2969
2980
|
const w = columnWidth(c.cell);
|
|
2970
2981
|
let open = `<TableCell${wrapperAttrs(w, first.row)}>`;
|
|
@@ -2976,11 +2987,21 @@ function tableOf(node, ctx) {
|
|
|
2976
2987
|
open = own.slice(0, end + 1).replace(/\s*\/>$/, ">");
|
|
2977
2988
|
close = `</${tag}>`;
|
|
2978
2989
|
}
|
|
2990
|
+
// Two-line templates own the presentation; both lines belong to each row.
|
|
2991
|
+
// Reserve every header key before naming secondary fields, so a column
|
|
2992
|
+
// called "Environment secondary" cannot alias Environment's second line.
|
|
2993
|
+
if (/^<TableCell\b/.test(open) && /\bsecondary=/.test(open)) {
|
|
2994
|
+
const base = `${keys[i]}Secondary`;
|
|
2995
|
+
let secondary = base;
|
|
2996
|
+
for (let n = 2; secondaryKeys.has(secondary); n++) secondary = `${base}${n}`;
|
|
2997
|
+
secondaryKeys.add(secondary);
|
|
2998
|
+
open = open.replace(new RegExp(`\\bsecondary=(${LITERAL})`), `secondary={row.${secondary}}`);
|
|
2999
|
+
}
|
|
2979
3000
|
if (invalidPii.has(i)) return indent(`${open}${comment(`unmapped: ${invalidPii.get(i)}`)}${close}`, depth + 4);
|
|
2980
3001
|
if (piiColumn[i]) {
|
|
2981
3002
|
const nullable = nullablePii.get(i);
|
|
2982
3003
|
const ref = `row.${keys[i]}`;
|
|
2983
|
-
const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(c, ref);
|
|
3004
|
+
const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(personSamples.get(i) ?? c, ref);
|
|
2984
3005
|
return indent(`${open}\n ${content}\n${close}`, depth + 4);
|
|
2985
3006
|
}
|
|
2986
3007
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|