@nodii/dev 0.6.155 → 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 +32 -9
- 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
|
|
|
@@ -2222,6 +2222,22 @@ function emitNode(node, ctx) {
|
|
|
2222
2222
|
const sizing = ctx.bare ? [] : sizeClasses(node, parent, false);
|
|
2223
2223
|
// A data slot passed straight to a prop is that prop (`trailing={<>{trailing}</>}` → `trailing={trailing}`).
|
|
2224
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
|
+
}
|
|
2225
2241
|
// A tab strip the page controls (tabOf reads the template's own strip first, to gather a run).
|
|
2226
2242
|
if (!ctx.tabProbe) own = own.replace(/<Tabs panelless(?: defaultValue="[^"]*")?>/g, CONTROLLED_TABS("tab", "onTabChange"));
|
|
2227
2243
|
// An Alert that shows its actions with nothing in the slot draws no AlertAction, never an
|
|
@@ -2589,7 +2605,7 @@ function emptyPiiCell(part) {
|
|
|
2589
2605
|
const literal = /^\{("(?:[^"\\]|\\.)*")\}$/.exec(inner);
|
|
2590
2606
|
if (!literal) return null;
|
|
2591
2607
|
const value = JSON.parse(literal[1]);
|
|
2592
|
-
return /^(?:\s*|\s*[-–—]\s*|\s*(?:unassigned|none|system)\s*)$/i.test(value) ? literal[1] : null;
|
|
2608
|
+
return /^(?:\s*|\s*[-–—]\s*|\s*(?:unassigned|none|no one|no reviewer|not needed|not found|system)\s*)$/i.test(value) ? literal[1] : null;
|
|
2593
2609
|
}
|
|
2594
2610
|
|
|
2595
2611
|
/**
|
|
@@ -3165,11 +3181,13 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
3165
3181
|
// --figma-version names a version outright; otherwise each file is read at its last library publish.
|
|
3166
3182
|
// The library read that finds the publish also gives the set index, so it is one read per file.
|
|
3167
3183
|
const versions = new Map();
|
|
3184
|
+
const componentIndexes = new Set();
|
|
3168
3185
|
const versionFor = async (fileKey) => {
|
|
3169
3186
|
if (figmaVersion) return figmaVersion;
|
|
3170
3187
|
if (!versions.has(fileKey)) {
|
|
3171
3188
|
const library = await fetchLibrary(figmaGet, fileKey);
|
|
3172
|
-
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);
|
|
3173
3191
|
const pin = await lastPublishedVersion(figmaGet, fileKey, { library });
|
|
3174
3192
|
log(`${fileKey}: last library publish ${pin.publishedAt} closed version ${pin.version} at ${pin.closedAt}${pin.label ? ` ("${pin.label}")` : " (unlabelled)"}`);
|
|
3175
3193
|
versions.set(fileKey, pin.version);
|
|
@@ -3195,10 +3213,15 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
3195
3213
|
}
|
|
3196
3214
|
}
|
|
3197
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
|
+
}
|
|
3198
3221
|
// --all covers a module: one unpublished Surface is reported, and the rest still generate.
|
|
3199
3222
|
// A Surface named on its own stays a refusal, because the run has nothing else to do.
|
|
3200
3223
|
if (f.all && !indexes.get(row.fileKey).has(row.componentSetKey)) {
|
|
3201
|
-
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`);
|
|
3202
3225
|
unpublished.push(row);
|
|
3203
3226
|
continue;
|
|
3204
3227
|
}
|