@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
@@ -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,
@@ -76,7 +76,8 @@ ${scenarioGroupFingerprint(current, sources)}`;
76
76
  investigations: investigationFingerprint(),
77
77
  results: executionResults.fingerprint(),
78
78
  drafts: drafts.fingerprint(),
79
- draftBuilds: draftBuilds()
79
+ draftBuilds: draftBuilds(),
80
+ viewChoices: view.viewChoices()
80
81
  };
81
82
  }
82
83
  const observe = async () => baseline ??= await initialFingerprints(), unregisterDigests = observeChanges && previewWatch ? registerInputDigests({
@@ -101,8 +102,8 @@ ${scenarioGroupFingerprint(current, sources)}`;
101
102
  const next = fingerprint(), artifacts = await artifactFingerprint(), assets = assetFingerprint(), buildReport = await view.builds(), build = JSON.stringify(buildReport), filesChanged = force || next !== base.files, buildChanged = build !== base.build;
102
103
  if (buildChanged)
103
104
  onBuildChange?.(buildReport);
104
- const artifactsChanged = artifacts !== base.artifacts, assetsChanged = assets !== base.assets, capturesChanged = captures.store.fingerprint() !== base.captures, investigationsChanged = investigationFingerprint() !== base.investigations, resultsChanged = executionResults.fingerprint() !== base.results, draftFingerprint = drafts.fingerprint(), draftsChanged = draftFingerprint !== base.drafts, previousDraftBuilds = base.draftBuilds, currentDraftBuilds = draftBuilds(), changedDraftBuilds = [...new Set([...previousDraftBuilds.keys(), ...currentDraftBuilds.keys()])].filter((uri) => previousDraftBuilds.get(uri) !== currentDraftBuilds.get(uri)), draftResourcesChanged = [...previousDraftBuilds.keys()].some((uri) => !currentDraftBuilds.has(uri)) || [...currentDraftBuilds.keys()].some((uri) => !previousDraftBuilds.has(uri));
105
- if (!filesChanged && !buildChanged && !artifactsChanged && !assetsChanged && !capturesChanged && !investigationsChanged && !resultsChanged && !draftsChanged && !deferredDiscovery)
105
+ const artifactsChanged = artifacts !== base.artifacts, assetsChanged = assets !== base.assets, capturesChanged = captures.store.fingerprint() !== base.captures, investigationsChanged = investigationFingerprint() !== base.investigations, resultsChanged = executionResults.fingerprint() !== base.results, viewChoices = view.viewChoices(), viewChoicesChanged = viewChoices !== base.viewChoices, draftFingerprint = drafts.fingerprint(), draftsChanged = draftFingerprint !== base.drafts, previousDraftBuilds = base.draftBuilds, currentDraftBuilds = draftBuilds(), changedDraftBuilds = [...new Set([...previousDraftBuilds.keys(), ...currentDraftBuilds.keys()])].filter((uri) => previousDraftBuilds.get(uri) !== currentDraftBuilds.get(uri)), draftResourcesChanged = [...previousDraftBuilds.keys()].some((uri) => !currentDraftBuilds.has(uri)) || [...currentDraftBuilds.keys()].some((uri) => !previousDraftBuilds.has(uri));
106
+ if (!filesChanged && !buildChanged && !artifactsChanged && !assetsChanged && !capturesChanged && !investigationsChanged && !resultsChanged && !draftsChanged && !viewChoicesChanged && !deferredDiscovery)
106
107
  return !1;
107
108
  if (filesChanged) {
108
109
  const updated = loadConfig(root);
@@ -140,8 +141,9 @@ ${scenarioGroupFingerprint(current, sources)}`;
140
141
  LIVE_PREVIEW_MANIFEST_URI,
141
142
  ...artifactsChanged ? (await discovery.scenarioApps(!0)).map((app) => appUri(app.id)) : []
142
143
  ].filter(visible);
143
- if ((discoveryChanged || draftsChanged) && visible(`${PROJECT_URI}/explorer`))
144
+ if ((discoveryChanged || draftsChanged || viewChoicesChanged) && visible(`${PROJECT_URI}/explorer`))
144
145
  targets.push(`${PROJECT_URI}/explorer`);
146
+ base.viewChoices = viewChoices;
145
147
  if (draftsChanged) {
146
148
  targets.push(...[...new Set([...previousDraftBuilds.keys(), ...currentDraftBuilds.keys()])].map((uri) => uri.replace(encodeURIComponent(BUILD_URI), encodeURIComponent(`${PROJECT_URI}/scenarios`))).filter(visible));
147
149
  targets.push(...[DRAFTS_URI, `${PROJECT_URI}/scenarios`, `${PROJECT_URI}/status`].filter(visible));
@@ -203,7 +203,9 @@ export function createProjectView({ root, era, mutations, controllers, cache, di
203
203
  if (Array.isArray(tokens))
204
204
  count = tokens.length;
205
205
  choices = adsViewChoices(facts);
206
- } catch {}
206
+ } catch {
207
+ return { count: null, choices: treeTotal?.choices ?? {} };
208
+ }
207
209
  treeTotal = { content: source.value.content, count, choices };
208
210
  return treeTotal;
209
211
  }
@@ -359,6 +361,7 @@ export function createProjectView({ root, era, mutations, controllers, cache, di
359
361
  builds,
360
362
  status,
361
363
  explorer,
364
+ viewChoices: () => JSON.stringify(treeFacts().choices),
362
365
  behaviors: (query) => analyzedBehaviorPage(root, query),
363
366
  architecture,
364
367
  captureInventory,
@@ -306,11 +306,13 @@ async function composedFindings(inputs, captured, check, foundation, document) {
306
306
  const declarations = await barrelDeclarations(inputs.dsRoot, inputs.publicAlias, inputs.framework ?? null), publics = new Set([...declarations?.values() ?? []].flatMap((item) => item === null ? [] : [`${item.file}#${item.declaration}`])), owners = new Map;
307
307
  for (const [name, owner] of analyzedOwners(check.outcomes))
308
308
  owners.set(name, owner.composition);
309
+ for (const [name, facts] of check.plainComposition)
310
+ owners.set(name, facts);
309
311
  const findings = composedContrastFindings({
310
312
  foundation,
311
313
  document: { surface: document.names.surface, text: { fontSize: document.text.get("font-size") ?? null, fontWeight: document.text.get("font-weight") ?? null } },
312
314
  owners,
313
- discovered: new Set(check.outcomes.keys()),
315
+ discovered: new Set([...check.outcomes.keys(), ...check.plainComposition.keys()]),
314
316
  publics,
315
317
  plain: check.plainPlacements
316
318
  }), text = (name) => captured.get(name) ?? null, at = (site) => {
@@ -622,6 +624,7 @@ function designInputPosition(inputs, failure) {
622
624
  return sitePositionIn(inputs, revisionDesignText(inputs), { kind: "macro-field", file: inner.file, macro: "profile", declaration: inner.declaration, path: inner.path });
623
625
  case "profile-rejected":
624
626
  case "token-role":
627
+ case "provided-role-self":
625
628
  return foundationPosition(inputs);
626
629
  case "document-profile-kind":
627
630
  return designFile(inputs, FOUNDATION_DECLARATION);
@@ -64,6 +64,7 @@ export function foundationError(failure) {
64
64
  case "profile-argument-default":
65
65
  case "profile-field-unknown":
66
66
  case "token-role":
67
+ case "provided-role-self":
67
68
  case "document-profile-kind":
68
69
  return { code: `foundation/${failure.kind}`, ...entry(foundationErrors, failure.kind, failure) };
69
70
  }
@@ -106,7 +107,6 @@ export function constructionError(failure) {
106
107
  case "drawn-height-below-minimum":
107
108
  case "paint-transition-redundant":
108
109
  case "paint-transition-effect-unsupported":
109
- case "prose-contrast-insufficient":
110
110
  case "condition-visual-unsupported":
111
111
  case "sequence-steps-invalid":
112
112
  case "sequence-not-seamless":
@@ -144,6 +144,7 @@ export function constructionError(failure) {
144
144
  case "rule-paint-missing":
145
145
  case "extent-conflict":
146
146
  case "extent-parent-unsupported":
147
+ case "space-parent-unsupported":
147
148
  case "extent-row-hugs":
148
149
  case "layered-parts-missing":
149
150
  case "condition-unknown":
@@ -3,7 +3,7 @@ import { reducedMotionPolicy } from "./lowering-motion.mjs";
3
3
  import { attempt } from "./result.mjs";
4
4
  import { tokenValueContexts } from "./design-foundation.mjs";
5
5
  import { lengthPx } from "./css-length.mjs";
6
- import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast } from "./paint-contrast.mjs";
6
+ import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast, unshown } from "./paint-contrast.mjs";
7
7
  import { normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
8
8
  import { frameValues } from "./region-lowering.mjs";
9
9
  import { FRAME_INSET_FIELDS } from "./lowering-region-layout.mjs";
@@ -120,7 +120,10 @@ export function lowerControl(spec, foundation, input) {
120
120
  lowerDecor(out, box, profile, motion, reject);
121
121
  if (hasText && label !== null) {
122
122
  const trim = label.textEdge.length === 0 ? {} : { "text-box-trim": "trim-both", "text-box-edge": label.textEdge.join(" ") }, wrap = label.wrap === "never" ? { "white-space": "nowrap" } : { "min-inline-size": "0", "overflow-wrap": label.wrap === "anywhere" ? "anywhere" : "break-word" };
123
- out.rule(`& > ${label.selector}`, { ...wrap, ...trim, ...label.align === null ? {} : { "text-align": label.align } });
123
+ if (label.extent === "fill" && spec.layout !== "inline")
124
+ return reject({ kind: "profile-field-unsupported", profile: "recipe", field: `parts.${label.name}.extent`, value: spec.layout });
125
+ const fill = label.extent === "fill" ? { "flex-grow": "1", "flex-basis": "0%", "min-inline-size": "0" } : {};
126
+ out.rule(`& > ${label.selector}`, { ...wrap, ...fill, ...trim, ...label.align === null ? {} : { "text-align": label.align } });
124
127
  }
125
128
  if (geometry !== null && glyph !== null) {
126
129
  const part = `& > ${glyph.selector}`, turns = glyph.when.some(([, effects]) => effects.some((effect) => effect.effect === "rotate"));
@@ -206,7 +209,10 @@ function slotArtworkContrast(foundation, asset, spec, surface, reject) {
206
209
  const background = fields.background ?? base.background;
207
210
  if (background === void 0)
208
211
  continue;
209
- const paints = [...asset.slots.values()].map((value) => value === "currentColor" ? fields.color ?? base.color ?? null : `var(${value})`).filter((value) => value !== null), outcomes = paints.map((foreground) => paintContrast(context, { foreground, background }, NON_TEXT_MINIMUM));
212
+ const paints = [...asset.slots.values()].map((value) => value === "currentColor" ? fields.color ?? base.color ?? null : `var(${value})`).filter((value) => value !== null), shown = paints.filter((foreground) => !unshown(foreground, context));
213
+ if (shown.length === 0)
214
+ continue;
215
+ const outcomes = shown.map((foreground) => paintContrast(context, { foreground, background }, NON_TEXT_MINIMUM));
210
216
  if (outcomes.some((outcome) => outcome.kind !== "insufficient"))
211
217
  continue;
212
218
  const ratio = Math.max(...outcomes.map((outcome) => outcome.kind === "insufficient" ? outcome.ratio : 0));
@@ -235,7 +241,7 @@ export function lowerArtwork(spec, foundation, input) {
235
241
  return attempt((reject) => {
236
242
  const profile = profiles(foundation, reject), { asset, visualProfile, theme } = input;
237
243
  if (asset === null || visualProfile === null)
238
- return reject({ kind: "artwork-binding-missing" });
244
+ return reject({ kind: "artwork-binding-missing", missing: asset === null ? "asset" : "visual" });
239
245
  const visual = profile.of(visualProfile, "visual"), geometry = visualPart(asset, visual, input.state, theme, reject), out = output(input.root, "lowerArtwork", reject, profile), height = drawnHeight(foundation, asset, visual, reject), { part } = spec, tone = spec.surface === null ? {} : profile.of(spec.surface, "surface");
240
246
  profile.only(tone, "surface", ["color"]);
241
247
  out.rule("&", { display: "inline-flex", "align-items": spec.align, "justify-content": "center", "min-inline-size": "0", ...tone.color === void 0 ? {} : { color: tone.color } });
@@ -10,8 +10,6 @@ import { PUBLIC_BARREL, ownerCompilerOptions, ownerProgramRoots, programSource }
10
10
  import ts from "./analysis/syntax.mjs";
11
11
  import { isScenarioFile, scenarioIdentity, sourceFiles } from "./config.mjs";
12
12
  import { isDevelopmentModule } from "./development-modules.mjs";
13
- import { publicProse } from "./analysis/prose-owners.mjs";
14
- import { isProseTag } from "./prose-model.mjs";
15
13
  import { findingRules } from "./finding-rules.mjs";
16
14
  import { err, ok } from "./result.mjs";
17
15
  import { createScenarioGroups } from "./scenario-groups.mjs";
@@ -175,7 +173,7 @@ async function registrationOf(options, program, checker, file) {
175
173
  for (const problem of subjects.problems)
176
174
  report(problem.rule, problem.message, problem.node ?? record.nodes.get(problem.field) ?? metadata?.node, problem.entry);
177
175
  if (kind !== "mocks")
178
- for (const problem of markupProblems(dsRoot, source, await publicProse(dsRoot)))
176
+ for (const problem of markupProblems(dsRoot, source))
179
177
  report("scenario-markup", problem.message, problem.node);
180
178
  let valid = !entry && subjects.renders.length > 0;
181
179
  for (const [name, node] of record.nodes)
@@ -595,7 +593,7 @@ const specimenRenders = (checker, source) => memoProgram(source, "owner-scenario
595
593
  const { metadata } = scenarioExports(source), record = metadata?.initializer === void 0 ? void 0 : await recordOf(checker, metadata.initializer, new Set, SUBJECT_FIELDS);
596
594
  return record === void 0 ? [] : (await specimensOf(checker, record)).renders;
597
595
  });
598
- function markupProblems(dsRoot, source, prose) {
596
+ function markupProblems(dsRoot, source) {
599
597
  const problems = [], development = new Map;
600
598
  for (const statement of source.statements) {
601
599
  if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || !statement.moduleSpecifier.text.startsWith("."))
@@ -624,12 +622,6 @@ function markupProblems(dsRoot, source, prose) {
624
622
  problems.push({ node: attribute, message: "A scenario does not style what it shows: remove `style`. A size or a position the subject needs comes from the scenario kit's Container, or from the owner's own props." });
625
623
  const tag = node.tagName, name = tag.getText();
626
624
  if (ts.isIdentifier(tag) && /^[a-z]/.test(name)) {
627
- const owner = isProseTag(name) ? proseOwnerOf(node, prose) : void 0;
628
- if (owner !== void 0) {
629
- if (!owner.tags.has(name))
630
- problems.push({ node: tag, message: `<${name}> is content of ${owner.name}, whose prose recipe declares no such element: it would be drawn without a design. Declare the element in the recipe's \`elements\`, or write the content with the elements it declares.` });
631
- return;
632
- }
633
625
  problems.push({ node: tag, message: `A scenario renders public owners and the scenario kit, not <${name}>. ADS draws the page: put text in \`title\`, \`description\` and each specimen's \`title\` and \`note\`, choose its \`arrangement\` and \`width\`, and use the kit (Container, Placeholder, Anchor, EventLog) around a subject that needs one.` });
634
626
  return;
635
627
  }
@@ -642,18 +634,6 @@ function markupProblems(dsRoot, source, prose) {
642
634
  });
643
635
  return problems;
644
636
  }
645
- function proseOwnerOf(node, prose) {
646
- for (let current = node.parent;current !== void 0; current = current.parent) {
647
- if (!ts.isJsxElement(current) || current.openingElement === node)
648
- continue;
649
- const tag = current.openingElement.tagName;
650
- if (ts.isIdentifier(tag) && isProseTag(tag.text))
651
- continue;
652
- const tags = ts.isIdentifier(tag) ? prose.get(tag.text) : void 0;
653
- return tags === void 0 ? void 0 : { name: tag.getText(), tags };
654
- }
655
- return;
656
- }
657
637
  const defaultExportNode = (source) => source.statements.find((statement) => ts.isExportAssignment(statement) || ts.isFunctionDeclaration(statement) && hasModifier(statement, ts.SyntaxKind.DefaultKeyword));
658
638
  async function renderedNames(checker, dsRoot, entries, exported) {
659
639
  const rendered = new Set, visited = new Set, pending = [...entries];
@@ -1,6 +1,6 @@
1
1
  import { fail, rejecting } from "./design-rejection.mjs";
2
2
  import { CURSORS, ELEMENT_NAMES, FRAME_CORNERS, FRAME_SIDES, GEOMETRY_CHANNELS, OVERFLOW_VALUES, PAINT_CHANNELS, RESIZES, SNAP_ALIGNS, SNAP_TYPES, TEXT_ALIGNS, TEXT_WRAPS, TOUCH_ACTIONS, USER_SELECTS } from "./construction-spec.mjs";
3
- const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent"]), outsetSpacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "outset-block", "outset-inline"]), anchorClear = (value) => value === "profile(layer-profile.clear-block-start)" || value === "profile(spacing-profile.anchor-gap)", overlapSpacing = metric("spacing", ["overlap"]), placement = {
3
+ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "space-before", "space-after"]), outsetSpacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "outset-block", "outset-inline"]), anchorClear = (value) => value === "profile(layer-profile.clear-block-start)" || value === "profile(spacing-profile.anchor-gap)", overlapSpacing = metric("spacing", ["overlap"]), placement = {
4
4
  start: (value) => value === "auto" || positive(value),
5
5
  end: positive,
6
6
  span: (value) => value === "full" || positive(value),
@@ -12,6 +12,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
12
12
  }, TEXT_ALIGN = oneOf(...TEXT_ALIGNS), OVERFLOW = oneOf(...OVERFLOW_VALUES), ELEMENT = oneOf(...ELEMENT_NAMES), FIELDS = {
13
13
  "ads-recipe": {
14
14
  profile: (value) => profile.test(value),
15
+ markers: wordList,
15
16
  text: binding,
16
17
  surface: binding,
17
18
  align: oneOf("start", "center", "end", "baseline", "stretch"),
@@ -21,7 +22,6 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
21
22
  gap: spacing,
22
23
  "row-gap": spacing,
23
24
  overlap: overlapSpacing,
24
- rhythm: spacing,
25
25
  "anchor-clear": anchorClear,
26
26
  columns: positive,
27
27
  weights: (value) => value.split(/\s+/).length <= 64 && value.split(/\s+/).every((weight) => /^\d+(\.\d+)?$/.test(weight) && Number(weight) > 0),
@@ -38,7 +38,11 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
38
38
  transition: oneOf("scale")
39
39
  },
40
40
  "ads-part": {
41
- kind: oneOf("text", "visual", "vector"),
41
+ kind: oneOf("text", "visual", "vector", "component"),
42
+ "space-before": spacing,
43
+ "space-after": spacing,
44
+ spacing: binding,
45
+ presence: oneOf("visible", "assistive"),
42
46
  scheme: oneOf("light", "dark"),
43
47
  selector: (value) => /^\.[a-z][\w-]*$/.test(value),
44
48
  required: oneOf("true", "false"),
@@ -46,6 +50,8 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
46
50
  "text-align": TEXT_ALIGN,
47
51
  "reserve-lines": oneOf("1", "2", "3"),
48
52
  collapsed: oneOf("true", "false"),
53
+ repeat: oneOf("true", "false"),
54
+ "drawn-by": (value) => /^[a-z][\w-]*$/i.test(value),
49
55
  "anchor-clear": anchorClear,
50
56
  lines: oneOf("2", "3"),
51
57
  overflow: OVERFLOW,
@@ -92,11 +98,13 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
92
98
  },
93
99
  motion: binding
94
100
  },
95
- "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
96
- "ads-pseudo": { surface: binding },
101
+ "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), "translate-inline": metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
102
+ "ads-pseudo": { surface: binding, text: binding },
103
+ "ads-counter": { reset: () => !0, increment: () => !0 },
104
+ "ads-between": { surface: binding, frame: binding },
105
+ "ads-content": { counter: () => !0, counters: () => !0, style: () => !0, separator: () => !0, prefix: () => !0, suffix: () => !0 },
97
106
  "ads-accessibility": { boundary: () => !0, reason: () => !0 },
98
107
  "ads-focus": { of: () => !0 },
99
- "ads-element": { text: binding, surface: binding, frame: binding, marker: binding, "marker-text": binding, markers: wordList, "space-before": spacing, "space-after": spacing, indent: spacing, "anchor-clear": anchorClear },
100
108
  "ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
101
109
  "ads-outset": { block: outsetSpacing, inline: outsetSpacing },
102
110
  "ads-sticky": { edge: oneOf("block-start", "block-end"), clear: oneOf("none", "block-start") },
@@ -114,7 +122,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
114
122
  clear: oneOf("none", "block-start"),
115
123
  placement: oneOf("measured")
116
124
  },
117
- "ads-cell": placement,
125
+ "ads-cell": { ...placement, required: oneOf("true", "false"), repeat: oneOf("true", "false") },
118
126
  "ads-at": placement,
119
127
  "ads-align": { rows: wordList },
120
128
  "ads-when": {
@@ -84,6 +84,12 @@ function gradientStops(value, context) {
84
84
  }
85
85
  return { kind: "stops", stops };
86
86
  }
87
+ export function unshown(foreground, context) {
88
+ if (foreground === null)
89
+ return !1;
90
+ const read = readColor(foreground, context);
91
+ return read.kind === "color" && read.rgba[3] === 0;
92
+ }
87
93
  export function opaque(value, context) {
88
94
  const resolved = resolveTokenValue(value, context.values);
89
95
  if (resolved.kind === "unresolved")
@@ -118,6 +118,9 @@ export const PLATFORM_FEATURES = [
118
118
  "box-sizing",
119
119
  "color",
120
120
  "content",
121
+ "counter-reset",
122
+ "counter-increment",
123
+ "clip-path",
121
124
  "display",
122
125
  "flex-basis",
123
126
  "flex-direction",
@@ -253,6 +256,9 @@ export const PLATFORM_FEATURES = [
253
256
  "format()",
254
257
  "local()",
255
258
  "attr()",
259
+ "counter()",
260
+ "counters()",
261
+ "inset()",
256
262
  "cubic-bezier()",
257
263
  "steps()",
258
264
  "linear-gradient()",
@@ -34,6 +34,13 @@ export interface ProfileSpec {
34
34
  readonly below?: Token;
35
35
  readonly above?: Token;
36
36
  }>>;
37
+ /**
38
+ * A `surface` profile's contextual roles: paint tokens it re-binds for the subtree of every element that takes
39
+ * it (base or a state), each to another paint token. `{ "--link-ink": "--heading-ink" }` on a heading's
40
+ * surface: a link inside it reads the heading's ink, with no prop and no rule on the link. Checked where it
41
+ * applies: what can sit inside is proven with the provided values on that element's background.
42
+ */
43
+ readonly provides?: Readonly<Record<`--${string}`, Token>>;
37
44
  /**
38
45
  * A `sequence` profile's steps, each at a whole percentage of the run from 0 to 100. A step states
39
46
  * what the part looks like there: `opacity`, travel (`translateInline`, `translateBlock`), one scale
@@ -18,7 +18,18 @@ export interface Placement {
18
18
  readonly visible?: boolean;
19
19
  readonly at?: Readonly<Record<string, Placement>>;
20
20
  }
21
- export type Layout = "inline" | "stack" | "fluid" | "hybrid" | "fixed" | "flow" | "inherited" | "layered" | "prose";
21
+ /** A grid cell: its placement, and how many times it renders. */
22
+ export interface Cell extends Placement {
23
+ /** `false`: the cell may be absent (an optional notice). Pinned to a `row`, it leaves that row empty when absent (listed for review). */
24
+ readonly required?: boolean;
25
+ /**
26
+ * The cell renders once per item of a list (`items.map(…)`), any number of times (at least once unless
27
+ * `required: false`). Its instances flow one after another: it auto-places (`start: "auto"`, implied) over
28
+ * its `span`, a number or `"full"`, and states no start line, `end` or `row`.
29
+ */
30
+ readonly repeat?: boolean;
31
+ }
32
+ export type Layout = "inline" | "stack" | "fluid" | "hybrid" | "fixed" | "flow" | "inherited" | "layered";
22
33
  /**
23
34
  * Where a jump to an element (a fragment link, `scrollIntoView`) lands below the top of its scroll container:
24
35
  * right under the region sticky elements clear (the layer profile's `clearBlockStart`), or at the element's
@@ -36,32 +47,6 @@ type SpacingField = {
36
47
  readonly slot: "spacing";
37
48
  readonly field: string;
38
49
  };
39
- /**
40
- * One element of a prose root (`layout: "prose"`): the profiles its plain markup takes, by name.
41
- * `spaceBefore` (blocks) replaces the rhythm before it, `indent` (list) is its start inset, `marker`
42
- * (item) a colour-only surface.
43
- */
44
- export interface ProseElement {
45
- readonly text?: string;
46
- readonly surface?: string;
47
- readonly frame?: string;
48
- readonly when?: Readonly<Record<string, {
49
- readonly surface: string;
50
- }>>;
51
- readonly spaceBefore?: SpacingField;
52
- /** The space after a block, in place of the rhythm (a heading closer to its text); the larger of it and the next block's own `spaceBefore`. */
53
- readonly spaceAfter?: SpacingField;
54
- /** A block: where a jump to it lands (a heading with an id). */
55
- readonly anchorClear?: AnchorClear;
56
- readonly indent?: SpacingField;
57
- readonly marker?: string;
58
- /** `item`: a text profile whose weight the marker takes. */
59
- readonly markerText?: string;
60
- /** `list`: an unordered list's marker shape at each depth of nesting, outermost first (one to three). */
61
- readonly markers?: readonly ("disc" | "circle" | "square")[];
62
- }
63
- /** The elements a prose root styles. */
64
- export type ProseElementName = "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "list" | "item" | "quote" | "rule" | "pre" | "table" | "headerCell" | "cell" | "figure" | "caption" | "media" | "descriptions" | "term" | "definition" | "link" | "strong" | "emphasis" | "deleted" | "code" | "sub" | "sup" | "kbd" | "mark";
65
50
  /** A logical side of the box; it mirrors with the writing direction. */
66
51
  export type Side = "block-start" | "block-end" | "inline-start" | "inline-end";
67
52
  export type Frame = "control" | "container" | {
@@ -111,7 +96,7 @@ export type Overflow = "clip" | "scroll-block" | "scroll-inline" | "scroll-both"
111
96
  /** A native element the region or part renders, for its closed normalization. */
112
97
  export type NativeElement = "iframe" | "select" | "search-input" | "text-input" | "table" | "header-cell" | "cell" | "list" | "summary";
113
98
  /** A paint a surface treatment can transition. */
114
- export type PaintChannel = "background-color" | "border-color" | "color" | "box-shadow" | "filter" | "backdrop-filter" | "opacity";
99
+ export type PaintChannel = "background-color" | "border-color" | "color" | "text-decoration-color" | "box-shadow" | "filter" | "backdrop-filter" | "opacity";
115
100
  /** Paint channels of one element that change between its state surfaces, timed by a motion profile. */
116
101
  export interface PaintTransition {
117
102
  readonly channels: readonly PaintChannel[];
@@ -124,7 +109,8 @@ export interface PaintTransition {
124
109
  * An entrance: the element starts from `from` on its first render and settles into its own look over
125
110
  * `motion`. `from.surface` is a surface profile that states only `opacity` and `blur`; at most one
126
111
  * movement, read from the entrance's motion profile (`translate` its `distance` on the block axis,
127
- * `scale` its `scale`, `rotate` its `angle`).
112
+ * `translateInline` its `distance` on the inline axis, mirrored right to left, `scale` its `scale`,
113
+ * `rotate` its `angle`).
128
114
  */
129
115
  export interface Enter {
130
116
  readonly from: {
@@ -133,6 +119,10 @@ export interface Enter {
133
119
  readonly slot: "motion";
134
120
  readonly field: "distance";
135
121
  };
122
+ readonly translateInline?: {
123
+ readonly slot: "motion";
124
+ readonly field: "distance";
125
+ };
136
126
  readonly scale?: {
137
127
  readonly slot: "motion";
138
128
  readonly field: "scale";
@@ -147,6 +137,33 @@ export interface Enter {
147
137
  readonly slot: "motion";
148
138
  } | string;
149
139
  }
140
+ /** A counter's number system. */
141
+ export type CounterStyle = "decimal" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
142
+ /**
143
+ * Generated content: a counter's value (`counter`), or every level of a nested counter joined by `separator`
144
+ * (`counters`: 1.1.2), in a number system, between short literals (at most four punctuation marks or spaces).
145
+ */
146
+ export type GeneratedContent = {
147
+ readonly counter: string;
148
+ readonly style?: CounterStyle;
149
+ readonly prefix?: string;
150
+ readonly suffix?: string;
151
+ } | {
152
+ readonly counters: string;
153
+ readonly separator?: string;
154
+ readonly style?: CounterStyle;
155
+ readonly prefix?: string;
156
+ readonly suffix?: string;
157
+ };
158
+ /** A marker's or generated content's treatment: a colour-only surface, a text profile of weight and numerals, content. */
159
+ export interface GeneratedTreatment {
160
+ readonly surface?: string;
161
+ readonly text?: string;
162
+ readonly content?: GeneratedContent;
163
+ readonly when?: Readonly<Record<string, {
164
+ readonly surface: string;
165
+ }>>;
166
+ }
150
167
  /** A colour-only surface on a part's pseudo-element, with owner-state treatments. */
151
168
  export interface PseudoTreatment {
152
169
  readonly surface: ProfileReference;
@@ -267,7 +284,8 @@ export interface RecipeSpec {
267
284
  readonly lines?: 2 | 3;
268
285
  readonly overflow?: Overflow;
269
286
  /**
270
- * Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis).
287
+ * Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis). A control's text
288
+ * part: `"fill"` takes the room an inline control's other content leaves, so a visual after it stands at the far end.
271
289
  * Root of an `inline` row: `"container"` takes the container's width, `"content"` (the default) is as wide as its content.
272
290
  */
273
291
  readonly extent?: "fill" | "fill-both" | "content" | "container";
@@ -289,7 +307,17 @@ export interface RecipeSpec {
289
307
  readonly bound?: "full" | "system";
290
308
  readonly context?: "viewport" | "container";
291
309
  readonly exposeRows?: readonly string[];
292
- readonly kind?: "text" | "visual" | "vector";
310
+ /**
311
+ * A part's content. `"component"`: a public component placed with the part's marker (`className`), as a grid
312
+ * cell is; the part states its placement only (`required`, `repeat`, `extent`, `at`, `spaceBefore`, `spaceAfter`).
313
+ */
314
+ readonly kind?: "text" | "visual" | "vector" | "component";
315
+ /**
316
+ * In a `stack`: the part's own space before it and after it, in place of the stack's gap (a heading further
317
+ * from what precedes it). Where one part's space after meets the next part's space before, the larger applies.
318
+ */
319
+ readonly spaceBefore?: SpacingField;
320
+ readonly spaceAfter?: SpacingField;
293
321
  readonly selector?: string;
294
322
  readonly required?: boolean;
295
323
  /** A visual part's binding: one declared asset (name or alias)… */
@@ -309,7 +337,14 @@ export interface RecipeSpec {
309
337
  readonly translateBlock?: SlotField;
310
338
  readonly scale?: SlotField;
311
339
  readonly rotate?: SlotField;
312
- readonly repeat?: "continuous";
340
+ /**
341
+ * On a part: `true` renders its element once per item of a list (`tabs.map((tab) => <a className="tab" …/>)`),
342
+ * any number of times, at least once when `required`. Every instance takes the part's construction;
343
+ * consecutive instances are neighbours of their arrangement, so targets are checked against each other.
344
+ * `extent: "fill"` shares the row among them. Not with `drawnBy` or `focus`.
345
+ * In a `when` entry: `"continuous"` repeats a rotation while the state holds.
346
+ */
347
+ readonly repeat?: boolean | "continuous";
313
348
  readonly frame?: Frame;
314
349
  /**
315
350
  * A text-entry control identified by other visual means than a 3:1 boundary (WCAG 1.4.11), declared on
@@ -323,6 +358,12 @@ export interface RecipeSpec {
323
358
  readonly focus?: {
324
359
  readonly of: string;
325
360
  };
361
+ /**
362
+ * A native control (a checkbox's `<input>`) that the named sibling part draws: invisible and taking no room, it
363
+ * lies over that part at its frame's size, so pointer and keyboard still reach it. The drawing part is declared
364
+ * right after it and shows its focus (`focus: { of }`).
365
+ */
366
+ readonly drawnBy?: string;
326
367
  /**
327
368
  * Neighbours of an `inline` or `stack` arrangement overlap by the spacing profile's `overlap`, in place of a
328
369
  * gap (a pile of faces, a stack of cards). Later neighbours paint over earlier ones.
@@ -331,7 +372,11 @@ export interface RecipeSpec {
331
372
  readonly slot: "spacing";
332
373
  readonly field: "overlap";
333
374
  };
334
- /** In a `when` entry: the spacing profile the element's arrangement reads its gap and overlap from under that state. */
375
+ /**
376
+ * On a part in a flow: its own spacing profile, whose `spaceBefore` and `spaceAfter` are the part's space before and
377
+ * after it (a heading 44 px above and 14 px below). In a `when` entry: the spacing profile the element's arrangement
378
+ * reads its gap and overlap from under that state.
379
+ */
335
380
  readonly spacing?: string;
336
381
  /** The geometry that animates between the element's states: closed channels, timed by a motion profile. */
337
382
  readonly geometryTransition?: {
@@ -351,7 +396,7 @@ export interface RecipeSpec {
351
396
  };
352
397
  readonly select?: Readonly<Record<string, string>>;
353
398
  readonly parts?: Readonly<Record<string, RecipeSpec>>;
354
- readonly cells?: Readonly<Record<string, Placement>>;
399
+ readonly cells?: Readonly<Record<string, Cell>>;
355
400
  /** Grid: placements under named conditions. Part: `{ visible }` under one named condition. */
356
401
  readonly at?: Readonly<Record<string, RecipeSpec & Placement>>;
357
402
  readonly when?: Readonly<Record<string, RecipeSpec>>;
@@ -382,16 +427,6 @@ export interface RecipeSpec {
382
427
  readonly sequence: string;
383
428
  readonly order?: number;
384
429
  };
385
- /** A prose root: the space between its blocks, from the spacing slot. */
386
- readonly rhythm?: SpacingField;
387
- /** A prose root: the plain elements it styles, wherever they nest in its content. */
388
- readonly elements?: Readonly<Partial<Record<ProseElementName, ProseElement>>> & {
389
- /** A component placed directly among the blocks: the space the flow gives it, in place of the rhythm. */
390
- readonly component?: {
391
- readonly spaceBefore?: SpacingField;
392
- readonly spaceAfter?: SpacingField;
393
- };
394
- };
395
430
  /**
396
431
  * The root or part stays at an edge of its scrolling container while the rest scrolls. `clear:
397
432
  * "block-start"` holds it below a region at the top by the layer profile's `clearBlockStart`.
@@ -404,9 +439,33 @@ export interface RecipeSpec {
404
439
  readonly enter?: Enter;
405
440
  /** Pseudo-element treatments of an `<input>` or `<textarea>` part. */
406
441
  readonly pseudo?: {
407
- readonly placeholder?: PseudoTreatment; /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
442
+ readonly placeholder?: PseudoTreatment;
443
+ /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
408
444
  readonly progressValue?: PseudoTreatment;
445
+ /** A list item's marker (`li`, `summary`): its colour, its weight and numerals (`text`), and what it shows (`content`). */
446
+ readonly marker?: GeneratedTreatment;
447
+ /** Generated content before the element (a section number): what it shows, in its colour and weight. */
448
+ readonly before?: GeneratedTreatment & {
449
+ readonly content: GeneratedContent;
450
+ };
451
+ };
452
+ /** CSS counters: where a count starts (`reset`) and what this element counts (`increment`). `list-item` is the browser's own list counter. */
453
+ readonly counter?: {
454
+ readonly reset?: string;
455
+ readonly increment?: string;
456
+ };
457
+ /**
458
+ * A rule between the element's consecutive children: the frame profile's border width and style, painted by the
459
+ * surface's `borderColor` (a hairline between table rows, none after the last).
460
+ */
461
+ readonly between?: {
462
+ readonly surface: string;
463
+ readonly frame: string;
409
464
  };
465
+ /** On a part: `"assistive"` hides it on screen while assistive technology still reads it (a table caption). */
466
+ readonly presence?: "visible" | "assistive";
467
+ /** A list's marker style at each nesting depth, outermost first; deeper lists keep the last. */
468
+ readonly markers?: readonly ("disc" | "circle" | "square" | "none" | CounterStyle)[];
410
469
  /** A top-layer root (recipe root only). */
411
470
  readonly layer?: LayerDeclaration;
412
471
  }