@reqvire-org/ads 0.5.13 → 0.5.14
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 +16 -0
- package/dist/analysis/content-model.mjs +156 -0
- package/dist/analysis/owner-source.mjs +5 -1
- package/dist/check.mjs +1 -0
- package/dist/construction-spec.d.mts +2 -2
- package/dist/construction-spec.mjs +1 -1
- package/dist/end-alignment.mjs +5 -0
- package/dist/owner-analysis-check.mjs +1 -0
- package/dist/recipe-macro.d.mts +1 -1
- package/dist/showcase/client.bundle.js +46 -46
- package/dist/showcase/http-client.bundle.js +13 -13
- package/dist/showcase/ui/ui.js +3 -3
- package/dist/skills/ads-designer/references/behaviors.md +31 -0
- package/dist/skills/ads-designer/references/recipes.md +5 -4
- package/dist/skills/ads-import/references/behaviors.md +31 -0
- package/dist/skills/ads-import/references/recipes.md +5 -4
- package/dist/skills/ads-port/references/behaviors.md +31 -0
- package/dist/skills/ads-port/references/recipes.md +5 -4
- package/docs/CHANGELOG.md +71 -0
- package/docs/GUIDE.md +8 -0
- package/docs/LANGUAGE.md +1 -1
- package/docs/RULES.md +4 -2
- package/package.json +1 -1
package/dist/ads-errors.mjs
CHANGED
|
@@ -873,6 +873,13 @@ export const choiceErrors = {
|
|
|
873
873
|
message: (failure) => `The ${failure.scheme} image of part "${failure.part}" is not always loading="lazy"; the default theme is ${failure.defaultScheme}, so this file would be downloaded while hidden.`,
|
|
874
874
|
repair: 'Write `loading="lazy"` on that image as a literal and apply any priority (eager loading, `fetchPriority`) to the default scheme\'s image only.'
|
|
875
875
|
},
|
|
876
|
+
"invalid-nesting": {
|
|
877
|
+
group: "accessibility-semantics",
|
|
878
|
+
rule: "An owner's markup follows HTML's content model: an element that takes phrasing content only (a span, a paragraph, a button, a label, a heading) holds no flow content (a div, a list, a paragraph, a heading); a link or a button holds no other link, button or form control; a list item sits in a list, a table row in a table, a cell in a row. A transparent element (a link) takes its parent's model. Browsers repair such markup differently, and assistive technology reads what they repaired.",
|
|
879
|
+
guides: ["ads://guides/accessibility"],
|
|
880
|
+
message: (failure) => failure.rule === "phrasing" ? `<${failure.element}> is flow content inside <${failure.parent}>, which holds phrasing content only.` : failure.rule === "interactive" ? `<${failure.element}> is interactive content inside <${failure.parent}>: one press would reach two targets.` : `<${failure.element}> sits in <${failure.parent}>; it belongs in ${failure.expected.map((name) => `<${name}>`).join(" or ")}.`,
|
|
881
|
+
repair: "Use an element whose content model fits: a <div> (or a list item) for a box that holds blocks, a <span> inside phrasing content; move the second control out of the link or button beside it; put list items in a list and cells in a row."
|
|
882
|
+
},
|
|
876
883
|
"image-alt-missing": {
|
|
877
884
|
group: "accessibility-semantics",
|
|
878
885
|
rule: "Every `<img>` an owner renders states its text alternative (WCAG 2.2 1.1.1): content media and any other image, as artwork images do; decorative images state it as empty.",
|
|
@@ -2189,6 +2196,15 @@ export const runtimeErrors = {
|
|
|
2189
2196
|
emitters: ["src/owner-analysis-check.mts"],
|
|
2190
2197
|
situations: "owner-analysis errors with code source/intrinsic-alt-missing (an artwork image) or source/image-alt-missing (content media and any other image), at the <img>; a spread on owned markup is rejected before."
|
|
2191
2198
|
},
|
|
2199
|
+
"a11y-nesting": {
|
|
2200
|
+
group: "accessibility-semantics",
|
|
2201
|
+
severity: "error",
|
|
2202
|
+
rule: "An owner's markup follows HTML's content model: no flow content inside phrasing-only elements, no press target inside another, and list items, table rows and cells in their list, table and row.",
|
|
2203
|
+
guides: ["ads://guides/accessibility"],
|
|
2204
|
+
repair: "Use an element whose content model fits (a <div> or a list item for a box of blocks), move the inner control beside the outer one, and put items in their list, rows in their table.",
|
|
2205
|
+
emitters: ["src/owner-analysis-check.mts"],
|
|
2206
|
+
situations: "an owner-analysis error with code source/invalid-nesting, at the element that may not sit there."
|
|
2207
|
+
},
|
|
2192
2208
|
"a11y-incomplete": {
|
|
2193
2209
|
group: "rendered-check",
|
|
2194
2210
|
severity: "info",
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isArrayLiteralExpression,
|
|
3
|
+
isArrowFunction,
|
|
4
|
+
isBinaryExpression,
|
|
5
|
+
isBlock,
|
|
6
|
+
isCallExpression,
|
|
7
|
+
isConditionalExpression,
|
|
8
|
+
isFunctionExpression,
|
|
9
|
+
isIfStatement,
|
|
10
|
+
isJsxElement,
|
|
11
|
+
isJsxExpression,
|
|
12
|
+
isJsxFragment,
|
|
13
|
+
isParenthesizedExpression,
|
|
14
|
+
isPropertyAccessExpression,
|
|
15
|
+
isReturnStatement
|
|
16
|
+
} from "typescript/ast";
|
|
17
|
+
const PHRASING_ONLY = new Set(["span", "p", "button", "label", "h1", "h2", "h3", "h4", "h5", "h6", "em", "strong", "small", "b", "i", "u", "s", "code", "kbd", "samp", "var", "abbr", "cite", "q", "sub", "sup", "time", "mark", "dfn", "data", "output", "legend", "summary", "pre"]), TRANSPARENT = new Set(["a", "ins", "del", "map", "object", "canvas", "noscript", "slot"]), PHRASING = new Set([
|
|
18
|
+
"a",
|
|
19
|
+
"abbr",
|
|
20
|
+
"audio",
|
|
21
|
+
"b",
|
|
22
|
+
"bdi",
|
|
23
|
+
"bdo",
|
|
24
|
+
"br",
|
|
25
|
+
"button",
|
|
26
|
+
"canvas",
|
|
27
|
+
"cite",
|
|
28
|
+
"code",
|
|
29
|
+
"data",
|
|
30
|
+
"datalist",
|
|
31
|
+
"del",
|
|
32
|
+
"dfn",
|
|
33
|
+
"em",
|
|
34
|
+
"embed",
|
|
35
|
+
"i",
|
|
36
|
+
"iframe",
|
|
37
|
+
"img",
|
|
38
|
+
"input",
|
|
39
|
+
"ins",
|
|
40
|
+
"kbd",
|
|
41
|
+
"label",
|
|
42
|
+
"map",
|
|
43
|
+
"mark",
|
|
44
|
+
"meter",
|
|
45
|
+
"noscript",
|
|
46
|
+
"object",
|
|
47
|
+
"output",
|
|
48
|
+
"picture",
|
|
49
|
+
"progress",
|
|
50
|
+
"q",
|
|
51
|
+
"ruby",
|
|
52
|
+
"s",
|
|
53
|
+
"samp",
|
|
54
|
+
"select",
|
|
55
|
+
"slot",
|
|
56
|
+
"small",
|
|
57
|
+
"span",
|
|
58
|
+
"strong",
|
|
59
|
+
"sub",
|
|
60
|
+
"sup",
|
|
61
|
+
"svg",
|
|
62
|
+
"template",
|
|
63
|
+
"textarea",
|
|
64
|
+
"time",
|
|
65
|
+
"u",
|
|
66
|
+
"var",
|
|
67
|
+
"video",
|
|
68
|
+
"wbr",
|
|
69
|
+
"math",
|
|
70
|
+
"area",
|
|
71
|
+
"source",
|
|
72
|
+
"track"
|
|
73
|
+
]), INTERACTIVE = new Set(["a", "button", "input", "select", "textarea", "details", "iframe", "embed"]), PLACED_IN = {
|
|
74
|
+
li: ["ul", "ol", "menu"],
|
|
75
|
+
tr: ["table", "thead", "tbody", "tfoot"],
|
|
76
|
+
td: ["tr"],
|
|
77
|
+
th: ["tr"]
|
|
78
|
+
};
|
|
79
|
+
function insideMarkup(fn) {
|
|
80
|
+
let current = fn.parent;
|
|
81
|
+
while (current !== void 0) {
|
|
82
|
+
if (isJsxExpression(current))
|
|
83
|
+
return !0;
|
|
84
|
+
if (isCallExpression(current) || isPropertyAccessExpression(current) || isParenthesizedExpression(current) || isConditionalExpression(current) || isBinaryExpression(current))
|
|
85
|
+
current = current.parent;
|
|
86
|
+
else
|
|
87
|
+
return !1;
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
}
|
|
91
|
+
export function enclosingOpening(node) {
|
|
92
|
+
let current = node.parent;
|
|
93
|
+
while (current !== void 0) {
|
|
94
|
+
if (isJsxElement(current))
|
|
95
|
+
return current.openingElement;
|
|
96
|
+
if (isArrowFunction(current) || isFunctionExpression(current)) {
|
|
97
|
+
if (!insideMarkup(current))
|
|
98
|
+
return null;
|
|
99
|
+
current = current.parent;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!(isJsxFragment(current) || isJsxExpression(current) || isParenthesizedExpression(current) || isConditionalExpression(current) || isBinaryExpression(current) || isCallExpression(current) || isPropertyAccessExpression(current) || isArrayLiteralExpression(current) || isReturnStatement(current) || isBlock(current) || isIfStatement(current)))
|
|
103
|
+
return null;
|
|
104
|
+
if ((isBlock(current) || isReturnStatement(current)) && !inMarkupCallback(current))
|
|
105
|
+
return null;
|
|
106
|
+
current = current.parent;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function inMarkupCallback(node) {
|
|
111
|
+
let current = node.parent;
|
|
112
|
+
while (current !== void 0) {
|
|
113
|
+
if (isArrowFunction(current) || isFunctionExpression(current))
|
|
114
|
+
return insideMarkup(current);
|
|
115
|
+
if (isBlock(current) || isReturnStatement(current) || isIfStatement(current)) {
|
|
116
|
+
current = current.parent;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
return !1;
|
|
122
|
+
}
|
|
123
|
+
export function nestingProblem(opening, elementOf, tagOf) {
|
|
124
|
+
const tag = tagOf(opening);
|
|
125
|
+
if (!/^[a-z]/.test(tag))
|
|
126
|
+
return null;
|
|
127
|
+
const chain = [];
|
|
128
|
+
let at = enclosingOpening(elementOf(opening));
|
|
129
|
+
while (at !== null) {
|
|
130
|
+
const parent = tagOf(at);
|
|
131
|
+
if (!/^[a-z]/.test(parent))
|
|
132
|
+
break;
|
|
133
|
+
if (parent === "svg" || parent === "math" || parent === "foreignObject")
|
|
134
|
+
return null;
|
|
135
|
+
chain.push(parent);
|
|
136
|
+
at = enclosingOpening(elementOf(at));
|
|
137
|
+
}
|
|
138
|
+
const [direct] = chain;
|
|
139
|
+
if (direct === void 0)
|
|
140
|
+
return null;
|
|
141
|
+
const placedIn = PLACED_IN[tag];
|
|
142
|
+
if (placedIn !== void 0 && !placedIn.includes(direct))
|
|
143
|
+
return { rule: "placement", element: tag, parent: direct, expected: placedIn };
|
|
144
|
+
if (INTERACTIVE.has(tag)) {
|
|
145
|
+
const host = chain.find((parent) => parent === "a" || parent === "button");
|
|
146
|
+
if (host !== void 0)
|
|
147
|
+
return { rule: "interactive", element: tag, parent: host };
|
|
148
|
+
}
|
|
149
|
+
const model = chain.find((parent) => !TRANSPARENT.has(parent));
|
|
150
|
+
if (model !== void 0 && PHRASING_ONLY.has(model) && !PHRASING.has(tag)) {
|
|
151
|
+
if ((model === "summary" || model === "legend") && /^h[1-6]$/.test(tag))
|
|
152
|
+
return null;
|
|
153
|
+
return { rule: "phrasing", element: tag, parent: model };
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
@@ -115,6 +115,7 @@ import { appIconEmission, withAppIconsModule } from "../emit/app-icon-emission.m
|
|
|
115
115
|
import { withOutputPackage } from "../emit/output-package.mjs";
|
|
116
116
|
import { analyzedOwners, outcomeCounts, rowsRead } from "./owner-outcomes.mjs";
|
|
117
117
|
import { capturedTreeFiles, findNode, walk } from "./helpers.mjs";
|
|
118
|
+
import { nestingProblem } from "./content-model.mjs";
|
|
118
119
|
import { factorClasses } from "./factored-classes.mjs";
|
|
119
120
|
import { programGlobals } from "./owner-analysis-key.mjs";
|
|
120
121
|
import { memoizedConstruction } from "./construction-memo.mjs";
|
|
@@ -1526,6 +1527,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1526
1527
|
const tag = values.tag(opening);
|
|
1527
1528
|
if (tag === "img" && attr(opening, "alt") === void 0)
|
|
1528
1529
|
return fail(opening, { kind: "image-alt-missing" });
|
|
1530
|
+
const nesting = nestingProblem(opening, elementOf, values.tag);
|
|
1531
|
+
if (nesting !== null)
|
|
1532
|
+
return fail(opening, { kind: "invalid-nesting", ...nesting, expected: nesting.rule === "placement" ? nesting.expected : [] });
|
|
1529
1533
|
if (clickWithoutKeyboard(opening, tag))
|
|
1530
1534
|
review(opening, { kind: "click-without-keyboard", element: tag });
|
|
1531
1535
|
if (!sections && !artworkThemed.has(opening))
|
|
@@ -1800,7 +1804,7 @@ export async function ownerModuleSource(name, owner, classOf, fail) {
|
|
|
1800
1804
|
}
|
|
1801
1805
|
const runtimeAxes = new Set(selections.flatMap((selection) => selection.result.axes.map((axis) => axis.declaration))), bindings = new Map;
|
|
1802
1806
|
for (const declaration of values.touched)
|
|
1803
|
-
if (declaration.parent.parent
|
|
1807
|
+
if (isVariableStatement(declaration.parent.parent) && isIdentifier(declaration.name))
|
|
1804
1808
|
bindings.set(await values.symbol(declaration.name), declaration);
|
|
1805
1809
|
const references = new Map([...bindings.values()].map((declaration) => [declaration, []]));
|
|
1806
1810
|
for (const identifier of nodesOfKind(source, SyntaxKind.Identifier, isIdentifier)) {
|
package/dist/check.mjs
CHANGED
|
@@ -1211,7 +1211,7 @@ export interface OutsetSpec {
|
|
|
1211
1211
|
/** Normalization as CSS property → value pairs, in authored order. */
|
|
1212
1212
|
export type Normalized = readonly (readonly [property: string, value: string])[];
|
|
1213
1213
|
/** The pointer cursors an element may show (`normalize.cursor`): a closed set, no image cursors. */
|
|
1214
|
-
export declare const CURSORS: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"];
|
|
1214
|
+
export declare const CURSORS: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"];
|
|
1215
1215
|
/** The touch gestures an element leaves to the browser (`normalize.touchAction`): none, or panning on one axis. */
|
|
1216
1216
|
export declare const TOUCH_ACTIONS: readonly ["none", "pan-x", "pan-y"];
|
|
1217
1217
|
/** How the user may resize a multi-line text field (`normalize.resize`, on a `<textarea>` part): by its block edge only, or not at all. */
|
|
@@ -1234,7 +1234,7 @@ export declare const NORMALIZE_FIELDS: {
|
|
|
1234
1234
|
};
|
|
1235
1235
|
readonly cursor: {
|
|
1236
1236
|
readonly property: "cursor";
|
|
1237
|
-
readonly values: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"];
|
|
1237
|
+
readonly values: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"];
|
|
1238
1238
|
};
|
|
1239
1239
|
readonly textDecoration: {
|
|
1240
1240
|
readonly property: "text-decoration-line";
|
|
@@ -842,7 +842,7 @@ function frameCondition(value, base, read) {
|
|
|
842
842
|
path: `${path}.frame`
|
|
843
843
|
};
|
|
844
844
|
}
|
|
845
|
-
export const CURSORS = ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"], TOUCH_ACTIONS = ["none", "pan-x", "pan-y"], RESIZES = ["vertical", "none"], USER_SELECTS = ["none"], NORMALIZE_FIELDS = {
|
|
845
|
+
export const CURSORS = ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"], TOUCH_ACTIONS = ["none", "pan-x", "pan-y"], RESIZES = ["vertical", "none"], USER_SELECTS = ["none"], NORMALIZE_FIELDS = {
|
|
846
846
|
margin: { property: "margin", values: ["0"] },
|
|
847
847
|
borderStyle: { property: "border-style", values: ["solid", "none"] },
|
|
848
848
|
cursor: { property: "cursor", values: CURSORS },
|
package/dist/end-alignment.mjs
CHANGED
|
@@ -76,6 +76,9 @@ function paintsFlushBox(foundation, spec) {
|
|
|
76
76
|
const end = frameInlineInsets(Object.fromEntries(fields)).end;
|
|
77
77
|
return end === void 0 || /^0(px)?$/.test(end.trim());
|
|
78
78
|
}
|
|
79
|
+
function holdsText(part) {
|
|
80
|
+
return part.content.kind === "text" || part.parts.some(holdsText);
|
|
81
|
+
}
|
|
79
82
|
export function stackPartsOf(foundation, spec) {
|
|
80
83
|
if (spec.kind !== "region" || spec.arrangement.layout !== "stack")
|
|
81
84
|
return [];
|
|
@@ -91,6 +94,8 @@ export function stackPartsOf(foundation, spec) {
|
|
|
91
94
|
const surface = part.surface === null ? null : selectedProfile(foundation, part.surface), painted = surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && (surface.value.fields.has("background") || surface.value.fields.has("background-image")) || borderedAtEnd(frame.value.fields, null) || part.overflow.kind === "clip";
|
|
92
95
|
if (painted && banded)
|
|
93
96
|
return [];
|
|
97
|
+
if (painted && !holdsText(part))
|
|
98
|
+
return [];
|
|
94
99
|
if (painted)
|
|
95
100
|
return [{ part: part.name, kind: "box", inset: [] }];
|
|
96
101
|
if (endsRagged(part.arrangement, part.parts))
|
|
@@ -43,6 +43,7 @@ export const OWNER_REVIEW_RULE = "owner-analysis-review";
|
|
|
43
43
|
const ACCESSIBILITY_RULES = new Map([
|
|
44
44
|
["source/intrinsic-alt-missing", "a11y-image-alt"],
|
|
45
45
|
["source/image-alt-missing", "a11y-image-alt"],
|
|
46
|
+
["source/invalid-nesting", "a11y-nesting"],
|
|
46
47
|
["source/control-name-missing", "a11y-icon-label"],
|
|
47
48
|
["construction/target-size-below-minimum", "a11y-target-size"],
|
|
48
49
|
["construction/target-area-overlap", "a11y-target-size"],
|
package/dist/recipe-macro.d.mts
CHANGED
|
@@ -68,7 +68,7 @@ export type Frame = "control" | "container" | {
|
|
|
68
68
|
/** A side of a frame by its logical name. */
|
|
69
69
|
export type SafeAreaSide = "block-start" | "block-end" | "inline-start" | "inline-end";
|
|
70
70
|
/** The pointer cursors an element may show: a closed set, no image cursors. */
|
|
71
|
-
export type Cursor = "pointer" | "default" | "grab" | "grabbing" | "col-resize" | "row-resize" | "move" | "text" | "not-allowed";
|
|
71
|
+
export type Cursor = "pointer" | "default" | "grab" | "grabbing" | "col-resize" | "row-resize" | "move" | "text" | "not-allowed" | "zoom-in" | "zoom-out";
|
|
72
72
|
/** The touch gestures an element leaves to the browser: none (the owner handles them all), or panning on one axis. */
|
|
73
73
|
export type TouchAction = "none" | "pan-x" | "pan-y";
|
|
74
74
|
interface NativeNormalization {
|