source: frontend/node_modules/axe-core/axe.d.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 18.5 KB
Line 
1// Type definitions for axe-core
2// Project: https://github.com/dequelabs/axe-core
3
4declare namespace axe {
5 type ImpactValue = 'minor' | 'moderate' | 'serious' | 'critical' | null;
6
7 type TagValue = string;
8
9 type ReporterVersion = 'v1' | 'v2' | 'raw' | 'rawEnv' | 'no-passes';
10
11 type RunOnlyType = 'rule' | 'rules' | 'tag' | 'tags';
12
13 type resultGroups = 'inapplicable' | 'passes' | 'incomplete' | 'violations';
14
15 type AriaAttrsType =
16 | 'boolean'
17 | 'nmtoken'
18 | 'mntokens'
19 | 'idref'
20 | 'idrefs'
21 | 'string'
22 | 'decimal'
23 | 'int';
24
25 type AriaRolesType = 'abstract' | 'widget' | 'structure' | 'landmark';
26
27 type DpubRolesType =
28 | 'section'
29 | 'landmark'
30 | 'link'
31 | 'listitem'
32 | 'img'
33 | 'navigation'
34 | 'note'
35 | 'separator'
36 | 'none'
37 | 'sectionhead';
38
39 type HtmlContentTypes =
40 | 'flow'
41 | 'sectioning'
42 | 'heading'
43 | 'phrasing'
44 | 'embedded'
45 | 'interactive';
46
47 // Array of length 2 or greater
48 type MultiArray<T> = [T, T, ...T[]];
49
50 // Selectors within a frame
51 type BaseSelector = string;
52
53 type ShadowDomSelector = MultiArray<BaseSelector>;
54 type CrossTreeSelector = BaseSelector | ShadowDomSelector;
55 type LabelledShadowDomSelector = { fromShadowDom: ShadowDomSelector };
56
57 // Cross-frame selectors
58 type FramesSelector = Array<CrossTreeSelector | LabelledShadowDomSelector>;
59 type UnlabelledFrameSelector = CrossTreeSelector[];
60 type LabelledFramesSelector = { fromFrames: MultiArray<FramesSelector[0]> };
61 /**
62 * @deprecated Use UnlabelledFrameSelector instead
63 */
64 type CrossFrameSelector = UnlabelledFrameSelector;
65
66 // Context options
67 type Selector =
68 | Node
69 | BaseSelector
70 | LabelledShadowDomSelector
71 | LabelledFramesSelector;
72 type SelectorList = Array<Selector | FramesSelector> | NodeList;
73 type ContextProp = Selector | SelectorList;
74 type ContextObject =
75 | {
76 include: ContextProp;
77 exclude?: ContextProp;
78 }
79 | {
80 exclude: ContextProp;
81 include?: ContextProp;
82 };
83 type ContextSpec = ContextProp | ContextObject;
84 /** Synonym to ContextSpec */
85 type ElementContext = ContextSpec;
86
87 type SerialSelector =
88 | BaseSelector
89 | LabelledShadowDomSelector
90 | LabelledFramesSelector;
91 type SerialFrameSelector = SerialSelector | FramesSelector;
92 type SerialSelectorList = Array<SerialFrameSelector>;
93
94 type SerialContextObject =
95 | {
96 include: SerialSelector | SerialSelectorList;
97 exclude?: SerialSelector | SerialSelectorList;
98 }
99 | {
100 exclude: SerialSelector | SerialSelectorList;
101 include?: SerialSelector | SerialSelectorList;
102 };
103
104 interface FrameContextObject {
105 include: UnlabelledFrameSelector[];
106 exclude: UnlabelledFrameSelector[];
107 }
108
109 type RunCallback<T = AxeResults> = (error: Error, results: T) => void;
110
111 interface TestEngine {
112 name: string;
113 version: string;
114 }
115 interface TestRunner {
116 name: string;
117 }
118 interface TestEnvironment {
119 userAgent: string;
120 windowWidth: number;
121 windowHeight: number;
122 orientationAngle?: number;
123 orientationType?: string;
124 }
125 interface RunOnly {
126 type: RunOnlyType;
127 values: TagValue[] | string[];
128 }
129 interface RuleObject {
130 [key: string]: {
131 enabled: boolean;
132 };
133 }
134 interface RunOptions {
135 runOnly?: RunOnly | TagValue[] | string[] | string;
136 rules?: RuleObject;
137 reporter?: ReporterVersion | string;
138 resultTypes?: resultGroups[];
139 selectors?: boolean;
140 ancestry?: boolean;
141 xpath?: boolean;
142 absolutePaths?: boolean;
143 iframes?: boolean;
144 elementRef?: boolean;
145 frameWaitTime?: number;
146 preload?: boolean | PreloadOptions;
147 performanceTimer?: boolean;
148 pingWaitTime?: number;
149 }
150 interface PreloadOptions {
151 assets: string[];
152 timeout?: number;
153 }
154 interface AxeResults extends EnvironmentData {
155 toolOptions: RunOptions;
156 passes: Result[];
157 violations: Result[];
158 incomplete: IncompleteResult[];
159 inapplicable: Result[];
160 }
161 interface Result {
162 description: string;
163 help: string;
164 helpUrl: string;
165 id: string;
166 impact?: ImpactValue;
167 tags: TagValue[];
168 nodes: NodeResult[];
169 }
170 interface IncompleteResult extends Result {
171 error?: Omit<RuleError, 'errorNode'>;
172 }
173 interface NodeResult {
174 html: string;
175 impact?: ImpactValue;
176 target: UnlabelledFrameSelector;
177 xpath?: string[];
178 ancestry?: UnlabelledFrameSelector;
179 any: CheckResult[];
180 all: CheckResult[];
181 none: CheckResult[];
182 failureSummary?: string;
183 element?: HTMLElement;
184 }
185 interface CheckResult {
186 id: string;
187 impact: string;
188 message: string;
189 data: any;
190 relatedNodes?: RelatedNode[];
191 }
192 interface RelatedNode {
193 html: string;
194 target: UnlabelledFrameSelector;
195 xpath?: string[];
196 ancestry?: UnlabelledFrameSelector;
197 element?: HTMLElement;
198 }
199 interface RuleLocale {
200 [key: string]: {
201 description: string;
202 help: string;
203 };
204 }
205 interface CheckMessages {
206 pass: string | { [key: string]: string };
207 fail: string | { [key: string]: string };
208 incomplete?: string | { [key: string]: string };
209 }
210 interface RuleError {
211 name: string;
212 message: string;
213 stack: string;
214 ruleId?: string;
215 method?: string;
216 cause?: SerialError;
217 errorNode?: SerialDqElement;
218 }
219 interface SerialError {
220 message: string;
221 stack: string;
222 name: string;
223 cause?: SerialError;
224 }
225 interface CheckLocale {
226 [key: string]: CheckMessages;
227 }
228 interface Locale {
229 lang?: string;
230 rules?: RuleLocale;
231 checks?: CheckLocale;
232 }
233 interface AriaAttrs {
234 type: AriaAttrsType;
235 values?: string[];
236 allowEmpty?: boolean;
237 global?: boolean;
238 unsupported?: boolean;
239 }
240 interface AriaRoles {
241 type: AriaRolesType | DpubRolesType;
242 requiredContext?: string[];
243 requiredOwned?: string[];
244 requiredAttrs?: string[];
245 allowedAttrs?: string[];
246 nameFromContent?: boolean;
247 unsupported?: boolean;
248 }
249 interface HtmlElmsVariant {
250 contentTypes?: HtmlContentTypes[];
251 allowedRoles: boolean | string[];
252 noAriaAttrs?: boolean;
253 shadowRoot?: boolean;
254 implicitAttrs?: { [key: string]: string };
255 namingMethods?: string[];
256 }
257 interface HtmlElms extends HtmlElmsVariant {
258 variant?: { [key: string]: HtmlElmsVariant };
259 }
260 interface Standards {
261 ariaAttrs?: { [key: string]: AriaAttrs };
262 ariaRoles?: { [key: string]: AriaRoles };
263 htmlElms?: { [key: string]: HtmlElms };
264 cssColors?: { [key: string]: number[] };
265 }
266 interface Spec {
267 branding?: string | Branding;
268 reporter?: ReporterVersion | string | AxeReporter;
269 checks?: Check[];
270 rules?: Rule[];
271 standards?: Standards;
272 locale?: Locale;
273 disableOtherRules?: boolean;
274 axeVersion?: string;
275 noHtml?: boolean;
276 allowedOrigins?: string[];
277 // Deprecated - do not use.
278 ver?: string;
279 }
280 /**
281 * @deprecated Use branding: string instead to set the application key in help URLs
282 */
283 interface Branding {
284 brand?: string;
285 application?: string;
286 }
287 interface CheckHelper {
288 async: () => (result: boolean | undefined | Error) => void;
289 data: (data: unknown) => void;
290 relatedNodes: (nodes: Element[]) => void;
291 }
292 interface AfterResult {
293 id: string;
294 data?: unknown;
295 relatedNodes: SerialDqElement[];
296 result: boolean | undefined;
297 node: SerialDqElement;
298 }
299 interface Check {
300 id: string;
301 evaluate?:
302 | string
303 | ((
304 this: CheckHelper,
305 node: Element,
306 options: unknown,
307 virtualNode: VirtualNode
308 ) => boolean | undefined | void);
309 after?:
310 | string
311 | ((results: AfterResult[], options: unknown) => AfterResult[]);
312 options?: any;
313 matches?: string;
314 enabled?: boolean;
315 metadata?: {
316 impact?: ImpactValue;
317 messages?: CheckMessages;
318 };
319 }
320 interface Rule {
321 id: string;
322 selector?: string;
323 impact?: ImpactValue;
324 excludeHidden?: boolean;
325 enabled?: boolean;
326 pageLevel?: boolean;
327 any?: string[];
328 all?: string[];
329 none?: string[];
330 tags?: string[];
331 matches?: string | ((node: Element, virtualNode: VirtualNode) => boolean);
332 reviewOnFail?: boolean;
333 actIds?: string[];
334 metadata?: Omit<RuleMetadata, 'ruleId' | 'tags' | 'actIds'>;
335 }
336 interface AxePlugin {
337 id: string;
338 run(...args: any[]): any;
339 commands: {
340 id: string;
341 callback(...args: any[]): void;
342 }[];
343 cleanup?(callback: Function): void;
344 }
345 interface RuleMetadata {
346 ruleId: string;
347 description: string;
348 help: string;
349 helpUrl: string;
350 tags: string[];
351 actIds?: string[];
352 }
353 interface SerialDqElement {
354 source: string;
355 nodeIndexes: number[];
356 selector: UnlabelledFrameSelector;
357 xpath: string[];
358 ancestry: UnlabelledFrameSelector;
359 }
360 interface DqElement extends SerialDqElement {
361 element: Element;
362 toJSON(): SerialDqElement;
363 }
364 interface DqElementConstructor {
365 new (elm: Element, options?: { absolutePaths?: boolean }): DqElement;
366 mergeSpecs(
367 childSpec: SerialDqElement,
368 parentSpec: SerialDqElement
369 ): SerialDqElement;
370 }
371 interface PartialRuleResult {
372 id: string;
373 result: 'inapplicable';
374 pageLevel: boolean;
375 impact: null;
376 nodes: Array<Record<string, unknown>>;
377 }
378 interface PartialResult {
379 frames: SerialDqElement[];
380 results: PartialRuleResult[];
381 environmentData?: EnvironmentData;
382 }
383 type PartialResults = Array<PartialResult | null>;
384 interface FrameContext {
385 frameSelector: CrossTreeSelector;
386 frameContext: FrameContextObject;
387 }
388
389 interface RawCheckResult extends Omit<
390 CheckResult,
391 'relatedNodes' | 'impact'
392 > {
393 relatedNodes?: Array<SerialDqElement | DqElement>;
394 impact?: ImpactValue;
395 }
396
397 interface RawNodeResult<T extends 'passed' | 'failed' | 'cantTell'> {
398 node: SerialDqElement | DqElement;
399 any: RawCheckResult[];
400 all: RawCheckResult[];
401 none: RawCheckResult[];
402 impact: ImpactValue | undefined;
403 result: T;
404 }
405
406 interface RawResult extends Omit<Result, 'nodes'> {
407 inapplicable: Array<never>;
408 passes: RawNodeResult<'passed'>[];
409 incomplete: RawNodeResult<'cantTell'>[];
410 violations: RawNodeResult<'failed'>[];
411 pageLevel: boolean;
412 result: 'failed' | 'passed' | 'incomplete' | 'inapplicable';
413 }
414
415 type AxeReporter<T = unknown> = (
416 rawResults: RawResult[],
417 option: RunOptions,
418 resolve: (report: T) => void,
419 reject: (error: Error) => void
420 ) => void;
421
422 interface VirtualNode {
423 actualNode?: Node;
424 shadowId?: string;
425 children?: VirtualNode[];
426 parent?: VirtualNode;
427 attr(attr: string): string | null;
428 hasAttr(attr: string): boolean;
429 props: { [key: string]: unknown };
430 boundingClientRect: DOMRect;
431 }
432
433 type GridCell = VirtualNode[];
434
435 interface Grid {
436 container: VirtualNode | null;
437 cells: unknown; // opaque implementation detail
438 boundaries?: DOMRect;
439 toGridIndex(num: number): number;
440 getCellFromPoint(point: { x: number; y: number }): GridCell;
441 loopGridPosition(
442 gridPosition: DOMRect,
443 callback: (gridCell: GridCell, pos: { row: number; col: number }) => void
444 ): void;
445 getGridPositionOfRect(
446 rect: { top: number; right: number; bottom: number; left: number },
447 margin?: number
448 ): DOMRect;
449 }
450
451 interface CustomNodeSerializer<T = SerialDqElement> {
452 toSpec: (dqElm: DqElement) => T;
453 mergeSpecs: (nodeSpec: T, parentFrameSpec: T) => T;
454 }
455
456 interface NodeSerializer {
457 update: <T>(serializer: CustomNodeSerializer<T>) => void;
458 toSpec: (node: Element | VirtualNode) => SerialDqElement;
459 dqElmToSpec: (
460 dqElm: DqElement | SerialDqElement,
461 options?: RunOptions
462 ) => SerialDqElement;
463 mergeSpecs: (
464 nodeSpec: SerialDqElement,
465 parentFrameSpec: SerialDqElement
466 ) => SerialDqElement;
467 }
468
469 interface Utils {
470 getElementSource: (
471 element: Node | null | undefined,
472 options?: { maxLength?: number; attrLimit?: number }
473 ) => string;
474 getFrameContexts: (
475 context?: ElementContext,
476 options?: RunOptions
477 ) => FrameContext[];
478 shadowSelect: (selector: CrossTreeSelector) => Element | null;
479 shadowSelectAll: (selector: CrossTreeSelector) => Element[];
480 getStandards(): Required<Standards>;
481 isContextSpec: (context: unknown) => context is ContextSpec;
482 isContextObject: (context: unknown) => context is ContextObject;
483 isContextProp: (context: unknown) => context is ContextProp;
484 isLabelledFramesSelector: (
485 selector: unknown
486 ) => selector is LabelledFramesSelector;
487 isLabelledShadowDomSelector: (
488 selector: unknown
489 ) => selector is LabelledShadowDomSelector;
490 RuleError: new (options: {
491 error: Error;
492 ruleId?: string;
493 method?: string;
494 errorNode?: SerialDqElement;
495 }) => RuleError;
496 serializeError: (error: Error) => SerialError;
497 DqElement: DqElementConstructor;
498 uuid: (
499 options?: { random?: Uint8Array | Array<number> },
500 buf?: Uint8Array | Array<number>,
501 offset?: number
502 ) => string | Uint8Array | Array<number>;
503 nodeSerializer: NodeSerializer;
504 }
505
506 interface Aria {
507 getRoleType: (role: string | Element | VirtualNode | null) => string | null;
508 }
509
510 interface Dom {
511 isFocusable: (node: Element | VirtualNode) => boolean;
512 isNativelyFocusable: (node: Element | VirtualNode) => boolean;
513 getNodeGrid: (node: Node | VirtualNode) => Grid;
514 }
515
516 type AccessibleTextOptions = {
517 inControlContext?: boolean;
518 inLabelledByContext?: boolean;
519 };
520
521 interface Text {
522 accessibleText: (
523 element: Element,
524 options?: AccessibleTextOptions
525 ) => string;
526 }
527
528 interface Commons {
529 aria: Aria;
530 dom: Dom;
531 text: Text;
532 }
533
534 interface EnvironmentData {
535 testEngine: TestEngine;
536 testRunner: TestRunner;
537 testEnvironment: TestEnvironment;
538 url: string;
539 timestamp: string;
540 }
541
542 let version: string;
543 let plugins: any;
544 let utils: Utils;
545 let commons: Commons;
546
547 /**
548 * Source string to use as an injected script in Selenium
549 */
550 let source: string;
551
552 /**
553 * Object for axe Results
554 */
555 var AxeResults: AxeResults;
556
557 /**
558 * Runs a number of rules against the provided HTML page and returns the resulting issue list
559 *
560 * @param {ElementContext} context Optional The `Context` specification object @see Context
561 * @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
562 * @param {RunCallback} callback Optional The function to invoke when analysis is complete.
563 * @returns {Promise<AxeResults>|void} If the callback was not defined, axe will return a Promise.
564 */
565 function run<T = AxeResults>(context?: ElementContext): Promise<T>;
566 function run<T = AxeResults>(options: RunOptions): Promise<T>;
567 function run<T = AxeResults>(
568 callback: (error: Error, results: T) => void
569 ): void;
570 function run<T = AxeResults>(
571 context: ElementContext,
572 callback: RunCallback<T>
573 ): void;
574 function run<T = AxeResults>(
575 options: RunOptions,
576 callback: RunCallback<T>
577 ): void;
578 function run<T = AxeResults>(
579 context: ElementContext,
580 options: RunOptions
581 ): Promise<T>;
582 function run<T = AxeResults>(
583 context: ElementContext,
584 options: RunOptions,
585 callback: RunCallback<T>
586 ): void;
587
588 /**
589 * Method for configuring the data format used by axe. Helpful for adding new
590 * rules, which must be registered with the library to execute.
591 * @param {Spec} Spec Object with valid `branding`, `reporter`, `checks` and `rules` data
592 */
593 function configure(spec: Spec): void;
594
595 /**
596 * Run axe in the current window only
597 * @param {ElementContext} context Optional The `Context` specification object @see Context
598 * @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
599 * @returns {Promise<PartialResult>} Partial result, for use in axe.finishRun.
600 */
601 function runPartial(
602 context: ElementContext,
603 options: RunOptions
604 ): Promise<PartialResult>;
605
606 /**
607 * Create a report from axe.runPartial results
608 * @param {PartialResult[]} partialResults Results from axe.runPartial, calls in different frames on the page.
609 * @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
610 */
611 function finishRun(
612 partialResults: PartialResults,
613 options: RunOptions
614 ): Promise<AxeResults>;
615
616 /**
617 * Searches and returns rules that contain a tag in the list of tags.
618 * @param {Array} tags Optional array of tags
619 * @return {Array} Array of rules
620 */
621 function getRules(tags?: string[]): RuleMetadata[];
622
623 /**
624 * Restores the default axe configuration
625 */
626 function reset(): void;
627
628 /**
629 * Function to register a plugin configuration in document and its subframes
630 * @param {Object} plugin A plugin configuration object
631 */
632 function registerPlugin(plugin: AxePlugin): void;
633
634 /**
635 * Function to clean up plugin configuration in document and its subframes
636 */
637 function cleanup(): void;
638
639 /**
640 * Set up alternative frame communication
641 */
642 function frameMessenger(frameMessenger: FrameMessenger): void;
643
644 /**
645 * Setup axe-core so axe.common functions can work properly.
646 */
647 function setup(node?: Element | Document): VirtualNode;
648
649 /**
650 * Clean up axe-core tree and caches. `axe.run` will call this function at the end of the run so there's no need to call it yourself afterwards.
651 */
652 function teardown(): void;
653
654 /**
655 * Check if a reporter is registered
656 */
657 function hasReporter(reporterName: string): boolean;
658
659 /**
660 * Get a reporter based the name it is registered with
661 */
662 function getReporter<T>(reporterName: string): AxeReporter<T>;
663
664 /**
665 * Register a new reporter, optionally setting it as the default
666 */
667 function addReporter<T>(
668 reporterName: string,
669 reporter: AxeReporter<T>,
670 isDefault?: boolean
671 ): void;
672
673 // axe.frameMessenger
674 type FrameMessenger = {
675 open: (topicHandler: TopicHandler) => Close | void;
676 post: (
677 frameWindow: Window,
678 data: TopicData,
679 replyHandler: ReplyHandler
680 ) => boolean | void;
681 };
682 type Close = Function;
683 type TopicHandler = (data: TopicData, responder: Responder) => void;
684 type ReplyHandler = (
685 message: any | Error,
686 keepalive: boolean,
687 responder: Responder
688 ) => void;
689 type Responder = (
690 message: any | Error,
691 keepalive?: boolean,
692 replyHandler?: ReplyHandler
693 ) => void;
694 type TopicData = { topic: string } & ReplyData;
695 type ReplyData = { channelId: string; message: any; keepalive: boolean };
696}
697
698export = axe;
Note: See TracBrowser for help on using the repository browser.