@holmdigital/engine 2.12.0 → 2.13.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 +11 -0
- package/dist/{chunk-CE5CPK4U.mjs → chunk-AQFORQWK.mjs} +108 -9
- package/dist/{chunk-5S6UAABI.mjs → chunk-ZPNGG5KS.mjs} +136 -4
- package/dist/cli/index.js +357 -19
- package/dist/cli/index.mjs +123 -12
- package/dist/{i18n-7WMKI7JK.mjs → i18n-TCH23V3M.mjs} +1 -1
- package/dist/index.d.mts +47 -3
- package/dist/index.d.ts +47 -3
- package/dist/index.js +243 -11
- package/dist/index.mjs +11 -3
- package/dist/{plain-report-WIL7FGCM.mjs → plain-report-OF2MNEE4.mjs} +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
generateBadgeUrl,
|
|
7
7
|
generateStatement,
|
|
8
8
|
generateStatementContent,
|
|
9
|
-
getEngineVersion
|
|
10
|
-
|
|
9
|
+
getEngineVersion,
|
|
10
|
+
isBadgeWithheldByRobustness
|
|
11
|
+
} from "../chunk-ZPNGG5KS.mjs";
|
|
11
12
|
import {
|
|
12
13
|
groupReportsByRule,
|
|
13
14
|
impactBreakdown,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
getCurrentLang,
|
|
19
20
|
setLanguage,
|
|
20
21
|
t
|
|
21
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-AQFORQWK.mjs";
|
|
22
23
|
import {
|
|
23
24
|
__dirname
|
|
24
25
|
} from "../chunk-DIBTSSLZ.mjs";
|
|
@@ -60,6 +61,45 @@ function formatDate(dateString) {
|
|
|
60
61
|
function escapeHtml(str) {
|
|
61
62
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
62
63
|
}
|
|
64
|
+
function renderNoScriptSection(result) {
|
|
65
|
+
const noScript = result.noScript;
|
|
66
|
+
if (!noScript) return "";
|
|
67
|
+
const palette = {
|
|
68
|
+
empty: { accent: "#b91c1c", bg: "#fef2f2", icon: "\u{1F534}" },
|
|
69
|
+
partial: { accent: "#b45309", bg: "#fffbeb", icon: "\u{1F7E1}" },
|
|
70
|
+
ok: { accent: "#15803d", bg: "#f0fdf4", icon: "\u{1F7E2}" },
|
|
71
|
+
unknown: { accent: "#475569", bg: "#f8fafc", icon: "\u26AA" }
|
|
72
|
+
}[noScript.verdict];
|
|
73
|
+
const summary = noScript.verdict === "empty" ? t("cli.noscript_empty") : noScript.verdict === "partial" ? t("cli.noscript_partial") : noScript.verdict === "ok" ? t("cli.noscript_ok") : t("cli.noscript_unknown");
|
|
74
|
+
const impact = noScript.verdict === "empty" || noScript.verdict === "partial" ? `<p style="margin: 0 0 0.5rem; color: #0f172a; font-size: 0.95rem; line-height: 1.55;">
|
|
75
|
+
${escapeHtml(t("cli.noscript_impact"))}
|
|
76
|
+
</p>` : "";
|
|
77
|
+
const detail = noScript.verdict === "unknown" ? "" : `<p style="margin: 0 0 0.5rem; color: #334155; font-size: 0.95rem;">
|
|
78
|
+
${escapeHtml(t("cli.noscript_coverage", {
|
|
79
|
+
percent: Math.round(noScript.coverageRatio * 100),
|
|
80
|
+
without: noScript.textLengthWithoutJs,
|
|
81
|
+
with: noScript.textLengthWithJs
|
|
82
|
+
}))}
|
|
83
|
+
</p>
|
|
84
|
+
${noScript.verdict !== "ok" ? `<p style="margin: 0 0 0.5rem; color: #475569; font-size: 0.9rem;">
|
|
85
|
+
${escapeHtml(noScript.hasNoScriptFallback ? t("cli.noscript_fallback") : t("cli.noscript_no_fallback"))}
|
|
86
|
+
</p>` : ""}`;
|
|
87
|
+
return `
|
|
88
|
+
<section style="margin: 2rem 0; padding: 1.25rem 1.5rem; background: ${palette.bg}; border-left: 5px solid ${palette.accent}; border-radius: 6px;">
|
|
89
|
+
<h2 style="margin: 0 0 0.75rem; font-size: 1.1rem; color: ${palette.accent};">
|
|
90
|
+
${escapeHtml(t("cli.noscript_heading").trim())}
|
|
91
|
+
</h2>
|
|
92
|
+
<p style="margin: 0 0 0.5rem; font-weight: 600; color: #0f172a; font-size: 1rem;">
|
|
93
|
+
<span aria-hidden="true">${palette.icon}</span> ${escapeHtml(summary)}
|
|
94
|
+
</p>
|
|
95
|
+
${impact}
|
|
96
|
+
${detail}
|
|
97
|
+
<p style="margin: 0.75rem 0 0; color: #475569; font-size: 0.85rem; line-height: 1.5;">
|
|
98
|
+
${escapeHtml(t("cli.noscript_advisory"))}
|
|
99
|
+
</p>
|
|
100
|
+
</section>
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
63
103
|
function generateReportHTML(result, sector = "public", audience = "developer", plainFallbackFrom) {
|
|
64
104
|
if (audience === "plain") {
|
|
65
105
|
return generatePlainReportHTML(result, plainFallbackFrom);
|
|
@@ -334,7 +374,7 @@ function generateReportHTML(result, sector = "public", audience = "developer", p
|
|
|
334
374
|
</div>
|
|
335
375
|
`;
|
|
336
376
|
}).join("")}
|
|
337
|
-
|
|
377
|
+
${renderNoScriptSection(result)}
|
|
338
378
|
<footer>
|
|
339
379
|
${t("report.footer", { version: getEngineVersion() })}
|
|
340
380
|
</footer>
|
|
@@ -695,7 +735,7 @@ ${sortedGroups.map((group) => {
|
|
|
695
735
|
</div>
|
|
696
736
|
|
|
697
737
|
${itemsHtml}
|
|
698
|
-
|
|
738
|
+
${renderNoScriptSection(result)}
|
|
699
739
|
<p class="closing">${t("plain.closing")}</p>
|
|
700
740
|
</div>
|
|
701
741
|
|
|
@@ -736,6 +776,26 @@ async function generatePDF(htmlContent, outputPath) {
|
|
|
736
776
|
}
|
|
737
777
|
}
|
|
738
778
|
|
|
779
|
+
// src/cli/parse-options.ts
|
|
780
|
+
var MAX_HYDRATION_WAIT_MS = 6e4;
|
|
781
|
+
var InvalidOptionError = class extends Error {
|
|
782
|
+
};
|
|
783
|
+
function parseHydrationWait(raw) {
|
|
784
|
+
const trimmed = String(raw).trim();
|
|
785
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
786
|
+
throw new InvalidOptionError(
|
|
787
|
+
`Invalid --wait-for-hydration value '${raw}'. Expected a whole number of milliseconds between 0 and ${MAX_HYDRATION_WAIT_MS} (e.g. --wait-for-hydration 5000).`
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
const ms = Number(trimmed);
|
|
791
|
+
if (ms > MAX_HYDRATION_WAIT_MS) {
|
|
792
|
+
throw new InvalidOptionError(
|
|
793
|
+
`--wait-for-hydration ${ms} is too high. The maximum is ${MAX_HYDRATION_WAIT_MS} ms. A page that has not hydrated within a minute will not hydrate at all.`
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
return ms;
|
|
797
|
+
}
|
|
798
|
+
|
|
739
799
|
// src/cli/cloud-client.ts
|
|
740
800
|
function transformToCloudPayload(result) {
|
|
741
801
|
const violations = result.reports.map((report) => {
|
|
@@ -816,6 +876,31 @@ async function sendToCloud(config, result) {
|
|
|
816
876
|
|
|
817
877
|
// src/cli/index.ts
|
|
818
878
|
import { cosmiconfig } from "cosmiconfig";
|
|
879
|
+
function renderNoScriptAdvisory(noScript) {
|
|
880
|
+
console.log(chalk.bold(t("cli.noscript_heading")));
|
|
881
|
+
if (noScript.verdict === "unknown") {
|
|
882
|
+
console.log(chalk.gray(` ${t("cli.noscript_unknown")}${noScript.error ? ` (${noScript.error})` : ""}`));
|
|
883
|
+
console.log(chalk.gray(` ${t("cli.noscript_advisory")}`));
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
const percent = Math.round(noScript.coverageRatio * 100);
|
|
887
|
+
const color = noScript.verdict === "empty" ? chalk.red : noScript.verdict === "partial" ? chalk.yellow : chalk.green;
|
|
888
|
+
const icon = noScript.verdict === "empty" ? "\u{1F534}" : noScript.verdict === "partial" ? "\u{1F7E1}" : "\u{1F7E2}";
|
|
889
|
+
const summary = noScript.verdict === "empty" ? t("cli.noscript_empty") : noScript.verdict === "partial" ? t("cli.noscript_partial") : t("cli.noscript_ok");
|
|
890
|
+
console.log(` ${icon} ${color.bold(summary)}`);
|
|
891
|
+
if (noScript.verdict !== "ok") {
|
|
892
|
+
console.log(chalk.white(` ${t("cli.noscript_impact")}`));
|
|
893
|
+
}
|
|
894
|
+
console.log(chalk.white(` ${t("cli.noscript_coverage", {
|
|
895
|
+
percent,
|
|
896
|
+
without: noScript.textLengthWithoutJs,
|
|
897
|
+
with: noScript.textLengthWithJs
|
|
898
|
+
})}`));
|
|
899
|
+
if (noScript.verdict !== "ok") {
|
|
900
|
+
console.log(chalk.gray(` ${noScript.hasNoScriptFallback ? t("cli.noscript_fallback") : t("cli.noscript_no_fallback")}`));
|
|
901
|
+
}
|
|
902
|
+
console.log(chalk.gray(` ${t("cli.noscript_advisory")}`));
|
|
903
|
+
}
|
|
819
904
|
function isValidUrl(urlString) {
|
|
820
905
|
try {
|
|
821
906
|
const url = new URL(urlString);
|
|
@@ -826,10 +911,20 @@ function isValidUrl(urlString) {
|
|
|
826
911
|
}
|
|
827
912
|
var program = new Command();
|
|
828
913
|
program.name("hd-a11y-scan").description("HolmDigital Regulatory Scanner").version(getEngineVersion());
|
|
829
|
-
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").option("--audience <mode>", "Output audience: developer (default) or plain", "developer").option("--plain", "Alias for --audience plain (klarspr\xE5ksl\xE4ge for non-technical recipients)").action(async (url, cliOptions) => {
|
|
914
|
+
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").option("--audience <mode>", "Output audience: developer (default) or plain", "developer").option("--plain", "Alias for --audience plain (klarspr\xE5ksl\xE4ge for non-technical recipients)").option("--noscript-check", "Robustness probe: measure how much content is available without JavaScript. Advisory only, never affects the compliance score.").option("--wait-for-hydration <ms>", `Milliseconds to wait after network idle so client-rendered SPAs finish hydrating before axe runs (default 2500, 0 disables, max ${MAX_HYDRATION_WAIT_MS})`).action(async (url, cliOptions) => {
|
|
830
915
|
const explorer = cosmiconfig("a11y");
|
|
831
916
|
const configResult = await explorer.search();
|
|
832
917
|
const fileConfig = configResult ? configResult.config : {};
|
|
918
|
+
let waitForHydrationMs;
|
|
919
|
+
try {
|
|
920
|
+
waitForHydrationMs = cliOptions.waitForHydration !== void 0 ? parseHydrationWait(cliOptions.waitForHydration) : fileConfig.waitForHydrationMs !== void 0 ? parseHydrationWait(String(fileConfig.waitForHydrationMs)) : void 0;
|
|
921
|
+
} catch (e) {
|
|
922
|
+
if (e instanceof InvalidOptionError) {
|
|
923
|
+
console.error(chalk.red(e.message));
|
|
924
|
+
process.exit(1);
|
|
925
|
+
}
|
|
926
|
+
throw e;
|
|
927
|
+
}
|
|
833
928
|
const options = {
|
|
834
929
|
lang: cliOptions.lang || fileConfig.lang || "en",
|
|
835
930
|
ci: cliOptions.ci ?? fileConfig.ci ?? false,
|
|
@@ -855,6 +950,9 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
855
950
|
publishDate: cliOptions.publishDate || fileConfig.publishDate,
|
|
856
951
|
light: cliOptions.light ?? fileConfig.light ?? false,
|
|
857
952
|
plain: cliOptions.plain ?? fileConfig.plain ?? false,
|
|
953
|
+
// Commander camelCase:ar --noscript-check till noscriptCheck.
|
|
954
|
+
noScriptCheck: cliOptions.noscriptCheck ?? fileConfig.noScriptCheck ?? false,
|
|
955
|
+
waitForHydrationMs,
|
|
858
956
|
audience: cliOptions.plain ? "plain" : cliOptions.audience || fileConfig.audience || "developer"
|
|
859
957
|
};
|
|
860
958
|
setLanguage(options.lang);
|
|
@@ -892,7 +990,9 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
892
990
|
silent: options.json || options.light,
|
|
893
991
|
severityThreshold: options.threshold,
|
|
894
992
|
invalidHttpsCert: options.invalidHttpsCert,
|
|
895
|
-
light: options.light
|
|
993
|
+
light: options.light,
|
|
994
|
+
noScriptCheck: options.noScriptCheck,
|
|
995
|
+
waitForHydrationMs: options.waitForHydrationMs
|
|
896
996
|
});
|
|
897
997
|
if (spinner) spinner.text = t("cli.analyzing");
|
|
898
998
|
const result = await scanner.scan();
|
|
@@ -929,6 +1029,9 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
929
1029
|
complianceStatus: result.complianceStatus,
|
|
930
1030
|
stats: result.stats,
|
|
931
1031
|
scanDuration: result.metadata.scanDuration,
|
|
1032
|
+
// Rådgivande robusthetsindikator. Undefined när --noscript-check
|
|
1033
|
+
// inte används och faller då ur JSON:en av sig själv.
|
|
1034
|
+
noScript: result.noScript,
|
|
932
1035
|
topIssues: result.reports.slice(0, 5).map((r) => ({
|
|
933
1036
|
id: r.ruleId,
|
|
934
1037
|
impact: r.holmdigitalInsight.diggRisk,
|
|
@@ -960,17 +1063,22 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
960
1063
|
console.log(chalk.gray(`
|
|
961
1064
|
Scan: ${result.metadata.scanDuration}ms | ${result.metadata.engineVersion}`));
|
|
962
1065
|
} else if (options.audience === "plain") {
|
|
963
|
-
const { renderPlainReport } = await import("../plain-report-
|
|
1066
|
+
const { renderPlainReport } = await import("../plain-report-OF2MNEE4.mjs");
|
|
964
1067
|
renderPlainReport(result, plainFallbackFrom ? "en" : options.lang, plainFallbackFrom);
|
|
965
1068
|
} else {
|
|
966
1069
|
console.log("\n");
|
|
967
1070
|
const scoreColor = result.score >= 90 ? chalk.green : result.score >= 70 ? chalk.yellow : chalk.red;
|
|
968
1071
|
console.log(chalk.bold(`[ Compliance Score: ${scoreColor(result.score + "/100")} ] ${result.score >= 90 ? "\u{1F7E2}" : result.score >= 70 ? "\u{1F7E1}" : "\u{1F534}"}`));
|
|
969
1072
|
if (result.score === 100) {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1073
|
+
if (isBadgeWithheldByRobustness(result.noScript)) {
|
|
1074
|
+
console.log(chalk.yellow(`
|
|
1075
|
+
${t("cli.badge_withheld")}`));
|
|
1076
|
+
} else {
|
|
1077
|
+
const badge = generateBadgeMarkdown(result.score);
|
|
1078
|
+
if (badge) {
|
|
1079
|
+
console.log(chalk.green.bold("\n\u{1F3C6} Perfect Score! Here is your accessibility badge:"));
|
|
1080
|
+
console.log(chalk.white(badge));
|
|
1081
|
+
}
|
|
974
1082
|
}
|
|
975
1083
|
}
|
|
976
1084
|
console.log(chalk.gray("----------------------------------------"));
|
|
@@ -1066,6 +1174,9 @@ Scan: ${result.metadata.scanDuration}ms | ${result.metadata.engineVersion}`));
|
|
|
1066
1174
|
});
|
|
1067
1175
|
}
|
|
1068
1176
|
}
|
|
1177
|
+
if (result.noScript && !options.json) {
|
|
1178
|
+
renderNoScriptAdvisory(result.noScript);
|
|
1179
|
+
}
|
|
1069
1180
|
if (options.ci && result.reports.length > 0) {
|
|
1070
1181
|
const { generateGitHubActionsAnnotations } = await import("../github-actions-5AFDFD4T.mjs");
|
|
1071
1182
|
generateGitHubActionsAnnotations(result.reports);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnrichedReport, RegulatoryReport } from '@holmdigital/standards';
|
|
2
|
-
import { Page } from 'puppeteer';
|
|
2
|
+
import { Browser, Page } from 'puppeteer';
|
|
3
3
|
|
|
4
4
|
interface ValidationResult {
|
|
5
5
|
valid: boolean;
|
|
@@ -12,6 +12,36 @@ interface ValidationResult {
|
|
|
12
12
|
}>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
declare const NOSCRIPT_EMPTY_THRESHOLD = 0.05;
|
|
16
|
+
declare const NOSCRIPT_PARTIAL_THRESHOLD = 0.5;
|
|
17
|
+
type NoScriptVerdict = 'ok' | 'partial' | 'empty' | 'unknown';
|
|
18
|
+
interface NoScriptResult {
|
|
19
|
+
textLengthWithoutJs: number;
|
|
20
|
+
textLengthWithJs: number;
|
|
21
|
+
coverageRatio: number;
|
|
22
|
+
verdict: NoScriptVerdict;
|
|
23
|
+
hasContentWithoutJs: boolean;
|
|
24
|
+
hasNoScriptFallback: boolean;
|
|
25
|
+
isWcagViolation: false;
|
|
26
|
+
affectsScore: false;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
declare function evaluateNoScriptCoverage(textLengthWithoutJs: number, textLengthWithJs: number, hasNoScriptFallback?: boolean): NoScriptResult;
|
|
30
|
+
interface NoScriptProbeOptions {
|
|
31
|
+
url: string;
|
|
32
|
+
userAgent?: string;
|
|
33
|
+
viewport?: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
timeout?: number;
|
|
38
|
+
}
|
|
39
|
+
interface NoScriptProbeMeasurement {
|
|
40
|
+
textLength: number;
|
|
41
|
+
hasNoScriptFallback: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function probeWithoutJavaScript(browser: Browser, options: NoScriptProbeOptions): Promise<NoScriptProbeMeasurement>;
|
|
44
|
+
|
|
15
45
|
declare function getEngineVersion(): string;
|
|
16
46
|
interface ScannerOptions {
|
|
17
47
|
url: string;
|
|
@@ -27,6 +57,7 @@ interface ScannerOptions {
|
|
|
27
57
|
invalidHttpsCert?: boolean;
|
|
28
58
|
light?: boolean;
|
|
29
59
|
waitForHydrationMs?: number;
|
|
60
|
+
noScriptCheck?: boolean;
|
|
30
61
|
}
|
|
31
62
|
interface ScanMetadata {
|
|
32
63
|
engineVersion: string;
|
|
@@ -52,6 +83,7 @@ interface ScanResult {
|
|
|
52
83
|
score: number;
|
|
53
84
|
complianceStatus: 'PASS' | 'FAIL';
|
|
54
85
|
htmlValidation?: ValidationResult;
|
|
86
|
+
noScript?: NoScriptResult;
|
|
55
87
|
legalSummary?: {
|
|
56
88
|
wadApplicable: number;
|
|
57
89
|
eaaApplicable: number;
|
|
@@ -68,6 +100,7 @@ declare class RegulatoryScanner {
|
|
|
68
100
|
private initBrowser;
|
|
69
101
|
private getPage;
|
|
70
102
|
private injectAxe;
|
|
103
|
+
private runNoScriptCheck;
|
|
71
104
|
private enrichResultsLight;
|
|
72
105
|
private enrichResults;
|
|
73
106
|
private generateResultPackage;
|
|
@@ -126,7 +159,18 @@ var cli = {
|
|
|
126
159
|
use_component: "Use component: {component}",
|
|
127
160
|
pseudo_tests: "\n🧬 Generating Pseudo-Automation Tests...\n",
|
|
128
161
|
test_for: "Test for {ruleId}:",
|
|
129
|
-
junit_saved: "JUnit XML report saved to {path}"
|
|
162
|
+
junit_saved: "JUnit XML report saved to {path}",
|
|
163
|
+
noscript_heading: "\n🧪 Robustness without JavaScript (advisory)",
|
|
164
|
+
noscript_coverage: "Content available without JavaScript: {percent}% ({without} of {with} characters)",
|
|
165
|
+
noscript_empty: "The page is effectively empty without JavaScript.",
|
|
166
|
+
noscript_partial: "A substantial part of the content is missing without JavaScript.",
|
|
167
|
+
noscript_ok: "Core content is available without JavaScript.",
|
|
168
|
+
noscript_unknown: "Could not be measured.",
|
|
169
|
+
noscript_fallback: "A <noscript> fallback is present.",
|
|
170
|
+
noscript_no_fallback: "No <noscript> fallback was found.",
|
|
171
|
+
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.",
|
|
172
|
+
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.",
|
|
173
|
+
badge_withheld: "100/100 with no findings. The robustness check is not clean, so we do not generate a shareable badge."
|
|
130
174
|
};
|
|
131
175
|
var report = {
|
|
132
176
|
title: "Accessibility Report - {url}",
|
|
@@ -195,4 +239,4 @@ interface StatementMetadata {
|
|
|
195
239
|
declare function generateStatementContent(result: ScanResult, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<string>;
|
|
196
240
|
declare function generateStatement(result: ScanResult, outputPath: string, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<void>;
|
|
197
241
|
|
|
198
|
-
export { PseudoAutomationEngine, RegulatoryScanner, type ScanMetadata, type ScanResult, type ScannerOptions, type StatementMetadata, VirtualDOMBuilder, type VirtualDOMConfig, type VirtualNode, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, setLanguage, t };
|
|
242
|
+
export { NOSCRIPT_EMPTY_THRESHOLD, NOSCRIPT_PARTIAL_THRESHOLD, type NoScriptProbeMeasurement, type NoScriptProbeOptions, type NoScriptResult, type NoScriptVerdict, PseudoAutomationEngine, RegulatoryScanner, type ScanMetadata, type ScanResult, type ScannerOptions, type StatementMetadata, VirtualDOMBuilder, type VirtualDOMConfig, type VirtualNode, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, probeWithoutJavaScript, setLanguage, t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnrichedReport, RegulatoryReport } from '@holmdigital/standards';
|
|
2
|
-
import { Page } from 'puppeteer';
|
|
2
|
+
import { Browser, Page } from 'puppeteer';
|
|
3
3
|
|
|
4
4
|
interface ValidationResult {
|
|
5
5
|
valid: boolean;
|
|
@@ -12,6 +12,36 @@ interface ValidationResult {
|
|
|
12
12
|
}>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
declare const NOSCRIPT_EMPTY_THRESHOLD = 0.05;
|
|
16
|
+
declare const NOSCRIPT_PARTIAL_THRESHOLD = 0.5;
|
|
17
|
+
type NoScriptVerdict = 'ok' | 'partial' | 'empty' | 'unknown';
|
|
18
|
+
interface NoScriptResult {
|
|
19
|
+
textLengthWithoutJs: number;
|
|
20
|
+
textLengthWithJs: number;
|
|
21
|
+
coverageRatio: number;
|
|
22
|
+
verdict: NoScriptVerdict;
|
|
23
|
+
hasContentWithoutJs: boolean;
|
|
24
|
+
hasNoScriptFallback: boolean;
|
|
25
|
+
isWcagViolation: false;
|
|
26
|
+
affectsScore: false;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
declare function evaluateNoScriptCoverage(textLengthWithoutJs: number, textLengthWithJs: number, hasNoScriptFallback?: boolean): NoScriptResult;
|
|
30
|
+
interface NoScriptProbeOptions {
|
|
31
|
+
url: string;
|
|
32
|
+
userAgent?: string;
|
|
33
|
+
viewport?: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
timeout?: number;
|
|
38
|
+
}
|
|
39
|
+
interface NoScriptProbeMeasurement {
|
|
40
|
+
textLength: number;
|
|
41
|
+
hasNoScriptFallback: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function probeWithoutJavaScript(browser: Browser, options: NoScriptProbeOptions): Promise<NoScriptProbeMeasurement>;
|
|
44
|
+
|
|
15
45
|
declare function getEngineVersion(): string;
|
|
16
46
|
interface ScannerOptions {
|
|
17
47
|
url: string;
|
|
@@ -27,6 +57,7 @@ interface ScannerOptions {
|
|
|
27
57
|
invalidHttpsCert?: boolean;
|
|
28
58
|
light?: boolean;
|
|
29
59
|
waitForHydrationMs?: number;
|
|
60
|
+
noScriptCheck?: boolean;
|
|
30
61
|
}
|
|
31
62
|
interface ScanMetadata {
|
|
32
63
|
engineVersion: string;
|
|
@@ -52,6 +83,7 @@ interface ScanResult {
|
|
|
52
83
|
score: number;
|
|
53
84
|
complianceStatus: 'PASS' | 'FAIL';
|
|
54
85
|
htmlValidation?: ValidationResult;
|
|
86
|
+
noScript?: NoScriptResult;
|
|
55
87
|
legalSummary?: {
|
|
56
88
|
wadApplicable: number;
|
|
57
89
|
eaaApplicable: number;
|
|
@@ -68,6 +100,7 @@ declare class RegulatoryScanner {
|
|
|
68
100
|
private initBrowser;
|
|
69
101
|
private getPage;
|
|
70
102
|
private injectAxe;
|
|
103
|
+
private runNoScriptCheck;
|
|
71
104
|
private enrichResultsLight;
|
|
72
105
|
private enrichResults;
|
|
73
106
|
private generateResultPackage;
|
|
@@ -126,7 +159,18 @@ var cli = {
|
|
|
126
159
|
use_component: "Use component: {component}",
|
|
127
160
|
pseudo_tests: "\n🧬 Generating Pseudo-Automation Tests...\n",
|
|
128
161
|
test_for: "Test for {ruleId}:",
|
|
129
|
-
junit_saved: "JUnit XML report saved to {path}"
|
|
162
|
+
junit_saved: "JUnit XML report saved to {path}",
|
|
163
|
+
noscript_heading: "\n🧪 Robustness without JavaScript (advisory)",
|
|
164
|
+
noscript_coverage: "Content available without JavaScript: {percent}% ({without} of {with} characters)",
|
|
165
|
+
noscript_empty: "The page is effectively empty without JavaScript.",
|
|
166
|
+
noscript_partial: "A substantial part of the content is missing without JavaScript.",
|
|
167
|
+
noscript_ok: "Core content is available without JavaScript.",
|
|
168
|
+
noscript_unknown: "Could not be measured.",
|
|
169
|
+
noscript_fallback: "A <noscript> fallback is present.",
|
|
170
|
+
noscript_no_fallback: "No <noscript> fallback was found.",
|
|
171
|
+
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.",
|
|
172
|
+
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.",
|
|
173
|
+
badge_withheld: "100/100 with no findings. The robustness check is not clean, so we do not generate a shareable badge."
|
|
130
174
|
};
|
|
131
175
|
var report = {
|
|
132
176
|
title: "Accessibility Report - {url}",
|
|
@@ -195,4 +239,4 @@ interface StatementMetadata {
|
|
|
195
239
|
declare function generateStatementContent(result: ScanResult, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<string>;
|
|
196
240
|
declare function generateStatement(result: ScanResult, outputPath: string, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<void>;
|
|
197
241
|
|
|
198
|
-
export { PseudoAutomationEngine, RegulatoryScanner, type ScanMetadata, type ScanResult, type ScannerOptions, type StatementMetadata, VirtualDOMBuilder, type VirtualDOMConfig, type VirtualNode, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, setLanguage, t };
|
|
242
|
+
export { NOSCRIPT_EMPTY_THRESHOLD, NOSCRIPT_PARTIAL_THRESHOLD, type NoScriptProbeMeasurement, type NoScriptProbeOptions, type NoScriptResult, type NoScriptVerdict, PseudoAutomationEngine, RegulatoryScanner, type ScanMetadata, type ScanResult, type ScannerOptions, type StatementMetadata, VirtualDOMBuilder, type VirtualDOMConfig, type VirtualNode, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, probeWithoutJavaScript, setLanguage, t };
|