@d-zero/a11y-check-core 0.2.0 → 0.3.0

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.
@@ -1,2 +1,6 @@
1
1
  import type { Violation } from './types.js';
2
+ /**
3
+ *
4
+ * @param results
5
+ */
2
6
  export declare function cleanResults(results: readonly Violation[]): Violation[];
@@ -1,6 +1,10 @@
1
1
  import { hash } from '@d-zero/shared/hash';
2
2
  import { pathComparator } from '@d-zero/shared/sort/path';
3
3
  import { scNumberComparator } from './sc-number-comparator.js';
4
+ /**
5
+ *
6
+ * @param results
7
+ */
4
8
  export function cleanResults(results) {
5
9
  const hashMap = new Map();
6
10
  for (const result of results) {
@@ -5,4 +5,8 @@ export declare enum ColorContrastError {
5
5
  FOREGROUND_COLOR_HAS_ALPHA = 2,
6
6
  BACKGROUND_COLOR_HAS_ALPHA = 3
7
7
  }
8
+ /**
9
+ *
10
+ * @param style
11
+ */
8
12
  export declare function colorContrastCheck(style: Style): ColorContrastError | ColorContrast;
@@ -9,6 +9,10 @@ export var ColorContrastError;
9
9
  ColorContrastError[ColorContrastError["FOREGROUND_COLOR_HAS_ALPHA"] = 2] = "FOREGROUND_COLOR_HAS_ALPHA";
10
10
  ColorContrastError[ColorContrastError["BACKGROUND_COLOR_HAS_ALPHA"] = 3] = "BACKGROUND_COLOR_HAS_ALPHA";
11
11
  })(ColorContrastError || (ColorContrastError = {}));
12
+ /**
13
+ *
14
+ * @param style
15
+ */
12
16
  export function colorContrastCheck(style) {
13
17
  const foreground = colorFnToHex(style.color);
14
18
  if (!foreground) {
package/dist/color.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import type { Color } from './types.js';
2
+ /**
3
+ *
4
+ * @param colorFn
5
+ */
2
6
  export declare function colorFnToHex(colorFn: string | null): Color | null;
package/dist/color.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * @param colorFn
4
+ */
1
5
  export function colorFnToHex(colorFn) {
2
6
  if (!colorFn) {
3
7
  return null;
@@ -1,2 +1,6 @@
1
1
  import type { ScenarioCreator } from './types.js';
2
+ /**
3
+ *
4
+ * @param creator
5
+ */
2
6
  export declare function createScenario<O>(creator: ScenarioCreator<O>): ScenarioCreator<O>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * @param creator
4
+ */
1
5
  export function createScenario(creator) {
2
6
  return creator;
3
7
  }
@@ -1 +1,6 @@
1
+ /**
2
+ *
3
+ * @param a
4
+ * @param b
5
+ */
1
6
  export declare function scNumberComparator(a: string | null, b: string | null): number;
@@ -1,3 +1,8 @@
1
+ /**
2
+ *
3
+ * @param a
4
+ * @param b
5
+ */
1
6
  export function scNumberComparator(a, b) {
2
7
  if (a === b) {
3
8
  return 0;
@@ -1,4 +1,10 @@
1
1
  import type { CoreOptions, Result, Scenario, ScenarioRunnerOptions } from './types.js';
2
+ /**
3
+ *
4
+ * @param urlList
5
+ * @param scenarios
6
+ * @param options
7
+ */
2
8
  export declare function scenarioRunner<O>(urlList: readonly (string | {
3
9
  id: string | null;
4
10
  url: string;
@@ -4,6 +4,12 @@ import { Cache } from '@d-zero/shared/cache';
4
4
  import { delay } from '@d-zero/shared/delay';
5
5
  import c from 'ansi-colors';
6
6
  import { cleanResults } from './clean-results.js';
7
+ /**
8
+ *
9
+ * @param urlList
10
+ * @param scenarios
11
+ * @param options
12
+ */
7
13
  export async function scenarioRunner(urlList, scenarios, options) {
8
14
  const cache = new Cache('a11y-check/run-puppeteer', options?.cacheDir);
9
15
  const hooks = options?.hooks;
package/dist/types.d.ts CHANGED
@@ -13,7 +13,6 @@ export type ScenarioRunnerOptions = DealOptions & {
13
13
  export type ScenarioCreator<O> = (options?: O) => Scenario;
14
14
  export type Scenario = {
15
15
  id: string;
16
- config?: {};
17
16
  exec: ScenarioExecutor;
18
17
  analyze?: ScenarioAnalyzer;
19
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/a11y-check-core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Accessibility Checker (Core Module)",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",
@@ -24,15 +24,15 @@
24
24
  "clean": "tsc --build --clean"
25
25
  },
26
26
  "dependencies": {
27
- "@d-zero/puppeteer-dealer": "0.2.0",
28
- "@d-zero/shared": "0.6.0",
27
+ "@d-zero/puppeteer-dealer": "0.3.0",
28
+ "@d-zero/shared": "0.7.0",
29
29
  "ansi-colors": "4.1.3",
30
30
  "color-contrast-checker": "2.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@d-zero/dealer": "1.2.0",
34
- "@d-zero/puppeteer-page": "0.2.0",
35
- "@d-zero/puppeteer-page-scan": "2.0.0"
33
+ "@d-zero/dealer": "1.3.0",
34
+ "@d-zero/puppeteer-page": "0.3.0",
35
+ "@d-zero/puppeteer-page-scan": "3.0.0"
36
36
  },
37
- "gitHead": "1eb1c03400580040119121e11ffb33acd876fe1b"
37
+ "gitHead": "e4fd17857e31022d121527b00fd7f009dbdb2142"
38
38
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +0,0 @@
1
- import { test, expect } from 'vitest';
2
- import { colorContrastCheck, ColorContrastError } from './color-contrast.js';
3
- test('#000 vs #FFF', () => {
4
- expect(colorContrastCheck({
5
- color: 'rgb(0, 0, 0)',
6
- backgroundColor: 'rgb(255, 255, 255)',
7
- backgroundImage: '',
8
- closestBackgroundColor: null,
9
- closestBackgroundImage: null,
10
- })).toStrictEqual({
11
- foreground: {
12
- a: 1,
13
- b: 0,
14
- g: 0,
15
- hex: '#000000',
16
- hexA: '#000000FF',
17
- r: 0,
18
- },
19
- background: {
20
- a: 1,
21
- b: 255,
22
- g: 255,
23
- hex: '#FFFFFF',
24
- hexA: '#FFFFFFFF',
25
- r: 255,
26
- },
27
- ratio: 21,
28
- ratioText: '21:1',
29
- AA: true,
30
- AAA: true,
31
- });
32
- });
33
- test('has alpha channel', () => {
34
- expect(colorContrastCheck({
35
- color: 'rgba(0, 0, 0, 0.5)',
36
- backgroundColor: 'rgb(255, 255, 255)',
37
- backgroundImage: '',
38
- closestBackgroundColor: null,
39
- closestBackgroundImage: null,
40
- })).toBe(ColorContrastError.FOREGROUND_COLOR_HAS_ALPHA);
41
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { test, expect } from 'vitest';
2
- import { scNumberComparator } from './sc-number-comparator.js';
3
- test('scNumberComparator', () => {
4
- expect([
5
- //
6
- '1.2.3',
7
- '1.1.1',
8
- '1.2.1',
9
- '1.1.2',
10
- null,
11
- '1.1.3',
12
- ].toSorted(scNumberComparator)).toStrictEqual([
13
- //
14
- '1.1.1',
15
- '1.1.2',
16
- '1.1.3',
17
- '1.2.1',
18
- '1.2.3',
19
- null,
20
- ]);
21
- });