@reqvire-org/ads 0.5.1 → 0.5.2
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 +110 -25
- 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/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +23 -4
- package/dist/analysis/owner-composition.mjs +118 -33
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +253 -76
- 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-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +3 -2
- package/dist/construction-spec.d.mts +111 -6
- package/dist/construction-spec.mjs +172 -30
- package/dist/corner-overpaint.mjs +16 -4
- package/dist/derived-states.mjs +182 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -4
- 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/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- 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/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +19 -5
- package/dist/owner-errors.mjs +4 -2
- package/dist/owner-lowering.mjs +71 -12
- package/dist/owner-scenarios.mjs +4 -1
- package/dist/ownership-model.mjs +18 -4
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +72 -13
- package/dist/recipe-model.mjs +9 -5
- package/dist/region-lowering.mjs +238 -40
- 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 +5 -0
- package/dist/role-vocabulary.mjs +12 -1
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +32 -32
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +4 -4
- package/dist/skills/ads-designer/references/accessibility.md +7 -0
- 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 +1 -1
- package/dist/skills/ads-designer/references/layout.md +5 -1
- package/dist/skills/ads-designer/references/motion.md +9 -1
- package/dist/skills/ads-designer/references/recipes.md +27 -3
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +1 -1
- package/dist/skills/ads-import/references/layout.md +5 -1
- package/dist/skills/ads-import/references/recipes.md +27 -3
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +1 -1
- package/dist/skills/ads-port/references/layout.md +5 -1
- package/dist/skills/ads-port/references/recipes.md +27 -3
- package/dist/surface-contrast.mjs +1 -0
- package/dist/surface-effects.mjs +5 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ARCHITECTURE.md +63 -7
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +200 -23
- package/docs/GUIDE.md +45 -1
- package/docs/LANGUAGE.md +146 -8
- package/docs/MOTION.md +10 -2
- package/docs/PROFILE-KINDS.md +9 -1
- package/docs/RULES.md +22 -14
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
package/dist/ownership-model.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fail, rejecting } from "./design-rejection.mjs";
|
|
2
|
-
import { CURSORS, ELEMENT_NAMES, FRAME_CORNERS, FRAME_SIDES, 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"]), placement = {
|
|
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 = {
|
|
4
4
|
start: (value) => value === "auto" || positive(value),
|
|
5
5
|
end: positive,
|
|
6
6
|
span: (value) => value === "full" || positive(value),
|
|
@@ -20,7 +20,9 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
20
20
|
extent: oneOf("content", "container"),
|
|
21
21
|
gap: spacing,
|
|
22
22
|
"row-gap": spacing,
|
|
23
|
+
overlap: overlapSpacing,
|
|
23
24
|
rhythm: spacing,
|
|
25
|
+
"anchor-clear": anchorClear,
|
|
24
26
|
columns: positive,
|
|
25
27
|
weights: (value) => value.split(/\s+/).length <= 64 && value.split(/\s+/).every((weight) => /^\d+(\.\d+)?$/.test(weight) && Number(weight) > 0),
|
|
26
28
|
rows: (value) => value.split(/\s+/).length <= 12 && value.split(/\s+/).every((row) => ["auto", "fill"].includes(row)),
|
|
@@ -43,6 +45,8 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
43
45
|
wrap: oneOf("true", "false", ...TEXT_WRAPS),
|
|
44
46
|
"text-align": TEXT_ALIGN,
|
|
45
47
|
"reserve-lines": oneOf("1", "2", "3"),
|
|
48
|
+
collapsed: oneOf("true", "false"),
|
|
49
|
+
"anchor-clear": anchorClear,
|
|
46
50
|
lines: oneOf("2", "3"),
|
|
47
51
|
overflow: OVERFLOW,
|
|
48
52
|
extent: oneOf("fill", "fill-both"),
|
|
@@ -81,12 +85,20 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
81
85
|
},
|
|
82
86
|
motion: binding
|
|
83
87
|
},
|
|
88
|
+
"ads-geometry-transition": {
|
|
89
|
+
channels: (value) => {
|
|
90
|
+
const channels = value.split(/\s+/);
|
|
91
|
+
return new Set(channels).size === channels.length && channels.every((channel) => GEOMETRY_CHANNELS.includes(channel));
|
|
92
|
+
},
|
|
93
|
+
motion: binding
|
|
94
|
+
},
|
|
84
95
|
"ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
|
|
85
96
|
"ads-pseudo": { surface: binding },
|
|
86
97
|
"ads-accessibility": { boundary: () => !0, reason: () => !0 },
|
|
87
|
-
"ads-
|
|
98
|
+
"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 },
|
|
88
100
|
"ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
|
|
89
|
-
"ads-outset": { block:
|
|
101
|
+
"ads-outset": { block: outsetSpacing, inline: outsetSpacing },
|
|
90
102
|
"ads-sticky": { edge: oneOf("block-start", "block-end"), clear: oneOf("none", "block-start") },
|
|
91
103
|
"ads-snap": { type: oneOf(...SNAP_TYPES), align: oneOf(...SNAP_ALIGNS) },
|
|
92
104
|
"ads-layer": {
|
|
@@ -107,6 +119,8 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
107
119
|
"ads-align": { rows: wordList },
|
|
108
120
|
"ads-when": {
|
|
109
121
|
surface: binding,
|
|
122
|
+
spacing: binding,
|
|
123
|
+
collapsed: oneOf("true", "false"),
|
|
110
124
|
text: binding,
|
|
111
125
|
repeat: oneOf("continuous"),
|
|
112
126
|
"translate-inline": metric("motion", ["distance"]),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inactiveCondition, paintContrast, reachablePairs, TEXT_MINIMUM } from "./paint-contrast.mjs";
|
|
1
|
+
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast, reachablePairs, TEXT_MINIMUM } from "./paint-contrast.mjs";
|
|
2
2
|
import { tokenValueContexts } from "./design-foundation.mjs";
|
|
3
3
|
import { err, ok } from "./result.mjs";
|
|
4
4
|
export const PLACEHOLDER_MINIMUM = TEXT_MINIMUM;
|
|
@@ -33,3 +33,19 @@ export function checkPlaceholderContrast(foundation, part, foreground, backgroun
|
|
|
33
33
|
}
|
|
34
34
|
return ok(null);
|
|
35
35
|
}
|
|
36
|
+
export function checkProgressContrast(foundation, part, fill, track) {
|
|
37
|
+
const pairs = reachablePairs(fill, track).filter((pair) => !inactiveCondition(pair.foreground.condition) && !inactiveCondition(pair.background.condition));
|
|
38
|
+
for (const context of tokenValueContexts(foundation))
|
|
39
|
+
for (const pair of pairs) {
|
|
40
|
+
const states = [pair.foreground.condition, pair.background.condition], outcome = paintContrast(context, { foreground: pair.foreground.value, background: pair.background.value }, NON_TEXT_MINIMUM);
|
|
41
|
+
switch (outcome.kind) {
|
|
42
|
+
case "sufficient":
|
|
43
|
+
continue;
|
|
44
|
+
case "insufficient":
|
|
45
|
+
return err({ kind: "progress-contrast-insufficient", part, context: context.label, states, ratio: outcome.ratio, minimum: outcome.minimum });
|
|
46
|
+
case "unresolved":
|
|
47
|
+
return err({ kind: "progress-contrast-unresolved", part, context: context.label, states, reason: outcome.unresolved.kind === "paint-missing" ? outcome.unresolved.paint === "background" ? "the part sets no background for its track" : "the fill's surface sets no background" : placeholderReason(outcome.unresolved) });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ok(null);
|
|
51
|
+
}
|
|
@@ -32,8 +32,14 @@ export const PLATFORM_FEATURES = [
|
|
|
32
32
|
prefixed: ["::-webkit-details-marker"],
|
|
33
33
|
degrades: "None expected: the standard list-style-type: none hides a summary's marker; the prefixed pseudo-element hides it where the engine draws it as a separate box."
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
id: "progress-parts",
|
|
37
|
+
css: ["appearance"],
|
|
38
|
+
prefixed: ["-webkit-appearance", "::-webkit-progress-bar", "::-webkit-progress-value", "::-moz-progress-bar"],
|
|
39
|
+
degrades: "A progress bar keeps the engine's own drawing: its track and fill are not the design's paints. Each engine reads only its own pseudo-element; there is no standard one."
|
|
40
|
+
},
|
|
35
41
|
{ id: "dir-pseudo-class", css: [":dir()"], degrades: "Right-to-left overrides do not apply: mirrored offsets and motion keep their left-to-right direction." },
|
|
36
|
-
{ id: "filter-effects", css: ["filter", "blur()", "drop-shadow()", "saturate()"], degrades: "A surface's blur and its shape or group shadow do not apply: the element is drawn sharp and without that shadow." },
|
|
42
|
+
{ id: "filter-effects", css: ["filter", "blur()", "drop-shadow()", "saturate()", "brightness()"], degrades: "A surface's brightness, blur and its shape or group shadow do not apply: the element is drawn as it is, sharp and without that shadow." },
|
|
37
43
|
{ id: "focus-visible", css: [":focus-visible"], degrades: "Required for focus indicators: rules selecting :focus-visible are dropped, so keyboard focus is not drawn." },
|
|
38
44
|
{ id: "has-pseudo-class", css: [":has()"], degrades: "Rules that select by a descendant are dropped: the page keeps scrolling behind an open modal dialog, and a part does not show its native part's state (a checkbox's drawn box stays unchecked)." },
|
|
39
45
|
{ id: "individual-transforms", css: ["translate", "rotate", "scale"], degrades: "Press scale, glyph offsets and their transitions and keyframes do not apply; elements stay at rest." },
|
|
@@ -69,6 +75,8 @@ export const PLATFORM_FEATURES = [
|
|
|
69
75
|
{ id: "prefers-reduced-motion", css: ["@media (prefers-reduced-motion)"], degrades: "Motion is not reduced for users who ask for less: transitions and animations run at full length." },
|
|
70
76
|
{ id: "interaction-media", css: ["@media (hover)", "@media (any-hover)", "@media (pointer)", "@media (any-pointer)"], degrades: "Input-dependent rules do not apply." },
|
|
71
77
|
{ id: "registered-custom-properties", css: ["@property"], degrades: "Registered custom properties behave as unregistered ones: no type checking, no interpolation, and they inherit." },
|
|
78
|
+
{ id: "interpolate-size", css: ["interpolate-size"], degrades: "A collapsed part opens and closes at once instead of growing: its size and what it shows are the same, without the animation." },
|
|
79
|
+
{ id: "scroll-margin", css: ["scroll-margin-block-start"], degrades: "A jump to an anchor puts its target at the very top of the scroll container, under whatever is stuck there." },
|
|
72
80
|
{ id: "scroll-snap", css: ["scroll-snap-type", "scroll-snap-align"], degrades: "Scrolling does not snap: a scrolled track stops wherever the scroll ends." },
|
|
73
81
|
{ id: "subgrid", css: ["grid-template-columns: subgrid", "grid-template-rows: subgrid"], degrades: "A subgrid cell lays out its items on its own tracks: parts no longer align across siblings." },
|
|
74
82
|
{ id: "starting-style", css: ["@starting-style"], degrades: "Entry animations are skipped: the element appears in its open state at once." },
|
|
@@ -143,6 +151,7 @@ export const PLATFORM_FEATURES = [
|
|
|
143
151
|
"overflow-wrap",
|
|
144
152
|
"pointer-events",
|
|
145
153
|
"position",
|
|
154
|
+
"visibility",
|
|
146
155
|
"text-align",
|
|
147
156
|
"text-decoration-line",
|
|
148
157
|
"font-stretch",
|
|
@@ -29,7 +29,7 @@ export function profileApplied(profile, selected, tokenValue) {
|
|
|
29
29
|
const sources = profile.kind === "composite" ? profile.fields.flatMap((field) => Object.hasOwn(SLOT_KINDS, field.field) && field.profile !== null ? [selected(field.profile)].flatMap((item) => item === void 0 ? [] : [item]) : []) : [profile], of = (kind) => sources.find((source) => source.kind === kind), stated = (kind, field) => of(kind)?.fields.find((item) => item.field === field)?.value, declarations = (kind) => {
|
|
30
30
|
const properties = APPLIED_PROPERTIES[kind] ?? {};
|
|
31
31
|
return (of(kind)?.fields ?? []).flatMap((field) => Object.hasOwn(properties, field.field) ? [[properties[field.field] ?? "", field.value]] : []);
|
|
32
|
-
}, css = (value) => /^--[\w-]+$/.test(value) ? `var(${value})` : value, frame = declarations("frame"), surface = declarations("surface"), shadow = stated("surface", "shapeShadow") ?? stated("surface", "groupShadow"), filter = [...stated("surface", "blur") === void 0 ? [] : [`blur(${css(stated("surface", "blur") ?? "")})`], ...shadow === void 0 ? [] : [`drop-shadow(${css(shadow)})`]], backdrop = [...stated("surface", "backdropBlur") === void 0 ? [] : [`blur(${css(stated("surface", "backdropBlur") ?? "")})`], ...stated("surface", "backdropSaturate") === void 0 ? [] : [`saturate(${css(stated("surface", "backdropSaturate") ?? "")})`]];
|
|
32
|
+
}, css = (value) => /^--[\w-]+$/.test(value) ? `var(${value})` : value, frame = declarations("frame"), surface = declarations("surface"), shadow = stated("surface", "shapeShadow") ?? stated("surface", "groupShadow"), filter = [...stated("surface", "brightness") === void 0 ? [] : [`brightness(${css(stated("surface", "brightness") ?? "")})`], ...stated("surface", "blur") === void 0 ? [] : [`blur(${css(stated("surface", "blur") ?? "")})`], ...shadow === void 0 ? [] : [`drop-shadow(${css(shadow)})`]], backdrop = [...stated("surface", "backdropBlur") === void 0 ? [] : [`blur(${css(stated("surface", "backdropBlur") ?? "")})`], ...stated("surface", "backdropSaturate") === void 0 ? [] : [`saturate(${css(stated("surface", "backdropSaturate") ?? "")})`]];
|
|
33
33
|
if (filter.length > 0)
|
|
34
34
|
surface.push(["filter", filter.join(" ")]);
|
|
35
35
|
if (backdrop.length > 0)
|
package/dist/recipe-macro.d.mts
CHANGED
|
@@ -19,6 +19,18 @@ export interface Placement {
|
|
|
19
19
|
readonly at?: Readonly<Record<string, Placement>>;
|
|
20
20
|
}
|
|
21
21
|
export type Layout = "inline" | "stack" | "fluid" | "hybrid" | "fixed" | "flow" | "inherited" | "layered" | "prose";
|
|
22
|
+
/**
|
|
23
|
+
* Where a jump to an element (a fragment link, `scrollIntoView`) lands below the top of its scroll container:
|
|
24
|
+
* right under the region sticky elements clear (the layer profile's `clearBlockStart`), or at the element's
|
|
25
|
+
* own distance (the spacing profile's `anchorGap`), where it lines up with something beside it.
|
|
26
|
+
*/
|
|
27
|
+
export type AnchorClear = {
|
|
28
|
+
readonly slot: "layer";
|
|
29
|
+
readonly field: "clearBlockStart";
|
|
30
|
+
} | {
|
|
31
|
+
readonly slot: "spacing";
|
|
32
|
+
readonly field: "anchorGap";
|
|
33
|
+
};
|
|
22
34
|
/** A profile field of the nearest recipe's spacing slot. */
|
|
23
35
|
type SpacingField = {
|
|
24
36
|
readonly slot: "spacing";
|
|
@@ -37,8 +49,16 @@ export interface ProseElement {
|
|
|
37
49
|
readonly surface: string;
|
|
38
50
|
}>>;
|
|
39
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;
|
|
40
56
|
readonly indent?: SpacingField;
|
|
41
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")[];
|
|
42
62
|
}
|
|
43
63
|
/** The elements a prose root styles. */
|
|
44
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";
|
|
@@ -296,6 +316,35 @@ export interface RecipeSpec {
|
|
|
296
316
|
* its part with a concrete reason: the boundary contrast error becomes a review item. Human-approved
|
|
297
317
|
* only (ads_accept asks the user, or the showcase approval view); never added silently.
|
|
298
318
|
*/
|
|
319
|
+
/**
|
|
320
|
+
* This part is the drawn stand-in of a native control beside it (the box of a checkbox whose `<input>`
|
|
321
|
+
* is visually hidden): it shows the focus profile's indicator while the named sibling part has keyboard focus.
|
|
322
|
+
*/
|
|
323
|
+
readonly focus?: {
|
|
324
|
+
readonly of: string;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Neighbours of an `inline` or `stack` arrangement overlap by the spacing profile's `overlap`, in place of a
|
|
328
|
+
* gap (a pile of faces, a stack of cards). Later neighbours paint over earlier ones.
|
|
329
|
+
*/
|
|
330
|
+
readonly overlap?: {
|
|
331
|
+
readonly slot: "spacing";
|
|
332
|
+
readonly field: "overlap";
|
|
333
|
+
};
|
|
334
|
+
/** In a `when` entry: the spacing profile the element's arrangement reads its gap and overlap from under that state. */
|
|
335
|
+
readonly spacing?: string;
|
|
336
|
+
/** The geometry that animates between the element's states: closed channels, timed by a motion profile. */
|
|
337
|
+
readonly geometryTransition?: {
|
|
338
|
+
readonly channels: readonly ("size" | "inset" | "gap" | "radius" | "border-width" | "overlap")[];
|
|
339
|
+
readonly motion: SlotField | string;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* A part that takes no room on its parent's main axis, is transparent and is hidden from assistive technology
|
|
343
|
+
* and focus; a `when` entry opens it (`collapsed: false`), or closes an open part.
|
|
344
|
+
*/
|
|
345
|
+
readonly collapsed?: boolean;
|
|
346
|
+
/** Where a jump to this element lands (a section or a block with an id). */
|
|
347
|
+
readonly anchorClear?: AnchorClear;
|
|
299
348
|
readonly accessibility?: {
|
|
300
349
|
readonly boundary: "visible-label" | "boundary-on-interaction";
|
|
301
350
|
readonly reason: string;
|
|
@@ -336,7 +385,13 @@ export interface RecipeSpec {
|
|
|
336
385
|
/** A prose root: the space between its blocks, from the spacing slot. */
|
|
337
386
|
readonly rhythm?: SpacingField;
|
|
338
387
|
/** A prose root: the plain elements it styles, wherever they nest in its content. */
|
|
339
|
-
readonly elements?: Readonly<Partial<Record<ProseElementName, ProseElement
|
|
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
|
+
};
|
|
340
395
|
/**
|
|
341
396
|
* The root or part stays at an edge of its scrolling container while the rest scrolls. `clear:
|
|
342
397
|
* "block-start"` holds it below a region at the top by the layer profile's `clearBlockStart`.
|
|
@@ -349,7 +404,8 @@ export interface RecipeSpec {
|
|
|
349
404
|
readonly enter?: Enter;
|
|
350
405
|
/** Pseudo-element treatments of an `<input>` or `<textarea>` part. */
|
|
351
406
|
readonly pseudo?: {
|
|
352
|
-
readonly placeholder?: PseudoTreatment;
|
|
407
|
+
readonly placeholder?: PseudoTreatment; /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
|
|
408
|
+
readonly progressValue?: PseudoTreatment;
|
|
353
409
|
};
|
|
354
410
|
/** A top-layer root (recipe root only). */
|
|
355
411
|
readonly layer?: LayerDeclaration;
|
|
@@ -437,18 +493,21 @@ type PartsDeclared<P, Empty> = [keyof P] extends [never] ? Empty : Intersection<
|
|
|
437
493
|
* parts (the names its setters are typed by): `P` infers each part's measured
|
|
438
494
|
* values, `R` each part's paints.
|
|
439
495
|
*/
|
|
440
|
-
export type RuntimeRecipeSpec<M, Q,
|
|
496
|
+
export type RuntimeRecipeSpec<M, Q, T> = Omit<RecipeSpec, "parts"> & {
|
|
441
497
|
readonly measured?: M;
|
|
442
498
|
readonly paints?: Q;
|
|
443
|
-
readonly parts?:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
499
|
+
readonly parts?: T;
|
|
500
|
+
};
|
|
501
|
+
/** A top-level part as the recipe's setters read it: the part itself, with its runtime declarations. */
|
|
502
|
+
export type RuntimePart = RecipeSpec & {
|
|
503
|
+
readonly measured?: MeasuredDeclarations;
|
|
504
|
+
readonly paints?: PaintDeclarations;
|
|
505
|
+
};
|
|
506
|
+
/** Each part's own `measured` (or `paints`) declarations, by part name. */
|
|
507
|
+
type PartClause<T, Name extends "measured" | "paints", Empty> = {
|
|
508
|
+
readonly [K in keyof T]: T[K] extends {
|
|
509
|
+
readonly [N in Name]: infer D;
|
|
510
|
+
} ? D : Empty;
|
|
452
511
|
};
|
|
453
512
|
/** A bound part's drawing: the selected SVG text (or image URL) of an asset binding. */
|
|
454
513
|
export interface DrawingSource {
|
|
@@ -493,7 +552,7 @@ export interface Recipe<A extends Readonly<Record<string, DrawingSource | SetSou
|
|
|
493
552
|
readonly paints: PaintSetter<Q>;
|
|
494
553
|
}
|
|
495
554
|
export declare function recipe(spec: SetBindingSpec): Recipe<Readonly<Record<string, SetSource>>>;
|
|
496
|
-
export declare function recipe<const M extends MeasuredDeclarations = NoMeasured, const Q extends PaintDeclarations = NoPaints, const
|
|
555
|
+
export declare function recipe<const M extends MeasuredDeclarations = NoMeasured, const Q extends PaintDeclarations = NoPaints, const T extends Readonly<Record<string, RuntimePart>> = Readonly<Record<never, RuntimePart>>>(spec: RuntimeRecipeSpec<M, Q, T>): Recipe<Readonly<Record<string, DrawingSource>>, Declared<M, NoMeasured> & PartsDeclared<PartClause<T, "measured", NoMeasured>, NoMeasured>, Declared<Q, NoPaints> & PartsDeclared<PartClause<T, "paints", NoPaints>, NoPaints>>;
|
|
497
556
|
/** The measured values and runtime paints of every combined recipe. */
|
|
498
557
|
type CombinedMeasured<R extends readonly unknown[]> = Intersection<R[number] extends infer E ? (E extends Recipe<Readonly<Record<string, DrawingSource>>, infer M, unknown> ? M : NoMeasured) : never>;
|
|
499
558
|
type CombinedPaints<R extends readonly unknown[]> = Intersection<R[number] extends infer E ? (E extends Recipe<Readonly<Record<string, DrawingSource>>, unknown, infer Q> ? Q : NoPaints) : never>;
|
package/dist/recipe-model.mjs
CHANGED
|
@@ -80,16 +80,16 @@ function buildProfileTree(spec) {
|
|
|
80
80
|
required(profileDefinition(node));
|
|
81
81
|
return root;
|
|
82
82
|
}
|
|
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"]), NESTED_IN = {
|
|
84
|
-
"ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset"],
|
|
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 = {
|
|
84
|
+
"ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset", "focus", "geometryTransition"],
|
|
85
85
|
"ads-cell": ["at"],
|
|
86
86
|
"ads-at": ["cells", "frame"],
|
|
87
|
-
"ads-when": ["play"],
|
|
87
|
+
"ads-when": ["play", "frame"],
|
|
88
88
|
"ads-pseudo": ["when"],
|
|
89
89
|
"ads-element": ["when"]
|
|
90
90
|
};
|
|
91
91
|
function body(node, spec) {
|
|
92
|
-
const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "elements", "play"] : []] : NESTED_IN[node.name] ?? [];
|
|
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] ?? [];
|
|
93
93
|
for (const field of Object.keys(spec))
|
|
94
94
|
if (NESTED.has(field))
|
|
95
95
|
check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
|
|
@@ -108,10 +108,14 @@ function body(node, spec) {
|
|
|
108
108
|
const transition = spec.paintTransition;
|
|
109
109
|
if (transition !== void 0)
|
|
110
110
|
clause(node, "ads-paint-transition", "", only(transition, ["channels", "motion"]));
|
|
111
|
+
if (spec.geometryTransition !== void 0)
|
|
112
|
+
clause(node, "ads-geometry-transition", "", only(spec.geometryTransition, ["channels", "motion"]));
|
|
111
113
|
if (spec.sticky !== void 0)
|
|
112
114
|
clause(node, "ads-sticky", "", only(spec.sticky, ["edge", "clear"]));
|
|
113
115
|
if (spec.outset !== void 0)
|
|
114
116
|
clause(node, "ads-outset", "", only(spec.outset, ["block", "inline"]));
|
|
117
|
+
if (spec.focus !== void 0)
|
|
118
|
+
clause(node, "ads-focus", "", only(spec.focus, ["of"]));
|
|
115
119
|
if (spec.play !== void 0)
|
|
116
120
|
clause(node, "ads-play", "", only(spec.play, ["sequence", "order"]));
|
|
117
121
|
const entrance = spec.enter;
|
|
@@ -125,7 +129,7 @@ function body(node, spec) {
|
|
|
125
129
|
clause(node, "ads-layer", "", { ...fields, ...Object.fromEntries([...nested("backdrop", backdrop, ["surface", "dismiss"]), ...nested("corner", corner, ["block", "inline"])]) });
|
|
126
130
|
}
|
|
127
131
|
for (const [name, child] of Object.entries(spec.elements === void 0 ? {} : object(spec.elements, "Invalid elements declaration"))) {
|
|
128
|
-
const { when, ...fields } = only(child, ["text", "surface", "frame", "marker", "spaceBefore", "indent", "when"]), element = clause(node, "ads-element", name, fields);
|
|
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);
|
|
129
133
|
for (const [condition, state] of Object.entries(when === void 0 ? {} : object(when, "Invalid when declaration")))
|
|
130
134
|
body(clause(element, "ads-when", condition), object(state, "Invalid when declaration"));
|
|
131
135
|
}
|