@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
@@ -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")) {
@@ -335,37 +340,105 @@ function pseudoColor(treatment, surface, profile, reject) {
335
340
  return reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: other });
336
341
  return fields.color ?? reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: null });
337
342
  }
338
- function pseudoRules(part, path, context) {
339
- const { out, profile, reject, foundation } = context, background = (surface) => surface === null ? null : profile.of(surface, "surface").background ?? null, fills = [{ condition: null, value: background(part.surface) }, ...part.when.map(([condition, surface]) => ({ condition, value: background(surface) }))];
340
- for (const treatment of part.pseudo)
343
+ const PSEUDO_TEXT_FIELDS = ["font-weight", "font-feature-settings"];
344
+ function pseudoText(treatment, text, profile, reject) {
345
+ const fields = profile.of(text, "text"), other = Object.keys(fields).find((field) => !PSEUDO_TEXT_FIELDS.includes(field));
346
+ if (other !== void 0)
347
+ return reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface: text, field: other });
348
+ return { ...fields };
349
+ }
350
+ const cssString = (text) => `"${text.replace(/[\\"]/g, (character) => `\\${character}`)}"`;
351
+ export function contentValue(content) {
352
+ const value = content.kind === "counter" ? `counter(${content.name}, ${content.style})` : `counters(${content.name}, ${cssString(content.separator)}, ${content.style})`;
353
+ return [...content.prefix === "" ? [] : [cssString(content.prefix)], value, ...content.suffix === "" ? [] : [cssString(content.suffix)]].join(" ");
354
+ }
355
+ function writeBetween(out, path, between, axis, profile, reject) {
356
+ if (between === null)
357
+ return;
358
+ const frame = profile.of(between.frame, "frame"), width = frame["border-width"] ?? reject({ kind: "profile-field-missing", profile: between.frame, field: "borderWidth" }), color = profile.of(between.surface, "surface")["border-color"] ?? reject({ kind: "profile-field-missing", profile: between.surface, field: "borderColor" }), side = `border-${axis}-start`;
359
+ out.rule(`${path} > * + *`, { [`${side}-width`]: width, [`${side}-style`]: frame[BORDER_STYLE] ?? "solid", [`${side}-color`]: color });
360
+ }
361
+ const ASSISTIVE_ONLY = { position: "absolute", "inline-size": "1px", "block-size": "1px", overflow: "hidden", "clip-path": "inset(50%)", "white-space": "nowrap" }, counterValues = (counter) => counter === null ? {} : { ...counter.reset === null ? {} : { "counter-reset": counter.reset }, ...counter.increment === null ? {} : { "counter-increment": counter.increment } };
362
+ function writeMarkerStyles(out, styles) {
363
+ styles.forEach((style, depth) => out.rule(`&${" li &".repeat(depth)}`, { "list-style-type": style }));
364
+ }
365
+ function pseudoRules(name, treatments, path, fills, context, hasBox) {
366
+ const { out, profile, reject, foundation } = context;
367
+ for (const treatment of treatments)
341
368
  switch (treatment.pseudo) {
342
369
  case "placeholder": {
343
- const suffix = "::placeholder", base = pseudoColor(treatment, treatment.surface, profile, reject), states = treatment.when.map(([condition, surface]) => ({ condition, value: pseudoColor(treatment, surface, profile, reject) }));
370
+ const suffix = "::placeholder", surface = treatment.surface ?? "", base = pseudoColor(treatment, surface, profile, reject), states = treatment.when.map(([condition, state]) => ({ condition, value: pseudoColor(treatment, state, profile, reject) }));
344
371
  out.rule(`${path}${suffix}`, { color: base, opacity: "1" });
345
372
  for (const { condition, value } of states)
346
373
  out.rule(`${under(condition, path)}${suffix}`, { color: value });
347
- const checked = checkPlaceholderContrast(foundation, part.name, [{ condition: null, value: base }, ...states], fills);
374
+ const checked = checkPlaceholderContrast(foundation, name, [{ condition: null, value: base }, ...states], fills);
348
375
  if (checked.kind === "err")
349
376
  return reject(checked.error);
350
377
  break;
351
378
  }
352
379
  case "progressValue": {
353
- const base = pseudoFill(treatment, treatment.surface, profile, reject), states = treatment.when.map(([condition, surface]) => ({ condition, value: pseudoFill(treatment, surface, profile, reject) }));
354
- out.rule(path, { appearance: "none", "-webkit-appearance": "none", ...part.box === null ? { "border-style": "none" } : {} });
380
+ const surface = treatment.surface ?? "", base = pseudoFill(treatment, surface, profile, reject), states = treatment.when.map(([condition, state]) => ({ condition, value: pseudoFill(treatment, state, profile, reject) }));
381
+ out.rule(path, { appearance: "none", "-webkit-appearance": "none", ...hasBox ? {} : { "border-style": "none" } });
355
382
  out.rule(`${path}::-webkit-progress-bar`, { background: "transparent" });
356
383
  for (const suffix of PROGRESS_FILLS) {
357
384
  out.rule(`${path}${suffix}`, { background: base, "border-radius": "inherit" });
358
385
  for (const { condition, value } of states)
359
386
  out.rule(`${under(condition, path)}${suffix}`, { background: value });
360
387
  }
361
- const checked = checkProgressContrast(foundation, part.name, [{ condition: null, value: base }, ...states], fills);
388
+ const checked = checkProgressContrast(foundation, name, [{ condition: null, value: base }, ...states], fills);
362
389
  if (checked.kind === "err")
363
390
  return reject(checked.error);
364
391
  break;
365
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
+ }
427
+ case "marker":
428
+ case "before": {
429
+ const suffix = `::${treatment.pseudo}`, values = {
430
+ ...treatment.content === null ? {} : { content: contentValue(treatment.content) },
431
+ ...treatment.surface === null ? {} : { color: pseudoColor(treatment, treatment.surface, profile, reject) },
432
+ ...treatment.text === null ? {} : pseudoText(treatment, treatment.text, profile, reject)
433
+ };
434
+ out.rule(`${path}${suffix}`, values);
435
+ for (const [condition, state] of treatment.when)
436
+ out.rule(`${under(condition, path)}${suffix}`, { color: pseudoColor(treatment, state, profile, reject) });
437
+ break;
438
+ }
366
439
  }
367
440
  }
368
- 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"];
369
442
  function pseudoFill(treatment, surface, profile, reject) {
370
443
  const fields = profile.of(surface, "surface"), other = Object.keys(fields).find((field) => field !== "background");
371
444
  if (other !== void 0)
@@ -431,15 +504,36 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
431
504
  return context.reject({ kind: "profile-field-missing", profile: drawing.box ?? drawing.name, field: inline === void 0 ? "inlineSize" : "blockSize" });
432
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" });
433
506
  }
434
- writePartSpace(parts, parent, layout, gap, context);
507
+ writePartSpace(parts, parent, layout, gap, context, context.carry);
435
508
  const lowered = parts.map((part) => lowerPart(part, parent, layout, context, parentGrows, overlapping));
436
509
  if (layout !== "inline" && layout !== "stack")
437
510
  return;
438
- const axes = layout === "inline" ? ["inline"] : ["block"];
439
- lowered.flatMap((first, index) => {
511
+ const axes = layout === "inline" ? ["inline"] : ["block"], pairs = lowered.flatMap((first, index) => {
440
512
  const own = first !== null && parts[index]?.repeat === !0 ? [[first, first]] : [], second = lowered[index + 1];
441
513
  return first === null || second === null || second === void 0 ? own : [...own, [first, second]];
442
- }).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]) => {
443
537
  if (overlapping !== null)
444
538
  return context.reject({ kind: "state-geometry-unsupported", element: parent === "&" ? "&" : parent, reason: "targets-overlap", detail: `${first.element} and ${second.element}` });
445
539
  for (const axis of axes)
@@ -447,25 +541,41 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
447
541
  context.neighbours.push({ axis, gap: between, first, second });
448
542
  });
449
543
  }
450
- function writePartSpace(parts, parent, layout, gap, context) {
451
- const spaced = parts.filter((part) => part.spaceBefore !== null || part.spaceAfter !== null);
452
- if (spaced.length === 0)
544
+ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
545
+ const { out, profile, slots } = context, own = (part, side) => {
546
+ const binding = side === "before" ? part.spaceBefore : part.spaceAfter;
547
+ if (binding !== null)
548
+ return profile.field(profile.of(slots["spacing-profile"], "spacing", "space"), "spacing", kebab(binding.field));
549
+ return part.spacing === null ? null : profile.of(part.spacing, "spacing", part.name)[`space-${side}`] ?? null;
550
+ }, spaced = parts.flatMap((part) => {
551
+ const before = own(part, "before"), after = own(part, "after");
552
+ if (part.spacing !== null && before === null && after === null)
553
+ return context.reject({ kind: "profile-field-missing", profile: part.spacing, field: "spaceBefore" });
554
+ return before === null && after === null ? [] : [{ part, before, after }];
555
+ }), [first] = spaced;
556
+ if (first === void 0)
453
557
  return;
454
- const [first] = spaced;
455
- if (layout !== "stack" && layout !== "native" && first !== void 0)
456
- return context.reject({ kind: "space-parent-unsupported", part: first.name, layout });
457
- const { out, profile, slots } = context, spacing = (binding) => profile.field(profile.of(slots["spacing-profile"], "spacing", "space"), "spacing", kebab(binding.field)), between = gap ?? "0px", margin = (space) => ({ "margin-block-start": `calc(${space} - ${between})` });
458
- for (const part of spaced) {
459
- if (part.spaceBefore !== null)
460
- out.rule(`${parent} > * + ${part.selector}`, margin(spacing(part.spaceBefore)));
461
- if (part.spaceAfter !== null)
462
- out.rule(`${parent} > ${part.selector} + :not(:first-child)`, margin(spacing(part.spaceAfter)));
558
+ if (layout !== "stack" && layout !== "native")
559
+ return context.reject({ kind: "space-parent-unsupported", part: first.part.name, layout });
560
+ const between = gap ?? "0px", margin = (space) => ({ "margin-block-start": `calc(${space} - ${between})` });
561
+ for (const { part, before, after } of spaced) {
562
+ if (before !== null)
563
+ out.rule(`${parent} > * + ${part.selector}:not(:first-child)`, margin(before));
564
+ if (after !== null)
565
+ out.rule(`${parent} > ${part.selector} + :not(:first-child):not(:first-child)`, margin(after));
566
+ }
567
+ for (const previous of spaced)
568
+ for (const next of spaced)
569
+ if (previous.after !== null && next.before !== null)
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)))` });
463
576
  }
464
- for (const before of spaced)
465
- for (const after of spaced)
466
- if (before.spaceAfter !== null && after.spaceBefore !== null)
467
- out.rule(`${parent} > ${before.selector} + ${after.selector}:not(:first-child)`, margin(`max(${spacing(before.spaceAfter)}, ${spacing(after.spaceBefore)})`));
468
577
  }
578
+ const FLOW_GAP = "--ads-flow-gap";
469
579
  function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping = null) {
470
580
  const { out, profile, slots, reject } = context, path = `${parent} > ${part.selector}`;
471
581
  if (part.content.kind === "vector") {
@@ -530,7 +640,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
530
640
  Object.assign(values, { "box-sizing": "border-box" }, boxFields);
531
641
  let target = null, frameFields = {};
532
642
  if (part.frame !== null) {
533
- const lineHeight = profile.field(text, "text", "line-height"), frame = profile.of(slots["frame-profile"], "frame", "control"), box = controlBox(frame, LINE_BOX, profile.field, reject);
643
+ const lineText = text["line-height"] === void 0 && slots["text-profile"] !== void 0 ? profile.of(slots["text-profile"], "text") : text, lineHeight = profile.field(lineText, "text", "line-height"), frame = profile.of(slots["frame-profile"], "frame", "control"), box = controlBox(frame, LINE_BOX, profile.field, reject);
534
644
  frameFields = controlBoxValues(box);
535
645
  if (part.frame.border.kind === "rules") {
536
646
  const paint = part.surface === null ? void 0 : profile.of(part.surface, "surface")["border-color"], rules = checked(frameRules(part.frame.border, frame["border-width"], { surface: part.surface, color: paint }, slots["frame-profile"] ?? null, frame[BORDER_STYLE]), reject);
@@ -541,14 +651,15 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
541
651
  if (!part.frame.border.sides.includes(side))
542
652
  frameFields[`padding-${side}`] = `calc(${frameFields[`padding-${side}`]} + ${box.border})`;
543
653
  }
544
- 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);
545
656
  const hitArea = hitAreaOf(frame);
546
657
  writeHitArea(out, path, hitArea);
547
658
  target = {
548
659
  element: part.name,
549
660
  frame: frameTarget(frame, box, profile.field),
550
661
  hitArea,
551
- content: { kind: "field", line: { lineHeight, fontSize: text["font-size"] ?? null } },
662
+ content: { kind: "field", line: { lineHeight, fontSize: lineText["font-size"] ?? null } },
552
663
  measured: measuredBounds(part.measured, values)
553
664
  };
554
665
  context.targets.push(target);
@@ -580,14 +691,22 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
580
691
  if (twice !== void 0)
581
692
  return reject({ kind: "extent-conflict", element: part.name, property: twice[0], providers: ["recipe.normalize.when", "normalize"] });
582
693
  add(normalizedDeclarations(part.normalize), "normalize");
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"));
695
+ if (context.input.margined?.includes(pathKey) === !0 && !ownMargin)
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
+ }
583
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;
584
703
  Object.assign(values, checked(measuredWrites(context.input.scope, part.measured, part.name, values, part.frame !== null ? supplied(slots, frameFields) : null, media), reject));
585
704
  Object.assign(values, paintValues(part.name, part.paints, "box", [part.surface], part.when, context));
586
705
  writeConditioned(part, path, values, context);
587
- const conditioned = conditionedVisual(part, context);
588
- 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")
589
708
  return reject({ kind: "scheme-unsupported", part: part.name });
590
- const unrendered = part.content.kind === "visual" && !part.required && visualOf(context.input, part.name) === null;
709
+ const unrendered = part.content.kind === "visual" && (!part.required || context.withinOptional === !0) && visualOf(context.input, part.name) === null;
591
710
  if (part.content.kind === "visual" && !unrendered)
592
711
  lowerVisual(path, context, part.measured.find((value) => value.type === "intrinsic-size") ?? null, conditioned, part.scheme, boxFields, part.name);
593
712
  if (snapped !== null)
@@ -595,8 +714,17 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
595
714
  stateRules(out, path, part.when, profile, entering?.blurred ?? !1);
596
715
  for (const [condition, normalized] of part.normalizeWhen)
597
716
  out.rule(under(condition, path), normalizedDeclarations(normalized));
598
- pseudoRules(part, path, context);
599
- lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap, context, growsWithContent(values), partGeometry.overlap, partGeometry.gaps);
717
+ {
718
+ const background = (surface) => surface === null ? null : profile.of(surface, "surface").background ?? null, fills = [{ condition: null, value: background(part.surface) }, ...part.when.map(([condition, surface]) => ({ condition, value: background(surface) }))];
719
+ pseudoRules(part.name, part.pseudo, path, fills, context, part.box !== null);
720
+ const counted = counterValues(part.counter);
721
+ if (Object.keys(counted).length > 0)
722
+ out.rule(path, counted);
723
+ writeBetween(out, path, part.between, part.arrangement?.layout === "inline" ? "inline" : "block", profile, reject);
724
+ if (part.presence === "assistive")
725
+ out.rule(path, { ...ASSISTIVE_ONLY });
726
+ }
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);
600
728
  return target;
601
729
  }
602
730
  const visualOf = (input, part) => input.visuals?.get(part) ?? input.visual;
@@ -626,13 +754,16 @@ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null
626
754
  out.rule(path, { ...COVER_FILL, display });
627
755
  return;
628
756
  }
629
- const size = profile.field(visualProfile, "visual", "size"), inline = intrinsic === null ? "auto" : intrinsicInlineSize(context.input.scope, intrinsic, size);
630
- 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)) });
631
762
  if (conditioned !== null && inCondition !== null) {
632
763
  if (covers(inCondition))
633
764
  return unsupported("media");
634
765
  const narrow = profile.field(inCondition, "visual", "size");
635
- 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);
636
767
  }
637
768
  return;
638
769
  }
@@ -663,7 +794,7 @@ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null
663
794
  return;
664
795
  }
665
796
  const geometry = visualPart(visual.asset, visualProfile, visual.state, visual.theme, reject);
666
- out.rule(path, inBox(geometry.part));
797
+ out.rule(path, { ...inBox(geometry.part), ...scheme === null ? {} : { display: schemeDisplay(scheme, geometry.part.display ?? "inline-flex") } });
667
798
  out.rule(`${path} > ${geometry.element}`, geometry.media);
668
799
  if (conditioned !== null && inCondition !== null) {
669
800
  const other = visualPart(visual.asset, inCondition, visual.state, visual.theme, reject);
@@ -690,7 +821,8 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
690
821
  switch (layer.kind) {
691
822
  case "modal-sheet":
692
823
  sheetQuery(layer, slots, profile, foundation, reject);
693
- return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion };
824
+ const margin = layer.edge === "center" || layer.edge === "block-start" ? profile.field(profile.of(slots["layer-profile"], "layer", "layer"), "layer", "viewport-margin") : null;
825
+ return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin };
694
826
  case "measured-popover": {
695
827
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
696
828
  profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin"]);
@@ -749,7 +881,7 @@ export function lowerRegion(spec, foundation, input) {
749
881
  out.own(paintProperty(input.scope, paint.name));
750
882
  for (const token of paintTokens(paints))
751
883
  out.use(`var(${token})`);
752
- 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;
753
885
  checkSurfaceEffects(foundation, profile, [slots["surface-profile"], spec.surface, ...spec.when.map(([, name]) => name)], spec.overflow.kind === "scroll" ? "scroller" : "container", reject);
754
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("&", "&", {
755
887
  frame: restFramed === null ? null : regionFrameValues(restFramed, slots, surface, profile, reject).values,
@@ -770,6 +902,13 @@ export function lowerRegion(spec, foundation, input) {
770
902
  const rootGroups = [...press === null ? [] : [press], ...measuredMotion(spec.measured, profile, reject), ...rootGeometry.group === null ? [] : [rootGeometry.group]], entering = writeEnter(out, profile, "&", spec.enter, rootSurface, stateSurfaces("&", spec.when, profile), slots, transitioned(spec.paintTransition, rootGroups), reject);
771
903
  transitionRules("&", spec.paintTransition, surface === null ? null : { name: surface, fields: rootSurface }, spec.when, context, entering === null ? rootGroups : [...rootGroups, entering.group]);
772
904
  writePlays(out, profile, foundation, "&", spec.plays, "&", transitioned(spec.paintTransition, entering === null ? rootGroups : [...rootGroups, entering.group]), reject);
905
+ const rootFill = (name) => name === null ? null : profile.of(name, "surface").background ?? null;
906
+ pseudoRules("&", spec.pseudo, "&", [{ condition: null, value: rootFill(surface) }, ...spec.when.map(([condition, name]) => ({ condition, value: rootFill(name) }))], context, spec.frame !== null);
907
+ const rootCounters = counterValues(spec.counter);
908
+ if (Object.keys(rootCounters).length > 0)
909
+ out.rule("&", rootCounters);
910
+ writeMarkerStyles(out, spec.markers);
911
+ writeBetween(out, "&", spec.between, spec.arrangement.layout === "inline" ? "inline" : "block", profile, reject);
773
912
  const { arrangement } = spec, values = arrangement.layout !== "native" || spec.frame !== null ? { "box-sizing": "border-box", "min-inline-size": "0" } : {};
774
913
  let exposed = null;
775
914
  if (spec.exposeRows.length > 0) {
@@ -797,6 +936,11 @@ export function lowerRegion(spec, foundation, input) {
797
936
  if (Object.keys(changed).length > 0)
798
937
  out.rule("&", changed, ["media", conditionQueries(bound).inside]);
799
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
+ }
800
944
  if (arrangement.layout === "inline" && spec.layer === null) {
801
945
  const fixed = values["inline-size"] !== void 0;
802
946
  if (spec.extent === "container") {
@@ -852,6 +996,11 @@ export function lowerRegion(spec, foundation, input) {
852
996
  out.rule("&", { ...settled(values, entering?.blurred ?? !1) });
853
997
  if (spec.normalize.length > 0)
854
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
+ }
855
1004
  writeHitArea(out, "&", rootHitArea);
856
1005
  }
857
1006
  if (rootSnap !== null)
@@ -860,7 +1009,13 @@ export function lowerRegion(spec, foundation, input) {
860
1009
  out.rule(selector, normalizedDeclarations(normalized));
861
1010
  stateRules(out, "&", spec.when, profile, entering?.blurred ?? !1);
862
1011
  const partLayout = spec.exposeRows.length > 0 ? "grid" : arrangement.layout;
863
- lowerParts(spec.parts, "&", partLayout, values.gap, context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps);
864
- 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);
865
1020
  });
866
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)