@holmdigital/engine 3.1.5 → 3.2.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.
@@ -246,8 +246,14 @@ function selectMappedRuleId(ruleId, tags, rules, selfMatchingIds = /* @__PURE__
246
246
  matched.sort((a, b) => compareCriteria(a.wcagCriteria, b.wcagCriteria));
247
247
  return matched[0].ruleId;
248
248
  }
249
+ var INTERSTITIAL_TITLE = /\b(v[aä]nta|please wait|just a moment|checking your browser|attention required|redirecting|one moment|ett [oö]gonblick|verifying you are human)\b/i;
250
+ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
251
+ if (pageTitle && INTERSTITIAL_TITLE.test(pageTitle)) return true;
252
+ if (hasMetaRefresh && bodyTextLength < 400) return true;
253
+ return false;
254
+ }
249
255
  function getEngineVersion() {
250
- return "3.1.5";
256
+ return "3.2.0";
251
257
  }
252
258
  function getStandardsVersion() {
253
259
  try {
@@ -294,6 +300,7 @@ var RegulatoryScanner = class {
294
300
  const startTime = Date.now();
295
301
  let pageTitle;
296
302
  let pageLanguage;
303
+ let interstitialSuspected;
297
304
  let passedCount = 0;
298
305
  try {
299
306
  await this.initBrowser();
@@ -332,6 +339,18 @@ var RegulatoryScanner = class {
332
339
  }
333
340
  pageTitle = await page.title();
334
341
  pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
342
+ const interstitialSignals = await page.evaluate(() => ({
343
+ hasMetaRefresh: !!document.querySelector('meta[http-equiv="refresh" i]'),
344
+ bodyTextLength: (document.body?.innerText ?? "").trim().length
345
+ }));
346
+ interstitialSuspected = isInterstitialPage(
347
+ pageTitle,
348
+ interstitialSignals.hasMetaRefresh,
349
+ interstitialSignals.bodyTextLength
350
+ );
351
+ if (interstitialSuspected) {
352
+ this.log("\u26A0\uFE0F Sidan ser ut som en v\xE4nta-/omdirigerings-/challenge-sida \u2014 resultatet kan g\xE4lla en platsh\xE5llarsida, inte det riktiga inneh\xE5llet. Prova ett h\xF6gre --wait-for-hydration <ms>.");
353
+ }
335
354
  let textLengthWithJs;
336
355
  if (this.options.noScriptCheck) {
337
356
  textLengthWithJs = await page.evaluate(
@@ -376,7 +395,7 @@ var RegulatoryScanner = class {
376
395
  noScript = await this.runNoScriptCheck(textLengthWithJs ?? 0);
377
396
  }
378
397
  const scanDuration = Date.now() - startTime;
379
- const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage);
398
+ const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected);
380
399
  if (htmlValidation) {
381
400
  result.htmlValidation = htmlValidation;
382
401
  }
@@ -680,7 +699,7 @@ var RegulatoryScanner = class {
680
699
  }
681
700
  return reports;
682
701
  }
683
- generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage) {
702
+ generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected) {
684
703
  const scored = reports.filter((r) => !r.cantTell);
685
704
  const needsReview = reports.length - scored.length;
686
705
  const stats = {
@@ -719,7 +738,10 @@ var RegulatoryScanner = class {
719
738
  standardsVersion: getStandardsVersion(),
720
739
  scanDuration,
721
740
  pageTitle,
722
- pageLanguage
741
+ pageLanguage,
742
+ // Intern #43: bara med när flaggan är satt, så äldre snapshots/JSON
743
+ // inte får ett nytt fält på nej-fallet.
744
+ ...interstitialSuspected ? { interstitialSuspected: true } : {}
723
745
  };
724
746
  const reportsWithContext = scored.filter((r) => r.legalContext);
725
747
  const legalSummary = {
@@ -1220,7 +1242,9 @@ export {
1220
1242
  criteriaFromTags,
1221
1243
  getSelfMatchingRuleIds,
1222
1244
  selectMappedRuleId,
1245
+ isInterstitialPage,
1223
1246
  getEngineVersion,
1247
+ getStandardsVersion,
1224
1248
  RegulatoryScanner,
1225
1249
  PseudoAutomationEngine,
1226
1250
  generateBadgeUrl,
package/dist/cli/index.js CHANGED
@@ -1495,8 +1495,14 @@ function selectMappedRuleId(ruleId, tags, rules, selfMatchingIds = /* @__PURE__
1495
1495
  matched.sort((a, b) => compareCriteria(a.wcagCriteria, b.wcagCriteria));
1496
1496
  return matched[0].ruleId;
1497
1497
  }
1498
+ var INTERSTITIAL_TITLE = /\b(v[aä]nta|please wait|just a moment|checking your browser|attention required|redirecting|one moment|ett [oö]gonblick|verifying you are human)\b/i;
1499
+ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
1500
+ if (pageTitle && INTERSTITIAL_TITLE.test(pageTitle)) return true;
1501
+ if (hasMetaRefresh && bodyTextLength < 400) return true;
1502
+ return false;
1503
+ }
1498
1504
  function getEngineVersion() {
1499
- return "3.1.5";
1505
+ return "3.2.0";
1500
1506
  }
1501
1507
  function getStandardsVersion() {
1502
1508
  try {
@@ -1543,6 +1549,7 @@ var RegulatoryScanner = class {
1543
1549
  const startTime = Date.now();
1544
1550
  let pageTitle;
1545
1551
  let pageLanguage;
1552
+ let interstitialSuspected;
1546
1553
  let passedCount = 0;
1547
1554
  try {
1548
1555
  await this.initBrowser();
@@ -1581,6 +1588,18 @@ var RegulatoryScanner = class {
1581
1588
  }
1582
1589
  pageTitle = await page.title();
1583
1590
  pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
1591
+ const interstitialSignals = await page.evaluate(() => ({
1592
+ hasMetaRefresh: !!document.querySelector('meta[http-equiv="refresh" i]'),
1593
+ bodyTextLength: (document.body?.innerText ?? "").trim().length
1594
+ }));
1595
+ interstitialSuspected = isInterstitialPage(
1596
+ pageTitle,
1597
+ interstitialSignals.hasMetaRefresh,
1598
+ interstitialSignals.bodyTextLength
1599
+ );
1600
+ if (interstitialSuspected) {
1601
+ this.log("\u26A0\uFE0F Sidan ser ut som en v\xE4nta-/omdirigerings-/challenge-sida \u2014 resultatet kan g\xE4lla en platsh\xE5llarsida, inte det riktiga inneh\xE5llet. Prova ett h\xF6gre --wait-for-hydration <ms>.");
1602
+ }
1584
1603
  let textLengthWithJs;
1585
1604
  if (this.options.noScriptCheck) {
1586
1605
  textLengthWithJs = await page.evaluate(
@@ -1625,7 +1644,7 @@ var RegulatoryScanner = class {
1625
1644
  noScript = await this.runNoScriptCheck(textLengthWithJs ?? 0);
1626
1645
  }
1627
1646
  const scanDuration = Date.now() - startTime;
1628
- const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage);
1647
+ const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected);
1629
1648
  if (htmlValidation) {
1630
1649
  result.htmlValidation = htmlValidation;
1631
1650
  }
@@ -1929,7 +1948,7 @@ var RegulatoryScanner = class {
1929
1948
  }
1930
1949
  return reports;
1931
1950
  }
1932
- generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage) {
1951
+ generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected) {
1933
1952
  const scored = reports.filter((r) => !r.cantTell);
1934
1953
  const needsReview = reports.length - scored.length;
1935
1954
  const stats = {
@@ -1968,7 +1987,10 @@ var RegulatoryScanner = class {
1968
1987
  standardsVersion: getStandardsVersion(),
1969
1988
  scanDuration,
1970
1989
  pageTitle,
1971
- pageLanguage
1990
+ pageLanguage,
1991
+ // Intern #43: bara med när flaggan är satt, så äldre snapshots/JSON
1992
+ // inte får ett nytt fält på nej-fallet.
1993
+ ...interstitialSuspected ? { interstitialSuspected: true } : {}
1972
1994
  };
1973
1995
  const reportsWithContext = scored.filter((r) => r.legalContext);
1974
1996
  const legalSummary = {
@@ -8,7 +8,7 @@ import {
8
8
  generateStatementContent,
9
9
  getEngineVersion,
10
10
  isBadgeWithheldByRobustness
11
- } from "../chunk-QIM5ZZCX.mjs";
11
+ } from "../chunk-D66R3ESC.mjs";
12
12
  import {
13
13
  groupReportsByRule,
14
14
  impactBreakdown,
package/dist/index.d.mts CHANGED
@@ -46,7 +46,9 @@ declare function wcagTagToCriterion(tag: string): string | null;
46
46
  declare function criteriaFromTags(tags: string[]): string[];
47
47
  declare function getSelfMatchingRuleIds(rules: ConvergenceRule[]): Set<string>;
48
48
  declare function selectMappedRuleId(ruleId: string, tags: string[], rules: ConvergenceRule[], selfMatchingIds?: Set<string>): string | null;
49
+ declare function isInterstitialPage(pageTitle: string | undefined, hasMetaRefresh: boolean, bodyTextLength: number): boolean;
49
50
  declare function getEngineVersion(): string;
51
+ declare function getStandardsVersion(): string;
50
52
  interface ScannerOptions {
51
53
  url: string;
52
54
  headless?: boolean;
@@ -70,6 +72,7 @@ interface ScanMetadata {
70
72
  scanDuration: number;
71
73
  pageTitle?: string;
72
74
  pageLanguage?: string;
75
+ interstitialSuspected?: boolean;
73
76
  }
74
77
  interface ScanResult {
75
78
  url: string;
@@ -250,4 +253,4 @@ declare function resolveNationalLawReference(country: Country, sector: 'public'
250
253
  declare function generateStatementContent(result: ScanResult, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<string>;
251
254
  declare function generateStatement(result: ScanResult, outputPath: string, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<void>;
252
255
 
253
- 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, criteriaFromTags, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, getSelfMatchingRuleIds, probeWithoutJavaScript, resolveNationalLawReference, selectMappedRuleId, setLanguage, t, wcagTagToCriterion };
256
+ 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, criteriaFromTags, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, getSelfMatchingRuleIds, getStandardsVersion, isInterstitialPage, probeWithoutJavaScript, resolveNationalLawReference, selectMappedRuleId, setLanguage, t, wcagTagToCriterion };
package/dist/index.d.ts CHANGED
@@ -46,7 +46,9 @@ declare function wcagTagToCriterion(tag: string): string | null;
46
46
  declare function criteriaFromTags(tags: string[]): string[];
47
47
  declare function getSelfMatchingRuleIds(rules: ConvergenceRule[]): Set<string>;
48
48
  declare function selectMappedRuleId(ruleId: string, tags: string[], rules: ConvergenceRule[], selfMatchingIds?: Set<string>): string | null;
49
+ declare function isInterstitialPage(pageTitle: string | undefined, hasMetaRefresh: boolean, bodyTextLength: number): boolean;
49
50
  declare function getEngineVersion(): string;
51
+ declare function getStandardsVersion(): string;
50
52
  interface ScannerOptions {
51
53
  url: string;
52
54
  headless?: boolean;
@@ -70,6 +72,7 @@ interface ScanMetadata {
70
72
  scanDuration: number;
71
73
  pageTitle?: string;
72
74
  pageLanguage?: string;
75
+ interstitialSuspected?: boolean;
73
76
  }
74
77
  interface ScanResult {
75
78
  url: string;
@@ -250,4 +253,4 @@ declare function resolveNationalLawReference(country: Country, sector: 'public'
250
253
  declare function generateStatementContent(result: ScanResult, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<string>;
251
254
  declare function generateStatement(result: ScanResult, outputPath: string, lang?: string, format?: 'html' | 'md' | 'markdown', metadata?: StatementMetadata): Promise<void>;
252
255
 
253
- 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, criteriaFromTags, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, getSelfMatchingRuleIds, probeWithoutJavaScript, resolveNationalLawReference, selectMappedRuleId, setLanguage, t, wcagTagToCriterion };
256
+ 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, criteriaFromTags, evaluateNoScriptCoverage, generateStatement, generateStatementContent, getCurrentLang, getEngineVersion, getSelfMatchingRuleIds, getStandardsVersion, isInterstitialPage, probeWithoutJavaScript, resolveNationalLawReference, selectMappedRuleId, setLanguage, t, wcagTagToCriterion };
package/dist/index.js CHANGED
@@ -912,6 +912,8 @@ __export(index_exports, {
912
912
  getCurrentLang: () => getCurrentLang,
913
913
  getEngineVersion: () => getEngineVersion,
914
914
  getSelfMatchingRuleIds: () => getSelfMatchingRuleIds,
915
+ getStandardsVersion: () => getStandardsVersion,
916
+ isInterstitialPage: () => isInterstitialPage,
915
917
  probeWithoutJavaScript: () => probeWithoutJavaScript,
916
918
  resolveNationalLawReference: () => resolveNationalLawReference,
917
919
  selectMappedRuleId: () => selectMappedRuleId,
@@ -1166,8 +1168,14 @@ function selectMappedRuleId(ruleId, tags, rules, selfMatchingIds = /* @__PURE__
1166
1168
  matched.sort((a, b) => compareCriteria(a.wcagCriteria, b.wcagCriteria));
1167
1169
  return matched[0].ruleId;
1168
1170
  }
1171
+ var INTERSTITIAL_TITLE = /\b(v[aä]nta|please wait|just a moment|checking your browser|attention required|redirecting|one moment|ett [oö]gonblick|verifying you are human)\b/i;
1172
+ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
1173
+ if (pageTitle && INTERSTITIAL_TITLE.test(pageTitle)) return true;
1174
+ if (hasMetaRefresh && bodyTextLength < 400) return true;
1175
+ return false;
1176
+ }
1169
1177
  function getEngineVersion() {
1170
- return "3.1.5";
1178
+ return "3.2.0";
1171
1179
  }
1172
1180
  function getStandardsVersion() {
1173
1181
  try {
@@ -1214,6 +1222,7 @@ var RegulatoryScanner = class {
1214
1222
  const startTime = Date.now();
1215
1223
  let pageTitle;
1216
1224
  let pageLanguage;
1225
+ let interstitialSuspected;
1217
1226
  let passedCount = 0;
1218
1227
  try {
1219
1228
  await this.initBrowser();
@@ -1252,6 +1261,18 @@ var RegulatoryScanner = class {
1252
1261
  }
1253
1262
  pageTitle = await page.title();
1254
1263
  pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
1264
+ const interstitialSignals = await page.evaluate(() => ({
1265
+ hasMetaRefresh: !!document.querySelector('meta[http-equiv="refresh" i]'),
1266
+ bodyTextLength: (document.body?.innerText ?? "").trim().length
1267
+ }));
1268
+ interstitialSuspected = isInterstitialPage(
1269
+ pageTitle,
1270
+ interstitialSignals.hasMetaRefresh,
1271
+ interstitialSignals.bodyTextLength
1272
+ );
1273
+ if (interstitialSuspected) {
1274
+ this.log("\u26A0\uFE0F Sidan ser ut som en v\xE4nta-/omdirigerings-/challenge-sida \u2014 resultatet kan g\xE4lla en platsh\xE5llarsida, inte det riktiga inneh\xE5llet. Prova ett h\xF6gre --wait-for-hydration <ms>.");
1275
+ }
1255
1276
  let textLengthWithJs;
1256
1277
  if (this.options.noScriptCheck) {
1257
1278
  textLengthWithJs = await page.evaluate(
@@ -1296,7 +1317,7 @@ var RegulatoryScanner = class {
1296
1317
  noScript = await this.runNoScriptCheck(textLengthWithJs ?? 0);
1297
1318
  }
1298
1319
  const scanDuration = Date.now() - startTime;
1299
- const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage);
1320
+ const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected);
1300
1321
  if (htmlValidation) {
1301
1322
  result.htmlValidation = htmlValidation;
1302
1323
  }
@@ -1600,7 +1621,7 @@ var RegulatoryScanner = class {
1600
1621
  }
1601
1622
  return reports;
1602
1623
  }
1603
- generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage) {
1624
+ generateResultPackage(reports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected) {
1604
1625
  const scored = reports.filter((r) => !r.cantTell);
1605
1626
  const needsReview = reports.length - scored.length;
1606
1627
  const stats = {
@@ -1639,7 +1660,10 @@ var RegulatoryScanner = class {
1639
1660
  standardsVersion: getStandardsVersion(),
1640
1661
  scanDuration,
1641
1662
  pageTitle,
1642
- pageLanguage
1663
+ pageLanguage,
1664
+ // Intern #43: bara med när flaggan är satt, så äldre snapshots/JSON
1665
+ // inte får ett nytt fält på nej-fallet.
1666
+ ...interstitialSuspected ? { interstitialSuspected: true } : {}
1643
1667
  };
1644
1668
  const reportsWithContext = scored.filter((r) => r.legalContext);
1645
1669
  const legalSummary = {
@@ -2146,6 +2170,8 @@ async function generateStatement(result, outputPath, lang = "en", format = "html
2146
2170
  getCurrentLang,
2147
2171
  getEngineVersion,
2148
2172
  getSelfMatchingRuleIds,
2173
+ getStandardsVersion,
2174
+ isInterstitialPage,
2149
2175
  probeWithoutJavaScript,
2150
2176
  resolveNationalLawReference,
2151
2177
  selectMappedRuleId,
package/dist/index.mjs CHANGED
@@ -10,11 +10,13 @@ import {
10
10
  generateStatementContent,
11
11
  getEngineVersion,
12
12
  getSelfMatchingRuleIds,
13
+ getStandardsVersion,
14
+ isInterstitialPage,
13
15
  probeWithoutJavaScript,
14
16
  resolveNationalLawReference,
15
17
  selectMappedRuleId,
16
18
  wcagTagToCriterion
17
- } from "./chunk-QIM5ZZCX.mjs";
19
+ } from "./chunk-D66R3ESC.mjs";
18
20
  import {
19
21
  getCurrentLang,
20
22
  setLanguage,
@@ -35,6 +37,8 @@ export {
35
37
  getCurrentLang,
36
38
  getEngineVersion,
37
39
  getSelfMatchingRuleIds,
40
+ getStandardsVersion,
41
+ isInterstitialPage,
38
42
  probeWithoutJavaScript,
39
43
  resolveNationalLawReference,
40
44
  selectMappedRuleId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holmdigital/engine",
3
- "version": "3.1.5",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "dependencies": {
88
88
  "@holmdigital/components": "^4.0.0",
89
- "@holmdigital/standards": "^3.0.2",
89
+ "@holmdigital/standards": "^3.0.5",
90
90
  "axe-core": "^4.13.0",
91
91
  "chalk": "^6.0.0",
92
92
  "commander": "^15.0.0",