@reqvire-org/ads 0.5.2 → 0.5.3

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 (68) 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 +33 -3
  7. package/dist/analysis/owner-composition.mjs +61 -12
  8. package/dist/analysis/owner-source.mjs +52 -35
  9. package/dist/composed-contrast.mjs +143 -62
  10. package/dist/construction-output.mjs +6 -1
  11. package/dist/construction-spec.d.mts +53 -44
  12. package/dist/construction-spec.mjs +64 -76
  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-session.mjs +10 -0
  20. package/dist/mcp/server-observation.mjs +6 -4
  21. package/dist/mcp/server-project.mjs +4 -1
  22. package/dist/owner-analysis-check.mjs +4 -1
  23. package/dist/owner-errors.mjs +2 -1
  24. package/dist/owner-lowering.mjs +10 -4
  25. package/dist/owner-scenarios.mjs +2 -22
  26. package/dist/ownership-model.mjs +7 -5
  27. package/dist/paint-contrast.mjs +6 -0
  28. package/dist/profile-macro.d.mts +7 -0
  29. package/dist/recipe-macro.d.mts +46 -42
  30. package/dist/recipe-model.mjs +12 -11
  31. package/dist/region-lowering.mjs +54 -109
  32. package/dist/role-vocabulary.d.mts +4 -0
  33. package/dist/role-vocabulary.mjs +4 -0
  34. package/dist/runtime-paint-contrast.mjs +5 -2
  35. package/dist/showcase/client.bundle.js +48 -48
  36. package/dist/showcase/http-client.bundle.js +13 -13
  37. package/dist/showcase/ui/ui.css +1 -1
  38. package/dist/showcase/ui/ui.js +5 -5
  39. package/dist/skills/ads-designer/references/accessibility.md +3 -4
  40. package/dist/skills/ads-designer/references/design-data.md +12 -6
  41. package/dist/skills/ads-designer/references/layout.md +7 -3
  42. package/dist/skills/ads-designer/references/motion.md +2 -1
  43. package/dist/skills/ads-designer/references/recipes.md +28 -18
  44. package/dist/skills/ads-import/references/design-data.md +12 -6
  45. package/dist/skills/ads-import/references/layout.md +7 -3
  46. package/dist/skills/ads-import/references/recipes.md +28 -18
  47. package/dist/skills/ads-migrate/SKILL.md +1 -0
  48. package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
  49. package/dist/skills/ads-port/references/design-data.md +12 -6
  50. package/dist/skills/ads-port/references/layout.md +7 -3
  51. package/dist/skills/ads-port/references/recipes.md +28 -18
  52. package/dist/spatial-model.mjs +2 -2
  53. package/dist/surface-contrast.mjs +6 -2
  54. package/dist/target-size.mjs +21 -3
  55. package/docs/ADS.md +9 -3
  56. package/docs/ARCHITECTURE.md +33 -23
  57. package/docs/CACHING.md +1 -1
  58. package/docs/CHANGELOG.md +128 -21
  59. package/docs/GUIDE.md +64 -19
  60. package/docs/LANGUAGE.md +141 -134
  61. package/docs/MCP.md +5 -1
  62. package/docs/MOTION.md +5 -2
  63. package/docs/PROFILE-KINDS.md +46 -4
  64. package/docs/RULES.md +16 -15
  65. package/package.json +1 -1
  66. package/dist/analysis/prose-owners.mjs +0 -57
  67. package/dist/prose-model.d.mts +0 -81
  68. package/dist/prose-model.mjs +0 -101
@@ -67,6 +67,15 @@ export function createLoweringSession(context, operation) {
67
67
  return err({ kind: "paint", error: channels.error });
68
68
  registry = withChannels(registry, slots);
69
69
  return write(channels.value);
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-"));
72
+ if (reserved !== void 0)
73
+ return err({ kind: "emission", error: { kind: "unregistered-property", property: reserved, origin } });
74
+ const extended = new Map(registry);
75
+ for (const property of roles)
76
+ extended.set(property, { kind: "independent" });
77
+ registry = extended;
78
+ return write(request);
70
79
  }, documents = new Map;
71
80
  return {
72
81
  write,
@@ -75,6 +84,7 @@ export function createLoweringSession(context, operation) {
75
84
  writeContinuousRotation,
76
85
  writeKeyframes,
77
86
  writePaintChannels,
87
+ writeProvidedRoles,
78
88
  writeDocument: (rule) => void documents.set(rule.kind, rule),
79
89
  blocks: () => written,
80
90
  keyframes: () => [...keyframes.values()],
@@ -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];
@@ -21,7 +21,6 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
21
21
  gap: spacing,
22
22
  "row-gap": spacing,
23
23
  overlap: overlapSpacing,
24
- rhythm: spacing,
25
24
  "anchor-clear": anchorClear,
26
25
  columns: positive,
27
26
  weights: (value) => value.split(/\s+/).length <= 64 && value.split(/\s+/).every((weight) => /^\d+(\.\d+)?$/.test(weight) && Number(weight) > 0),
@@ -38,7 +37,9 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
38
37
  transition: oneOf("scale")
39
38
  },
40
39
  "ads-part": {
41
- kind: oneOf("text", "visual", "vector"),
40
+ kind: oneOf("text", "visual", "vector", "component"),
41
+ "space-before": spacing,
42
+ "space-after": spacing,
42
43
  scheme: oneOf("light", "dark"),
43
44
  selector: (value) => /^\.[a-z][\w-]*$/.test(value),
44
45
  required: oneOf("true", "false"),
@@ -46,6 +47,8 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
46
47
  "text-align": TEXT_ALIGN,
47
48
  "reserve-lines": oneOf("1", "2", "3"),
48
49
  collapsed: oneOf("true", "false"),
50
+ repeat: oneOf("true", "false"),
51
+ "drawn-by": (value) => /^[a-z][\w-]*$/i.test(value),
49
52
  "anchor-clear": anchorClear,
50
53
  lines: oneOf("2", "3"),
51
54
  overflow: OVERFLOW,
@@ -92,11 +95,10 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
92
95
  },
93
96
  motion: binding
94
97
  },
95
- "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
98
+ "ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), translateInline: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
96
99
  "ads-pseudo": { surface: binding },
97
100
  "ads-accessibility": { boundary: () => !0, reason: () => !0 },
98
101
  "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
102
  "ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
101
103
  "ads-outset": { block: outsetSpacing, inline: outsetSpacing },
102
104
  "ads-sticky": { edge: oneOf("block-start", "block-end"), clear: oneOf("none", "block-start") },
@@ -114,7 +116,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
114
116
  clear: oneOf("none", "block-start"),
115
117
  placement: oneOf("measured")
116
118
  },
117
- "ads-cell": placement,
119
+ "ads-cell": { ...placement, required: oneOf("true", "false"), repeat: oneOf("true", "false") },
118
120
  "ads-at": placement,
119
121
  "ads-align": { rows: wordList },
120
122
  "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")
@@ -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" | {
@@ -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";
@@ -267,7 +257,8 @@ export interface RecipeSpec {
267
257
  readonly lines?: 2 | 3;
268
258
  readonly overflow?: Overflow;
269
259
  /**
270
- * Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis).
260
+ * Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis). A control's text
261
+ * part: `"fill"` takes the room an inline control's other content leaves, so a visual after it stands at the far end.
271
262
  * Root of an `inline` row: `"container"` takes the container's width, `"content"` (the default) is as wide as its content.
272
263
  */
273
264
  readonly extent?: "fill" | "fill-both" | "content" | "container";
@@ -289,7 +280,17 @@ export interface RecipeSpec {
289
280
  readonly bound?: "full" | "system";
290
281
  readonly context?: "viewport" | "container";
291
282
  readonly exposeRows?: readonly string[];
292
- readonly kind?: "text" | "visual" | "vector";
283
+ /**
284
+ * A part's content. `"component"`: a public component placed with the part's marker (`className`), as a grid
285
+ * cell is; the part states its placement only (`required`, `repeat`, `extent`, `at`, `spaceBefore`, `spaceAfter`).
286
+ */
287
+ readonly kind?: "text" | "visual" | "vector" | "component";
288
+ /**
289
+ * In a `stack`: the part's own space before it and after it, in place of the stack's gap (a heading further
290
+ * from what precedes it). Where one part's space after meets the next part's space before, the larger applies.
291
+ */
292
+ readonly spaceBefore?: SpacingField;
293
+ readonly spaceAfter?: SpacingField;
293
294
  readonly selector?: string;
294
295
  readonly required?: boolean;
295
296
  /** A visual part's binding: one declared asset (name or alias)… */
@@ -309,7 +310,14 @@ export interface RecipeSpec {
309
310
  readonly translateBlock?: SlotField;
310
311
  readonly scale?: SlotField;
311
312
  readonly rotate?: SlotField;
312
- readonly repeat?: "continuous";
313
+ /**
314
+ * On a part: `true` renders its element once per item of a list (`tabs.map((tab) => <a className="tab" …/>)`),
315
+ * any number of times, at least once when `required`. Every instance takes the part's construction;
316
+ * consecutive instances are neighbours of their arrangement, so targets are checked against each other.
317
+ * `extent: "fill"` shares the row among them. Not with `drawnBy` or `focus`.
318
+ * In a `when` entry: `"continuous"` repeats a rotation while the state holds.
319
+ */
320
+ readonly repeat?: boolean | "continuous";
313
321
  readonly frame?: Frame;
314
322
  /**
315
323
  * A text-entry control identified by other visual means than a 3:1 boundary (WCAG 1.4.11), declared on
@@ -323,6 +331,12 @@ export interface RecipeSpec {
323
331
  readonly focus?: {
324
332
  readonly of: string;
325
333
  };
334
+ /**
335
+ * A native control (a checkbox's `<input>`) that the named sibling part draws: invisible and taking no room, it
336
+ * lies over that part at its frame's size, so pointer and keyboard still reach it. The drawing part is declared
337
+ * right after it and shows its focus (`focus: { of }`).
338
+ */
339
+ readonly drawnBy?: string;
326
340
  /**
327
341
  * Neighbours of an `inline` or `stack` arrangement overlap by the spacing profile's `overlap`, in place of a
328
342
  * gap (a pile of faces, a stack of cards). Later neighbours paint over earlier ones.
@@ -351,7 +365,7 @@ export interface RecipeSpec {
351
365
  };
352
366
  readonly select?: Readonly<Record<string, string>>;
353
367
  readonly parts?: Readonly<Record<string, RecipeSpec>>;
354
- readonly cells?: Readonly<Record<string, Placement>>;
368
+ readonly cells?: Readonly<Record<string, Cell>>;
355
369
  /** Grid: placements under named conditions. Part: `{ visible }` under one named condition. */
356
370
  readonly at?: Readonly<Record<string, RecipeSpec & Placement>>;
357
371
  readonly when?: Readonly<Record<string, RecipeSpec>>;
@@ -382,16 +396,6 @@ export interface RecipeSpec {
382
396
  readonly sequence: string;
383
397
  readonly order?: number;
384
398
  };
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
399
  /**
396
400
  * The root or part stays at an edge of its scrolling container while the rest scrolls. `clear:
397
401
  * "block-start"` holds it below a region at the top by the layer profile's `clearBlockStart`.
@@ -48,7 +48,7 @@ function clause(parent, name, params, values) {
48
48
  }
49
49
  const strings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
50
50
  function buildProfileTree(spec) {
51
- only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps"]);
51
+ only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides"]);
52
52
  const { name, kind } = spec;
53
53
  check(typeof name === "string" && typeof kind === "string", "Profiles need a string name and kind");
54
54
  const inputs = spec.with === void 0 ? [] : strings(spec.with);
@@ -61,6 +61,13 @@ function buildProfileTree(spec) {
61
61
  const ratios = fields.ratios;
62
62
  if (Array.isArray(ratios))
63
63
  fields.ratios = ratios.map((ratio) => Array.isArray(ratio) ? ratio.join(" / ") : modelValue(ratio)).join(", ");
64
+ const provides = spec.provides === void 0 ? {} : object(spec.provides, "Expected provided roles");
65
+ check(Object.keys(provides).length === 0 || kind === "surface", "Only a surface profile provides contextual roles");
66
+ for (const [token, value] of Object.entries(provides)) {
67
+ check(/^--[a-z][\w-]*$/.test(token) && typeof value === "string" && /^--[a-z][\w-]*$/.test(value), `A provided role names a token and the token it reads: ${token}`);
68
+ check(!Object.hasOwn(fields, token), `Duplicate provided role: ${token}`);
69
+ fields[token] = value;
70
+ }
64
71
  declarations(node, fields);
65
72
  for (const [choiceName, choice] of Object.entries(spec.choices === void 0 ? {} : object(spec.choices, "Expected choices"))) {
66
73
  const declared = only(choice, ["default", "options"]), child = clause(node, "ads-choice", choiceName, declared.default ? { default: declared.default } : {});
@@ -80,16 +87,15 @@ function buildProfileTree(spec) {
80
87
  required(profileDefinition(node));
81
88
  return root;
82
89
  }
83
- const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "recipe", "normalize", "theme", "paintTransition", "pseudo", "layer", "measured", "paints", "snap", "accessibility", "enter", "sticky", "outset", "elements", "play", "focus", "geometryTransition"]), NESTED_IN = {
90
+ const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "recipe", "normalize", "theme", "paintTransition", "pseudo", "layer", "measured", "paints", "snap", "accessibility", "enter", "sticky", "outset", "play", "focus", "geometryTransition"]), NESTED_IN = {
84
91
  "ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset", "focus", "geometryTransition"],
85
92
  "ads-cell": ["at"],
86
93
  "ads-at": ["cells", "frame"],
87
94
  "ads-when": ["play", "frame"],
88
- "ads-pseudo": ["when"],
89
- "ads-element": ["when"]
95
+ "ads-pseudo": ["when"]
90
96
  };
91
97
  function body(node, spec) {
92
- const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "elements", "play"] : []] : NESTED_IN[node.name] ?? [];
98
+ const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play"] : []] : NESTED_IN[node.name] ?? [];
93
99
  for (const field of Object.keys(spec))
94
100
  if (NESTED.has(field))
95
101
  check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
@@ -121,18 +127,13 @@ function body(node, spec) {
121
127
  const entrance = spec.enter;
122
128
  if (entrance !== void 0) {
123
129
  const { from, motion } = only(entrance, ["from", "motion"]);
124
- clause(node, "ads-enter", "", { ...only(from, ["surface", "translate", "scale", "rotate"]), ...motion === void 0 ? {} : { motion } });
130
+ clause(node, "ads-enter", "", { ...only(from, ["surface", "translate", "translateInline", "scale", "rotate"]), ...motion === void 0 ? {} : { motion } });
125
131
  }
126
132
  const layer = spec.layer;
127
133
  if (layer !== void 0) {
128
134
  const { backdrop, corner, ...fields } = only(layer, ["element", "edge", "backdrop", "motion", "modalBelow", "popover", "corner", "clear", "placement"]), nested = (name, value, keys) => value === void 0 ? [] : Object.entries(only(value, keys)).map(([key, item]) => [`${name}${key[0]?.toUpperCase() ?? ""}${key.slice(1)}`, item]);
129
135
  clause(node, "ads-layer", "", { ...fields, ...Object.fromEntries([...nested("backdrop", backdrop, ["surface", "dismiss"]), ...nested("corner", corner, ["block", "inline"])]) });
130
136
  }
131
- for (const [name, child] of Object.entries(spec.elements === void 0 ? {} : object(spec.elements, "Invalid elements declaration"))) {
132
- const { when, ...fields } = only(child, name === "component" ? ["spaceBefore", "spaceAfter"] : ["text", "surface", "frame", "marker", "markerText", "markers", "spaceBefore", "spaceAfter", "indent", "anchorClear", "when"]), element = clause(node, "ads-element", name, fields);
133
- for (const [condition, state] of Object.entries(when === void 0 ? {} : object(when, "Invalid when declaration")))
134
- body(clause(element, "ads-when", condition), object(state, "Invalid when declaration"));
135
- }
136
137
  for (const [field, kind] of [["parts", "part"], ["cells", "cell"], ["at", "at"], ["when", "when"], ["pseudo", "pseudo"]])
137
138
  for (const [name, child] of Object.entries(spec[field] === void 0 ? {} : object(spec[field], `Invalid ${field} declaration`)))
138
139
  body(clause(node, `ads-${kind}`, name), object(child, `Invalid ${field} declaration`));