@reqvire-org/ads 0.5.4 → 0.5.6

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 (97) 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 +12 -2
  7. package/dist/analysis/owner-composition.mjs +19 -4
  8. package/dist/analysis/owner-source.mjs +112 -15
  9. package/dist/border-paint.mjs +34 -0
  10. package/dist/check.mjs +2 -0
  11. package/dist/composed-contrast.mjs +10 -7
  12. package/dist/construction-output.mjs +52 -27
  13. package/dist/construction-spec.d.mts +40 -10
  14. package/dist/construction-spec.mjs +41 -19
  15. package/dist/corner-overpaint.mjs +3 -1
  16. package/dist/design-foundation.mjs +14 -0
  17. package/dist/emit/owner-emission-cache.mjs +1 -1
  18. package/dist/end-alignment.mjs +75 -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/grid-facts.mjs +1 -1
  25. package/dist/guard/externals.mjs +64 -0
  26. package/dist/guard/run.mjs +9 -5
  27. package/dist/inventories.mjs +1 -1
  28. package/dist/lowering-emitter.mjs +2 -1
  29. package/dist/lowering-layer.mjs +39 -4
  30. package/dist/lowering-overlaps.mjs +7 -0
  31. package/dist/lowering-properties.mjs +2 -0
  32. package/dist/lowering-region-layout.mjs +23 -3
  33. package/dist/lowering-session.mjs +1 -1
  34. package/dist/mcp/preview-http.bundle.js +2 -2
  35. package/dist/mcp/preview-widget.bundle.js +12 -12
  36. package/dist/measured-geometry.mjs +8 -2
  37. package/dist/owner-analysis-check.mjs +190 -11
  38. package/dist/owner-errors.mjs +3 -0
  39. package/dist/owner-lowering.mjs +3 -2
  40. package/dist/ownership-model.mjs +6 -3
  41. package/dist/platform-features.mjs +2 -0
  42. package/dist/preview-bun.mjs +15 -2
  43. package/dist/profile-macro.d.mts +18 -0
  44. package/dist/recipe-macro.d.mts +49 -6
  45. package/dist/recipe-model.mjs +13 -5
  46. package/dist/region-lowering.mjs +115 -22
  47. package/dist/render-audit/axe-run.page.mjs +40 -1
  48. package/dist/render-audit/forced-states.page.mjs +37 -0
  49. package/dist/render-audit/layout-overflow.page.mjs +52 -2
  50. package/dist/render-audit/non-text-contrast.page.mjs +14 -10
  51. package/dist/render-audit/worker.mjs +38 -0
  52. package/dist/render-audit.mjs +42 -5
  53. package/dist/role-vocabulary.d.mts +2 -2
  54. package/dist/role-vocabulary.mjs +3 -3
  55. package/dist/scenario-kit.d.mts +2 -2
  56. package/dist/showcase/assets-view.mjs +17 -47
  57. package/dist/showcase/client.bundle.js +54 -54
  58. package/dist/showcase/http-client.bundle.js +18 -18
  59. package/dist/showcase/token-sample.mjs +16 -6
  60. package/dist/showcase/ui/ui.css +1 -1
  61. package/dist/showcase/ui/ui.js +13 -13
  62. package/dist/skills/ads-designer/references/accessibility.md +21 -1
  63. package/dist/skills/ads-designer/references/branding.md +4 -0
  64. package/dist/skills/ads-designer/references/design-data.md +6 -0
  65. package/dist/skills/ads-designer/references/layers.md +5 -0
  66. package/dist/skills/ads-designer/references/layout.md +8 -1
  67. package/dist/skills/ads-designer/references/recipes.md +36 -0
  68. package/dist/skills/ads-designer/references/runtimes.md +4 -0
  69. package/dist/skills/ads-designer/references/scenarios.md +2 -0
  70. package/dist/skills/ads-import/references/design-data.md +6 -0
  71. package/dist/skills/ads-import/references/layers.md +5 -0
  72. package/dist/skills/ads-import/references/layout.md +8 -1
  73. package/dist/skills/ads-import/references/recipes.md +36 -0
  74. package/dist/skills/ads-import/references/runtimes.md +4 -0
  75. package/dist/skills/ads-import/references/scenarios.md +2 -0
  76. package/dist/skills/ads-migrate/SKILL.md +1 -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 +36 -0
  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 +184 -27
  93. package/docs/GUIDE.md +31 -20
  94. package/docs/LANGUAGE.md +122 -6
  95. package/docs/PROFILE-KINDS.md +50 -4
  96. package/docs/RULES.md +21 -8
  97. package/package.json +7 -1
@@ -1,3 +1,4 @@
1
+ import { FORCED_KEYS } from "./system-colors.mjs";
1
2
  import { createHash } from "node:crypto";
2
3
  import postcss from "postcss";
3
4
  import { isJsonObject, isRecord } from "./json.mjs";
@@ -48,7 +49,7 @@ function clause(parent, name, params, values) {
48
49
  }
49
50
  const strings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
50
51
  function buildProfileTree(spec) {
51
- only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides"]);
52
+ only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides", "forcedColors"]);
52
53
  const { name, kind } = spec;
53
54
  check(typeof name === "string" && typeof kind === "string", "Profiles need a string name and kind");
54
55
  const inputs = spec.with === void 0 ? [] : strings(spec.with);
@@ -68,6 +69,13 @@ function buildProfileTree(spec) {
68
69
  check(!Object.hasOwn(fields, token), `Duplicate provided role: ${token}`);
69
70
  fields[token] = value;
70
71
  }
72
+ const forced = spec.forcedColors === void 0 ? {} : object(spec.forcedColors, "Expected forced colours");
73
+ check(Object.keys(forced).length === 0 || kind === "surface", "Only a surface profile declares forced colours");
74
+ for (const [key, value] of Object.entries(forced)) {
75
+ const field = FORCED_KEYS[key];
76
+ check(field !== void 0 && typeof value === "string", `Forced colours are background, color and border, each a system colour: ${key}`);
77
+ fields[field] = value;
78
+ }
71
79
  declarations(node, fields);
72
80
  for (const [choiceName, choice] of Object.entries(spec.choices === void 0 ? {} : object(spec.choices, "Expected choices"))) {
73
81
  const declared = only(choice, ["default", "options"]), child = clause(node, "ads-choice", choiceName, declared.default ? { default: declared.default } : {});
@@ -95,12 +103,12 @@ const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "sele
95
103
  "ads-pseudo": ["when", "content"]
96
104
  };
97
105
  function body(node, spec) {
98
- const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play", "pseudo", "counter", "between"] : []] : NESTED_IN[node.name] ?? [];
106
+ const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play", "pseudo", "counter", "between"] : []] : NESTED_IN[node.name] ?? [], nestedKey = (key) => NESTED.has(key) && !(node.name === "ads-pseudo" && key === "frame");
99
107
  for (const field of Object.keys(spec))
100
- if (NESTED.has(field))
108
+ if (nestedKey(field))
101
109
  check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
102
- declarations(node, Object.fromEntries(Object.entries(spec).flatMap(([key, value]) => NESTED.has(key) ? [] : [[key === "state" ? "assetState" : key, value]])));
103
- const declaredFrame = spec.frame;
110
+ declarations(node, Object.fromEntries(Object.entries(spec).flatMap(([key, value]) => nestedKey(key) ? [] : [[key === "state" ? "assetState" : key, value]])));
111
+ const declaredFrame = node.name === "ads-pseudo" ? void 0 : spec.frame;
104
112
  if (declaredFrame !== void 0) {
105
113
  const frame = typeof declaredFrame === "string" ? { kind: declaredFrame } : object(declaredFrame, "Frame needs an operation"), { kind = "", ...fields } = frame;
106
114
  clause(node, "ads-frame", String(kind), Object.keys(fields).length > 0 ? fields : void 0);
@@ -21,6 +21,7 @@ import {
21
21
  writeRootPress,
22
22
  writeTransitions,
23
23
  checkSurfaceEffects,
24
+ controlInlineExtent,
24
25
  writeEnter,
25
26
  writePlays,
26
27
  writeStateText
@@ -41,6 +42,7 @@ import {
41
42
  elementNormalization,
42
43
  extentValues,
43
44
  growsWithContent,
45
+ nativeReset,
44
46
  frameInsets,
45
47
  frameRules,
46
48
  layeredValues,
@@ -83,8 +85,11 @@ function arrangementValues(arrangement, slots, profile, overflow = { kind: "visi
83
85
  values.display = "grid";
84
86
  const spacingReference = slots["spacing-profile"];
85
87
  if (spacingReference !== void 0) {
86
- const spacing = profile.of(spacingReference, "spacing"), field = arrangement.gap === null ? "content-gap" : kebab(arrangement.gap.field);
87
- if (arrangement.overlap === null)
88
+ const spacing = profile.of(spacingReference, "spacing"), field = arrangement.gap === null ? "content-gap" : kebab(arrangement.gap.field), lines = arrangement.rowGap === void 0 || arrangement.rowGap === null ? null : profile.field(spacing, "spacing", kebab(arrangement.rowGap.field));
89
+ if (arrangement.overlap === null && lines !== null && layout === "inline") {
90
+ values["column-gap"] = profile.field(spacing, "spacing", field);
91
+ values["row-gap"] = lines;
92
+ } else if (arrangement.overlap === null)
88
93
  values[layout === "flow" ? "row-gap" : "gap"] = profile.field(spacing, "spacing", field);
89
94
  } else if (arrangement.gap !== null)
90
95
  profile.field({}, "spacing-profile", kebab(arrangement.gap.field));
@@ -139,8 +144,8 @@ function writeStateGeometry(path, element, rest, states, transition, frameOf, co
139
144
  Object.assign(values, collapsedValues(state.collapsed, rest.axis));
140
145
  for (const property of Object.keys(values))
141
146
  changed.add(property);
142
- if (values.gap !== void 0)
143
- gaps.push(values.gap);
147
+ if ((values.gap ?? values["column-gap"]) !== void 0)
148
+ gaps.push(values.gap ?? values["column-gap"] ?? "");
144
149
  if (Object.keys(values).length > 0)
145
150
  out.rule(under(state.condition, path), values);
146
151
  if (state.condition.includes(":hover")) {
@@ -385,6 +390,40 @@ function pseudoRules(name, treatments, path, fills, context, hasBox) {
385
390
  return reject(checked.error);
386
391
  break;
387
392
  }
393
+ case "sliderTrack":
394
+ case "sliderThumb": {
395
+ out.rule(path, { appearance: "none", "-webkit-appearance": "none", background: "transparent" });
396
+ const box = (of, surface) => {
397
+ const fields = profile.of(surface, "surface"), frame = of.frame === null || of.frame === void 0 ? {} : profile.of(of.frame, "frame", name), paint = {};
398
+ if (fields.background !== void 0)
399
+ paint.background = fields.background;
400
+ if (fields["border-color"] !== void 0)
401
+ paint["border-color"] = fields["border-color"];
402
+ if (frame["border-width"] !== void 0)
403
+ Object.assign(paint, { "border-width": frame["border-width"], "border-style": "solid" });
404
+ else
405
+ paint["border-style"] = "none";
406
+ for (const [field, property] of [["inline-size", "inline-size"], ["block-size", "block-size"], ["radius", "border-radius"]])
407
+ if (frame[field] !== void 0)
408
+ paint[property] = frame[field];
409
+ return paint;
410
+ }, track = treatments.find((item) => item.pseudo === "sliderTrack"), thumb = treatment.pseudo === "sliderThumb", suffixes = thumb ? SLIDER_THUMBS : SLIDER_TRACKS, own = box(treatment, treatment.surface ?? "");
411
+ for (const suffix of suffixes) {
412
+ out.rule(`${path}${suffix}`, { ...thumb ? { appearance: "none", "-webkit-appearance": "none" } : {}, ...own });
413
+ for (const [condition, state] of treatment.when)
414
+ if (state !== null)
415
+ out.rule(`${under(condition, path)}${suffix}`, box(treatment, state));
416
+ }
417
+ const thumbBlock = own["block-size"], trackBlock = track === void 0 || track.frame === null || track.frame === void 0 ? void 0 : profile.of(track.frame, "frame", name)["block-size"];
418
+ if (thumb && thumbBlock !== void 0 && trackBlock !== void 0)
419
+ out.rule(`${path}::-webkit-slider-thumb`, { "margin-block-start": `calc((${trackBlock} - ${thumbBlock}) / 2)` });
420
+ if (thumb && track !== void 0 && track.surface !== null) {
421
+ const fill = (surface) => profile.of(surface, "surface").background ?? null, paints = (of, base) => [{ condition: null, value: fill(base) }, ...of.when.flatMap(([condition, state]) => state === null ? [] : [{ condition, value: fill(state) }])], checked = checkProgressContrast(foundation, name, paints(treatment, treatment.surface ?? ""), paints(track, track.surface));
422
+ if (checked.kind === "err")
423
+ return reject({ ...checked.error, subject: "slider-thumb" });
424
+ }
425
+ break;
426
+ }
388
427
  case "marker":
389
428
  case "before": {
390
429
  const suffix = `::${treatment.pseudo}`, values = {
@@ -399,7 +438,7 @@ function pseudoRules(name, treatments, path, fills, context, hasBox) {
399
438
  }
400
439
  }
401
440
  }
402
- const PROGRESS_FILLS = ["::-webkit-progress-value", "::-moz-progress-bar"];
441
+ const SLIDER_TRACKS = ["::-webkit-slider-runnable-track", "::-moz-range-track"], SLIDER_THUMBS = ["::-webkit-slider-thumb", "::-moz-range-thumb"], PROGRESS_FILLS = ["::-webkit-progress-value", "::-moz-progress-bar"];
403
442
  function pseudoFill(treatment, surface, profile, reject) {
404
443
  const fields = profile.of(surface, "surface"), other = Object.keys(fields).find((field) => field !== "background");
405
444
  if (other !== void 0)
@@ -465,15 +504,36 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
465
504
  return context.reject({ kind: "profile-field-missing", profile: drawing.box ?? drawing.name, field: inline === void 0 ? "inlineSize" : "blockSize" });
466
505
  context.out.rule(`${parent} > ${part.selector}`, { position: "absolute", "inline-size": inline, "block-size": block, "margin-block": "0", "margin-inline": "0", opacity: "0", "z-index": "1" });
467
506
  }
468
- writePartSpace(parts, parent, layout, gap, context);
507
+ writePartSpace(parts, parent, layout, gap, context, context.carry);
469
508
  const lowered = parts.map((part) => lowerPart(part, parent, layout, context, parentGrows, overlapping));
470
509
  if (layout !== "inline" && layout !== "stack")
471
510
  return;
472
- const axes = layout === "inline" ? ["inline"] : ["block"];
473
- lowered.flatMap((first, index) => {
511
+ const axes = layout === "inline" ? ["inline"] : ["block"], pairs = lowered.flatMap((first, index) => {
474
512
  const own = first !== null && parts[index]?.repeat === !0 ? [[first, first]] : [], second = lowered[index + 1];
475
513
  return first === null || second === null || second === void 0 ? own : [...own, [first, second]];
476
- }).forEach(([first, second]) => {
514
+ }), side = (index) => {
515
+ const part = parts[index], geometry = lowered[index];
516
+ if (part === void 0)
517
+ return null;
518
+ if (part.content.kind === "component")
519
+ return { kind: "placed", part: part.name };
520
+ return geometry === null || geometry === void 0 ? null : { kind: "own", geometry };
521
+ };
522
+ if (overlapping === null)
523
+ parts.forEach((part, index) => {
524
+ const first = side(index);
525
+ if (first === null)
526
+ return;
527
+ const nexts = [...part.repeat && part.content.kind === "component" ? [first] : [], side(index + 1)];
528
+ for (const second of nexts) {
529
+ if (second === null || first.kind === "own" && second.kind === "own")
530
+ continue;
531
+ for (const axis of axes)
532
+ for (const between of [gap ?? "0px", ...stateGaps])
533
+ context.placed.push({ axis, gap: between, first, second });
534
+ }
535
+ });
536
+ pairs.forEach(([first, second]) => {
477
537
  if (overlapping !== null)
478
538
  return context.reject({ kind: "state-geometry-unsupported", element: parent === "&" ? "&" : parent, reason: "targets-overlap", detail: `${first.element} and ${second.element}` });
479
539
  for (const axis of axes)
@@ -481,7 +541,7 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
481
541
  context.neighbours.push({ axis, gap: between, first, second });
482
542
  });
483
543
  }
484
- function writePartSpace(parts, parent, layout, gap, context) {
544
+ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
485
545
  const { out, profile, slots } = context, own = (part, side) => {
486
546
  const binding = side === "before" ? part.spaceBefore : part.spaceAfter;
487
547
  if (binding !== null)
@@ -508,7 +568,14 @@ function writePartSpace(parts, parent, layout, gap, context) {
508
568
  for (const next of spaced)
509
569
  if (previous.after !== null && next.before !== null)
510
570
  out.rule(`${parent} > ${previous.part.selector} + ${next.part.selector}:not(:first-child):not(:first-child)`, margin(`max(${previous.after}, ${next.before})`));
571
+ if (carry && parent === "&") {
572
+ out.own(FLOW_GAP);
573
+ for (const { part, after } of spaced)
574
+ if (after !== null)
575
+ out.rule(`&:not(:last-child):has(> ${part.selector}:last-child)`, { "margin-block-end": `max(0px, calc(${after} - var(${FLOW_GAP}, 0px)))` });
576
+ }
511
577
  }
578
+ const FLOW_GAP = "--ads-flow-gap";
512
579
  function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping = null) {
513
580
  const { out, profile, slots, reject } = context, path = `${parent} > ${part.selector}`;
514
581
  if (part.content.kind === "vector") {
@@ -584,7 +651,8 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
584
651
  if (!part.frame.border.sides.includes(side))
585
652
  frameFields[`padding-${side}`] = `calc(${frameFields[`padding-${side}`]} + ${box.border})`;
586
653
  }
587
- Object.assign(values, { "box-sizing": "border-box", "min-inline-size": "0" }, frameFields);
654
+ const lineOwn = lineText === text ? {} : Object.fromEntries(["line-height", "font-size"].flatMap((field) => lineText[field] === void 0 ? [] : [[field, lineText[field]]]));
655
+ Object.assign(values, { "box-sizing": "border-box", ...controlInlineExtent(frame, "0") }, lineOwn, frameFields);
588
656
  const hitArea = hitAreaOf(frame);
589
657
  writeHitArea(out, path, hitArea);
590
658
  target = {
@@ -626,12 +694,17 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
626
694
  const pathKey = path.split(" > ").slice(1).join(" "), ownMargin = Object.keys(values).some((property) => property.startsWith("margin")) || (context.rootNormalized.get(path) ?? []).some((property) => property.startsWith("margin"));
627
695
  if (context.input.margined?.includes(pathKey) === !0 && !ownMargin)
628
696
  out.rule(path, { margin: "0" });
697
+ if (context.input.native?.includes(pathKey) === !0) {
698
+ const reset = nativeReset(values);
699
+ if (Object.keys(reset).length > 0)
700
+ out.rule(path, reset);
701
+ }
629
702
  const media = part.measured.some((value) => value.type === "position" || value.type === "intrinsic-size") && part.content.kind === "visual" && visualOf(context.input, part.name)?.kind === "content-media" ? covers(profile.of(slots["visual-profile"], "visual", "visual")) ? "cover" : "contain" : null;
630
703
  Object.assign(values, checked(measuredWrites(context.input.scope, part.measured, part.name, values, part.frame !== null ? supplied(slots, frameFields) : null, media), reject));
631
704
  Object.assign(values, paintValues(part.name, part.paints, "box", [part.surface], part.when, context));
632
705
  writeConditioned(part, path, values, context);
633
- const conditioned = conditionedVisual(part, context);
634
- if (part.scheme !== null && visualOf(context.input, part.name)?.kind !== "content-media")
706
+ const conditioned = conditionedVisual(part, context), schemed = visualOf(context.input, part.name)?.kind;
707
+ if (part.scheme !== null && schemed !== "content-media" && schemed !== "asset")
635
708
  return reject({ kind: "scheme-unsupported", part: part.name });
636
709
  const unrendered = part.content.kind === "visual" && (!part.required || context.withinOptional === !0) && visualOf(context.input, part.name) === null;
637
710
  if (part.content.kind === "visual" && !unrendered)
@@ -651,7 +724,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
651
724
  if (part.presence === "assistive")
652
725
  out.rule(path, { ...ASSISTIVE_ONLY });
653
726
  }
654
- lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap, part.required && context.withinOptional !== !0 ? context : { ...context, withinOptional: !0 }, growsWithContent(values), partGeometry.overlap, partGeometry.gaps);
727
+ lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap ?? values["column-gap"], part.required && context.withinOptional !== !0 ? context : { ...context, withinOptional: !0 }, growsWithContent(values), partGeometry.overlap, partGeometry.gaps);
655
728
  return target;
656
729
  }
657
730
  const visualOf = (input, part) => input.visuals?.get(part) ?? input.visual;
@@ -681,13 +754,16 @@ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null
681
754
  out.rule(path, { ...COVER_FILL, display });
682
755
  return;
683
756
  }
684
- const size = profile.field(visualProfile, "visual", "size"), inline = intrinsic === null ? "auto" : intrinsicInlineSize(context.input.scope, intrinsic, size);
685
- out.rule(path, { display, "max-inline-size": "100%", "max-block-size": size, "inline-size": inline, "block-size": "auto", "object-fit": "contain" });
757
+ const size = profile.field(visualProfile, "visual", "size"), axisOf = (fields) => {
758
+ const axis = fields["size-axis"] ?? "block";
759
+ return axis === "block" || axis === "inline" ? axis : reject({ kind: "profile-field-unsupported", profile: "visual", field: "size-axis", value: axis });
760
+ }, sized = (cap, axis) => axis === "inline" ? { "inline-size": `min(100%, ${cap})`, "max-block-size": "none" } : { "max-block-size": cap, ...intrinsic === null ? {} : { "inline-size": intrinsicInlineSize(context.input.scope, intrinsic, cap) } };
761
+ out.rule(path, { display, "max-inline-size": "100%", "inline-size": "auto", "block-size": "auto", "object-fit": "contain", ...sized(size, axisOf(visualProfile)) });
686
762
  if (conditioned !== null && inCondition !== null) {
687
763
  if (covers(inCondition))
688
764
  return unsupported("media");
689
765
  const narrow = profile.field(inCondition, "visual", "size");
690
- out.rule(path, { "max-block-size": narrow, ...intrinsic === null ? {} : { "inline-size": intrinsicInlineSize(context.input.scope, intrinsic, narrow) } }, conditioned.query);
766
+ out.rule(path, sized(narrow, axisOf(inCondition)), conditioned.query);
691
767
  }
692
768
  return;
693
769
  }
@@ -718,7 +794,7 @@ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null
718
794
  return;
719
795
  }
720
796
  const geometry = visualPart(visual.asset, visualProfile, visual.state, visual.theme, reject);
721
- out.rule(path, inBox(geometry.part));
797
+ out.rule(path, { ...inBox(geometry.part), ...scheme === null ? {} : { display: schemeDisplay(scheme, geometry.part.display ?? "inline-flex") } });
722
798
  out.rule(`${path} > ${geometry.element}`, geometry.media);
723
799
  if (conditioned !== null && inCondition !== null) {
724
800
  const other = visualPart(visual.asset, inCondition, visual.state, visual.theme, reject);
@@ -745,7 +821,8 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
745
821
  switch (layer.kind) {
746
822
  case "modal-sheet":
747
823
  sheetQuery(layer, slots, profile, foundation, reject);
748
- return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion };
824
+ const layerFields = layer.edge === "center" || layer.edge === "block-start" ? profile.of(slots["layer-profile"], "layer", "layer") : null, inline = layerFields === null ? null : profile.field(layerFields, "layer", "viewport-margin"), margin = inline === null || layerFields === null ? null : { inline, block: layer.edge === "block-start" ? layerFields["edge-gap"] ?? inline : inline };
825
+ return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin };
749
826
  case "measured-popover": {
750
827
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
751
828
  profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin"]);
@@ -804,7 +881,7 @@ export function lowerRegion(spec, foundation, input) {
804
881
  out.own(paintProperty(input.scope, paint.name));
805
882
  for (const token of paintTokens(paints))
806
883
  out.use(`var(${token})`);
807
- const placedArtwork = [], placedByPart = new Map, targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), context = { out, profile, slots, input, reject, placedArtwork, placedByPart, foundation, targets, neighbours, rootNormalized, coverBox }, surface = slots["surface-profile"] ?? spec.surface;
884
+ const placedArtwork = [], placedByPart = new Map, targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), placed = [], context = { out, profile, slots, input, reject, placedArtwork, placedByPart, foundation, targets, neighbours, placed, carry: spec.carry, rootNormalized, coverBox }, surface = slots["surface-profile"] ?? spec.surface;
808
885
  checkSurfaceEffects(foundation, profile, [slots["surface-profile"], spec.surface, ...spec.when.map(([, name]) => name)], spec.overflow.kind === "scroll" ? "scroller" : "container", reject);
809
886
  const press = spec.press.when.length === 0 ? null : writeRootPress(out, spec.press, profile.of(slots["motion-profile"], "motion", spec.profile ?? "recipe"), profile, reject), rootSurface = surface === null ? {} : profile.of(surface, "surface"), restFramed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootGeometry = writeStateGeometry("&", "&", {
810
887
  frame: restFramed === null ? null : regionFrameValues(restFramed, slots, surface, profile, reject).values,
@@ -859,6 +936,11 @@ export function lowerRegion(spec, foundation, input) {
859
936
  if (Object.keys(changed).length > 0)
860
937
  out.rule("&", changed, ["media", conditionQueries(bound).inside]);
861
938
  }
939
+ if (spec.element?.kind === "table" && arrangement.layout !== "inline" && spec.extent === "container") {
940
+ if (values["inline-size"] !== void 0)
941
+ return reject({ kind: "extent-conflict", element: "&", property: "inline-size", providers: ["frame", "extent"] });
942
+ values["inline-size"] = "100%";
943
+ }
862
944
  if (arrangement.layout === "inline" && spec.layer === null) {
863
945
  const fixed = values["inline-size"] !== void 0;
864
946
  if (spec.extent === "container") {
@@ -914,6 +996,11 @@ export function lowerRegion(spec, foundation, input) {
914
996
  out.rule("&", { ...settled(values, entering?.blurred ?? !1) });
915
997
  if (spec.normalize.length > 0)
916
998
  out.rule("&", normalizedDeclarations(spec.normalize));
999
+ if (input.native?.includes("&") === !0) {
1000
+ const reset = nativeReset({ ...values, ...Object.fromEntries(spec.normalize) });
1001
+ if (Object.keys(reset).length > 0)
1002
+ out.rule("&", reset);
1003
+ }
917
1004
  writeHitArea(out, "&", rootHitArea);
918
1005
  }
919
1006
  if (rootSnap !== null)
@@ -922,7 +1009,13 @@ export function lowerRegion(spec, foundation, input) {
922
1009
  out.rule(selector, normalizedDeclarations(normalized));
923
1010
  stateRules(out, "&", spec.when, profile, entering?.blurred ?? !1);
924
1011
  const partLayout = spec.exposeRows.length > 0 ? "grid" : arrangement.layout;
925
- lowerParts(spec.parts, "&", partLayout, values.gap, context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps);
926
- return out.finish({ kind: "region", artwork: placedArtwork[0] ?? null, artworks: placedByPart, exposed, targets: { elements: targets, neighbours } }, input.hidden);
1012
+ lowerParts(spec.parts, "&", partLayout, values.gap ?? values["column-gap"], context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps);
1013
+ if (spec.carry) {
1014
+ if (partLayout !== "stack")
1015
+ return reject({ kind: "space-parent-unsupported", part: "&", layout: partLayout });
1016
+ out.own(FLOW_GAP);
1017
+ out.rule("& > *", { [FLOW_GAP]: values.gap ?? "0px" });
1018
+ }
1019
+ return out.finish({ kind: "region", artwork: placedArtwork[0] ?? null, artworks: placedByPart, exposed, targets: { elements: targets, neighbours, ...placed.length === 0 ? {} : { placed } } }, input.hidden);
927
1020
  });
928
1021
  }
@@ -14,9 +14,48 @@ export async function axeRun({
14
14
  }), reason = (node) => {
15
15
  const checks = [...node.any, ...node.all, ...node.none], key = (check) => check?.data?.messageKey, check = checks.find((item) => key(item)) ?? checks[0];
16
16
  return clip(key(check) ?? check?.id ?? "", 80);
17
+ }, enlarged = (node) => {
18
+ const [first] = node.target;
19
+ if (typeof first !== "string")
20
+ return !1;
21
+ const element = document.querySelector(first);
22
+ if (element === null)
23
+ return !1;
24
+ const drawn = element instanceof HTMLInputElement && getComputedStyle(element).opacity === "0" ? element.nextElementSibling : null;
25
+ return [element, drawn].some((holder) => {
26
+ if (holder === null)
27
+ return !1;
28
+ const after = getComputedStyle(holder, "::after");
29
+ if (after.content === "none" || after.content === "normal" || after.position !== "absolute")
30
+ return !1;
31
+ return Number.parseFloat(after.width) >= 24 && Number.parseFloat(after.height) >= 24;
32
+ });
33
+ }, labelled = (node) => {
34
+ const [first] = node.target;
35
+ if (typeof first !== "string")
36
+ return !1;
37
+ const element = document.querySelector(first), name = element?.getAttribute("aria-label")?.trim().toLowerCase();
38
+ if (element === null || element === void 0 || !name)
39
+ return !1;
40
+ let visible = "";
41
+ const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
42
+ for (let text = walker.nextNode();text !== null; text = walker.nextNode())
43
+ if (text.parentElement?.closest('[aria-hidden="true"]') === null)
44
+ visible += ` ${text.textContent ?? ""}`;
45
+ const label = visible.replace(/\s+/g, " ").trim().toLowerCase();
46
+ return label === "" || name.includes(label);
17
47
  };
18
48
  return {
19
- violations: outcome.violations.map((violation) => ({
49
+ violations: outcome.violations.flatMap((violation) => {
50
+ if (violation.id === "label-content-name-mismatch") {
51
+ const nodes = violation.nodes.filter((node) => !labelled(node));
52
+ return nodes.length === 0 ? [] : [{ ...violation, nodes }];
53
+ }
54
+ if (violation.id !== "target-size")
55
+ return [violation];
56
+ const nodes = violation.nodes.filter((node) => !enlarged(node));
57
+ return nodes.length === 0 ? [] : [{ ...violation, nodes }];
58
+ }).map((violation) => ({
20
59
  ...group(violation),
21
60
  nodes: violation.nodes.slice(0, nodeLimit).map((node) => ({ selector: selector(node), html: html(node), summary: clip(node.failureSummary, 500) }))
22
61
  })),
@@ -0,0 +1,37 @@
1
+ export function forcedStates({ nodeLimit }) {
2
+ const attributes = ["aria-selected", "aria-pressed", "aria-checked", "aria-current"], describe = (element) => {
3
+ const id = element.id ? `#${element.id}` : "", classes = [...element.classList].slice(0, 3).map((name) => `.${name}`).join("");
4
+ return `${element.tagName.toLowerCase()}${id}${classes}`.slice(0, 200);
5
+ }, look = (element) => {
6
+ const style = getComputedStyle(element);
7
+ return [
8
+ style.color,
9
+ style.backgroundColor,
10
+ style.borderTopColor,
11
+ style.borderTopWidth,
12
+ style.borderTopStyle,
13
+ style.borderBottomWidth,
14
+ style.outlineStyle,
15
+ style.outlineWidth,
16
+ style.outlineColor,
17
+ style.textDecorationLine,
18
+ style.fontWeight
19
+ ].join("|");
20
+ }, drawn = (element) => [element, ...element.querySelectorAll("*")].map((node) => `${node.tagName}:${look(node)}`).join(";"), meant = (value) => value !== null && value !== "false", issues = [];
21
+ for (const attribute of attributes)
22
+ for (const element of document.querySelectorAll(`#root [${attribute}]`)) {
23
+ if (issues.length >= nodeLimit)
24
+ break;
25
+ if (!meant(element.getAttribute(attribute)))
26
+ continue;
27
+ const parent = element.parentElement;
28
+ if (parent === null)
29
+ continue;
30
+ const sibling = [...parent.children].find((other) => other !== element && other.tagName === element.tagName && !meant(other.getAttribute(attribute)));
31
+ if (sibling === void 0)
32
+ continue;
33
+ if (drawn(element) === drawn(sibling))
34
+ issues.push({ selector: describe(element), attribute, sibling: describe(sibling) });
35
+ }
36
+ return { issues };
37
+ }
@@ -44,7 +44,7 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
44
44
  }
45
45
  return found;
46
46
  function measure() {
47
- const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, container: 0, clipped: 0, "block-clipped": 0, spilled: 0, overlap: 0, "focus-clipped": 0 }, pane = container ? scope.getBoundingClientRect() : { left: 0, right: width }, edge = container ? "container" : "viewport", selector = (element) => {
47
+ const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, container: 0, clipped: 0, "broken-word": 0, "collapsed-scroller": 0, "block-clipped": 0, spilled: 0, overlap: 0, "focus-clipped": 0 }, pane = container ? scope.getBoundingClientRect() : { left: 0, right: width }, edge = container ? "container" : "viewport", selector = (element) => {
48
48
  const parts = [];
49
49
  for (let node = element;node !== scope; ) {
50
50
  const parent = node.parentElement;
@@ -90,7 +90,7 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
90
90
  const known = exempt.get(element);
91
91
  if (known !== void 0)
92
92
  return known;
93
- const style = getComputedStyle(element), box = element.getBoundingClientRect(), value = /^(?:auto|scroll)$/.test(style.overflowX) && !frame(element) || style.position === "fixed" || style.clip !== "auto" && style.position === "absolute" || style.clipPath !== "none" || (box.width <= 1 || box.height <= 1) && style.overflow !== "visible" || excluded(element.parentElement);
93
+ const style = getComputedStyle(element), box = element.getBoundingClientRect(), value = /^(?:auto|scroll)$/.test(style.overflowX) && !frame(element) || style.position === "fixed" || style.clip !== "auto" && style.position === "absolute" || style.clipPath !== "none" || (box.width <= 1 || box.height <= 1) && style.overflow !== "visible" || element.hasAttribute("inert") && (box.width <= 1 || box.height <= 1) || excluded(element.parentElement);
94
94
  exempt.set(element, value);
95
95
  return value;
96
96
  }
@@ -125,6 +125,13 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
125
125
  continue;
126
126
  if (node.matches(focusable))
127
127
  consider(past(node.getBoundingClientRect()), "control", node);
128
+ else {
129
+ const bordered = ["Top", "Right", "Bottom", "Left"].some((side) => Number.parseFloat(style.getPropertyValue(`border-${side.toLowerCase()}-width`)) > 0 && style.getPropertyValue(`border-${side.toLowerCase()}-style`) !== "none"), filled = !/rgba?\([^)]*,\s*0\)|transparent/.test(style.backgroundColor) && style.backgroundColor !== "";
130
+ if (bordered || filled) {
131
+ const edge = Math.max(Number.parseFloat(style.borderTopWidth) || 0, Number.parseFloat(style.borderBottomWidth) || 0);
132
+ consider(past(node.getBoundingClientRect()) - edge, "box", node);
133
+ }
134
+ }
128
135
  if (/^(?:hidden|clip|auto|scroll)$/.test(inline ? style.overflowX : style.overflowY)) {
129
136
  if (node.textContent?.trim())
130
137
  consider(past(node.getBoundingClientRect()), "text", node);
@@ -137,6 +144,16 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
137
144
  range.detach();
138
145
  return best;
139
146
  }
147
+ for (const element of scope.querySelectorAll("*")) {
148
+ const style = getComputedStyle(element);
149
+ if (!/^(?:auto|scroll)$/.test(style.overflowY) && !/^(?:auto|scroll)$/.test(style.overflowX))
150
+ continue;
151
+ if (element.closest("[inert], [hidden], [aria-hidden='true']") || style.display === "none" || style.visibility === "hidden")
152
+ continue;
153
+ const box = element.getBoundingClientRect(), blockCollapsed = /^(?:auto|scroll)$/.test(style.overflowY) && box.height < 2 && element.scrollHeight > 8, inlineCollapsed = /^(?:auto|scroll)$/.test(style.overflowX) && box.width < 2 && element.scrollWidth > 8;
154
+ if (blockCollapsed || inlineCollapsed)
155
+ report("collapsed-scroller", element, { overflow: blockCollapsed ? element.scrollHeight : element.scrollWidth });
156
+ }
140
157
  const measured = [];
141
158
  for (const element of scope.querySelectorAll("*")) {
142
159
  if (element.closest("#ads-preview-status") || element.closest("svg") && element.localName !== "svg")
@@ -158,6 +175,39 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
158
175
  }, parent = element.parentElement === scope || !element.parentElement ? pane : element.parentElement.getBoundingClientRect();
159
176
  if ((box.right > pane.right + 1 || box.left < pane.left - 1) && !(parent.right > pane.right + 1 || parent.left < pane.left - 1) && !contained() && forced(element))
160
177
  report(edge, element, { overflow: Math.round(Math.max(box.right - pane.right, pane.left - box.left)) });
178
+ {
179
+ let broken = 0;
180
+ const flowing = style.textOverflow !== "ellipsis" && !style.whiteSpace.startsWith("pre") && !style.whiteSpace.startsWith("break");
181
+ for (const node of flowing ? element.childNodes : []) {
182
+ if (node.nodeType !== Node.TEXT_NODE)
183
+ continue;
184
+ const text = node.textContent ?? "";
185
+ for (const match of text.matchAll(/[^\s]+/g)) {
186
+ const word = match[0];
187
+ if (word.length < 2 || word.length > 24 || /[/\\._:@=?&#-]/.test(word))
188
+ continue;
189
+ const range = document.createRange();
190
+ range.setStart(node, match.index ?? 0);
191
+ range.setEnd(node, (match.index ?? 0) + word.length);
192
+ const tops = new Set([...range.getClientRects()].filter((rect) => rect.width > 0).map((rect) => Math.round(rect.top)));
193
+ range.detach();
194
+ if (tops.size > 1)
195
+ broken++;
196
+ }
197
+ }
198
+ const field = element instanceof HTMLTextAreaElement ? element : null;
199
+ if (broken === 0 && field !== null && field.placeholder && !field.value) {
200
+ const context = document.createElement("canvas").getContext("2d");
201
+ if (context !== null) {
202
+ context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
203
+ const inner = field.clientWidth - Number.parseFloat(style.paddingLeft) - Number.parseFloat(style.paddingRight), words = field.placeholder.split(/\s+/).filter((word) => word.length >= 2 && word.length <= 24 && !/[/\\._:@=?&#-]/.test(word));
204
+ if (inner > 0 && words.some((word) => context.measureText(word).width > inner + 1))
205
+ broken++;
206
+ }
207
+ }
208
+ if (broken > 0)
209
+ report("broken-word", element, { overflow: broken });
210
+ }
161
211
  if (/^(?:hidden|clip)$/.test(style.overflowX) && element.scrollWidth > element.clientWidth + 4 && style.textOverflow !== "ellipsis" && !element.closest('[aria-roledescription="carousel"], [role="application"]') && !/^(?:input|textarea|select)$/.test(element.localName) && style.clip === "auto" && style.clipPath === "none" && forced(element)) {
162
212
  const cut = meaningfulReach(element, !0);
163
213
  if (cut !== null && cut.reach > 4)
@@ -121,17 +121,21 @@ export function nonTextContrast({ nodeLimit, scope, declared: declarations = []
121
121
  }
122
122
  const icon = (busy || !text(element)) && [...element.querySelectorAll("svg")].find((svg) => svg.checkVisibility({ checkOpacity: !0, checkVisibilityCSS: !0 }));
123
123
  if (icon) {
124
- const shape = [...icon.querySelectorAll("path, circle, rect, ellipse, line, polyline, polygon, use, text")].find((node) => {
125
- const paint = getComputedStyle(node);
126
- return paint.stroke !== "none" && rgba(paint.stroke)[3] > 0 || paint.fill !== "none" && !paint.fill.startsWith("url(") && rgba(paint.fill)[3] > 0;
127
- });
128
- if (shape) {
129
- const paint = getComputedStyle(shape), value = paint.stroke !== "none" && rgba(paint.stroke)[3] > 0 ? paint.stroke : paint.fill, color = rgba(value).slice();
130
- color[3] *= opacity(shape, element) / Number(style.opacity);
131
- const back = background(shape.parentElement) ?? own, measured = ratio(color, back);
132
- if (measured + 0.000000001 < 3)
133
- report("icon", measured, over(color, back), back);
124
+ let best = null;
125
+ for (const shape of icon.querySelectorAll("path, circle, rect, ellipse, line, polyline, polygon, use, text")) {
126
+ const paint = getComputedStyle(shape);
127
+ for (const value of [paint.stroke, paint.fill]) {
128
+ if (value === "none" || value.startsWith("url(") || rgba(value)[3] <= 0)
129
+ continue;
130
+ const color = rgba(value).slice();
131
+ color[3] *= opacity(shape, element) / Number(style.opacity);
132
+ const back = background(shape.parentElement) ?? own, measured = ratio(color, back);
133
+ if (best === null || measured > best.measured)
134
+ best = { measured, color, back };
135
+ }
134
136
  }
137
+ if (best !== null && best.measured + 0.000000001 < 3)
138
+ report("icon", best.measured, over(best.color, best.back), best.back);
135
139
  }
136
140
  }
137
141
  return { issues, counts, ...declaredHits.length ? { declared: declaredHits } : {} };
@@ -9,6 +9,7 @@ import { layoutOverflow } from "./layout-overflow.page.mjs";
9
9
  import { layoutShift } from "./layout-shift.page.mjs";
10
10
  import { imageShape } from "./image-shape.page.mjs";
11
11
  import { cornerOverpaint } from "./corner-overpaint.page.mjs";
12
+ import { forcedStates } from "./forced-states.page.mjs";
12
13
  import { overflowOnly, overridePasses, viewportPasses } from "./text-scale.mjs";
13
14
  import { auditRenderStates, listTargets } from "./render-states.mjs";
14
15
  import { brandReady, hasAxe, hasMainLandmark, markRenderAudit, setScenarioState, themeReady } from "./worker.page.mjs";
@@ -109,6 +110,38 @@ try {
109
110
  };
110
111
  }
111
112
  }
113
+ async function environmentPass(app, environment) {
114
+ if (browser === void 0)
115
+ throw Error("The audit browser is not running.");
116
+ const own = await browser.newContext({
117
+ viewport: request.viewport,
118
+ deviceScaleFactor: 1,
119
+ colorScheme: app.scheme,
120
+ bypassCSP: !0,
121
+ reducedMotion: "reduce",
122
+ ...environment === "forced-colors" ? { forcedColors: "active" } : { hasTouch: !0 }
123
+ });
124
+ try {
125
+ await own.addInitScript(markRenderAudit);
126
+ const page = await own.newPage();
127
+ if (app.state !== void 0)
128
+ await page.addInitScript(setScenarioState, app.state);
129
+ const url = new URL(app.url);
130
+ url.searchParams.set("environment", environment);
131
+ const opened = await openPreviewScenario(page, url.href, app.scenario, { timeout });
132
+ await opened.waitForFunction(themeReady, app.theme, { timeout });
133
+ if (app.brand)
134
+ await opened.waitForFunction(brandReady, app.brand, { timeout });
135
+ await page.mouse.move(request.viewport.width - 1, request.viewport.height - 1);
136
+ await opened.evaluate(firstRender);
137
+ if (!await opened.evaluate(hasAxe))
138
+ await opened.addScriptTag({ content: axe });
139
+ const found = await opened.evaluate(axeRun, { tags: request.tags, nodeLimit: request.nodeLimit }), forced = environment === "forced-colors" ? (await opened.evaluate(forcedStates, { nodeLimit: request.nodeLimit })).issues : void 0;
140
+ return { environment, ...found, ...forced === void 0 ? {} : { forced } };
141
+ } finally {
142
+ await own.close().catch(() => {});
143
+ }
144
+ }
112
145
  async function audit(app, partial, index) {
113
146
  const page = await context.newPage();
114
147
  if (app.state !== void 0)
@@ -187,6 +220,11 @@ try {
187
220
  if (app.text) {
188
221
  textScale.push(...await viewportPasses(page, frame, { nodeLimit: request.nodeLimit, widths: request.textWidths, height: request.viewport.height, rest }));
189
222
  result.textScale = textScale;
223
+ const environments = [];
224
+ for (const environment of request.environments ?? [])
225
+ environments.push(await environmentPass(app, environment));
226
+ if (environments.length > 0)
227
+ result.environments = environments;
190
228
  }
191
229
  const assigned = await turns[index] ?? { triggers: [], controls: [] };
192
230
  await auditRenderStates({ page, frame, result, request, phoneWidth: request.overflowWidths[0], assigned });