@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
@@ -0,0 +1,69 @@
1
+ import { selectedProfile } from "./design-foundation.mjs";
2
+ import { frameInlineInsets } from "./lowering-region-layout.mjs";
3
+ const tokenOf = (value) => value === void 0 ? void 0 : value.startsWith("--") ? `var(${value})` : value;
4
+ export function endInsetOf(foundation, spec) {
5
+ switch (spec.kind) {
6
+ case "region": {
7
+ if (spec.frame === null || spec.profile === null)
8
+ return [];
9
+ const selected = selectedProfile(foundation, spec.profile, spec.select);
10
+ if (selected.kind === "err")
11
+ return null;
12
+ const frameName = selected.value.kind === "frame" ? spec.profile : selected.value.kind === "composite" ? selected.value.fields.get("frame-profile") : void 0;
13
+ if (frameName === void 0)
14
+ return [];
15
+ const frame = frameName === spec.profile ? selected : selectedProfile(foundation, frameName);
16
+ if (frame.kind === "err" || frame.value.kind !== "frame")
17
+ return null;
18
+ const surfaceName = spec.surface ?? (selected.value.kind === "composite" ? selected.value.fields.get("surface-profile") : void 0), surface = surfaceName === void 0 ? null : selectedProfile(foundation, surfaceName);
19
+ if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || frame.value.fields.has("border-width"))
20
+ return [];
21
+ const end = frameInlineInsets(Object.fromEntries(frame.value.fields)).end;
22
+ return end === void 0 ? [] : [end];
23
+ }
24
+ case "grid": {
25
+ if (spec.mode !== "fluid" && spec.mode !== "hybrid")
26
+ return null;
27
+ const mode = spec.layout.find(([key]) => key === "gutter")?.[1] ?? "wide";
28
+ if (mode === "none")
29
+ return [];
30
+ const named = selectedProfile(foundation, spec.profile);
31
+ if (named.kind === "err")
32
+ return null;
33
+ const reference = named.value.kind === "spatial" ? spec.profile : named.value.fields.get("spatial-profile");
34
+ if (reference === void 0)
35
+ return null;
36
+ const spatial = reference === spec.profile ? named : selectedProfile(foundation, reference);
37
+ if (spatial.kind === "err" || spatial.value.kind !== "spatial")
38
+ return null;
39
+ const gutter = spatial.value.clauses.get(`ads-gutter ${String(mode)}`);
40
+ if (gutter === void 0)
41
+ return null;
42
+ if (gutter.get("gap") !== void 0)
43
+ return [];
44
+ const end = tokenOf(gutter.get("end"));
45
+ return end === void 0 ? null : [end];
46
+ }
47
+ case "control":
48
+ case "artwork":
49
+ return null;
50
+ }
51
+ }
52
+ export function stackPartsOf(foundation, spec) {
53
+ if (spec.kind !== "region" || spec.arrangement.layout !== "stack")
54
+ return [];
55
+ return spec.parts.flatMap((part) => {
56
+ if (part.content.kind === "component")
57
+ return [{ part: part.name, kind: "component", inset: [] }];
58
+ if (part.box === null)
59
+ return [];
60
+ const frame = selectedProfile(foundation, part.box);
61
+ if (frame.kind === "err" || frame.value.kind !== "frame")
62
+ return [];
63
+ const surface = part.surface === null ? null : selectedProfile(foundation, part.surface);
64
+ if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || frame.value.fields.has("border-width"))
65
+ return [{ part: part.name, kind: "box", inset: [] }];
66
+ const end = frameInlineInsets(Object.fromEntries(frame.value.fields)).end;
67
+ return [{ part: part.name, kind: "box", inset: end === void 0 ? [] : [end] }];
68
+ });
69
+ }
@@ -0,0 +1,20 @@
1
+ /** What an external renders and where it comes from. */
2
+ export interface ExternalSpec {
3
+ /** The module that exports it: `"next/link"`. */
4
+ readonly from: string;
5
+ /** Its export: `"default"` (the default) or a named export (`"Html"` of `next/document`). */
6
+ readonly name?: string;
7
+ /** The one element it renders (`"a"`): ADS checks owners as if they wrote that element. */
8
+ readonly renders: string;
9
+ /** The library component needs the client (state, effects): owners that render it are "use client". */
10
+ readonly client?: boolean;
11
+ }
12
+ /** The props every external takes beside its declared ones: the owner's class and what it holds. */
13
+ export interface ExternalBaseProps {
14
+ readonly className?: string;
15
+ readonly children?: unknown;
16
+ }
17
+ /** A declared external, typed as a component of its props. Never called by ADS: owners render the real one. */
18
+ export type External<Props> = (props: Props & ExternalBaseProps) => never;
19
+ /** Declares an external component. */
20
+ export declare function external<Props>(spec: ExternalSpec): External<Props>;
@@ -0,0 +1,12 @@
1
+ const MODULE = /^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(?:\/[\w.-]+)*$/, ELEMENT = /^[a-z][a-z0-9-]*$/;
2
+ export function external(spec) {
3
+ if (!MODULE.test(spec.from))
4
+ throw Error(`external: "${spec.from}" is not a package module (a bare specifier such as "next/link").`);
5
+ if (!ELEMENT.test(spec.renders))
6
+ throw Error(`external: renders "${spec.renders}" is not an element name.`);
7
+ if (spec.name !== void 0 && !/^[A-Za-z_$][\w$]*$/.test(spec.name))
8
+ throw Error(`external: name "${spec.name}" is not an export name.`);
9
+ return () => {
10
+ throw Error(`external ${spec.from}: an ADS declaration is not rendered; the emitted design system re-exports the real component.`);
11
+ };
12
+ }
@@ -5,6 +5,7 @@ export const findingRules = Object.freeze({
5
5
  "a11y-text-scale": "error",
6
6
  "a11y-text-spacing-override": "error",
7
7
  "a11y-reflow": "error",
8
+ "a11y-forced-colors-render": "error",
8
9
  "render-audit": "error",
9
10
  "a11y-focus": "error",
10
11
  "a11y-icon-label": "error",
@@ -13,6 +14,8 @@ export const findingRules = Object.freeze({
13
14
  "a11y-text-resize": "error",
14
15
  "a11y-focus-unresolved": "review",
15
16
  "a11y-target-size-unresolved": "review",
17
+ "a11y-forced-colors": "error",
18
+ "a11y-forced-colors-review": "review",
16
19
  "a11y-keyboard": "review",
17
20
  "a11y-motion-endless": "info",
18
21
  "a11y-incomplete": "info",
@@ -0,0 +1,81 @@
1
+ import { selectedProfile } from "./design-foundation.mjs";
2
+ export { SYSTEM_COLORS } from "./system-colors.mjs";
3
+ export const FORCED_FIELDS = {
4
+ "forced-colors-background": "background",
5
+ "forced-colors-color": "color",
6
+ "forced-colors-border": "border-color"
7
+ }, FORCED_PREFIX = "forced-colors-";
8
+ export { FORCED_KEYS } from "./system-colors.mjs";
9
+ export const FORCED_ONLY = "forced-only", declaresForced = (fields) => [...fields instanceof Map ? fields.keys() : Object.keys(fields)].some((field) => field.startsWith(FORCED_PREFIX));
10
+ const fieldsOf = (foundation, name, kind, select = {}) => {
11
+ if (name === null || name === void 0)
12
+ return null;
13
+ const selected = selectedProfile(foundation, name, select);
14
+ return selected.kind === "ok" && selected.value.kind === kind ? selected.value.fields : null;
15
+ };
16
+ function slotsOf(foundation, profile, select) {
17
+ if (profile === null)
18
+ return new Map;
19
+ const selected = selectedProfile(foundation, profile, select);
20
+ if (selected.kind === "err")
21
+ return new Map;
22
+ return selected.value.kind === "composite" ? selected.value.fields : new Map([[`${selected.value.kind}-profile`, profile]]);
23
+ }
24
+ const borderless = (frame) => frame?.get("border-width") === void 0 ? "every context" : null;
25
+ export function forcedBoundaryMissing(foundation, spec) {
26
+ switch (spec.kind) {
27
+ case "control": {
28
+ const name = slotsOf(foundation, spec.profile, spec.select).get("frame-profile") ?? null, context = borderless(fieldsOf(foundation, name, "frame"));
29
+ return context === null ? null : { kind: "forced-boundary-missing", element: "&", frame: name, context };
30
+ }
31
+ case "region": {
32
+ const name = slotsOf(foundation, spec.profile, spec.select).get("frame-profile") ?? null;
33
+ for (const part of spec.parts) {
34
+ if (part.frame === null)
35
+ continue;
36
+ const context = borderless(fieldsOf(foundation, name, "frame"));
37
+ if (context !== null)
38
+ return { kind: "forced-boundary-missing", element: part.name, frame: name, context };
39
+ }
40
+ return null;
41
+ }
42
+ case "artwork":
43
+ case "grid":
44
+ return null;
45
+ }
46
+ }
47
+ const FILL_FIELDS = new Set(["background", "background-color", "background-image", "box-shadow", "group-shadow", "shape-shadow"]), MEANT = /aria-(selected|pressed|checked|current)|:checked\b/;
48
+ function fillOnly(base, state) {
49
+ const own = (fields) => new Map([...fields ?? new Map].filter(([field]) => !field.startsWith(FORCED_PREFIX) && field !== "state")), before = own(base), after = own(state), changed = new Set([...before.keys(), ...after.keys()].filter((field) => before.get(field) !== after.get(field)));
50
+ return changed.size > 0 && [...changed].every((field) => FILL_FIELDS.has(field));
51
+ }
52
+ export function forcedStateFillOnly(foundation, spec) {
53
+ const found = [], visit = (element, base, when) => {
54
+ const baseFields = fieldsOf(foundation, base, "surface");
55
+ for (const [condition, surface] of when) {
56
+ if (surface === null || !MEANT.test(condition))
57
+ continue;
58
+ const fields = fieldsOf(foundation, surface, "surface");
59
+ if (fields === null || declaresForced(fields))
60
+ continue;
61
+ if (fillOnly(baseFields, fields))
62
+ found.push({ kind: "forced-state-fill-only", element, condition, surface });
63
+ }
64
+ };
65
+ switch (spec.kind) {
66
+ case "control":
67
+ visit("&", spec.surface, spec.when);
68
+ break;
69
+ case "region": {
70
+ const slots = slotsOf(foundation, spec.profile, spec.select);
71
+ visit("&", spec.surface ?? slots.get("surface-profile") ?? null, spec.when);
72
+ for (const part of spec.parts)
73
+ visit(part.name, part.surface, part.when);
74
+ break;
75
+ }
76
+ case "artwork":
77
+ case "grid":
78
+ break;
79
+ }
80
+ return found;
81
+ }
@@ -185,7 +185,7 @@ function frameRegionOf(foundation, place, spec, regions, moved, under) {
185
185
  context: context.label
186
186
  }), placed = (bounds) => bounds[cell] ?? [], lowest = moved.has(cell) && conditions.length > 0 ? Math.min(...conditions.map((item) => item.boundPx)) : -1 / 0;
187
187
  for (const bound of placed(cells)) {
188
- if (bound.kind === "hidden")
188
+ if (bound.kind === "hidden" || bound.kind === "content")
189
189
  continue;
190
190
  if (bound.kind === "unbounded") {
191
191
  review(`its ${px(need.px)} ${need.field} sits in inherited tracks at ${bound.tier}, which the grid algebra does not bound here`, context.label);
@@ -204,7 +204,7 @@ function frameRegionOf(foundation, place, spec, regions, moved, under) {
204
204
  for (const bound of placed(condition.cells)) {
205
205
  if (bound.kind === "hidden" || bound.fromPx >= condition.boundPx)
206
206
  continue;
207
- if (bound.kind === "unbounded")
207
+ if (bound.kind === "unbounded" || bound.kind === "content")
208
208
  continue;
209
209
  if (need.px > space(bound) + 0.01)
210
210
  return exceeds(bound, condition.condition);
@@ -0,0 +1,64 @@
1
+ import { readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ const MARK = /export \{ ([\w$]+)(?: as ([\w$]+))? \} from "([^"]+)";\n\/\* ads-external (\{[^*]*\}) \*\//g, PROBE = "ads-external-probe";
6
+ function declared(folder) {
7
+ const found = [], visit = (directory, depth) => {
8
+ if (depth > 6)
9
+ return;
10
+ for (const entry of readdirSync(directory)) {
11
+ if (entry === "node_modules" || entry.startsWith("."))
12
+ continue;
13
+ const file = path.join(directory, entry);
14
+ if (statSync(file).isDirectory())
15
+ visit(file, depth + 1);
16
+ else if (/\.ads\.[cm]?[jt]s$/.test(entry))
17
+ for (const match of readFileSync(file, "utf8").matchAll(MARK)) {
18
+ const mark = JSON.parse(match[4] ?? "{}");
19
+ if (mark.name !== void 0 && mark.renders !== void 0)
20
+ found.push({ name: mark.name, exportName: match[1] ?? "default", from: match[3] ?? "", renders: mark.renders });
21
+ }
22
+ }
23
+ };
24
+ visit(folder, 0);
25
+ return found;
26
+ }
27
+ export async function verifyExternals(root, entry) {
28
+ const externals = declared(path.dirname(entry));
29
+ if (externals.length === 0)
30
+ return [];
31
+ const require = createRequire(path.join(root, "package.json"));
32
+ let react, server;
33
+ try {
34
+ react = require("react");
35
+ server = require("react-dom/server");
36
+ } catch {
37
+ return externals.map((external) => ({ ...external, problem: "the application has no react and react-dom/server to render it with: verify it by hand" }));
38
+ }
39
+ const checks = [];
40
+ for (const external of externals) {
41
+ let problem = null;
42
+ try {
43
+ const module = await import(pathToFileURL(require.resolve(external.from)).href), exported = external.exportName === "default" ? module.default?.default ?? module.default : module[external.exportName];
44
+ if (exported === void 0)
45
+ problem = `${external.from} exports no ${external.exportName}`;
46
+ else {
47
+ const markup = server.renderToStaticMarkup(react.createElement(exported, { className: PROBE, href: "/", children: "probe" })).replace(/^(?:<link[^>]*\brel="(?:preload|modulepreload|preconnect|dns-prefetch)"[^>]*\/?>)+/, ""), root = /^<([a-z][\w-]*)([^>]*)>/.exec(markup), closes = root === null ? !1 : markup.endsWith(`</${root[1]}>`) || markup.endsWith("/>");
48
+ if (root === null || !closes)
49
+ problem = `it renders ${markup.slice(0, 80)}, not one element`;
50
+ else if (root[1] !== external.renders)
51
+ problem = `it renders <${root[1]}>, not the declared <${external.renders}>`;
52
+ else if (!new RegExp(`class="[^"]*\\b${PROBE}\\b`).test(root[2] ?? ""))
53
+ problem = "it does not put the class it is given on its element";
54
+ else if (/\sstyle="/.test(root[2] ?? ""))
55
+ problem = "it brings a style of its own: it carries design (use its data function instead)";
56
+ }
57
+ } catch (error) {
58
+ problem = `it could not be rendered: ${error instanceof Error ? error.message.split(`
59
+ `)[0] : String(error)}`;
60
+ }
61
+ checks.push({ name: external.name, from: external.from, renders: external.renders, problem });
62
+ }
63
+ return checks;
64
+ }
@@ -5,6 +5,7 @@ import { checkDesignUsage, designSystemEntry } from "../design-usage.mjs";
5
5
  import { err, ok } from "../result.mjs";
6
6
  import { readGuardConfig } from "./config.mjs";
7
7
  import { guardScope } from "./files.mjs";
8
+ import { verifyExternals } from "./externals.mjs";
8
9
  const ENTRY_NAMES = ["index.ts", "index.tsx", "index.mts", "index.js", "index.mjs"];
9
10
  function entryFile(root, config) {
10
11
  if (config.entry !== void 0) {
@@ -29,15 +30,16 @@ export async function runGuard(root) {
29
30
  const located = entryFile(absolute, config.value);
30
31
  if (located.kind === "err")
31
32
  return err([located.error]);
32
- const entry = await designSystemEntry(config.value.designSystem, located.value), folder = path.dirname(located.value), scope = guardScope(absolute, config.value.include, config.value.exclude, folder.startsWith(absolute + path.sep) ? folder : null), sources = scope.files.map((file) => ({ file, text: readFileSync(path.join(absolute, file), "utf8") })), findings = await checkDesignUsage(sources, entry, { components: config.value.allow, metadata: !0 }), inside = located.value.startsWith(absolute + path.sep);
33
+ const entry = await designSystemEntry(config.value.designSystem, located.value), folder = path.dirname(located.value), scope = guardScope(absolute, config.value.include, config.value.exclude, folder.startsWith(absolute + path.sep) ? folder : null), sources = scope.files.map((file) => ({ file, text: readFileSync(path.join(absolute, file), "utf8") })), findings = await checkDesignUsage(sources, entry, { components: config.value.allow, metadata: !0 }), inside = located.value.startsWith(absolute + path.sep), externals = await verifyExternals(absolute, located.value);
33
34
  return ok({
34
- ok: findings.length === 0,
35
+ ok: findings.length === 0 && externals.every((item) => item.problem === null),
35
36
  designSystem: config.value.designSystem,
36
37
  entry: inside ? path.relative(absolute, located.value).split(path.sep).join("/") : located.value,
37
38
  patterns: entry.patterns.size,
38
39
  checked: scope.files.length,
39
40
  scope: { excluded: scope.excluded, tests: scope.tests, designSystem: scope.designSystem },
40
- findings
41
+ findings,
42
+ externals
41
43
  });
42
44
  }
43
45
  export function guardText(report) {
@@ -50,7 +52,9 @@ export function guardText(report) {
50
52
  left.push(`${report.scope.tests} test file${report.scope.tests === 1 ? "" : "s"}`);
51
53
  if (report.scope.designSystem > 0)
52
54
  left.push(`${report.scope.designSystem} file${report.scope.designSystem === 1 ? "" : "s"} of the design system`);
53
- const summary = `Checked ${report.checked} file${report.checked === 1 ? "" : "s"} against ${report.designSystem} (${report.patterns} pattern${report.patterns === 1 ? "" : "s"})${left.length ? `; not checked: ${left.join("; ")}` : ""}.`, verdict = report.ok ? "The source uses the design system only." : `${report.findings.length} finding${report.findings.length === 1 ? "" : "s"}.`;
54
- return [...lines, summary, verdict].join(`
55
+ const summary = `Checked ${report.checked} file${report.checked === 1 ? "" : "s"} against ${report.designSystem} (${report.patterns} pattern${report.patterns === 1 ? "" : "s"})${left.length ? `; not checked: ${left.join("; ")}` : ""}.`, externals = report.externals.map((item) => item.problem === null ? `external ${item.name} (${item.from}) renders <${item.renders}> as declared` : `external ${item.name} (${item.from}) external-mismatch
56
+ ${item.problem}
57
+ Declare what it renders, or use a component that renders one element with the given class and no style of its own.`), failing = report.findings.length + report.externals.filter((item) => item.problem !== null).length, verdict = report.ok ? "The source uses the design system only." : `${failing} finding${failing === 1 ? "" : "s"}.`;
58
+ return [...lines, ...externals, summary, verdict].join(`
55
59
  `);
56
60
  }
@@ -58,7 +58,7 @@ export function revisionTokenInventory(options) {
58
58
  }
59
59
  const used = new Set;
60
60
  for (const construction of outcome.owner.styles.values())
61
- for (const token of construction.used)
61
+ for (const token of [...construction.used, ...construction.scriptTokens ?? []])
62
62
  used.add(token);
63
63
  tokens.push({ owner: path.posix.join(designSystem, name), tokens: used });
64
64
  }
@@ -24,10 +24,13 @@ const transition = (property, timing) => ({
24
24
  "transition-timing-function": timing.easing,
25
25
  ...timing.delay === null ? {} : { "transition-delay": timing.delay }
26
26
  }), REDUCED = { "transition-duration": "0s", "transition-delay": "0s" };
27
- function sheetRules(sheet, backdrop, own, motion) {
28
- const field = Object.keys(backdrop.fields).find((name) => name !== "background"), background = backdrop.fields.background;
27
+ function sheetRules(sheet, backdrop, own, motion, margin) {
28
+ const field = Object.keys(backdrop.fields).find((name) => name !== "background" && name !== "backdrop-blur"), background = backdrop.fields.background;
29
29
  if (field !== void 0 || background === void 0)
30
30
  return err({ kind: "backdrop-surface-unsupported", surface: backdrop.name, field: field ?? null });
31
+ const blur = backdrop.fields["backdrop-blur"], veil = { background, ...blur === void 0 ? {} : { "-webkit-backdrop-filter": `blur(${blur})`, "backdrop-filter": `blur(${blur})` } };
32
+ if (sheet.edge === "center" || sheet.edge === "block-start")
33
+ return ok(cardRules(sheet, veil, own, motion, margin ?? "0px"));
31
34
  const placement = {
32
35
  position: "fixed",
33
36
  "inset-block-start": "0",
@@ -37,7 +40,7 @@ function sheetRules(sheet, backdrop, own, motion) {
37
40
  "block-size": "auto",
38
41
  "max-block-size": "none",
39
42
  "max-inline-size": own["max-inline-size"] ?? "100%"
40
- }, paint = { selector: "&::backdrop", values: { background }, condition: null };
43
+ }, paint = { selector: "&::backdrop", values: veil, condition: null };
41
44
  if (motion === null || sheet.motion === null)
42
45
  return ok({ root: placement, rules: [paint] });
43
46
  const away = sheet.edge === "start" ? "-100% 0" : "100% 0", mirrored = sheet.edge === "start" ? "100% 0" : "-100% 0";
@@ -57,6 +60,37 @@ function sheetRules(sheet, backdrop, own, motion) {
57
60
  ]
58
61
  });
59
62
  }
63
+ function cardRules(sheet, veil, own, motion, margin) {
64
+ const placement = {
65
+ position: "fixed",
66
+ "inset-block-start": "0",
67
+ "inset-block-end": "0",
68
+ "inset-inline-start": "0",
69
+ "inset-inline-end": "0",
70
+ "margin-block-start": sheet.edge === "block-start" ? margin : "auto",
71
+ "margin-block-end": "auto",
72
+ "margin-inline-start": "auto",
73
+ "margin-inline-end": "auto",
74
+ "block-size": "fit-content",
75
+ "max-block-size": `calc(100dvh - ${margin} * 2)`,
76
+ "max-inline-size": inlineCap(margin, own)
77
+ }, paint = { selector: "&::backdrop", values: veil, condition: null };
78
+ if (motion === null || sheet.motion === null)
79
+ return { root: placement, rules: [paint] };
80
+ return {
81
+ root: { ...placement, ...transition("opacity", motion) },
82
+ rules: [
83
+ paint,
84
+ { selector: "&:not([open])", values: { opacity: "0" }, condition: null },
85
+ { selector: "&[open]", values: { opacity: "0" }, condition: STARTING },
86
+ { selector: "&::backdrop", values: transition("opacity", motion), condition: null },
87
+ { selector: "&:not([open])::backdrop", values: { opacity: "0" }, condition: null },
88
+ { selector: "&[open]::backdrop", values: { opacity: "0" }, condition: STARTING },
89
+ { selector: "&", values: REDUCED, condition: REDUCED_MOTION },
90
+ { selector: "&::backdrop", values: REDUCED, condition: REDUCED_MOTION }
91
+ ]
92
+ };
93
+ }
60
94
  function inlineCap(margin, own) {
61
95
  const cap = `calc(100vw - ${margin} * 2)`, frameCap = own["max-inline-size"];
62
96
  return frameCap === void 0 ? cap : `min(${frameCap}, ${cap})`;
@@ -100,7 +134,7 @@ function popoverRules(popover, layout, own, motion) {
100
134
  function variantRules(input, own) {
101
135
  switch (input.kind) {
102
136
  case "modal-sheet":
103
- return sheetRules(input.sheet, input.backdrop, own, input.motion);
137
+ return sheetRules(input.sheet, input.backdrop, own, input.motion, input.margin);
104
138
  case "anchored-popover":
105
139
  return ok(popoverRules(input.popover, input.placement, own, input.motion));
106
140
  case "measured-popover":
@@ -101,7 +101,7 @@ function parseShape(selector) {
101
101
  }).processSync(selector);
102
102
  return shape;
103
103
  }
104
- const childChain = (shape) => shape.combinators.every((combinator) => combinator === ">"), typeOf = (compound) => /^[a-z][\w-]*/i.exec(compound.structure)?.[0].toLowerCase() ?? null, markersOf = (compound) => [...compound.structure.matchAll(/\.([\w-]+)/g)].map((match) => match[1] ?? ""), pseudoElementOf = (compound) => /::([\w-]+)/.exec(compound.structure)?.[1]?.toLowerCase() ?? null;
104
+ const childChain = (shape) => shape.combinators.every((combinator) => combinator === ">"), fixedChain = (shape) => shape.combinators.every((combinator) => combinator === ">" || combinator === "+"), typeOf = (compound) => /^[a-z][\w-]*/i.exec(compound.structure)?.[0].toLowerCase() ?? null, markersOf = (compound) => [...compound.structure.matchAll(/\.([\w-]+)/g)].map((match) => match[1] ?? ""), pseudoElementOf = (compound) => /::([\w-]+)/.exec(compound.structure)?.[1]?.toLowerCase() ?? null;
105
105
  function compoundsDiffer(a, b) {
106
106
  if (pseudoElementOf(a) !== pseudoElementOf(b))
107
107
  return !0;
@@ -125,6 +125,11 @@ function mayCoincide(a, b) {
125
125
  return other !== void 0 && compoundsDiffer(compound, other);
126
126
  });
127
127
  }
128
+ if (fixedChain(a) && a.combinators.length === b.combinators.length && a.combinators.every((combinator, index) => combinator === b.combinators[index]))
129
+ return !a.compounds.some((compound, index) => {
130
+ const other = b.compounds[index];
131
+ return other !== void 0 && compoundsDiffer(compound, other);
132
+ });
128
133
  return !compoundsDiffer(lastA, lastB);
129
134
  }
130
135
  const samePath = (a, b) => a.compounds.length === b.compounds.length && a.combinators.every((combinator, index) => combinator === b.combinators[index]) && a.compounds.every((compound, index) => compound.structure === b.compounds[index]?.structure);
@@ -135,6 +140,13 @@ function tokensExclude(a, b) {
135
140
  if (a.name === ":dir" && b.name === ":dir" && !a.negated && !b.negated)
136
141
  return a.argument !== b.argument;
137
142
  const pair = [a.name, b.name].sort().join(" ");
143
+ if (a.name === ":has" && b.name === ":has" && !a.negated && !b.negated) {
144
+ const end = (argument) => {
145
+ const found = /^>\s*\.([\w-]+):(last-child|first-child)$/.exec(argument.trim());
146
+ return found?.[1] === void 0 || found[2] === void 0 ? null : [found[1], found[2]];
147
+ }, left = end(a.argument), right = end(b.argument);
148
+ return left !== null && right !== null && left[1] === right[1] && left[0] !== right[0];
149
+ }
138
150
  return !a.negated && !b.negated && (pair === ":disabled :enabled" || pair === ":checked :indeterminate");
139
151
  }
140
152
  if (a.kind === "attribute" && b.kind === "attribute" && a.name === b.name) {
@@ -38,6 +38,10 @@ export const FAMILIES = [
38
38
  "-webkit-line-clamp",
39
39
  "-webkit-box-orient",
40
40
  "text-wrap",
41
+ "counter-reset",
42
+ "counter-increment",
43
+ "forced-color-adjust",
44
+ "clip-path",
41
45
  "text-decoration-line",
42
46
  "pointer-events",
43
47
  "stroke",
@@ -122,11 +122,14 @@ export function textLayoutValues(layout, part, hasText) {
122
122
  case "never":
123
123
  values["white-space"] = "nowrap";
124
124
  break;
125
+ case "preserve":
126
+ Object.assign(values, { "white-space": "pre-wrap", "overflow-wrap": "anywhere", "min-inline-size": "0" });
127
+ break;
125
128
  case "truncate":
126
129
  if (layout.lines !== null)
127
130
  Object.assign(values, { display: "-webkit-box", "-webkit-box-orient": "vertical", "-webkit-line-clamp": String(layout.lines), "line-clamp": String(layout.lines), overflow: "hidden", "min-inline-size": "0" });
128
131
  else
129
- Object.assign(values, { "white-space": "nowrap", overflow: "hidden", "text-overflow": "ellipsis", "min-inline-size": "0" });
132
+ Object.assign(values, { "white-space": "nowrap", overflow: "clip visible", "text-overflow": "ellipsis", "min-inline-size": "0" });
130
133
  break;
131
134
  case "balance":
132
135
  case "pretty":
@@ -152,7 +155,7 @@ export function extentValues(extent, parent, part, parentGrows = !1) {
152
155
  case "fill": {
153
156
  if (parent !== "stack" && parent !== "inline")
154
157
  return err({ kind: "extent-parent-unsupported", part, layout: parent });
155
- const main = parent === "stack" ? "block" : "inline", values = { "flex-grow": "1", "flex-shrink": "1", "flex-basis": "0" };
158
+ const main = parent === "stack" ? "block" : "inline", values = { "flex-grow": "1", "flex-shrink": "1", "flex-basis": parent === "stack" ? "auto" : "0" };
156
159
  if (!(parent === "stack" && parentGrows))
157
160
  values[`min-${main}-size`] = "0";
158
161
  if (extent.axis === "both")
@@ -161,6 +164,20 @@ export function extentValues(extent, parent, part, parentGrows = !1) {
161
164
  }
162
165
  }
163
166
  }
167
+ export function nativeReset(values) {
168
+ const reset = {}, unless = (property, value, written = [property]) => {
169
+ if (!written.some((name) => Object.keys(values).some((key) => key === name || key.startsWith(`${name}-`))))
170
+ reset[property] = value;
171
+ };
172
+ for (const property of ["font-family", "font-size", "font-weight", "line-height", "letter-spacing"])
173
+ unless(property, "inherit");
174
+ unless("text-align", "start");
175
+ unless("color", "inherit");
176
+ unless("background", "transparent");
177
+ unless("border-style", "none", ["border"]);
178
+ unless("margin", "0");
179
+ return reset;
180
+ }
164
181
  export function layeredValues(align, justify) {
165
182
  return {
166
183
  display: "grid",
@@ -190,7 +207,7 @@ export function elementNormalization(element, values) {
190
207
  return plain({ "border-collapse": "collapse" });
191
208
  case "cell":
192
209
  return plain({
193
- "vertical-align": "middle",
210
+ "vertical-align": { start: "top", center: "middle", end: "bottom" }[element.align],
194
211
  ...values["text-align"] === void 0 ? { "text-align": "start" } : {},
195
212
  ...element.header && values["font-weight"] === void 0 ? { "font-weight": "inherit" } : {}
196
213
  });
@@ -198,6 +215,8 @@ export function elementNormalization(element, values) {
198
215
  return plain({ "list-style-type": "none", margin: "0", ...values["padding-inline-start"] === void 0 ? { "padding-inline-start": "0" } : {} });
199
216
  case "summary":
200
217
  return element.marker === "none" ? { values: { "list-style-type": "none" }, marker: !0 } : plain({});
218
+ case "document":
219
+ return plain({});
201
220
  }
202
221
  }
203
222
  export const MARKER_HIDDEN = { display: "none" };
@@ -68,7 +68,7 @@ export function createLoweringSession(context, operation) {
68
68
  registry = withChannels(registry, slots);
69
69
  return write(channels.value);
70
70
  }, writeProvidedRoles = (request) => {
71
- const roles = request.values.map(([property]) => property), reserved = roles.find((property) => !/^--[a-z][\w-]*$/.test(property) || property.startsWith("--ads-") || property.startsWith("--asset-"));
71
+ const roles = request.values.map(([property]) => property), reserved = roles.find((property) => !/^--[a-z][\w-]*$/.test(property) || property.startsWith("--ads-") && property !== "--ads-flow-gap" || property.startsWith("--asset-"));
72
72
  if (reserved !== void 0)
73
73
  return err({ kind: "emission", error: { kind: "unregistered-property", property: reserved, origin } });
74
74
  const extended = new Map(registry);
@@ -4,6 +4,7 @@ export const CHANNEL_FIELDS = {
4
4
  "background-color": ["background"],
5
5
  "border-color": ["border-color", "border-block-start-color", "border-block-end-color", "border-inline-start-color", "border-inline-end-color"],
6
6
  color: ["color"],
7
+ "text-decoration-color": ["text-decoration-color"],
7
8
  "box-shadow": ["box-shadow"],
8
9
  opacity: ["opacity"],
9
10
  filter: EFFECT_PROPERTY_FIELDS.filter,