@histoire/plugin-a11y 0.0.0-stage → 1.0.0-beta.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +433 -0
  3. package/README.md +97 -2
  4. package/dist/build/scan.d.ts +11 -0
  5. package/dist/build/scan.js +85 -0
  6. package/dist/chunks/_histoire-a11y-axe-BL07tEuN.js +53627 -0
  7. package/dist/chunks/messages-KjPUArEa.js +12 -0
  8. package/dist/chunks/results-C0vYpcmy.js +41 -0
  9. package/dist/chunks/run-lct8FHuk.js +134 -0
  10. package/dist/client.d.ts +2 -0
  11. package/dist/client.js +1368 -0
  12. package/dist/frame/highlight.d.ts +6 -0
  13. package/dist/frame.d.ts +2 -0
  14. package/dist/frame.js +211 -0
  15. package/dist/index.d.ts +5 -0
  16. package/dist/index.js +44 -0
  17. package/dist/messages.d.ts +43 -0
  18. package/dist/messages.js +11 -0
  19. package/dist/options.d.ts +41 -0
  20. package/dist/options.js +22 -0
  21. package/dist/results.d.ts +6 -0
  22. package/dist/results.js +6 -0
  23. package/dist/scanner/policy.d.ts +11 -0
  24. package/dist/scanner/run.d.ts +24 -0
  25. package/dist/test.d.ts +13 -0
  26. package/dist/test.js +25 -0
  27. package/dist/workbench/AuditPanel.vue.d.ts +11 -0
  28. package/dist/workbench/FindingRow.vue.d.ts +15 -0
  29. package/dist/workbench/ProjectPanel.vue.d.ts +16 -0
  30. package/dist/workbench/VariantGroup.vue.d.ts +17 -0
  31. package/dist/workbench/filters.d.ts +26 -0
  32. package/dist/workbench/fix-summary.d.ts +33 -0
  33. package/dist/workbench/locate.d.ts +26 -0
  34. package/dist/workbench/model.d.ts +42 -0
  35. package/dist/workbench/project-model.d.ts +66 -0
  36. package/dist/workbench/project-source.d.ts +51 -0
  37. package/dist/workbench/sources.d.ts +40 -0
  38. package/dist/workbench/sources.js +62 -0
  39. package/package.json +170 -3
package/dist/client.js ADDED
@@ -0,0 +1,1368 @@
1
+ import { i as IMPACTS, n as A11Y_TEST_DATA_KEY, t as A11Y_BUILD_REPORT_FILE } from "./chunks/results-C0vYpcmy.js";
2
+ import { r as normalizeOptions, t as nodeKey } from "./chunks/run-lct8FHuk.js";
3
+ import { n as send } from "./chunks/messages-KjPUArEa.js";
4
+ import { defineWorkbenchPlugin, installPluginStyles } from "@histoire/plugin-kit";
5
+ import { WorkbenchEmptyState, WorkbenchErrorState, WorkbenchLoadingState, WorkbenchPaneHeader, WorkbenchPaneList, WorkbenchPaneToolbar, WorkbenchPanelAction, defineWorkbenchComponent } from "@histoire/plugin-kit/vue";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, isRef, nextTick, normalizeStyle, onScopeDispose, openBlock, reactive, ref, renderList, shallowRef, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
7
+ import { HstButton, HstPulsatingDisc, HstSelect, HstSwitch } from "@histoire/controls/vue";
8
+ import { getHistoireTargetKey } from "@histoire/protocol";
9
+ import { HISTOIRE_VARIANT_ERROR_TEST_NAME } from "@histoire/shared";
10
+ // src/workbench/filters.ts
11
+ /** Options of the outcome select. */
12
+ var OUTCOME_OPTIONS = {
13
+ violations: "Violations",
14
+ incomplete: "Needs review"
15
+ };
16
+ /** Options of the severity select. */
17
+ var SEVERITY_OPTIONS = {
18
+ all: "All severities",
19
+ critical: "Critical",
20
+ serious: "Serious",
21
+ moderate: "Moderate",
22
+ minor: "Minor",
23
+ unknown: "Unknown"
24
+ };
25
+ /**
26
+ * Outcome and severity filters persisted in plugin preferences, shared by the inspector tab and
27
+ * the project pane. Invalid stored values read as defaults. Must run in a component scope.
28
+ * @param preferences Plugin preferences.
29
+ */
30
+ function useFindingFilters(preferences) {
31
+ const revision = ref(0);
32
+ const stops = ["outcome", "severity"].map((key) => preferences.subscribe(key, () => revision.value++));
33
+ onScopeDispose(() => stops.forEach((stop) => stop()));
34
+ return {
35
+ outcome: computed({
36
+ get: () => {
37
+ revision.value;
38
+ return preferences.get("outcome", "violations") === "incomplete" ? "incomplete" : "violations";
39
+ },
40
+ set: (value) => preferences.set("outcome", value)
41
+ }),
42
+ severity: computed({
43
+ get: () => {
44
+ revision.value;
45
+ const value = preferences.get("severity", "all");
46
+ return value === "all" || value === "unknown" || Object.hasOwn(IMPACTS, value) ? value : "all";
47
+ },
48
+ set: (value) => preferences.set("severity", value)
49
+ })
50
+ };
51
+ }
52
+ // src/workbench/fix-summary.ts
53
+ var HEADING = /^Fix (all|any) of the following:$/i;
54
+ /**
55
+ * Splits an axe `failureSummary` into its "Fix all" / "Fix any" requirement lists.
56
+ * Lines before any heading form an `all` list.
57
+ * @param summary Raw summary; `undefined` reads as no requirement.
58
+ */
59
+ function parseFailureSummary(summary) {
60
+ const sections = [];
61
+ let current;
62
+ for (const raw of summary?.split("\n") ?? []) {
63
+ const line = raw.trim();
64
+ if (!line) continue;
65
+ const heading = HEADING.exec(line);
66
+ if (heading) {
67
+ sections.push(current = {
68
+ kind: heading[1].toLowerCase(),
69
+ items: []
70
+ });
71
+ continue;
72
+ }
73
+ if (!current) sections.push(current = {
74
+ kind: "all",
75
+ items: []
76
+ });
77
+ current.items.push(line);
78
+ }
79
+ return sections.filter((section) => section.items.length);
80
+ }
81
+ /**
82
+ * Groups elements with an identical failure summary, so a shared fix shows once.
83
+ * Groups keep the order in which their first element appears.
84
+ * @param nodes Affected elements of one finding.
85
+ */
86
+ function groupNodesByFix(nodes) {
87
+ const groups = /* @__PURE__ */ new Map();
88
+ for (const node of nodes) {
89
+ const key = node.failureSummary?.trim() ?? "";
90
+ let group = groups.get(key);
91
+ if (!group) groups.set(key, group = {
92
+ sections: parseFailureSummary(node.failureSummary),
93
+ nodes: []
94
+ });
95
+ group.nodes.push(node);
96
+ }
97
+ return [...groups.values()];
98
+ }
99
+ // src/workbench/FindingRow.vue?vue&type=script&setup=true&lang.ts
100
+ var _hoisted_1$3 = { class: "histoire-a11y-rule" };
101
+ var _hoisted_2$3 = { class: "histoire-a11y-rule-meta" };
102
+ var _hoisted_3$3 = ["data-impact"];
103
+ var _hoisted_4$3 = { class: "histoire-a11y-rule-count" };
104
+ var _hoisted_5$3 = { class: "histoire-a11y-details" };
105
+ var _hoisted_6$3 = { class: "histoire-a11y-elements" };
106
+ var _hoisted_7$3 = { class: "histoire-a11y-element-number" };
107
+ var _hoisted_8$3 = ["title"];
108
+ var _hoisted_9$3 = [
109
+ "aria-label",
110
+ "title",
111
+ "onClick"
112
+ ];
113
+ var _hoisted_10$3 = {
114
+ key: 0,
115
+ viewBox: "0 0 16 16",
116
+ "aria-hidden": "true"
117
+ };
118
+ var _hoisted_11$2 = {
119
+ key: 1,
120
+ viewBox: "0 0 16 16",
121
+ "aria-hidden": "true"
122
+ };
123
+ var _hoisted_12$2 = ["onClick"];
124
+ var _hoisted_13$1 = { class: "histoire-a11y-fix-head" };
125
+ var _hoisted_14$1 = { class: "histoire-a11y-fix-label" };
126
+ var _hoisted_15 = ["href"];
127
+ var _hoisted_16 = { class: "histoire-a11y-fix-items" };
128
+ var _hoisted_17 = ["onClick"];
129
+ var _hoisted_18 = ["href"];
130
+ var VISIBLE_ITEMS = 3;
131
+ // src/workbench/FindingRow.vue
132
+ var FindingRow_default = /* @__PURE__ */ defineComponent({
133
+ __name: "FindingRow",
134
+ props: {
135
+ rule: {},
136
+ outcome: {}
137
+ },
138
+ emits: ["highlight"],
139
+ setup(__props, { emit: __emit }) {
140
+ const props = __props;
141
+ const emit = __emit;
142
+ /** Fix items shown before "N more". */
143
+ const groups = computed(() => {
144
+ let number = 0;
145
+ return groupNodesByFix(props.rule.nodes).map((group) => ({
146
+ ...group,
147
+ nodes: group.nodes.map((node) => ({
148
+ node,
149
+ number: ++number
150
+ }))
151
+ }));
152
+ });
153
+ /** Fix lists expanded past {@link VISIBLE_ITEMS}, by `group:section` index. */
154
+ const expanded = reactive(/* @__PURE__ */ new Set());
155
+ /** Number of the element whose selector was just copied. */
156
+ const copied = ref();
157
+ let copiedTimer;
158
+ onScopeDispose(() => clearTimeout(copiedTimer));
159
+ /**
160
+ * Selector chain as displayed and copied (frames first).
161
+ * @param node Affected element.
162
+ */
163
+ function selector(node) {
164
+ return node.selectors.join(" / ");
165
+ }
166
+ /**
167
+ * Copy an element selector, confirming on the button for a moment.
168
+ * @param node Affected element.
169
+ * @param number Element number in the row.
170
+ */
171
+ async function copy(node, number) {
172
+ try {
173
+ await navigator.clipboard.writeText(selector(node));
174
+ copied.value = number;
175
+ clearTimeout(copiedTimer);
176
+ copiedTimer = setTimeout(() => copied.value = void 0, 1500);
177
+ } catch {}
178
+ }
179
+ /**
180
+ * Toggle a clamped fix list.
181
+ * @param key `group:section` index.
182
+ */
183
+ function toggle(key) {
184
+ if (!expanded.delete(key)) expanded.add(key);
185
+ }
186
+ return (_ctx, _cache) => {
187
+ return openBlock(), createElementBlock("details", _hoisted_1$3, [createElementVNode("summary", null, [createElementVNode("span", _hoisted_2$3, [createElementVNode("span", {
188
+ class: "histoire-a11y-impact",
189
+ "data-impact": __props.rule.impact
190
+ }, toDisplayString(__props.rule.impact ?? "unknown"), 9, _hoisted_3$3), createElementVNode("span", _hoisted_4$3, toDisplayString(__props.rule.nodes.length) + " " + toDisplayString(__props.rule.nodes.length === 1 ? "element" : "elements"), 1)]), createElementVNode("strong", null, toDisplayString(__props.rule.help), 1)]), createElementVNode("div", _hoisted_5$3, [(openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (group, groupIndex) => {
191
+ return openBlock(), createElementBlock("div", {
192
+ key: groupIndex,
193
+ class: "histoire-a11y-fix-group"
194
+ }, [createElementVNode("ol", _hoisted_6$3, [(openBlock(true), createElementBlock(Fragment, null, renderList(group.nodes, ({ node, number }) => {
195
+ return openBlock(), createElementBlock("li", {
196
+ key: number,
197
+ class: "histoire-a11y-element"
198
+ }, [
199
+ createElementVNode("span", _hoisted_7$3, toDisplayString(number), 1),
200
+ createElementVNode("code", {
201
+ class: "histoire-a11y-selector",
202
+ title: selector(node)
203
+ }, toDisplayString(selector(node)), 9, _hoisted_8$3),
204
+ createElementVNode("button", {
205
+ type: "button",
206
+ class: "histoire-a11y-icon-button histoire-a11y-copy",
207
+ "aria-label": copied.value === number ? "Copied" : "Copy selector",
208
+ title: copied.value === number ? "Copied" : "Copy selector",
209
+ onClick: ($event) => copy(node, number)
210
+ }, [copied.value === number ? (openBlock(), createElementBlock("svg", _hoisted_10$3, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M3.5 8.5l3 3 6-7" }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_11$2, [..._cache[1] || (_cache[1] = [createElementVNode("rect", {
211
+ x: "5.5",
212
+ y: "5.5",
213
+ width: "8",
214
+ height: "8",
215
+ rx: "1.5"
216
+ }, null, -1), createElementVNode("path", { d: "M10.5 3.5v-.5a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h.5" }, null, -1)])]))], 8, _hoisted_9$3),
217
+ createElementVNode("button", {
218
+ type: "button",
219
+ class: "histoire-a11y-icon-button",
220
+ "aria-label": "Highlight in canvas",
221
+ title: "Highlight in canvas",
222
+ onClick: ($event) => emit("highlight", {
223
+ outcome: __props.outcome,
224
+ rule: __props.rule.id,
225
+ selectors: node.selectors,
226
+ index: __props.rule.nodes.indexOf(node),
227
+ count: __props.rule.nodes.length
228
+ })
229
+ }, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
230
+ viewBox: "0 0 16 16",
231
+ "aria-hidden": "true"
232
+ }, [createElementVNode("circle", {
233
+ cx: "8",
234
+ cy: "8",
235
+ r: "4.75"
236
+ }), createElementVNode("path", { d: "M8 1v3M8 12v3M1 8h3M12 8h3" })], -1)])], 8, _hoisted_12$2)
237
+ ]);
238
+ }), 128))]), (openBlock(true), createElementBlock(Fragment, null, renderList(group.sections, (section, sectionIndex) => {
239
+ return openBlock(), createElementBlock("div", {
240
+ key: sectionIndex,
241
+ class: "histoire-a11y-fix"
242
+ }, [
243
+ createElementVNode("div", _hoisted_13$1, [createElementVNode("span", _hoisted_14$1, toDisplayString(section.kind === "all" ? "Fix all" : "Fix any"), 1), groupIndex === 0 && sectionIndex === 0 ? (openBlock(), createElementBlock("a", {
244
+ key: 0,
245
+ class: "histoire-a11y-rule-id",
246
+ href: __props.rule.helpUrl,
247
+ target: "_blank",
248
+ rel: "noopener noreferrer",
249
+ title: "Rule guidance"
250
+ }, [createTextVNode(toDisplayString(__props.rule.id) + " ", 1), _cache[3] || (_cache[3] = createElementVNode("svg", {
251
+ viewBox: "0 0 16 16",
252
+ "aria-hidden": "true"
253
+ }, [createElementVNode("path", { d: "M9.5 2.5h4v4M13.5 2.5 7.5 8.5M11.5 9.5v4h-9v-9h4" })], -1))], 8, _hoisted_15)) : createCommentVNode("", true)]),
254
+ createElementVNode("ul", _hoisted_16, [(openBlock(true), createElementBlock(Fragment, null, renderList(expanded.has(`${groupIndex}:${sectionIndex}`) ? section.items : section.items.slice(0, VISIBLE_ITEMS), (item, itemIndex) => {
255
+ return openBlock(), createElementBlock("li", { key: itemIndex }, toDisplayString(item), 1);
256
+ }), 128))]),
257
+ section.items.length > VISIBLE_ITEMS ? (openBlock(), createElementBlock("button", {
258
+ key: 0,
259
+ type: "button",
260
+ class: "histoire-a11y-more",
261
+ onClick: ($event) => toggle(`${groupIndex}:${sectionIndex}`)
262
+ }, toDisplayString(expanded.has(`${groupIndex}:${sectionIndex}`) ? "Show less" : `${section.items.length - VISIBLE_ITEMS} more`), 9, _hoisted_17)) : createCommentVNode("", true)
263
+ ]);
264
+ }), 128))]);
265
+ }), 128)), !groups.value[0]?.sections.length ? (openBlock(), createElementBlock("a", {
266
+ key: 0,
267
+ class: "histoire-a11y-rule-id",
268
+ href: __props.rule.helpUrl,
269
+ target: "_blank",
270
+ rel: "noopener noreferrer",
271
+ title: "Rule guidance"
272
+ }, [createTextVNode(toDisplayString(__props.rule.id) + " ", 1), _cache[4] || (_cache[4] = createElementVNode("svg", {
273
+ viewBox: "0 0 16 16",
274
+ "aria-hidden": "true"
275
+ }, [createElementVNode("path", { d: "M9.5 2.5h4v4M13.5 2.5 7.5 8.5M11.5 9.5v4h-9v-9h4" })], -1))], 8, _hoisted_18)) : createCommentVNode("", true)])]);
276
+ };
277
+ }
278
+ });
279
+ // src/workbench/project-model.ts
280
+ /** Weight of a rule impact; unknown impact sorts after known ones. */
281
+ function weight(rule) {
282
+ return IMPACTS[rule.impact] ?? 0;
283
+ }
284
+ /**
285
+ * Most severe known impact among rules, for coloring counts; `undefined` when none is known.
286
+ * @param rules Rules to scan.
287
+ */
288
+ function worstImpact(rules) {
289
+ let worst;
290
+ for (const rule of rules) if (weight(rule) > (worst ? weight(worst) : 0)) worst = rule;
291
+ return worst?.impact;
292
+ }
293
+ /**
294
+ * Canvas frame header badge of a report: violation count, colored by the worst impact.
295
+ * `null` without violations, so clean variants stay quiet.
296
+ * @param report Report of the variant, if any.
297
+ */
298
+ function violationBadge(report) {
299
+ if (!report?.violationsCount) return null;
300
+ const impact = worstImpact(report.violations);
301
+ const tone = impact === "critical" || impact === "serious" ? "danger" : impact === "moderate" ? "warning" : "neutral";
302
+ return {
303
+ text: report.violationsCount,
304
+ tone,
305
+ label: `${report.violationsCount} accessibility ${report.violationsCount === 1 ? "violation" : "violations"}`
306
+ };
307
+ }
308
+ /**
309
+ * Builds pane rows: variants with matching findings and variants whose check failed. Failed
310
+ * checks come first, then variants by worst matching impact, then by title.
311
+ * @param results Results of the active source.
312
+ * @param titles Resolves display titles; `undefined` falls back to ids.
313
+ * @param filter Outcome and severity filter.
314
+ */
315
+ function projectGroups(results, titles, filter) {
316
+ const totals = {
317
+ checked: 0,
318
+ affected: 0,
319
+ violations: 0,
320
+ failed: 0
321
+ };
322
+ const groups = [];
323
+ for (const result of results) {
324
+ if (result.report) {
325
+ totals.checked++;
326
+ totals.violations += result.report.violationsCount;
327
+ if (result.report.violationsCount) totals.affected++;
328
+ } else if (result.error) totals.failed++;
329
+ const findings = [...result.report?.[filter.outcome] ?? []].filter((rule) => filter.severity === "all" || (rule.impact ?? "unknown") === filter.severity).sort((a, b) => weight(b) - weight(a) || a.id.localeCompare(b.id));
330
+ if (!findings.length && !(result.error && !result.report)) continue;
331
+ const title = titles(result.target);
332
+ groups.push({
333
+ ...result,
334
+ key: getHistoireTargetKey(result.target),
335
+ storyTitle: title?.story ?? result.target.storyId,
336
+ variantTitle: title?.variant ?? result.target.variantId,
337
+ findings
338
+ });
339
+ }
340
+ const rank = (group) => group.report ? group.findings[0] ? weight(group.findings[0]) : 0 : Number.POSITIVE_INFINITY;
341
+ groups.sort((a, b) => rank(b) - rank(a) || a.storyTitle.localeCompare(b.storyTitle) || a.variantTitle.localeCompare(b.variantTitle));
342
+ return {
343
+ groups,
344
+ totals
345
+ };
346
+ }
347
+ // src/workbench/AuditPanel.vue?vue&type=script&setup=true&lang.ts
348
+ var _hoisted_1$2 = {
349
+ class: "histoire-a11y histoire-a11y-tab",
350
+ "aria-label": "Accessibility audit"
351
+ };
352
+ var _hoisted_2$2 = { class: "histoire-a11y-tab-header" };
353
+ var _hoisted_3$2 = {
354
+ key: 0,
355
+ class: "histoire-a11y-counters",
356
+ role: "status",
357
+ "aria-live": "polite"
358
+ };
359
+ var _hoisted_4$2 = ["data-impact", "title"];
360
+ var _hoisted_5$2 = { class: "histoire-a11y-sr" };
361
+ var _hoisted_6$2 = ["title"];
362
+ var _hoisted_7$2 = ["title"];
363
+ var _hoisted_8$2 = ["title"];
364
+ var _hoisted_9$2 = {
365
+ key: 1,
366
+ class: "histoire-a11y-counter",
367
+ title: "Results may be outdated"
368
+ };
369
+ var _hoisted_10$2 = { class: "histoire-a11y-auto" };
370
+ var _hoisted_11$1 = { class: "histoire-a11y-filters" };
371
+ var _hoisted_12$1 = {
372
+ key: 2,
373
+ class: "histoire-a11y-tab-list"
374
+ };
375
+ var _hoisted_13 = {
376
+ key: 3,
377
+ class: "histoire-a11y-note",
378
+ role: "status"
379
+ };
380
+ var _hoisted_14 = {
381
+ key: 4,
382
+ class: "histoire-a11y-note",
383
+ role: "status"
384
+ };
385
+ // src/workbench/AuditPanel.vue
386
+ var AuditPanel_default = /* @__PURE__ */ defineComponent({
387
+ __name: "AuditPanel",
388
+ props: {
389
+ context: {},
390
+ model: {}
391
+ },
392
+ setup(__props) {
393
+ const props = __props;
394
+ const state = shallowRef();
395
+ const revision = ref(0);
396
+ let stop;
397
+ watch(() => props.context.frame.key, (key) => {
398
+ stop?.();
399
+ stop = props.model.watch(key, () => {
400
+ state.value = props.model.get(key);
401
+ revision.value++;
402
+ });
403
+ }, { immediate: true });
404
+ onScopeDispose(() => stop?.());
405
+ const autoRun = computed({
406
+ get: () => {
407
+ revision.value;
408
+ return props.model.autoRun();
409
+ },
410
+ set: (value) => props.model.preferences.set("autoRun", value)
411
+ });
412
+ const { outcome, severity } = useFindingFilters(props.model.preferences);
413
+ const findings = computed(() => [...state.value?.report?.[outcome.value] ?? []].filter((rule) => severity.value === "all" || (rule.impact ?? "unknown") === severity.value).sort((a, b) => (IMPACTS[b.impact] ?? 0) - (IMPACTS[a.impact] ?? 0) || a.id.localeCompare(b.id)));
414
+ /**
415
+ * Highlight an element of this frame's live report through its private handle.
416
+ * @param finding Element to highlight.
417
+ */
418
+ function highlight(finding) {
419
+ props.model.highlight(props.context.frame.key, nodeKey(finding.outcome, finding.rule, finding.selectors));
420
+ }
421
+ /** Start manual scan without changing live-audit preference. */
422
+ function run() {
423
+ props.model.run(props.context.frame.key);
424
+ }
425
+ return (_ctx, _cache) => {
426
+ return openBlock(), createElementBlock("section", _hoisted_1$2, [createElementVNode("div", _hoisted_2$2, [
427
+ state.value?.report ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
428
+ state.value.running ? (openBlock(), createBlock(unref(HstPulsatingDisc), {
429
+ key: 0,
430
+ size: 12
431
+ })) : createCommentVNode("", true),
432
+ createElementVNode("span", {
433
+ class: "histoire-a11y-counter histoire-a11y-severity-text",
434
+ "data-impact": unref(worstImpact)(state.value.report.violations),
435
+ title: `${state.value.report.violationsCount} ${state.value.report.violationsCount === 1 ? "violation" : "violations"}`
436
+ }, [
437
+ createTextVNode(toDisplayString(state.value.report.violationsCount), 1),
438
+ _cache[3] || (_cache[3] = createElementVNode("svg", {
439
+ viewBox: "0 0 16 16",
440
+ "aria-hidden": "true"
441
+ }, [createElementVNode("circle", {
442
+ cx: "8",
443
+ cy: "8",
444
+ r: "6"
445
+ }), createElementVNode("path", { d: "M8 5v3.5M8 11h.01" })], -1)),
446
+ createElementVNode("span", _hoisted_5$2, toDisplayString(state.value.report.violationsCount === 1 ? "violation" : "violations"), 1)
447
+ ], 8, _hoisted_4$2),
448
+ createElementVNode("span", {
449
+ class: "histoire-a11y-counter",
450
+ title: `${state.value.report.incompleteCount} need review`
451
+ }, [
452
+ createTextVNode(toDisplayString(state.value.report.incompleteCount), 1),
453
+ _cache[4] || (_cache[4] = createElementVNode("svg", {
454
+ viewBox: "0 0 16 16",
455
+ "aria-hidden": "true"
456
+ }, [createElementVNode("circle", {
457
+ cx: "8",
458
+ cy: "8",
459
+ r: "6"
460
+ }), createElementVNode("path", { d: "M6.2 6.3a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M8 11.2h.01" })], -1)),
461
+ _cache[5] || (_cache[5] = createElementVNode("span", { class: "histoire-a11y-sr" }, "need review", -1))
462
+ ], 8, _hoisted_6$2),
463
+ createElementVNode("span", {
464
+ class: "histoire-a11y-counter",
465
+ title: `${state.value.report.passesCount} passed`
466
+ }, [
467
+ createTextVNode(toDisplayString(state.value.report.passesCount), 1),
468
+ _cache[6] || (_cache[6] = createElementVNode("svg", {
469
+ viewBox: "0 0 16 16",
470
+ "aria-hidden": "true"
471
+ }, [createElementVNode("circle", {
472
+ cx: "8",
473
+ cy: "8",
474
+ r: "6"
475
+ }), createElementVNode("path", { d: "M5.5 8.2l1.7 1.7 3.3-3.6" })], -1)),
476
+ _cache[7] || (_cache[7] = createElementVNode("span", { class: "histoire-a11y-sr" }, "passed", -1))
477
+ ], 8, _hoisted_7$2),
478
+ createElementVNode("span", {
479
+ class: "histoire-a11y-counter",
480
+ title: `${state.value.report.inapplicableCount} inapplicable`
481
+ }, [
482
+ createTextVNode(toDisplayString(state.value.report.inapplicableCount), 1),
483
+ _cache[8] || (_cache[8] = createElementVNode("svg", {
484
+ viewBox: "0 0 16 16",
485
+ "aria-hidden": "true"
486
+ }, [createElementVNode("circle", {
487
+ cx: "8",
488
+ cy: "8",
489
+ r: "6"
490
+ }), createElementVNode("path", { d: "M5.5 8h5" })], -1)),
491
+ _cache[9] || (_cache[9] = createElementVNode("span", { class: "histoire-a11y-sr" }, "inapplicable", -1))
492
+ ], 8, _hoisted_8$2),
493
+ state.value.stale && !state.value.running ? (openBlock(), createElementBlock("span", _hoisted_9$2, [..._cache[10] || (_cache[10] = [createElementVNode("svg", {
494
+ viewBox: "0 0 16 16",
495
+ "aria-hidden": "true"
496
+ }, [createElementVNode("circle", {
497
+ cx: "8",
498
+ cy: "8",
499
+ r: "6"
500
+ }), createElementVNode("path", { d: "M8 5v3l2 1.5" })], -1), createElementVNode("span", { class: "histoire-a11y-sr" }, "Results may be outdated", -1)])])) : createCommentVNode("", true)
501
+ ])) : createCommentVNode("", true),
502
+ createElementVNode("label", _hoisted_10$2, [createVNode(unref(HstSwitch), {
503
+ modelValue: autoRun.value,
504
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => autoRun.value = $event),
505
+ layout: "inline",
506
+ "aria-label": "Auto-run"
507
+ }, null, 8, ["modelValue"]), _cache[11] || (_cache[11] = createTextVNode("Auto-run", -1))]),
508
+ createVNode(unref(WorkbenchPanelAction), {
509
+ icon: "play-filled-alt",
510
+ label: "Run",
511
+ disabled: !state.value || state.value.running,
512
+ onClick: run
513
+ }, null, 8, ["disabled"])
514
+ ]), !state.value ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
515
+ key: 0,
516
+ icon: "list-checked",
517
+ title: "No variant available"
518
+ })) : state.value.running && !state.value.report ? (openBlock(), createBlock(unref(WorkbenchLoadingState), {
519
+ key: 1,
520
+ title: "Checking accessibility"
521
+ })) : state.value.error && !state.value.report ? (openBlock(), createBlock(unref(WorkbenchErrorState), {
522
+ key: 2,
523
+ title: "Accessibility check failed"
524
+ }, {
525
+ actions: withCtx(() => [createVNode(unref(HstButton), { onClick: run }, {
526
+ default: withCtx(() => [..._cache[12] || (_cache[12] = [createTextVNode(" Try again ", -1)])]),
527
+ _: 1
528
+ })]),
529
+ default: withCtx(() => [createTextVNode(toDisplayString(state.value.error) + " ", 1)]),
530
+ _: 1
531
+ })) : !state.value.report ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
532
+ key: 3,
533
+ icon: "list-checked",
534
+ title: "Ready to check"
535
+ }, {
536
+ actions: withCtx(() => [createVNode(unref(HstButton), { onClick: run }, {
537
+ default: withCtx(() => [..._cache[13] || (_cache[13] = [createTextVNode(" Run checks ", -1)])]),
538
+ _: 1
539
+ })]),
540
+ _: 1
541
+ })) : (openBlock(), createElementBlock(Fragment, { key: 4 }, [
542
+ state.value.error ? (openBlock(), createBlock(unref(WorkbenchErrorState), {
543
+ key: 0,
544
+ title: "Accessibility check failed"
545
+ }, {
546
+ actions: withCtx(() => [createVNode(unref(HstButton), { onClick: run }, {
547
+ default: withCtx(() => [..._cache[14] || (_cache[14] = [createTextVNode(" Try again ", -1)])]),
548
+ _: 1
549
+ })]),
550
+ default: withCtx(() => [createTextVNode(toDisplayString(state.value.error) + " ", 1)]),
551
+ _: 1
552
+ })) : createCommentVNode("", true),
553
+ createElementVNode("div", _hoisted_11$1, [createVNode(unref(HstSelect), {
554
+ modelValue: unref(outcome),
555
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(outcome) ? outcome.value = $event : null),
556
+ class: "histoire-a11y-filter",
557
+ "aria-label": "Results",
558
+ options: unref(OUTCOME_OPTIONS)
559
+ }, null, 8, ["modelValue", "options"]), createVNode(unref(HstSelect), {
560
+ modelValue: unref(severity),
561
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(severity) ? severity.value = $event : null),
562
+ class: "histoire-a11y-filter",
563
+ "aria-label": "Severity",
564
+ options: unref(SEVERITY_OPTIONS)
565
+ }, null, 8, ["modelValue", "options"])]),
566
+ !findings.value.length ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
567
+ key: 1,
568
+ icon: "checkmark",
569
+ title: !state.value.report.violationsCount && unref(outcome) === "violations" && !state.value.report.truncated ? "No violations found" : unref(outcome) === "incomplete" && !state.value.report.incompleteCount && !state.value.report.truncated ? "No checks need review" : "No matching findings"
570
+ }, {
571
+ default: withCtx(() => [state.value.report.incompleteCount && !state.value.report.violationsCount ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(state.value.report.incompleteCount) + " rules need manual review ", 1)], 64)) : createCommentVNode("", true)]),
572
+ _: 1
573
+ }, 8, ["title"])) : (openBlock(), createElementBlock("div", _hoisted_12$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(findings.value, (rule) => {
574
+ return openBlock(), createBlock(FindingRow_default, {
575
+ key: `${unref(outcome)}:${rule.id}`,
576
+ rule,
577
+ outcome: unref(outcome),
578
+ onHighlight: highlight
579
+ }, null, 8, ["rule", "outcome"]);
580
+ }), 128))])),
581
+ state.value.report.droppedCount ? (openBlock(), createElementBlock("p", _hoisted_13, toDisplayString(state.value.report.droppedCount) + " result details omitted ", 1)) : createCommentVNode("", true),
582
+ state.value.feedback ? (openBlock(), createElementBlock("p", _hoisted_14, toDisplayString(state.value.feedback), 1)) : createCommentVNode("", true)
583
+ ], 64))]);
584
+ };
585
+ }
586
+ });
587
+ // src/workbench/locate.ts
588
+ /**
589
+ * Element of a live report matching a finding from another report (a project run, the build
590
+ * report). Same selectors win; selectors computed in another document only match by position,
591
+ * and only when the rule reports as many elements, so a changed variant never highlights a guess.
592
+ * @param report Live report of the variant.
593
+ * @param finding Element to find.
594
+ */
595
+ function matchNode(report, finding) {
596
+ const rule = report[finding.outcome].find((rule) => rule.id === finding.rule);
597
+ if (!rule) return;
598
+ const key = finding.selectors.join("\n");
599
+ return rule.nodes.find((node) => node.selectors.join("\n") === key) ?? (rule.nodes.length === finding.count ? rule.nodes[finding.index] : void 0);
600
+ }
601
+ // src/workbench/model.ts
602
+ /** Wait for an inspector tab to open a frame visit after navigation; slow variants load late. */
603
+ var VISIT_TIMEOUT = 3e4;
604
+ /** Maintain isolated reports, preferences and channel visits for one extension host. */
605
+ function createAuditModel(api) {
606
+ const options = normalizeOptions(api.options);
607
+ const entries = /* @__PURE__ */ new Map();
608
+ const watchers = /* @__PURE__ */ new Map();
609
+ /** Pending {@link until} checks, re-evaluated on every change. */
610
+ const waiters = /* @__PURE__ */ new Set();
611
+ let disposed = false;
612
+ /** Notify subscribed views and refresh inspector badge. */
613
+ function notify() {
614
+ for (const set of watchers.values()) for (const listener of set) listener();
615
+ for (const waiter of [...waiters]) waiter();
616
+ api.invalidate();
617
+ }
618
+ /**
619
+ * Resolve with the first truthy value of `read`, re-read on every model change; `undefined`
620
+ * after `timeoutMs` or once the plugin retires.
621
+ */
622
+ function until(read, timeoutMs) {
623
+ return new Promise((resolve) => {
624
+ let timer;
625
+ function check() {
626
+ const value = disposed ? void 0 : read();
627
+ if (value || disposed) done(value);
628
+ }
629
+ function done(value) {
630
+ waiters.delete(check);
631
+ clearTimeout(timer);
632
+ resolve(value);
633
+ }
634
+ timer = setTimeout(done, timeoutMs, void 0);
635
+ waiters.add(check);
636
+ check();
637
+ });
638
+ }
639
+ /** Current live-auditing preference, guarded against invalid stored values. */
640
+ function autoRun() {
641
+ const saved = api.preferences.get("autoRun", options.autoRun);
642
+ return typeof saved === "boolean" ? saved : options.autoRun;
643
+ }
644
+ /** End visit before asynchronous messages can publish into successor. */
645
+ function stop(entry) {
646
+ if (entry.channel && entry.visit) send(entry.channel, "stop", { visit: entry.visit }).catch(() => {});
647
+ entry.stop?.();
648
+ entry.stop = void 0;
649
+ entry.channel = void 0;
650
+ entry.visit = void 0;
651
+ entry.state = {
652
+ ...entry.state,
653
+ running: false,
654
+ stale: true
655
+ };
656
+ }
657
+ /** Start actor-bound visit only while a view observes this frame. */
658
+ function start(entry) {
659
+ if (entry.channel || disposed) return;
660
+ try {
661
+ const channel = api.frames.open(entry.frame);
662
+ const visit = crypto.randomUUID();
663
+ entry.channel = channel;
664
+ entry.visit = visit;
665
+ entry.stop = channel.on("update", (value) => {
666
+ const data = value;
667
+ if (!data || data.visit !== entry.visit || entries.get(entry.frame.key) !== entry || !Number.isInteger(data.request) || data.request < entry.request) return;
668
+ entry.request = data.request;
669
+ entry.state = {
670
+ ...entry.state,
671
+ ...data.running !== void 0 ? {
672
+ running: data.running,
673
+ error: void 0,
674
+ feedback: void 0
675
+ } : {},
676
+ ...data.stale !== void 0 ? { stale: data.stale } : {},
677
+ ...data.report ? {
678
+ report: data.report,
679
+ reportId: data.reportId,
680
+ error: void 0
681
+ } : {},
682
+ ...data.error ? { error: data.error } : {},
683
+ ...data.feedback ? { feedback: data.feedback } : {}
684
+ };
685
+ notify();
686
+ });
687
+ send(channel, "activate", {
688
+ visit,
689
+ autoRun: autoRun()
690
+ }).catch((error) => {
691
+ if (entry.visit !== visit) return;
692
+ entry.state = {
693
+ ...entry.state,
694
+ running: false,
695
+ error: String(error)
696
+ };
697
+ notify();
698
+ });
699
+ } catch {}
700
+ }
701
+ /** Retire replaced actors and attach waiting views to their exact successors. */
702
+ function sync() {
703
+ if (disposed) return;
704
+ const frames = api.frames.list();
705
+ const live = new Set(frames.map((frame) => frame.key));
706
+ for (const [key, entry] of entries) if (!live.has(key)) {
707
+ stop(entry);
708
+ entries.delete(key);
709
+ }
710
+ for (const frame of frames) {
711
+ let entry = entries.get(frame.key);
712
+ if (entry?.frame.actorId !== frame.actorId) {
713
+ if (entry) stop(entry);
714
+ entry = {
715
+ frame,
716
+ state: {
717
+ running: false,
718
+ stale: true
719
+ },
720
+ request: 0
721
+ };
722
+ entries.set(frame.key, entry);
723
+ }
724
+ if (watchers.get(frame.key)?.size) start(entry);
725
+ }
726
+ notify();
727
+ }
728
+ const stopFrames = api.frames.subscribe(sync);
729
+ const stopAutoRun = api.preferences.subscribe("autoRun", () => {
730
+ for (const entry of entries.values()) if (entry.channel && entry.visit) send(entry.channel, "configure", {
731
+ visit: entry.visit,
732
+ autoRun: autoRun()
733
+ }).catch(() => {});
734
+ notify();
735
+ });
736
+ api.signal.addEventListener("abort", () => {
737
+ disposed = true;
738
+ for (const entry of entries.values()) stop(entry);
739
+ for (const waiter of [...waiters]) waiter();
740
+ stopFrames();
741
+ stopAutoRun();
742
+ entries.clear();
743
+ watchers.clear();
744
+ }, { once: true });
745
+ sync();
746
+ return {
747
+ autoRun,
748
+ preferences: api.preferences,
749
+ /** Current result belonging to exact frame key. */
750
+ get: (key) => entries.get(key)?.state,
751
+ /** Observe visit; final observer closes it and automatic scanning. */
752
+ watch(key, listener) {
753
+ if (disposed) return () => {};
754
+ const set = watchers.get(key) ?? /* @__PURE__ */ new Set();
755
+ watchers.set(key, set);
756
+ set.add(listener);
757
+ const entry = entries.get(key);
758
+ if (entry) start(entry);
759
+ listener();
760
+ return () => {
761
+ set.delete(listener);
762
+ if (!set.size) {
763
+ watchers.delete(key);
764
+ const current = entries.get(key);
765
+ if (current) stop(current);
766
+ }
767
+ };
768
+ },
769
+ /** Request one scan without enabling automatic work. */
770
+ run(key) {
771
+ const entry = entries.get(key);
772
+ if (entry?.channel && entry.visit) send(entry.channel, "run", { visit: entry.visit }).catch(api.reportError);
773
+ },
774
+ /** Highlight exact node from latest successful report. */
775
+ highlight(key, node) {
776
+ const entry = entries.get(key);
777
+ if (entry?.channel && entry.visit) send(entry.channel, "highlight", {
778
+ visit: entry.visit,
779
+ reportId: entry.state.reportId,
780
+ node
781
+ }).catch(api.reportError);
782
+ },
783
+ /**
784
+ * Highlight an element reported elsewhere (project run, build report) in the variant's
785
+ * frame. Needs the inspector tab to hold that frame's visit; checks it again first when its
786
+ * live report is missing or outdated, then highlights the matching live element.
787
+ * @param target Variant of the finding.
788
+ * @param finding Element to highlight.
789
+ */
790
+ async locate(target, finding) {
791
+ const key = getHistoireTargetKey(target);
792
+ const entry = await until(() => [...entries.values()].find((entry) => entry.channel && getHistoireTargetKey(entry.frame.target) === key), VISIT_TIMEOUT);
793
+ if (!entry) return;
794
+ const fresh = () => entry.state.report && !entry.state.running && !entry.state.stale && entries.get(entry.frame.key) === entry ? entry.state.report : void 0;
795
+ if (!fresh()) this.run(entry.frame.key);
796
+ const report = await until(fresh, options.timeoutMs + VISIT_TIMEOUT);
797
+ const node = report && matchNode(report, finding);
798
+ if (node) return this.highlight(entry.frame.key, nodeKey(finding.outcome, finding.rule, node.selectors));
799
+ if (entries.get(entry.frame.key) !== entry) return;
800
+ entry.state = {
801
+ ...entry.state,
802
+ feedback: "Element not found; run checks again"
803
+ };
804
+ notify();
805
+ }
806
+ };
807
+ }
808
+ // src/workbench/sources.ts
809
+ /** Plain object guard. */
810
+ function isRecord(value) {
811
+ return !!value && typeof value === "object" && !Array.isArray(value);
812
+ }
813
+ /** Structural check of a bounded report received from a test result or a file. */
814
+ function isAuditReport(value) {
815
+ if (!isRecord(value) || !Array.isArray(value.violations) || !Array.isArray(value.incomplete)) return false;
816
+ if (![value.violationsCount, value.incompleteCount].every((count) => Number.isSafeInteger(count))) return false;
817
+ return [...value.violations, ...value.incomplete].every((rule) => isRecord(rule) && typeof rule.id === "string" && typeof rule.help === "string" && Array.isArray(rule.nodes));
818
+ }
819
+ /** Variant target with a concrete variant id. */
820
+ function isVariantTarget(value) {
821
+ return isRecord(value) && typeof value.storyId === "string" && typeof value.variantId === "string";
822
+ }
823
+ /**
824
+ * Reads accessibility results out of project test entries: only the case registered by the
825
+ * `test` option counts; a failed case without data reports its first error.
826
+ * @param entries Entries of the host tests service.
827
+ */
828
+ function resultsFromTests(entries) {
829
+ const results = [];
830
+ for (const entry of entries) {
831
+ if (!isVariantTarget(entry.target)) continue;
832
+ const test = entry.summary?.tests.find((test) => test.name === "Accessibility (axe-core)") ?? entry.summary?.tests.find((test) => test.name === HISTOIRE_VARIANT_ERROR_TEST_NAME && test.state === "failed");
833
+ if (!test && !entry.running) continue;
834
+ const data = (test?.data)?.[A11Y_TEST_DATA_KEY];
835
+ const report = isRecord(data) && isAuditReport(data.report) ? data.report : void 0;
836
+ const failure = test?.state === "failed" && !report ? test.errors[0] : void 0;
837
+ const error = failure === void 0 ? void 0 : typeof failure === "string" ? failure : failure.message;
838
+ results.push({
839
+ target: entry.target,
840
+ report,
841
+ ...error ? { error } : {},
842
+ stale: entry.stale,
843
+ running: entry.running
844
+ });
845
+ }
846
+ return results;
847
+ }
848
+ /**
849
+ * Validates a build report file; malformed content reads as `undefined`.
850
+ * @param value Parsed JSON.
851
+ */
852
+ function parseBuildReport(value) {
853
+ if (!isRecord(value) || value.version !== 1 || typeof value.generatedAt !== "string" || !Array.isArray(value.results)) return;
854
+ for (const result of value.results) {
855
+ if (!isRecord(result) || !isVariantTarget(result.target)) return;
856
+ if (result.report !== void 0 && !isAuditReport(result.report)) return;
857
+ if (result.error !== void 0 && typeof result.error !== "string") return;
858
+ }
859
+ return value;
860
+ }
861
+ // src/workbench/project-source.ts
862
+ /**
863
+ * Picks the pane data source: live project test runs on the dev server, else the report the
864
+ * `build` option embedded into the static book. Disposed with the plugin.
865
+ * @param api Workbench plugin API.
866
+ * @param options Whether the `test` and `build` options are enabled.
867
+ * @param options.tests Accessibility tests are registered.
868
+ * @param options.report The book embeds a build report.
869
+ */
870
+ function createProjectSource(api, options) {
871
+ const tests = options.tests ? api.context.tests : void 0;
872
+ const listeners = /* @__PURE__ */ new Set();
873
+ let state = {
874
+ results: [],
875
+ kind: tests ? "tests" : options.report ? "build" : "none",
876
+ running: false,
877
+ canRun: false,
878
+ progress: null
879
+ };
880
+ /** Publish a new state to views and refresh the rail badge. */
881
+ function update(patch) {
882
+ if (api.signal.aborted) return;
883
+ state = {
884
+ ...state,
885
+ ...patch
886
+ };
887
+ for (const listener of [...listeners]) listener();
888
+ api.invalidate();
889
+ }
890
+ if (tests) {
891
+ const read = () => update({
892
+ results: resultsFromTests(tests.entries()),
893
+ running: tests.running,
894
+ canRun: tests.canRun,
895
+ progress: tests.progress,
896
+ error: tests.error?.split("\n")[0] || void 0
897
+ });
898
+ tests.subscribe(read);
899
+ read();
900
+ } else if (options.report) loadReport();
901
+ /** Download the build report next to the book entry; a missing file means no results. */
902
+ async function loadReport() {
903
+ update({ running: true });
904
+ try {
905
+ const url = new URL(`${import.meta.env.BASE_URL}${A11Y_BUILD_REPORT_FILE}`, document.baseURI);
906
+ const response = await fetch(url, { signal: api.signal });
907
+ if (response.status === 404) return update({ running: false });
908
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
909
+ const report = parseBuildReport(await response.json());
910
+ if (!report) throw new Error("Invalid accessibility report");
911
+ update({
912
+ running: false,
913
+ results: report.results,
914
+ generatedAt: report.generatedAt
915
+ });
916
+ } catch (error) {
917
+ if (!api.signal.aborted) update({
918
+ running: false,
919
+ error: error instanceof Error ? error.message : String(error)
920
+ });
921
+ }
922
+ }
923
+ return {
924
+ /** Current state; replaced on every change. */
925
+ get: () => state,
926
+ /** Observe state changes. */
927
+ subscribe(listener) {
928
+ listeners.add(listener);
929
+ return () => void listeners.delete(listener);
930
+ },
931
+ /** Run accessibility checks of every variant (with the rest of the project tests). */
932
+ runAll() {
933
+ if (tests?.canRun) tests.runAll().catch(api.reportError);
934
+ }
935
+ };
936
+ }
937
+ /**
938
+ * Report of one variant in the source's latest results. The index is rebuilt only when the
939
+ * results change, since frame header badges read it for every laid-out frame.
940
+ * @param source Project source.
941
+ */
942
+ function createReportLookup(source) {
943
+ let indexed;
944
+ let index = /* @__PURE__ */ new Map();
945
+ return (target) => {
946
+ const { results } = source.get();
947
+ if (results !== indexed) {
948
+ indexed = results;
949
+ index = new Map(results.map((result) => [getHistoireTargetKey(result.target), result.report]));
950
+ }
951
+ return index.get(getHistoireTargetKey(target));
952
+ };
953
+ }
954
+ // src/workbench/VariantGroup.vue?vue&type=script&setup=true&lang.ts
955
+ var _hoisted_1$1 = { class: "histoire-a11y-variant" };
956
+ var _hoisted_2$1 = { class: "histoire-a11y-variant-title" };
957
+ var _hoisted_3$1 = { class: "histoire-a11y-variant-story" };
958
+ var _hoisted_4$1 = { class: "histoire-a11y-variant-name" };
959
+ var _hoisted_5$1 = {
960
+ key: 0,
961
+ class: "histoire-a11y-variant-flag",
962
+ title: "Results may be outdated"
963
+ };
964
+ var _hoisted_6$1 = ["data-impact", "title"];
965
+ var _hoisted_7$1 = { class: "histoire-a11y-sr" };
966
+ var _hoisted_8$1 = {
967
+ key: 2,
968
+ class: "histoire-a11y-variant-flag histoire-a11y-variant-failed",
969
+ title: "Check failed"
970
+ };
971
+ var _hoisted_9$1 = { class: "histoire-a11y-variant-body" };
972
+ var _hoisted_10$1 = {
973
+ key: 0,
974
+ class: "histoire-a11y-error"
975
+ };
976
+ // src/workbench/VariantGroup.vue
977
+ var VariantGroup_default = /* @__PURE__ */ defineComponent({
978
+ __name: "VariantGroup",
979
+ props: {
980
+ group: {},
981
+ outcome: {}
982
+ },
983
+ emits: ["open", "highlight"],
984
+ setup(__props, { emit: __emit }) {
985
+ const props = __props;
986
+ const emit = __emit;
987
+ const impact = computed(() => worstImpact(props.group.findings));
988
+ const count = computed(() => `${props.group.findings.length} ${props.group.findings.length === 1 ? "rule" : "rules"}`);
989
+ return (_ctx, _cache) => {
990
+ return openBlock(), createElementBlock("details", _hoisted_1$1, [createElementVNode("summary", null, [
991
+ createElementVNode("span", _hoisted_2$1, [createElementVNode("span", _hoisted_3$1, toDisplayString(__props.group.storyTitle), 1), createElementVNode("span", _hoisted_4$1, toDisplayString(__props.group.variantTitle), 1)]),
992
+ __props.group.stale ? (openBlock(), createElementBlock("span", _hoisted_5$1, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
993
+ viewBox: "0 0 16 16",
994
+ "aria-hidden": "true"
995
+ }, [createElementVNode("circle", {
996
+ cx: "8",
997
+ cy: "8",
998
+ r: "6"
999
+ }), createElementVNode("path", { d: "M8 5v3l2 1.5" })], -1), createElementVNode("span", { class: "histoire-a11y-sr" }, "Results may be outdated", -1)])])) : createCommentVNode("", true),
1000
+ __props.group.report ? (openBlock(), createElementBlock("span", {
1001
+ key: 1,
1002
+ class: "histoire-a11y-count",
1003
+ "data-impact": impact.value,
1004
+ title: count.value
1005
+ }, [createTextVNode(toDisplayString(__props.group.findings.length), 1), createElementVNode("span", _hoisted_7$1, toDisplayString(__props.group.findings.length === 1 ? "rule" : "rules"), 1)], 8, _hoisted_6$1)) : (openBlock(), createElementBlock("span", _hoisted_8$1, [..._cache[3] || (_cache[3] = [createElementVNode("svg", {
1006
+ viewBox: "0 0 16 16",
1007
+ "aria-hidden": "true"
1008
+ }, [createElementVNode("circle", {
1009
+ cx: "8",
1010
+ cy: "8",
1011
+ r: "6"
1012
+ }), createElementVNode("path", { d: "M6 6l4 4M10 6l-4 4" })], -1), createElementVNode("span", { class: "histoire-a11y-sr" }, "Check failed", -1)])])),
1013
+ createElementVNode("button", {
1014
+ type: "button",
1015
+ class: "histoire-a11y-icon-button",
1016
+ "aria-label": "Open variant",
1017
+ title: "Open variant",
1018
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => emit("open"), ["prevent"]))
1019
+ }, [..._cache[4] || (_cache[4] = [createElementVNode("svg", {
1020
+ viewBox: "0 0 16 16",
1021
+ "aria-hidden": "true"
1022
+ }, [createElementVNode("path", { d: "M9.5 2.5h4v4M13.5 2.5 7.5 8.5M11.5 9.5v4h-9v-9h4" })], -1)])])
1023
+ ]), createElementVNode("div", _hoisted_9$1, [__props.group.error && !__props.group.report ? (openBlock(), createElementBlock("pre", _hoisted_10$1, toDisplayString(__props.group.error), 1)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.group.findings, (rule) => {
1024
+ return openBlock(), createBlock(FindingRow_default, {
1025
+ key: rule.id,
1026
+ rule,
1027
+ outcome: __props.outcome,
1028
+ onHighlight: _cache[1] || (_cache[1] = ($event) => emit("highlight", $event))
1029
+ }, null, 8, ["rule", "outcome"]);
1030
+ }), 128))])]);
1031
+ };
1032
+ }
1033
+ });
1034
+ // src/workbench/ProjectPanel.vue?vue&type=script&setup=true&lang.ts
1035
+ var _hoisted_1 = {
1036
+ class: "histoire-a11y",
1037
+ "aria-label": "Accessibility issues"
1038
+ };
1039
+ var _hoisted_2 = {
1040
+ key: 0,
1041
+ class: "histoire-a11y-run-progress"
1042
+ };
1043
+ var _hoisted_3 = [
1044
+ "data-indeterminate",
1045
+ "aria-label",
1046
+ "aria-valuemax",
1047
+ "aria-valuenow"
1048
+ ];
1049
+ var _hoisted_4 = { key: 0 };
1050
+ var _hoisted_5 = { key: 1 };
1051
+ var _hoisted_6 = {
1052
+ class: "histoire-a11y-counters histoire-a11y-summary",
1053
+ role: "status",
1054
+ "aria-live": "polite"
1055
+ };
1056
+ var _hoisted_7 = ["title"];
1057
+ var _hoisted_8 = ["data-impact", "title"];
1058
+ var _hoisted_9 = { class: "histoire-a11y-sr" };
1059
+ var _hoisted_10 = ["title"];
1060
+ var _hoisted_11 = ["title"];
1061
+ var _hoisted_12 = { class: "histoire-a11y-filters" };
1062
+ // src/workbench/ProjectPanel.vue
1063
+ var ProjectPanel_default = /* @__PURE__ */ defineComponent({
1064
+ __name: "ProjectPanel",
1065
+ props: {
1066
+ context: {},
1067
+ source: {},
1068
+ preferences: {},
1069
+ model: {}
1070
+ },
1071
+ setup(__props) {
1072
+ const props = __props;
1073
+ const state = shallowRef(props.source.get());
1074
+ onScopeDispose(props.source.subscribe(() => state.value = props.source.get()));
1075
+ const { outcome, severity } = useFindingFilters(props.preferences);
1076
+ const titles = shallowRef(/* @__PURE__ */ new Map());
1077
+ watch(() => state.value.results, async () => {
1078
+ try {
1079
+ const stories = await props.context.catalog.list();
1080
+ titles.value = new Map(stories.flatMap((story) => story.variants.map((variant) => [getHistoireTargetKey({
1081
+ storyId: story.id,
1082
+ variantId: variant.id
1083
+ }), {
1084
+ story: story.title,
1085
+ variant: variant.title
1086
+ }])));
1087
+ } catch {}
1088
+ }, { immediate: true });
1089
+ const projection = computed(() => projectGroups(state.value.results, (target) => titles.value.get(getHistoireTargetKey(target)), {
1090
+ outcome: outcome.value,
1091
+ severity: severity.value
1092
+ }));
1093
+ const hasResults = computed(() => state.value.results.some((result) => result.report || result.error));
1094
+ const determinate = computed(() => !!state.value.progress && state.value.progress.total > 0);
1095
+ const PHASE_LABELS = {
1096
+ queued: "Waiting to start",
1097
+ collect: "Collecting stories",
1098
+ run: "Checking variants"
1099
+ };
1100
+ const phaseLabel = computed(() => PHASE_LABELS[state.value.progress?.phase ?? "run"]);
1101
+ const errorTitle = computed(() => state.value.kind === "build" ? "Accessibility report unavailable" : "Accessibility checks failed");
1102
+ const generatedAt = computed(() => state.value.generatedAt ? new Date(state.value.generatedAt).toLocaleString() : void 0);
1103
+ /** Select the variant unless it is current, and show its live accessibility tab. */
1104
+ async function open(group) {
1105
+ const current = props.context.selection.target;
1106
+ if (!current || getHistoireTargetKey(current) !== group.key) await props.context.navigation.selectStory(group.target);
1107
+ props.context.navigation.openInspectorTab("a11y:accessibility");
1108
+ }
1109
+ /**
1110
+ * Open the variant, then highlight the element in its canvas once the tab checked it live.
1111
+ * @param group Variant of the element.
1112
+ * @param finding Element to highlight.
1113
+ */
1114
+ async function highlight(group, finding) {
1115
+ await open(group);
1116
+ await props.model.locate(group.target, finding);
1117
+ }
1118
+ return (_ctx, _cache) => {
1119
+ return openBlock(), createElementBlock("section", _hoisted_1, [
1120
+ createVNode(unref(WorkbenchPaneHeader), { title: "Accessibility" }, {
1121
+ default: withCtx(() => [state.value.kind === "tests" ? (openBlock(), createBlock(unref(WorkbenchPanelAction), {
1122
+ key: 0,
1123
+ icon: "play-filled-alt",
1124
+ label: "Run all",
1125
+ disabled: !state.value.canRun || state.value.running,
1126
+ onClick: _cache[0] || (_cache[0] = ($event) => __props.source.runAll())
1127
+ }, null, 8, ["disabled"])) : createCommentVNode("", true)]),
1128
+ _: 1
1129
+ }),
1130
+ state.value.kind === "tests" && state.value.running ? (openBlock(), createElementBlock("div", _hoisted_2, [createElementVNode("div", {
1131
+ class: "histoire-a11y-progress",
1132
+ "data-indeterminate": determinate.value ? void 0 : "",
1133
+ role: "progressbar",
1134
+ "aria-label": phaseLabel.value,
1135
+ "aria-valuemin": "0",
1136
+ "aria-valuemax": determinate.value ? state.value.progress.total : void 0,
1137
+ "aria-valuenow": determinate.value ? state.value.progress.completed : void 0
1138
+ }, [createElementVNode("span", { style: normalizeStyle(determinate.value ? { width: `${state.value.progress.completed / state.value.progress.total * 100}%` } : void 0) }, null, 4)], 8, _hoisted_3), determinate.value ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(phaseLabel.value) + " " + toDisplayString(state.value.progress.completed) + "/" + toDisplayString(state.value.progress.total), 1)) : state.value.progress ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(phaseLabel.value), 1)) : createCommentVNode("", true)])) : createCommentVNode("", true),
1139
+ state.value.running && !hasResults.value && state.value.kind === "tests" ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
1140
+ key: 1,
1141
+ icon: "list-checked",
1142
+ tone: "neutral",
1143
+ title: "Checking accessibility"
1144
+ })) : state.value.running && !hasResults.value ? (openBlock(), createBlock(unref(WorkbenchLoadingState), {
1145
+ key: 2,
1146
+ title: "Loading accessibility report"
1147
+ })) : state.value.error && !hasResults.value ? (openBlock(), createBlock(unref(WorkbenchErrorState), {
1148
+ key: 3,
1149
+ title: errorTitle.value
1150
+ }, {
1151
+ default: withCtx(() => [createTextVNode(toDisplayString(state.value.error), 1)]),
1152
+ _: 1
1153
+ }, 8, ["title"])) : !hasResults.value ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
1154
+ key: 4,
1155
+ icon: "list-checked",
1156
+ tone: "neutral",
1157
+ title: "No results"
1158
+ })) : (openBlock(), createElementBlock(Fragment, { key: 5 }, [
1159
+ createElementVNode("div", _hoisted_6, [
1160
+ createElementVNode("span", {
1161
+ class: "histoire-a11y-counter",
1162
+ title: `${projection.value.totals.affected} of ${projection.value.totals.checked} variants with violations`
1163
+ }, [
1164
+ createTextVNode(toDisplayString(projection.value.totals.affected) + "/" + toDisplayString(projection.value.totals.checked), 1),
1165
+ _cache[3] || (_cache[3] = createElementVNode("svg", {
1166
+ viewBox: "0 0 16 16",
1167
+ "aria-hidden": "true"
1168
+ }, [createElementVNode("rect", {
1169
+ x: "2.5",
1170
+ y: "2.5",
1171
+ width: "11",
1172
+ height: "11",
1173
+ rx: "2"
1174
+ }), createElementVNode("path", { d: "M2.5 6.5h11" })], -1)),
1175
+ _cache[4] || (_cache[4] = createElementVNode("span", { class: "histoire-a11y-sr" }, "variants with violations", -1))
1176
+ ], 8, _hoisted_7),
1177
+ createElementVNode("span", {
1178
+ class: "histoire-a11y-counter histoire-a11y-severity-text",
1179
+ "data-impact": unref(worstImpact)(projection.value.groups.flatMap((group) => group.findings)),
1180
+ title: `${projection.value.totals.violations} ${projection.value.totals.violations === 1 ? "violation" : "violations"}`
1181
+ }, [
1182
+ createTextVNode(toDisplayString(projection.value.totals.violations), 1),
1183
+ _cache[5] || (_cache[5] = createElementVNode("svg", {
1184
+ viewBox: "0 0 16 16",
1185
+ "aria-hidden": "true"
1186
+ }, [createElementVNode("circle", {
1187
+ cx: "8",
1188
+ cy: "8",
1189
+ r: "6"
1190
+ }), createElementVNode("path", { d: "M8 5v3.5M8 11h.01" })], -1)),
1191
+ createElementVNode("span", _hoisted_9, toDisplayString(projection.value.totals.violations === 1 ? "violation" : "violations"), 1)
1192
+ ], 8, _hoisted_8),
1193
+ projection.value.totals.failed ? (openBlock(), createElementBlock("span", {
1194
+ key: 0,
1195
+ class: "histoire-a11y-counter histoire-a11y-variant-failed",
1196
+ title: `${projection.value.totals.failed} failed ${projection.value.totals.failed === 1 ? "check" : "checks"}`
1197
+ }, [
1198
+ createTextVNode(toDisplayString(projection.value.totals.failed), 1),
1199
+ _cache[6] || (_cache[6] = createElementVNode("svg", {
1200
+ viewBox: "0 0 16 16",
1201
+ "aria-hidden": "true"
1202
+ }, [createElementVNode("circle", {
1203
+ cx: "8",
1204
+ cy: "8",
1205
+ r: "6"
1206
+ }), createElementVNode("path", { d: "M6 6l4 4M10 6l-4 4" })], -1)),
1207
+ _cache[7] || (_cache[7] = createElementVNode("span", { class: "histoire-a11y-sr" }, "failed", -1))
1208
+ ], 8, _hoisted_10)) : createCommentVNode("", true),
1209
+ generatedAt.value ? (openBlock(), createElementBlock("span", {
1210
+ key: 1,
1211
+ class: "histoire-a11y-counter histoire-a11y-generated",
1212
+ title: `Results from build ${generatedAt.value}`
1213
+ }, [_cache[8] || (_cache[8] = createElementVNode("svg", {
1214
+ viewBox: "0 0 16 16",
1215
+ "aria-hidden": "true"
1216
+ }, [createElementVNode("circle", {
1217
+ cx: "8",
1218
+ cy: "8",
1219
+ r: "6"
1220
+ }), createElementVNode("path", { d: "M8 5v3l2 1.5" })], -1)), createTextVNode(toDisplayString(generatedAt.value), 1)], 8, _hoisted_11)) : createCommentVNode("", true)
1221
+ ]),
1222
+ state.value.error ? (openBlock(), createBlock(unref(WorkbenchErrorState), {
1223
+ key: 0,
1224
+ title: errorTitle.value
1225
+ }, {
1226
+ default: withCtx(() => [createTextVNode(toDisplayString(state.value.error), 1)]),
1227
+ _: 1
1228
+ }, 8, ["title"])) : createCommentVNode("", true),
1229
+ createVNode(unref(WorkbenchPaneToolbar), null, {
1230
+ default: withCtx(() => [createElementVNode("div", _hoisted_12, [createVNode(unref(HstSelect), {
1231
+ modelValue: unref(outcome),
1232
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(outcome) ? outcome.value = $event : null),
1233
+ class: "histoire-a11y-filter",
1234
+ "aria-label": "Results",
1235
+ options: unref(OUTCOME_OPTIONS)
1236
+ }, null, 8, ["modelValue", "options"]), createVNode(unref(HstSelect), {
1237
+ modelValue: unref(severity),
1238
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(severity) ? severity.value = $event : null),
1239
+ class: "histoire-a11y-filter",
1240
+ "aria-label": "Severity",
1241
+ options: unref(SEVERITY_OPTIONS)
1242
+ }, null, 8, ["modelValue", "options"])])]),
1243
+ _: 1
1244
+ }),
1245
+ !projection.value.groups.length ? (openBlock(), createBlock(unref(WorkbenchEmptyState), {
1246
+ key: 1,
1247
+ icon: "checkmark",
1248
+ title: unref(outcome) === "violations" && unref(severity) === "all" ? "No violations found" : "No matching findings"
1249
+ }, null, 8, ["title"])) : (openBlock(), createBlock(unref(WorkbenchPaneList), { key: 2 }, {
1250
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(projection.value.groups, (group) => {
1251
+ return openBlock(), createBlock(VariantGroup_default, {
1252
+ key: group.key,
1253
+ group,
1254
+ outcome: unref(outcome),
1255
+ onOpen: ($event) => open(group),
1256
+ onHighlight: ($event) => highlight(group, $event)
1257
+ }, null, 8, [
1258
+ "group",
1259
+ "outcome",
1260
+ "onOpen",
1261
+ "onHighlight"
1262
+ ]);
1263
+ }), 128))]),
1264
+ _: 1
1265
+ }))
1266
+ ], 64))
1267
+ ]);
1268
+ };
1269
+ }
1270
+ });
1271
+ // src/workbench/styles.css?inline
1272
+ var styles_default = ".histoire-a11y {\n display: flex;\n flex-direction: column;\n min-height: 0;\n height: 100%;\n color: var(--histoire-text, inherit);\n font-size: 13px;\n}\n.histoire-a11y-auto { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; white-space: nowrap; --histoire-control-margin: 0px; --histoire-control-wrapper-padding: 0px; }\n/* Project pane counters row, between the pane header and the filters. */\n.histoire-a11y-summary { flex-wrap: wrap; row-gap: 4px; padding: 0 var(--histoire-pane-gutter); font-size: 12px; }\n/* Counts take the text color of their most severe impact tag. */\n.histoire-a11y-severity-text[data-impact=\"critical\"], .histoire-a11y-severity-text[data-impact=\"serious\"] { color: rgb(var(--histoire-danger-text-rgb, 220 60 80)); }\n.histoire-a11y-severity-text[data-impact=\"moderate\"] { color: rgb(var(--histoire-warn-rgb, 190 140 40)); }\n.histoire-a11y-filter { min-width: 0; --histoire-control-margin: 0px; --histoire-control-wrapper-padding: 0px; }\n.histoire-a11y-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 104px), 1fr)); gap: 8px; width: 100%; }\n.histoire-a11y-rule { margin-bottom: 6px; border-radius: var(--histoire-radius-control, 6px); background: var(--histoire-chip, rgb(128 128 128 / .06)); }\n/* Expanded rows separate header and details; a text-derived tone stays visible on the chip background in both themes. */\n.histoire-a11y-rule[open] > summary { border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent); }\n.histoire-a11y-rule[open] > .histoire-a11y-details { padding-top: 6px; }\n/* Two rows: caret, severity and count, then the title aligned under the severity tag. */\n.histoire-a11y-rule summary { display: flex; flex-direction: column; gap: 4px; cursor: pointer; padding: var(--histoire-comment-row-padding, 10px) var(--histoire-pane-row-inset); list-style: none; }\n.histoire-a11y-rule summary::-webkit-details-marker { display: none; }\n.histoire-a11y-rule-meta { display: flex; align-items: center; gap: 6px; min-height: 18px; }\n/* One drawn chevron rotated per state, so collapsed and expanded share the same size. */\n.histoire-a11y-rule-meta::before, .histoire-a11y-variant > summary::before { content: ''; flex: none; width: 5px; height: 5px; margin: 0 4px 0 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }\n.histoire-a11y-rule[open] > summary .histoire-a11y-rule-meta::before, .histoire-a11y-variant[open] > summary::before { transform: rotate(45deg); }\n.histoire-a11y-rule-count { font-size: 11px; opacity: .7; }\n.histoire-a11y-rule summary strong { padding-left: 18px; font-size: 12px; line-height: 1.4; }\n/* Impact tags: tinted fill, matching full border and status-colored text; critical is the strongest. */\n.histoire-a11y-impact { padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 600; border: 1px solid rgb(128 128 128 / .35); background: rgb(128 128 128 / .16); }\n.histoire-a11y-impact[data-impact=\"critical\"], .histoire-a11y-impact[data-impact=\"serious\"] { color: rgb(var(--histoire-danger-text-rgb, 220 60 80)); border-color: rgb(var(--histoire-danger-rgb, 220 60 80) / .5); background: rgb(var(--histoire-danger-rgb, 220 60 80) / .2); }\n.histoire-a11y-impact[data-impact=\"critical\"] { color: rgb(var(--histoire-danger-soft-rgb, 255 255 255)); border-color: rgb(var(--histoire-danger-rgb, 220 60 80)); background: rgb(var(--histoire-danger-rgb, 220 60 80) / .85); }\n.histoire-a11y-impact[data-impact=\"moderate\"] { color: rgb(var(--histoire-warn-rgb, 190 140 40)); border-color: rgb(var(--histoire-warn-rgb, 190 140 40) / .5); background: rgb(var(--histoire-warn-rgb, 190 140 40) / .2); }\n.histoire-a11y-details { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--histoire-pane-row-inset) 8px; }\n/* Direction B: numbered elements, then the fix they share. */\n.histoire-a11y-fix-group { display: flex; flex-direction: column; gap: 6px; }\n.histoire-a11y-elements { margin: 0; padding: 0; list-style: none; border: 1px solid color-mix(in srgb, currentColor 12%, transparent); border-radius: 5px; overflow: hidden; }\n.histoire-a11y-element { display: flex; align-items: center; gap: 2px; min-height: 30px; padding: 0 3px 0 8px; }\n.histoire-a11y-element + .histoire-a11y-element { border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); }\n.histoire-a11y-element-number { flex: none; width: 14px; font-family: var(--histoire-font-mono, ui-monospace, monospace); font-size: 10px; opacity: .6; }\n.histoire-a11y-selector { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }\n.histoire-a11y-icon-button { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: inherit; opacity: .7; cursor: pointer; }\n.histoire-a11y-icon-button:hover, .histoire-a11y-icon-button:focus-visible { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }\n/* Copy stays out of the way until the element row is hovered or focused. */\n.histoire-a11y-copy { opacity: 0; }\n.histoire-a11y-element:hover .histoire-a11y-copy, .histoire-a11y-element:focus-within .histoire-a11y-copy { opacity: .7; }\n.histoire-a11y-icon-button svg, .histoire-a11y-rule-id svg, .histoire-a11y-counter svg, .histoire-a11y-variant-flag svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }\n.histoire-a11y-fix { padding: 8px; border-radius: 5px; background: color-mix(in srgb, currentColor 5%, transparent); }\n.histoire-a11y-fix-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }\n.histoire-a11y-fix-label { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .7; }\n.histoire-a11y-rule-id { display: inline-flex; align-items: center; gap: 4px; font-family: var(--histoire-font-mono, ui-monospace, monospace); font-size: 11px; text-decoration: none; opacity: .75; }\n.histoire-a11y-rule-id:hover { opacity: 1; }\n.histoire-a11y-rule-id svg { width: 12px; height: 12px; }\n.histoire-a11y-fix-items { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 0; padding: 0 0 0 14px; font-size: 12px; line-height: 1.45; }\n.histoire-a11y-more { margin: 4px 0 0 14px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-size: 11px; opacity: .7; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }\n.histoire-a11y a { color: inherit; text-underline-offset: 3px; }\n.histoire-a11y-note { padding: 6px var(--histoire-pane-gutter); margin: 0; font-size: 12px; }\n/* Inspector tab: the host already pads the content, so blocks drop their gutters and share one gap. */\n.histoire-a11y-tab { gap: 12px; }\n.histoire-a11y-tab-header { display: flex; flex: none; align-items: center; gap: 10px; min-width: 0; font-size: 12px; }\n.histoire-a11y-tab-header > .histoire-a11y-auto { margin-left: auto; }\n/* Same gap as the header row, so counters and controls space evenly. */\n.histoire-a11y-counters { display: flex; align-items: center; gap: 10px; min-width: 0; }\n.histoire-a11y-counter { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }\n.histoire-a11y-counter:not(.histoire-a11y-severity-text) { opacity: .75; }\n.histoire-a11y-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.histoire-a11y-tab > .histoire-a11y-note { padding: 0; }\n.histoire-a11y-tab > .histoire-a11y-filters { flex: none; }\n.histoire-a11y-tab-list { flex: 1; min-height: 0; overflow: auto; }\n.histoire-a11y-tab-list > .histoire-a11y-rule:last-child { margin-bottom: 0; }\n/* Project pane: flat variant rows; only the rule cards inside are boxed, indented under the title. */\n.histoire-a11y-variant + .histoire-a11y-variant { margin-top: 2px; }\n/* Positioned: anchors the visually hidden labels inside, which otherwise escape the scrolling list and stretch the page. */\n.histoire-a11y-variant > summary { position: relative; display: flex; align-items: center; gap: 6px; min-height: 28px; padding: var(--histoire-list-row-padding, 8px) var(--histoire-pane-row-inset); border-radius: var(--histoire-radius-control, 6px); cursor: pointer; list-style: none; }\n.histoire-a11y-variant > summary::-webkit-details-marker { display: none; }\n.histoire-a11y-variant > summary:hover { background: var(--histoire-chip, rgb(128 128 128 / .08)); }\n.histoire-a11y-variant-title { display: flex; flex: 1; flex-wrap: wrap; column-gap: 4px; min-width: 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }\n.histoire-a11y-variant-story { opacity: .65; }\n.histoire-a11y-variant-story::after { content: ' /'; }\n.histoire-a11y-variant-name { font-weight: 600; }\n.histoire-a11y-variant-flag { display: inline-flex; flex: none; opacity: .7; }\n.histoire-a11y-variant-failed { color: rgb(var(--histoire-danger-text-rgb, 220 60 80)); opacity: 1; }\n/* Rule count pill, tinted like the worst impact tag of the variant. */\n.histoire-a11y-count { flex: none; min-width: 18px; padding: 1px 5px; border-radius: 9px; font-size: 11px; font-weight: 600; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; background: rgb(128 128 128 / .16); }\n.histoire-a11y-count[data-impact=\"critical\"], .histoire-a11y-count[data-impact=\"serious\"] { color: rgb(var(--histoire-danger-text-rgb, 220 60 80)); background: rgb(var(--histoire-danger-rgb, 220 60 80) / .2); }\n.histoire-a11y-count[data-impact=\"moderate\"] { color: rgb(var(--histoire-warn-rgb, 190 140 40)); background: rgb(var(--histoire-warn-rgb, 190 140 40) / .2); }\n/* Open action shows on hover or focus, so many rows don't repeat the same icon. */\n.histoire-a11y-variant > summary > .histoire-a11y-icon-button { opacity: 0; }\n.histoire-a11y-variant > summary:hover > .histoire-a11y-icon-button, .histoire-a11y-variant > summary:focus-within > .histoire-a11y-icon-button, .histoire-a11y-variant[open] > summary > .histoire-a11y-icon-button { opacity: .7; }\n.histoire-a11y-variant > summary > .histoire-a11y-icon-button:hover, .histoire-a11y-variant > summary > .histoire-a11y-icon-button:focus-visible { opacity: 1; }\n/* Narrow panes: rule cards use the full row width, no indentation. */\n.histoire-a11y-variant-body { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 10px; }\n.histoire-a11y-variant-body > .histoire-a11y-rule { margin-bottom: 0; }\n.histoire-a11y-error { margin: 0; padding: 8px; max-height: 14em; overflow: auto; border-radius: 5px; color: rgb(var(--histoire-danger-text-rgb, 220 60 80)); background: rgb(var(--histoire-danger-rgb, 220 60 80) / .1); font-family: var(--histoire-font-mono, ui-monospace, monospace); font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }\n.histoire-a11y-run-progress { display: flex; flex-direction: column; gap: 6px; padding: 0 var(--histoire-pane-gutter) 8px; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .8; }\n.histoire-a11y-progress { flex: none; height: 4px; overflow: hidden; border-radius: 4px; background: var(--histoire-chip, rgb(128 128 128 / .12)); }\n.histoire-a11y-progress > span { display: block; height: 100%; border-radius: inherit; background: rgb(var(--histoire-accent-rgb, 52 211 153)); transition: width .2s; }\n.histoire-a11y-progress[data-indeterminate] > span { width: 35%; background: var(--histoire-muted, currentColor); animation: histoire-a11y-indeterminate 1.2s ease-in-out infinite; }\n@keyframes histoire-a11y-indeterminate { from { transform: translateX(-100%) } to { transform: translateX(290%) } }\n@media (prefers-reduced-motion: reduce) { .histoire-a11y-progress[data-indeterminate] > span { width: 100%; animation: none; opacity: .5; } }\n";
1273
+ // src/client.ts
1274
+ var client_default = defineWorkbenchPlugin({
1275
+ id: "a11y",
1276
+ apiVersion: 1,
1277
+ setup(api) {
1278
+ installPluginStyles(document, "a11y", styles_default, api.signal);
1279
+ const model = createAuditModel(api);
1280
+ /** Attached actor of the captured selection, never a different variant's frame. */
1281
+ function auditFrame(context) {
1282
+ const target = context.selection.target;
1283
+ return target && api.frames.list().find((frame) => frame.target.storyId === target.storyId && frame.target.variantId === target.variantId);
1284
+ }
1285
+ api.commands.add({
1286
+ id: "run-audit",
1287
+ label: "Run audit",
1288
+ icon: "play-filled-alt",
1289
+ /** Manual scans require an attached, idle actor of the selected variant. */
1290
+ available(context) {
1291
+ const frame = auditFrame(context);
1292
+ return !!frame && !model.get(frame.key)?.running;
1293
+ },
1294
+ /** Open the channel-owning tab and scan only the originally captured actor. */
1295
+ async run(context, { signal }) {
1296
+ const frame = auditFrame(context);
1297
+ if (!frame) return;
1298
+ context.navigation.openInspectorTab("a11y:accessibility");
1299
+ await nextTick();
1300
+ if (!signal.aborted && api.frames.list().some((current) => current.key === frame.key && current.actorId === frame.actorId)) model.run(frame.key);
1301
+ }
1302
+ });
1303
+ api.inspector.addTab({
1304
+ id: "accessibility",
1305
+ primaryCommand: "run-audit",
1306
+ label: "Accessibility",
1307
+ icon: "list-checked",
1308
+ badge: (context) => model.get(context.frame.key)?.report?.violationsCount || null,
1309
+ component: defineWorkbenchComponent(defineComponent({
1310
+ name: "AccessibilityInspector",
1311
+ props: {
1312
+ /** Current frame scope. */
1313
+ context: {
1314
+ type: Object,
1315
+ required: true
1316
+ } },
1317
+ setup: (props) => () => h(AuditPanel_default, {
1318
+ context: props.context,
1319
+ model
1320
+ })
1321
+ }))
1322
+ });
1323
+ const flags = api.options ?? {};
1324
+ const tests = flags.tests === true && api.context.capabilities.has("tests");
1325
+ const report = flags.report === true && api.context.source.mode === "static";
1326
+ const source = tests || report ? createProjectSource(api, {
1327
+ tests,
1328
+ report
1329
+ }) : void 0;
1330
+ const projectReport = source && createReportLookup(source);
1331
+ api.canvas.addFrameBadge({
1332
+ id: "violations",
1333
+ badge: (context) => violationBadge(model.get(context.frame.key)?.report ?? projectReport?.(context.frame.target))
1334
+ });
1335
+ if (!source) return;
1336
+ api.commands.add({
1337
+ id: "run-all",
1338
+ label: "Run all",
1339
+ icon: "play-filled-alt",
1340
+ available: () => source.get().canRun && !source.get().running,
1341
+ run: () => source.runAll()
1342
+ });
1343
+ api.shell.addPane({
1344
+ id: "issues",
1345
+ primaryCommand: "run-all",
1346
+ label: "Accessibility",
1347
+ icon: "list-checked",
1348
+ header: false,
1349
+ badge: () => source.get().results.filter((result) => result.report?.violationsCount).length || null,
1350
+ component: defineWorkbenchComponent(defineComponent({
1351
+ name: "AccessibilityProject",
1352
+ props: {
1353
+ /** Root workbench scope. */
1354
+ context: {
1355
+ type: Object,
1356
+ required: true
1357
+ } },
1358
+ setup: (props) => () => h(ProjectPanel_default, {
1359
+ context: props.context,
1360
+ source,
1361
+ preferences: api.preferences,
1362
+ model
1363
+ })
1364
+ }))
1365
+ });
1366
+ }
1367
+ });
1368
+ export { client_default as default };