@nodii/dev 0.6.163 → 0.6.165

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 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.163";
7
+ export const VERSION = "0.6.165";
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
@@ -27,12 +27,12 @@
27
27
  import { execFileSync } from "node:child_process";
28
28
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
29
29
  import { tmpdir } from "node:os";
30
- import { dirname, join, relative, resolve } from "node:path";
30
+ import { basename, dirname, join, relative, resolve } from "node:path";
31
31
  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 = 32;
35
+ export const GENERATOR_FORMAT = 34;
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). */
@@ -505,6 +505,31 @@ export function mergeImports(statements, body = null) {
505
505
  return [...lines, ...[...other].sort()];
506
506
  }
507
507
 
508
+ /** The registry is the authority for block aliases used by Code Connect. */
509
+ export function blockImportPaths(items) {
510
+ const paths = new Map();
511
+ for (const item of items) {
512
+ if (item.type !== "registry:block") continue;
513
+ const files = item.files ?? [];
514
+ for (const file of files) {
515
+ const name = files.length === 1 ? item.name : basename(file.path).replace(/-block(\.tsx?)$/, "$1").replace(/\.[^.]+$/, "");
516
+ paths.set(`@/components/ui/${name}`, file.path);
517
+ }
518
+ }
519
+ return paths;
520
+ }
521
+
522
+ /** Generated pages live in blocks itself, so use the registry's source, not a consumer alias. */
523
+ export function resolveBlockImports(imports, sourcePath, paths = new Map()) {
524
+ if (!sourcePath) return imports;
525
+ return imports.map(statement => statement.replace(/\bfrom\s+(["'])(@\/components\/ui\/[^"']+)\1/, (all, quote, alias) => {
526
+ const target = paths.get(alias);
527
+ if (!target) return all;
528
+ const path = relative(dirname(sourcePath), target).replaceAll("\\", "/").replace(/\.tsx?$/, "");
529
+ return `from ${quote}${path.startsWith(".") ? path : `./${path}`}${quote}`;
530
+ }));
531
+ }
532
+
508
533
  /** The design system's inputs to emitting: templates, the key index, tokens and text utilities. */
509
534
  export function loadDesignSystem(root, { exec = execFileSync, docs } = {}) {
510
535
  const dsFileKey = readJson(join(root, DS_FILE_META)).fileKey;
@@ -527,7 +552,9 @@ export function loadDesignSystem(root, { exec = execFileSync, docs } = {}) {
527
552
  const set = optionalProps.get(doc.component) ?? optionalProps.set(doc.component, new Set()).get(doc.component);
528
553
  for (const name of listed) set.add(name);
529
554
  }
530
- return { dsFileKey, renderer, byKey, colours, textStyles, optionalProps };
555
+ const registryPath = join(root, "apps/web/public/registry.json");
556
+ const registry = existsSync(registryPath) ? readJson(registryPath) : [];
557
+ return { dsFileKey, renderer, byKey, colours, textStyles, optionalProps, blockImports: blockImportPaths(registry.items ?? registry) };
531
558
  }
532
559
 
533
560
  /** `figma connect parse`, the repository's own Code Connect compile, into memory. */
@@ -602,7 +629,7 @@ export function emitSurface(tree, row, ds) {
602
629
  ];
603
630
  const lines = [
604
631
  ...header,
605
- ...mergeImports([...imports, ...(reactTypes.length ? [`import type { ${reactTypes.join(", ")} } from "react";`] : [])], [...views.map((v) => v.body), reactTypes.join(" ")].join("\n")),
632
+ ...mergeImports(resolveBlockImports([...imports, ...(reactTypes.length ? [`import type { ${reactTypes.join(", ")} } from "react";`] : [])], row.sourcePath, ds.blockImports), [...views.map((v) => v.body), reactTypes.join(" ")].join("\n")),
606
633
  "",
607
634
  `export type ${stateType} = ${views.map((v) => JSON.stringify(v.state)).join(" | ")};`,
608
635
  "",
@@ -989,6 +1016,17 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
989
1016
  const scope = nameOf(label ? literalText(label[1]) : node.name, node.name);
990
1017
  return `<DescriptionItem${attrs.replace(value[0], `value={${lift(scope, "value")}}`)}/>`;
991
1018
  });
1019
+ out = rewriteTags(out, "DetailFact|RightPaneRow", (attrs) => {
1020
+ const parsed = tagAttributes(`${attrs}>`, 0);
1021
+ if (!parsed?.literals.has("value")) return attrs;
1022
+ const label = parsed.literals.get("label");
1023
+ const factScope = nameOf(label ? literalText(label) : node.name, node.name);
1024
+ const flat = maskStrings(attrs);
1025
+ return attrs.replace(new RegExp(String.raw`\bvalue=${LITERAL}`, "g"), (value, at) => {
1026
+ const depth = [...flat.slice(0, at)].reduce((d, c) => d + (c === "{") - (c === "}"), 0);
1027
+ return depth === 0 ? `value={${lift(factScope, "value")}}` : value;
1028
+ });
1029
+ });
992
1030
  out = out.replace(/<StatusPill\b([^>]*?)(\/?)>/g, (all, attrs, close) => {
993
1031
  const label = new RegExp(String.raw`\blabel=${LITERAL}`).exec(attrs);
994
1032
  if (!label) return all;
@@ -1091,7 +1129,14 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1091
1129
  out = rewriteTags(out, "PageSizeSelect", (attrs) => attrs.replace(/\bvalue=\{(?:\d+|Number\("(?:[^"\\\n]|\\.)*"\))\}/, () => `value={${lift(scope, "pageSize")}}`));
1092
1130
  out = rewriteTags(out, "CopyField", (attrs) => {
1093
1131
  const value = new RegExp(String.raw`\bvalue=${LITERAL}`).exec(attrs);
1094
- return value ? attrs.replace(value[0], `value={${lift(scope, "value")}}`) : attrs;
1132
+ let next = value ? attrs.replace(value[0], `value={${lift(scope, "value")}}`) : attrs;
1133
+ const label = new RegExp(String.raw`\blabel=(${LITERAL})`).exec(next);
1134
+ if (label) {
1135
+ lifted.push("label");
1136
+ const name = optionalMark(ctx, scope, "label");
1137
+ next = next.replace(label[0], `label={${name} ?? ${JSON.stringify(literalText(label[1]))}}`);
1138
+ }
1139
+ return next;
1095
1140
  });
1096
1141
  out = rewriteTags(out, "PiiText", (attrs) => {
1097
1142
  const hint = new RegExp(String.raw`\bmaskHint=${LITERAL}`).exec(attrs);
@@ -1873,7 +1918,7 @@ function dataProps(views, propsType) {
1873
1918
  (entry(m[1]).tabValues ??= new Set()).add(JSON.parse(m[2]));
1874
1919
  view.uses.add(m[1]);
1875
1920
  }
1876
- for (const m of body.matchAll(/([A-Za-z][\w-]*)=\{([a-z][A-Za-z0-9]*)(?:\.([A-Za-z][A-Za-z0-9]*))?(?: \?\? (?:true|false))?\}/g)) {
1921
+ for (const m of body.matchAll(/([A-Za-z][\w-]*)=\{([a-z][A-Za-z0-9]*)(?:\.([A-Za-z][A-Za-z0-9]*))?(?: \?\? (?:true|false|"(?:[^"\\]|\\.)*"))?\}/g)) {
1877
1922
  if (JS_LITERALS.has(m[2]) || data.get(m[2])?.raw) continue;
1878
1923
  const list = m[3] ? itemList(m.index, m[2]) : null;
1879
1924
  // A list item's React key is its own: a string, never a DS prop.
@@ -2275,7 +2320,9 @@ function emitNode(node, ctx) {
2275
2320
  return indent(comment(`unmapped: ${describe(node)} (${why})`), depth);
2276
2321
  }
2277
2322
  ctx.imports.push(...rendered.imports);
2278
- const sizing = ctx.bare ? [] : sizeClasses(node, parent, false);
2323
+ // Detail Section owns its grid. The Row template emits sibling facts,
2324
+ // not a layout box: a wrapper would turn the entire row into one grid cell.
2325
+ const sizing = ctx.bare || node.instance.set === "Detail Section / Row" ? [] : sizeClasses(node, parent, false);
2279
2326
  // A data slot passed straight to a prop is that prop (`trailing={<>{trailing}</>}` → `trailing={trailing}`).
2280
2327
  let own = rendered.code.trim().replace(/=\{<>\{([a-z][A-Za-z0-9]*)\}<\/>\}/g, "={$1}");
2281
2328
  // The toolbar builds rows itself, so its template never renders the table slot.
@@ -2674,7 +2721,9 @@ function piiCellText({ cell, code }, ref) {
2674
2721
  const { attrs = "", before = "", after = "" } = piiCellParts({ code }) ?? {};
2675
2722
  const kind = piiTreeKind(cell);
2676
2723
  const size = /\ssize="\w+"/.exec(attrs)?.[0] ?? "";
2677
- return `${before}<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint}${size} />${after}`;
2724
+ // Repeated people are a bulk disclosure surface even inside a record page or
2725
+ // a permissive ambient provider. Keep the served self relation unchanged.
2726
+ return `${before}<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
2678
2727
  }
2679
2728
 
2680
2729
  /** Only a plain literal empty cell is compatible with a nullable person. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.163",
3
+ "version": "0.6.165",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {