web 3d图形渲染器

311 lines
7.4 KiB

  1. // Type definitions for axe-core
  2. // Project: https://github.com/dequelabs/axe-core
  3. // Definitions by: Marcy Sutton <https://github.com/marcysutton>
  4. declare namespace axe {
  5. type ImpactValue = 'minor' | 'moderate' | 'serious' | 'critical' | null;
  6. type TagValue = string;
  7. type ReporterVersion = 'v1' | 'v2' | 'raw' | 'raw-env' | 'no-passes';
  8. type RunOnlyType = 'rule' | 'rules' | 'tag' | 'tags';
  9. type resultGroups = 'inapplicable' | 'passes' | 'incomplete' | 'violations';
  10. type AriaAttrsType =
  11. | 'boolean'
  12. | 'nmtoken'
  13. | 'mntokens'
  14. | 'idref'
  15. | 'idrefs'
  16. | 'string'
  17. | 'decimal'
  18. | 'int';
  19. type AriaRolesType = 'abstract' | 'widget' | 'structure' | 'landmark';
  20. type DpubRolesType =
  21. | 'section'
  22. | 'landmark'
  23. | 'link'
  24. | 'listitem'
  25. | 'img'
  26. | 'navigation'
  27. | 'note'
  28. | 'separator'
  29. | 'none'
  30. | 'sectionhead';
  31. type HtmlContentTypes =
  32. | 'flow'
  33. | 'sectioning'
  34. | 'heading'
  35. | 'phrasing'
  36. | 'embedded'
  37. | 'interactive';
  38. type ContextObject = {
  39. include?: string[] | string[][];
  40. exclude?: string[] | string[][];
  41. };
  42. type RunCallback = (error: Error, results: AxeResults) => void;
  43. type ElementContext = Node | string | ContextObject;
  44. interface TestEngine {
  45. name: string;
  46. version: string;
  47. }
  48. interface TestRunner {
  49. name: string;
  50. }
  51. interface TestEnvironment {
  52. userAgent: string;
  53. windowWidth: number;
  54. windowHeight: number;
  55. orientationAngle?: number;
  56. orientationType?: string;
  57. }
  58. interface RunOnly {
  59. type: RunOnlyType;
  60. values: TagValue[] | string[];
  61. }
  62. interface RuleObject {
  63. [key: string]: {
  64. enabled: boolean;
  65. };
  66. }
  67. interface RunOptions {
  68. runOnly?: RunOnly | TagValue[] | string[];
  69. rules?: RuleObject;
  70. reporter?: ReporterVersion;
  71. resultTypes?: resultGroups[];
  72. selectors?: boolean;
  73. ancestry?: boolean;
  74. xpath?: boolean;
  75. absolutePaths?: boolean;
  76. iframes?: boolean;
  77. elementRef?: boolean;
  78. frameWaitTime?: number;
  79. preload?: boolean;
  80. performanceTimer?: boolean;
  81. }
  82. interface AxeResults {
  83. toolOptions: RunOptions;
  84. testEngine: TestEngine;
  85. testRunner: TestRunner;
  86. testEnvironment: TestEnvironment;
  87. url: string;
  88. timestamp: string;
  89. passes: Result[];
  90. violations: Result[];
  91. incomplete: Result[];
  92. inapplicable: Result[];
  93. }
  94. interface Result {
  95. description: string;
  96. help: string;
  97. helpUrl: string;
  98. id: string;
  99. impact?: ImpactValue;
  100. tags: TagValue[];
  101. nodes: NodeResult[];
  102. }
  103. interface NodeResult {
  104. html: string;
  105. impact?: ImpactValue;
  106. target: string[];
  107. xpath?: string[];
  108. ancestry?: string[];
  109. any: CheckResult[];
  110. all: CheckResult[];
  111. none: CheckResult[];
  112. failureSummary?: string;
  113. element?: HTMLElement;
  114. }
  115. interface CheckResult {
  116. id: string;
  117. impact: string;
  118. message: string;
  119. data: any;
  120. relatedNodes?: RelatedNode[];
  121. }
  122. interface RelatedNode {
  123. target: string[];
  124. html: string;
  125. }
  126. interface RuleLocale {
  127. [key: string]: {
  128. description: string;
  129. help: string;
  130. };
  131. }
  132. interface CheckLocale {
  133. [key: string]: {
  134. pass: string | { [key: string]: string };
  135. fail: string | { [key: string]: string };
  136. incomplete: string | { [key: string]: string };
  137. };
  138. }
  139. interface Locale {
  140. lang?: string;
  141. rules?: RuleLocale;
  142. checks?: CheckLocale;
  143. }
  144. interface AriaAttrs {
  145. type: AriaAttrsType;
  146. values?: string[];
  147. allowEmpty?: boolean;
  148. global?: boolean;
  149. unsupported?: boolean;
  150. }
  151. interface AriaRoles {
  152. type: AriaRolesType | DpubRolesType;
  153. requiredContext?: string[];
  154. requiredOwned?: string[];
  155. requiredAttrs?: string[];
  156. allowedAttrs?: string[];
  157. nameFromContent?: boolean;
  158. unsupported?: boolean;
  159. }
  160. interface HtmlElmsVariant {
  161. contentTypes?: HtmlContentTypes[];
  162. allowedRoles: boolean | string[];
  163. noAriaAttrs?: boolean;
  164. shadowRoot?: boolean;
  165. implicitAttrs?: { [key: string]: string };
  166. namingMethods?: string[];
  167. }
  168. interface HtmlElms extends HtmlElmsVariant {
  169. variant?: { [key: string]: HtmlElmsVariant };
  170. }
  171. interface Standards {
  172. ariaAttrs?: { [key: string]: AriaAttrs };
  173. ariaRoles?: { [key: string]: AriaRoles };
  174. htmlElms?: { [key: string]: HtmlElms };
  175. cssColors?: { [key: string]: number[] };
  176. }
  177. interface Spec {
  178. branding?: {
  179. brand?: string;
  180. application?: string;
  181. };
  182. reporter?: ReporterVersion;
  183. checks?: Check[];
  184. rules?: Rule[];
  185. standards?: Standards;
  186. locale?: Locale;
  187. disableOtherRules?: boolean;
  188. axeVersion?: string;
  189. noHtml?: boolean;
  190. // Deprecated - do not use.
  191. ver?: string;
  192. }
  193. interface Check {
  194. id: string;
  195. evaluate: Function | string;
  196. after?: Function | string;
  197. options?: any;
  198. matches?: string;
  199. enabled?: boolean;
  200. }
  201. interface Rule {
  202. id: string;
  203. selector?: string;
  204. impact?: ImpactValue;
  205. excludeHidden?: boolean;
  206. enabled?: boolean;
  207. pageLevel?: boolean;
  208. any?: string[];
  209. all?: string[];
  210. none?: string[];
  211. tags?: string[];
  212. matches?: string;
  213. }
  214. interface AxePlugin {
  215. id: string;
  216. run(...args: any[]): any;
  217. commands: {
  218. id: string;
  219. callback(...args: any[]): void;
  220. }[];
  221. cleanup?(callback: Function): void;
  222. }
  223. interface RuleMetadata {
  224. ruleId: string;
  225. description: string;
  226. help: string;
  227. helpUrl: string;
  228. tags: string[];
  229. }
  230. let version: string;
  231. let plugins: any;
  232. /**
  233. * Source string to use as an injected script in Selenium
  234. */
  235. let source: string;
  236. /**
  237. * Object for axe Results
  238. */
  239. var AxeResults: AxeResults;
  240. /**
  241. * Runs a number of rules against the provided HTML page and returns the resulting issue list
  242. *
  243. * @param {ElementContext} context Optional The `Context` specification object @see Context
  244. * @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
  245. * @param {RunCallback} callback Optional The function to invoke when analysis is complete.
  246. * @returns {Promise<AxeResults>|void} If the callback was not defined, axe will return a Promise.
  247. */
  248. function run(context?: ElementContext): Promise<AxeResults>;
  249. function run(options: RunOptions): Promise<AxeResults>;
  250. function run(callback: (error: Error, results: AxeResults) => void): void;
  251. function run(context: ElementContext, callback: RunCallback): void;
  252. function run(options: RunOptions, callback: RunCallback): void;
  253. function run(
  254. context: ElementContext,
  255. options: RunOptions
  256. ): Promise<AxeResults>;
  257. function run(
  258. context: ElementContext,
  259. options: RunOptions,
  260. callback: RunCallback
  261. ): void;
  262. /**
  263. * Method for configuring the data format used by axe. Helpful for adding new
  264. * rules, which must be registered with the library to execute.
  265. * @param {Spec} Spec Object with valid `branding`, `reporter`, `checks` and `rules` data
  266. */
  267. function configure(spec: Spec): void;
  268. /**
  269. * Searches and returns rules that contain a tag in the list of tags.
  270. * @param {Array} tags Optional array of tags
  271. * @return {Array} Array of rules
  272. */
  273. function getRules(tags?: string[]): RuleMetadata[];
  274. /**
  275. * Restores the default axe configuration
  276. */
  277. function reset(): void;
  278. /**
  279. * Function to register a plugin configuration in document and its subframes
  280. * @param {Object} plugin A plugin configuration object
  281. */
  282. function registerPlugin(plugin: AxePlugin): void;
  283. /**
  284. * Function to clean up plugin configuration in document and its subframes
  285. */
  286. function cleanup(): void;
  287. }
  288. export = axe;