@ouispec/cli 0.9.0 → 0.11.0

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/analyze.d.ts CHANGED
@@ -166,6 +166,12 @@ export declare class PageAnalyzer {
166
166
  private componentName;
167
167
  /** The props a component destructures: local name → prop name. */
168
168
  private destructuredProps;
169
+ /**
170
+ * Where a component destructures its props, each name with the prop it is:
171
+ * in its parameter (`({ agent })`), or from it in its body
172
+ * (`const { tableAgent } = props as TableProps`).
173
+ */
174
+ private propElements;
169
175
  private walk;
170
176
  /**
171
177
  * `useRoomRegistration(catalog, …)` and `readQuery(declaration, …)` in a
@@ -173,11 +179,42 @@ export declare class PageAnalyzer {
173
179
  * `useLaneQuery()`), followed hook by hook.
174
180
  */
175
181
  private findRegistrations;
182
+ /**
183
+ * `useAgentFacts(agent, title, facts)` in a component's body, or in an app
184
+ * hook it calls: a display the page shows. Its binding is followed through
185
+ * the hook's arguments and the component's props to where it is written (a
186
+ * page's `<ReportFacts agent={{ … }} … />`), and read as a control's is. A
187
+ * binding the build cannot read is an error: the page would report facts
188
+ * the manifest does not record.
189
+ */
190
+ private findFacts;
191
+ /**
192
+ * The props of a component as the element that rendered it passed them,
193
+ * for reading a value built from them (a display's id from a prop, its
194
+ * description from a constant record by a prop): each read where it is
195
+ * written, in its own component's scope.
196
+ */
197
+ private scopeOf;
198
+ /** One `useAgentFacts` call: each binding it can report under, read where it is written. */
199
+ private recordFacts;
200
+ /**
201
+ * A display's `agent`, followed through the props of the components that
202
+ * pass it down to where it is written, with the scope it is written in.
203
+ * Null when an element on the way passes none: it then reports nothing.
204
+ */
205
+ private forwardedPropAgent;
206
+ /**
207
+ * The labels of a display's facts the build can read: the keys of the
208
+ * object the page passes, through constants, conditionals, spreads and the
209
+ * app's own functions that return one (`topicFacts(topic)`).
210
+ */
211
+ private factLabels;
176
212
  /** The catalog an expression names: a package's, by import, or the app's own, by module and export. */
177
213
  private catalogFor;
178
214
  /**
179
215
  * Whether a callee is `@ouispec/bindings`'s export of this name: imported
180
- * from the package (renamed or through a namespace import), or re-exported
216
+ * from the package or a subpath of it (`@ouispec/bindings/react`), renamed
217
+ * or through a namespace import, or re-exported
181
218
  * by the app's own module and resolved to the package's declaration.
182
219
  */
183
220
  private isBindingsExport;
@@ -285,6 +322,13 @@ export declare class PageAnalyzer {
285
322
  */
286
323
  private forwardedAgent;
287
324
  private control;
325
+ /**
326
+ * A design-system display where a page uses it: the binding it reports
327
+ * what it shows under, its own `agent`, or a composite's `slot` binding,
328
+ * else the first of its `parts` the page bound; and its facts' labels, the
329
+ * ones it always reports and those of its `itemsProp`.
330
+ */
331
+ private display;
288
332
  private entry;
289
333
  private checkRow;
290
334
  private binding;
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,cAAc,EAGnB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAwB,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAaL,KAAK,MAAM,EACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAE/D,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gDAAgD;IAChD,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;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;IACH,OAAO,CAAC,cAAc;IAwCtB,iGAAiG;IACjG,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,UAAU;IA0ClB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAsBpB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,OAAO;IAkMf;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAwDf,OAAO,CAAC,KAAK;IAwDb,OAAO,CAAC,QAAQ;IAehB,OAAO,CAAC,OAAO;IAgCf,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,OAAO;IA4Bf;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,WAAW;IAcnB;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAqDf,4FAA4F;IAC5F,OAAO,CAAC,YAAY;IAapB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAgCd;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IA6BtB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;CAoB1B;AA2ID,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,MAAM,EAAE,CAWnE"}
package/dist/analyze.js CHANGED
@@ -12,7 +12,7 @@ import { dirname, relative } from 'node:path';
12
12
  import ts from 'typescript';
13
13
  import { CALLBACK_PROP, effectKind, INTERACTIVE_HANDLERS, INTERACTIVE_TAGS, isAgentBinding, mappedOptions, } from '@ouispec/bindings';
14
14
  import { componentDeclaration } from './inputs.js';
15
- import { evaluate, hasJsxAttribute, humanizeId, isComparison, jsxAttribute, jsxText, objectProperty, resolveSymbol, stringLiterals, UNKNOWN, unwrap, } from './program.js';
15
+ import { evaluate, hasJsxAttribute, humanizeId, isComparison, jsxAttribute, jsxText, objectProperty, propertyName, resolveSymbol, stringLiterals, UNKNOWN, unwrap, } from './program.js';
16
16
  import { listedPackage } from './specifier.js';
17
17
  const ITERATORS = new Set(['map', 'flatMap']);
18
18
  export class PageAnalyzer {
@@ -141,16 +141,40 @@ export class PageAnalyzer {
141
141
  }
142
142
  /** The props a component destructures: local name → prop name. */
143
143
  destructuredProps(decl) {
144
+ return new Map([...this.propElements(decl)].map(([el, prop]) => [el.name.text, prop]));
145
+ }
146
+ /**
147
+ * Where a component destructures its props, each name with the prop it is:
148
+ * in its parameter (`({ agent })`), or from it in its body
149
+ * (`const { tableAgent } = props as TableProps`).
150
+ */
151
+ propElements(decl) {
144
152
  const fn = this.componentFunction(decl);
145
153
  const out = new Map();
146
154
  const param = fn?.parameters[0];
147
- if (param && ts.isObjectBindingPattern(param.name)) {
148
- for (const el of param.name.elements) {
149
- if (ts.isIdentifier(el.name)) {
150
- const prop = el.propertyName ? el.propertyName.getText() : el.name.text;
151
- out.set(el.name.text, prop);
155
+ const take = (pattern) => {
156
+ for (const el of pattern.elements) {
157
+ if (ts.isIdentifier(el.name) && !el.dotDotDotToken) {
158
+ out.set(el, el.propertyName ? el.propertyName.getText() : el.name.text);
152
159
  }
153
160
  }
161
+ };
162
+ if (param && ts.isObjectBindingPattern(param.name))
163
+ take(param.name);
164
+ const body = this.body(decl);
165
+ if (param && ts.isIdentifier(param.name) && body) {
166
+ const props = param.name.text;
167
+ // Anywhere in its body (a branch for one layout's props), but not in a function of its own.
168
+ const visit = (n) => {
169
+ if (ts.isVariableDeclaration(n) && ts.isObjectBindingPattern(n.name) && n.initializer) {
170
+ const init = unwrap(n.initializer);
171
+ if (ts.isIdentifier(init) && init.text === props)
172
+ take(n.name);
173
+ }
174
+ if (!ts.isFunctionLike(n))
175
+ ts.forEachChild(n, visit);
176
+ };
177
+ ts.forEachChild(body, visit);
154
178
  }
155
179
  return out;
156
180
  }
@@ -162,7 +186,7 @@ export class PageAnalyzer {
162
186
  if (!this.source.isAppFile(sf))
163
187
  return;
164
188
  out.components.add(decl);
165
- const key = `${sf.fileName}:${decl.pos}:${ctx.element ? `${ctx.element.getSourceFile().fileName}@${ctx.element.pos}` : ''}:${ctx.reach.map(r => JSON.stringify({ ...r, owner: undefined, setters: undefined })).join('>')}:${ctx.itemized}`;
189
+ const key = `${sf.fileName}:${decl.pos}:${ctx.trail ?? ''}:${ctx.reach.map(r => JSON.stringify({ ...r, owner: undefined, setters: undefined })).join('>')}:${ctx.itemized}`;
166
190
  if (seen.has(key) || ctx.depth > 40)
167
191
  return;
168
192
  seen.add(key);
@@ -171,6 +195,8 @@ export class PageAnalyzer {
171
195
  this.checkMappedImports(sf, out);
172
196
  // Rooms this component registers, itself or through the app's own hooks.
173
197
  this.findRegistrations(body, out, new Set());
198
+ // What it reports it shows (`useAgentFacts`), itself or through the app's own hooks.
199
+ this.findFacts(body, decl, ctx, out, new Set());
174
200
  const visit = (n) => {
175
201
  if (ts.isJsxSelfClosingElement(n) || ts.isJsxOpeningElement(n))
176
202
  this.element(n, decl, component, body, ctx, tabs, out, seen, isPage);
@@ -226,6 +252,193 @@ export class PageAnalyzer {
226
252
  };
227
253
  visit(node);
228
254
  }
255
+ /**
256
+ * `useAgentFacts(agent, title, facts)` in a component's body, or in an app
257
+ * hook it calls: a display the page shows. Its binding is followed through
258
+ * the hook's arguments and the component's props to where it is written (a
259
+ * page's `<ReportFacts agent={{ … }} … />`), and read as a control's is. A
260
+ * binding the build cannot read is an error: the page would report facts
261
+ * the manifest does not record.
262
+ */
263
+ findFacts(node, decl, ctx, out, seen, args = new Map()) {
264
+ const passed = (expr) => {
265
+ const e = unwrap(expr);
266
+ return ts.isIdentifier(e) && args.has(e.text) ? args.get(e.text) : expr;
267
+ };
268
+ const visit = (n) => {
269
+ if (ts.isCallExpression(n)) {
270
+ const callee = n.expression;
271
+ if (this.isBindingsExport(callee, 'useAgentFacts')) {
272
+ const [agent, title, facts] = n.arguments.map(passed);
273
+ this.recordFacts(agent, title, facts, decl, ctx, out);
274
+ }
275
+ else if (ts.isIdentifier(callee) && /^use[A-Z]/.test(callee.text)) {
276
+ const symbol = resolveSymbol(this.source.checker, callee);
277
+ const hook = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
278
+ if (hook && this.source.isAppFile(hook.getSourceFile())) {
279
+ const callArgs = n.arguments.map(passed);
280
+ const key = `${hook.getSourceFile().fileName}:${hook.pos}:${callArgs.map(a => a.getText()).join(',')}`;
281
+ if (!seen.has(key)) {
282
+ seen.add(key);
283
+ const body = this.body(hook);
284
+ const params = this.componentFunction(hook)?.parameters ?? [];
285
+ const inner = new Map();
286
+ params.forEach((param, i) => {
287
+ if (ts.isIdentifier(param.name) && callArgs[i])
288
+ inner.set(param.name.text, callArgs[i]);
289
+ });
290
+ if (body)
291
+ this.findFacts(body, decl, ctx, out, seen, inner);
292
+ }
293
+ }
294
+ }
295
+ }
296
+ ts.forEachChild(n, visit);
297
+ };
298
+ visit(node);
299
+ }
300
+ /**
301
+ * The props of a component as the element that rendered it passed them,
302
+ * for reading a value built from them (a display's id from a prop, its
303
+ * description from a constant record by a prop): each read where it is
304
+ * written, in its own component's scope.
305
+ */
306
+ scopeOf(owner, ctx) {
307
+ return id => {
308
+ const declared = this.source.checker.getSymbolAtLocation(id)?.valueDeclaration;
309
+ // Only the component's own destructured prop, not a local of the same name.
310
+ const prop = declared && ts.isBindingElement(declared) ? this.propElements(owner).get(declared) : undefined;
311
+ const from = prop !== undefined ? ctx.props.get(prop) : undefined;
312
+ return from ? { expr: from.expr, scope: this.scopeOf(from.owner, from.ctx) } : undefined;
313
+ };
314
+ }
315
+ /** One `useAgentFacts` call: each binding it can report under, read where it is written. */
316
+ recordFacts(agentArg, titleArg, factsArg, decl, ctx, out) {
317
+ if (!agentArg)
318
+ return;
319
+ // The title and the facts, where they are written.
320
+ const title = titleArg ? evaluate(this.source.checker, titleArg, 0, this.scopeOf(decl, ctx)) : UNKNOWN;
321
+ const labels = factsArg ? this.factLabels(this.throughProps(factsArg, decl, ctx).expr) : [];
322
+ for (const candidate of bindingCandidates(agentArg)) {
323
+ const forwarded = this.forwardedPropAgent(candidate, decl, ctx);
324
+ // Given no binding where it is used, it reports nothing.
325
+ if (!forwarded)
326
+ continue;
327
+ const { expr, scope } = forwarded;
328
+ for (const branch of bindingCandidates(expr)) {
329
+ const value = evaluate(this.source.checker, branch, 0, scope);
330
+ if (value === undefined || value === null)
331
+ continue;
332
+ // Where the binding is written: the call itself, or the element that passed it down.
333
+ const asf = branch.getSourceFile();
334
+ const at = { file: this.source.rel(asf), line: asf.getLineAndCharacterOfPosition(branch.getStart()).line + 1 };
335
+ if (value === UNKNOWN || typeof value !== 'object') {
336
+ out.errors.push({
337
+ ...at,
338
+ message: `useAgentFacts(…)'s binding must be readable at build time (\`${branch.getText().slice(0, 60)}\`): an object literal or a constant, so the manifest records the display`,
339
+ });
340
+ continue;
341
+ }
342
+ const agentObj = value;
343
+ if ('nonAgent' in agentObj) {
344
+ this.noteNonAgent(agentObj.nonAgent, branch);
345
+ continue;
346
+ }
347
+ const binding = this.binding(agentObj, at, 'useAgentFacts', out);
348
+ if (!binding)
349
+ continue;
350
+ out.displays.push({
351
+ site: `${at.file}:${branch.pos}`,
352
+ binding,
353
+ title: binding.title ?? (typeof title === 'string' ? title : ''),
354
+ labels,
355
+ reach: ctx.reach,
356
+ declaredIn: at.file,
357
+ line: at.line,
358
+ });
359
+ }
360
+ }
361
+ }
362
+ /**
363
+ * A display's `agent`, followed through the props of the components that
364
+ * pass it down to where it is written, with the scope it is written in.
365
+ * Null when an element on the way passes none: it then reports nothing.
366
+ */
367
+ forwardedPropAgent(expr, owner, ctx) {
368
+ const e = unwrap(expr);
369
+ let prop;
370
+ if (ts.isIdentifier(e))
371
+ prop = this.destructuredProps(owner).get(e.text);
372
+ else if (ts.isPropertyAccessExpression(e) && ts.isIdentifier(e.expression)) {
373
+ const param = this.componentFunction(owner)?.parameters[0];
374
+ if (param && ts.isIdentifier(param.name) && param.name.text === e.expression.text)
375
+ prop = e.name.text;
376
+ }
377
+ if (prop === undefined)
378
+ return { expr, scope: this.scopeOf(owner, ctx) };
379
+ const from = ctx.props.get(prop);
380
+ if (!from)
381
+ return ctx.element ? null : { expr, scope: this.scopeOf(owner, ctx) };
382
+ return this.forwardedPropAgent(from.expr, from.owner, from.ctx);
383
+ }
384
+ /**
385
+ * The labels of a display's facts the build can read: the keys of the
386
+ * object the page passes, through constants, conditionals, spreads and the
387
+ * app's own functions that return one (`topicFacts(topic)`).
388
+ */
389
+ factLabels(expr, depth = 0) {
390
+ if (depth > 6)
391
+ return [];
392
+ const e = unwrap(expr);
393
+ if (ts.isObjectLiteralExpression(e)) {
394
+ return [
395
+ ...new Set(e.properties.flatMap(p => {
396
+ if (ts.isPropertyAssignment(p)) {
397
+ if (ts.isComputedPropertyName(p.name)) {
398
+ const key = evaluate(this.source.checker, p.name.expression);
399
+ return typeof key === 'string' ? [key] : [];
400
+ }
401
+ const name = propertyName(p.name);
402
+ return name !== null ? [name] : [];
403
+ }
404
+ if (ts.isShorthandPropertyAssignment(p))
405
+ return [p.name.text];
406
+ if (ts.isSpreadAssignment(p))
407
+ return this.factLabels(p.expression, depth + 1);
408
+ return [];
409
+ })),
410
+ ];
411
+ }
412
+ if (ts.isConditionalExpression(e))
413
+ return [...new Set([...this.factLabels(e.whenTrue, depth + 1), ...this.factLabels(e.whenFalse, depth + 1)])];
414
+ if (ts.isIdentifier(e)) {
415
+ const symbol = resolveSymbol(this.source.checker, e);
416
+ const d = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
417
+ return d && ts.isVariableDeclaration(d) && d.initializer ? this.factLabels(d.initializer, depth + 1) : [];
418
+ }
419
+ if (ts.isCallExpression(e)) {
420
+ const symbol = resolveSymbol(this.source.checker, e.expression);
421
+ const fn = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
422
+ if (!fn || !this.source.isAppFile(fn.getSourceFile()))
423
+ return [];
424
+ const body = this.body(fn);
425
+ if (!body)
426
+ return [];
427
+ if (!ts.isBlock(body))
428
+ return this.factLabels(body, depth + 1);
429
+ const returned = [];
430
+ const visit = (n) => {
431
+ if (ts.isReturnStatement(n) && n.expression)
432
+ returned.push(...this.factLabels(n.expression, depth + 1));
433
+ // A nested function's returns are its own.
434
+ if (!ts.isFunctionLike(n))
435
+ ts.forEachChild(n, visit);
436
+ };
437
+ ts.forEachChild(body, visit);
438
+ return [...new Set(returned)];
439
+ }
440
+ return [];
441
+ }
229
442
  /** The catalog an expression names: a package's, by import, or the app's own, by module and export. */
230
443
  catalogFor(expr) {
231
444
  const pkg = this.importSource(expr);
@@ -244,7 +457,8 @@ export class PageAnalyzer {
244
457
  }
245
458
  /**
246
459
  * Whether a callee is `@ouispec/bindings`'s export of this name: imported
247
- * from the package (renamed or through a namespace import), or re-exported
460
+ * from the package or a subpath of it (`@ouispec/bindings/react`), renamed
461
+ * or through a namespace import, or re-exported
248
462
  * by the app's own module and resolved to the package's declaration.
249
463
  */
250
464
  isBindingsExport(callee, name) {
@@ -258,7 +472,10 @@ export class PageAnalyzer {
258
472
  let n = decl;
259
473
  while (n && !ts.isImportDeclaration(n))
260
474
  n = n.parent;
261
- if (n && ts.isImportDeclaration(n) && ts.isStringLiteral(n.moduleSpecifier) && n.moduleSpecifier.text === BINDINGS) {
475
+ if (n &&
476
+ ts.isImportDeclaration(n) &&
477
+ ts.isStringLiteral(n.moduleSpecifier) &&
478
+ (n.moduleSpecifier.text === BINDINGS || n.moduleSpecifier.text.startsWith(`${BINDINGS}/`))) {
262
479
  if (ts.isNamespaceImport(decl))
263
480
  return ts.isPropertyAccessExpression(e) && e.name.text === name;
264
481
  return ts.isImportSpecifier(decl) && !ts.isPropertyAccessExpression(e) && (decl.propertyName ?? decl.name).text === name;
@@ -562,14 +779,18 @@ export class PageAnalyzer {
562
779
  out.rooms.add(appRoom);
563
780
  const props = new Map();
564
781
  for (const attr of el.attributes.properties) {
565
- if (ts.isJsxAttribute(attr) &&
566
- attr.initializer &&
567
- ts.isJsxExpression(attr.initializer) &&
568
- attr.initializer.expression) {
782
+ if (!ts.isJsxAttribute(attr) || !attr.initializer)
783
+ continue;
784
+ // `title="Texts"` as much as `title={heading}`: a display's heading is often a literal.
785
+ if (ts.isStringLiteral(attr.initializer)) {
786
+ props.set(attr.name.getText(), { expr: attr.initializer, owner: decl, ctx });
787
+ }
788
+ else if (ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
569
789
  props.set(attr.name.getText(), { expr: attr.initializer.expression, owner: decl, ctx });
570
790
  }
571
791
  }
572
- this.walk(target, { reach, itemized, props, depth: ctx.depth + 1, element: el }, out, seen, false);
792
+ const trail = `${ctx.trail ?? ''}>${el.getSourceFile().fileName}@${el.pos}`;
793
+ this.walk(target, { reach, itemized, props, depth: ctx.depth + 1, element: el, trail }, out, seen, false);
573
794
  }
574
795
  /** The app's own component a tag names, through `lazy` and `React.lazy`; null for anything else. */
575
796
  appComponent(tag) {
@@ -896,10 +1117,10 @@ export class PageAnalyzer {
896
1117
  prop = e.name.text;
897
1118
  }
898
1119
  if (prop === undefined)
899
- return { expr };
1120
+ return { expr, scope: this.scopeOf(owner, ctx) };
900
1121
  const from = ctx.props.get(prop);
901
1122
  if (!from)
902
- return ctx.element ? { missing: ctx.element } : { expr };
1123
+ return ctx.element ? { missing: ctx.element } : { expr, scope: this.scopeOf(owner, ctx) };
903
1124
  return this.forwardedAgent(from.expr, from.owner, from.ctx);
904
1125
  }
905
1126
  // ─── One design-system control ─────────────────────────────────────────────
@@ -915,6 +1136,10 @@ export class PageAnalyzer {
915
1136
  // A wrapper may forward its own `agent` prop to the control it renders:
916
1137
  // the binding is then declared where the wrapper is used.
917
1138
  const forwarded = this.forwardedAgent(asExpr(jsxAttribute(el, 'agent')), decl, ctx);
1139
+ // One that only shows facts: given no binding where it is used, it reports nothing, and is no gap.
1140
+ const onlyDisplay = !!descriptor.display && !descriptor.kind && !descriptor.slots && !descriptor.entries;
1141
+ if (forwarded.missing && onlyDisplay)
1142
+ return;
918
1143
  if (forwarded.missing) {
919
1144
  const parent = forwarded.missing;
920
1145
  const psf = parent.getSourceFile();
@@ -929,7 +1154,10 @@ export class PageAnalyzer {
929
1154
  // A binding forwarded through a wrapper is declared where the wrapper is used,
930
1155
  // so each use is its own site, even when the uses sit in the wrapper's own file.
931
1156
  const isForwarded = !!agentExpr && agentExpr !== asExpr(jsxAttribute(el, 'agent'));
932
- const agent = agentExpr ? evaluate(this.source.checker, agentExpr) : undefined;
1157
+ // A display's binding may be built from the props it is given (`id: \`replai-${product}.sequences\``).
1158
+ const agent = agentExpr
1159
+ ? evaluate(this.source.checker, agentExpr, 0, onlyDisplay ? forwarded.scope : undefined)
1160
+ : undefined;
933
1161
  if (agentExpr && (agent === UNKNOWN || typeof agent !== 'object' || agent === null)) {
934
1162
  out.errors.push({
935
1163
  ...at,
@@ -958,31 +1186,13 @@ export class PageAnalyzer {
958
1186
  if (own)
959
1187
  reach = [...reach, own];
960
1188
  }
961
- // A display of facts: not a control; bound, it names what the page reports.
1189
+ // What it shows: bound, it names what the page reports. One that only
1190
+ // shows facts is not a control; a control or a composite that also reports
1191
+ // what it shows (a card bound to open, a list) goes on to its controls.
962
1192
  if (descriptor.display) {
963
- if (agentObj && !('nonAgent' in agentObj)) {
964
- const binding = this.binding(agentObj, at, tag, out);
965
- if (binding) {
966
- // Its facts' labels, read as a menu's entries are: literals, spreads, conditionals, a .map.
967
- const labelKey = descriptor.display.labelKey;
968
- const labels = [
969
- ...new Set(this.arrayOf(asExpr(jsxAttribute(el, descriptor.display.itemsProp)), []).flatMap(o => {
970
- const label = evaluate(this.source.checker, objectProperty(o, labelKey));
971
- return typeof label === 'string' ? [label] : [];
972
- })),
973
- ];
974
- out.displays.push({
975
- site: siteOf(),
976
- binding,
977
- title: binding.title ?? this.title(el, descriptor),
978
- labels,
979
- reach,
980
- declaredIn: at.file,
981
- line: at.line,
982
- });
983
- }
984
- }
985
- return;
1193
+ this.display(el, descriptor, agentObj, at, tag, siteOf, reach, out, this.scopeOf(decl, ctx));
1194
+ if (onlyDisplay)
1195
+ return;
986
1196
  }
987
1197
  // The control itself.
988
1198
  if (descriptor.kind) {
@@ -1087,6 +1297,63 @@ export class PageAnalyzer {
1087
1297
  }
1088
1298
  }
1089
1299
  }
1300
+ /**
1301
+ * A design-system display where a page uses it: the binding it reports
1302
+ * what it shows under, its own `agent`, or a composite's `slot` binding,
1303
+ * else the first of its `parts` the page bound; and its facts' labels, the
1304
+ * ones it always reports and those of its `itemsProp`.
1305
+ */
1306
+ display(el, descriptor, agentObj, at, tag, siteOf, reach, out,
1307
+ /** The props of the component it is used in, for a heading it is given (`label={title}`). */
1308
+ scope) {
1309
+ const display = descriptor.display;
1310
+ if (!agentObj || 'nonAgent' in agentObj)
1311
+ return;
1312
+ let value = agentObj;
1313
+ let part;
1314
+ if (display.slot !== undefined || display.parts?.length) {
1315
+ value = null;
1316
+ for (const key of [display.slot, ...(display.parts ?? [])]) {
1317
+ if (key === undefined)
1318
+ continue;
1319
+ const v = agentObj[key];
1320
+ if (!v || typeof v !== 'object')
1321
+ continue;
1322
+ // A `nonAgent` slot keeps what it shows out on purpose; a `nonAgent` part is passed over.
1323
+ if ('nonAgent' in v) {
1324
+ if (key === display.slot)
1325
+ return;
1326
+ continue;
1327
+ }
1328
+ value = v;
1329
+ part = key;
1330
+ break;
1331
+ }
1332
+ if (!value)
1333
+ return;
1334
+ }
1335
+ const binding = this.binding(value, at, part ? `${tag} ${part}` : tag, out);
1336
+ if (!binding)
1337
+ return;
1338
+ // Its facts' labels, read as a menu's entries are: literals, spreads, conditionals, a .map.
1339
+ const { itemsProp, labelKey } = display;
1340
+ const listed = itemsProp && labelKey
1341
+ ? this.arrayOf(asExpr(jsxAttribute(el, itemsProp)), []).flatMap(o => {
1342
+ const label = evaluate(this.source.checker, objectProperty(o, labelKey));
1343
+ return typeof label === 'string' ? [label] : [];
1344
+ })
1345
+ : [];
1346
+ out.displays.push({
1347
+ // A part's facts are under the part's own binding: the same site.
1348
+ site: siteOf(part ? `:${part}` : ''),
1349
+ binding,
1350
+ title: binding.title ?? this.title(el, descriptor, scope),
1351
+ labels: [...new Set([...(display.labels ?? []), ...listed])],
1352
+ reach,
1353
+ declaredIn: at.file,
1354
+ line: at.line,
1355
+ });
1356
+ }
1090
1357
  entry(obj, kind, callback, titleKey, _decl, component, reach, itemized, tag, base, out) {
1091
1358
  const cb = objectProperty(obj, callback);
1092
1359
  const agentExpr = objectProperty(obj, 'agent');
@@ -1163,7 +1430,7 @@ export class PageAnalyzer {
1163
1430
  ...(confirm === true ? { confirm: true } : {}),
1164
1431
  };
1165
1432
  }
1166
- title(el, descriptor) {
1433
+ title(el, descriptor, scope) {
1167
1434
  for (const prop of descriptor.titleProps) {
1168
1435
  if (prop === 'children') {
1169
1436
  const parent = ts.isJsxOpeningElement(el) ? el.parent : null;
@@ -1172,7 +1439,7 @@ export class PageAnalyzer {
1172
1439
  return text;
1173
1440
  continue;
1174
1441
  }
1175
- const v = evaluate(this.source.checker, asExpr(jsxAttribute(el, prop)));
1442
+ const v = evaluate(this.source.checker, asExpr(jsxAttribute(el, prop)), 0, scope);
1176
1443
  if (typeof v === 'string' && v.trim())
1177
1444
  return v.trim();
1178
1445
  }
@@ -1413,6 +1680,24 @@ export class PageAnalyzer {
1413
1680
  function asExpr(v) {
1414
1681
  return v === true ? undefined : v;
1415
1682
  }
1683
+ /**
1684
+ * The bindings an `agent` expression can be, each where it is written: both
1685
+ * branches of a conditional, the right of `&&`, either side of `??` and `||`
1686
+ * (`active ? agent : undefined`, `own ?? scope`).
1687
+ */
1688
+ function bindingCandidates(expr) {
1689
+ const e = unwrap(expr);
1690
+ if (ts.isConditionalExpression(e))
1691
+ return [...bindingCandidates(e.whenTrue), ...bindingCandidates(e.whenFalse)];
1692
+ if (ts.isBinaryExpression(e)) {
1693
+ const op = e.operatorToken.kind;
1694
+ if (op === ts.SyntaxKind.AmpersandAmpersandToken)
1695
+ return bindingCandidates(e.right);
1696
+ if (op === ts.SyntaxKind.QuestionQuestionToken || op === ts.SyntaxKind.BarBarToken)
1697
+ return [...bindingCandidates(e.left), ...bindingCandidates(e.right)];
1698
+ }
1699
+ return [e];
1700
+ }
1416
1701
  /** The object literals an expression can be: through conditionals and `&&`. */
1417
1702
  function objectsOf(expr) {
1418
1703
  const e = unwrap(expr);