@holmdigital/engine 1.4.11 → 2.0.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 CHANGED
@@ -1,59 +1,59 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Holm Digital AB
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.
22
-
23
- ================================================================================
24
-
25
- THIRD PARTY NOTICES
26
-
27
- This project includes code or libraries from third parties.
28
-
29
- 1. axe-core
30
- License: Mozilla Public License 2.0 (MPL-2.0)
31
- Source: https://github.com/dequelabs/axe-core
32
-
33
- This software is used unmodified as a dependency.
34
- The Source Code Form of axe-core is subject to the terms of the Mozilla Public License, v. 2.0.
35
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
36
-
37
- 2. puppeteer
38
- License: Apache License 2.0
39
- Source: https://github.com/puppeteer/puppeteer
40
-
41
- Licensed under the Apache License, Version 2.0 (the "License");
42
- you may not use this file except in compliance with the License.
43
- You may obtain a copy of the License at
44
-
45
- http://www.apache.org/licenses/LICENSE-2.0
46
-
47
- Unless required by applicable law or agreed to in writing, software
48
- distributed under the License is distributed on an "AS IS" BASIS,
49
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
- See the License for the specific language governing permissions and
51
- limitations under the License.
52
-
53
- 3. React & ReactDOM
54
- License: MIT
55
- Source: https://github.com/facebook/react
56
-
57
- 4. Vite
58
- License: MIT
59
- Source: https://github.com/vitejs/vite
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Holm Digital AB
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.
22
+
23
+ ================================================================================
24
+
25
+ THIRD PARTY NOTICES
26
+
27
+ This project includes code or libraries from third parties.
28
+
29
+ 1. axe-core
30
+ License: Mozilla Public License 2.0 (MPL-2.0)
31
+ Source: https://github.com/dequelabs/axe-core
32
+
33
+ This software is used unmodified as a dependency.
34
+ The Source Code Form of axe-core is subject to the terms of the Mozilla Public License, v. 2.0.
35
+ If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
36
+
37
+ 2. puppeteer
38
+ License: Apache License 2.0
39
+ Source: https://github.com/puppeteer/puppeteer
40
+
41
+ Licensed under the Apache License, Version 2.0 (the "License");
42
+ you may not use this file except in compliance with the License.
43
+ You may obtain a copy of the License at
44
+
45
+ http://www.apache.org/licenses/LICENSE-2.0
46
+
47
+ Unless required by applicable law or agreed to in writing, software
48
+ distributed under the License is distributed on an "AS IS" BASIS,
49
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
+ See the License for the specific language governing permissions and
51
+ limitations under the License.
52
+
53
+ 3. React & ReactDOM
54
+ License: MIT
55
+ Source: https://github.com/facebook/react
56
+
57
+ 4. Vite
58
+ License: MIT
59
+ Source: https://github.com/vitejs/vite
package/README.md CHANGED
@@ -1,158 +1,198 @@
1
- # @holmdigital/engine
2
-
3
- [![npm version](https://img.shields.io/npm/v/@holmdigital/engine.svg)](https://www.npmjs.com/package/@holmdigital/engine)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)
6
- [![Downloads](https://img.shields.io/npm/dm/@holmdigital/engine.svg)](https://www.npmjs.com/package/@holmdigital/engine)
7
-
8
- > Regulatory accessibility test engine with Virtual DOM, Shadow DOM support, and built-in legal compliance reporting.
9
-
10
- ## Why this package?
11
-
12
- Most accessibility tools give you technical errors (e.g., "Color contrast must be 4.5:1"). This engine bridges the gap between **technical code validation** (using `axe-core`) and **legal compliance** (EN 301 549, Section 508, DOS-lagen).
13
-
14
- It handles the heavy lifting of:
15
- 1. **Mapping** technical failures to specific legal clauses.
16
- 2. **Validating** HTML structure to ensure test accuracy.
17
- 3. **Reporting** in multiple languages (EN, SV, NL, DE, FR, ES) for non-technical stakeholders.
18
-
19
- ## Features
20
-
21
- - **Regulatory Mapping**: Maps technical failures to EU laws (EN 301 549, EAA).
22
- - **HTML Structure Validation**: Built-in `html-validate` checks to prevent false positives/negatives.
23
- - **Internationalization (i18n)**: Supports English (`en`), Swedish (`sv`), German (`de`), French (`fr`), Spanish (`es`), and Dutch (`nl`).
24
- - **Configurable Severity Threshold**: Fail CI only on critical/high issues (configurable).
25
- - **Rich Metadata**: Includes scan duration, page title, language, and version info.
26
- - **Pseudo-Automation**: Automatically generates Playwright/Puppeteer test scripts for manual verification steps.
27
- - **PDF Reporting**: Generates beautiful, compliant PDF reports with severity-sorted violations, HTML error counts, and `@HolmDigital/engine` branding.
28
- - **TypeScript**: Written in TypeScript with full type definitions included.
29
-
30
- ## Installation
31
-
32
- ```bash
33
- npm install @holmdigital/engine
34
- ```
35
-
36
- ## CLI Usage
37
-
38
- ```bash
39
- npx hd-a11y-scan <url> [options]
40
- ```
41
-
42
- **Options:**
43
- | Option | Description |
44
- |--------|-------------|
45
- | `--lang <code>` | Language code (`en`, `sv`, `de`, `fr`, `es`, `nl`, `en-us`, `en-gb`) |
46
- | `--threshold <level>` | Severity threshold for compliance (`critical`, `high`, `medium`, `low`). Default: `high` |
47
- | `--ci` | Run in CI mode (exit code 1 on failure) |
48
- | `--json` | Output results as JSON |
49
- | `--pdf <path>` | Generate a PDF report |
50
- | `--viewport <size>` | Set viewport size (`mobile`, `tablet`, `desktop`, or custom `1024x768`) |
51
- | `--generate-tests` | Generate Pseudo-Automation tests |
52
- | `--invalid-https-cert` | Allow scanning sites with invalid/self-signed HTTPS certificates ⚠️ |
53
- | `--api-key <key>` | API Key for HolmDigital Cloud |
54
- | `--cloud-url <url>` | Custom Cloud API Endpoint (default: cloud.holmdigital.se) |
55
-
56
- ### 🏆 Accessibility Badge
57
- If your site achieves a **100% score**, the CLI will generate a [Shields.io](https://shields.io/) badge that you can add to your project's README:
58
-
59
- ![Accessibility Status: 100% Compliant](https://img.shields.io/badge/HolmDigital_Engine-100%25-00703C?style=flat-square)
60
-
61
- The badge uses accessible colors (AAA compliant contrast) and is included in both the CLI output and the HTML report.
62
-
63
- > **⚠️ Security Note:** The `--invalid-https-cert` flag should only be used in trusted environments (local dev, staging). It disables certificate validation and is not recommended for production. *(Contributed by [@FerdiStro](https://github.com/FerdiStro))*
64
-
65
- **Example:**
66
- ```bash
67
- # Fail only on critical issues in CI
68
- npx hd-a11y-scan https://example.com --ci --threshold critical
69
-
70
- # Full JSON output with metadata
71
- npx hd-a11y-scan https://example.com --json
72
- ```
73
-
74
- ## JSON Output
75
-
76
- ```json
77
- {
78
- "url": "https://example.com",
79
- "timestamp": "2026-01-13T17:05:11.749Z",
80
- "metadata": {
81
- "engineVersion": "1.4.6",
82
- "axeCoreVersion": "4.10.2",
83
- "standardsVersion": "1.2.2",
84
- "scanDuration": 2891,
85
- "pageTitle": "Example Domain",
86
- "pageLanguage": "en"
87
- },
88
- "stats": {
89
- "passed": 13,
90
- "critical": 0,
91
- "high": 0,
92
- "medium": 2,
93
- "low": 0,
94
- "total": 2
95
- },
96
- "score": 90,
97
- "complianceStatus": "PASS"
98
- }
99
- ```
100
-
101
- ## Severity Threshold
102
-
103
- The `--threshold` flag controls when `complianceStatus` becomes `FAIL`:
104
-
105
- | Threshold | Fails on |
106
- |-----------|----------|
107
- | `critical` | Only critical violations |
108
- | `high` (default) | Critical + high violations |
109
- | `medium` | Critical + high + medium violations |
110
- | `low` | Any violation |
111
-
112
- **Why this matters for CI/CD:**
113
-
114
- ```bash
115
- # Strict: Block deployment on any serious issue
116
- npx hd-a11y-scan https://staging.example.com --ci --threshold high
117
-
118
- # Lenient: Only block on critical issues (like missing alt text)
119
- npx hd-a11y-scan https://staging.example.com --ci --threshold critical
120
- ```
121
-
122
- Medium violations (like missing `<main>` landmark) won't fail your CI by default, but are still reported for awareness.
123
-
124
- ## Metadata Fields
125
-
126
- | Field | Description |
127
- |-------|-------------|
128
- | `engineVersion` | Version of @holmdigital/engine |
129
- | `axeCoreVersion` | Version of axe-core used |
130
- | `standardsVersion` | Version of @holmdigital/standards database |
131
- | `scanDuration` | Scan time in milliseconds |
132
- | `pageTitle` | HTML `<title>` of scanned page |
133
- | `pageLanguage` | `lang` attribute of `<html>` |
134
- | `stats.passed` | Number of accessibility checks that passed |
135
-
136
-
137
- ## Programmatic Usage
138
-
139
- ```typescript
140
- import { RegulatoryScanner, setLanguage } from '@holmdigital/engine';
141
-
142
- const scanner = new RegulatoryScanner({
143
- url: 'https://example.com',
144
- severityThreshold: 'high' // critical, high, medium, low
145
- });
146
-
147
- setLanguage('sv');
148
-
149
- const result = await scanner.scan();
150
-
151
- console.log(`Score: ${result.score}`);
152
- console.log(`Duration: ${result.metadata.scanDuration}ms`);
153
- console.log(`Passed: ${result.stats.passed}, Failed: ${result.stats.total}`);
154
- ```
155
-
156
- ## License
157
-
158
- MIT © Holm Digital AB
1
+ # @holmdigital/engine
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@holmdigital/engine.svg)](https://www.npmjs.com/package/@holmdigital/engine)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)
6
+ [![Downloads](https://img.shields.io/npm/dm/@holmdigital/engine.svg)](https://www.npmjs.com/package/@holmdigital/engine)
7
+
8
+ > Regulatory accessibility test engine with Virtual DOM, Shadow DOM support, and built-in legal compliance reporting.
9
+
10
+ ## Why this package?
11
+
12
+ Most accessibility tools give you technical errors (e.g., "Color contrast must be 4.5:1"). This engine bridges the gap between **technical code validation** (using `axe-core`) and **legal compliance** (EN 301 549, Section 508, DOS-lagen).
13
+
14
+ It handles the heavy lifting of:
15
+ 1. **Mapping** technical failures to specific legal clauses.
16
+ 2. **Validating** HTML structure to ensure test accuracy.
17
+ 3. **Reporting** in multiple languages (EN, SV, NL, DE, FR, ES) for non-technical stakeholders.
18
+ 4. **CI/CD Pipeline Integration** with automatic enforcement.
19
+
20
+ For a comprehensive guide on CLI flags, CI/CD integration, and configuration files, see the **[Engine Library Catalog](../../docs/reference/engine.md)**.
21
+
22
+ ## Features
23
+
24
+ - **Regulatory Mapping**: Maps technical failures to EU laws (EN 301 549, EAA).
25
+ - **HTML Structure Validation**: Built-in `html-validate` checks to prevent false positives/negatives.
26
+ - **Internationalization (i18n)**: Supports English (`en`), Swedish (`sv`), Norwegian (`no`), Finnish (`fi`), Danish (`da`), German (`de`), French (`fr`), Spanish (`es`), and Dutch (`nl`).
27
+ - **Premium V2 Accessibility Statement**: Generates modern, glassmorphism-styled statements compliant with Digg & EU templates.
28
+ - **Multi-Company Metadata**: Easily customize statements via CLI flags or `.a11yrc` for scalable client generation.
29
+ - **Configurable Severity Threshold**: Fail CI only on critical/high issues (configurable).
30
+ - **Rich Metadata**: Includes scan duration, page title, language, and version info.
31
+ - **Pseudo-Automation**: Automatically generates Playwright/Puppeteer test scripts for manual verification steps.
32
+ - **PDF Reporting**: Generates beautiful, compliant PDF reports with severity-sorted violations, HTML error counts, and `@HolmDigital/engine` branding.
33
+ - **TypeScript**: Written in TypeScript with full type definitions included.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ npm install @holmdigital/engine
39
+ ```
40
+
41
+ ## CLI Usage
42
+
43
+ ```bash
44
+ npx hd-a11y-scan <url> [options]
45
+ ```
46
+
47
+ **Options:**
48
+ | Option | Description |
49
+ |--------|-------------|
50
+ | `--lang <code>` | Language code (`en`, `sv`, `de`, `fr`, `es`, `nl`, `no`, `fi`, `da`, `en-gb`, `en-us`, `en-ca`) |
51
+ | `--threshold <level>` | Severity threshold for compliance (`critical`, `high`, `medium`, `low`). Default: `high` |
52
+ | `--ci` | Run in CI mode (exit code 1 on failure) |
53
+ | `--json` | Output results as JSON |
54
+ | `--pdf <path>` | Generate a PDF report |
55
+ | `--statement <path>` | Generate a Premium V2 accessibility statement (HTML) |
56
+ | `--org <name>` | Organization name for the statement metadata |
57
+ | `--email <email>` | Contact email for the statement metadata |
58
+ | `--phone <number>` | Contact phone for the statement metadata |
59
+ | `--response-time <val>` | Response time for the statement metadata |
60
+ | `--publish-date <date>` | Publish date for the website (YYYY-MM-DD) |
61
+ | `--viewport <size>` | Set viewport size (`mobile`, `tablet`, `desktop`, or custom `1024x768`) |
62
+ | `--generate-tests` | Generate Pseudo-Automation tests |
63
+ | `--invalid-https-cert` | Allow scanning sites with invalid/self-signed HTTPS certificates ⚠️ |
64
+ | `--api-key <key>` | API Key for HolmDigital Cloud |
65
+ | `--cloud-url <url>` | Custom Cloud API Endpoint (default: cloud.holmdigital.se) |
66
+
67
+ ### 🏆 Accessibility Badge
68
+ If your site achieves a **100% score**, the CLI will generate a [Shields.io](https://shields.io/) badge that you can add to your project's README:
69
+
70
+ ![Accessibility Status: 100% Compliant](https://img.shields.io/badge/HolmDigital_Engine-100%25-00703C?style=flat-square)
71
+
72
+ The badge uses accessible colors (AAA compliant contrast) and is included in both the CLI output and the HTML report.
73
+
74
+ > **⚠️ Security Note:** The `--invalid-https-cert` flag should only be used in trusted environments (local dev, staging). It disables certificate validation and is not recommended for production. *(Contributed by [@FerdiStro](https://github.com/FerdiStro))*
75
+
76
+ **Example:**
77
+ ```bash
78
+ # Fail only on critical issues in CI
79
+ npx hd-a11y-scan https://example.com --ci --threshold critical
80
+
81
+ # Full JSON output with metadata
82
+ npx hd-a11y-scan https://example.com --json
83
+ ```
84
+
85
+ ## JSON Output
86
+
87
+ ```json
88
+ {
89
+ "url": "https://example.com",
90
+ "timestamp": "2026-01-13T17:05:11.749Z",
91
+ "metadata": {
92
+ "engineVersion": "1.4.12",
93
+ "axeCoreVersion": "4.10.2",
94
+ "standardsVersion": "1.2.3",
95
+ "scanDuration": 2891,
96
+ "pageTitle": "Example Domain",
97
+ "pageLanguage": "en"
98
+ },
99
+ "stats": {
100
+ "passed": 13,
101
+ "critical": 0,
102
+ "high": 0,
103
+ "medium": 2,
104
+ "low": 0,
105
+ "total": 2
106
+ },
107
+ "legalSummary": {
108
+ "wadApplicable": 2,
109
+ "eaaApplicable": 2,
110
+ "eaaDeadlineViolations": 2
111
+ },
112
+ "score": 90,
113
+ "complianceStatus": "PASS"
114
+ }
115
+ ```
116
+
117
+ ## EU Legal Framework
118
+
119
+ The engine maps violations to EU legal frameworks:
120
+
121
+ | Framework | Description | Deadline |
122
+ |-----------|-------------|----------|
123
+ | **WAD** | Web Accessibility Directive 2016/2102 (Public Sector) | Already in force |
124
+ | **EAA** | European Accessibility Act 2019/882 (Private Sector) | **June 28, 2025** |
125
+
126
+ ### legalSummary Fields
127
+
128
+ | Field | Description |
129
+ |-------|-------------|
130
+ | `wadApplicable` | Violations that affect WAD compliance (public sector) |
131
+ | `eaaApplicable` | Violations that affect EAA compliance (private sector) |
132
+ | `eaaDeadlineViolations` | Issues that must be fixed before EAA 2025 deadline |
133
+
134
+ ### HTML Report Enhancements
135
+
136
+ The HTML/PDF report now includes:
137
+ - **EU Legal Framework Impact** summary section
138
+ - **WAD/EAA badges** on each violation card
139
+ - **EAA deadline warnings** for issues requiring immediate attention
140
+
141
+ ## Severity Threshold
142
+
143
+ The `--threshold` flag controls when `complianceStatus` becomes `FAIL`:
144
+
145
+ | Threshold | Fails on |
146
+ |-----------|----------|
147
+ | `critical` | Only critical violations |
148
+ | `high` (default) | Critical + high violations |
149
+ | `medium` | Critical + high + medium violations |
150
+ | `low` | Any violation |
151
+
152
+ **Why this matters for CI/CD:**
153
+
154
+ ```bash
155
+ # Strict: Block deployment on any serious issue
156
+ npx hd-a11y-scan https://staging.example.com --ci --threshold high
157
+
158
+ # Lenient: Only block on critical issues (like missing alt text)
159
+ npx hd-a11y-scan https://staging.example.com --ci --threshold critical
160
+ ```
161
+
162
+ Medium violations (like missing `<main>` landmark) won't fail your CI by default, but are still reported for awareness.
163
+
164
+ ## Metadata Fields
165
+
166
+ | Field | Description |
167
+ |-------|-------------|
168
+ | `engineVersion` | Version of @holmdigital/engine |
169
+ | `axeCoreVersion` | Version of axe-core used |
170
+ | `standardsVersion` | Version of @holmdigital/standards database |
171
+ | `scanDuration` | Scan time in milliseconds |
172
+ | `pageTitle` | HTML `<title>` of scanned page |
173
+ | `pageLanguage` | `lang` attribute of `<html>` |
174
+ | `stats.passed` | Number of accessibility checks that passed |
175
+
176
+
177
+ ## Programmatic Usage
178
+
179
+ ```typescript
180
+ import { RegulatoryScanner, setLanguage } from '@holmdigital/engine';
181
+
182
+ const scanner = new RegulatoryScanner({
183
+ url: 'https://example.com',
184
+ severityThreshold: 'high' // critical, high, medium, low
185
+ });
186
+
187
+ setLanguage('sv');
188
+
189
+ const result = await scanner.scan();
190
+
191
+ console.log(`Score: ${result.score}`);
192
+ console.log(`Duration: ${result.metadata.scanDuration}ms`);
193
+ console.log(`Passed: ${result.stats.passed}, Failed: ${result.stats.total}`);
194
+ ```
195
+
196
+ ## License
197
+
198
+ MIT © Holm Digital AB