@holmdigital/engine 2.12.0 → 3.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/README.md CHANGED
@@ -36,6 +36,7 @@ For a comprehensive guide on CLI flags, CI/CD integration, and configuration fil
36
36
  - **Pseudo-Automation**: Automatically generates Playwright/Puppeteer test scripts for manual verification steps.
37
37
  - **PDF Reporting**: Generates beautiful, compliant PDF reports with severity-sorted violations, HTML error counts, and `@HolmDigital/engine` branding.
38
38
  - **Plain-Language Reports**: `--plain` (or `--audience plain`) renders the report and PDF in plain language for managers, lawyers, and buyers without a technical background. Findings of the same rule are grouped into one card with an occurrence count, with a business-impact breakdown and Swedish-language fallback.
39
+ - **Robustness Without JavaScript** (opt-in): `--noscript-check` loads the page a second time with JavaScript disabled and reports how much of the content survives. A client-rendered SPA that is blank without JS breaks for every user whose script fails to load (network, proxy, firewall, extension). They get an empty page, not a degraded one. When the page is empty or partial, the report also names who is affected, so the finding is not waved away with "everyone has JavaScript". **This is advisory, not a legal requirement**: no WCAG success criterion requires a page to work without JavaScript, so the finding never affects the compliance score and is never reported as a WCAG violation.
39
40
  - **Type-Safe Results**: Scan results return fully typed `EnrichedReport[]` with `failingNodes` and `legalContext` — zero `as any` casts in the pipeline.
40
41
  - **Build-Time Version Injection**: Engine version derived from `package.json` at build time via tsup `define` — CLI, cloud client, and reports always report the correct version.
41
42
  - **TypeScript**: Written in TypeScript with full type definitions included.
@@ -70,12 +71,16 @@ npx hd-a11y-scan <url> [options]
70
71
  | `--sector <type>` | Sector type: `public` (WAD) or `private` (EAA). Default: `public` |
71
72
  | `--viewport <size>` | Set viewport size (`mobile`, `tablet`, `desktop`, or custom `1024x768`) |
72
73
  | `--generate-tests` | Generate Pseudo-Automation tests |
74
+ | `--junit <path>` | Generate a JUnit XML report for CI dashboards |
75
+ | `--format <type>` | Output format for statement (`html`, `md`). Default: `html` |
73
76
  | `--invalid-https-cert` | Allow scanning sites with invalid/self-signed HTTPS certificates ⚠️ |
74
77
  | `--api-key <key>` | API Key for HolmDigital Cloud |
75
78
  | `--cloud-url <url>` | Custom Cloud API Endpoint (default: cloud.holmdigital.se) |
76
79
  | `--light` | Fast score-only mode — skips HTML validation and detailed legal mapping |
77
80
  | `--plain` | Plain-language mode (klarspråksläge): report and PDF in non-technical language for recipients without a technical background. Alias for `--audience plain`. |
78
81
  | `--audience <mode>` | Report audience: `developer` (default) or `plain`. |
82
+ | `--noscript-check` | Robustness probe: measures how much of the page content is available without JavaScript. **Advisory only. Never affects the compliance score.** |
83
+ | `--wait-for-hydration <ms>` | Settle time after network idle so client-rendered SPAs finish hydrating before axe runs. Default: `2500`. `0` disables the wait, maximum `60000`. |
79
84
 
80
85
  ### 🏆 Accessibility Badge
81
86
  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:
@@ -84,6 +89,14 @@ If your site achieves a **100% score**, the CLI will generate a [Shields.io](htt
84
89
 
85
90
  The badge uses accessible colors (AAA compliant contrast) and is included in both the CLI output and the HTML report.
86
91
 
92
+ **One exception.** If you run `--noscript-check` and the verdict is `empty` (the page is effectively blank without JavaScript), the badge is not generated. The score is untouched: the page still shows 100/100 and PASS, because it is genuinely WCAG conformant and lowering the score would misrepresent the law. But the badge is a shareable marketing artefact, not a legal verdict, and we do not hand out an award to a page that a user on a weak network never gets to see. The CLI prints one line instead:
93
+
94
+ ```
95
+ 100/100 with no findings. The robustness check is not clean, so we do not generate a shareable badge.
96
+ ```
97
+
98
+ A `partial` verdict still earns the badge: core content is there and the page can be read.
99
+
87
100
  > **⚠️ 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))*
88
101
 
89
102
  **Example:**
@@ -116,9 +129,9 @@ npx hd-a11y-scan https://hospital.example.com --country US --sector private --st
116
129
  "url": "https://example.com",
117
130
  "timestamp": "2026-01-13T17:05:11.749Z",
118
131
  "metadata": {
119
- "engineVersion": "2.8.0",
120
- "axeCoreVersion": "4.11.1",
121
- "standardsVersion": "2.8.0",
132
+ "engineVersion": "2.13.0",
133
+ "axeCoreVersion": "4.12.1",
134
+ "standardsVersion": "2.10.0",
122
135
  "scanDuration": 2891,
123
136
  "pageTitle": "Example Domain",
124
137
  "pageLanguage": "en"
@@ -20,7 +20,18 @@ var en_default = {
20
20
  use_component: "Use component: {component}",
21
21
  pseudo_tests: "\n\u{1F9EC} Generating Pseudo-Automation Tests...\n",
22
22
  test_for: "Test for {ruleId}:",
23
- junit_saved: "JUnit XML report saved to {path}"
23
+ junit_saved: "JUnit XML report saved to {path}",
24
+ noscript_heading: "\n\u{1F9EA} Robustness without JavaScript (advisory)",
25
+ noscript_coverage: "Content available without JavaScript: {percent}% ({without} of {with} characters)",
26
+ noscript_empty: "The page is effectively empty without JavaScript.",
27
+ noscript_partial: "A substantial part of the content is missing without JavaScript.",
28
+ noscript_ok: "Core content is available without JavaScript.",
29
+ noscript_unknown: "Could not be measured.",
30
+ noscript_fallback: "A <noscript> fallback is present.",
31
+ noscript_no_fallback: "No <noscript> fallback was found.",
32
+ noscript_impact: "This rarely affects the people who turned JavaScript off, but the people whose scripts never arrived: a weak mobile network, a corporate proxy, a browser extension that misbehaves, a timeout. They get an empty page instead of a slow one.",
33
+ noscript_advisory: "Recommendation, not a legal requirement. No WCAG success criterion requires a page to work without JavaScript, so this does not affect the compliance score.",
34
+ badge_withheld: "100/100 with no findings. The robustness check is not clean, so we do not generate a shareable badge."
24
35
  },
25
36
  report: {
26
37
  title: "Accessibility Report - {url}",
@@ -86,7 +97,18 @@ var sv_default = {
86
97
  use_component: "Anv\xE4nd komponent: {component}",
87
98
  pseudo_tests: "\n\u{1F9EC} Genererar Pseudo-automationstester...\n",
88
99
  test_for: "Test f\xF6r {ruleId}:",
89
- junit_saved: "JUnit XML-rapport sparad till {path}"
100
+ junit_saved: "JUnit XML-rapport sparad till {path}",
101
+ noscript_heading: "\n\u{1F9EA} Robusthet utan JavaScript (r\xE5dgivande)",
102
+ noscript_coverage: "Inneh\xE5ll som finns utan JavaScript: {percent}% ({without} av {with} tecken)",
103
+ noscript_empty: "Sidan \xE4r i praktiken tom utan JavaScript.",
104
+ noscript_partial: "En v\xE4sentlig del av inneh\xE5llet saknas utan JavaScript.",
105
+ noscript_ok: "K\xE4rninneh\xE5llet finns tillg\xE4ngligt utan JavaScript.",
106
+ noscript_unknown: "Kunde inte m\xE4tas.",
107
+ noscript_fallback: "Sidan har en <noscript>-fallback.",
108
+ noscript_no_fallback: "Ingen <noscript>-fallback hittades.",
109
+ noscript_impact: "Det drabbar s\xE4llan den som valt bort JavaScript, utan den vars skript aldrig kom fram: d\xE5ligt mobiln\xE4t, en f\xF6retagsproxy, ett webbl\xE4sartill\xE4gg som kr\xE5nglar, en timeout. De f\xE5r en tom sida i st\xE4llet f\xF6r en l\xE5ngsam.",
110
+ noscript_advisory: "Rekommendation, inte ett lagkrav. Inget WCAG-kriterium kr\xE4ver att en sida fungerar utan JavaScript, s\xE5 detta p\xE5verkar inte konformansscoren.",
111
+ badge_withheld: "100/100 utan anm\xE4rkning. Robusthetskontrollen \xE4r inte ren, s\xE5 vi genererar ingen delbar badge."
90
112
  },
91
113
  report: {
92
114
  title: "Tillg\xE4nglighetsrapport - {url}",
@@ -152,7 +174,18 @@ var de_default = {
152
174
  use_component: "Verwenden Sie die Komponente: {component}",
153
175
  pseudo_tests: "\n\u{1F9EC} Generiere Pseudo-Automatisierungstests...\n",
154
176
  test_for: "Test f\xFCr {ruleId}:",
155
- junit_saved: "JUnit XML-Bericht gespeichert unter {path}"
177
+ junit_saved: "JUnit XML-Bericht gespeichert unter {path}",
178
+ noscript_heading: "\n\u{1F9EA} Robustheit ohne JavaScript (Empfehlung)",
179
+ noscript_coverage: "Ohne JavaScript verf\xFCgbare Inhalte: {percent}% ({without} von {with} Zeichen)",
180
+ noscript_empty: "Die Seite ist ohne JavaScript praktisch leer.",
181
+ noscript_partial: "Ohne JavaScript fehlt ein wesentlicher Teil des Inhalts.",
182
+ noscript_ok: "Die Kerninhalte sind ohne JavaScript verf\xFCgbar.",
183
+ noscript_unknown: "Konnte nicht gemessen werden.",
184
+ noscript_fallback: "Ein <noscript>-Fallback ist vorhanden.",
185
+ noscript_no_fallback: "Es wurde kein <noscript>-Fallback gefunden.",
186
+ noscript_impact: "Das trifft selten die Menschen, die JavaScript abgeschaltet haben, sondern die Menschen, deren Skripte nie ankamen: ein schwaches Mobilfunknetz, ein Firmenproxy, eine st\xF6rende Browsererweiterung, ein Timeout. Sie bekommen eine leere Seite statt einer langsamen.",
187
+ noscript_advisory: "Empfehlung, keine gesetzliche Anforderung. Kein WCAG-Erfolgskriterium verlangt, dass eine Seite ohne JavaScript funktioniert. Dies beeinflusst daher den Konformit\xE4tswert nicht.",
188
+ badge_withheld: "100/100 ohne Befund. Die Robustheitspr\xFCfung ist nicht sauber, deshalb erzeugen wir kein teilbares Badge."
156
189
  },
157
190
  report: {
158
191
  title: "Barrierefreiheitsbericht - {url}",
@@ -218,7 +251,18 @@ var fr_default = {
218
251
  use_component: "Utilisez le composant : {component}",
219
252
  pseudo_tests: "\n\u{1F9EC} G\xE9n\xE9ration de tests de pseudo-automatisation...\n",
220
253
  test_for: "Test pour {ruleId} :",
221
- junit_saved: "Rapport XML JUnit enregistr\xE9 sous {path}"
254
+ junit_saved: "Rapport XML JUnit enregistr\xE9 sous {path}",
255
+ noscript_heading: "\n\u{1F9EA} Robustesse sans JavaScript (recommandation)",
256
+ noscript_coverage: "Contenu disponible sans JavaScript : {percent}% ({without} sur {with} caract\xE8res)",
257
+ noscript_empty: "La page est pratiquement vide sans JavaScript.",
258
+ noscript_partial: "Une partie importante du contenu est absente sans JavaScript.",
259
+ noscript_ok: "Le contenu principal est disponible sans JavaScript.",
260
+ noscript_unknown: "N'a pas pu \xEAtre mesur\xE9.",
261
+ noscript_fallback: "Une solution de repli <noscript> est pr\xE9sente.",
262
+ noscript_no_fallback: "Aucune solution de repli <noscript> n'a \xE9t\xE9 trouv\xE9e.",
263
+ noscript_impact: "Cela touche rarement les personnes qui ont d\xE9sactiv\xE9 JavaScript, mais celles dont les scripts ne sont jamais arriv\xE9s : un r\xE9seau mobile faible, un proxy d'entreprise, une extension de navigateur d\xE9faillante, un d\xE9lai d\xE9pass\xE9. Elles obtiennent une page vide au lieu d'une page lente.",
264
+ noscript_advisory: "Recommandation, pas une obligation l\xE9gale. Aucun crit\xE8re de succ\xE8s WCAG n'exige qu'une page fonctionne sans JavaScript. Cela n'affecte donc pas le score de conformit\xE9.",
265
+ badge_withheld: "100/100 sans r\xE9serve. Le contr\xF4le de robustesse n'est pas propre, nous ne g\xE9n\xE9rons donc pas de badge partageable."
222
266
  },
223
267
  report: {
224
268
  title: "Rapport d'Accessibilit\xE9 - {url}",
@@ -284,7 +328,18 @@ var es_default = {
284
328
  use_component: "Use el componente: {component}",
285
329
  pseudo_tests: "\n\u{1F9EC} Generando pruebas de pseudo-automatizaci\xF3n...\n",
286
330
  test_for: "Prueba para {ruleId}:",
287
- junit_saved: "Informe JUnit XML guardado en {path}"
331
+ junit_saved: "Informe JUnit XML guardado en {path}",
332
+ noscript_heading: "\n\u{1F9EA} Robustez sin JavaScript (recomendaci\xF3n)",
333
+ noscript_coverage: "Contenido disponible sin JavaScript: {percent}% ({without} de {with} caracteres)",
334
+ noscript_empty: "La p\xE1gina est\xE1 pr\xE1cticamente vac\xEDa sin JavaScript.",
335
+ noscript_partial: "Falta una parte sustancial del contenido sin JavaScript.",
336
+ noscript_ok: "El contenido principal est\xE1 disponible sin JavaScript.",
337
+ noscript_unknown: "No se pudo medir.",
338
+ noscript_fallback: "Hay una alternativa <noscript> presente.",
339
+ noscript_no_fallback: "No se encontr\xF3 ninguna alternativa <noscript>.",
340
+ noscript_impact: "Rara vez afecta a quien ha desactivado JavaScript, sino a quien nunca recibi\xF3 los scripts: una red m\xF3vil deficiente, un proxy corporativo, una extensi\xF3n del navegador que falla, un tiempo de espera agotado. Ven una p\xE1gina vac\xEDa en lugar de una lenta.",
341
+ noscript_advisory: "Recomendaci\xF3n, no un requisito legal. Ning\xFAn criterio de conformidad de las WCAG exige que una p\xE1gina funcione sin JavaScript, por lo que esto no afecta a la puntuaci\xF3n de conformidad.",
342
+ badge_withheld: "100/100 sin observaciones. La comprobaci\xF3n de robustez no est\xE1 limpia, por lo que no generamos una insignia compartible."
288
343
  },
289
344
  report: {
290
345
  title: "Informe de Accesibilidad - {url}",
@@ -350,7 +405,18 @@ var fi_default = {
350
405
  use_component: "K\xE4yt\xE4 komponenttia: {component}",
351
406
  pseudo_tests: "\n\u{1F9EC} Luodaan Pseudo-automaatiotestej\xE4...\n",
352
407
  test_for: "Testi {ruleId}:lle:",
353
- junit_saved: "JUnit XML -raportti tallennettu kohteeseen {path}"
408
+ junit_saved: "JUnit XML -raportti tallennettu kohteeseen {path}",
409
+ noscript_heading: "\n\u{1F9EA} Vakaus ilman JavaScripti\xE4 (suositus)",
410
+ noscript_coverage: "Sis\xE4lt\xF6\xE4 saatavilla ilman JavaScripti\xE4: {percent}% ({without}/{with} merkki\xE4)",
411
+ noscript_empty: "Sivu on k\xE4yt\xE4nn\xF6ss\xE4 tyhj\xE4 ilman JavaScripti\xE4.",
412
+ noscript_partial: "Merkitt\xE4v\xE4 osa sis\xE4ll\xF6st\xE4 puuttuu ilman JavaScripti\xE4.",
413
+ noscript_ok: "Ydinsis\xE4lt\xF6 on saatavilla ilman JavaScripti\xE4.",
414
+ noscript_unknown: "Ei voitu mitata.",
415
+ noscript_fallback: "Sivulla on <noscript>-varasis\xE4lt\xF6.",
416
+ noscript_no_fallback: "<noscript>-varasis\xE4lt\xF6\xE4 ei l\xF6ytynyt.",
417
+ noscript_impact: "T\xE4m\xE4 koskee harvoin niit\xE4, jotka ovat kytkeneet JavaScriptin pois. Se koskee niit\xE4, joiden skriptit eiv\xE4t koskaan tulleet perille: heikko mobiiliverkko, yrityksen v\xE4lityspalvelin, h\xE4irik\xF6iv\xE4 selainlaajennus, aikakatkaisu. He saavat tyhj\xE4n sivun hitaan sivun sijaan.",
418
+ noscript_advisory: "Suositus, ei lakis\xE4\xE4teinen vaatimus. Mik\xE4\xE4n WCAG-onnistumiskriteeri ei edellyt\xE4, ett\xE4 sivu toimii ilman JavaScripti\xE4, joten t\xE4m\xE4 ei vaikuta vaatimustenmukaisuuspisteisiin.",
419
+ badge_withheld: "100/100 ilman huomautuksia. Robustiustarkistus ei ole puhdas, joten emme luo jaettavaa merkki\xE4."
354
420
  },
355
421
  report: {
356
422
  title: "Saavutettavuusraportti - {url}",
@@ -416,7 +482,18 @@ var dk_default = {
416
482
  use_component: "Brug komponent: {component}",
417
483
  pseudo_tests: "\n\u{1F9EC} Genererer Pseudo-automatiseringstests...\n",
418
484
  test_for: "Test for {ruleId}:",
419
- junit_saved: "JUnit XML-rapport gemt i {path}"
485
+ junit_saved: "JUnit XML-rapport gemt i {path}",
486
+ noscript_heading: "\n\u{1F9EA} Robusthed uden JavaScript (anbefaling)",
487
+ noscript_coverage: "Indhold tilg\xE6ngeligt uden JavaScript: {percent}% ({without} af {with} tegn)",
488
+ noscript_empty: "Siden er reelt tom uden JavaScript.",
489
+ noscript_partial: "En v\xE6sentlig del af indholdet mangler uden JavaScript.",
490
+ noscript_ok: "Kerneindholdet er tilg\xE6ngeligt uden JavaScript.",
491
+ noscript_unknown: "Kunne ikke m\xE5les.",
492
+ noscript_fallback: "Der findes en <noscript>-fallback.",
493
+ noscript_no_fallback: "Der blev ikke fundet nogen <noscript>-fallback.",
494
+ noscript_impact: "Det rammer sj\xE6ldent dem, der har sl\xE5et JavaScript fra, men dem, hvis scripts aldrig n\xE5ede frem: d\xE5rligt mobilnet, en virksomhedsproxy, en browserudvidelse der driller, en timeout. De f\xE5r en tom side i stedet for en langsom.",
495
+ noscript_advisory: "Anbefaling, ikke et lovkrav. Intet WCAG-succeskriterium kr\xE6ver, at en side fungerer uden JavaScript, s\xE5 dette p\xE5virker ikke konformitetsscoren.",
496
+ badge_withheld: "100/100 uden anm\xE6rkninger. Robusthedstjekket er ikke rent, s\xE5 vi genererer ikke et delbart badge."
420
497
  },
421
498
  report: {
422
499
  title: "Tilg\xE6ngelighedsrapport - {url}",
@@ -482,7 +559,18 @@ var no_default = {
482
559
  use_component: "Bruk komponent: {component}",
483
560
  pseudo_tests: "\n\u{1F9EC} Genererer Pseudo-automatiseringstester...\n",
484
561
  test_for: "Test for {ruleId}:",
485
- junit_saved: "JUnit XML-rapport lagret i {path}"
562
+ junit_saved: "JUnit XML-rapport lagret i {path}",
563
+ noscript_heading: "\n\u{1F9EA} Robusthet uten JavaScript (anbefaling)",
564
+ noscript_coverage: "Innhold tilgjengelig uten JavaScript: {percent}% ({without} av {with} tegn)",
565
+ noscript_empty: "Siden er i praksis tom uten JavaScript.",
566
+ noscript_partial: "En vesentlig del av innholdet mangler uten JavaScript.",
567
+ noscript_ok: "Kjerneinnholdet er tilgjengelig uten JavaScript.",
568
+ noscript_unknown: "Kunne ikke m\xE5les.",
569
+ noscript_fallback: "Siden har en <noscript>-fallback.",
570
+ noscript_no_fallback: "Ingen <noscript>-fallback ble funnet.",
571
+ noscript_impact: "Det rammer sjelden den som har sl\xE5tt av JavaScript, men den som aldri fikk skriptene: d\xE5rlig mobilnett, en bedriftsproxy, en nettleserutvidelse som svikter, et tidsavbrudd. De f\xE5r en tom side i stedet for en treg.",
572
+ noscript_advisory: "Anbefaling, ikke et lovkrav. Ingen WCAG-suksesskriterier krever at en side fungerer uten JavaScript, s\xE5 dette p\xE5virker ikke samsvarsscoren.",
573
+ badge_withheld: "100/100 uten anmerkninger. Robusthetssjekken er ikke ren, s\xE5 vi genererer ikke et delbart badge."
486
574
  },
487
575
  report: {
488
576
  title: "Tilgjengelighetsrapport - {url}",
@@ -548,7 +636,18 @@ var nl_default = {
548
636
  use_component: "Gebruik component: {component}",
549
637
  pseudo_tests: "\n\u{1F9EC} Pseudo-automatiseringstests genereren...\n",
550
638
  test_for: "Test voor {ruleId}:",
551
- junit_saved: "JUnit XML-rapport opgeslagen op {path}"
639
+ junit_saved: "JUnit XML-rapport opgeslagen op {path}",
640
+ noscript_heading: "\n\u{1F9EA} Robuustheid zonder JavaScript (advies)",
641
+ noscript_coverage: "Inhoud beschikbaar zonder JavaScript: {percent}% ({without} van {with} tekens)",
642
+ noscript_empty: "De pagina is zonder JavaScript in feite leeg.",
643
+ noscript_partial: "Een aanzienlijk deel van de inhoud ontbreekt zonder JavaScript.",
644
+ noscript_ok: "De kerninhoud is beschikbaar zonder JavaScript.",
645
+ noscript_unknown: "Kon niet worden gemeten.",
646
+ noscript_fallback: "Er is een <noscript>-fallback aanwezig.",
647
+ noscript_no_fallback: "Er is geen <noscript>-fallback gevonden.",
648
+ noscript_impact: "Dit treft zelden de mensen die JavaScript hebben uitgezet, maar de mensen bij wie de scripts nooit aankwamen: een zwak mobiel netwerk, een bedrijfsproxy, een browserextensie die hapert, een time-out. Zij krijgen een lege pagina in plaats van een trage.",
649
+ noscript_advisory: "Aanbeveling, geen wettelijke vereiste. Geen enkel WCAG-succescriterium vereist dat een pagina zonder JavaScript werkt. Dit heeft dus geen invloed op de conformiteitsscore.",
650
+ badge_withheld: "100/100 zonder bevindingen. De robuustheidscontrole is niet schoon, dus we genereren geen deelbare badge."
552
651
  },
553
652
  report: {
554
653
  title: "Toegankelijkheidsrapport - {url}",
@@ -93,6 +93,69 @@ var VirtualDOMBuilder = class {
93
93
  }
94
94
  };
95
95
 
96
+ // src/core/noscript-check.ts
97
+ var NOSCRIPT_EMPTY_THRESHOLD = 0.05;
98
+ var NOSCRIPT_PARTIAL_THRESHOLD = 0.5;
99
+ function evaluateNoScriptCoverage(textLengthWithoutJs, textLengthWithJs, hasNoScriptFallback = false) {
100
+ const withoutJs = Math.max(0, Math.trunc(textLengthWithoutJs) || 0);
101
+ const withJs = Math.max(0, Math.trunc(textLengthWithJs) || 0);
102
+ const base = {
103
+ textLengthWithoutJs: withoutJs,
104
+ textLengthWithJs: withJs,
105
+ hasNoScriptFallback,
106
+ isWcagViolation: false,
107
+ affectsScore: false
108
+ };
109
+ if (withJs === 0) {
110
+ return {
111
+ ...base,
112
+ coverageRatio: 0,
113
+ verdict: "unknown",
114
+ hasContentWithoutJs: withoutJs > 0
115
+ };
116
+ }
117
+ const coverageRatio = Math.min(1, withoutJs / withJs);
118
+ let verdict;
119
+ if (coverageRatio < NOSCRIPT_EMPTY_THRESHOLD) {
120
+ verdict = "empty";
121
+ } else if (coverageRatio < NOSCRIPT_PARTIAL_THRESHOLD) {
122
+ verdict = "partial";
123
+ } else {
124
+ verdict = "ok";
125
+ }
126
+ return {
127
+ ...base,
128
+ coverageRatio,
129
+ verdict,
130
+ hasContentWithoutJs: coverageRatio >= NOSCRIPT_EMPTY_THRESHOLD
131
+ };
132
+ }
133
+ async function probeWithoutJavaScript(browser, options) {
134
+ const page = await browser.newPage();
135
+ try {
136
+ if (options.userAgent) await page.setUserAgent(options.userAgent);
137
+ if (options.viewport) await page.setViewport(options.viewport);
138
+ await page.setJavaScriptEnabled(false);
139
+ await page.goto(options.url, {
140
+ waitUntil: "domcontentloaded",
141
+ timeout: options.timeout ?? 6e4
142
+ });
143
+ await page.setJavaScriptEnabled(true);
144
+ return await page.evaluate(() => {
145
+ const noScriptEls = Array.from(document.querySelectorAll("noscript"));
146
+ noScriptEls.forEach((el) => {
147
+ el.style.display = "none";
148
+ });
149
+ return {
150
+ textLength: (document.body?.innerText ?? "").trim().length,
151
+ hasNoScriptFallback: noScriptEls.length > 0
152
+ };
153
+ });
154
+ } finally {
155
+ await page.close();
156
+ }
157
+ }
158
+
96
159
  // src/core/regulatory-scanner.ts
97
160
  import axeCore from "axe-core";
98
161
  import puppeteer from "puppeteer";
@@ -138,7 +201,7 @@ var HtmlValidator = class {
138
201
  // src/core/regulatory-scanner.ts
139
202
  import { readFileSync } from "fs";
140
203
  function getEngineVersion() {
141
- return "2.12.0";
204
+ return "3.0.0";
142
205
  }
143
206
  function getStandardsVersion() {
144
207
  try {
@@ -149,6 +212,7 @@ function getStandardsVersion() {
149
212
  return "unknown";
150
213
  }
151
214
  }
215
+ var SCAN_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";
152
216
  var RegulatoryScanner = class {
153
217
  browser = null;
154
218
  options;
@@ -162,8 +226,13 @@ var RegulatoryScanner = class {
162
226
  invalidHttpsCert: false,
163
227
  waitForHydrationMs: 2500,
164
228
  // Default PÅ: klientrenderade SPA:er behöver tid att hydrera innan axe körs
229
+ noScriptCheck: false,
230
+ // Default AV: opt-in, kostar en extra sidladdning
165
231
  ...options
166
232
  };
233
+ if (this.options.waitForHydrationMs === void 0) {
234
+ this.options.waitForHydrationMs = 2500;
235
+ }
167
236
  this.htmlValidator = new HtmlValidator();
168
237
  }
169
238
  /** Log only when not in silent mode */
@@ -217,6 +286,12 @@ var RegulatoryScanner = class {
217
286
  }
218
287
  pageTitle = await page.title();
219
288
  pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
289
+ let textLengthWithJs;
290
+ if (this.options.noScriptCheck) {
291
+ textLengthWithJs = await page.evaluate(
292
+ () => (document.body?.innerText ?? "").trim().length
293
+ );
294
+ }
220
295
  let htmlValidation;
221
296
  if (!this.options.light) {
222
297
  const pageContent = await page.content();
@@ -248,11 +323,18 @@ var RegulatoryScanner = class {
248
323
  this.log(`Raw Axe Violations: ${axeResults.violations?.length || 0}`);
249
324
  passedCount = axeResults.passes?.length || 0;
250
325
  const regulatoryReports = this.options.light ? await this.enrichResultsLight(axeResults) : await this.enrichResults(axeResults);
326
+ let noScript;
327
+ if (this.options.noScriptCheck) {
328
+ noScript = await this.runNoScriptCheck(textLengthWithJs ?? 0);
329
+ }
251
330
  const scanDuration = Date.now() - startTime;
252
331
  const result = this.generateResultPackage(regulatoryReports, passedCount, scanDuration, pageTitle, pageLanguage);
253
332
  if (htmlValidation) {
254
333
  result.htmlValidation = htmlValidation;
255
334
  }
335
+ if (noScript) {
336
+ result.noScript = noScript;
337
+ }
256
338
  return result;
257
339
  } finally {
258
340
  await this.close();
@@ -273,13 +355,55 @@ var RegulatoryScanner = class {
273
355
  async getPage() {
274
356
  if (!this.browser) throw new Error("Browser not initialized");
275
357
  const page = await this.browser.newPage();
276
- await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
358
+ await page.setUserAgent(SCAN_USER_AGENT);
277
359
  return page;
278
360
  }
279
361
  async injectAxe(page) {
280
362
  const axeSource = axeCore.source;
281
363
  await page.evaluate(axeSource);
282
364
  }
365
+ /**
366
+ * Laddar sidan en andra gång med JS avstängt och jämför innehållsmängden
367
+ * med den hydrerade sidan. Rådgivande robusthetsindikator, aldrig ett
368
+ * WCAG-fel och aldrig en faktor i scoren. Se noscript-check.ts.
369
+ *
370
+ * Kastar aldrig: en misslyckad sond får inte fälla en i övrigt lyckad scan.
371
+ * Vid fel returneras verdict 'unknown' med felmeddelandet bevarat, inte
372
+ * 'empty' (vi vill inte larma om en tom sida när det var sonden som brast).
373
+ */
374
+ async runNoScriptCheck(textLengthWithJs) {
375
+ try {
376
+ if (!this.browser) throw new Error("Browser not initialized");
377
+ this.log("M\xE4ter robusthet utan JavaScript...");
378
+ const measurement = await probeWithoutJavaScript(this.browser, {
379
+ // SAMMA user agent och viewport som huvudskanningen. Skiljer de sig
380
+ // åt kan servern svara med annan markup och jämförelsen blir falsk:
381
+ // vi skulle mäta två olika sidor, inte JS-effekten.
382
+ url: this.options.url,
383
+ userAgent: SCAN_USER_AGENT,
384
+ viewport: this.options.viewport
385
+ });
386
+ return evaluateNoScriptCoverage(
387
+ measurement.textLength,
388
+ textLengthWithJs,
389
+ measurement.hasNoScriptFallback
390
+ );
391
+ } catch (e) {
392
+ const message = e instanceof Error ? e.message : String(e);
393
+ this.log(`Robusthetskontrollen kunde inte genomf\xF6ras: ${message}`);
394
+ return {
395
+ textLengthWithoutJs: 0,
396
+ textLengthWithJs: Math.max(0, textLengthWithJs),
397
+ coverageRatio: 0,
398
+ verdict: "unknown",
399
+ hasContentWithoutJs: false,
400
+ hasNoScriptFallback: false,
401
+ isWcagViolation: false,
402
+ affectsScore: false,
403
+ error: message
404
+ };
405
+ }
406
+ }
283
407
  /**
284
408
  * Light enrichment — maps axe severity directly, then attaches plain-language
285
409
  * (klarspråk) copy to the top findings so the public light scan can render
@@ -298,7 +422,7 @@ var RegulatoryScanner = class {
298
422
  };
299
423
  const KLARSPRAK_TOP_N = 8;
300
424
  const { generateRegulatoryReport } = await import("@holmdigital/standards");
301
- const { getCurrentLang } = await import("./i18n-7WMKI7JK.mjs");
425
+ const { getCurrentLang } = await import("./i18n-TCH23V3M.mjs");
302
426
  const lang = getCurrentLang();
303
427
  return axeResults.violations.map((violation, index) => {
304
428
  const impact = violation.impact || "moderate";
@@ -341,7 +465,7 @@ var RegulatoryScanner = class {
341
465
  async enrichResults(axeResults) {
342
466
  const reports = [];
343
467
  const { searchRulesByTags, generateRegulatoryReport, getConvergenceRule } = await import("@holmdigital/standards");
344
- const { getCurrentLang } = await import("./i18n-7WMKI7JK.mjs");
468
+ const { getCurrentLang } = await import("./i18n-TCH23V3M.mjs");
345
469
  const lang = getCurrentLang();
346
470
  for (const violation of axeResults.violations) {
347
471
  let report = generateRegulatoryReport(violation.id, lang);
@@ -570,6 +694,9 @@ function generateBadgeMarkdown(score) {
570
694
  }
571
695
  return `![Accessibility Status: 100% Compliant](${url})`;
572
696
  }
697
+ function isBadgeWithheldByRobustness(noScript) {
698
+ return noScript?.verdict === "empty";
699
+ }
573
700
 
574
701
  // src/reporting/statement-generator.ts
575
702
  import React from "react";
@@ -917,11 +1044,16 @@ async function generateStatement(result, outputPath, lang = "en", format = "html
917
1044
 
918
1045
  export {
919
1046
  VirtualDOMBuilder,
1047
+ NOSCRIPT_EMPTY_THRESHOLD,
1048
+ NOSCRIPT_PARTIAL_THRESHOLD,
1049
+ evaluateNoScriptCoverage,
1050
+ probeWithoutJavaScript,
920
1051
  getEngineVersion,
921
1052
  RegulatoryScanner,
922
1053
  PseudoAutomationEngine,
923
1054
  generateBadgeUrl,
924
1055
  generateBadgeMarkdown,
1056
+ isBadgeWithheldByRobustness,
925
1057
  generateStatementContent,
926
1058
  generateStatement
927
1059
  };