@reqvire-org/ads 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/ads-errors.mjs +33 -26
  2. package/dist/analysis/design-usage.mjs +4 -20
  3. package/dist/analysis/mock-check.mjs +4 -5
  4. package/dist/analysis/owner-accessibility.mjs +4 -4
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +35 -3
  7. package/dist/analysis/owner-composition.mjs +75 -13
  8. package/dist/analysis/owner-source.mjs +64 -40
  9. package/dist/composed-contrast.mjs +165 -65
  10. package/dist/construction-output.mjs +12 -5
  11. package/dist/construction-spec.d.mts +125 -50
  12. package/dist/construction-spec.mjs +154 -81
  13. package/dist/corner-overpaint.mjs +5 -4
  14. package/dist/design-foundation.mjs +16 -0
  15. package/dist/design-usage.mjs +2 -8
  16. package/dist/emit/emission.mjs +0 -5
  17. package/dist/grid-lowering.mjs +3 -1
  18. package/dist/lowering-enter.mjs +6 -6
  19. package/dist/lowering-overlaps.mjs +6 -1
  20. package/dist/lowering-properties.mjs +3 -0
  21. package/dist/lowering-session.mjs +10 -0
  22. package/dist/lowering-transitions.mjs +1 -0
  23. package/dist/mcp/server-observation.mjs +6 -4
  24. package/dist/mcp/server-project.mjs +4 -1
  25. package/dist/owner-analysis-check.mjs +4 -1
  26. package/dist/owner-errors.mjs +2 -1
  27. package/dist/owner-lowering.mjs +10 -4
  28. package/dist/owner-scenarios.mjs +2 -22
  29. package/dist/ownership-model.mjs +15 -7
  30. package/dist/paint-contrast.mjs +6 -0
  31. package/dist/platform-features.mjs +6 -0
  32. package/dist/profile-macro.d.mts +7 -0
  33. package/dist/recipe-macro.d.mts +104 -45
  34. package/dist/recipe-model.mjs +19 -12
  35. package/dist/region-lowering.mjs +128 -121
  36. package/dist/role-vocabulary.d.mts +7 -0
  37. package/dist/role-vocabulary.mjs +7 -0
  38. package/dist/runtime-paint-contrast.mjs +5 -2
  39. package/dist/showcase/client.bundle.js +51 -51
  40. package/dist/showcase/http-client.bundle.js +13 -13
  41. package/dist/showcase/ui/ui.css +1 -1
  42. package/dist/showcase/ui/ui.js +6 -6
  43. package/dist/skills/ads-designer/references/accessibility.md +3 -4
  44. package/dist/skills/ads-designer/references/design-data.md +12 -6
  45. package/dist/skills/ads-designer/references/layout.md +7 -3
  46. package/dist/skills/ads-designer/references/motion.md +2 -1
  47. package/dist/skills/ads-designer/references/recipes.md +43 -19
  48. package/dist/skills/ads-import/references/design-data.md +12 -6
  49. package/dist/skills/ads-import/references/layout.md +7 -3
  50. package/dist/skills/ads-import/references/recipes.md +43 -19
  51. package/dist/skills/ads-migrate/SKILL.md +2 -0
  52. package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
  53. package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
  54. package/dist/skills/ads-port/references/design-data.md +12 -6
  55. package/dist/skills/ads-port/references/layout.md +7 -3
  56. package/dist/skills/ads-port/references/recipes.md +43 -19
  57. package/dist/spatial-model.mjs +2 -2
  58. package/dist/surface-contrast.mjs +6 -2
  59. package/dist/target-size.mjs +21 -3
  60. package/docs/ADS.md +9 -3
  61. package/docs/ARCHITECTURE.md +33 -23
  62. package/docs/CACHING.md +1 -1
  63. package/docs/CHANGELOG.md +181 -21
  64. package/docs/GUIDE.md +64 -19
  65. package/docs/LANGUAGE.md +169 -139
  66. package/docs/MCP.md +5 -1
  67. package/docs/MOTION.md +16 -3
  68. package/docs/PROFILE-KINDS.md +52 -5
  69. package/docs/RULES.md +16 -15
  70. package/package.json +1 -1
  71. package/dist/analysis/prose-owners.mjs +0 -57
  72. package/dist/prose-model.d.mts +0 -81
  73. package/dist/prose-model.mjs +0 -101
@@ -81,7 +81,7 @@ import {
81
81
  elementTags,
82
82
  parseConstruction,
83
83
  CONTROL_TEXT_TAGS,
84
- PSEUDO_HOSTS,
84
+ pseudoHosted,
85
85
  VECTOR_SHAPES
86
86
  } from "../construction-spec.mjs";
87
87
  import { recipeDefaults, visualBindingRedundancy } from "../recipe-defaults.mjs";
@@ -172,7 +172,7 @@ function insideMap(node, ancestor) {
172
172
  return !0;
173
173
  return !1;
174
174
  }
175
- const isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), lowercaseTag = (opening) => /^[a-z]/.test(opening.tagName.getText()), NO_CLASSES = { fragments: [], calls: [], markers: [], placement: [], bindings: [] };
175
+ const isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), NO_CLASSES = { fragments: [], calls: [], markers: [], placement: [], bindings: [] };
176
176
  function validateReferences(foundation, spec) {
177
177
  if (typeof spec !== "object" || spec === null)
178
178
  return null;
@@ -266,14 +266,14 @@ export async function checkOwners(root, names, options, reuse) {
266
266
  const { program, graph } = walked.value, emitted = new Set(graph.modules.keys());
267
267
  options.stats.analyses++;
268
268
  const outcomes = new Map, facts = new Map, pass = await timing.timeStage("owner-keys", () => reuse.begin(program, graph));
269
- let plain = { modules: new Map, failures: [], placements: [] }, unemitted = [];
269
+ let plain = { modules: new Map, failures: [], placements: [], composition: new Map }, unemitted = [];
270
270
  await timing.timeStage("owner-facts", async () => {
271
271
  for (const name of names) {
272
272
  throwIfCancelled();
273
273
  const analyze = (foundation, assets) => checkedOwner(root, emitted, name, program, { ...options, foundation, assets }, outcomes, (analyzed) => facts.set(name, analyzed));
274
274
  outcomes.set(name, await pass.owner({ name, settled: outcomes, analyze }));
275
275
  }
276
- plain = await checkedPlainModules(root, graph, program, options.publicAlias, emitted, options.assets);
276
+ plain = await checkedPlainModules(root, graph, program, options.publicAlias, emitted, options.assets, options.foundation);
277
277
  unemitted = [
278
278
  ...(await unemittedStyling(root, emitted)).map(stylingFailure),
279
279
  ...await frameworkMismatches(root, options.framework ?? null),
@@ -299,7 +299,8 @@ export async function checkOwners(root, names, options, reuse) {
299
299
  checkProgram: program,
300
300
  facts,
301
301
  plain: plain.modules,
302
- plainPlacements: plain.placements
302
+ plainPlacements: plain.placements,
303
+ plainComposition: plain.composition
303
304
  });
304
305
  }
305
306
  async function checkedOwner(root, emitted, name, program, options, settled, retain) {
@@ -341,8 +342,8 @@ async function plainModules(root, graph, program, publicAlias, emitted, catalog,
341
342
  }
342
343
  return plain;
343
344
  }
344
- async function checkedPlainModules(root, graph, program, publicAlias, emitted, catalog) {
345
- const modules = new Map, failures = [], placements = [], checker = program.getTypeChecker();
345
+ async function checkedPlainModules(root, graph, program, publicAlias, emitted, catalog, foundation) {
346
+ const modules = new Map, failures = [], placements = [], composition = new Map, checker = program.getTypeChecker();
346
347
  for (const module of graph.modules.values()) {
347
348
  if (module.role === "owner")
348
349
  continue;
@@ -352,14 +353,24 @@ async function checkedPlainModules(root, graph, program, publicAlias, emitted, c
352
353
  switch (checked.kind) {
353
354
  case "ok":
354
355
  modules.set(file, checked.value);
355
- placements.push(...await timing.timeStage("plain-placements", () => plainPlacements(root, checked.value.source, (node) => valueSymbolAt(checker, node))));
356
+ const placed = await timing.timeStage("plain-placements", () => plainPlacements(root, checked.value.source, (node) => valueSymbolAt(checker, node)));
357
+ if (placed.length === 0)
358
+ break;
359
+ const facts = await attemptAsync(async (reject) => {
360
+ const source = checked.value.source, values = await choiceValues({ program, source, root, validateSpec: (spec) => validateReferences(foundation, spec), fail: failAt(reject) });
361
+ return timing.timeStage("plain-composition", () => compositionFacts({ root, source, values, checker, foundation }));
362
+ });
363
+ if (facts.kind === "ok")
364
+ composition.set(file, facts.value);
365
+ else
366
+ placements.push(...placed);
356
367
  break;
357
368
  case "err":
358
369
  failures.push(checked.error);
359
370
  break;
360
371
  }
361
372
  }
362
- return { modules, failures, placements };
373
+ return { modules, failures, placements, composition };
363
374
  }
364
375
  async function plainStyling(root, file, program) {
365
376
  return plainModuleStyling(await programSource(program, path.join(root, file)), program, program.getTypeChecker());
@@ -426,7 +437,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
426
437
  const [stylesheet] = ownerStylesheetImports(source);
427
438
  if (stylesheet !== void 0)
428
439
  return fail(stylesheet.node, stylesheet.problem);
429
- const values = await choiceValues({ program, source, root, validateSpec: (spec) => validateReferences(foundation, spec), fail }), checker = program.getTypeChecker(), [styleWrite] = await ownerStyleWrites(source, program, checker);
440
+ const values = await choiceValues({ program, source, root, validateSpec: (spec) => validateReferences(foundation, spec), fail }), lowercaseTag = (opening) => /^[a-z]/.test(values.tag(opening)), checker = program.getTypeChecker(), [styleWrite] = await ownerStyleWrites(source, program, checker);
430
441
  if (styleWrite !== void 0)
431
442
  return fail(styleWrite.node, styleWrite.problem);
432
443
  const [animation] = await scriptAnimations(source, program, checker);
@@ -530,7 +541,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
530
541
  }
531
542
  async function intrinsicSource(opening, context, resolve) {
532
543
  const images = await children(opening, context, resolve), [image] = images;
533
- if (images.length !== 1 || image === void 0 || image.tagName.getText() !== "img")
544
+ if (images.length !== 1 || image === void 0 || values.tag(image) !== "img")
534
545
  return fail(opening, { kind: "intrinsic-image-count" });
535
546
  const src = expression(attr(image, "src"));
536
547
  if (src === void 0)
@@ -581,9 +592,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
581
592
  const descendants = (opening) => {
582
593
  const element = elementOf(opening);
583
594
  return openings.filter((other) => other !== opening && other.getStart() >= element.getStart() && other.end <= element.end);
584
- }, FOCUSABLE_TAGS = ["a", "button", "input", "select", "textarea", "summary", "iframe"], focusable = (other) => FOCUSABLE_TAGS.includes(other.tagName.getText()) || attr(other, "tabIndex") !== void 0 || attr(other, "href") !== void 0;
595
+ }, FOCUSABLE_TAGS = ["a", "button", "input", "select", "textarea", "summary", "iframe"], focusable = (other) => FOCUSABLE_TAGS.includes(values.tag(other)) || attr(other, "tabIndex") !== void 0 || attr(other, "href") !== void 0;
585
596
  async function textEntryElement(opening, partName, context, resolve) {
586
- const expected = ['<input type="text|email|tel|url|password|search|number">', "<textarea>", "<select>"], tag = opening.tagName.getText();
597
+ const expected = ['<input type="text|email|tel|url|password|search|number">', "<textarea>", "<select>"], tag = values.tag(opening);
587
598
  if (tag === "textarea" || tag === "select")
588
599
  return;
589
600
  if (tag !== "input")
@@ -595,7 +606,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
595
606
  async function nativeElement(opening, element, partName, parent, context, resolve) {
596
607
  if (element === null)
597
608
  return;
598
- const tag = opening.tagName.getText(), tags = elementTags(element);
609
+ const tag = values.tag(opening), tags = elementTags(element);
599
610
  if (!tags.includes(tag))
600
611
  return fail(opening, { kind: "part-element-mismatch", part: partName, expected: tags.map((expected) => `<${expected}>`), actual: `<${tag}>` });
601
612
  switch (element.kind) {
@@ -609,9 +620,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
609
620
  let host = parent === null ? elementOf(opening).parent : elementOf(parent);
610
621
  while (host !== void 0 && !isJsxElement(host) && !isJsxSelfClosingElement(host) && (isJsxExpression(host) || isParenthesizedExpression(host) || isJsxFragment(host)))
611
622
  host = host.parent;
612
- if ((host === void 0 ? null : openingOf(host)?.tagName.getText() ?? null) !== "details")
623
+ if ((host === void 0 ? null : openingOf(host) === void 0 ? null : values.tag(openingOf(host))) !== "details")
613
624
  return fail(opening, { kind: "summary-outside-details", part: partName });
614
- if (element.marker === "none" && !descendants(opening).some((other) => !lowercaseTag(other) || other.tagName.getText() === "svg" || attr(other, "aria-hidden") !== void 0))
625
+ if (element.marker === "none" && !descendants(opening).some((other) => !lowercaseTag(other) || values.tag(other) === "svg" || attr(other, "aria-hidden") !== void 0))
615
626
  review(opening, { kind: "marker-none-unlabelled", part: partName });
616
627
  return;
617
628
  }
@@ -688,7 +699,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
688
699
  const touchDisabled = [], handovers = [];
689
700
  let containerGrids = !1;
690
701
  async function layerRoot(opening, layer, context, resolve) {
691
- const tag = opening.tagName.getText(), named = attr(opening, "aria-label") !== void 0 || attr(opening, "aria-labelledby") !== void 0;
702
+ const tag = values.tag(opening), named = attr(opening, "aria-label") !== void 0 || attr(opening, "aria-labelledby") !== void 0;
692
703
  switch (layer.kind) {
693
704
  case "modal-sheet": {
694
705
  if (tag !== "dialog")
@@ -878,14 +889,16 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
878
889
  hidden.push(within.length === 0 ? { kind: "part", selector } : { kind: "part", selector, within });
879
890
  }, parts = declaredParts(parsed.value), declaredMarkers = new Set([...parts.map((part) => part.selector.slice(1)), ...declaredCells(parsed.value).map((cell) => cell.slice(1))]);
880
891
  if (parsed.value.kind === "region") {
881
- const region = parsed.value;
892
+ const region = parsed.value, rootTag = values.tag(opening), rootless = region.pseudo.find((treatment) => !pseudoHosted(treatment.pseudo, rootTag));
893
+ if (rootless !== void 0)
894
+ return fail(opening, { kind: "pseudo-host-unsupported", part: "&", pseudo: rootless.pseudo, element: rootTag });
882
895
  await nativeElement(opening, region.element, "&", null, context, resolve);
883
896
  if (region.normalize.some(([property, value]) => property === "pointer-events" && value === "none"))
884
897
  await pointerTransparent(opening, "&", context, resolve);
885
898
  if (region.overflow.kind === "scroll")
886
899
  scrollReview(opening, "&", node);
887
900
  }
888
- const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set;
901
+ const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set, margined = new Set;
889
902
  let schemed = !1;
890
903
  for (const part of parts) {
891
904
  if (!/^\.[\w-]+$/.test(part.selector))
@@ -893,7 +906,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
893
906
  const parent = matched.get(part.within.join(" "));
894
907
  if (parent === void 0)
895
908
  continue;
896
- const candidates = (await factsOf(parent)).filter((fact) => !fact.component);
909
+ const candidates = (await factsOf(parent)).filter((fact) => fact.component === (part.kind === "component"));
897
910
  for (const fact of candidates) {
898
911
  const shared = fact.classes.markers.filter((marker) => declaredMarkers.has(marker));
899
912
  if (shared.length > 1)
@@ -904,21 +917,26 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
904
917
  if (part.required && match === void 0)
905
918
  return fail(node, { kind: "part-missing-or-repeated", part: part.name });
906
919
  for (const shape of matches) {
907
- const tag = shape.opening.tagName.getText(), host = parent.tagName.getText();
920
+ const tag = values.tag(shape.opening), host = values.tag(parent);
908
921
  if (!VECTOR_SHAPES.includes(tag) || host !== "svg")
909
922
  return fail(shape.opening, { kind: "part-element-mismatch", part: part.name, expected: VECTOR_SHAPES.map((shapeTag) => `<svg> > <${shapeTag}>`), actual: `<${host}> > <${tag}>` });
910
923
  }
911
924
  continue;
912
925
  }
913
- if (matches.length > 1 || match?.repeated === !0 || part.required && match === void 0)
926
+ if (!part.repeat && (matches.length > 1 || match?.repeated === !0) || part.required && match === void 0)
914
927
  return fail(node, { kind: "part-missing-or-repeated", part: part.name });
915
928
  if (match === void 0)
916
929
  continue;
930
+ if (part.kind === "component")
931
+ continue;
917
932
  matched.set([...part.within, part.selector].join(" "), match.opening);
918
933
  const ariaHidden = attr(match.opening, "aria-hidden");
919
934
  if (tinted.has(part.name) && ariaHidden !== void 0 && (ariaHidden.initializer === void 0 || [!0, "true"].includes(await resolve(expression(ariaHidden), context))))
920
935
  decorative.add(part.name);
921
- const element = match.opening.tagName.getText(), hostless = part.pseudo.find((pseudo) => !PSEUDO_HOSTS[pseudo].includes(element));
936
+ const element = values.tag(match.opening);
937
+ if (UA_MARGIN_TAGS.includes(element))
938
+ margined.add([...part.within, part.selector].join(" "));
939
+ const hostless = part.pseudo.find((pseudo) => !pseudoHosted(pseudo, element));
922
940
  if (hostless !== void 0)
923
941
  return fail(match.opening, { kind: "pseudo-host-unsupported", part: part.name, pseudo: hostless, element });
924
942
  await nativeElement(match.opening, part.element, part.name, parent, context, resolve);
@@ -939,9 +957,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
939
957
  if ((foundation.profiles.get(sequence)?.fields.repeat ?? "loop") !== "once")
940
958
  review(authoredAt(classes.calls, `${part.path}.play`) ?? node, { kind: "motion-endless", part: part.name, sequence });
941
959
  if (part.clamped) {
942
- const enclosing = part.within.map((_, index) => matched.get(part.within.slice(0, index + 1).join(" "))), control = [match.opening, ...enclosing.reverse(), opening].find((element) => element !== void 0 && CONTROL_TEXT_TAGS.includes(element.tagName.getText()));
960
+ const enclosing = part.within.map((_, index) => matched.get(part.within.slice(0, index + 1).join(" "))), control = [match.opening, ...enclosing.reverse(), opening].find((element) => element !== void 0 && CONTROL_TEXT_TAGS.includes(values.tag(element)));
943
961
  if (control !== void 0)
944
- return fail(match.opening, { kind: "clamp-on-control", part: part.name, element: `<${control.tagName.getText()}>` });
962
+ return fail(match.opening, { kind: "clamp-on-control", part: part.name, element: `<${values.tag(control)}>` });
945
963
  }
946
964
  guardChild(match, part.selector, part.within);
947
965
  if (part.kind === "text")
@@ -984,7 +1002,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
984
1002
  visuals.set(part.name, { fact: { kind: "inspected-svg" }, drawings: void 0 });
985
1003
  continue;
986
1004
  }
987
- if (match.classes.bindings.length === 0 && parsed.value.kind === "region" && match.opening.tagName.getText() === "img") {
1005
+ if (match.classes.bindings.length === 0 && parsed.value.kind === "region" && values.tag(match.opening) === "img") {
988
1006
  visual ??= { kind: "content-media" };
989
1007
  visuals.set(part.name, { fact: { kind: "content-media" }, drawings: void 0 });
990
1008
  continue;
@@ -1052,7 +1070,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1052
1070
  return fail(fact.opening, { kind: "markers-shared", markers: shared });
1053
1071
  }
1054
1072
  if (parsed.value.kind === "control" && !hasText && (visual !== void 0 || parsed.value.decor.length > 0) && !await namedByAttribute(opening, async (condition) => values.truthy(await resolve(condition, context), condition, context)))
1055
- return fail(opening, { kind: "control-name-missing", element: opening.tagName.getText() });
1073
+ return fail(opening, { kind: "control-name-missing", element: values.tag(opening) });
1056
1074
  const theme = visual?.kind === "asset" ? visual.theme : void 0, rootTheme = attr(opening, "data-theme"), boundThemes = [...new Set([...theme === void 0 ? [] : [theme.name], ...[...visuals.values()].flatMap(({ fact }) => fact.kind === "asset" ? [fact.theme.name] : [])])];
1057
1075
  if (rootTheme !== void 0 && boundThemes.length > 0) {
1058
1076
  const named = await resolve(expression(rootTheme), context), other = boundThemes.find((name) => name !== named);
@@ -1063,9 +1081,13 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1063
1081
  artworkThemed.add(opening);
1064
1082
  const inherited = new Map, aligned = new Map;
1065
1083
  for (const selector of declaredCells(parsed.value)) {
1066
- const cells = allFacts.filter((fact) => fact.classes.markers.includes(selector.slice(1))), [cell] = cells, single = cells.length === 1 && cell?.repeated === !1;
1067
- if (!/^\.[\w-]+$/.test(selector) || cell === void 0 || !single && !autoPlaced(parsed.value, selector))
1084
+ const cells = allFacts.filter((fact) => fact.classes.markers.includes(selector.slice(1))), [cell] = cells, declared = parsed.value.kind === "grid" ? parsed.value.cells.find((item) => item.selector === selector) : void 0, single = cells.length === 1 && cell?.repeated === !1, many = declared?.repeat === !0 || autoPlaced(parsed.value, selector);
1085
+ if (!/^\.[\w-]+$/.test(selector) || cell === void 0 && declared?.required !== !1 || cell !== void 0 && !single && !many)
1068
1086
  return fail(node, { kind: "cell-missing-or-repeated", cell: selector });
1087
+ if (declared !== void 0 && !declared.required && [declared.values, ...declared.at.map(([, values]) => values)].some((values) => values.some(([field]) => field === "row")))
1088
+ review(authoredAt(classes.calls, `recipe.cells.${selector}.row`) ?? node, { kind: "optional-cell-row", cell: selector });
1089
+ if (cell === void 0)
1090
+ continue;
1069
1091
  for (const each of cells)
1070
1092
  guardChild(each, selector);
1071
1093
  if (cell.classes.fragments.length === 0)
@@ -1098,13 +1120,14 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1098
1120
  ...aligned.size > 0 ? [[...aligned]] : [],
1099
1121
  ...writesInline ? [scope] : [],
1100
1122
  ...decorative.size > 0 ? [["decorative", ...decorative]] : [],
1123
+ ...margined.size > 0 ? [["margined", ...[...margined].sort()]] : [],
1101
1124
  ...visuals.size > 1 ? [[...visuals].map(([name, { fact, drawings: drawn }]) => fact.kind === "asset" ? [name, drawn, fact.state, fact.visualProfile, fact.theme.name] : [name, fact.kind])] : []
1102
1125
  ], paintedBy = (element) => parsed.value.kind === "control" ? hasText ? "text" : "graphic" : element.visual ? decorative.has(element.element) ? "decorative" : "graphic" : "text", key = constructionId(digest(hidden.length > 0 ? [...identity, hidden] : identity));
1103
1126
  let owned = styles.get(key);
1104
1127
  if (owned === void 0) {
1105
1128
  if (styles.size >= choiceLimits.alternatives)
1106
1129
  return fail(node, { kind: "choice", problem: { kind: "construction-limit" } });
1107
- const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
1130
+ const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope, margined: [...margined].sort() }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
1108
1131
  const reviews = [], failed = (failure, at = null) => ({ kind: "failed", failure: { path: at, item: failure }, reviews }), lowered = lower(spec, read, rootName, input);
1109
1132
  if (lowered.kind === "err")
1110
1133
  return failed(lowered.error);
@@ -1173,7 +1196,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1173
1196
  fail(expression(attr(host, "className")) ?? host, missed);
1174
1197
  }, check = (place, spec, component) => tiles ? tileFrameFinding(foundation, place, spec, component, regions) : component !== null ? componentCellFinding(foundation, place.cell, component, regions) : spec === null ? null : frameRegionFinding(foundation, place, spec, regions, moved), inside = async (cell, host, path) => {
1175
1198
  for (const child of await children(host, context, resolve)) {
1176
- const step = lowercaseTag(child) ? { kind: "element", tag: child.tagName.getText(), spec: await constructionOf(child) } : { kind: "component", name: child.tagName.getText() };
1199
+ const step = lowercaseTag(child) ? { kind: "element", tag: values.tag(child), spec: await constructionOf(child) } : { kind: "component", name: values.tag(child) };
1177
1200
  if (step.kind === "element") {
1178
1201
  if (step.spec?.kind === "grid")
1179
1202
  continue;
@@ -1185,14 +1208,14 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1185
1208
  }
1186
1209
  }, visit = async (cell, opening) => {
1187
1210
  if (!lowercaseTag(opening)) {
1188
- report(check({ cell, element: null, path: [] }, null, opening.tagName.getText()), opening);
1211
+ report(check({ cell, element: null, path: [] }, null, values.tag(opening)), opening);
1189
1212
  return;
1190
1213
  }
1191
1214
  const own = await constructionOf(opening);
1192
1215
  report(check({ cell, element: null, path: [] }, own, null), opening);
1193
1216
  aligned({ cell, element: null, path: [] }, own, opening);
1194
1217
  if (own?.kind !== "grid")
1195
- return inside(cell, opening, [{ kind: "element", tag: opening.tagName.getText(), spec: own }]);
1218
+ return inside(cell, opening, [{ kind: "element", tag: values.tag(opening), spec: own }]);
1196
1219
  if (own.mode !== "inherited")
1197
1220
  return;
1198
1221
  for (const child of await children(opening, context, resolve)) {
@@ -1204,7 +1227,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1204
1227
  };
1205
1228
  if (tiles)
1206
1229
  for (const fact of allFacts)
1207
- await visit(`a tile <${fact.opening.tagName.getText()}>`, fact.opening);
1230
+ await visit(`a tile <${values.tag(fact.opening)}>`, fact.opening);
1208
1231
  else
1209
1232
  for (const selector of declaredCells(parsed.value))
1210
1233
  for (const fact of allFacts.filter((item) => item.classes.markers.includes(selector.slice(1))))
@@ -1398,10 +1421,10 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1398
1421
  for (const opening of openings) {
1399
1422
  if (!lowercaseTag(opening))
1400
1423
  continue;
1401
- const tag = opening.tagName.getText();
1424
+ const tag = values.tag(opening);
1402
1425
  if (tag === "img" && attr(opening, "alt") === void 0)
1403
1426
  return fail(opening, { kind: "image-alt-missing" });
1404
- if (clickWithoutKeyboard(opening))
1427
+ if (clickWithoutKeyboard(opening, tag))
1405
1428
  review(opening, { kind: "click-without-keyboard", element: tag });
1406
1429
  if (!sections && !artworkThemed.has(opening))
1407
1430
  for (const attribute of ["data-theme", "data-brand"]) {
@@ -1411,10 +1434,10 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1411
1434
  }
1412
1435
  }
1413
1436
  for (const opening of openings) {
1414
- const component = !lowercaseTag(opening), suggestion = missingAutocomplete(opening, component);
1437
+ const component = !lowercaseTag(opening), suggestion = missingAutocomplete(opening, component, values.tag(opening));
1415
1438
  if (suggestion === null || component && !await takesAutocomplete(opening))
1416
1439
  continue;
1417
- review(opening, { kind: "autocomplete-missing", element: opening.tagName.getText(), suggestion });
1440
+ review(opening, { kind: "autocomplete-missing", element: values.tag(opening), suggestion });
1418
1441
  }
1419
1442
  if (!openings.some((opening) => opening.attributes.properties.some((attribute) => isJsxAttribute(attribute) && /^on(?:Pointer|Touch)[A-Z]/.test(nameText(attribute.name) ?? ""))))
1420
1443
  for (const { at, element } of touchDisabled)
@@ -1464,6 +1487,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1464
1487
  }), artwork = { assets: [...boundAssets].sort(), sets: [...boundSets].sort(), glyphs: macros.glyphs, support: macros.support, uses };
1465
1488
  return { source, values, selections, styles, edits, assetEdits, imports, coverage: { constructions: styles.size, coveredLeaves }, publicRows, controls: ownerControls(selections.flatMap((selection) => selection.result.axes)), reviews, artwork, design: ownerDesign([...styles.values()].flatMap((construction) => construction.profiles)) };
1466
1489
  }
1490
+ const UA_MARGIN_TAGS = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dl", "dd", "blockquote", "figure", "pre", "hr", "menu"];
1467
1491
  function drawnRecords(input, root) {
1468
1492
  return [input.visual, ...input.visuals.values()].map((fact) => fact !== null && fact.kind === "asset" ? designValueDigest(fact.asset, root) : null);
1469
1493
  }
@@ -1482,7 +1506,7 @@ function lower(spec, foundation, root, input) {
1482
1506
  hidden: input.hidden
1483
1507
  });
1484
1508
  case "region":
1485
- return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope });
1509
+ return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope, ...input.margined.length === 0 ? {} : { margined: input.margined } });
1486
1510
  case "grid":
1487
1511
  return lowerGrid(spec, foundation, { root, hidden: input.hidden, inherited: input.inherited, aligned: input.aligned, scope: input.scope });
1488
1512
  }
@@ -1726,7 +1750,7 @@ function presenceTest(identifier) {
1726
1750
  return !1;
1727
1751
  const operator = parent.operatorToken.kind;
1728
1752
  if (operator === SyntaxKind.AmpersandAmpersandToken)
1729
- return parent.left === node;
1753
+ return parent.left === node || presenceTest(parent);
1730
1754
  const equality = [SyntaxKind.EqualsEqualsEqualsToken, SyntaxKind.ExclamationEqualsEqualsToken, SyntaxKind.EqualsEqualsToken, SyntaxKind.ExclamationEqualsToken].includes(operator), other = parent.left === node ? parent.right : parent.left;
1731
1755
  return equality && (isIdentifier(other) && other.text === "undefined" || other.kind === SyntaxKind.NullKeyword);
1732
1756
  }