@nodii/dev 0.6.200 → 0.6.201

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/README.md CHANGED
@@ -1342,7 +1342,12 @@ product-page catalog names the Surface by its published component-set key
1342
1342
  Item hidden while its value is missing still draws while loading
1343
1343
  (`{(loading || fromValue != null) && (…)}`). Each value keeps the type of the
1344
1344
  part that draws it. `Skeleton` is imported from the module the page's DS parts
1345
- come from; a view with no fact is unchanged.
1345
+ come from; a view with no fact is unchanged. The skeleton only takes the
1346
+ fact's own ReactNode `value`, never a typed prop of a DS part inside it
1347
+ (hub-642): a value that is a DS part reading the page's data is replaced
1348
+ whole, `value={loading ? <Skeleton shape="text" /> : <PiiText value={emailValue} … />}`,
1349
+ so PiiText's `value` stays `string | null`. A value that reads nothing (fixed
1350
+ copy) is left as it is.
1346
1351
  - **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
1347
1352
  `<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
1348
1353
  `state` with only the props its view reads (`{ state: "read-error" } &
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
4
4
  import { homedir, platform } from "node:os";
5
5
  import { basename, dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.200";
7
+ export const VERSION = "0.6.201";
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
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
34
34
  import { createRenderer } from "./vendor/render-templates.mjs";
35
35
 
36
36
  /** Bumped whenever the emitted code changes shape for the same inputs. */
37
- export const GENERATOR_FORMAT = 54;
37
+ export const GENERATOR_FORMAT = 55;
38
38
  /**
39
39
  * DS parts that are an item of their parent's own list or grid, so they take no sizing
40
40
  * wrapper: a Detail Section / Row's facts are the section grid's cells, a Right Pane / Row
@@ -2440,10 +2440,24 @@ function passLoading(code) {
2440
2440
  * draws its skeleton while loading. Run after the props are typed, so each value keeps
2441
2441
  * the type of the part that draws it. Skeleton comes from the DS module the page's DS
2442
2442
  * parts come from; a page with no such import is left as it is.
2443
+ *
2444
+ * The skeleton only ever takes a ReactNode slot: the fact part's own top-level `value`
2445
+ * (or a pair's value span). A fact whose value is a DS part reading the page's data
2446
+ * (`value={<PiiText value={emailValue} … />}`) draws the skeleton in place of that whole
2447
+ * part, never inside one of its typed props, so PiiText's `value` stays `string | null`
2448
+ * (hub-642). A value that is fixed copy, or any other expression, is left as it is.
2443
2449
  */
2444
2450
  const FACT_SKELETON = '<Skeleton shape="text" />';
2445
2451
  const FACT_PARTS = /<(?:DescriptionItem|DetailFact|RightPaneRow)(?=[\s/>])/g;
2446
- const FACT_VALUE = /(\svalue=\{)([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\}/;
2452
+ const FACT_READ = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
2453
+ /** One JSX element (self-closing, or closed by its own tag) that reads the page's data: `{ident}` somewhere in it. */
2454
+ const factElement = (expr) => {
2455
+ const tag = /^<([A-Z][\w.]*)(?=[\s/>])/.exec(expr)?.[1];
2456
+ if (!tag) return false;
2457
+ const end = openTagEnd(expr);
2458
+ const whole = expr[end - 1] === "/" ? end === expr.length - 1 : expr.endsWith(`</${tag}>`) && expr.indexOf(`<${tag}`, 1) === -1;
2459
+ return whole && /\{[A-Za-z_$][\w$.]*\}/.test(expr);
2460
+ };
2447
2461
  const SKELETON_HOST = /\b(?:DescriptionItem|DescriptionList|DetailFact|DetailSection|Card|Badge|PiiText|Tabs|Field|Alert|EmptyState|Button|TableCell|TableHead)\b/;
2448
2462
  const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2449
2463
  function skeletonFacts(views, imports, factTexts) {
@@ -2457,14 +2471,20 @@ function skeletonFacts(views, imports, factTexts) {
2457
2471
  const masked = maskStrings(body);
2458
2472
  const edits = [];
2459
2473
  for (const m of masked.matchAll(FACT_PARTS)) {
2460
- const open = masked.slice(m.index, m.index + openTagEnd(masked.slice(m.index)) + 1);
2461
- const value = FACT_VALUE.exec(open);
2462
- if (value) edits.push({ at: m.index + value.index + value[1].length, read: value[2] });
2474
+ const at = m.index + m[0].length;
2475
+ const open = masked.slice(at, m.index + openTagEnd(masked.slice(m.index)) + 1);
2476
+ // The part's own value, never a `value` inside a DS part it draws (hub-642).
2477
+ const value = topLevelAttr(open, "value");
2478
+ if (!value) continue;
2479
+ const from = at + value.from + "value={".length;
2480
+ const expr = body.slice(from, at + value.to - 1);
2481
+ if (FACT_READ.test(expr)) edits.push({ at: from, read: expr });
2482
+ else if (factElement(expr)) edits.push({ at: from, read: null });
2463
2483
  }
2464
2484
  const gated = new Set();
2465
2485
  for (const { at, read } of edits.reverse()) {
2466
2486
  body = `${body.slice(0, at)}loading ? ${FACT_SKELETON} : ${body.slice(at)}`;
2467
- if (!read.includes(".")) gated.add(read);
2487
+ if (read && !read.includes(".")) gated.add(read);
2468
2488
  }
2469
2489
  for (const read of gated) body = body.replace(new RegExp(String.raw`\{${escapeRegExp(read)} != null && \(`, "g"), `{(loading || ${read} != null) && (`);
2470
2490
  for (const name of factTexts) body = body.replace(new RegExp(String.raw`(<span\b[^>\n]*>)\{${escapeRegExp(name)}\}(</span>)`, "g"), `$1{loading ? ${FACT_SKELETON} : ${name}}$2`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.200",
3
+ "version": "0.6.201",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {