@reqvire-org/ads 0.5.1 → 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.
- package/dist/ads-errors.mjs +143 -51
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +56 -7
- package/dist/analysis/owner-composition.mjs +179 -45
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +304 -110
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-contrast.mjs +143 -62
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +9 -3
- package/dist/construction-spec.d.mts +145 -31
- package/dist/construction-spec.mjs +204 -74
- package/dist/corner-overpaint.mjs +20 -7
- package/dist/derived-states.mjs +182 -0
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -9
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/grid-lowering.mjs +3 -1
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +23 -6
- package/dist/owner-errors.mjs +6 -3
- package/dist/owner-lowering.mjs +78 -13
- package/dist/owner-scenarios.mjs +6 -23
- package/dist/ownership-model.mjs +24 -8
- package/dist/paint-contrast.mjs +6 -0
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-macro.d.mts +7 -0
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +103 -40
- package/dist/recipe-model.mjs +18 -13
- package/dist/region-lowering.mjs +266 -123
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +9 -0
- package/dist/role-vocabulary.mjs +16 -1
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +10 -4
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +13 -7
- package/dist/skills/ads-designer/references/layout.md +12 -4
- package/dist/skills/ads-designer/references/motion.md +11 -2
- package/dist/skills/ads-designer/references/recipes.md +49 -15
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +13 -7
- package/dist/skills/ads-import/references/layout.md +12 -4
- package/dist/skills/ads-import/references/recipes.md +49 -15
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +13 -7
- package/dist/skills/ads-port/references/layout.md +12 -4
- package/dist/skills/ads-port/references/recipes.md +49 -15
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +7 -2
- package/dist/surface-effects.mjs +5 -3
- package/dist/target-size.mjs +21 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +96 -30
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +307 -23
- package/docs/GUIDE.md +109 -20
- package/docs/LANGUAGE.md +262 -117
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +15 -4
- package/docs/PROFILE-KINDS.md +54 -4
- package/docs/RULES.md +34 -25
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
- package/dist/analysis/prose-owners.mjs +0 -57
- package/dist/prose-model.d.mts +0 -81
- package/dist/prose-model.mjs +0 -101
package/dist/cli.mjs
CHANGED
|
@@ -127,7 +127,7 @@ async function printText(report, target) {
|
|
|
127
127
|
console.log(`ADS accessibility audit (${result.engine}): ${findingCounts(result.diagnostics.length, result.findings.filter((finding) => finding.severity === "review").length, info)}, ${result.incomplete ?? 0} that axe could not decide across ${result.scenarios} scenarios \xD7 ${result.themes.length} themes (${result.themes.join(", ")})${result.brands ? ` \xD7 ${result.brands.length} brands (${result.brands.join(", ")})` : ""}.`);
|
|
128
128
|
if (result.coverage) {
|
|
129
129
|
const skipped = Object.entries(result.coverage.skipped);
|
|
130
|
-
console.log(`Covered: ${result.coverage.renders} renders, ${result.coverage.overlaysOpened} overlays opened, ${result.coverage.controlsMeasured} controls hovered and focused; ${skipped.length ? `skipped ${skipped.map(([reason, entry]) => `${reason} ${entry.count}`).join(", ")}` : "nothing skipped"}.`);
|
|
130
|
+
console.log(`Covered: ${result.coverage.renders} renders, ${result.coverage.overlaysOpened} overlays opened, ${result.coverage.controlsMeasured} controls hovered and focused, ${result.coverage.derivedMeasured ?? 0} owner states derived from the recipes; ${skipped.length ? `skipped ${skipped.map(([reason, entry]) => `${reason} ${entry.count}`).join(", ")}` : "nothing skipped"}.`);
|
|
131
131
|
}
|
|
132
132
|
if (result.retries)
|
|
133
133
|
console.log(`Retried ${result.retries.length} render${result.retries.length === 1 ? "" : "s"} that then passed: ${result.retries.map((retry) => `${retry.scenario} [${[retry.theme, retry.brand].filter(Boolean).join(", ")}] in ${retry.attempts} attempts`).join("; ")}.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { selectedProfile, tokenDefinitionContexts } from "./design-foundation.mjs";
|
|
2
|
-
import { inactiveCondition, layeredBackdrop, layeredContrast, opaque, readColor } from "./paint-contrast.mjs";
|
|
2
|
+
import { inactiveCondition, layeredBackdrop, layeredContrast, opaque, readColor, unshown } from "./paint-contrast.mjs";
|
|
3
3
|
import { describeUnresolved, textMinimum } from "./surface-contrast.mjs";
|
|
4
4
|
import { sectionsDeclared } from "./token-sections.mjs";
|
|
5
5
|
export const NO_COMPOSITION = { positions: [] }, compositionLimits = Object.freeze({ chains: 512, hops: 24, backdrops: 256 });
|
|
@@ -44,6 +44,13 @@ export function composedContrastFindings(inputs) {
|
|
|
44
44
|
const selected = selectedProfile(foundation, surface), fields = selected.kind === "ok" && selected.value.kind === "surface" ? selected.value.fields : null, paint = fields === null ? null : { color: fields.get("color") ?? null, background: fields.get("background") ?? null, backgroundImage: fields.get("background-image") ?? null, opacity: fields.get("opacity") ?? null };
|
|
45
45
|
paints.set(surface, paint);
|
|
46
46
|
return paint;
|
|
47
|
+
}, provided = new Map, providesOf = (surface) => {
|
|
48
|
+
const known = provided.get(surface);
|
|
49
|
+
if (known !== void 0)
|
|
50
|
+
return known;
|
|
51
|
+
const selected = selectedProfile(foundation, surface), roles = new Map(selected.kind === "ok" && selected.value.kind === "surface" ? [...selected.value.fields].filter(([field]) => field.startsWith("--")) : []);
|
|
52
|
+
provided.set(surface, roles);
|
|
53
|
+
return roles;
|
|
47
54
|
}, documentElement = {
|
|
48
55
|
owner: null,
|
|
49
56
|
component: "the document",
|
|
@@ -72,10 +79,20 @@ export function composedContrastFindings(inputs) {
|
|
|
72
79
|
return "the base context";
|
|
73
80
|
const named = reported(context);
|
|
74
81
|
return `${[named.theme ?? "the base context", ...named.brand === void 0 ? [] : [named.brand]].join(", ")}${named.condition === void 0 ? "" : ` under ${named.condition}`}`;
|
|
75
|
-
}, FIRST = { index: 0, label: nameOf(contexts[0]) },
|
|
82
|
+
}, FIRST = { index: 0, label: nameOf(contexts[0]) }, evaluationKey = (elements) => {
|
|
83
|
+
let sized = !1;
|
|
84
|
+
return elements.flatMap((placed) => {
|
|
85
|
+
const { fact } = placed, text = sized ? null : fact.text;
|
|
86
|
+
if (fact.text !== null)
|
|
87
|
+
sized = !0;
|
|
88
|
+
if (placed.boundary === void 0 && fact.surfaces !== null && fact.surfaces.length === 0 && text === null && fact.flow === "in" && fact.context === null && fact.exempt === null && !UA_COLOR.has(fact.tag) && !UA_FILL.has(fact.tag))
|
|
89
|
+
return [];
|
|
90
|
+
return [[placed.owner, fact.scope ?? `${fact.at.file}:${fact.at.line}:${fact.at.column}`, fact.tag, fact.surfaces?.map((state) => [state.condition, state.surface]) ?? null, text, fact.flow, fact.context, fact.exempt, placed.boundary?.reason ?? null]];
|
|
91
|
+
});
|
|
92
|
+
}, chainRelated = new Map, chains = [], emit = (walk, certain, top) => {
|
|
76
93
|
if (walk.elements.some((placed) => placed.fact.exempt !== null))
|
|
77
94
|
return null;
|
|
78
|
-
const elements = [...walk.elements, top], key = JSON.stringify([certain, elements
|
|
95
|
+
const elements = [...walk.elements, top], key = JSON.stringify([certain, evaluationKey(elements)]);
|
|
79
96
|
let related = chainRelated.get(key);
|
|
80
97
|
if (related === void 0) {
|
|
81
98
|
chainRelated.set(key, related = new Map);
|
|
@@ -103,10 +120,13 @@ export function composedContrastFindings(inputs) {
|
|
|
103
120
|
return !1;
|
|
104
121
|
continue;
|
|
105
122
|
}
|
|
106
|
-
|
|
123
|
+
const value = arg === void 0 ? void 0 : arg.value.kind === "literal" ? arg.value.value : null;
|
|
124
|
+
if (arg === void 0 || typeof value === "object" && value !== null) {
|
|
125
|
+
if (prop.omitted === !1)
|
|
126
|
+
return !1;
|
|
107
127
|
continue;
|
|
108
|
-
|
|
109
|
-
if (
|
|
128
|
+
}
|
|
129
|
+
if (arg.value.kind !== "literal")
|
|
110
130
|
continue;
|
|
111
131
|
switch (prop.test) {
|
|
112
132
|
case "text": {
|
|
@@ -206,7 +226,7 @@ export function composedContrastFindings(inputs) {
|
|
|
206
226
|
note(source(placement.at), `it is rendered through <${content.tag}>${of}, a component ADS does not analyze: whether that wrapper paints a backdrop or passes the text on is unknown`, FIRST, walk.related);
|
|
207
227
|
return;
|
|
208
228
|
}
|
|
209
|
-
if (helper(owner, content.target)) {
|
|
229
|
+
if (helper(owner, content.target) && placement.component !== content.target.name) {
|
|
210
230
|
note(source(placement.at), sameFileReason(content.tag), FIRST, walk.related);
|
|
211
231
|
return;
|
|
212
232
|
}
|
|
@@ -250,8 +270,10 @@ export function composedContrastFindings(inputs) {
|
|
|
250
270
|
for (const { owner, position } of placementsOf.get(key) ?? []) {
|
|
251
271
|
if (!consistent(argsOf(position), frame.props))
|
|
252
272
|
continue;
|
|
253
|
-
const tag = position.content.kind === "placement" ? position.content.tag : frame.component;
|
|
254
|
-
if (
|
|
273
|
+
const tag = position.content.kind === "placement" ? position.content.tag : frame.component, recursive = owner === frame.owner && position.component === frame.component, recursion = pointKey(position.at);
|
|
274
|
+
if (recursive && (walk.recursed ?? []).includes(recursion))
|
|
275
|
+
continue;
|
|
276
|
+
if (!recursive && helper(owner, { file: frame.owner, name: frame.component })) {
|
|
255
277
|
steps.emit({ ...walk, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)] }, boundaryAt(position.at, position.component, sameFileReason(tag)));
|
|
256
278
|
continue;
|
|
257
279
|
}
|
|
@@ -264,7 +286,7 @@ export function composedContrastFindings(inputs) {
|
|
|
264
286
|
continue;
|
|
265
287
|
}
|
|
266
288
|
for (const leaf of position.leaves.leaves)
|
|
267
|
-
walkFrame({ owner, component: position.component, segments: leaf.segments, index: 0, props: leaf.props }, { ...walk, hops: walk.hops + 1, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)] }, mode, steps);
|
|
289
|
+
walkFrame({ owner, component: position.component, segments: leaf.segments, index: 0, props: leaf.props }, { ...walk, hops: walk.hops + 1, related: [...walk.related, relatedOf(position.at, `rendered as <${tag}>`)], ...recursive ? { recursed: [...walk.recursed ?? [], recursion] } : {} }, mode, steps);
|
|
268
290
|
}
|
|
269
291
|
for (const placement of plainOf.get(key) ?? [])
|
|
270
292
|
steps.emit({ ...walk, related: [...walk.related, relatedOf(placement.at, `rendered as <${placement.tag}> in ${placement.module}`)] }, boundaryAt(placement.at, frame.component, `${frame.component} is placed as <${placement.tag}> in ${placement.module}, a plain module whose composition ADS does not follow, so the backdrop ${frame.component} is rendered on there is unknown`));
|
|
@@ -379,66 +401,125 @@ export function composedContrastFindings(inputs) {
|
|
|
379
401
|
note(b.site, b.reason, contextLabel(index), related);
|
|
380
402
|
continue;
|
|
381
403
|
}
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
404
|
+
for (const variant of providedVariants(elements, f, b)) {
|
|
405
|
+
if (variant.requires.some((condition) => variant.excludes.includes(condition)))
|
|
406
|
+
continue;
|
|
407
|
+
const { value, layers } = variant, terminal = layers.at(-1);
|
|
408
|
+
if (terminal === void 0)
|
|
409
|
+
continue;
|
|
410
|
+
if (layers.length === 1 && terminal.element === f.element && !variant.changed)
|
|
411
|
+
continue;
|
|
412
|
+
const above = opacityAbove(terminal.element);
|
|
413
|
+
if (above !== void 0) {
|
|
414
|
+
note(siteOf(above.placed, above.state.at), `${describeUnresolved({ kind: "opacity", value: paintOf(above.state.surface)?.opacity ?? "" })}: it fades the text and its backdrop together`, contextLabel(index), related);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (unshown(value, context))
|
|
418
|
+
continue;
|
|
419
|
+
const backdrop = layeredBackdrop(context, layers);
|
|
420
|
+
if (backdrop.kind === "unresolved") {
|
|
421
|
+
const layer = layers[backdrop.layer] ?? terminal, placed = elements[layer.element];
|
|
422
|
+
if (placed !== void 0)
|
|
423
|
+
note(siteOf(placed, layer.state.at), describeUnresolved(backdrop.unresolved), contextLabel(index), related);
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const minimum = textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
|
|
427
|
+
if (foreElement === void 0)
|
|
428
|
+
continue;
|
|
429
|
+
switch (outcome.kind) {
|
|
430
|
+
case "sufficient":
|
|
431
|
+
break;
|
|
432
|
+
case "unresolved":
|
|
433
|
+
note(siteOf(foreElement, f.state.at), describeUnresolved(outcome.unresolved), contextLabel(index), related);
|
|
411
434
|
break;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
435
|
+
case "insufficient": {
|
|
436
|
+
const worst = layers[outcome.worst.layer] ?? terminal, backElement = elements[worst.element];
|
|
437
|
+
if (backElement === void 0)
|
|
438
|
+
break;
|
|
439
|
+
const backPaint = paintOf(worst.state.surface), backToken = (outcome.worst.image ? backPaint?.backgroundImage : backPaint?.background) ?? worst.state.surface, foregroundSite = siteOf(foreElement, f.state.at), backdropSite = siteOf(backElement, worst.state.at);
|
|
440
|
+
if (!chain.certain) {
|
|
441
|
+
note(foregroundSite.kind === "source" ? foregroundSite : backdropSite, `the expression it renders may be text: ${tokenOf(value)} on ${tokenOf(backToken)} is ${outcome.ratio}:1, below ${minimum}:1, if it is`, contextLabel(index), related);
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
const terminalElement = elements[terminal.element], over = worst === terminal || terminalElement === void 0 ? null : {
|
|
445
|
+
side: { component: terminalElement.component, surface: terminal.state.surface, token: tokenOf(paintOf(terminal.state.surface)?.background ?? terminal.state.surface) },
|
|
446
|
+
site: siteOf(terminalElement, terminal.state.at)
|
|
447
|
+
}, groupKey = JSON.stringify([siteKey(foregroundSite), siteKey(backdropSite), value, backToken, over === null ? null : siteKey(over.site)]), group = failures.get(groupKey) ?? {
|
|
448
|
+
over,
|
|
449
|
+
site: foregroundSite.kind === "source" ? foregroundSite : backdropSite,
|
|
450
|
+
foreground: { component: foreElement.component, surface: f.state.surface, token: tokenOf(value) },
|
|
451
|
+
background: { component: backElement.component, surface: worst.state.surface, token: tokenOf(backToken) },
|
|
452
|
+
foregroundSite,
|
|
453
|
+
backdropSite,
|
|
454
|
+
contexts: new Map,
|
|
455
|
+
related: new Map
|
|
456
|
+
};
|
|
457
|
+
failures.set(groupKey, group);
|
|
458
|
+
const failure = { ratio: outcome.ratio, minimum, foreground: outcome.foreground, background: outcome.background, states: [stateOf(f.requires), stateOf(b.requires.at(-1) ?? null)] }, known = group.contexts.get(index);
|
|
459
|
+
if (known === void 0 || failure.ratio < known.ratio)
|
|
460
|
+
group.contexts.set(index, failure);
|
|
461
|
+
for (const item of related)
|
|
462
|
+
group.related.set(siteKey(item.site), item);
|
|
415
463
|
break;
|
|
416
464
|
}
|
|
417
|
-
const terminalElement = elements[terminal.element], over = worst === terminal || terminalElement === void 0 ? null : {
|
|
418
|
-
side: { component: terminalElement.component, surface: terminal.state.surface, token: tokenOf(paintOf(terminal.state.surface)?.background ?? terminal.state.surface) },
|
|
419
|
-
site: siteOf(terminalElement, terminal.state.at)
|
|
420
|
-
}, groupKey = JSON.stringify([siteKey(foregroundSite), siteKey(backdropSite), f.value, backToken, over === null ? null : siteKey(over.site)]), group = failures.get(groupKey) ?? {
|
|
421
|
-
over,
|
|
422
|
-
site: foregroundSite.kind === "source" ? foregroundSite : backdropSite,
|
|
423
|
-
foreground: { component: foreElement.component, surface: f.state.surface, token: tokenOf(f.value) },
|
|
424
|
-
background: { component: backElement.component, surface: worst.state.surface, token: tokenOf(backToken) },
|
|
425
|
-
foregroundSite,
|
|
426
|
-
backdropSite,
|
|
427
|
-
contexts: new Map,
|
|
428
|
-
related: new Map
|
|
429
|
-
};
|
|
430
|
-
failures.set(groupKey, group);
|
|
431
|
-
const failure = { ratio: outcome.ratio, minimum, foreground: outcome.foreground, background: outcome.background, states: [stateOf(f.requires), stateOf(b.requires.at(-1) ?? null)] }, known = group.contexts.get(index);
|
|
432
|
-
if (known === void 0 || failure.ratio < known.ratio)
|
|
433
|
-
group.contexts.set(index, failure);
|
|
434
|
-
for (const item of related)
|
|
435
|
-
group.related.set(siteKey(item.site), item);
|
|
436
|
-
break;
|
|
437
465
|
}
|
|
438
466
|
}
|
|
439
467
|
}
|
|
440
468
|
});
|
|
441
469
|
}
|
|
470
|
+
function providedVariants(elements, f, b) {
|
|
471
|
+
const base = { value: f.value, layers: b.layers, requires: [...f.requires === null ? [] : [f.requires], ...b.requires], excludes: [...f.excludes, ...b.excludes], changed: !1 };
|
|
472
|
+
if (!elements.some((placed) => (placed.fact.surfaces ?? []).some((state) => providesOf(state.surface).size > 0)))
|
|
473
|
+
return [base];
|
|
474
|
+
const resolve = (value, from, depth) => {
|
|
475
|
+
const tokens = [...new Set([...value.matchAll(/var\(\s*(--[\w-]+)/g)].map((match) => match[1] ?? ""))];
|
|
476
|
+
let results = [{ value, requires: [], excludes: [], changed: !1 }];
|
|
477
|
+
for (const token of tokens) {
|
|
478
|
+
const options = depth > 4 ? [] : bindings(token, from, depth);
|
|
479
|
+
if (options.length === 0)
|
|
480
|
+
continue;
|
|
481
|
+
results = results.flatMap((result) => options.map((option) => ({
|
|
482
|
+
value: option.value === null ? result.value : result.value.replaceAll(new RegExp(`var\\(\\s*${token}\\s*\\)`, "g"), option.value),
|
|
483
|
+
requires: [...result.requires, ...option.requires],
|
|
484
|
+
excludes: [...result.excludes, ...option.excludes],
|
|
485
|
+
changed: result.changed || option.value !== null
|
|
486
|
+
})));
|
|
487
|
+
if (results.length > compositionLimits.backdrops)
|
|
488
|
+
return results.slice(0, compositionLimits.backdrops);
|
|
489
|
+
}
|
|
490
|
+
return results;
|
|
491
|
+
}, bindings = (token, from, depth) => {
|
|
492
|
+
const out = [];
|
|
493
|
+
let passed = [];
|
|
494
|
+
for (let index = from;index < elements.length; index++) {
|
|
495
|
+
const placed = elements[index];
|
|
496
|
+
if (placed === void 0)
|
|
497
|
+
break;
|
|
498
|
+
const states = (placed.fact.surfaces ?? []).filter((state) => providesOf(state.surface).has(token));
|
|
499
|
+
if (states.length === 0)
|
|
500
|
+
continue;
|
|
501
|
+
const conditions = states.flatMap((state) => state.condition === null ? [] : [conditionKey(placed, state.condition)]);
|
|
502
|
+
for (const state of states) {
|
|
503
|
+
const raw = providesOf(state.surface).get(token) ?? "", requires = state.condition === null ? [] : [conditionKey(placed, state.condition)], excludes = state.condition === null ? [...passed, ...conditions] : passed;
|
|
504
|
+
for (const inner of resolve(raw, index, depth + 1))
|
|
505
|
+
out.push({ value: inner.value, requires: [...requires, ...inner.requires], excludes: [...excludes, ...inner.excludes] });
|
|
506
|
+
}
|
|
507
|
+
if (states.some((state) => state.condition === null))
|
|
508
|
+
return out;
|
|
509
|
+
passed = [...passed, ...conditions];
|
|
510
|
+
}
|
|
511
|
+
out.push({ value: null, requires: [], excludes: passed });
|
|
512
|
+
return out;
|
|
513
|
+
};
|
|
514
|
+
let variants = resolve(f.value, f.element, 0).map((fore) => ({ value: fore.value, layers: [], requires: [...base.requires, ...fore.requires], excludes: [...base.excludes, ...fore.excludes], changed: fore.changed }));
|
|
515
|
+
for (const layer of b.layers) {
|
|
516
|
+
const options = layer.background === null ? [null] : resolve(layer.background, layer.element, 0);
|
|
517
|
+
variants = variants.flatMap((variant) => options.map((option) => option === null ? { ...variant, layers: [...variant.layers, layer] } : { value: variant.value, layers: [...variant.layers, { ...layer, background: option.value }], requires: [...variant.requires, ...option.requires], excludes: [...variant.excludes, ...option.excludes], changed: variant.changed || option.changed }));
|
|
518
|
+
if (variants.length > compositionLimits.backdrops)
|
|
519
|
+
variants = variants.slice(0, compositionLimits.backdrops);
|
|
520
|
+
}
|
|
521
|
+
return variants;
|
|
522
|
+
}
|
|
442
523
|
function foregroundOptions(elements) {
|
|
443
524
|
const options = [];
|
|
444
525
|
let excludes = [];
|
|
@@ -53,8 +53,8 @@ function rootsOf(owners, ref, known, hops) {
|
|
|
53
53
|
}
|
|
54
54
|
const outer = last.elements.at(-1);
|
|
55
55
|
if (outer !== void 0) {
|
|
56
|
-
|
|
57
|
-
frames.set(JSON.stringify([outer.at,
|
|
56
|
+
for (const frame of outer.frame === void 0 ? [] : [outer.frame, ...outer.frame.states ?? []])
|
|
57
|
+
frames.set(JSON.stringify([outer.at, frame.name, frame.padding]), { name: frame.name, padding: frame.padding, at: outer.at });
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
60
|
if (leaf.segments.length !== 1 || position.content.kind !== "placement")
|
package/dist/config.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { isDraftFile } from "./draft-boundary.mjs";
|
|
4
|
+
import { revisionText } from "./analysis/context.mjs";
|
|
4
5
|
import { defaultCompileSettings, outputDirectory, outputDirectoryProblem } from "./emit/output-location.mjs";
|
|
5
6
|
export const supportedFrameworks = ["react", "preact"];
|
|
6
7
|
const isFramework = (value) => value === "react" || value === "preact";
|
|
@@ -92,7 +93,7 @@ const scriptList = (value, name) => {
|
|
|
92
93
|
return value;
|
|
93
94
|
};
|
|
94
95
|
export function loadConfig(directory = process.cwd()) {
|
|
95
|
-
const root = path.resolve(directory), configFile = path.join(root, "ds.config.json"), configText = existsSync(configFile) ? readFileSync(configFile, "utf8") : "{}", user = JSON.parse(configText);
|
|
96
|
+
const root = path.resolve(directory), configFile = path.join(root, "ds.config.json"), captured = revisionText(configFile), configText = (captured === void 0 ? existsSync(configFile) ? readFileSync(configFile, "utf8") : null : captured.text) ?? "{}", user = JSON.parse(configText);
|
|
96
97
|
if (!isFields(user))
|
|
97
98
|
throw Error("ds.config.json must be an object.");
|
|
98
99
|
for (const field of Object.keys(user))
|
|
@@ -48,7 +48,12 @@ export function output(root, operation, reject, profile) {
|
|
|
48
48
|
use(own);
|
|
49
49
|
declarations.push([name, own]);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
const conditions = condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], roles = declarations.filter(([property]) => property.startsWith("--"));
|
|
52
|
+
if (roles.length > 0)
|
|
53
|
+
checked(session.writeProvidedRoles({ selector, conditions, values: roles, important: !1 }));
|
|
54
|
+
const rest = declarations.filter(([property]) => !property.startsWith("--"));
|
|
55
|
+
if (rest.length > 0 || roles.length === 0)
|
|
56
|
+
checked(session.write({ selector, conditions, values: rest, important: !1 }));
|
|
52
57
|
},
|
|
53
58
|
tree: (node) => checked(session.writeTree(node, root)),
|
|
54
59
|
document: (rule) => session.writeDocument(rule),
|
|
@@ -268,6 +273,7 @@ export function visualPart(asset, visual, state, theme, reject) {
|
|
|
268
273
|
const size = visual.size ?? reject({ kind: "profile-field-missing", profile: "visual", field: "size" }), drawing = model(selectAsset(asset, theme, size, state), reject), intrinsic = asset.paint === "intrinsic", [, , width, height] = drawing.box, [x, y] = drawing.center, ratio = width / height, factors = { block: 1 + 2 * Math.abs(y), inline: ratio * (1 + 2 * Math.abs(x)) }, extent = `calc(${size} * ${factors.block})`;
|
|
269
274
|
return {
|
|
270
275
|
drawing,
|
|
276
|
+
size,
|
|
271
277
|
extent,
|
|
272
278
|
factors,
|
|
273
279
|
element: intrinsic ? "img" : "svg",
|
|
@@ -293,9 +299,9 @@ export function visualPart(asset, visual, state, theme, reject) {
|
|
|
293
299
|
}
|
|
294
300
|
export function coverArtwork(asset, visual, state, theme, reject) {
|
|
295
301
|
const drawing = model(selectAsset(asset, theme, visual.size ?? "", state), reject);
|
|
296
|
-
return { drawing, element: "img", source: `data:image/svg+xml,${encodeURIComponent(drawing.text)}` };
|
|
302
|
+
return { drawing, size: null, element: "img", source: `data:image/svg+xml,${encodeURIComponent(drawing.text)}` };
|
|
297
303
|
}
|
|
298
|
-
export const placed = (geometry) => ({ drawing: geometry.drawing, element: geometry.element, source: geometry.source }), LINE_BOX = "1lh";
|
|
304
|
+
export const placed = (geometry) => ({ drawing: geometry.drawing, size: geometry.size, element: geometry.element, source: geometry.source }), LINE_BOX = "1lh";
|
|
299
305
|
export function controlBox(frame, envelope, field, reject) {
|
|
300
306
|
const insets = controlFrameInsets(frame);
|
|
301
307
|
if (insets.kind === "err")
|
|
@@ -2,7 +2,6 @@ import { type Result } from "./result.mjs";
|
|
|
2
2
|
import type { ColorScheme } from "./asset-declaration.mjs";
|
|
3
3
|
import { type Json, type JsonObject } from "./json.mjs";
|
|
4
4
|
import { type ConditionProblem } from "./state-conditions.mjs";
|
|
5
|
-
import { type ProseElementName } from "./prose-model.mjs";
|
|
6
5
|
export type ConstructionKind = "control" | "artwork" | "region" | "grid";
|
|
7
6
|
export type SpecFailure = {
|
|
8
7
|
readonly kind: "field-unsupported";
|
|
@@ -74,11 +73,15 @@ export interface TextPart {
|
|
|
74
73
|
readonly required: boolean;
|
|
75
74
|
readonly textEdge: readonly string[];
|
|
76
75
|
readonly wrap: ControlLabelWrap;
|
|
76
|
+
/** How the label's lines sit in its box (`text-align`): it shows once the label wraps or the control is wider than it. */
|
|
77
|
+
readonly align: TextAlign | null;
|
|
78
|
+
/** `fill`: in an inline control the label takes the room the control's other content leaves, so a visual after it sits at the far end. */
|
|
79
|
+
readonly extent: "content" | "fill";
|
|
77
80
|
}
|
|
78
81
|
/** A state effect on a control's visual part, bound to the motion profile. */
|
|
79
82
|
/** A control's artwork effect under an owner state. The three scales are one channel: whole, or one axis only (a blink). */
|
|
80
83
|
export type GlyphEffect = {
|
|
81
|
-
readonly effect: "scale" | "scale-inline" | "scale-block" | "translate-inline";
|
|
84
|
+
readonly effect: "scale" | "scale-inline" | "scale-block" | "translate-inline" | "rotate";
|
|
82
85
|
readonly field: string;
|
|
83
86
|
};
|
|
84
87
|
export interface GlyphPart {
|
|
@@ -141,11 +144,15 @@ export declare const PART_EFFECTS: {
|
|
|
141
144
|
readonly channel: "translate";
|
|
142
145
|
readonly field: "distance";
|
|
143
146
|
};
|
|
147
|
+
readonly rotate: {
|
|
148
|
+
readonly channel: "rotate";
|
|
149
|
+
readonly field: "angle";
|
|
150
|
+
};
|
|
144
151
|
};
|
|
145
152
|
/** A scale effect's value on its axis: the whole element, or one axis with the other at rest. */
|
|
146
153
|
export declare const scaleValue: (effect: "scale" | "scaleInline" | "scaleBlock" | "scale-inline" | "scale-block", value: string) => string;
|
|
147
154
|
export type PartEffectName = keyof typeof PART_EFFECTS;
|
|
148
|
-
export type PartChannel = "translate" | "scale";
|
|
155
|
+
export type PartChannel = "translate" | "scale" | "rotate";
|
|
149
156
|
/**
|
|
150
157
|
* A region part's motion under owner states: a card whose arrow slides, or whose picture grows, while
|
|
151
158
|
* the card is hovered. `transition` lists the channels that animate (an effect whose channel is not
|
|
@@ -182,6 +189,7 @@ export interface StickySpec {
|
|
|
182
189
|
/** What an entering element moves by: each reads one field of the entrance's motion profile. */
|
|
183
190
|
export declare const ENTER_MOVEMENTS: {
|
|
184
191
|
readonly translate: "distance";
|
|
192
|
+
readonly translateInline: "distance";
|
|
185
193
|
readonly scale: "scale";
|
|
186
194
|
readonly rotate: "angle";
|
|
187
195
|
};
|
|
@@ -194,7 +202,7 @@ export type EnterDriver = {
|
|
|
194
202
|
readonly kind: "first-render";
|
|
195
203
|
};
|
|
196
204
|
/**
|
|
197
|
-
* `enter: { from: { surface?, translate? | scale? | rotate? }, motion }`: the element starts from a
|
|
205
|
+
* `enter: { from: { surface?, translate? | translateInline? | scale? | rotate? }, motion }`: the element starts from a
|
|
198
206
|
* declared look and settles into its own. The starting surface states only `opacity` and `blur`
|
|
199
207
|
* (checked when it lowers); at most one movement, read from the entrance's motion profile.
|
|
200
208
|
*/
|
|
@@ -213,8 +221,12 @@ export interface PaintTransition {
|
|
|
213
221
|
readonly channels: readonly PaintChannel[];
|
|
214
222
|
readonly motion: MotionBinding;
|
|
215
223
|
}
|
|
216
|
-
/**
|
|
217
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Pseudo-elements an owned part may treat. `placeholder` is the native placeholder text of an input or
|
|
226
|
+
* textarea (a colour). `progressValue` is the filled part of a `<progress>` (a background): the part's own
|
|
227
|
+
* surface is its track.
|
|
228
|
+
*/
|
|
229
|
+
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue"];
|
|
218
230
|
export type PseudoElement = (typeof PSEUDO_ELEMENTS)[number];
|
|
219
231
|
/** The elements that have each pseudo-element: a treatment on any other element would never match. */
|
|
220
232
|
export declare const PSEUDO_HOSTS: {
|
|
@@ -264,9 +276,30 @@ interface ControlCommon {
|
|
|
264
276
|
readonly textWhen: readonly StateText[];
|
|
265
277
|
/** The control's own text profile, replacing its profile's text slot; `null`: the slot's. */
|
|
266
278
|
readonly text: string | null;
|
|
267
|
-
|
|
279
|
+
/** `null` for a control that renders no text of its own (a switch, whose label is beside it). */
|
|
280
|
+
readonly label: TextPart | null;
|
|
268
281
|
/** `null` for a text-only control. */
|
|
269
282
|
readonly glyph: GlyphPart | null;
|
|
283
|
+
/** The control's decorative boxes (a switch's knob), in authored order. */
|
|
284
|
+
readonly decor: readonly DecorPart[];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* A decorative box of a control: an empty element with a frame profile's box and a surface, hidden from
|
|
288
|
+
* assistive technology, that shows the control's state by its paint or position (a switch's knob, a
|
|
289
|
+
* radio's dot). `effects` move it under owner states; a move is the state's shape, so reduced motion keeps
|
|
290
|
+
* it and drops only its animation.
|
|
291
|
+
*/
|
|
292
|
+
export interface DecorPart {
|
|
293
|
+
readonly kind: "box";
|
|
294
|
+
readonly name: string;
|
|
295
|
+
readonly selector: string;
|
|
296
|
+
readonly required: boolean;
|
|
297
|
+
/** The frame profile that sizes and shapes the box. */
|
|
298
|
+
readonly box: string;
|
|
299
|
+
readonly surface: string | null;
|
|
300
|
+
readonly when: readonly (readonly [condition: string, surface: string | null, effects: readonly GlyphEffect[]])[];
|
|
301
|
+
/** The channels that animate (`translate`, `scale`), each with an effect in some `when` entry. */
|
|
302
|
+
readonly transition: readonly ("translate" | "scale")[];
|
|
270
303
|
}
|
|
271
304
|
/** A declared continuous rotation of standalone artwork under one condition. */
|
|
272
305
|
export interface ContinuousEffect {
|
|
@@ -288,34 +321,15 @@ export interface ArtworkSpec {
|
|
|
288
321
|
readonly source: JsonObject;
|
|
289
322
|
readonly align: string;
|
|
290
323
|
readonly part: ArtworkPart;
|
|
324
|
+
/** A colour-only surface: the colour a foreground drawing takes (an icon's own quiet tone); `null`: its container's. */
|
|
325
|
+
readonly surface: string | null;
|
|
291
326
|
}
|
|
292
327
|
/**
|
|
293
328
|
* `native` keeps the element's own display: a treatment or frame without an
|
|
294
329
|
* arrangement. `layered` stacks every declared child part in one grid area,
|
|
295
330
|
* painted in DOM order.
|
|
296
331
|
*/
|
|
297
|
-
export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered"
|
|
298
|
-
/**
|
|
299
|
-
* One element of a prose recipe (./prose-model.mts): the profiles its plain markup takes, by name.
|
|
300
|
-
* `spaceBefore` replaces the rhythm before a block (more space above a heading); `indent` is a
|
|
301
|
-
* list's start inset; `marker` a colour-only surface for a list item's marker.
|
|
302
|
-
*/
|
|
303
|
-
export interface ProseElement {
|
|
304
|
-
readonly name: ProseElementName;
|
|
305
|
-
readonly path: string;
|
|
306
|
-
readonly text: string | null;
|
|
307
|
-
readonly surface: string | null;
|
|
308
|
-
readonly frame: string | null;
|
|
309
|
-
readonly when: readonly StateTreatment[];
|
|
310
|
-
readonly spaceBefore: SlotBinding | null;
|
|
311
|
-
readonly indent: SlotBinding | null;
|
|
312
|
-
readonly marker: string | null;
|
|
313
|
-
}
|
|
314
|
-
/** `layout: "prose"`: the space between blocks and the elements the recipe styles, in authored order. */
|
|
315
|
-
export interface ProseSpec {
|
|
316
|
-
readonly rhythm: SlotBinding | null;
|
|
317
|
-
readonly elements: readonly ProseElement[];
|
|
318
|
-
}
|
|
332
|
+
export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered";
|
|
319
333
|
/** The scroll-snap axis and strictness a scrolling element declares (`scroll-snap-type`), on logical axes: they follow the writing mode, as `overflow` does. */
|
|
320
334
|
export declare const SNAP_TYPES: readonly ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"];
|
|
321
335
|
export type SnapType = (typeof SNAP_TYPES)[number];
|
|
@@ -332,12 +346,46 @@ export interface Snap {
|
|
|
332
346
|
readonly align: SnapAlign;
|
|
333
347
|
}
|
|
334
348
|
/** How an element arranges its children. */
|
|
349
|
+
/** Later neighbours paint over earlier ones (DOM order). */
|
|
350
|
+
export interface OverlapSpec {
|
|
351
|
+
readonly by: SlotBinding;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Geometry an element takes under one owner state: another frame profile (sizes, insets, radius, border
|
|
355
|
+
* widths), another spacing profile (the arrangement's gap and overlap are read from it), and for a part
|
|
356
|
+
* whether it is collapsed. Each is a whole profile, lowered and checked as the base one is.
|
|
357
|
+
*/
|
|
358
|
+
export interface StateGeometry {
|
|
359
|
+
readonly condition: string;
|
|
360
|
+
readonly frame: string | null;
|
|
361
|
+
readonly spacing: string | null;
|
|
362
|
+
/** A part only: `null` leaves the part as it is at rest. */
|
|
363
|
+
readonly collapsed: boolean | null;
|
|
364
|
+
readonly path: string;
|
|
365
|
+
}
|
|
366
|
+
/** The geometry that animates between states, as closed channels, timed by a motion profile. */
|
|
367
|
+
/**
|
|
368
|
+
* `overlap` is the element's own start margin where an overlapping arrangement places it: the arrangement
|
|
369
|
+
* decides the value, the element animates its change (a face in a pile that spreads).
|
|
370
|
+
*/
|
|
371
|
+
export declare const GEOMETRY_CHANNELS: readonly ["size", "inset", "gap", "radius", "border-width", "overlap"];
|
|
372
|
+
export type GeometryChannel = (typeof GEOMETRY_CHANNELS)[number];
|
|
373
|
+
export interface GeometryTransition {
|
|
374
|
+
readonly channels: readonly GeometryChannel[];
|
|
375
|
+
readonly motion: MotionBinding;
|
|
376
|
+
readonly path: string;
|
|
377
|
+
}
|
|
335
378
|
export interface Arrangement {
|
|
336
379
|
readonly layout: RegionLayout;
|
|
337
380
|
readonly align: string | null;
|
|
338
381
|
readonly justify: string | null;
|
|
339
382
|
readonly wrap: boolean;
|
|
340
383
|
readonly gap: SlotBinding | null;
|
|
384
|
+
/**
|
|
385
|
+
* `overlap`: neighbours overlap by a spacing value instead of being separated by one (a pile of faces, a
|
|
386
|
+
* stack of cards). Real layout: the row is as wide as what it shows. Never beside `gap`.
|
|
387
|
+
*/
|
|
388
|
+
readonly overlap: OverlapSpec | null;
|
|
341
389
|
/** `null` when the element does not snap its children. */
|
|
342
390
|
readonly snap: Snap | null;
|
|
343
391
|
}
|
|
@@ -396,6 +444,18 @@ export type RegionFrame =
|
|
|
396
444
|
*/
|
|
397
445
|
export declare const FRAME_CORNERS: readonly ["start-start", "start-end", "end-start", "end-end"];
|
|
398
446
|
export type FrameCorner = (typeof FRAME_CORNERS)[number];
|
|
447
|
+
/**
|
|
448
|
+
* A frame profile's own radius for one corner (`startStartRadius` …): it replaces the profile's `radius`
|
|
449
|
+
* on that corner (a chat bubble's small tail corner). A corner with neither is square.
|
|
450
|
+
*/
|
|
451
|
+
export declare const CORNER_RADIUS_FIELDS: {
|
|
452
|
+
readonly "start-start": "start-start-radius";
|
|
453
|
+
readonly "start-end": "start-end-radius";
|
|
454
|
+
readonly "end-start": "end-start-radius";
|
|
455
|
+
readonly "end-end": "end-end-radius";
|
|
456
|
+
};
|
|
457
|
+
/** The radius a frame's fields give one corner, or `undefined` where it is square. */
|
|
458
|
+
export declare const cornerRadius: (field: (name: string) => string | undefined, corner: FrameCorner) => string | undefined;
|
|
399
459
|
/** A region root's frame under one named condition: other ruled sides, other rounded corners, or both. */
|
|
400
460
|
export interface FrameCondition {
|
|
401
461
|
readonly condition: string;
|
|
@@ -489,6 +549,13 @@ export type PartContent = {
|
|
|
489
549
|
readonly stroke: string;
|
|
490
550
|
} | {
|
|
491
551
|
readonly kind: "element";
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* A public component placed with the part's marker (`<Heading className="ux-article-heading" …/>`), as a grid
|
|
555
|
+
* cell is: its interior is its owner's, so the part takes placement only (its space, extent, visibility).
|
|
556
|
+
*/
|
|
557
|
+
| {
|
|
558
|
+
readonly kind: "component";
|
|
492
559
|
};
|
|
493
560
|
/** A state treatment: an owner condition selecting a surface profile. */
|
|
494
561
|
export type StateTreatment = readonly [condition: string, surface: string];
|
|
@@ -559,7 +626,41 @@ export interface RuntimePaint {
|
|
|
559
626
|
export interface RegionPart {
|
|
560
627
|
readonly name: string;
|
|
561
628
|
readonly selector: string;
|
|
629
|
+
/** `anchorClear`: where a jump to this element lands below the scroll container's top edge. */
|
|
630
|
+
readonly anchorClear: SlotBinding | null;
|
|
631
|
+
/** The geometry the part takes under owner states. */
|
|
632
|
+
readonly geometryWhen: readonly StateGeometry[];
|
|
633
|
+
readonly geometryTransition: GeometryTransition | null;
|
|
634
|
+
/**
|
|
635
|
+
* `collapsed: true`: the part takes no room on its parent's main axis, is transparent, and is hidden from
|
|
636
|
+
* assistive technology and focus; a `when` entry may open it (`collapsed: false`) or close an open one.
|
|
637
|
+
*/
|
|
638
|
+
readonly collapsed: boolean;
|
|
639
|
+
/**
|
|
640
|
+
* `focus: { of: "<sibling part>" }`: this part is the drawn stand-in of a native control beside it (the box
|
|
641
|
+
* of a checkbox whose `<input>` is hidden) and shows the focus indicator while that control has keyboard focus.
|
|
642
|
+
*/
|
|
643
|
+
readonly focusOf: string | null;
|
|
644
|
+
/**
|
|
645
|
+
* `drawnBy: "<sibling part>"`: this part is a native control (a checkbox's `<input>`) that the named part draws.
|
|
646
|
+
* It is invisible and takes no room, laid over that part at its frame's size, so pointer and keyboard still
|
|
647
|
+
* reach the real control. The drawing part follows it and shows its focus (`focus: { of }`).
|
|
648
|
+
*/
|
|
649
|
+
readonly drawnBy: string | null;
|
|
562
650
|
readonly required: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* `repeat: true`: the part's element renders once per item of a list (`tabs.map(…)`), any number of times
|
|
653
|
+
* (at least once when `required`). Every instance takes the part's construction; consecutive instances are
|
|
654
|
+
* neighbours of their arrangement (a target's hit area and spacing are checked against the next one).
|
|
655
|
+
*/
|
|
656
|
+
readonly repeat: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* In a `stack`: the space before this part, in place of the stack's gap (a heading further from what precedes
|
|
659
|
+
* it), and the space between it and whatever follows. Where one part's space after meets the next part's
|
|
660
|
+
* space before, the larger applies. A spacing slot field.
|
|
661
|
+
*/
|
|
662
|
+
readonly spaceBefore: SlotBinding | null;
|
|
663
|
+
readonly spaceAfter: SlotBinding | null;
|
|
563
664
|
readonly content: PartContent;
|
|
564
665
|
readonly textEdge: readonly string[];
|
|
565
666
|
readonly textLayout: TextLayout;
|
|
@@ -686,8 +787,11 @@ export interface RegionSpec {
|
|
|
686
787
|
readonly textWhen: readonly StateText[];
|
|
687
788
|
/** The root's frame under one named condition; `null` when it is the same at every width. */
|
|
688
789
|
readonly frameAt: FrameCondition | null;
|
|
689
|
-
/**
|
|
690
|
-
readonly
|
|
790
|
+
/** Where a jump to the root lands; never on a top-layer root, which is not in the page's flow. */
|
|
791
|
+
readonly anchorClear: SlotBinding | null;
|
|
792
|
+
/** The geometry the root takes under owner states; never on a top-layer root. */
|
|
793
|
+
readonly geometryWhen: readonly StateGeometry[];
|
|
794
|
+
readonly geometryTransition: GeometryTransition | null;
|
|
691
795
|
/** The root's entrance; never on a top-layer root, whose layer motion is its entrance. */
|
|
692
796
|
readonly enter: EnterSpec | null;
|
|
693
797
|
/** The root stays at an edge of its scrolling container; never on a top-layer root, which the top layer places. */
|
|
@@ -708,6 +812,14 @@ export type SpatialValue = string | number | boolean | readonly (string | number
|
|
|
708
812
|
export type SpatialValues = readonly (readonly [field: string, value: SpatialValue])[];
|
|
709
813
|
export interface GridCell {
|
|
710
814
|
readonly selector: string;
|
|
815
|
+
/** `required: false`: the cell may be absent (an optional notice); it renders at most once unless repeated. */
|
|
816
|
+
readonly required: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* `repeat: true`: the cell renders once per item of a list, any number of times (at least once when required).
|
|
819
|
+
* Its instances flow one after another: it auto-places at every tier (`start: "auto"`, implied) and takes no
|
|
820
|
+
* row of its own; its span may be `"full"` or a number.
|
|
821
|
+
*/
|
|
822
|
+
readonly repeat: boolean;
|
|
711
823
|
readonly values: SpatialValues;
|
|
712
824
|
/** Breakpoint tier → placement changes from that tier on. */
|
|
713
825
|
readonly at: readonly (readonly [tier: string, values: SpatialValues])[];
|
|
@@ -745,6 +857,8 @@ export interface DeclaredPart {
|
|
|
745
857
|
readonly path: string;
|
|
746
858
|
readonly selector: string;
|
|
747
859
|
readonly required: boolean;
|
|
860
|
+
/** Rendered once per item of a list: any number of instances (see {@link RegionPart.repeat}). */
|
|
861
|
+
readonly repeat: boolean;
|
|
748
862
|
readonly kind: RegionPartContent;
|
|
749
863
|
/** Enclosing declared parts' selectors, outermost first: the part is a child of the last. */
|
|
750
864
|
readonly within: readonly string[];
|