@geonosis/walk 3.1.0 → 3.3.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +41 -10
  3. package/dist/browser.d.ts +2 -18
  4. package/dist/config.d.ts +3 -2
  5. package/dist/config.js +65 -15
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +11 -2
  8. package/dist/options.d.ts +2 -11
  9. package/dist/options.js +4 -1
  10. package/dist/probes/buy-box-above-fold.d.ts +1 -14
  11. package/dist/probes/buy-box-above-fold.js +3 -5
  12. package/dist/probes/define.d.ts +7 -0
  13. package/dist/probes/define.js +12 -0
  14. package/dist/probes/empty-section.d.ts +1 -16
  15. package/dist/probes/empty-section.js +3 -3
  16. package/dist/probes/error-page-status.d.ts +1 -20
  17. package/dist/probes/error-page-status.js +8 -31
  18. package/dist/probes/fabricated-claim.d.ts +1 -14
  19. package/dist/probes/fabricated-claim.js +6 -23
  20. package/dist/probes/fake-session.d.ts +1 -14
  21. package/dist/probes/fake-session.js +3 -4
  22. package/dist/probes/index.d.ts +1 -5
  23. package/dist/probes/light-on-light.d.ts +1 -15
  24. package/dist/probes/light-on-light.js +3 -3
  25. package/dist/probes/link-integrity.d.ts +2 -14
  26. package/dist/probes/link-integrity.js +19 -12
  27. package/dist/probes/money-format.d.ts +1 -14
  28. package/dist/probes/money-format.js +3 -3
  29. package/dist/probes/ops-leakage.d.ts +1 -13
  30. package/dist/probes/ops-leakage.js +6 -23
  31. package/dist/probes/orphan-url.d.ts +1 -13
  32. package/dist/probes/orphan-url.js +3 -3
  33. package/dist/probes/placeholder-asset.d.ts +1 -14
  34. package/dist/probes/placeholder-asset.js +3 -4
  35. package/dist/probes/stub-only-entity.d.ts +1 -14
  36. package/dist/probes/stub-only-entity.js +3 -3
  37. package/dist/probes/text-probe.d.ts +12 -0
  38. package/dist/probes/text-probe.js +37 -0
  39. package/dist/probes/thin-page.d.ts +1 -14
  40. package/dist/probes/thin-page.js +3 -3
  41. package/dist/types.d.ts +18 -55
  42. package/dist/types.js +11 -1
  43. package/dist/walk-cli.js +31 -8
  44. package/dist/walk.d.ts +5 -13
  45. package/dist/walk.js +81 -28
  46. package/package.json +19 -4
@@ -1,29 +1,12 @@
1
1
  // src/probes/fabricated-claim.ts
2
- import { collect } from "../browser.js";
3
- import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
- var fabricatedClaim = {
2
+ import { defineTextProbe } from "./text-probe.js";
3
+ var fabricatedClaim = defineTextProbe({
5
4
  class: "fabricated-claim",
5
+ evidence: (hit) => `"${hit.text}" is on the page, matching /${hit.pattern}/`,
6
6
  id: "fabricated-claim",
7
- needs: (options) => {
8
- const claims = requireStrings("fabricated-claim", options, "claims");
9
- assertPatterns("fabricated-claim", claims, patternFlags("fabricated-claim", options));
10
- },
11
- run: async (page, { options, url }) => {
12
- const hits = await collect(page, {
13
- flags: patternFlags("fabricated-claim", options),
14
- kind: "text",
15
- patterns: requireStrings("fabricated-claim", options, "claims"),
16
- scope: stringOption("fabricated-claim", options, "scope", "")
17
- });
18
- return hits.map((hit) => ({
19
- class: "fabricated-claim",
20
- evidence: `"${hit.text}" is on the page, matching /${hit.pattern}/`,
21
- selector: hit.selector,
22
- severity: "blocking",
23
- url
24
- }));
25
- }
26
- };
7
+ option: "claims",
8
+ severity: "blocking"
9
+ });
27
10
  export {
28
11
  fabricatedClaim
29
12
  };
@@ -1,14 +1 @@
1
- import { type Probe } from '../types.js';
2
- /**
3
- * A visitor who never signed in, shown somebody's session.
4
- *
5
- * A Medusa storefront's default session object carried a profile, so an anonymous first-time
6
- * visitor with no cookies was shown "Your account — Dana Reyes · 4 orders · Sign out". `walk` gives
7
- * every page a context with no cookies and no storage, which is what makes the reading mean
8
- * anything: whatever is on the page was rendered for somebody who is not signed in.
9
- *
10
- * What "signed in" LOOKS like is a repo's own vocabulary — a `data-` attribute, a menu, a word in a
11
- * language the kit does not know — so the probe refuses until it is told (D-031), by selector or by
12
- * text or both.
13
- */
14
- export declare const fakeSession: Probe;
1
+ export declare const fakeSession: import('../index.js').Probe;
@@ -2,8 +2,9 @@
2
2
  import { collect } from "../browser.js";
3
3
  import { stringsOption } from "../options.js";
4
4
  import { WalkError } from "../types.js";
5
+ import { defineProbe } from "./define.js";
5
6
  var escapeForRegex = (value) => value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
6
- var fakeSession = {
7
+ var fakeSession = defineProbe({
7
8
  class: "fake-session",
8
9
  id: "fake-session",
9
10
  needs: (options) => {
@@ -24,14 +25,12 @@ var fakeSession = {
24
25
  scope: ""
25
26
  });
26
27
  const bySelector = present.filter((hit) => hit.present).map((hit) => ({
27
- class: "fake-session",
28
28
  evidence: `a context nobody signed in to renders ${hit.selector}`,
29
29
  selector: hit.selector,
30
30
  severity: "blocking",
31
31
  url
32
32
  }));
33
33
  const byText = said.map((hit) => ({
34
- class: "fake-session",
35
34
  evidence: `a context nobody signed in to reads "${hit.text}"`,
36
35
  selector: hit.selector,
37
36
  severity: "blocking",
@@ -39,7 +38,7 @@ var fakeSession = {
39
38
  }));
40
39
  return [...bySelector, ...byText];
41
40
  }
42
- };
41
+ });
43
42
  export {
44
43
  fakeSession
45
44
  };
@@ -1,9 +1,5 @@
1
1
  import type { Probe } from '../types.js';
2
2
  export declare const PROBES: Probe[];
3
3
  export declare const probeById: (id: string) => Probe;
4
- /**
5
- * The probes a walk runs when nobody named any: the ones whose reading is a property of any page.
6
- * The other five need a repo's own list to mean anything (D-031) and would refuse the run, so a
7
- * default set that included them would make `geonosis-walk <url>` fail on every repo.
8
- */
4
+ /** The probes that need no option; the rest refuse the run without a repo's own list (D-031). */
9
5
  export declare const DEFAULT_PROBES: Probe[];
@@ -1,15 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * An element that declares its own surface, and is invisible on the one behind it.
4
- *
5
- * A Medusa storefront's t34 shipped a "cream" chip on a cream page and t22 a skeleton on paper;
6
- * both passed a screenshot review, because a JPEG of two colours a reader cannot tell apart looks
7
- * exactly like a JPEG of a surface that is there. The DOM tells the truth, so the probe reads
8
- * painted backgrounds and computes the WCAG ratio rather than looking at pixels.
9
- *
10
- * It only judges an element that is trying to be a distinct surface and is distinguished by nothing
11
- * else: an opaque background of its own, no background image, no border, no shadow, no outline, and
12
- * a box that does not simply repaint the one behind it. Every one of those exclusions is a shape a
13
- * designer used deliberately, and a probe that fired on them would be switched off within a week.
14
- */
15
- export declare const lightOnLight: Probe;
1
+ export declare const lightOnLight: import('../index.js').Probe;
@@ -1,7 +1,8 @@
1
1
  // src/probes/light-on-light.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { numberOption, stringOption, stringsOption } from "../options.js";
4
- var lightOnLight = {
4
+ import { defineProbe } from "./define.js";
5
+ var lightOnLight = defineProbe({
5
6
  class: "light-on-light",
6
7
  id: "light-on-light",
7
8
  run: async (page, { options, url }) => {
@@ -13,14 +14,13 @@ var lightOnLight = {
13
14
  selector: stringOption("light-on-light", options, "selector", "*")
14
15
  });
15
16
  return hits.map((hit) => ({
16
- class: "light-on-light",
17
17
  evidence: `${hit.background} on ${hit.container} (${hit.containerSelector}) — contrast ${hit.contrast.toFixed(2)}, floor ${minContrast}`,
18
18
  selector: hit.selector,
19
19
  severity: "major",
20
20
  url
21
21
  }));
22
22
  }
23
- };
23
+ });
24
24
  export {
25
25
  lightOnLight
26
26
  };
@@ -1,14 +1,2 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * Controls that go nowhere, and links that go somewhere gone.
4
- *
5
- * The dead half is a DOM read: an `href` that is absent, empty, `#` or `javascript:` is a control a
6
- * buyer will click and nothing will happen — a Medusa storefront shipped a kit default's "Looking
7
- * for a gift?" pointing at `#` on every category page. The broken half is a request: same-origin
8
- * links are HEAD-ed (GET when a server answers 405 or 501, which some do), and anything from 400 up
9
- * is a link that 404s in front of the buyer.
10
- *
11
- * Another origin is left alone unless asked for: a gate that fails because someone else's site was
12
- * down is a gate that gets disabled, and it would make the walk a crawler of the whole internet.
13
- */
14
- export declare const linkIntegrity: Probe;
1
+ /** Another origin is left alone unless asked: a gate that fails when someone else's site is down gets disabled. */
2
+ export declare const linkIntegrity: import('../index.js').Probe;
@@ -1,13 +1,16 @@
1
1
  // src/probes/link-integrity.ts
2
+ import { errorMessage } from "@geonosis/base";
2
3
  import { collect } from "../browser.js";
3
- import { flagOption, stringOption, stringsOption } from "../options.js";
4
+ import { assertPatterns, flagOption, stringOption, stringsOption } from "../options.js";
5
+ import { defineProbe } from "./define.js";
4
6
  var DEAD = ["", "#"];
5
- var linkIntegrity = {
7
+ var linkIntegrity = defineProbe({
6
8
  class: "link-integrity",
7
9
  id: "link-integrity",
8
- run: async (page, { memo, options, url }) => {
10
+ run: async (page, { headers, memo, options, url }) => {
9
11
  const dead = stringsOption(options, "deadHrefs", DEAD);
10
12
  const ignore = stringsOption(options, "ignore", []);
13
+ assertPatterns("link-integrity", ignore, "");
11
14
  const checkExternal = flagOption(options, "checkExternal", false);
12
15
  const origin = new URL(url).origin;
13
16
  const hits = await collect(page, {
@@ -19,7 +22,6 @@ var linkIntegrity = {
19
22
  const href = hit.href;
20
23
  if (href === null || dead.includes(href.trim()) || href.trim().startsWith("javascript:")) {
21
24
  found.push({
22
- class: "link-integrity",
23
25
  evidence: `dead control: href ${href === null ? "absent" : `"${href}"`} on "${hit.text}"`,
24
26
  selector: hit.selector,
25
27
  severity: "major",
@@ -34,12 +36,11 @@ var linkIntegrity = {
34
36
  continue;
35
37
  if (!checkExternal && new URL(target).origin !== origin)
36
38
  continue;
37
- const status = await statusOf(page, memo, target);
39
+ const status = await statusOf(page, memo, target, new URL(target).origin === origin ? headers : undefined);
38
40
  if (status < 400)
39
41
  continue;
40
42
  found.push({
41
- class: "link-integrity",
42
- evidence: `${target} answered ${status}`,
43
+ evidence: unreachable(memo, target) ?? `${target} answered ${status}`,
43
44
  selector: hit.selector,
44
45
  severity: "blocking",
45
46
  url
@@ -47,19 +48,25 @@ var linkIntegrity = {
47
48
  }
48
49
  return found;
49
50
  }
51
+ });
52
+ var unreachable = (memo, target) => {
53
+ const why = memo.get(`${statusKey(target)}:why`);
54
+ return typeof why === "string" ? `${target} could not be reached: ${why}` : undefined;
50
55
  };
51
- var statusOf = async (page, memo, target) => {
52
- const key = `link-integrity:${target}`;
56
+ var statusKey = (target) => `link-integrity:${target}`;
57
+ var statusOf = async (page, memo, target, headers) => {
58
+ const key = statusKey(target);
53
59
  const seen = memo.get(key);
54
60
  if (typeof seen === "number")
55
61
  return seen;
56
62
  let status;
57
63
  try {
58
- const head = await page.request.head(target, { failOnStatusCode: false });
59
- status = head.status() === 405 || head.status() === 501 ? (await page.request.get(target, { failOnStatusCode: false })).status() : head.status();
64
+ const options = { failOnStatusCode: false, ...headers === undefined ? {} : { headers } };
65
+ const head = await page.request.head(target, options);
66
+ status = head.status() === 405 || head.status() === 501 ? (await page.request.get(target, options)).status() : head.status();
60
67
  } catch (error) {
61
68
  status = 599;
62
- memo.set(`${key}:why`, error.message);
69
+ memo.set(`${key}:why`, errorMessage(error));
63
70
  }
64
71
  memo.set(key, status);
65
72
  return status;
@@ -1,14 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * A price on the page in a shape this repo does not write.
4
- *
5
- * `£24` beside `£24.00` is not a rendering bug and not a broken page; it is two answers to "what
6
- * does a price look like here", and the one a reader meets is whichever component happened to
7
- * format it. A currency that lost its minor units, a thousands separator that appears on one page
8
- * and not the next, a bare number where every other price carries a symbol.
9
- *
10
- * `accept` is REQUIRED (D-031): what a correct price looks like is a fact about a business, never
11
- * about a kit, and a probe that ran with no accepted shape would report a clean page for every repo
12
- * that had not configured it.
13
- */
14
- export declare const moneyFormat: Probe;
1
+ export declare const moneyFormat: import('../index.js').Probe;
@@ -1,9 +1,10 @@
1
1
  // src/probes/money-format.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
+ import { defineProbe } from "./define.js";
4
5
  var AMOUNT = String.raw`\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{1,2})?`;
5
6
  var MONEY = String.raw`[€$£¥₺]\s?${AMOUNT}|${AMOUNT}\s?(?:USD|EUR|GBP|TRY|JPY)\b`;
6
- var moneyFormat = {
7
+ var moneyFormat = defineProbe({
7
8
  class: "content-integrity",
8
9
  id: "money-format",
9
10
  needs: (options) => {
@@ -20,14 +21,13 @@ var moneyFormat = {
20
21
  scope: stringOption("money-format", options, "scope", "")
21
22
  });
22
23
  return hits.filter((hit) => !accept.some((one) => one.test(hit.text.trim()))).map((hit) => ({
23
- class: "content-integrity",
24
24
  evidence: `"${hit.text}" is money in a shape this repo does not accept`,
25
25
  selector: hit.selector,
26
26
  severity: "major",
27
27
  url
28
28
  }));
29
29
  }
30
- };
30
+ });
31
31
  export {
32
32
  moneyFormat
33
33
  };
@@ -1,13 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * The operations side, showing through into what a customer is offered.
4
- *
5
- * A Medusa storefront's checkout offered a US buyer of 5,000 mailer boxes four ocean-freight options — the
6
- * INBOUND freight the logistics side books, registered in the same seed as store-visible shipping.
7
- * The words that mean "internal" are a repo's own vocabulary, so `patterns` is required (D-031).
8
- *
9
- * `scope` is what separates this from a page-wide word hunt: the same words in a footnote about how
10
- * the company sources board are not a leak. The probe's own fixture pair is exactly that — the same
11
- * two phrases inside the delivery fieldset and outside it.
12
- */
13
- export declare const opsLeakage: Probe;
1
+ export declare const opsLeakage: import('../index.js').Probe;
@@ -1,29 +1,12 @@
1
1
  // src/probes/ops-leakage.ts
2
- import { collect } from "../browser.js";
3
- import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
- var opsLeakage = {
2
+ import { defineTextProbe } from "./text-probe.js";
3
+ var opsLeakage = defineTextProbe({
5
4
  class: "ops-leakage",
5
+ evidence: (hit) => `"${hit.text}" is offered to the customer, matching /${hit.pattern}/`,
6
6
  id: "ops-leakage",
7
- needs: (options) => {
8
- const patterns = requireStrings("ops-leakage", options, "patterns");
9
- assertPatterns("ops-leakage", patterns, patternFlags("ops-leakage", options));
10
- },
11
- run: async (page, { options, url }) => {
12
- const hits = await collect(page, {
13
- flags: patternFlags("ops-leakage", options),
14
- kind: "text",
15
- patterns: requireStrings("ops-leakage", options, "patterns"),
16
- scope: stringOption("ops-leakage", options, "scope", "")
17
- });
18
- return hits.map((hit) => ({
19
- class: "ops-leakage",
20
- evidence: `"${hit.text}" is offered to the customer, matching /${hit.pattern}/`,
21
- selector: hit.selector,
22
- severity: "blocking",
23
- url
24
- }));
25
- }
26
- };
7
+ option: "patterns",
8
+ severity: "blocking"
9
+ });
27
10
  export {
28
11
  opsLeakage
29
12
  };
@@ -1,13 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * A page the walk was told about that nothing on the walk links to.
4
- *
5
- * It answers 200, it renders, every per-page probe passes it — and the only way a reader reaches it
6
- * is by being handed the URL. That is not a fact any one page can know, which is why this is the
7
- * probe with a report-level half: `run` records what each page links to, and `finish` names the
8
- * walked URLs nothing pointed at.
9
- *
10
- * A page that is deliberately unlinked — a campaign landing page, a print view — goes in `entry`,
11
- * which is the repo's list and empty by default.
12
- */
13
- export declare const orphanUrl: Probe;
1
+ export declare const orphanUrl: import('../index.js').Probe;
@@ -1,6 +1,7 @@
1
1
  // src/probes/orphan-url.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { stringOption, stringsOption } from "../options.js";
4
+ import { defineProbe } from "./define.js";
4
5
  var MEMO = "orphan-url:linked";
5
6
  var linkedIn = (memo) => {
6
7
  const seen = memo.get(MEMO);
@@ -18,7 +19,7 @@ var bare = (url) => {
18
19
  return url;
19
20
  }
20
21
  };
21
- var orphanUrl = {
22
+ var orphanUrl = defineProbe({
22
23
  class: "content-integrity",
23
24
  finish: ({ memo, options, urls }) => {
24
25
  if (urls.length < 2)
@@ -26,7 +27,6 @@ var orphanUrl = {
26
27
  const linked = linkedIn(memo);
27
28
  const entry = stringsOption(options, "entry", []).map(bare);
28
29
  return urls.filter((url) => !linked.has(bare(url)) && !entry.includes(bare(url))).map((url) => ({
29
- class: "content-integrity",
30
30
  evidence: `no page in this walk links to ${bare(url)} — it is reachable only by being handed the URL`,
31
31
  severity: "major",
32
32
  url
@@ -48,7 +48,7 @@ var orphanUrl = {
48
48
  }
49
49
  return [];
50
50
  }
51
- };
51
+ });
52
52
  export {
53
53
  orphanUrl
54
54
  };
@@ -1,14 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * One mark in many slots, and marks whose own name says they are stand-ins.
4
- *
5
- * A Medusa storefront shipped ONE green-square SVG for thirteen content-icon keys and one stacked-shippers
6
- * photo for four of six category tiles. A screenshot showed thirteen shapes; the DOM showed one
7
- * repeated, which is what `new Set(signatures).size` is for. A signature is the resolved `src` of
8
- * an image or the geometry of an SVG's own shapes, so two files that draw the same thing under
9
- * different names still read as different marks, and one file under two names reads as one.
10
- *
11
- * `signatures` is the second half: patterns matched against the signature AND the element's
12
- * alt/aria-label/title, because the audit's own placeholder said "placeholder" in its label.
13
- */
14
- export declare const placeholderAsset: Probe;
1
+ export declare const placeholderAsset: import('../index.js').Probe;
@@ -1,7 +1,8 @@
1
1
  // src/probes/placeholder-asset.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { assertPatterns, numberOption, patternFlags, stringOption, stringsOption } from "../options.js";
4
- var placeholderAsset = {
4
+ import { defineProbe } from "./define.js";
5
+ var placeholderAsset = defineProbe({
5
6
  class: "placeholder-asset",
6
7
  id: "placeholder-asset",
7
8
  run: async (page, { options, url }) => {
@@ -15,7 +16,6 @@ var placeholderAsset = {
15
16
  scope: stringOption("placeholder-asset", options, "scope", "body")
16
17
  });
17
18
  const named = hits.filter((hit) => signatures.some((pattern) => new RegExp(pattern, flags).test(`${hit.signature} ${hit.label}`))).map((hit) => ({
18
- class: "placeholder-asset",
19
19
  evidence: `asset matches a placeholder signature: ${hit.signature.slice(0, 120)}`,
20
20
  selector: hit.selector,
21
21
  severity: "major",
@@ -26,7 +26,6 @@ var placeholderAsset = {
26
26
  bySignature.set(hit.signature, [...bySignature.get(hit.signature) ?? [], hit.selector]);
27
27
  }
28
28
  const repeated = [...bySignature.entries()].filter(([, selectors]) => selectors.length > maxRepeats).map(([signature, selectors]) => ({
29
- class: "placeholder-asset",
30
29
  evidence: `the same asset in ${selectors.length} slots, more than the ${maxRepeats} allowed — ${signature.slice(0, 120)}`,
31
30
  selector: selectors[0],
32
31
  severity: "major",
@@ -34,7 +33,7 @@ var placeholderAsset = {
34
33
  }));
35
34
  return [...named, ...repeated];
36
35
  }
37
- };
36
+ });
38
37
  export {
39
38
  placeholderAsset
40
39
  };
@@ -1,14 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * A page that offers to sell something the backend does not have.
4
- *
5
- * A Medusa storefront rendered full product pages with an Add to cart for three handles that were
6
- * in no live store: a buyer could configure `standard-mailer-box` and never place an order for it.
7
- * The page cannot know this on its own, so the authoritative set is required (D-031) — it comes
8
- * from the store's own API, the seed, or wherever the repo's truth actually lives.
9
- *
10
- * The affordance matters as much as the id: a retired handle that renders an explainer and no way
11
- * to buy is the FIX (a redirect stub), not the bug, and a probe that could not tell them apart
12
- * would fire on every correct retirement.
13
- */
14
- export declare const stubOnlyEntity: Probe;
1
+ export declare const stubOnlyEntity: import('../index.js').Probe;
@@ -1,7 +1,8 @@
1
1
  // src/probes/stub-only-entity.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { requireStrings, stringOption } from "../options.js";
4
- var stubOnlyEntity = {
4
+ import { defineProbe } from "./define.js";
5
+ var stubOnlyEntity = defineProbe({
5
6
  class: "stub-only-entity",
6
7
  id: "stub-only-entity",
7
8
  needs: (options) => {
@@ -17,14 +18,13 @@ var stubOnlyEntity = {
17
18
  selector: stringOption("stub-only-entity", options, "selector", `[${attribute}]`)
18
19
  });
19
20
  return hits.filter((hit) => hit.id !== "" && hit.affordance && !known.has(hit.id)).map((hit) => ({
20
- class: "stub-only-entity",
21
21
  evidence: `"${hit.id}" can be bought here and is in no authoritative set of ${known.size} entities`,
22
22
  selector: hit.selector,
23
23
  severity: "blocking",
24
24
  url
25
25
  }));
26
26
  }
27
- };
27
+ });
28
28
  export {
29
29
  stubOnlyEntity
30
30
  };
@@ -0,0 +1,12 @@
1
+ import { type TextHit } from '../browser.js';
2
+ import type { DefectClass, Probe, Severity } from '../types.js';
3
+ type TextProbeSpec = {
4
+ class: DefectClass;
5
+ evidence: (hit: TextHit, status: number) => string;
6
+ id: string;
7
+ option: string;
8
+ severity: Severity;
9
+ skip?: (options: Record<string, unknown>, status: number) => boolean;
10
+ };
11
+ export declare const defineTextProbe: ({ class: defect, evidence, id, option, severity, skip }: TextProbeSpec) => Probe;
12
+ export {};
@@ -0,0 +1,37 @@
1
+ // src/probes/text-probe.ts
2
+ import { collect } from "../browser.js";
3
+ import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
+ import { defineProbe } from "./define.js";
5
+ var defineTextProbe = ({
6
+ class: defect,
7
+ evidence,
8
+ id,
9
+ option,
10
+ severity,
11
+ skip
12
+ }) => defineProbe({
13
+ class: defect,
14
+ id,
15
+ needs: (options) => {
16
+ assertPatterns(id, requireStrings(id, options, option), patternFlags(id, options));
17
+ },
18
+ run: async (page, { options, status, url }) => {
19
+ if (skip?.(options, status))
20
+ return [];
21
+ const hits = await collect(page, {
22
+ flags: patternFlags(id, options),
23
+ kind: "text",
24
+ patterns: requireStrings(id, options, option),
25
+ scope: stringOption(id, options, "scope", "")
26
+ });
27
+ return hits.map((hit) => ({
28
+ evidence: evidence(hit, status),
29
+ selector: hit.selector,
30
+ severity,
31
+ url
32
+ }));
33
+ }
34
+ });
35
+ export {
36
+ defineTextProbe
37
+ };
@@ -1,14 +1 @@
1
- import type { Probe } from '../types.js';
2
- /**
3
- * A page that renders correctly and says almost nothing.
4
- *
5
- * The page is not broken: it has a heading, a layout, a 200. It has three sentences where a reader
6
- * came for an answer, and every gate in the stack reads it as fine — a screenshot looks like a
7
- * page, a link check passes, a status check passes. Only counting the words a reader is actually
8
- * shown says otherwise.
9
- *
10
- * `minWords` is REQUIRED (D-031), because how much a page owes a reader is a property of what the
11
- * page is for — a checkout step owes almost nothing, a guide owes a lot — and a floor the kit
12
- * picked would be somebody else's idea of thin applied to every repo that never chose one.
13
- */
14
- export declare const thinPage: Probe;
1
+ export declare const thinPage: import('../index.js').Probe;
@@ -1,7 +1,8 @@
1
1
  // src/probes/thin-page.ts
2
2
  import { collect } from "../browser.js";
3
3
  import { requireNumber, stringOption } from "../options.js";
4
- var thinPage = {
4
+ import { defineProbe } from "./define.js";
5
+ var thinPage = defineProbe({
5
6
  class: "content-integrity",
6
7
  id: "thin-page",
7
8
  needs: (options) => {
@@ -17,14 +18,13 @@ var thinPage = {
17
18
  selector: scope
18
19
  });
19
20
  return hits.filter((hit) => hit.words < minWords).map((hit) => ({
20
- class: "content-integrity",
21
21
  evidence: `${scope} renders ${hit.words} word(s), ${hit.headingWords} of them headings — the floor is ${minWords}`,
22
22
  ...hit.selector === "" ? {} : { selector: hit.selector },
23
23
  severity: "major",
24
24
  url
25
25
  }));
26
26
  }
27
- };
27
+ });
28
28
  export {
29
29
  thinPage
30
30
  };