@geonosis/walk 2.13.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/geonosis-walk.mjs +1 -1
  3. package/dist/browser.d.ts +124 -0
  4. package/dist/browser.js +242 -0
  5. package/dist/config.d.ts +16 -0
  6. package/dist/config.js +100 -0
  7. package/dist/index.d.ts +7 -153
  8. package/dist/index.js +5 -13
  9. package/dist/options.d.ts +19 -0
  10. package/dist/options.js +64 -0
  11. package/dist/probes/buy-box-above-fold.d.ts +14 -0
  12. package/dist/probes/buy-box-above-fold.js +54 -0
  13. package/dist/probes/empty-section.d.ts +16 -0
  14. package/dist/probes/empty-section.js +29 -0
  15. package/dist/probes/error-page-status.d.ts +20 -0
  16. package/dist/probes/error-page-status.js +37 -0
  17. package/dist/probes/fabricated-claim.d.ts +14 -0
  18. package/dist/probes/fabricated-claim.js +29 -0
  19. package/dist/probes/fake-session.d.ts +14 -0
  20. package/dist/probes/fake-session.js +45 -0
  21. package/dist/probes/index.d.ts +9 -0
  22. package/dist/probes/index.js +42 -0
  23. package/dist/probes/light-on-light.d.ts +15 -0
  24. package/dist/probes/light-on-light.js +26 -0
  25. package/dist/probes/link-integrity.d.ts +14 -0
  26. package/dist/probes/link-integrity.js +69 -0
  27. package/dist/probes/money-format.d.ts +14 -0
  28. package/dist/probes/money-format.js +33 -0
  29. package/dist/probes/ops-leakage.d.ts +13 -0
  30. package/dist/probes/ops-leakage.js +29 -0
  31. package/dist/probes/orphan-url.d.ts +13 -0
  32. package/dist/probes/orphan-url.js +54 -0
  33. package/dist/probes/placeholder-asset.d.ts +14 -0
  34. package/dist/probes/placeholder-asset.js +40 -0
  35. package/dist/probes/stub-only-entity.d.ts +14 -0
  36. package/dist/probes/stub-only-entity.js +30 -0
  37. package/dist/probes/thin-page.d.ts +14 -0
  38. package/dist/probes/thin-page.js +30 -0
  39. package/dist/types.d.ts +104 -0
  40. package/dist/types.js +10 -0
  41. package/dist/walk-cli.js +41 -47
  42. package/dist/walk.d.ts +23 -0
  43. package/dist/walk.js +93 -0
  44. package/package.json +5 -4
  45. package/dist/chunk-VCGYSFL5.js +0 -956
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @geonosis/walk
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 1e38e4e: `geonosis-themekit`, `geonosis-rails` and `geonosis-evals` read their arguments with `node:util`'s `parseArgs`. A flag one does not know is refused by name, exit 2, where the hand-written readers ignored it and ran without it; a flag given twice keeps its last value in all three (evals kept the first). `geonosis-evals compare --tolerance x=0.1 a.json b.json` reads `a.json` and `b.json` as the scores: the old reader took the tolerance's value for the first score file. `geonosis-ratchet` and `geonosis-verify`, which already refused what they did not know, read their flags the same way; verify still refuses a flag that belongs to another of its commands. `geonosis-doctor` reads its flags with `parseArgs` too, its optional `--baseline-against` ref through the parser's tokens. `@geonosis/ledger`'s exported `parseArgs(argv, valued, switches)` is `node:util`'s underneath and takes the switches it accepts, refusing an undeclared one and a valued flag followed by another flag (`--note --plan 3` used to store `--plan` as the note); `rejectUnknownSwitches` is gone. `geonosis-walk`, `geonosis-review` and `geonosis-lint-parity` parse the same way; parity keeps its own words for a bare `--corpus` or `--expect-changed`. `geonosis-observability`, `geonosis-verify-arch`, `geonosis-testbed` and `geonosis-visual-diff` follow; the last two used to accept a flag they did not know (testbed ignored it, visual-diff read it as a switch) and now refuse it. `@geonosis/release`'s exported `parseArgs` keeps its `Parsed` shape over `node:util`'s. `@geonosis/cli`'s `parseArgv` and `create-geonosis`'s `parseArgs` are built on it too, keeping their own refusals; `parseArgv` now refuses a valued flag followed by another flag instead of taking that flag as its value.
8
+
3
9
  ## 2.13.0
4
10
 
5
11
  ## 2.12.0
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
  // Generated by pnpm generate:shims. In the kit's own tree src/ sits beside dist/, and a dist older
3
3
  // than src once answered for a fix it did not carry (#62); a published package ships no src/.
4
4
  import { existsSync } from 'node:fs'
@@ -0,0 +1,124 @@
1
+ import type { Page } from 'playwright';
2
+ /**
3
+ * The browser's own globals, declared here rather than by adding `"lib": ["DOM"]`.
4
+ *
5
+ * The repo typechecks eleven packages against one `tsconfig.base.json`; turning the DOM on for all
6
+ * of them so that this one file can say `document` would put `fetch`, `Response` and `Request` into
7
+ * ten Node packages that have their own. So the surface these probes actually read is written out,
8
+ * module-locally — it leaks into nothing, and it is a list of exactly what the walk touches.
9
+ */
10
+ type DomRect = {
11
+ height: number;
12
+ left: number;
13
+ top: number;
14
+ width: number;
15
+ };
16
+ export type ContrastHit = {
17
+ background: string;
18
+ container: string;
19
+ containerSelector: string;
20
+ contrast: number;
21
+ selector: string;
22
+ };
23
+ export type AssetHit = {
24
+ label: string;
25
+ selector: string;
26
+ signature: string;
27
+ };
28
+ export type LinkHit = {
29
+ href: null | string;
30
+ resolved: string;
31
+ selector: string;
32
+ text: string;
33
+ };
34
+ export type TextHit = {
35
+ pattern: string;
36
+ selector: string;
37
+ text: string;
38
+ };
39
+ export type EntityHit = {
40
+ affordance: boolean;
41
+ id: string;
42
+ selector: string;
43
+ };
44
+ export type PresentHit = {
45
+ present: boolean;
46
+ selector: string;
47
+ };
48
+ export type GeometryHit = {
49
+ rect: DomRect | null;
50
+ selector: string;
51
+ };
52
+ /**
53
+ * How much a container actually says, counted after layout: the words a reader is shown, how many
54
+ * of them are its own headings, and how many pieces of media stand in for the rest. A section with
55
+ * a heading and nothing under it renders perfectly and tells nobody anything.
56
+ */
57
+ export type ProseHit = {
58
+ headingWords: number;
59
+ media: number;
60
+ selector: string;
61
+ words: number;
62
+ };
63
+ export type Job = {
64
+ assetSelector: string;
65
+ kind: 'assets';
66
+ scope: string;
67
+ } | {
68
+ affordance: string;
69
+ attribute: string;
70
+ kind: 'entities';
71
+ selector: string;
72
+ } | {
73
+ flags: string;
74
+ kind: 'text';
75
+ patterns: string[];
76
+ scope: string;
77
+ } | {
78
+ kind: 'contrast';
79
+ ignore: string[];
80
+ minContrast: number;
81
+ selector: string;
82
+ } | {
83
+ kind: 'geometry';
84
+ selectors: string[];
85
+ } | {
86
+ kind: 'links';
87
+ selector: string;
88
+ } | {
89
+ kind: 'present';
90
+ selectors: string[];
91
+ } | {
92
+ headingSelector: string;
93
+ kind: 'prose';
94
+ mediaSelector: string;
95
+ selector: string;
96
+ } | {
97
+ flags: string;
98
+ kind: 'matches';
99
+ patterns: string[];
100
+ scope: string;
101
+ };
102
+ export type JobResult = {
103
+ assets: AssetHit[];
104
+ contrast: ContrastHit[];
105
+ entities: EntityHit[];
106
+ geometry: {
107
+ rects: GeometryHit[];
108
+ viewportHeight: number;
109
+ };
110
+ links: LinkHit[];
111
+ matches: TextHit[];
112
+ present: PresentHit[];
113
+ prose: ProseHit[];
114
+ text: TextHit[];
115
+ };
116
+ /**
117
+ * The one cast in the package. `page.evaluate` runs `inPage` in another VM, so nothing about the
118
+ * value that comes back is checkable from here — the discriminant is the contract, and it is
119
+ * covered by the probe tests that read each shape through a real browser.
120
+ */
121
+ export declare const collect: <K extends Job['kind']>(page: Page, job: Extract<Job, {
122
+ kind: K;
123
+ }>) => Promise<JobResult[K]>;
124
+ export {};
@@ -0,0 +1,242 @@
1
+ // src/browser.ts
2
+ var inPage = (job) => {
3
+ const dom = {
4
+ deepest: (root, needle) => {
5
+ let node = root;
6
+ let moved = true;
7
+ while (moved) {
8
+ moved = false;
9
+ for (const child of node.children) {
10
+ if (dom.textOf(child).includes(needle)) {
11
+ node = child;
12
+ moved = true;
13
+ break;
14
+ }
15
+ }
16
+ }
17
+ return node;
18
+ },
19
+ rectOf: (element) => {
20
+ const box = element.getBoundingClientRect();
21
+ return { height: box.height, left: box.left, top: box.top, width: box.width };
22
+ },
23
+ selectorOf: (element) => {
24
+ if (element.id !== "")
25
+ return `#${element.id}`;
26
+ const testId = element.getAttribute("data-testid");
27
+ if (testId !== null && testId !== "")
28
+ return `[data-testid="${testId}"]`;
29
+ const parts = [];
30
+ let node = element;
31
+ while (node !== null && parts.length < 5 && node.tagName !== "BODY") {
32
+ const parent = node.parentElement;
33
+ if (parent === null)
34
+ break;
35
+ const current = node;
36
+ const siblings = [...parent.children].filter((one) => one.tagName === current.tagName);
37
+ const nth = siblings.indexOf(current) + 1;
38
+ const tag = current.tagName.toLowerCase();
39
+ parts.unshift(siblings.length > 1 ? `${tag}:nth-of-type(${nth})` : tag);
40
+ node = parent;
41
+ }
42
+ return parts.join(" > ");
43
+ },
44
+ shown: (element) => {
45
+ const box = element.getBoundingClientRect();
46
+ return box.width > 0 && box.height > 0 && getComputedStyle(element).visibility !== "hidden";
47
+ },
48
+ textOf: (element) => element.innerText ?? element.textContent ?? "",
49
+ wordsIn: (text) => text.split(/\s+/).filter((one) => one !== "").length
50
+ };
51
+ if (job.kind === "contrast") {
52
+ const rgb = {
53
+ bordered: (style) => style.borderStyle !== "none" && [
54
+ style.borderTopWidth,
55
+ style.borderRightWidth,
56
+ style.borderBottomWidth,
57
+ style.borderLeftWidth
58
+ ].some((width) => Number.parseFloat(width) > 0),
59
+ channel: (value) => value / 255 <= 0.03928 ? value / 255 / 12.92 : ((value / 255 + 0.055) / 1.055) ** 2.4,
60
+ luminance: ({ b, g, r }) => 0.2126 * rgb.channel(r) + 0.7152 * rgb.channel(g) + 0.0722 * rgb.channel(b),
61
+ parse: (value) => {
62
+ const inside = /rgba?\(([^)]+)\)/.exec(value)?.[1];
63
+ if (inside === undefined)
64
+ return null;
65
+ const numbers = inside.split(/[,\s/]+/).filter((one) => one !== "").map(Number);
66
+ const [r, g, b, a] = numbers;
67
+ if (r === undefined || g === undefined || b === undefined)
68
+ return null;
69
+ return { a: a ?? 1, b, g, r };
70
+ },
71
+ ratio: (one, other) => {
72
+ const first = rgb.luminance(one);
73
+ const second = rgb.luminance(other);
74
+ return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
75
+ }
76
+ };
77
+ const hits = [];
78
+ const white = { a: 1, b: 255, g: 255, r: 255 };
79
+ for (const element of document.querySelectorAll(job.selector)) {
80
+ const tag = element.tagName;
81
+ if (tag === "HTML" || tag === "BODY")
82
+ continue;
83
+ if (job.ignore.some((one) => element.matches(one)))
84
+ continue;
85
+ const style = getComputedStyle(element);
86
+ const own = rgb.parse(style.backgroundColor);
87
+ if (own === null || own.a !== 1)
88
+ continue;
89
+ if (style.backgroundImage !== "none" || style.boxShadow !== "none")
90
+ continue;
91
+ if (style.outlineStyle !== "none" || rgb.bordered(style))
92
+ continue;
93
+ if (!dom.shown(element))
94
+ continue;
95
+ const box = element.getBoundingClientRect();
96
+ let node = element.parentElement;
97
+ let behind = null;
98
+ let fullBleed = false;
99
+ let behindSelector = "the canvas";
100
+ let behindValue = "rgb(255, 255, 255)";
101
+ while (node !== null) {
102
+ const parentStyle = getComputedStyle(node);
103
+ const colour = rgb.parse(parentStyle.backgroundColor);
104
+ if (colour !== null && colour.a === 1) {
105
+ const parentBox = node.getBoundingClientRect();
106
+ fullBleed = parentBox.width <= box.width && parentBox.height <= box.height;
107
+ behind = colour;
108
+ behindSelector = node.tagName === "BODY" ? "body" : dom.selectorOf(node);
109
+ behindValue = parentStyle.backgroundColor;
110
+ break;
111
+ }
112
+ node = node.parentElement;
113
+ }
114
+ if (fullBleed)
115
+ continue;
116
+ const contrast = rgb.ratio(own, behind ?? white);
117
+ if (contrast >= job.minContrast)
118
+ continue;
119
+ hits.push({
120
+ background: style.backgroundColor,
121
+ container: behindValue,
122
+ containerSelector: behindSelector,
123
+ contrast: Math.round(contrast * 100) / 100,
124
+ selector: dom.selectorOf(element)
125
+ });
126
+ }
127
+ return hits;
128
+ }
129
+ if (job.kind === "assets") {
130
+ const geometry = ["d", "points", "cx", "cy", "r", "x", "y", "x1", "y1", "x2", "y2", "href"];
131
+ const scope = document.querySelector(job.scope) ?? document.body;
132
+ const hits = [];
133
+ for (const element of scope.querySelectorAll(job.assetSelector)) {
134
+ if (!dom.shown(element))
135
+ continue;
136
+ const tag = element.tagName.toLowerCase();
137
+ const signature = tag === "img" ? `src:${element.src ?? element.getAttribute("src") ?? ""}` : `svg:${[
138
+ ...element.querySelectorAll("path,circle,rect,ellipse,line,polygon,polyline,use")
139
+ ].map((shape) => `${shape.tagName.toLowerCase()}(${geometry.map((name) => shape.getAttribute(name) ?? "").join(",")})`).join("|")}`;
140
+ hits.push({
141
+ label: [
142
+ element.getAttribute("alt") ?? "",
143
+ element.getAttribute("aria-label") ?? "",
144
+ element.getAttribute("title") ?? ""
145
+ ].filter((one) => one !== "").join(" "),
146
+ selector: dom.selectorOf(element),
147
+ signature
148
+ });
149
+ }
150
+ return hits;
151
+ }
152
+ if (job.kind === "links") {
153
+ return [...document.querySelectorAll(job.selector)].map((element) => ({
154
+ href: element.getAttribute("href"),
155
+ resolved: element.href ?? "",
156
+ selector: dom.selectorOf(element),
157
+ text: dom.textOf(element).trim().slice(0, 80)
158
+ }));
159
+ }
160
+ if (job.kind === "text") {
161
+ const roots = job.scope === "" ? [document.body] : [...document.querySelectorAll(job.scope)];
162
+ const hits = [];
163
+ for (const root of roots) {
164
+ const text = dom.textOf(root);
165
+ for (const pattern of job.patterns) {
166
+ const matcher = new RegExp(pattern, `${job.flags}g`);
167
+ let found = matcher.exec(text);
168
+ while (found !== null) {
169
+ const matched = found[0];
170
+ if (matched === "")
171
+ break;
172
+ hits.push({
173
+ pattern,
174
+ selector: dom.selectorOf(dom.deepest(root, matched)),
175
+ text: matched
176
+ });
177
+ found = matcher.exec(text);
178
+ }
179
+ }
180
+ }
181
+ return hits;
182
+ }
183
+ if (job.kind === "entities") {
184
+ return [...document.querySelectorAll(job.selector)].map((element) => ({
185
+ affordance: job.affordance === "" || element.querySelector(job.affordance) !== null,
186
+ id: element.getAttribute(job.attribute) ?? "",
187
+ selector: dom.selectorOf(element)
188
+ }));
189
+ }
190
+ if (job.kind === "matches") {
191
+ const scope = job.scope === "" ? document.body : document.querySelector(job.scope);
192
+ const hits = [];
193
+ if (scope === null)
194
+ return hits;
195
+ const walker = document.createTreeWalker(scope, 4);
196
+ let node = walker.nextNode();
197
+ while (node !== null) {
198
+ const parent = node.parentElement;
199
+ const text = node.nodeValue ?? "";
200
+ if (parent !== null && text.trim() !== "" && dom.shown(parent)) {
201
+ for (const pattern of job.patterns) {
202
+ const matcher = new RegExp(pattern, `${job.flags}g`);
203
+ let found = matcher.exec(text);
204
+ while (found !== null) {
205
+ const matched = found[0];
206
+ if (matched === "")
207
+ break;
208
+ hits.push({ pattern, selector: dom.selectorOf(parent), text: matched });
209
+ found = matcher.exec(text);
210
+ }
211
+ }
212
+ }
213
+ node = walker.nextNode();
214
+ }
215
+ return hits;
216
+ }
217
+ if (job.kind === "prose") {
218
+ return [...document.querySelectorAll(job.selector)].filter((element) => dom.shown(element)).map((element) => ({
219
+ headingWords: [...element.querySelectorAll(job.headingSelector)].filter((heading) => dom.shown(heading)).reduce((total, heading) => total + dom.wordsIn(dom.textOf(heading)), 0),
220
+ media: [...element.querySelectorAll(job.mediaSelector)].filter((one) => dom.shown(one)).length,
221
+ selector: dom.selectorOf(element),
222
+ words: dom.wordsIn(dom.textOf(element))
223
+ }));
224
+ }
225
+ if (job.kind === "present") {
226
+ return job.selectors.map((selector) => ({
227
+ present: document.querySelector(selector) !== null,
228
+ selector
229
+ }));
230
+ }
231
+ return {
232
+ rects: job.selectors.map((selector) => {
233
+ const element = document.querySelector(selector);
234
+ return { rect: element === null ? null : dom.rectOf(element), selector };
235
+ }),
236
+ viewportHeight: innerHeight
237
+ };
238
+ };
239
+ var collect = async (page, job) => await page.evaluate(inPage, job);
240
+ export {
241
+ collect
242
+ };
@@ -0,0 +1,16 @@
1
+ import type { Viewport } from './types.js';
2
+ export type WalkConfig = {
3
+ options: Record<string, Record<string, unknown>>;
4
+ probes: string[];
5
+ report: string;
6
+ urls: string[];
7
+ viewport: Viewport;
8
+ };
9
+ export declare const WALK_REPORT = ".geonosis/walk-report.json";
10
+ export declare const WALK_DEFAULT: WalkConfig;
11
+ export declare const configShape: () => string;
12
+ /** `WxH`, the shape a viewport is written in everywhere else — 1440x900, 390x844. */
13
+ export declare const parseViewport: (value: string) => Viewport;
14
+ /** The `walk` block of `geonosis.json`, every key optional, every default a contract. */
15
+ export declare const loadWalkConfig: (file: string) => WalkConfig;
16
+ export declare const configPath: (cwd: string, given?: string) => string;
package/dist/config.js ADDED
@@ -0,0 +1,100 @@
1
+ // src/config.ts
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { DEFAULT_PROBES } from "./probes/index.js";
5
+ import { WalkError } from "./types.js";
6
+ var VIEWPORT = { height: 900, width: 1440 };
7
+ var WALK_REPORT = ".geonosis/walk-report.json";
8
+ var WALK_DEFAULT = {
9
+ options: {},
10
+ probes: DEFAULT_PROBES.map((one) => one.id),
11
+ report: WALK_REPORT,
12
+ urls: [],
13
+ viewport: VIEWPORT
14
+ };
15
+ var KNOWN = new Set(["options", "probes", "report", "urls", "viewport"]);
16
+ var ABOUT = {
17
+ options: "object? keyed by probe id; each probe validates its own",
18
+ probes: "string[]? the probe ids to run",
19
+ report: "string? where the JSON report is written",
20
+ urls: "string[]? the pages to walk",
21
+ viewport: 'object? { "width": <number>, "height": <number> }'
22
+ };
23
+ var configShape = () => [
24
+ "geonosis-walk reads geonosis.json",
25
+ "",
26
+ 'geonosis.json → "walk" every key optional, every default a contract',
27
+ ...[...KNOWN].toSorted().map((key) => ` ${key.padEnd(11)}${ABOUT[key] ?? ""}`),
28
+ "",
29
+ "A key outside this list is REFUSED by name: a misspelling accepted in silence is a probe nobody",
30
+ "is running against a page nobody is walking."
31
+ ].join(`
32
+ `);
33
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
34
+ var readViewport = (value) => {
35
+ if (value === undefined)
36
+ return VIEWPORT;
37
+ if (!isRecord(value) || typeof value.height !== "number" || typeof value.width !== "number") {
38
+ throw new WalkError('walk.viewport must be { "width": <number>, "height": <number> }');
39
+ }
40
+ return { height: value.height, width: value.width };
41
+ };
42
+ var parseViewport = (value) => {
43
+ const found = /^(\d+)x(\d+)$/.exec(value.trim());
44
+ if (found?.[1] === undefined || found[2] === undefined) {
45
+ throw new WalkError(`"${value}" is not a viewport — write it as WIDTHxHEIGHT, e.g. 390x844`);
46
+ }
47
+ return { height: Number(found[2]), width: Number(found[1]) };
48
+ };
49
+ var readStrings = (value, name, fallback) => {
50
+ if (value === undefined)
51
+ return fallback;
52
+ if (!Array.isArray(value) || value.some((one) => typeof one !== "string")) {
53
+ throw new WalkError(`walk.${name} must be a list of strings`);
54
+ }
55
+ return value;
56
+ };
57
+ var loadWalkConfig = (file) => {
58
+ if (!existsSync(file))
59
+ return WALK_DEFAULT;
60
+ let parsed;
61
+ try {
62
+ parsed = JSON.parse(readFileSync(file, "utf8"));
63
+ } catch (error) {
64
+ throw new WalkError(`${file} is not valid JSON: ${error.message}`);
65
+ }
66
+ if (!isRecord(parsed))
67
+ throw new WalkError(`${file} must hold an object`);
68
+ const block = parsed.walk;
69
+ if (block === undefined)
70
+ return WALK_DEFAULT;
71
+ if (!isRecord(block))
72
+ throw new WalkError("walk must be an object");
73
+ for (const key of Object.keys(block)) {
74
+ if (!KNOWN.has(key))
75
+ throw new WalkError(`walk.${key} is not a key of the walk block`);
76
+ }
77
+ const options = block.options ?? {};
78
+ if (!isRecord(options))
79
+ throw new WalkError("walk.options must be an object keyed by probe id");
80
+ for (const [id, one] of Object.entries(options)) {
81
+ if (!isRecord(one))
82
+ throw new WalkError(`walk.options.${id} must be an object`);
83
+ }
84
+ return {
85
+ options,
86
+ probes: readStrings(block.probes, "probes", WALK_DEFAULT.probes),
87
+ report: typeof block.report === "string" ? block.report : WALK_REPORT,
88
+ urls: readStrings(block.urls, "urls", []),
89
+ viewport: readViewport(block.viewport)
90
+ };
91
+ };
92
+ var configPath = (cwd, given) => resolve(cwd, given ?? "geonosis.json");
93
+ export {
94
+ WALK_DEFAULT,
95
+ WALK_REPORT,
96
+ configPath,
97
+ configShape,
98
+ loadWalkConfig,
99
+ parseViewport
100
+ };
package/dist/index.d.ts CHANGED
@@ -1,153 +1,7 @@
1
- import { Page, Browser } from 'playwright';
2
-
3
- /**
4
- * The ten defect classes the walk is mechanical about.
5
- *
6
- * Six are a storefront CX audit's own groups, generalised; `light-on-light` is that audit's
7
- * browser-proof probe (a cream chip on a cream page reads as broken, and the screenshot says it is
8
- * fine), `buy-box-above-fold` is one of its groups promoted to a class, and `error-page-status`
9
- * came from an error surface served with a 200, which every health check read as healthy.
10
- * `content-integrity` is the tenth: a page that renders correctly and says nothing — a section with
11
- * a heading and no body, a price in a shape the repo does not write, a page nothing links to. Four
12
- * of an audit's own defects were filed under `fabricated-claim`'s forbidden-string engine for want
13
- * of it, which is a class borrowing another class's mechanism. What the ten do NOT cover — a number that disagrees with a number on another page, copy
14
- * that promises a control nobody built, four levels of taxonomy for fourteen products — is in
15
- * `docs/walk-review-inventory-2026-08-30.md`, and stays the walker's judgement. A green walk report
16
- * is not a clean surface.
17
- */
18
- type DefectClass = 'buy-box-above-fold' | 'content-integrity' | 'error-page-status' | 'fabricated-claim' | 'fake-session' | 'light-on-light' | 'link-integrity' | 'ops-leakage' | 'placeholder-asset' | 'stub-only-entity';
19
- /** `blocking` breaks trust or the buy path; `major` confuses the buyer; `minor` is polish. */
20
- type Severity = 'blocking' | 'major' | 'minor';
21
- /**
22
- * One defect, as the build plan's contract states it. `evidence` is the measured value — the two
23
- * colours and the ratio, the status code, the matched text — never a restatement of the class,
24
- * because the reader's next question is always "what did you actually see".
25
- */
26
- type Finding = {
27
- class: DefectClass;
28
- evidence: string;
29
- selector?: string;
30
- severity: Severity;
31
- url: string;
32
- };
33
- type Viewport = {
34
- height: number;
35
- width: number;
36
- };
37
- type ProbeContext = {
38
- /**
39
- * One walk, one memo. `link-integrity` would otherwise send a HEAD request for the same footer
40
- * link once per page, which is forty requests for one answer on a forty-page walk.
41
- */
42
- memo: Map<string, unknown>;
43
- /** This probe's own block of the `options` map, already narrowed by id. */
44
- options: Record<string, unknown>;
45
- /**
46
- * The status the page's OWN response carried. Read from `page.goto`, because nothing on a loaded
47
- * page remembers it and a second request for it would ask a different question of a server that
48
- * may not answer twice the same way.
49
- */
50
- status: number;
51
- url: string;
52
- viewport: Viewport;
53
- };
54
- type Probe = {
55
- class: DefectClass;
56
- id: string;
57
- /**
58
- * D-031, per probe: a probe that cannot mean anything without an option refuses the run when it
59
- * is missing, naming the option. Five of the eight have one — a claim list, an authoritative id
60
- * set, what "signed in" looks like, the operations patterns, the buy-box selector — because none
61
- * of those five can have a default that is true of a repo that has not configured it. A probe
62
- * that ran and reported nothing because nobody told it what to look for is indistinguishable
63
- * from a clean page.
64
- */
65
- needs?: (options: Record<string, unknown>) => void;
66
- run: (page: Page, context: ProbeContext) => Promise<Finding[]>;
67
- /**
68
- * The reading no single page can make. `orphan-url` is the reason it exists: whether anything
69
- * links to a page is a fact about the whole walk, and a probe handed one page at a time can only
70
- * record what it saw. Called once, after every page, with the pages walked; each finding is filed
71
- * against the page whose `url` it names.
72
- */
73
- finish?: (context: FinishContext) => Finding[];
74
- };
75
- /** What a probe knows once the walk is over: its own memo, its options, and where it went. */
76
- type FinishContext = {
77
- memo: Map<string, unknown>;
78
- options: Record<string, unknown>;
79
- urls: string[];
80
- };
81
- type PageReport = {
82
- findings: Finding[];
83
- url: string;
84
- };
85
- type WalkReport = {
86
- /**
87
- * Keyed by the classes that RAN. A zero therefore means "probed for, none found"; a class that is
88
- * absent was never looked for. All eight keys with five zeros would read as five clean gates
89
- * nobody enabled.
90
- */
91
- counts: Partial<Record<DefectClass, number>>;
92
- finishedAt: string;
93
- pages: PageReport[];
94
- probes: string[];
95
- startedAt: string;
96
- viewport: Viewport;
97
- };
98
- /**
99
- * The walk could not run: no browser, no URL, a page that did not answer, a probe with no option it
100
- * needs. Distinct from "the walk ran and found nothing", which is a report with zeros in it — the
101
- * CLI turns this into exit 2 and that into exit 0.
102
- */
103
- declare class WalkError extends Error {
104
- constructor(message: string);
105
- }
106
-
107
- type WalkConfig = {
108
- options: Record<string, Record<string, unknown>>;
109
- probes: string[];
110
- report: string;
111
- urls: string[];
112
- viewport: Viewport;
113
- };
114
- declare const WALK_REPORT = ".geonosis/walk-report.json";
115
- declare const WALK_DEFAULT: WalkConfig;
116
- /** `WxH`, the shape a viewport is written in everywhere else — 1440x900, 390x844. */
117
- declare const parseViewport: (value: string) => Viewport;
118
- /** The `walk` block of `geonosis.json`, every key optional, every default a contract. */
119
- declare const loadWalkConfig: (file: string) => WalkConfig;
120
- declare const configPath: (cwd: string, given?: string) => string;
121
-
122
- declare const PROBES: Probe[];
123
- declare const probeById: (id: string) => Probe;
124
- /**
125
- * The probes a walk runs when nobody named any: the ones whose reading is a property of any page.
126
- * The other five need a repo's own list to mean anything (D-031) and would refuse the run, so a
127
- * default set that included them would make `geonosis-walk <url>` fail on every repo.
128
- */
129
- declare const DEFAULT_PROBES: Probe[];
130
-
131
- type WalkInput = {
132
- /** An already-open browser, for a walker driving a flow. Absent means launch one and close it. */
133
- browser?: Browser;
134
- /** Each probe's options, keyed by probe id. */
135
- options?: Record<string, Record<string, unknown>>;
136
- probes: Probe[];
137
- urls: string[];
138
- viewport: Viewport;
139
- };
140
- /**
141
- * Every URL, every probe, one report.
142
- *
143
- * Each page gets its OWN context, with no cookies and no storage. That is what makes `fake-session`
144
- * mean anything, and it is why `walk` is the stateless surface: a walker that has to reach a
145
- * checkout with a cart in it drives its own page and calls `probe.run(page, context)` directly.
146
- *
147
- * Refusals come BEFORE the browser opens, and a page that did not answer stops the walk. A report
148
- * with no findings in it must only ever mean the probes looked and found none.
149
- */
150
- declare const walk: ({ browser, options, probes, urls, viewport }: WalkInput) => Promise<WalkReport>;
151
- declare const findingsIn: (report: WalkReport) => number;
152
-
153
- export { DEFAULT_PROBES, type DefectClass, type Finding, PROBES, type PageReport, type Probe, type ProbeContext, type Severity, type Viewport, WALK_DEFAULT, WALK_REPORT, type WalkConfig, WalkError, type WalkInput, type WalkReport, configPath, findingsIn, loadWalkConfig, parseViewport, probeById, walk };
1
+ export type { WalkConfig } from './config.js';
2
+ export { configPath, loadWalkConfig, parseViewport, WALK_DEFAULT, WALK_REPORT } from './config.js';
3
+ export { DEFAULT_PROBES, PROBES, probeById } from './probes/index.js';
4
+ export type { DefectClass, Finding, PageReport, Probe, ProbeContext, Severity, Viewport, WalkReport } from './types.js';
5
+ export { WalkError } from './types.js';
6
+ export type { WalkInput } from './walk.js';
7
+ export { findingsIn, walk } from './walk.js';
package/dist/index.js CHANGED
@@ -1,16 +1,8 @@
1
- import {
2
- DEFAULT_PROBES,
3
- PROBES,
4
- WALK_DEFAULT,
5
- WALK_REPORT,
6
- WalkError,
7
- configPath,
8
- findingsIn,
9
- loadWalkConfig,
10
- parseViewport,
11
- probeById,
12
- walk
13
- } from "./chunk-VCGYSFL5.js";
1
+ // src/index.ts
2
+ import { configPath, loadWalkConfig, parseViewport, WALK_DEFAULT, WALK_REPORT } from "./config.js";
3
+ import { DEFAULT_PROBES, PROBES, probeById } from "./probes/index.js";
4
+ import { WalkError } from "./types.js";
5
+ import { findingsIn, walk } from "./walk.js";
14
6
  export {
15
7
  DEFAULT_PROBES,
16
8
  PROBES,