@reqvire-org/ads 0.5.2 → 0.5.4

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.
Files changed (73) hide show
  1. package/dist/ads-errors.mjs +33 -26
  2. package/dist/analysis/design-usage.mjs +4 -20
  3. package/dist/analysis/mock-check.mjs +4 -5
  4. package/dist/analysis/owner-accessibility.mjs +4 -4
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +35 -3
  7. package/dist/analysis/owner-composition.mjs +75 -13
  8. package/dist/analysis/owner-source.mjs +64 -40
  9. package/dist/composed-contrast.mjs +165 -65
  10. package/dist/construction-output.mjs +12 -5
  11. package/dist/construction-spec.d.mts +125 -50
  12. package/dist/construction-spec.mjs +154 -81
  13. package/dist/corner-overpaint.mjs +5 -4
  14. package/dist/design-foundation.mjs +16 -0
  15. package/dist/design-usage.mjs +2 -8
  16. package/dist/emit/emission.mjs +0 -5
  17. package/dist/grid-lowering.mjs +3 -1
  18. package/dist/lowering-enter.mjs +6 -6
  19. package/dist/lowering-overlaps.mjs +6 -1
  20. package/dist/lowering-properties.mjs +3 -0
  21. package/dist/lowering-session.mjs +10 -0
  22. package/dist/lowering-transitions.mjs +1 -0
  23. package/dist/mcp/server-observation.mjs +6 -4
  24. package/dist/mcp/server-project.mjs +4 -1
  25. package/dist/owner-analysis-check.mjs +4 -1
  26. package/dist/owner-errors.mjs +2 -1
  27. package/dist/owner-lowering.mjs +10 -4
  28. package/dist/owner-scenarios.mjs +2 -22
  29. package/dist/ownership-model.mjs +15 -7
  30. package/dist/paint-contrast.mjs +6 -0
  31. package/dist/platform-features.mjs +6 -0
  32. package/dist/profile-macro.d.mts +7 -0
  33. package/dist/recipe-macro.d.mts +104 -45
  34. package/dist/recipe-model.mjs +19 -12
  35. package/dist/region-lowering.mjs +128 -121
  36. package/dist/role-vocabulary.d.mts +7 -0
  37. package/dist/role-vocabulary.mjs +7 -0
  38. package/dist/runtime-paint-contrast.mjs +5 -2
  39. package/dist/showcase/client.bundle.js +51 -51
  40. package/dist/showcase/http-client.bundle.js +13 -13
  41. package/dist/showcase/ui/ui.css +1 -1
  42. package/dist/showcase/ui/ui.js +6 -6
  43. package/dist/skills/ads-designer/references/accessibility.md +3 -4
  44. package/dist/skills/ads-designer/references/design-data.md +12 -6
  45. package/dist/skills/ads-designer/references/layout.md +7 -3
  46. package/dist/skills/ads-designer/references/motion.md +2 -1
  47. package/dist/skills/ads-designer/references/recipes.md +43 -19
  48. package/dist/skills/ads-import/references/design-data.md +12 -6
  49. package/dist/skills/ads-import/references/layout.md +7 -3
  50. package/dist/skills/ads-import/references/recipes.md +43 -19
  51. package/dist/skills/ads-migrate/SKILL.md +2 -0
  52. package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
  53. package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
  54. package/dist/skills/ads-port/references/design-data.md +12 -6
  55. package/dist/skills/ads-port/references/layout.md +7 -3
  56. package/dist/skills/ads-port/references/recipes.md +43 -19
  57. package/dist/spatial-model.mjs +2 -2
  58. package/dist/surface-contrast.mjs +6 -2
  59. package/dist/target-size.mjs +21 -3
  60. package/docs/ADS.md +9 -3
  61. package/docs/ARCHITECTURE.md +33 -23
  62. package/docs/CACHING.md +1 -1
  63. package/docs/CHANGELOG.md +181 -21
  64. package/docs/GUIDE.md +64 -19
  65. package/docs/LANGUAGE.md +169 -139
  66. package/docs/MCP.md +5 -1
  67. package/docs/MOTION.md +16 -3
  68. package/docs/PROFILE-KINDS.md +52 -5
  69. package/docs/RULES.md +16 -15
  70. package/package.json +1 -1
  71. package/dist/analysis/prose-owners.mjs +0 -57
  72. package/dist/prose-model.d.mts +0 -81
  73. package/dist/prose-model.mjs +0 -101
@@ -1,5 +1,5 @@
1
1
  import { selectedProfile, tokenDefinitionContexts } from "./design-foundation.mjs";
2
- import { inactiveCondition, layeredBackdrop, layeredContrast, opaque, readColor } from "./paint-contrast.mjs";
2
+ import { inactiveCondition, layeredBackdrop, layeredContrast, NON_TEXT_MINIMUM, opaque, readColor, unshown } from "./paint-contrast.mjs";
3
3
  import { describeUnresolved, textMinimum } from "./surface-contrast.mjs";
4
4
  import { sectionsDeclared } from "./token-sections.mjs";
5
5
  export const NO_COMPOSITION = { positions: [] }, compositionLimits = Object.freeze({ chains: 512, hops: 24, backdrops: 256 });
@@ -44,6 +44,13 @@ export function composedContrastFindings(inputs) {
44
44
  const selected = selectedProfile(foundation, surface), fields = selected.kind === "ok" && selected.value.kind === "surface" ? selected.value.fields : null, paint = fields === null ? null : { color: fields.get("color") ?? null, background: fields.get("background") ?? null, backgroundImage: fields.get("background-image") ?? null, opacity: fields.get("opacity") ?? null };
45
45
  paints.set(surface, paint);
46
46
  return paint;
47
+ }, provided = new Map, providesOf = (surface) => {
48
+ const known = provided.get(surface);
49
+ if (known !== void 0)
50
+ return known;
51
+ const selected = selectedProfile(foundation, surface), roles = new Map(selected.kind === "ok" && selected.value.kind === "surface" ? [...selected.value.fields].filter(([field]) => field.startsWith("--")) : []);
52
+ provided.set(surface, roles);
53
+ return roles;
47
54
  }, documentElement = {
48
55
  owner: null,
49
56
  component: "the document",
@@ -72,10 +79,20 @@ export function composedContrastFindings(inputs) {
72
79
  return "the base context";
73
80
  const named = reported(context);
74
81
  return `${[named.theme ?? "the base context", ...named.brand === void 0 ? [] : [named.brand]].join(", ")}${named.condition === void 0 ? "" : ` under ${named.condition}`}`;
75
- }, FIRST = { index: 0, label: nameOf(contexts[0]) }, chainRelated = new Map, chains = [], emit = (walk, certain, top) => {
82
+ }, FIRST = { index: 0, label: nameOf(contexts[0]) }, evaluationKey = (elements) => {
83
+ let sized = !1;
84
+ return elements.flatMap((placed) => {
85
+ const { fact } = placed, text = sized ? null : fact.text;
86
+ if (fact.text !== null)
87
+ sized = !0;
88
+ if (placed.boundary === void 0 && fact.surfaces !== null && fact.surfaces.length === 0 && text === null && fact.flow === "in" && fact.context === null && fact.exempt === null && !UA_COLOR.has(fact.tag) && !UA_FILL.has(fact.tag))
89
+ return [];
90
+ return [[placed.owner, fact.scope ?? `${fact.at.file}:${fact.at.line}:${fact.at.column}`, fact.tag, fact.surfaces?.map((state) => [state.condition, state.surface]) ?? null, text, fact.flow, fact.context, fact.exempt, placed.boundary?.reason ?? null]];
91
+ });
92
+ }, chainRelated = new Map, chains = [], emit = (walk, certain, top) => {
76
93
  if (walk.elements.some((placed) => placed.fact.exempt !== null))
77
94
  return null;
78
- const elements = [...walk.elements, top], key = JSON.stringify([certain, elements.map((placed) => [placed.owner, placed.component, placed.fact, placed.boundary ?? null])]);
95
+ const elements = [...walk.elements, top], key = JSON.stringify([certain, evaluationKey(elements)]);
79
96
  let related = chainRelated.get(key);
80
97
  if (related === void 0) {
81
98
  chainRelated.set(key, related = new Map);
@@ -103,10 +120,13 @@ export function composedContrastFindings(inputs) {
103
120
  return !1;
104
121
  continue;
105
122
  }
106
- if (arg === void 0 || arg.value.kind !== "literal")
123
+ const value = arg === void 0 ? void 0 : arg.value.kind === "literal" ? arg.value.value : null;
124
+ if (arg === void 0 || typeof value === "object" && value !== null) {
125
+ if (prop.omitted === !1)
126
+ return !1;
107
127
  continue;
108
- const value = arg.value.value;
109
- if (typeof value === "object" && value !== null)
128
+ }
129
+ if (arg.value.kind !== "literal")
110
130
  continue;
111
131
  switch (prop.test) {
112
132
  case "text": {
@@ -137,7 +157,7 @@ export function composedContrastFindings(inputs) {
137
157
  }
138
158
  return [...distinct.values()];
139
159
  }, argsOf = (placement) => placement.content.kind === "placement" && placement.content.spread === null ? placement.content.args : null, origin = (start, certain, run) => {
140
- const seen = new Set;
160
+ const seen = new Set, reached = new Set;
141
161
  let walks = 0, limited = !1;
142
162
  run({
143
163
  emit: (walk, top) => {
@@ -155,7 +175,13 @@ export function composedContrastFindings(inputs) {
155
175
  if (limited)
156
176
  note(source(start), `its compositions exceed ${compositionLimits.chains} distinct chains`, FIRST, walk.related);
157
177
  },
158
- limited: () => limited
178
+ limited: () => limited,
179
+ first: (state) => {
180
+ if (reached.has(state))
181
+ return !1;
182
+ reached.add(state);
183
+ return !0;
184
+ }
159
185
  });
160
186
  }, relatedOf = (point, message) => ({ site: source(point), message }), boundaryAt = (at, component, reason) => ({
161
187
  owner: at.file,
@@ -206,7 +232,7 @@ export function composedContrastFindings(inputs) {
206
232
  note(source(placement.at), `it is rendered through <${content.tag}>${of}, a component ADS does not analyze: whether that wrapper paints a backdrop or passes the text on is unknown`, FIRST, walk.related);
207
233
  return;
208
234
  }
209
- if (helper(owner, content.target)) {
235
+ if (helper(owner, content.target) && placement.component !== content.target.name) {
210
236
  note(source(placement.at), sameFileReason(content.tag), FIRST, walk.related);
211
237
  return;
212
238
  }
@@ -246,12 +272,16 @@ export function composedContrastFindings(inputs) {
246
272
  }
247
273
  function ascend(frame, walk, mode, steps) {
248
274
  const key = componentKey(frame.owner, frame.component);
275
+ if (!steps.first(JSON.stringify([key, frame.props, mode, evaluationKey(walk.elements), [...walk.recursed ?? []].sort()])))
276
+ return;
249
277
  if (mode === "data")
250
278
  for (const { owner, position } of placementsOf.get(key) ?? []) {
251
279
  if (!consistent(argsOf(position), frame.props))
252
280
  continue;
253
- const tag = position.content.kind === "placement" ? position.content.tag : frame.component;
254
- if (helper(owner, { file: frame.owner, name: frame.component })) {
281
+ const tag = position.content.kind === "placement" ? position.content.tag : frame.component, recursive = owner === frame.owner && position.component === frame.component, recursion = pointKey(position.at);
282
+ if (recursive && (walk.recursed ?? []).includes(recursion))
283
+ continue;
284
+ if (!recursive && helper(owner, { file: frame.owner, name: frame.component })) {
255
285
  steps.emit({ ...walk, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)] }, boundaryAt(position.at, position.component, sameFileReason(tag)));
256
286
  continue;
257
287
  }
@@ -264,7 +294,7 @@ export function composedContrastFindings(inputs) {
264
294
  continue;
265
295
  }
266
296
  for (const leaf of position.leaves.leaves)
267
- walkFrame({ owner, component: position.component, segments: leaf.segments, index: 0, props: leaf.props }, { ...walk, hops: walk.hops + 1, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)] }, mode, steps);
297
+ walkFrame({ owner, component: position.component, segments: leaf.segments, index: 0, props: leaf.props }, { ...walk, hops: walk.hops + 1, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)], ...recursive ? { recursed: [...walk.recursed ?? [], recursion] } : {} }, mode, steps);
268
298
  }
269
299
  for (const placement of plainOf.get(key) ?? [])
270
300
  steps.emit({ ...walk, related: [...walk.related, relatedOf(placement.at, `rendered as <${placement.tag}> in ${placement.module}`)] }, boundaryAt(placement.at, frame.component, `${frame.component} is placed as <${placement.tag}> in ${placement.module}, a plain module whose composition ADS does not follow, so the backdrop ${frame.component} is rendered on there is unknown`));
@@ -331,7 +361,18 @@ export function composedContrastFindings(inputs) {
331
361
  }
332
362
  }
333
363
  }
334
- const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1);
364
+ const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1), derived = new Set(chains.map(({ key }) => key));
365
+ for (const { key, chain } of chains.slice())
366
+ chain.elements.forEach((placed, index) => {
367
+ for (const pseudo of placed.fact.pseudo ?? []) {
368
+ const elements = [{ owner: placed.owner, component: placed.component, fact: { ...placed.fact, tag: `::${pseudo.name}`, surfaces: pseudo.surfaces, text: pseudo.text ?? placed.fact.text, pseudo: [] } }, ...chain.elements.slice(index)], derivedKey = JSON.stringify([chain.certain, pseudo.graphic, evaluationKey(elements)]);
369
+ if (derived.has(derivedKey))
370
+ continue;
371
+ derived.add(derivedKey);
372
+ chains.push({ key: derivedKey, chain: { elements, certain: chain.certain, graphic: pseudo.graphic } });
373
+ chainRelated.set(derivedKey, chainRelated.get(key) ?? new Map);
374
+ }
375
+ });
335
376
  for (const { key, chain } of chains)
336
377
  evaluateChain(chain, [...chainRelated.get(key)?.values() ?? []]);
337
378
  function conditionKey(placed, condition) {
@@ -379,66 +420,125 @@ export function composedContrastFindings(inputs) {
379
420
  note(b.site, b.reason, contextLabel(index), related);
380
421
  continue;
381
422
  }
382
- const terminal = b.layers.at(-1);
383
- if (terminal === void 0)
384
- continue;
385
- if (b.layers.length === 1 && terminal.element === f.element)
386
- continue;
387
- const above = opacityAbove(terminal.element);
388
- if (above !== void 0) {
389
- note(siteOf(above.placed, above.state.at), `${describeUnresolved({ kind: "opacity", value: paintOf(above.state.surface)?.opacity ?? "" })}: it fades the text and its backdrop together`, contextLabel(index), related);
390
- continue;
391
- }
392
- const backdrop = layeredBackdrop(context, b.layers);
393
- if (backdrop.kind === "unresolved") {
394
- const layer = b.layers[backdrop.layer] ?? terminal, placed = elements[layer.element];
395
- if (placed !== void 0)
396
- note(siteOf(placed, layer.state.at), describeUnresolved(backdrop.unresolved), contextLabel(index), related);
397
- continue;
398
- }
399
- const minimum = textMinimum(text, context), outcome = layeredContrast(context, f.value, backdrop.colors, minimum), foreElement = elements[f.element];
400
- if (foreElement === void 0)
401
- continue;
402
- switch (outcome.kind) {
403
- case "sufficient":
404
- break;
405
- case "unresolved":
406
- note(siteOf(foreElement, f.state.at), describeUnresolved(outcome.unresolved), contextLabel(index), related);
407
- break;
408
- case "insufficient": {
409
- const worst = b.layers[outcome.worst.layer] ?? terminal, backElement = elements[worst.element];
410
- if (backElement === void 0)
423
+ for (const variant of providedVariants(elements, f, b)) {
424
+ if (variant.requires.some((condition) => variant.excludes.includes(condition)))
425
+ continue;
426
+ const { value, layers } = variant, terminal = layers.at(-1);
427
+ if (terminal === void 0)
428
+ continue;
429
+ if (layers.length === 1 && terminal.element === f.element && !variant.changed)
430
+ continue;
431
+ const above = opacityAbove(terminal.element);
432
+ if (above !== void 0) {
433
+ note(siteOf(above.placed, above.state.at), `${describeUnresolved({ kind: "opacity", value: paintOf(above.state.surface)?.opacity ?? "" })}: it fades the text and its backdrop together`, contextLabel(index), related);
434
+ continue;
435
+ }
436
+ if (unshown(value, context))
437
+ continue;
438
+ const backdrop = layeredBackdrop(context, layers);
439
+ if (backdrop.kind === "unresolved") {
440
+ const layer = layers[backdrop.layer] ?? terminal, placed = elements[layer.element];
441
+ if (placed !== void 0)
442
+ note(siteOf(placed, layer.state.at), describeUnresolved(backdrop.unresolved), contextLabel(index), related);
443
+ continue;
444
+ }
445
+ const minimum = chain.graphic === !0 ? NON_TEXT_MINIMUM : textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
446
+ if (foreElement === void 0)
447
+ continue;
448
+ switch (outcome.kind) {
449
+ case "sufficient":
450
+ break;
451
+ case "unresolved":
452
+ note(siteOf(foreElement, f.state.at), describeUnresolved(outcome.unresolved), contextLabel(index), related);
411
453
  break;
412
- const backPaint = paintOf(worst.state.surface), backToken = (outcome.worst.image ? backPaint?.backgroundImage : backPaint?.background) ?? worst.state.surface, foregroundSite = siteOf(foreElement, f.state.at), backdropSite = siteOf(backElement, worst.state.at);
413
- if (!chain.certain) {
414
- note(foregroundSite.kind === "source" ? foregroundSite : backdropSite, `the expression it renders may be text: ${tokenOf(f.value)} on ${tokenOf(backToken)} is ${outcome.ratio}:1, below ${minimum}:1, if it is`, contextLabel(index), related);
454
+ case "insufficient": {
455
+ const worst = layers[outcome.worst.layer] ?? terminal, backElement = elements[worst.element];
456
+ if (backElement === void 0)
457
+ break;
458
+ const backPaint = paintOf(worst.state.surface), backToken = (outcome.worst.image ? backPaint?.backgroundImage : backPaint?.background) ?? worst.state.surface, foregroundSite = siteOf(foreElement, f.state.at), backdropSite = siteOf(backElement, worst.state.at);
459
+ if (!chain.certain) {
460
+ note(foregroundSite.kind === "source" ? foregroundSite : backdropSite, `the expression it renders may be text: ${tokenOf(value)} on ${tokenOf(backToken)} is ${outcome.ratio}:1, below ${minimum}:1, if it is`, contextLabel(index), related);
461
+ break;
462
+ }
463
+ const terminalElement = elements[terminal.element], over = worst === terminal || terminalElement === void 0 ? null : {
464
+ side: { component: terminalElement.component, surface: terminal.state.surface, token: tokenOf(paintOf(terminal.state.surface)?.background ?? terminal.state.surface) },
465
+ site: siteOf(terminalElement, terminal.state.at)
466
+ }, groupKey = JSON.stringify([siteKey(foregroundSite), siteKey(backdropSite), value, backToken, over === null ? null : siteKey(over.site)]), group = failures.get(groupKey) ?? {
467
+ over,
468
+ site: foregroundSite.kind === "source" ? foregroundSite : backdropSite,
469
+ foreground: { component: foreElement.component, surface: f.state.surface, token: tokenOf(value) },
470
+ background: { component: backElement.component, surface: worst.state.surface, token: tokenOf(backToken) },
471
+ foregroundSite,
472
+ backdropSite,
473
+ contexts: new Map,
474
+ related: new Map
475
+ };
476
+ failures.set(groupKey, group);
477
+ const failure = { ratio: outcome.ratio, minimum, foreground: outcome.foreground, background: outcome.background, states: [stateOf(f.requires), stateOf(b.requires.at(-1) ?? null)] }, known = group.contexts.get(index);
478
+ if (known === void 0 || failure.ratio < known.ratio)
479
+ group.contexts.set(index, failure);
480
+ for (const item of related)
481
+ group.related.set(siteKey(item.site), item);
415
482
  break;
416
483
  }
417
- const terminalElement = elements[terminal.element], over = worst === terminal || terminalElement === void 0 ? null : {
418
- side: { component: terminalElement.component, surface: terminal.state.surface, token: tokenOf(paintOf(terminal.state.surface)?.background ?? terminal.state.surface) },
419
- site: siteOf(terminalElement, terminal.state.at)
420
- }, groupKey = JSON.stringify([siteKey(foregroundSite), siteKey(backdropSite), f.value, backToken, over === null ? null : siteKey(over.site)]), group = failures.get(groupKey) ?? {
421
- over,
422
- site: foregroundSite.kind === "source" ? foregroundSite : backdropSite,
423
- foreground: { component: foreElement.component, surface: f.state.surface, token: tokenOf(f.value) },
424
- background: { component: backElement.component, surface: worst.state.surface, token: tokenOf(backToken) },
425
- foregroundSite,
426
- backdropSite,
427
- contexts: new Map,
428
- related: new Map
429
- };
430
- failures.set(groupKey, group);
431
- const failure = { ratio: outcome.ratio, minimum, foreground: outcome.foreground, background: outcome.background, states: [stateOf(f.requires), stateOf(b.requires.at(-1) ?? null)] }, known = group.contexts.get(index);
432
- if (known === void 0 || failure.ratio < known.ratio)
433
- group.contexts.set(index, failure);
434
- for (const item of related)
435
- group.related.set(siteKey(item.site), item);
436
- break;
437
484
  }
438
485
  }
439
486
  }
440
487
  });
441
488
  }
489
+ function providedVariants(elements, f, b) {
490
+ const base = { value: f.value, layers: b.layers, requires: [...f.requires === null ? [] : [f.requires], ...b.requires], excludes: [...f.excludes, ...b.excludes], changed: !1 };
491
+ if (!elements.some((placed) => (placed.fact.surfaces ?? []).some((state) => providesOf(state.surface).size > 0)))
492
+ return [base];
493
+ const resolve = (value, from, depth) => {
494
+ const tokens = [...new Set([...value.matchAll(/var\(\s*(--[\w-]+)/g)].map((match) => match[1] ?? ""))];
495
+ let results = [{ value, requires: [], excludes: [], changed: !1 }];
496
+ for (const token of tokens) {
497
+ const options = depth > 4 ? [] : bindings(token, from, depth);
498
+ if (options.length === 0)
499
+ continue;
500
+ results = results.flatMap((result) => options.map((option) => ({
501
+ value: option.value === null ? result.value : result.value.replaceAll(new RegExp(`var\\(\\s*${token}\\s*\\)`, "g"), option.value),
502
+ requires: [...result.requires, ...option.requires],
503
+ excludes: [...result.excludes, ...option.excludes],
504
+ changed: result.changed || option.value !== null
505
+ })));
506
+ if (results.length > compositionLimits.backdrops)
507
+ return results.slice(0, compositionLimits.backdrops);
508
+ }
509
+ return results;
510
+ }, bindings = (token, from, depth) => {
511
+ const out = [];
512
+ let passed = [];
513
+ for (let index = from;index < elements.length; index++) {
514
+ const placed = elements[index];
515
+ if (placed === void 0)
516
+ break;
517
+ const states = (placed.fact.surfaces ?? []).filter((state) => providesOf(state.surface).has(token));
518
+ if (states.length === 0)
519
+ continue;
520
+ const conditions = states.flatMap((state) => state.condition === null ? [] : [conditionKey(placed, state.condition)]);
521
+ for (const state of states) {
522
+ const raw = providesOf(state.surface).get(token) ?? "", requires = state.condition === null ? [] : [conditionKey(placed, state.condition)], excludes = state.condition === null ? [...passed, ...conditions] : passed;
523
+ for (const inner of resolve(raw, index, depth + 1))
524
+ out.push({ value: inner.value, requires: [...requires, ...inner.requires], excludes: [...excludes, ...inner.excludes] });
525
+ }
526
+ if (states.some((state) => state.condition === null))
527
+ return out;
528
+ passed = [...passed, ...conditions];
529
+ }
530
+ out.push({ value: null, requires: [], excludes: passed });
531
+ return out;
532
+ };
533
+ let variants = resolve(f.value, f.element, 0).map((fore) => ({ value: fore.value, layers: [], requires: [...base.requires, ...fore.requires], excludes: [...base.excludes, ...fore.excludes], changed: fore.changed }));
534
+ for (const layer of b.layers) {
535
+ const options = layer.background === null ? [null] : resolve(layer.background, layer.element, 0);
536
+ variants = variants.flatMap((variant) => options.map((option) => option === null ? { ...variant, layers: [...variant.layers, layer] } : { value: variant.value, layers: [...variant.layers, { ...layer, background: option.value }], requires: [...variant.requires, ...option.requires], excludes: [...variant.excludes, ...option.excludes], changed: variant.changed || option.changed }));
537
+ if (variants.length > compositionLimits.backdrops)
538
+ variants = variants.slice(0, compositionLimits.backdrops);
539
+ }
540
+ return variants;
541
+ }
442
542
  function foregroundOptions(elements) {
443
543
  const options = [];
444
544
  let excludes = [];
@@ -48,7 +48,12 @@ export function output(root, operation, reject, profile) {
48
48
  use(own);
49
49
  declarations.push([name, own]);
50
50
  }
51
- checked(session.write({ selector, conditions: condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], values: declarations, important: !1 }));
51
+ const conditions = condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], roles = declarations.filter(([property]) => property.startsWith("--"));
52
+ if (roles.length > 0)
53
+ checked(session.writeProvidedRoles({ selector, conditions, values: roles, important: !1 }));
54
+ const rest = declarations.filter(([property]) => !property.startsWith("--"));
55
+ if (rest.length > 0 || roles.length === 0)
56
+ checked(session.write({ selector, conditions, values: rest, important: !1 }));
52
57
  },
53
58
  tree: (node) => checked(session.writeTree(node, root)),
54
59
  document: (rule) => session.writeDocument(rule),
@@ -197,16 +202,18 @@ export function writeEnter(out, profile, selector, enter, base, states, slots, t
197
202
  out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
198
203
  return { group: lowered.value.group, blurred: lowered.value.blurred };
199
204
  }
200
- export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing"];
205
+ export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing", "text-decoration-color", "text-decoration-thickness", "text-underline-offset"];
206
+ const STATE_TEXT_INITIAL = { "text-decoration-color": "currentcolor", "text-decoration-thickness": "auto", "text-underline-offset": "auto" };
201
207
  export function writeStateText(out, profile, element, base, texts, selector, reject) {
202
208
  for (const { condition, text } of texts) {
203
- if (base["font-size"] === void 0)
209
+ const fields = profile.of(text, "text"), changed = [...new Set([...Object.keys(base), ...Object.keys(fields)])].filter((property) => base[property] !== fields[property]);
210
+ if (base["font-size"] === void 0 && changed.some((property) => property === "font-weight" || property === "letter-spacing"))
204
211
  return reject({ kind: "state-text-unbound", element, profile: text });
205
- const fields = profile.of(text, "text"), changed = [...new Set([...Object.keys(base), ...Object.keys(fields)])].filter((property) => base[property] !== fields[property]), moved = changed.find((property) => !STATE_TEXT_PROPERTIES.includes(property));
212
+ const moved = changed.find((property) => !STATE_TEXT_PROPERTIES.includes(property));
206
213
  if (moved !== void 0)
207
214
  return reject({ kind: "state-text-field", element, profile: text, property: moved });
208
215
  if (changed.length > 0)
209
- out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? "normal"])));
216
+ out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? STATE_TEXT_INITIAL[property] ?? "normal"])));
210
217
  }
211
218
  }
212
219
  export function writePlays(out, profile, foundation, element, plays, selector, taken, reject) {
@@ -2,7 +2,6 @@ import { type Result } from "./result.mjs";
2
2
  import type { ColorScheme } from "./asset-declaration.mjs";
3
3
  import { type Json, type JsonObject } from "./json.mjs";
4
4
  import { type ConditionProblem } from "./state-conditions.mjs";
5
- import { type ProseElementName } from "./prose-model.mjs";
6
5
  export type ConstructionKind = "control" | "artwork" | "region" | "grid";
7
6
  export type SpecFailure = {
8
7
  readonly kind: "field-unsupported";
@@ -76,6 +75,8 @@ export interface TextPart {
76
75
  readonly wrap: ControlLabelWrap;
77
76
  /** How the label's lines sit in its box (`text-align`): it shows once the label wraps or the control is wider than it. */
78
77
  readonly align: TextAlign | null;
78
+ /** `fill`: in an inline control the label takes the room the control's other content leaves, so a visual after it sits at the far end. */
79
+ readonly extent: "content" | "fill";
79
80
  }
80
81
  /** A state effect on a control's visual part, bound to the motion profile. */
81
82
  /** A control's artwork effect under an owner state. The three scales are one channel: whole, or one axis only (a blink). */
@@ -112,7 +113,7 @@ export interface RootPressState {
112
113
  readonly path: string;
113
114
  }
114
115
  /** The paints a surface treatment can transition, as CSS transition properties. */
115
- export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"];
116
+ export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"];
116
117
  export type PaintChannel = (typeof PAINT_CHANNELS)[number];
117
118
  /** The motion profile that times a transition: the nearest recipe's motion slot, or a named motion profile. */
118
119
  export type MotionBinding = {
@@ -188,6 +189,7 @@ export interface StickySpec {
188
189
  /** What an entering element moves by: each reads one field of the entrance's motion profile. */
189
190
  export declare const ENTER_MOVEMENTS: {
190
191
  readonly translate: "distance";
192
+ readonly translateInline: "distance";
191
193
  readonly scale: "scale";
192
194
  readonly rotate: "angle";
193
195
  };
@@ -200,7 +202,7 @@ export type EnterDriver = {
200
202
  readonly kind: "first-render";
201
203
  };
202
204
  /**
203
- * `enter: { from: { surface?, translate? | scale? | rotate? }, motion }`: the element starts from a
205
+ * `enter: { from: { surface?, translate? | translateInline? | scale? | rotate? }, motion }`: the element starts from a
204
206
  * declared look and settles into its own. The starting surface states only `opacity` and `blur`
205
207
  * (checked when it lowers); at most one movement, read from the entrance's motion profile.
206
208
  */
@@ -224,16 +226,60 @@ export interface PaintTransition {
224
226
  * textarea (a colour). `progressValue` is the filled part of a `<progress>` (a background): the part's own
225
227
  * surface is its track.
226
228
  */
227
- export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue"];
229
+ export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue", "marker", "before"];
228
230
  export type PseudoElement = (typeof PSEUDO_ELEMENTS)[number];
229
- /** The elements that have each pseudo-element: a treatment on any other element would never match. */
231
+ /** Elements that never render generated content or a marker: a `before` treatment there would never show. */
232
+ export declare const REPLACED_ELEMENTS: readonly string[];
233
+ /**
234
+ * The elements that have each pseudo-element: a treatment on any other element would never match. A list item's
235
+ * marker is on `li` and `summary` (a disclosure's marker); `before` is on any element that is not replaced.
236
+ */
230
237
  export declare const PSEUDO_HOSTS: {
231
- readonly [P in PseudoElement]: readonly string[];
238
+ readonly [P in PseudoElement]: readonly string[] | "non-replaced";
232
239
  };
233
- /** A surface (colour only) on a part's pseudo-element, with owner-state treatments. */
240
+ /** Whether `element` has the pseudo-element `pseudo`. */
241
+ export declare const pseudoHosted: (pseudo: PseudoElement, element: string) => boolean;
242
+ /** The number systems a marker or a counter is written in, and the bullet shapes. */
243
+ export declare const MARKER_STYLES: readonly ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
244
+ export type MarkerStyle = (typeof MARKER_STYLES)[number];
245
+ /** The number systems a counter's generated content may use. */
246
+ export declare const COUNTER_STYLES: readonly ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
247
+ export type CounterStyle = (typeof COUNTER_STYLES)[number];
248
+ /**
249
+ * Generated content a marker or a `before` pseudo-element shows: a counter's value (`counter`), or every level of
250
+ * a nested counter joined by `separator` (`counters`: 1.1.2), in a number system, between short literals.
251
+ */
252
+ export interface GeneratedContent {
253
+ readonly kind: "counter" | "counters";
254
+ readonly name: string;
255
+ readonly style: CounterStyle;
256
+ readonly separator: string;
257
+ readonly prefix: string;
258
+ readonly suffix: string;
259
+ }
260
+ /**
261
+ * A rule between an element's consecutive children (`between: { surface, frame }`): the frame profile's border width
262
+ * and style, painted by the surface's `border-color`, before every child but the first, on the arrangement's axis (a
263
+ * hairline between table rows or settings rows, none after the last).
264
+ */
265
+ export interface BetweenRule {
266
+ readonly surface: string;
267
+ readonly frame: string;
268
+ }
269
+ /** An element's counters (`counter-reset`, `counter-increment`): where a count starts and what it counts. */
270
+ export interface CounterSpec {
271
+ readonly reset: string | null;
272
+ readonly increment: string | null;
273
+ }
274
+ /**
275
+ * A pseudo-element's treatment: a colour-only surface (with owner-state treatments) for a placeholder, a progress
276
+ * fill or a marker; a marker's or generated content's weight and numerals (`text`); generated content.
277
+ */
234
278
  export interface PseudoTreatment {
235
279
  readonly pseudo: PseudoElement;
236
- readonly surface: string;
280
+ readonly surface: string | null;
281
+ readonly text: string | null;
282
+ readonly content: GeneratedContent | null;
237
283
  readonly when: readonly StateTreatment[];
238
284
  }
239
285
  export type ControlSpec = ControlCommon & ({
@@ -327,46 +373,7 @@ export interface ArtworkSpec {
327
373
  * arrangement. `layered` stacks every declared child part in one grid area,
328
374
  * painted in DOM order.
329
375
  */
330
- export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered" | "prose";
331
- /**
332
- * One element of a prose recipe (./prose-model.mts): the profiles its plain markup takes, by name.
333
- * `spaceBefore` replaces the rhythm before a block (more space above a heading); `indent` is a
334
- * list's start inset; `marker` a colour-only surface for a list item's marker.
335
- */
336
- export interface ProseElement {
337
- readonly name: ProseElementName;
338
- readonly path: string;
339
- readonly text: string | null;
340
- readonly surface: string | null;
341
- readonly frame: string | null;
342
- readonly when: readonly StateTreatment[];
343
- readonly spaceBefore: SlotBinding | null;
344
- /** The space between a block and whatever follows it, in place of the rhythm (a heading closer to its text); the larger of it and the next block's own `spaceBefore`. */
345
- readonly spaceAfter: SlotBinding | null;
346
- readonly indent: SlotBinding | null;
347
- readonly marker: string | null;
348
- /** Where a jump to the block lands (a heading with an id). */
349
- readonly anchorClear: SlotBinding | null;
350
- /** A text profile whose weight an item's marker takes (bold numbers and bullets). */
351
- readonly markerText: string | null;
352
- /** An unordered list's marker shape at each depth of nesting, outermost first; deeper lists keep the last. */
353
- readonly markers: readonly ProseMarker[];
354
- }
355
- export declare const PROSE_MARKERS: readonly ["disc", "circle", "square"];
356
- export type ProseMarker = (typeof PROSE_MARKERS)[number];
357
- /** `layout: "prose"`: the space between blocks and the elements the recipe styles, in authored order. */
358
- export interface ProseSpec {
359
- readonly rhythm: SlotBinding | null;
360
- readonly elements: readonly ProseElement[];
361
- /**
362
- * `elements.component`: the space around a component placed directly among the blocks (a callout, a code
363
- * block with its own owner). Its design is its owner's; only the space the flow gives it is prose's.
364
- */
365
- readonly component: {
366
- readonly spaceBefore: SlotBinding | null;
367
- readonly spaceAfter: SlotBinding | null;
368
- } | null;
369
- }
376
+ export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered";
370
377
  /** The scroll-snap axis and strictness a scrolling element declares (`scroll-snap-type`), on logical axes: they follow the writing mode, as `overflow` does. */
371
378
  export declare const SNAP_TYPES: readonly ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"];
372
379
  export type SnapType = (typeof SNAP_TYPES)[number];
@@ -481,6 +488,18 @@ export type RegionFrame =
481
488
  */
482
489
  export declare const FRAME_CORNERS: readonly ["start-start", "start-end", "end-start", "end-end"];
483
490
  export type FrameCorner = (typeof FRAME_CORNERS)[number];
491
+ /**
492
+ * A frame profile's own radius for one corner (`startStartRadius` …): it replaces the profile's `radius`
493
+ * on that corner (a chat bubble's small tail corner). A corner with neither is square.
494
+ */
495
+ export declare const CORNER_RADIUS_FIELDS: {
496
+ readonly "start-start": "start-start-radius";
497
+ readonly "start-end": "start-end-radius";
498
+ readonly "end-start": "end-start-radius";
499
+ readonly "end-end": "end-end-radius";
500
+ };
501
+ /** The radius a frame's fields give one corner, or `undefined` where it is square. */
502
+ export declare const cornerRadius: (field: (name: string) => string | undefined, corner: FrameCorner) => string | undefined;
484
503
  /** A region root's frame under one named condition: other ruled sides, other rounded corners, or both. */
485
504
  export interface FrameCondition {
486
505
  readonly condition: string;
@@ -574,6 +593,13 @@ export type PartContent = {
574
593
  readonly stroke: string;
575
594
  } | {
576
595
  readonly kind: "element";
596
+ }
597
+ /**
598
+ * A public component placed with the part's marker (`<Heading className="ux-article-heading" …/>`), as a grid
599
+ * cell is: its interior is its owner's, so the part takes placement only (its space, extent, visibility).
600
+ */
601
+ | {
602
+ readonly kind: "component";
577
603
  };
578
604
  /** A state treatment: an owner condition selecting a surface profile. */
579
605
  export type StateTreatment = readonly [condition: string, surface: string];
@@ -659,7 +685,31 @@ export interface RegionPart {
659
685
  * of a checkbox whose `<input>` is hidden) and shows the focus indicator while that control has keyboard focus.
660
686
  */
661
687
  readonly focusOf: string | null;
688
+ /**
689
+ * `drawnBy: "<sibling part>"`: this part is a native control (a checkbox's `<input>`) that the named part draws.
690
+ * It is invisible and takes no room, laid over that part at its frame's size, so pointer and keyboard still
691
+ * reach the real control. The drawing part follows it and shows its focus (`focus: { of }`).
692
+ */
693
+ readonly drawnBy: string | null;
662
694
  readonly required: boolean;
695
+ /**
696
+ * `repeat: true`: the part's element renders once per item of a list (`tabs.map(…)`), any number of times
697
+ * (at least once when `required`). Every instance takes the part's construction; consecutive instances are
698
+ * neighbours of their arrangement (a target's hit area and spacing are checked against the next one).
699
+ */
700
+ readonly repeat: boolean;
701
+ /**
702
+ * In a `stack`: the space before this part, in place of the stack's gap (a heading further from what precedes
703
+ * it), and the space between it and whatever follows. Where one part's space after meets the next part's
704
+ * space before, the larger applies. A spacing slot field.
705
+ */
706
+ readonly spaceBefore: SlotBinding | null;
707
+ readonly spaceAfter: SlotBinding | null;
708
+ /**
709
+ * The part's own spacing profile: its `spaceBefore` and `spaceAfter` fields are the part's space before and after
710
+ * it, where a flow needs more distances than one spacing profile's fields (a heading 44 px above, 14 px below).
711
+ */
712
+ readonly spacing: string | null;
663
713
  readonly content: PartContent;
664
714
  readonly textEdge: readonly string[];
665
715
  readonly textLayout: TextLayout;
@@ -701,6 +751,15 @@ export interface RegionPart {
701
751
  readonly sticky: StickySpec | null;
702
752
  /** Treatments of the part's pseudo-elements, at most one per pseudo-element. */
703
753
  readonly pseudo: readonly PseudoTreatment[];
754
+ /** Where a count starts (`counter-reset`) and what the part counts (`counter-increment`). */
755
+ readonly counter: CounterSpec | null;
756
+ /** A rule between the part's consecutive children (a table body's rows). */
757
+ readonly between: BetweenRule | null;
758
+ /**
759
+ * `presence: "assistive"`: the part is hidden on screen and still read by assistive technology (a table's caption, a
760
+ * skip link's text, an icon-only control's label); `"visible"` otherwise.
761
+ */
762
+ readonly presence: "visible" | "assistive";
704
763
  /** A nested recipe arranging this part's children. */
705
764
  readonly arrangement: Arrangement | null;
706
765
  readonly parts: readonly RegionPart[];
@@ -761,6 +820,14 @@ export interface Backdrop {
761
820
  export interface RegionSpec {
762
821
  readonly kind: "region";
763
822
  readonly source: JsonObject;
823
+ /** The root's own pseudo-elements: a list item's marker, generated content before the root. */
824
+ readonly pseudo: readonly PseudoTreatment[];
825
+ /** Where a count starts on the root and what the root counts. */
826
+ readonly counter: CounterSpec | null;
827
+ /** A list's marker style at each nesting depth, outermost first. */
828
+ readonly markers: readonly MarkerStyle[];
829
+ /** A rule between the root's consecutive children. */
830
+ readonly between: BetweenRule | null;
764
831
  /** `null` for a treatment fragment without a profile. */
765
832
  readonly profile: string | null;
766
833
  readonly select: Readonly<Record<string, string>>;
@@ -786,8 +853,6 @@ export interface RegionSpec {
786
853
  readonly textWhen: readonly StateText[];
787
854
  /** The root's frame under one named condition; `null` when it is the same at every width. */
788
855
  readonly frameAt: FrameCondition | null;
789
- /** The elements a prose root styles; `null` for every other layout. */
790
- readonly prose: ProseSpec | null;
791
856
  /** Where a jump to the root lands; never on a top-layer root, which is not in the page's flow. */
792
857
  readonly anchorClear: SlotBinding | null;
793
858
  /** The geometry the root takes under owner states; never on a top-layer root. */
@@ -813,6 +878,14 @@ export type SpatialValue = string | number | boolean | readonly (string | number
813
878
  export type SpatialValues = readonly (readonly [field: string, value: SpatialValue])[];
814
879
  export interface GridCell {
815
880
  readonly selector: string;
881
+ /** `required: false`: the cell may be absent (an optional notice); it renders at most once unless repeated. */
882
+ readonly required: boolean;
883
+ /**
884
+ * `repeat: true`: the cell renders once per item of a list, any number of times (at least once when required).
885
+ * Its instances flow one after another: it auto-places at every tier (`start: "auto"`, implied) and takes no
886
+ * row of its own; its span may be `"full"` or a number.
887
+ */
888
+ readonly repeat: boolean;
816
889
  readonly values: SpatialValues;
817
890
  /** Breakpoint tier → placement changes from that tier on. */
818
891
  readonly at: readonly (readonly [tier: string, values: SpatialValues])[];
@@ -850,6 +923,8 @@ export interface DeclaredPart {
850
923
  readonly path: string;
851
924
  readonly selector: string;
852
925
  readonly required: boolean;
926
+ /** Rendered once per item of a list: any number of instances (see {@link RegionPart.repeat}). */
927
+ readonly repeat: boolean;
853
928
  readonly kind: RegionPartContent;
854
929
  /** Enclosing declared parts' selectors, outermost first: the part is a child of the last. */
855
930
  readonly within: readonly string[];