accented 0.0.1-dev.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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/package.json +29 -0
- package/src/accented.js +31 -0
- package/src/task-queue.js +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Pavel Pomerantsev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Accented
|
|
2
|
+
|
|
3
|
+
Continuous accessibility testing and issue highlighting for web development
|
|
4
|
+
|
|
5
|
+
This is a work in progress.
|
|
6
|
+
|
|
7
|
+
## High-level
|
|
8
|
+
|
|
9
|
+
* Uses axe-core.
|
|
10
|
+
|
|
11
|
+
## Running locally
|
|
12
|
+
|
|
13
|
+
* `npx http-server`
|
|
14
|
+
|
|
15
|
+
## Usage notes
|
|
16
|
+
|
|
17
|
+
* On a page with many elements, axe-core may be slow. We may deal with this in two ways:
|
|
18
|
+
* First, we'll ensure that we only scan the elements that changed.
|
|
19
|
+
* Second, we'll see if it's possible to modify axe-core so it yields execution at certain intervals.
|
|
20
|
+
|
|
21
|
+
## Development notes
|
|
22
|
+
|
|
23
|
+
* Placeholder favicon generated with https://favicon.io/favicon-generator/. I immediately forgot what the font was, but I won't relese this like this anyway.
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "accented",
|
|
3
|
+
"version": "0.0.1-dev.0",
|
|
4
|
+
"description": "Continuous accessibility testing and issue highlighting for web development",
|
|
5
|
+
"main": "src/accented.js",
|
|
6
|
+
"files": ["src"],
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/pomerantsev/accented.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"accessibility",
|
|
16
|
+
"a11y",
|
|
17
|
+
"axe",
|
|
18
|
+
"axe-core"
|
|
19
|
+
],
|
|
20
|
+
"author": "Pavel Pomerantsev",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/pomerantsev/accented/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/pomerantsev/accented#readme",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"axe-core": "^4.10.2"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/accented.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axe from 'axe-core';
|
|
2
|
+
import TaskQueue from './task-queue.js';
|
|
3
|
+
|
|
4
|
+
export default function accented() {
|
|
5
|
+
const taskQueue = new TaskQueue(async () => {
|
|
6
|
+
performance.mark('axe-start');
|
|
7
|
+
|
|
8
|
+
const result = await axe.run();
|
|
9
|
+
|
|
10
|
+
const axeMeasure = performance.measure('axe', 'axe-start');
|
|
11
|
+
|
|
12
|
+
console.log('Result:', result);
|
|
13
|
+
console.log('Axe run duration:', Math.round(axeMeasure.duration), 'ms');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
taskQueue.add(document);
|
|
17
|
+
|
|
18
|
+
const mutationObserver = new MutationObserver(mutationList => {
|
|
19
|
+
// TODO: filter out irrelevant mutations
|
|
20
|
+
for (const mutationRecord of mutationList) {
|
|
21
|
+
taskQueue.add(mutationRecord.target);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// TODO: read more about the params and decide which ones we need.
|
|
26
|
+
mutationObserver.observe(document, {
|
|
27
|
+
subtree: true,
|
|
28
|
+
childList: true,
|
|
29
|
+
attributes: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// TODO: add generic typing
|
|
2
|
+
export default class TaskQueue {
|
|
3
|
+
items = new Set();
|
|
4
|
+
|
|
5
|
+
idleCallbackId = null;
|
|
6
|
+
|
|
7
|
+
asyncCallback = null;
|
|
8
|
+
|
|
9
|
+
constructor(asyncCallback) {
|
|
10
|
+
this.asyncCallback = asyncCallback;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// TODO: test all the asynchronicity
|
|
14
|
+
|
|
15
|
+
#scheduleRun() {
|
|
16
|
+
if (this.idleCallbackId !== null || this.items.size === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.idleCallbackId = requestIdleCallback(() => this.#run());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async #run() {
|
|
24
|
+
this.items.clear();
|
|
25
|
+
|
|
26
|
+
await this.asyncCallback();
|
|
27
|
+
|
|
28
|
+
this.idleCallbackId = null;
|
|
29
|
+
|
|
30
|
+
this.#scheduleRun();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
add(item) {
|
|
34
|
+
this.items.add(item);
|
|
35
|
+
this.#scheduleRun();
|
|
36
|
+
}
|
|
37
|
+
}
|