@reqvire-org/ads 0.5.3 → 0.5.5

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 (98) hide show
  1. package/dist/ads-errors.mjs +105 -8
  2. package/dist/analysis/client-directive.mjs +26 -0
  3. package/dist/analysis/externals.mjs +47 -0
  4. package/dist/analysis/module-graph.mjs +6 -0
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +14 -2
  7. package/dist/analysis/owner-composition.mjs +32 -4
  8. package/dist/analysis/owner-source.mjs +121 -17
  9. package/dist/border-paint.mjs +34 -0
  10. package/dist/check.mjs +2 -0
  11. package/dist/composed-contrast.mjs +34 -12
  12. package/dist/construction-output.mjs +58 -31
  13. package/dist/construction-spec.d.mts +111 -15
  14. package/dist/construction-spec.mjs +129 -20
  15. package/dist/corner-overpaint.mjs +3 -1
  16. package/dist/design-foundation.mjs +18 -4
  17. package/dist/emit/owner-emission-cache.mjs +1 -1
  18. package/dist/end-alignment.mjs +69 -0
  19. package/dist/external-macro.d.mts +20 -0
  20. package/dist/external-macro.mjs +12 -0
  21. package/dist/finding-rules.mjs +3 -0
  22. package/dist/forced-colors.mjs +81 -0
  23. package/dist/frame-regions.mjs +2 -2
  24. package/dist/guard/externals.mjs +64 -0
  25. package/dist/guard/run.mjs +9 -5
  26. package/dist/inventories.mjs +1 -1
  27. package/dist/lowering-layer.mjs +38 -4
  28. package/dist/lowering-overlaps.mjs +13 -1
  29. package/dist/lowering-properties.mjs +4 -0
  30. package/dist/lowering-region-layout.mjs +22 -3
  31. package/dist/lowering-session.mjs +1 -1
  32. package/dist/lowering-transitions.mjs +1 -0
  33. package/dist/mcp/preview-http.bundle.js +2 -2
  34. package/dist/mcp/preview-widget.bundle.js +12 -12
  35. package/dist/measured-geometry.mjs +8 -2
  36. package/dist/owner-analysis-check.mjs +190 -11
  37. package/dist/owner-errors.mjs +3 -0
  38. package/dist/owner-lowering.mjs +3 -2
  39. package/dist/ownership-model.mjs +14 -5
  40. package/dist/platform-features.mjs +7 -0
  41. package/dist/preview-bun.mjs +15 -2
  42. package/dist/profile-macro.d.mts +18 -0
  43. package/dist/recipe-macro.d.mts +107 -9
  44. package/dist/recipe-model.mjs +22 -8
  45. package/dist/region-lowering.mjs +204 -49
  46. package/dist/render-audit/axe-run.page.mjs +40 -1
  47. package/dist/render-audit/forced-states.page.mjs +37 -0
  48. package/dist/render-audit/layout-overflow.page.mjs +52 -2
  49. package/dist/render-audit/non-text-contrast.page.mjs +14 -10
  50. package/dist/render-audit/worker.mjs +38 -0
  51. package/dist/render-audit.mjs +42 -5
  52. package/dist/role-vocabulary.d.mts +5 -2
  53. package/dist/role-vocabulary.mjs +6 -3
  54. package/dist/scenario-kit.d.mts +2 -2
  55. package/dist/showcase/assets-view.mjs +12 -47
  56. package/dist/showcase/client.bundle.js +50 -50
  57. package/dist/showcase/http-client.bundle.js +18 -18
  58. package/dist/showcase/token-sample.mjs +2 -2
  59. package/dist/showcase/ui/ui.css +1 -1
  60. package/dist/showcase/ui/ui.js +13 -13
  61. package/dist/skills/ads-designer/references/accessibility.md +21 -1
  62. package/dist/skills/ads-designer/references/branding.md +4 -0
  63. package/dist/skills/ads-designer/references/design-data.md +6 -0
  64. package/dist/skills/ads-designer/references/layers.md +5 -0
  65. package/dist/skills/ads-designer/references/layout.md +8 -1
  66. package/dist/skills/ads-designer/references/recipes.md +52 -2
  67. package/dist/skills/ads-designer/references/runtimes.md +4 -0
  68. package/dist/skills/ads-designer/references/scenarios.md +2 -0
  69. package/dist/skills/ads-import/references/design-data.md +6 -0
  70. package/dist/skills/ads-import/references/layers.md +5 -0
  71. package/dist/skills/ads-import/references/layout.md +8 -1
  72. package/dist/skills/ads-import/references/recipes.md +52 -2
  73. package/dist/skills/ads-import/references/runtimes.md +4 -0
  74. package/dist/skills/ads-import/references/scenarios.md +2 -0
  75. package/dist/skills/ads-migrate/SKILL.md +2 -0
  76. package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
  77. package/dist/skills/ads-migrate/references/0.5.4-to-0.5.5.md +61 -0
  78. package/dist/skills/ads-port/references/design-data.md +6 -0
  79. package/dist/skills/ads-port/references/layers.md +5 -0
  80. package/dist/skills/ads-port/references/layout.md +8 -1
  81. package/dist/skills/ads-port/references/recipes.md +52 -2
  82. package/dist/skills/ads-port/references/runtimes.md +4 -0
  83. package/dist/skills/ads-port/references/scenarios.md +2 -0
  84. package/dist/spatial-model.mjs +37 -10
  85. package/dist/system-colors.d.mts +9 -0
  86. package/dist/system-colors.mjs +1 -0
  87. package/dist/target-size.mjs +14 -1
  88. package/dist/tsconfig.declarations.json +1 -0
  89. package/docs/ADS.md +23 -1
  90. package/docs/ASSETS.md +21 -0
  91. package/docs/CACHING.md +1 -1
  92. package/docs/CHANGELOG.md +220 -21
  93. package/docs/GUIDE.md +31 -20
  94. package/docs/LANGUAGE.md +146 -11
  95. package/docs/MOTION.md +11 -1
  96. package/docs/PROFILE-KINDS.md +60 -9
  97. package/docs/RULES.md +21 -8
  98. package/package.json +5 -1
@@ -14,14 +14,15 @@ export const MEASURED_PROPERTIES = {
14
14
  "max-block-size"
15
15
  ],
16
16
  transform: ["translate"],
17
+ scale: ["scale"],
17
18
  "size-track": ["grid-template-columns", "grid-template-rows"],
18
19
  position: ["object-position"],
19
20
  "intrinsic-size": ["inline-size"]
20
21
  };
21
- const HOSTS = { length: "region", transform: "region", "size-track": "grid", position: "region", "intrinsic-size": "region" }, POSITIONS = ["inset-block-start", "inset-block-end", "inset-inline-start", "inset-inline-end", "translate"];
22
+ const HOSTS = { length: "region", transform: "region", scale: "region", "size-track": "grid", position: "region", "intrinsic-size": "region" }, POSITIONS = ["inset-block-start", "inset-block-end", "inset-inline-start", "inset-inline-end", "translate"];
22
23
  export const positions = (property) => POSITIONS.includes(property), measuredProperty = (scope, name) => privateProperty(scope, "measured", name);
23
24
  function initialValue(property) {
24
- if (property === "translate")
25
+ if (property === "translate" || property === "scale")
25
26
  return "none";
26
27
  if (property.startsWith("max-"))
27
28
  return "none";
@@ -35,6 +36,8 @@ export function measuredFallback(value, own) {
35
36
  return value.fallback === null ? own ?? initialValue(value.property) : px(value.fallback);
36
37
  case "transform":
37
38
  return value.fallback === null ? own ?? initialValue(value.property) : `${px(value.fallback.x)} ${px(value.fallback.y)}`;
39
+ case "scale":
40
+ return value.fallback === null ? own ?? initialValue(value.property) : `${value.fallback.x} ${value.fallback.y}`;
38
41
  case "position":
39
42
  return own ?? CENTRE;
40
43
  case "intrinsic-size":
@@ -122,6 +125,7 @@ export function measuredTrack(list, track, read) {
122
125
  function valueType(value) {
123
126
  switch (value.type) {
124
127
  case "transform":
128
+ case "scale":
125
129
  return "{ readonly x: number; readonly y: number }";
126
130
  case "position":
127
131
  return "readonly [x: number, y: number]";
@@ -137,6 +141,8 @@ function written(value) {
137
141
  switch (value.type) {
138
142
  case "transform":
139
143
  return `\`\${${read}.x}px \${${read}.y}px\``;
144
+ case "scale":
145
+ return `\`\${${read}.x} \${${read}.y}\``;
140
146
  case "position":
141
147
  return `\`\${(0.5 + ${read}[0]) * 100}% \${(0.5 + ${read}[1]) * 100}%\``;
142
148
  case "intrinsic-size":
@@ -14,7 +14,7 @@ import { jsonObject } from "./json.mjs";
14
14
  import { unusedArtwork } from "./asset-usage.mjs";
15
15
  import { catalogError, contextError, fontCatalogError } from "./owner-errors.mjs";
16
16
  import { FOUNDATION_DECLARATION, listProblemSite, sitePosition } from "./design-contexts.mjs";
17
- import { tokenCss } from "./design-foundation.mjs";
17
+ import { tokenCss, tokenValueContexts } from "./design-foundation.mjs";
18
18
  import { capturedDesignFiles, createDesignInputCache, designInputKey, designTexts } from "./design-inputs.mjs";
19
19
  import { createProjectExtractionCache } from "./linaria/persisted-extraction-cache.mjs";
20
20
  import { findingSeverity } from "./finding-rules.mjs";
@@ -27,7 +27,8 @@ import { describeTokenType } from "./token-type-check.mjs";
27
27
  import { describeTokenSheet } from "./token-sheet-check.mjs";
28
28
  import { describeSurfaceContrast, describeUnresolved, sufficientForUses } from "./surface-contrast.mjs";
29
29
  import { describeFocus, focusChecks } from "./focus-checks.mjs";
30
- import { NO_TARGETS, targetSizeFindings } from "./target-size.mjs";
30
+ import { lengthPx } from "./css-length.mjs";
31
+ import { NO_TARGETS, placedSpaced, targetSizeFindings } from "./target-size.mjs";
31
32
  import { describeTokenOverlap } from "./token-overlap.mjs";
32
33
  import { describeGridCheck, gridChecks } from "./grid-checks.mjs";
33
34
  import { describeFont, fontChecks } from "./font-checks.mjs";
@@ -46,12 +47,14 @@ const ACCESSIBILITY_RULES = new Map([
46
47
  ["construction/target-size-below-minimum", "a11y-target-size"],
47
48
  ["construction/target-area-overlap", "a11y-target-size"],
48
49
  ["construction/non-text-contrast-insufficient", "a11y-non-text-contrast"],
49
- ["construction/accessibility-declaration-unmet", "a11y-non-text-contrast"]
50
+ ["construction/accessibility-declaration-unmet", "a11y-non-text-contrast"],
51
+ ["construction/forced-boundary-missing", "a11y-forced-colors"]
50
52
  ]), ACCESSIBILITY_REVIEWS = new Map([
51
53
  ["review/click-without-keyboard", "a11y-keyboard"],
52
54
  ["review/motion-endless", "a11y-motion-endless"],
53
55
  ["review/target-size-unresolved", "a11y-target-size-unresolved"],
54
- ["review/target-area-overlap-unresolved", "a11y-target-size-unresolved"]
56
+ ["review/target-area-overlap-unresolved", "a11y-target-size-unresolved"],
57
+ ["review/forced-state-fill-only", "a11y-forced-colors-review"]
55
58
  ]), ownerRule = (code) => ACCESSIBILITY_RULES.get(code) ?? OWNER_ANALYSIS_RULE, reviewRule = (code) => ACCESSIBILITY_REVIEWS.get(code) ?? OWNER_REVIEW_RULE, TOKEN_CHECK_GUIDES = {
56
59
  "token-provenance": "ads://guides/tokens",
57
60
  "token-role-duplicate": "ads://guides/tokens",
@@ -161,7 +164,7 @@ async function analyzeRevision(inputs, captured, settings) {
161
164
  const iconAssets = design.value.appIcon === null ? [] : appIconAssets(design.value.appIcon, assets), composed = [
162
165
  ...await timing.timeStage("composed-contrast", () => composedFindings(inputs, texts, analyzed.value, foundation, design.value.document)),
163
166
  ...timing.timeStage("composed-keyline", () => keylineFindings(inputs, analyzed.value, foundation))
164
- ], checkedFindings = checkFindings(inputs, analyzed.value), released = releasedSurfaces(foundation, analyzed.value, design.value.document), usedTokens = released.size === 0 ? tokens : tokenFindings(inputs, texts, foundation, design.value.document, released);
167
+ ], checkedFindings = checkFindings(inputs, analyzed.value, await publicComponents(inputs)), released = releasedSurfaces(foundation, analyzed.value, design.value.document), usedTokens = released.size === 0 ? tokens : tokenFindings(inputs, texts, foundation, design.value.document, released);
165
168
  return {
166
169
  report: { ...checkedFindings, diagnostics: distinct([...missing, ...checkedFindings.diagnostics]), contexts: contextFindings, palette, tokens: usedTokens, fonts, appIcon, assets: [...assetFindings(inputs, texts, assets, analyzed.value, iconAssets), ...unreachedFindings(inputs, analyzed.value)], composed, packages: packageFindings(inputs, analyzed.value) },
167
170
  checked: { check: analyzed.value, contexts, foundation, document: design.value.document, assets, fonts: design.value.fonts, appIcon: icon.plan, keys: new Map(reuse.keys()), options, tally }
@@ -302,8 +305,14 @@ function tokenFindings(inputs, captured, foundation, document, released = new Se
302
305
  ...gridChecks(foundation).map((finding) => located(finding.kind, atProfile(finding.file, finding.profile), describeGridCheck(finding)))
303
306
  ];
304
307
  }
308
+ async function publicComponents(inputs) {
309
+ const declarations = await barrelDeclarations(inputs.dsRoot, inputs.publicAlias, inputs.framework ?? null);
310
+ if (declarations === null)
311
+ return null;
312
+ return new Set([...declarations.values()].flatMap((item) => item === null ? [] : [`${item.file}#${item.declaration}`]));
313
+ }
305
314
  async function composedFindings(inputs, captured, check, foundation, document) {
306
- const declarations = await barrelDeclarations(inputs.dsRoot, inputs.publicAlias, inputs.framework ?? null), publics = new Set([...declarations?.values() ?? []].flatMap((item) => item === null ? [] : [`${item.file}#${item.declaration}`])), owners = new Map;
315
+ const publics = await publicComponents(inputs) ?? new Set, owners = new Map;
307
316
  for (const [name, owner] of analyzedOwners(check.outcomes))
308
317
  owners.set(name, owner.composition);
309
318
  for (const [name, facts] of check.plainComposition)
@@ -434,7 +443,7 @@ function sitePositionIn(inputs, text, site) {
434
443
  const { line, column } = sitePosition(site, text(site.file));
435
444
  return { file: projectFile(inputs, path.join(inputs.dsRoot, site.file)), line, column };
436
445
  }
437
- export function checkFindings(inputs, check) {
446
+ export function checkFindings(inputs, check, publics = null) {
438
447
  const diagnostics = [], advisories = [];
439
448
  for (const [name, outcome] of check.outcomes)
440
449
  switch (outcome.kind) {
@@ -451,12 +460,15 @@ export function checkFindings(inputs, check) {
451
460
  for (const failure of check.program)
452
461
  diagnostics.push(...findingsOf(inputs, { kind: "owner", failure }));
453
462
  diagnostics.push(...tokenCssFindings(inputs, analyzedOwners(check.outcomes), check.foundation));
454
- const targets = timing.timeStage("target-size", () => targetFindings(inputs, analyzedOwners(check.outcomes), check.foundation));
463
+ const targets = timing.timeStage("target-size", () => targetFindings(inputs, analyzedOwners(check.outcomes), check.foundation, placedSpacing(analyzedOwners(check.outcomes), check.plainPlacements ?? [], publics)));
455
464
  diagnostics.push(...targets.diagnostics);
456
465
  advisories.push(...targets.advisories);
466
+ advisories.push(...counterFindings(inputs, analyzedOwners(check.outcomes)));
467
+ diagnostics.push(...documentFindings(inputs, analyzedOwners(check.outcomes)));
468
+ diagnostics.push(...endAlignmentFindings(inputs, analyzedOwners(check.outcomes), check.foundation));
457
469
  return { diagnostics: distinct(diagnostics), advisories };
458
470
  }
459
- function targetFindings(inputs, owners, foundation) {
471
+ function targetFindings(inputs, owners, foundation, spacing) {
460
472
  const diagnostics = [], advisories = new Map;
461
473
  for (const facts of owners.values())
462
474
  for (const style of facts.styles.values()) {
@@ -464,7 +476,9 @@ function targetFindings(inputs, owners, foundation) {
464
476
  if (first?.kind !== "point")
465
477
  continue;
466
478
  const origin = { ...first, file: path.join(inputs.dsRoot, first.file) };
467
- for (const finding of targetSizeFindings(foundation, constructionTargets(style.facts)))
479
+ for (const finding of targetSizeFindings(foundation, constructionTargets(style.facts))) {
480
+ if (finding.kind === "target-size-below-minimum" && finding.element === "&" && spacedWhereverPlaced(foundation, style, spacing))
481
+ continue;
468
482
  switch (finding.kind) {
469
483
  case "target-size-below-minimum":
470
484
  case "target-area-overlap":
@@ -477,9 +491,172 @@ function targetFindings(inputs, owners, foundation) {
477
491
  break;
478
492
  }
479
493
  }
494
+ }
480
495
  }
481
496
  return { diagnostics, advisories: [...advisories.values()] };
482
497
  }
498
+ function endAlignmentFindings(inputs, owners, foundation) {
499
+ const insets = new Map;
500
+ for (const facts of owners.values())
501
+ for (const style of facts.styles.values())
502
+ if (style.endInset !== void 0 && style.endInset !== null)
503
+ for (const root of style.roots ?? [])
504
+ insets.set(root, style.endInset);
505
+ const findings = [];
506
+ for (const facts of owners.values())
507
+ for (const style of facts.styles.values()) {
508
+ const parts = style.stackParts ?? [];
509
+ if (parts.length < 2)
510
+ continue;
511
+ const [first] = style.origins;
512
+ if (first?.kind !== "point")
513
+ continue;
514
+ const resolved = parts.flatMap((stacked) => {
515
+ if (stacked.kind === "box")
516
+ return [{ part: stacked.part, inset: stacked.inset }];
517
+ const placement = (style.placements ?? []).find((item) => item.part === stacked.part && item.target !== null), inset = placement?.target === void 0 || placement.target === null ? void 0 : insets.get(`${placement.target.file}#${placement.target.name}`);
518
+ return inset === void 0 ? [] : [{ part: stacked.part, inset }];
519
+ });
520
+ if (resolved.length < 2)
521
+ continue;
522
+ for (const context of tokenValueContexts(foundation)) {
523
+ const ends = resolved.flatMap(({ part, inset }) => {
524
+ let px = 0;
525
+ for (const value of inset) {
526
+ const read = lengthPx(value, context);
527
+ if (read.kind !== "px")
528
+ return [];
529
+ px += read.px;
530
+ }
531
+ return [{ part, px }];
532
+ }), counts = new Map;
533
+ for (const { px } of ends)
534
+ counts.set(Math.round(px), (counts.get(Math.round(px)) ?? 0) + 1);
535
+ const line = [...counts].sort((a, b) => b[1] - a[1])[0]?.[0];
536
+ if (line === void 0)
537
+ continue;
538
+ const off = ends.find(({ px }) => Math.abs(px - line) > 1 && Math.abs(px - line) <= 64);
539
+ if (off === void 0)
540
+ continue;
541
+ const other = ends.find(({ px }) => Math.round(px) === line);
542
+ findings.push(...findingsOf(inputs, {
543
+ kind: "owner",
544
+ failure: { kind: "source", origin: { ...first, file: path.join(inputs.dsRoot, first.file) }, problem: { kind: "end-misaligned", part: off.part, other: other?.part ?? "", distancePx: Math.round((line - off.px) * 100) / 100, context: context.label } }
545
+ }));
546
+ break;
547
+ }
548
+ }
549
+ return findings;
550
+ }
551
+ function documentFindings(inputs, owners) {
552
+ let first = null;
553
+ const findings = [];
554
+ for (const [name, facts] of owners)
555
+ for (const style of facts.styles.values()) {
556
+ if (style.document !== !0)
557
+ continue;
558
+ const [origin] = style.origins;
559
+ if (first === null || first === name) {
560
+ first = name;
561
+ continue;
562
+ }
563
+ if (origin?.kind !== "point")
564
+ continue;
565
+ findings.push(...findingsOf(inputs, { kind: "owner", failure: { kind: "source", origin: { ...origin, file: path.join(inputs.dsRoot, origin.file) }, problem: { kind: "document-duplicate", first } } }));
566
+ }
567
+ return findings;
568
+ }
569
+ function counterFindings(inputs, owners) {
570
+ const reset = new Set, used = new Map;
571
+ for (const facts of owners.values())
572
+ for (const style of facts.styles.values()) {
573
+ for (const match of style.css.matchAll(/counter-reset:\s*([a-z][a-z0-9-]*)/g))
574
+ reset.add(match[1] ?? "");
575
+ const [first] = style.origins;
576
+ if (first?.kind !== "point")
577
+ continue;
578
+ for (const match of style.css.matchAll(/counter-increment:\s*([a-z][a-z0-9-]*)|counters?\(\s*([a-z][a-z0-9-]*)/g)) {
579
+ const name = match[1] ?? match[2] ?? "";
580
+ if (name !== "list-item" && !used.has(name))
581
+ used.set(name, { ...first, file: path.join(inputs.dsRoot, first.file) });
582
+ }
583
+ }
584
+ return [...used].flatMap(([counter, origin]) => reset.has(counter) ? [] : [reviewFinding(inputs, { origin, review: { kind: "counter-unreset", counter } })]);
585
+ }
586
+ function placedSpacing(owners, plain, publics) {
587
+ if (publics === null)
588
+ return new Map;
589
+ const roots = new Map;
590
+ for (const facts of owners.values())
591
+ for (const style of facts.styles.values()) {
592
+ const root = constructionTargets(style.facts).elements.find((element) => element.element === "&");
593
+ if (root !== void 0)
594
+ for (const component of style.roots ?? [])
595
+ roots.set(component, root);
596
+ }
597
+ const keyOf = (target) => target === null ? null : `${target.file}#${target.name}`, spacing = new Map, unknown = (key) => void spacing.set(key, null), add = (key, neighbour) => {
598
+ const known = spacing.get(key);
599
+ if (known === null)
600
+ return;
601
+ if (known === void 0)
602
+ spacing.set(key, [neighbour]);
603
+ else
604
+ known.push(neighbour);
605
+ }, accounted = new Set;
606
+ for (const [file, facts] of owners)
607
+ for (const style of facts.styles.values()) {
608
+ const placements = style.placements ?? [];
609
+ for (const placement of placements) {
610
+ const key = keyOf(placement.target);
611
+ if (key !== null)
612
+ accounted.add(`${key}@${file}:${placement.at.line}:${placement.at.column}`);
613
+ }
614
+ for (const pair of constructionTargets(style.facts).placed ?? []) {
615
+ const keys = (side) => side.kind === "own" ? [] : placements.filter((item) => item.part === side.part).map((item) => keyOf(item.target)), geometry = (side) => {
616
+ if (side.kind === "own")
617
+ return side.geometry;
618
+ const found = keys(side).map((key) => key === null ? void 0 : roots.get(key));
619
+ return found.length === 1 ? found[0] ?? null : null;
620
+ };
621
+ for (const [own, other] of [[pair.first, pair.second], [pair.second, pair.first]]) {
622
+ const neighbour = geometry(other);
623
+ for (const key of keys(own)) {
624
+ if (key === null)
625
+ continue;
626
+ if (neighbour === null)
627
+ unknown(key);
628
+ else
629
+ add(key, { axis: pair.axis, gap: pair.gap, other: neighbour });
630
+ }
631
+ }
632
+ }
633
+ }
634
+ for (const [file, facts] of owners)
635
+ for (const position of facts.composition.positions) {
636
+ if (position.content.kind !== "placement")
637
+ continue;
638
+ const key = keyOf(position.content.target);
639
+ if (key !== null && !accounted.has(`${key}@${file}:${position.at.line}:${position.at.column}`))
640
+ unknown(key);
641
+ }
642
+ for (const placement of plain) {
643
+ const key = keyOf(placement.target);
644
+ if (key !== null)
645
+ unknown(key);
646
+ }
647
+ for (const key of publics)
648
+ unknown(key);
649
+ return spacing;
650
+ }
651
+ function spacedWhereverPlaced(foundation, style, spacing) {
652
+ const root = constructionTargets(style.facts).elements.find((element) => element.element === "&"), components = style.roots ?? [];
653
+ if (root === void 0 || components.length === 0)
654
+ return !1;
655
+ return components.every((component) => {
656
+ const neighbours = spacing.get(component);
657
+ return neighbours !== null && neighbours !== void 0 && placedSpaced(foundation, root, neighbours);
658
+ });
659
+ }
483
660
  function constructionTargets(facts) {
484
661
  switch (facts.kind) {
485
662
  case "control":
@@ -533,7 +710,7 @@ function revisionEnvironment() {
533
710
  function tokenCssFindings(inputs, owners, foundation) {
534
711
  const findings = [];
535
712
  for (const [owner, facts] of owners) {
536
- const used = new Set([...facts.styles.values()].flatMap((style) => [...style.used])), css = tokenCss(foundation, used);
713
+ const used = new Set([...facts.styles.values()].flatMap((style) => [...style.used, ...style.scriptTokens ?? []])), css = tokenCss(foundation, used);
537
714
  if (css.kind === "err")
538
715
  findings.push(...findingsOf(inputs, { kind: "owner", failure: { kind: "token-css", owner, failure: css.error } }));
539
716
  }
@@ -625,7 +802,9 @@ function designInputPosition(inputs, failure) {
625
802
  case "profile-rejected":
626
803
  case "token-role":
627
804
  case "provided-role-self":
805
+ case "forced-color-invalid":
628
806
  return foundationPosition(inputs);
807
+ case "document-text-incomplete":
629
808
  case "document-profile-kind":
630
809
  return designFile(inputs, FOUNDATION_DECLARATION);
631
810
  }
@@ -65,6 +65,8 @@ export function foundationError(failure) {
65
65
  case "profile-field-unknown":
66
66
  case "token-role":
67
67
  case "provided-role-self":
68
+ case "forced-color-invalid":
69
+ case "document-text-incomplete":
68
70
  case "document-profile-kind":
69
71
  return { code: `foundation/${failure.kind}`, ...entry(foundationErrors, failure.kind, failure) };
70
72
  }
@@ -131,6 +133,7 @@ export function constructionError(failure) {
131
133
  case "target-area-overlap":
132
134
  case "non-text-contrast-insufficient":
133
135
  case "corner-overpaint":
136
+ case "forced-boundary-missing":
134
137
  case "accessibility-declaration-unmet":
135
138
  case "layer-root-padding":
136
139
  case "layer-frame-position":
@@ -13,6 +13,7 @@ import {
13
13
  REFERENCE_ROOT_PX,
14
14
  controlBox,
15
15
  controlBoxValues,
16
+ controlInlineExtent,
16
17
  LINE_BOX,
17
18
  frameTarget,
18
19
  hitAreaOf,
@@ -71,7 +72,7 @@ export function lowerControl(spec, foundation, input) {
71
72
  const line = frame[BORDER_STYLE];
72
73
  if (line !== void 0 && spec.normalize.some(([property]) => property === "border-style"))
73
74
  return reject({ kind: "extent-conflict", element: "&", property: "border-style", providers: ["frame profile", "normalize"] });
74
- const minInline = frame["min-inline-size"], { asset, hasText } = input;
75
+ const { asset, hasText } = input;
75
76
  if (!hasText && asset === null && spec.decor.length === 0)
76
77
  return reject({ kind: "content-missing" });
77
78
  if (asset !== null && asset.paint === "slots")
@@ -81,7 +82,7 @@ export function lowerControl(spec, foundation, input) {
81
82
  ...controlArrangement(spec),
82
83
  ...spec.extent === "container" && spec.layout !== "native" ? { display: "flex", "inline-size": "100%" } : {},
83
84
  "box-sizing": "border-box",
84
- ...minInline !== void 0 ? { "min-inline-size": minInline } : keepsWidth ? {} : { "min-inline-size": "0" },
85
+ ...controlInlineExtent(frame, keepsWidth ? null : "0"),
85
86
  ...text,
86
87
  ...controlBoxValues(box),
87
88
  ...line === void 0 ? {} : { "border-style": line },
@@ -1,6 +1,6 @@
1
1
  import { fail, rejecting } from "./design-rejection.mjs";
2
2
  import { CURSORS, ELEMENT_NAMES, FRAME_CORNERS, FRAME_SIDES, GEOMETRY_CHANNELS, OVERFLOW_VALUES, PAINT_CHANNELS, RESIZES, SNAP_ALIGNS, SNAP_TYPES, TEXT_ALIGNS, TEXT_WRAPS, TOUCH_ACTIONS, USER_SELECTS } from "./construction-spec.mjs";
3
- const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent"]), outsetSpacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "outset-block", "outset-inline"]), anchorClear = (value) => value === "profile(layer-profile.clear-block-start)" || value === "profile(spacing-profile.anchor-gap)", overlapSpacing = metric("spacing", ["overlap"]), placement = {
3
+ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "space-before", "space-after"]), outsetSpacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "outset-block", "outset-inline"]), anchorClear = (value) => value === "profile(layer-profile.clear-block-start)" || value === "profile(spacing-profile.anchor-gap)", overlapSpacing = metric("spacing", ["overlap"]), placement = {
4
4
  start: (value) => value === "auto" || positive(value),
5
5
  end: positive,
6
6
  span: (value) => value === "full" || positive(value),
@@ -12,17 +12,20 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
12
12
  }, TEXT_ALIGN = oneOf(...TEXT_ALIGNS), OVERFLOW = oneOf(...OVERFLOW_VALUES), ELEMENT = oneOf(...ELEMENT_NAMES), FIELDS = {
13
13
  "ads-recipe": {
14
14
  profile: (value) => profile.test(value),
15
+ markers: wordList,
15
16
  text: binding,
16
17
  surface: binding,
17
18
  align: oneOf("start", "center", "end", "baseline", "stretch"),
18
- justify: oneOf("start", "center", "end"),
19
+ justify: oneOf("start", "center", "end", "space-between", "space-around", "space-evenly"),
19
20
  wrap: oneOf("true", "false"),
21
+ carry: oneOf("true", "false"),
20
22
  extent: oneOf("content", "container"),
21
23
  gap: spacing,
22
24
  "row-gap": spacing,
23
25
  overlap: overlapSpacing,
24
26
  "anchor-clear": anchorClear,
25
27
  columns: positive,
28
+ "content-from": (value) => /^[a-z][\w-]*$/.test(value),
26
29
  weights: (value) => value.split(/\s+/).length <= 64 && value.split(/\s+/).every((weight) => /^\d+(\.\d+)?$/.test(weight) && Number(weight) > 0),
27
30
  rows: (value) => value.split(/\s+/).length <= 12 && value.split(/\s+/).every((row) => ["auto", "fill"].includes(row)),
28
31
  gutter: (value) => identifier.test(value),
@@ -38,8 +41,11 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
38
41
  },
39
42
  "ads-part": {
40
43
  kind: oneOf("text", "visual", "vector", "component"),
44
+ align: oneOf("start", "center", "end"),
41
45
  "space-before": spacing,
42
46
  "space-after": spacing,
47
+ spacing: binding,
48
+ presence: oneOf("visible", "assistive"),
43
49
  scheme: oneOf("light", "dark"),
44
50
  selector: (value) => /^\.[a-z][\w-]*$/.test(value),
45
51
  required: oneOf("true", "false"),
@@ -95,8 +101,11 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
95
101
  },
96
102
  motion: binding
97
103
  },
98
- "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), translateInline: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
99
- "ads-pseudo": { surface: binding },
104
+ "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), "translate-inline": metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
105
+ "ads-pseudo": { surface: binding, text: binding, frame: binding },
106
+ "ads-counter": { reset: () => !0, increment: () => !0 },
107
+ "ads-between": { surface: binding, frame: binding },
108
+ "ads-content": { counter: () => !0, counters: () => !0, style: () => !0, separator: () => !0, prefix: () => !0, suffix: () => !0 },
100
109
  "ads-accessibility": { boundary: () => !0, reason: () => !0 },
101
110
  "ads-focus": { of: () => !0 },
102
111
  "ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
@@ -105,7 +114,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
105
114
  "ads-snap": { type: oneOf(...SNAP_TYPES), align: oneOf(...SNAP_ALIGNS) },
106
115
  "ads-layer": {
107
116
  element: oneOf("dialog", "popover"),
108
- edge: oneOf("start", "end"),
117
+ edge: oneOf("start", "end", "center", "block-start"),
109
118
  "backdrop-surface": binding,
110
119
  "backdrop-dismiss": oneOf("press", "none"),
111
120
  motion: oneOf("slide", "fade"),
@@ -118,6 +118,10 @@ export const PLATFORM_FEATURES = [
118
118
  "box-sizing",
119
119
  "color",
120
120
  "content",
121
+ "counter-reset",
122
+ "counter-increment",
123
+ "clip-path",
124
+ "forced-color-adjust",
121
125
  "display",
122
126
  "flex-basis",
123
127
  "flex-direction",
@@ -253,6 +257,9 @@ export const PLATFORM_FEATURES = [
253
257
  "format()",
254
258
  "local()",
255
259
  "attr()",
260
+ "counter()",
261
+ "counters()",
262
+ "inset()",
256
263
  "cubic-bezier()",
257
264
  "steps()",
258
265
  "linear-gradient()",
@@ -1,3 +1,5 @@
1
+ import { CLIENT_DIRECTIVE } from "./analysis/client-directive.mjs";
2
+ import { EXTERNAL_MARKER } from "./analysis/externals.mjs";
1
3
  import { eachChild, mapAsync } from "./analysis/queries.mjs";
2
4
  import { createHash, randomUUID } from "node:crypto";
3
5
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -23,7 +25,7 @@ import { isRecord } from "./unknown.mjs";
23
25
  import { adsViewDefinition } from "./ads-views.mjs";
24
26
  import { PREVIEW_CONTROLS_FILE, PREVIEW_FACTS_FILE, PREVIEW_TOKENS_SHEET } from "./emit/preview-tree.mjs";
25
27
  import { parsePreviewControls } from "./preview-controls.mjs";
26
- const distributedFrame = existsSync(new URL("./showcase/preview-frame.mjs", import.meta.url)), builtFrame = !distributedFrame && existsSync(new URL("../dist/showcase/ui/ui.js", import.meta.url)), compiledFrame = distributedFrame || builtFrame, previewFrameDirectory = distributedFrame ? "./showcase/" : builtFrame ? "../dist/showcase/" : "../showcase-client/", previewFrameFile = (file) => fileURLToPath(new URL(`${previewFrameDirectory}${file}`, import.meta.url)), previewFrameModule = (name) => previewFrameFile(`${name}${compiledFrame ? ".mjs" : ".mts"}`);
28
+ const JSX_DOCUMENT_TAGS = /(?:(?<=(?:^|[(>{}?:,=]|\breturn|&&|\|\|)\s*)<()(html|head|body)|<(\/)(html|head|body))(?=[\s>])/gm, JSX_DOCUMENT_TAG = /(?<=(?:^|[(>{?:,=]|\breturn|&&|\|\|)\s*)<html(?=[\s>])/m, distributedFrame = existsSync(new URL("./showcase/preview-frame.mjs", import.meta.url)), builtFrame = !distributedFrame && existsSync(new URL("../dist/showcase/ui/ui.js", import.meta.url)), compiledFrame = distributedFrame || builtFrame, previewFrameDirectory = distributedFrame ? "./showcase/" : builtFrame ? "../dist/showcase/" : "../showcase-client/", previewFrameFile = (file) => fileURLToPath(new URL(`${previewFrameDirectory}${file}`, import.meta.url)), previewFrameModule = (name) => previewFrameFile(`${name}${compiledFrame ? ".mjs" : ".mts"}`);
27
29
  export const SCENARIO_KIT = "@reqvire-org/ads/showcase", previewFrameFiles = [
28
30
  previewFrameModule("preview-frame"),
29
31
  previewFrameFile("preview-frame.css"),
@@ -222,7 +224,8 @@ export function createBunPreviewBuilder() {
222
224
  return pending;
223
225
  }
224
226
  async function source(file, ancestors, defer) {
225
- const original = readFileSync(file, "utf8");
227
+ const read = readFileSync(file, "utf8"), clientFree = read.startsWith(`${CLIENT_DIRECTIVE}
228
+ `) ? read.slice(CLIENT_DIRECTIVE.length + 1) : read, standIn = externalStandIn(clientFree, options.config.framework), original = standIn !== null ? standIn : /\.[jt]sx$/.test(file) && JSX_DOCUMENT_TAG.test(clientFree) ? clientFree.replace(JSX_DOCUMENT_TAGS, (_, __, opened) => opened !== void 0 ? `<div data-ads-${opened}=""${opened === "head" ? " hidden" : ""}` : "</div") : clientFree;
226
229
  inputs.add(file);
227
230
  let code = await optimizeImports(original, file);
228
231
  if (/\bnew\s+(?:Worker|SharedWorker|URL)\s*\(/.test(code)) {
@@ -521,3 +524,13 @@ function workerArguments(node) {
521
524
  return node.arguments ?? [];
522
525
  return;
523
526
  }
527
+ export function externalStandIn(source, framework) {
528
+ const marks = [...source.matchAll(/\/\* ads-external (\{[^*]*\}) \*\//g)].map((match) => JSON.parse(match[1] ?? "{}"));
529
+ if (!source.includes(EXTERNAL_MARKER) || marks.length === 0)
530
+ return null;
531
+ const create = framework === "preact" ? 'import { h as createElement } from "preact";' : 'import { createElement } from "react";', pass = 'Object.fromEntries(Object.entries(props).filter(([key, value]) => key === "children" || key === "className" || typeof value === "string" || typeof value === "number" || key.startsWith("on") || key.startsWith("aria-") || key.startsWith("data-")))';
532
+ return `${create}
533
+ ${marks.map((mark) => `export function ${mark.name}(props) { const { children, ...rest } = ${pass}; return createElement(${JSON.stringify(mark.renders)}, rest, children); }`).join(`
534
+ `)}
535
+ `;
536
+ }
@@ -1,5 +1,6 @@
1
1
  import { type Token } from "./authoring-macro.mjs";
2
2
  import type { TokenProfileKind } from "./role-vocabulary.mjs";
3
+ import type { SystemColor } from "./system-colors.mjs";
3
4
  /** Derived from the role vocabulary, so a kind the model accepts is always a kind authors can type; `composite` holds slots, not token fields. */
4
5
  export type ProfileKind = TokenProfileKind | "composite";
5
6
  export type ProfileReference = string | {
@@ -24,9 +25,15 @@ export interface ProfileSpec {
24
25
  readonly fixedStart?: Token;
25
26
  readonly fixedEnd?: Token;
26
27
  }>>;
28
+ /**
29
+ * Gutter modes: an edge gutter insets each cell by `start` and `end`; a gap gutter (`{ gap }`) separates the
30
+ * tracks by `column-gap`, with the outer cells flush to the region's edges (card grids).
31
+ */
27
32
  readonly gutters?: Readonly<Record<string, {
28
33
  readonly start?: Token;
29
34
  readonly end?: Token;
35
+ } | {
36
+ readonly gap: Token;
30
37
  }>>;
31
38
  readonly conditions?: Readonly<Record<string, {
32
39
  readonly maxWidth?: Token;
@@ -41,6 +48,17 @@ export interface ProfileSpec {
41
48
  * applies: what can sit inside is proven with the provided values on that element's background.
42
49
  */
43
50
  readonly provides?: Readonly<Record<`--${string}`, Token>>;
51
+ /**
52
+ * A `surface` profile's colours in forced colours (Windows contrast themes), from the CSS system colours:
53
+ * a selected item's `{ background: "Highlight", color: "HighlightText" }`, a disabled control's
54
+ * `{ color: "GrayText", border: "GrayText" }`. Written under `@media (forced-colors: active)` wherever the
55
+ * surface applies, its states included. Undeclared surfaces keep the browser's own mapping.
56
+ */
57
+ readonly forcedColors?: {
58
+ readonly background?: SystemColor;
59
+ readonly color?: SystemColor;
60
+ readonly border?: SystemColor;
61
+ };
44
62
  /**
45
63
  * A `sequence` profile's steps, each at a whole percentage of the run from 0 to 100. A step states
46
64
  * what the part looks like there: `opacity`, travel (`translateInline`, `translateBlock`), one scale